MythTV  master
Public Slots | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes | Friends | List of all members
MythContextPrivate Class Reference
Inheritance diagram for MythContextPrivate:
Inheritance graph
[legend]
Collaboration diagram for MythContextPrivate:
Collaboration graph
[legend]

Public Slots

void OnCloseDialog ()
 

Public Member Functions

 MythContextPrivate (MythContext *lparent)
 
 ~MythContextPrivate () override
 
bool Init (bool gui, bool promptForBackend, bool disableAutoDiscovery, bool ignoreDB)
 
bool FindDatabase (bool prompt, bool noAutodetect)
 Get database connection settings and test connectivity. More...
 
void TempMainWindow (bool languagePrompt=true)
 Setup a minimal themed main window, and prompt for user's language. More...
 
void EndTempWindow (void)
 
bool LoadDatabaseSettings (void)
 Load database and host settings from XmlConfiguration::k_default_filename, or set some defaults. More...
 
bool SaveDatabaseParams (const DatabaseParams &params, bool force)
 
bool PromptForDatabaseParams (const QString &error)
 
QString TestDBconnection (bool prompt=true)
 Some quick sanity checks before opening a database connection. More...
 
void SilenceDBerrors (void)
 Cause MSqlDatabase::OpenDatabase() and MSqlQuery to fail silently. More...
 
void EnableDBerrors (void)
 
void ResetDatabase (void) const
 Called when the user changes the DB connection settings. More...
 
BackendSelection::Decision ChooseBackend (const QString &error)
 Search for backends via UPnP, put up a UI for the user to choose one. More...
 
int UPnPautoconf (std::chrono::milliseconds milliSeconds=2s)
 If there is only a single UPnP backend, use it. More...
 
bool DefaultUPnP (QString &Error)
 Get the default backend from XmlConfiguration::kDefaultFilename, use UPnP to find it. More...
 
bool UPnPconnect (const DeviceLocation *backend, const QString &PIN)
 Query a backend via UPnP for its database connection parameters. More...
 
void ShowGuiStartup (void)
 
bool checkPort (QString &host, int port, std::chrono::seconds timeLimit) const
 Check if a port is open and sort out the link-local scope. More...
 

Static Public Member Functions

static void processEvents (void)
 

Public Attributes

MythContextm_parent {nullptr}
 
bool m_gui {false}
 Should this context use GUI elements? More...
 
QString m_masterhostname
 master backend hostname More...
 
DatabaseParams m_dbParams
 Current database host & WOL details. More...
 
QString m_dbHostCp
 dbHostName backup More...
 
bool m_disableeventpopup {false}
 
MythUIHelperm_ui {nullptr}
 
MythContextSlotHandlerm_sh {nullptr}
 
GUIStartupm_guiStartup {nullptr}
 
QEventLoop * m_loop {nullptr}
 
bool m_needsBackend {false}
 
GUISettingsCache m_GUISettingsCache
 

Protected Member Functions

bool event (QEvent *) override
 
void ShowConnectionFailurePopup (bool persistent)
 
void HideConnectionFailurePopup (void)
 
void ShowVersionMismatchPopup (uint remote_version)
 

Private Attributes

MythConfirmationDialogm_mbeVersionPopup {nullptr}
 
int m_registration {-1}
 
QDateTime m_lastCheck
 
QTcpSocket * m_socket {nullptr}
 

Friends

class MythContextSlotHandler
 

Detailed Description

Definition at line 97 of file mythcontext.cpp.

Constructor & Destructor Documentation

◆ MythContextPrivate()

MythContextPrivate::MythContextPrivate ( MythContext lparent)
explicit

Definition at line 269 of file mythcontext.cpp.

◆ ~MythContextPrivate()

MythContextPrivate::~MythContextPrivate ( )
override

Definition at line 277 of file mythcontext.cpp.

Member Function Documentation

◆ Init()

bool MythContextPrivate::Init ( bool  gui,
bool  promptForBackend,
bool  disableAutoDiscovery,
bool  ignoreDB 
)

Definition at line 360 of file mythcontext.cpp.

Referenced by MythContext::Init().

◆ FindDatabase()

bool MythContextPrivate::FindDatabase ( bool  prompt,
bool  noAutodetect 
)

Get database connection settings and test connectivity.

Can use UPnP AutoDiscovery to locate backends, and get their DB settings. The user can force the AutoDiscovery chooser with the –prompt argument, and disable it by using the –disable-autodiscovery argument. There is also an autoconfigure function, which counts the backends, and if there is exactly one, uses it as above.

