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

Public Slots

void OnCloseDialog () const
 
void VersionMismatchPopupClosed ()
 

Public Member Functions

 Impl ()
 
 ~Impl () 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...
 
bool FindDatabaseChoose (bool loaded, bool manualSelect, bool autoSelect)
 Helper function for getting database connection settings and test connectivity. More...
 
void TempMainWindow ()
 Setup a minimal themed main window, and prompt for user's language. More...
 
void EndTempWindow ()
 
bool PromptForDatabaseParams (const QString &error)
 
QString TestDBconnection (bool prompt=true)
 Some quick sanity checks before opening a database connection. More...
 
void SilenceDBerrors ()
 Cause MSqlDatabase::OpenDatabase() and MSqlQuery to fail silently. More...
 
void EnableDBerrors () const
 
BackendSelection::Decision ChooseBackend (const QString &error)
 Search for backends via UPnP, put up a UI for the user to choose one. More...
 
void ShowGuiStartup ()
 
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 LanguagePrompt ()
 
static bool LoadDatabaseSettings ()
 Load database and host settings from XmlConfiguration::k_default_filename, or set some defaults. More...
 
static QString setLocalHostName (QString hostname)
 
static void ResetDatabase (const DatabaseParams &dbParams)
 Called when the user changes the DB connection settings. More...
 
static int UPnPautoconf (std::chrono::milliseconds milliSeconds=2s)
 If there is only a single UPnP backend, use it. More...
 
static bool DefaultUPnP (QString &Error)
 Get the default backend from XmlConfiguration::kDefaultFilename, use UPnP to find it. More...
 
static bool UPnPconnect (const DeviceLocation *backend, const QString &PIN)
 Query a backend via UPnP for its database connection parameters. More...
 
static void processEvents ()
 

Public Attributes

bool m_gui {false}
 Should this context use GUI elements? More...
 
QString m_masterhostname
 master backend hostname More...
 
QString m_dbHostCp
 dbHostName backup More...
 
bool m_disableeventpopup {false}
 
