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);
73 delete backendSettings;
111 LOG(VB_GENERAL, LOG_ERR,
112 "Could not get device details from UI element?");
145 QString usn = dev->
m_sUSN;
161 infomap[
"version"] = infomap[
"modelnumber"].section(
'.', 0, 1);
164 QVariant::fromValue(dev));
165 item->SetTextFromMap(infomap);
167 bool protoMatch = (infomap[
"protocolversion"] == MYTH_PROTO_VERSION);
169 QString status =
"good";
171 status =
"protocolmismatch";
176 if (infomap[
"modelname"].isEmpty())
179 item->DisplayState(status,
"connection");
182 item->DisplayState(needPin ?
"yes" :
"no",
"securitypin");
204 if (backendName ==
"<Unknown>")
210 LOG(VB_UPNP, LOG_INFO,
211 QString(
"ConnectBackend() - success. New hostname: %1")
216 LOG(VB_GENERAL, LOG_ERR, QString(
"Need Human: %1").arg(message));
225 LOG(VB_GENERAL, LOG_ERR,
226 QString(
"Access denied for %1. Wrong PIN?")
232 LOG(VB_GENERAL, LOG_ERR,
233 QString(
"GetConnectionInfo() failed for %1 : %2")
234 .arg(backendName, message));
263 for (
auto * devLoc : qAsConst(ourMap))
280 ItemMap::iterator it =
m_devices.find(USN_);
295 " host with default database parameters?")))
297 static const QRegularExpression re {
"http[s]?://([^:/]+)",
298 QRegularExpression::CaseInsensitiveOption};
299 QRegularExpressionMatch match = re.match(URL);
300 if (match.hasMatch())
314 auto *me =
dynamic_cast<MythEvent *
>(event);
318 const QString& message = me->
Message();
319 const QString& URI = me->ExtraData(0);
320 const QString& URN = me->ExtraData(1);
321 const QString& URL = me->ExtraData(2);
324 LOG(VB_UPNP, LOG_DEBUG,
325 QString(
"BackendSelection::customEvent(%1, %2, %3, %4)")
326 .arg(message, URI, URN, URL));
328 if (message.startsWith(
"SSDP_ADD") &&
329 URI.startsWith(
"urn:schemas-mythtv-org:device:MasterMediaServer:"))
338 else if (message.startsWith(
"SSDP_REMOVE"))
351 QString resultid = dce->
GetId();
353 if (resultid ==
"password")
363 QString message = tr(
"Please enter the backend access PIN");
370 if (pwDialog->Create())
372 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
@ UPnPResult_HumanInterventionRequired
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)
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)