Despite its name, the disable argument currently only disables the chooser. If set, autoconfigure will still be attempted in some situations.

Definition at line 437 of file mythcontext.cpp.

Referenced by Init().

◆ TempMainWindow()

void MythContextPrivate::TempMainWindow ( bool  languagePrompt = true)

Setup a minimal themed main window, and prompt for user's language.

Used for warnings before the database is opened, or bootstrapping pages. After using the window, call EndTempWindow().

Bug:
Some of these settings (e.g. window size, theme) seem to be used after the temp window is destroyed.

Definition at line 302 of file mythcontext.cpp.

Referenced by ChooseBackend(), MythContext::Init(), Init(), PromptForDatabaseParams(), and ShowGuiStartup().

◆ EndTempWindow()

void MythContextPrivate::EndTempWindow ( void  )

Definition at line 325 of file mythcontext.cpp.

Referenced by ChooseBackend(), Init(), and PromptForDatabaseParams().

◆ LoadDatabaseSettings()

bool MythContextPrivate::LoadDatabaseSettings ( void  )

Load database and host settings from XmlConfiguration::k_default_filename, or set some defaults.

Returns
true if XmlConfiguration::k_default_filename was parsed

Definition at line 564 of file mythcontext.cpp.

Referenced by FindDatabase().

◆ SaveDatabaseParams()

bool MythContextPrivate::SaveDatabaseParams ( const DatabaseParams params,
bool  force 
)

Definition at line 658 of file mythcontext.cpp.

Referenced by FindDatabase(), and MythContext::SaveDatabaseParams().

◆ PromptForDatabaseParams()

bool MythContextPrivate::PromptForDatabaseParams ( const QString &  error)

Definition at line 723 of file mythcontext.cpp.

Referenced by FindDatabase().

◆ TestDBconnection()

QString MythContextPrivate::TestDBconnection ( bool  prompt = true)

Some quick sanity checks before opening a database connection.

Todo:
Rationalise the WOL stuff. We should have one method to wake BEs

Definition at line 816 of file mythcontext.cpp.

Referenced by FindDatabase().

◆ SilenceDBerrors()

void MythContextPrivate::SilenceDBerrors ( void  )

Cause MSqlDatabase::OpenDatabase() and MSqlQuery to fail silently.

This is used when the DB host address is bad, is non-routable, the passwords are bad, or the DB has some other problem.

It prevents hundreds of long TCP/IP timeouts or DB connect errors.

Definition at line 1109 of file mythcontext.cpp.

Referenced by PromptForDatabaseParams(), TempMainWindow(), and TestDBconnection().

◆ EnableDBerrors()

void MythContextPrivate::EnableDBerrors ( void  )

◆ ResetDatabase()

void MythContextPrivate::ResetDatabase ( void  ) const

Called when the user changes the DB connection settings.

The current DB connections may be invalid (e.g. wrong password), or the user may have changed to a different database host. Either way, any current connections need to be closed so that the new connection can be attempted.

Any cached settings also need to be cleared, so that they can be re-read from the new database

Definition at line 1148 of file mythcontext.cpp.

Referenced by FindDatabase(), SaveDatabaseParams(), and TestDBconnection().

◆ ChooseBackend()

BackendSelection::Decision MythContextPrivate::ChooseBackend ( const QString &  error)

Search for backends via UPnP, put up a UI for the user to choose one.

Definition at line 1158 of file mythcontext.cpp.

Referenced by FindDatabase().

◆ UPnPautoconf()

int MythContextPrivate::UPnPautoconf ( std::chrono::milliseconds  milliSeconds = 2s)

If there is only a single UPnP backend, use it.

This does not prompt for PIN entry. If the backend requires one, it will fail, and the caller needs to put up a UI to ask for one.

Definition at line 1186 of file mythcontext.cpp.

Referenced by FindDatabase().

◆ DefaultUPnP()

bool MythContextPrivate::DefaultUPnP ( QString &  Error)

Get the default backend from XmlConfiguration::kDefaultFilename, use UPnP to find it.

Sets a string if there any connection problems

Definition at line 1257 of file mythcontext.cpp.

Referenced by FindDatabase().

◆ UPnPconnect()

bool MythContextPrivate::UPnPconnect ( const DeviceLocation backend,
const QString &  PIN 
)

Query a backend via UPnP for its database connection parameters.

Definition at line 1338 of file mythcontext.cpp.

Referenced by DefaultUPnP(), and UPnPautoconf().