MythUIHelperm_ui {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 ShowVersionMismatchPopup (uint remote_version)
 

Private Attributes

MythConfirmationDialogm_mbeVersionPopup {nullptr}
 
int m_registration {-1}
 
QDateTime m_lastCheck
 

Detailed Description

Definition at line 102 of file mythcontext.cpp.

Constructor & Destructor Documentation

◆ Impl()

MythContext::Impl::Impl ( )
explicit

Definition at line 275 of file mythcontext.cpp.

◆ ~Impl()

MythContext::Impl::~Impl ( )
override

Definition at line 281 of file mythcontext.cpp.

Member Function Documentation

◆ checkPort()

bool MythContext::Impl::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 353 of file mythcontext.cpp.

◆ ChooseBackend()

BackendSelection::Decision MythContext::Impl::ChooseBackend ( const QString &  error)

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

Definition at line 1134 of file mythcontext.cpp.

◆ DefaultUPnP()

bool MythContext::Impl::DefaultUPnP ( QString &  Error)
static

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

Sets a string if there any connection problems

Definition at line 1235 of file mythcontext.cpp.

◆ EnableDBerrors()

void MythContext::Impl::EnableDBerrors ( ) const

Definition at line 1098 of file mythcontext.cpp.

◆ EndTempWindow()

void MythContext::Impl::EndTempWindow ( )

Definition at line 320 of file mythcontext.cpp.

◆ event()

bool MythContext::Impl::event ( QEvent *  e)
overrideprotected

Definition at line 1361 of file mythcontext.cpp.

◆ FindDatabase()

bool MythContext::Impl::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 544 of file mythcontext.cpp.

◆ FindDatabaseChoose()

bool MythContext::Impl::FindDatabaseChoose ( bool  loaded,
bool  manualSelect,
bool  autoSelect 
)

Helper function for getting database connection settings and test connectivity.

Return true if a database connection was found, false otherwise

Definition at line 431 of file mythcontext.cpp.

◆ HideConnectionFailurePopup()

void MythContext::Impl::HideConnectionFailurePopup ( )
protected

Definition at line 1425 of file mythcontext.cpp.

◆ Init()

bool MythContext::Impl::Init ( bool  gui,
bool  promptForBackend,
bool  disableAutoDiscovery,
bool  ignoreDB 
)

Definition at line 362 of file mythcontext.cpp.

Referenced by MythContext::Init().

◆ LanguagePrompt()

void MythContext::Impl::LanguagePrompt ( )
static

Definition at line 337 of file mythcontext.cpp.

◆ LoadDatabaseSettings()

bool MythContext::Impl::LoadDatabaseSettings ( )
static

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 580 of file mythcontext.cpp.

◆ OnCloseDialog

void MythContext::Impl::OnCloseDialog ( ) const
slot

Definition at line 677 of file mythcontext.cpp.

Referenced by PromptForDatabaseParams().

◆ processEvents()

void MythContext::Impl::processEvents ( )
static

Definition at line 1468 of file mythcontext.cpp.

◆ PromptForDatabaseParams()

bool MythContext::Impl::PromptForDatabaseParams ( const QString &  error)

Definition at line 690 of file mythcontext.cpp.

◆ ResetDatabase()

void MythContext::Impl::ResetDatabase ( const DatabaseParams dbParams)
static

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 1123 of file mythcontext.cpp.

◆ setLocalHostName()

QString MythContext::Impl::setLocalHostName ( QString  hostname)
static

Definition at line 612 of file mythcontext.cpp.

◆ ShowConnectionFailurePopup()

void MythContext::Impl::ShowConnectionFailurePopup ( bool  persistent)
protected

Definition at line 1391 of file mythcontext.cpp.

◆ ShowGuiStartup()

void MythContext::Impl::ShowGuiStartup ( )

Definition at line 1047 of file mythcontext.cpp.

◆ ShowVersionMismatchPopup()

void MythContext::Impl::ShowVersionMismatchPopup ( uint  remote_version)
protected

Definition at line 1441 of file mythcontext.cpp.

◆ SilenceDBerrors()

void MythContext::Impl::SilenceDBerrors ( )

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 1081 of file mythcontext.cpp.

◆ TempMainWindow()

void MythContext::Impl::TempMainWindow ( )

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 304 of file mythcontext.cpp.

Referenced by MythContext::Init().

◆ TestDBconnection()

QString MythContext::Impl::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 786 of file mythcontext.cpp.

◆ UPnPautoconf()

int MythContext::Impl::UPnPautoconf ( std::chrono::milliseconds  milliSeconds = 2s)
static

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 1164 of file mythcontext.cpp.

◆ UPnPconnect()

bool MythContext::Impl::UPnPconnect ( const DeviceLocation backend,
const QString &  PIN 
)
static

Query a backend via UPnP for its database connection parameters.

Definition at line 1316 of file mythcontext.cpp.

◆ VersionMismatchPopupClosed

void MythContext::Impl::VersionMismatchPopupClosed ( )
slot

Definition at line 1551 of file mythcontext.cpp.

Referenced by ShowVersionMismatchPopup().

Member Data Documentation

◆ m_dbHostCp

QString MythContext::Impl::m_dbHostCp

dbHostName backup

Definition at line 158 of file mythcontext.cpp.

◆ m_disableeventpopup

bool MythContext::Impl::m_disableeventpopup {false}

Definition at line 160 of file mythcontext.cpp.

Referenced by MythContext::SetDisableEventPopup().

◆ m_gui

bool MythContext::Impl::m_gui {false}

Should this context use GUI elements?

Definition at line 154 of file mythcontext.cpp.

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

◆ m_GUISettingsCache

GUISettingsCache MythContext::Impl::m_GUISettingsCache

Definition at line 167 of file mythcontext.cpp.

Referenced by MythContext::saveSettingsCache().

◆ m_guiStartup

GUIStartup* MythContext::Impl::m_guiStartup {nullptr}

Definition at line 163 of file mythcontext.cpp.

◆ m_lastCheck

QDateTime MythContext::Impl::m_lastCheck
private

Definition at line 172 of file mythcontext.cpp.

◆ m_loop

QEventLoop* MythContext::Impl::m_loop {nullptr}

Definition at line 164 of file mythcontext.cpp.

◆ m_masterhostname

QString MythContext::Impl::m_masterhostname

master backend hostname

Definition at line 156 of file mythcontext.cpp.

◆ m_mbeVersionPopup

MythConfirmationDialog* MythContext::Impl::m_mbeVersionPopup {nullptr}
private

Definition at line 170 of file mythcontext.cpp.

◆ m_needsBackend

bool MythContext::Impl::m_needsBackend {false}

Definition at line 165 of file mythcontext.cpp.

Referenced by MythContext::MythContext().

◆ m_registration

int MythContext::Impl::m_registration {-1}
private

Definition at line 171 of file mythcontext.cpp.

◆ m_ui

MythUIHelper* MythContext::Impl::m_ui {nullptr}

Definition at line 162 of file mythcontext.cpp.


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