Go to the documentation of this file.
10 #include "libmythbase/mythversion.h"
21 QString config_filename,
26 m_configFilename(std::move(config_filename)),
27 m_exitOnFinish(exitOnFinish)
62 auto *backendSettings =
65 if (backendSettings->Create())
67 mainStack->
AddScreen(backendSettings,
false);
68 backendSettings->m_loop->exec();
69 ret = backendSettings->m_backendDecision;
70 mainStack->
PopScreen(backendSettings,
false);
74 delete backendSettings;
113 LOG(VB_GENERAL, LOG_ERR,
114 "Could not get device details from UI element?");
147 QString usn = dev->
m_sUSN;
163 infomap[
"version"] = infomap[
"modelnumber"].section(
'.', 0, 1);
166 QVariant::fromValue(dev));
167 item->SetTextFromMap(infomap);
169 bool protoMatch = (infomap[
"protocolversion"] == MYTH_PROTO_VERSION);
171 QString status =
"good";
173 status =
"protocolmismatch";
178 if (infomap[
"modelname"].isEmpty())
181 item->DisplayState(status,
"connection");
184 item->DisplayState(needPin ?
"yes" :
"no",
"securitypin");
208 if (backendName ==
"<Unknown>")
214 LOG(VB_UPNP, LOG_INFO,
215 QString(
"ConnectBackend() - success. New hostname: %1")
220 LOG(VB_GENERAL, LOG_ERR, QString(
"Need Human: %1").arg(message));
229 LOG(VB_GENERAL, LOG_ERR,
230 QString(
"Access denied for %1. Wrong PIN?")
236 LOG(VB_GENERAL, LOG_ERR,
237 QString(
"GetConnectionInfo() failed for %1 : %2")
238 .arg(backendName, message));
267 for (
auto * devLoc : std::as_const(ourMap))
284 ItemMap::iterator it =
m_devices.find(USN_);
299 " host with default database parameters?")))
301 static const QRegularExpression re {
"http[s]?://([^:/]+)",
302 QRegularExpression::CaseInsensitiveOption};
303 QRegularExpressionMatch match = re.match(URL);
304 if (match.hasMatch())
318 auto *me =
dynamic_cast<MythEvent *
>(event);
322 const QString& message = me->
Message();
323 const QString& URI = me->ExtraData(0);
324 const QString& URN = me->ExtraData(1);
325 const QString& URL = me->ExtraData(2);
328 LOG(VB_UPNP, LOG_DEBUG,
329 QString(
"BackendSelection::customEvent(%1, %2, %3, %4)")
330 .arg(message, URI, URN, URL));
332 if (message.startsWith(
"SSDP_ADD") &&
333 URI.startsWith(
"urn:schemas-mythtv-org:device:MasterMediaServer:"))
342 else if (message.startsWith(
"SSDP_REMOVE"))
355 QString resultid = dce->
GetId();
357 if (resultid ==
"password")
367 QString message = tr(
"Please enter the backend access PIN");
374 if (pwDialog->Create())
376 pwDialog->SetReturnEvent(
this,
"password");
DatabaseParams * m_dbParams
void LoadInBackground(const QString &message="")
MythScreenStack * GetMainStack()
void Cancel(void)
Linked to 'Cancel' button.
void Close(void) override
QString m_dbHostName
database server
static const Type kMythEventMessage
static void error(const char *str,...)
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
void PerformSearch(const QString &sST, std::chrono::seconds timeout=2s)
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
void customEvent(QEvent *event) override
Structure containing the basic Database parameters.
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
This class is used as a container for messages.
void AddItem(DeviceLocation *dev)
static SSDPCacheEntries * Find(const QString &sURI)
QString GetFriendlyName(void)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Screen in which all other widgets are contained and rendered.
void GetEntryMap(EntryMap &map)
Returns a copy of the EntryMap.
static SSDPCache * Instance()
const QString & Message() const
QHash< QString, QString > InfoMap
bool NeedSecurityPin(void)
BackendSelection(MythScreenStack *parent, DatabaseParams *params, QString config_filename, bool exitOnFinish=false)
void CloseWithDecision(Decision d)
bool SetFocusWidget(MythUIType *widget=nullptr)
SSDPCacheEntries * Find(const QString &sURI)
Finds the SSDPCacheEntries in the cache, returns nullptr when absent.
void RemoveItem(const QString &USN)
void BuildFocusList(void)
void Manual(void)
Linked to 'Configure Manually' button.
QMap< QString, DeviceLocation * > EntryMap
Key == Unique Service Name (USN)
MythUIButton * m_saveButton
const QString kBackendURI
@ UPnPResult_ActionNotAuthorized
bool ConnectBackend(DeviceLocation *dev)
Attempt UPnP connection to a backend device, get its DB details.
~BackendSelection() override
MythUIButtonList * m_backendList
static Decision Prompt(DatabaseParams *dbParams, const QString &config_filename)
bool TryDBfromURL(const QString &error, const QString &URL)
Decision m_backendDecision
bool Create(void) override
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
void PromptForPassword(void)
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
virtual void PopScreen(MythScreenType *screen=nullptr, bool allowFade=true, bool deleteScreen=true)
const QString kDefaultUSN
static const Type kEventType
MythMainWindow * GetMythMainWindow(void)
UPnPResultCode GetConnectionInfo(const QString &sPin, DatabaseParams *pParams, QString &sMsg)
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
MythScreenStack * GetStack(const QString &Stackname)
@ UPnPResult_HumanInterventionRequired
const QString kDefaultPIN
MythUIButton * m_cancelButton
static void AddListener(QObject *listener)
MythUIButton * m_manualButton
static const iso6937table * d
Dialog prompting the user to enter a text string.
virtual int IncrRef(void)
Increments reference count.
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
static void RemoveListener(QObject *listener)
void GetDeviceDetail(InfoMap &map)