◆ ShowGuiStartup()

void MythContextPrivate::ShowGuiStartup ( void  )

Definition at line 1075 of file mythcontext.cpp.

Referenced by TestDBconnection().

◆ checkPort()

bool MythContextPrivate::checkPort ( QString &  host,
int  port,
std::chrono::seconds  timeLimit 
) const

Check if a port is open and sort out the link-local scope.

Parameters
hostHost or IP address. Will be updated with link-local scope if needed.
portPort number to check.
timeLimitLimit in seconds for testing.

Definition at line 351 of file mythcontext.cpp.

Referenced by TestDBconnection().

◆ processEvents()

void MythContextPrivate::processEvents ( void  )
static

Definition at line 1488 of file mythcontext.cpp.

Referenced by ShowGuiStartup(), and TestDBconnection().

◆ event()

bool MythContextPrivate::event ( QEvent *  e)
overrideprotected

Definition at line 1381 of file mythcontext.cpp.

◆ ShowConnectionFailurePopup()

void MythContextPrivate::ShowConnectionFailurePopup ( bool  persistent)
protected

Definition at line 1411 of file mythcontext.cpp.

Referenced by event().

◆ HideConnectionFailurePopup()

void MythContextPrivate::HideConnectionFailurePopup ( void  )
protected

Definition at line 1445 of file mythcontext.cpp.

Referenced by event().

◆ ShowVersionMismatchPopup()

void MythContextPrivate::ShowVersionMismatchPopup ( uint  remote_version)
protected

Definition at line 1461 of file mythcontext.cpp.

Referenced by event().

◆ OnCloseDialog

void MythContextPrivate::OnCloseDialog ( )
slot

Friends And Related Function Documentation

◆ MythContextSlotHandler

friend class MythContextSlotHandler
friend

Definition at line 99 of file mythcontext.cpp.

Member Data Documentation

◆ m_parent

MythContext* MythContextPrivate::m_parent {nullptr}

Definition at line 144 of file mythcontext.cpp.

Referenced by PromptForDatabaseParams().

◆ m_gui

bool MythContextPrivate::m_gui {false}

Should this context use GUI elements?

Definition at line 147 of file mythcontext.cpp.

Referenced by FindDatabase(), MythContext::Init(), Init(), PromptForDatabaseParams(), MythContext::saveSettingsCache(), ShowGuiStartup(), and TestDBconnection().

◆ m_masterhostname

QString MythContextPrivate::m_masterhostname

master backend hostname

Definition at line 149 of file mythcontext.cpp.

◆ m_dbParams

DatabaseParams MythContextPrivate::m_dbParams

◆ m_dbHostCp

QString MythContextPrivate::m_dbHostCp

dbHostName backup

Definition at line 152 of file mythcontext.cpp.

Referenced by EnableDBerrors(), SilenceDBerrors(), and TestDBconnection().

◆ m_disableeventpopup

bool MythContextPrivate::m_disableeventpopup {false}

Definition at line 154 of file mythcontext.cpp.

Referenced by event(), and MythContext::SetDisableEventPopup().

◆ m_ui

MythUIHelper* MythContextPrivate::m_ui {nullptr}

◆ m_sh

MythContextSlotHandler* MythContextPrivate::m_sh {nullptr}

◆ m_guiStartup

GUIStartup* MythContextPrivate::m_guiStartup {nullptr}

◆ m_loop

QEventLoop* MythContextPrivate::m_loop {nullptr}

◆ m_needsBackend

bool MythContextPrivate::m_needsBackend {false}

Definition at line 160 of file mythcontext.cpp.

Referenced by Init(), MythContext::MythContext(), and TestDBconnection().

◆ m_GUISettingsCache

GUISettingsCache MythContextPrivate::m_GUISettingsCache

Definition at line 162 of file mythcontext.cpp.

Referenced by Init(), and MythContext::saveSettingsCache().

◆ m_mbeVersionPopup

MythConfirmationDialog* MythContextPrivate::m_mbeVersionPopup {nullptr}
private

◆ m_registration

int MythContextPrivate::m_registration {-1}
private

◆ m_lastCheck

QDateTime MythContextPrivate::m_lastCheck
private

Definition at line 167 of file mythcontext.cpp.

Referenced by HideConnectionFailurePopup(), and ShowConnectionFailurePopup().

◆ m_socket

QTcpSocket* MythContextPrivate::m_socket {nullptr}
private

Definition at line 168 of file mythcontext.cpp.


The documentation for this class was generated from the following file: