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