MythTV  master
backendselect.h
Go to the documentation of this file.
1 #ifndef BACKENDSELECT_H
2 #define BACKENDSELECT_H
3 
4 #include <QMutex>
5 #include <QString>
6 
7 // MythTV
10 
11 class QEventLoop;
12 class MythUIButtonList;
13 class MythUIButton;
14 
15 class DatabaseParams;
16 
17 // TODO: The following do not belong here, but I cannot think of a better
18 // location at this moment in time
19 // Some common UPnP search and XML value strings
20 const QString kBackendURI = "urn:schemas-mythtv-org:device:MasterMediaServer:1";
21 const QString kDefaultDB = "Database/";
22 const QString kDefaultWOL = "WakeOnLAN/";
23 const QString kDefaultMFE = "UPnP/MythFrontend/DefaultBackend/";
24 const QString kDefaultPIN = kDefaultMFE + "SecurityPin";
25 const QString kDefaultUSN = kDefaultMFE + "USN";
26 
27 using ItemMap = QMap <QString, DeviceLocation*>;
28 
37 {
38  Q_OBJECT
39 
40  public:
41  enum Decision : std::int8_t
42  {
46  };
47  static Decision Prompt(DatabaseParams *dbParams, const QString& config_filename);
48 
50  QString config_filename, bool exitOnFinish = false);
51  ~BackendSelection() override;
52 
53  bool Create(void) override; // MythScreenType
54  void Close(void) override; // MythScreenType
55  void customEvent(QEvent *event) override; // QObject
56 
57  protected slots:
58  void Accept(void);
59  void Accept(MythUIButtonListItem *item);
60  void Manual(void);
61  void Cancel(void);
62 
63  private:
64  void Load(void) override; // MythScreenType
65  void Init(void) override; // MythScreenType
66  bool ConnectBackend(DeviceLocation *dev);
67  void AddItem(DeviceLocation *dev);
68  void RemoveItem(const QString& USN);
69  bool TryDBfromURL(const QString &error, const QString& URL);
70  void PromptForPassword(void);
72 
77 
82 
83  QString m_pinCode;
84  QString m_usn;
85 
86  QMutex m_mutex;
87 
89  QEventLoop *m_loop {nullptr};
90 };
91 
93 
94 #endif // BACKENDSELECT_H
BackendSelection::m_dbParams
DatabaseParams * m_dbParams
Definition: backendselect.h:73
BackendSelection::Decision
Decision
Definition: backendselect.h:41
BackendSelection::Cancel
void Cancel(void)
Linked to 'Cancel' button.
Definition: backendselect.cpp:247
BackendSelection::Close
void Close(void) override
Definition: backendselect.cpp:385
upnpdevice.h
error
static void error(const char *str,...)
Definition: vbi.cpp:37
BackendSelection::Init
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
Definition: backendselect.cpp:258
BackendSelection::m_mutex
QMutex m_mutex
Definition: backendselect.h:86
BackendSelection::customEvent
void customEvent(QEvent *event) override
Definition: backendselect.cpp:314
DatabaseParams
Structure containing the basic Database parameters.
Definition: mythdbparams.h:10
BackendSelection::AddItem
void AddItem(DeviceLocation *dev)
Definition: backendselect.cpp:142
kDefaultWOL
const QString kDefaultWOL
Definition: backendselect.h:22
MythScreenStack
Definition: mythscreenstack.h:16
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
DeviceLocation
Definition: upnpdevice.h:210
BackendSelection::m_exitOnFinish
bool m_exitOnFinish
Definition: backendselect.h:75
BackendSelection::m_devices
ItemMap m_devices
Definition: backendselect.h:76
MythUIButtonListItem
Definition: mythuibuttonlist.h:41
kDefaultDB
const QString kDefaultDB
Definition: backendselect.h:21
BackendSelection::kManualConfigure
@ kManualConfigure
Definition: backendselect.h:43
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(std::chrono::seconds)
BackendSelection::BackendSelection
BackendSelection(MythScreenStack *parent, DatabaseParams *params, QString config_filename, bool exitOnFinish=false)
Definition: backendselect.cpp:18
BackendSelection::CloseWithDecision
void CloseWithDecision(Decision d)
Definition: backendselect.cpp:390
BackendSelection::RemoveItem
void RemoveItem(const QString &USN)
Definition: backendselect.cpp:280
BackendSelection::Manual
void Manual(void)
Linked to 'Configure Manually' button.
Definition: backendselect.cpp:275
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
BackendSelection
Classes to Prompt user for a master backend.
Definition: backendselect.h:36
BackendSelection::m_configFilename
QString m_configFilename
Definition: backendselect.h:74
BackendSelection::m_pinCode
QString m_pinCode
Definition: backendselect.h:83
BackendSelection::Accept
void Accept(void)
Definition: backendselect.cpp:131
BackendSelection::m_saveButton
MythUIButton * m_saveButton
Definition: backendselect.h:80
kBackendURI
const QString kBackendURI
Definition: backendselect.h:20
BackendSelection::kCancelConfigure
@ kCancelConfigure
Definition: backendselect.h:44
BackendSelection::ConnectBackend
bool ConnectBackend(DeviceLocation *dev)
Attempt UPnP connection to a backend device, get its DB details.
Definition: backendselect.cpp:196
ItemMap
QMap< QString, DeviceLocation * > ItemMap
Definition: backendselect.h:27
BackendSelection::~BackendSelection
~BackendSelection() override
Definition: backendselect.cpp:35
BackendSelection::m_backendList
MythUIButtonList * m_backendList
Definition: backendselect.h:78
BackendSelection::m_usn
QString m_usn
Definition: backendselect.h:84
BackendSelection::Prompt
static Decision Prompt(DatabaseParams *dbParams, const QString &config_filename)
Definition: backendselect.cpp:54
BackendSelection::TryDBfromURL
bool TryDBfromURL(const QString &error, const QString &URL)
Definition: backendselect.cpp:296
BackendSelection::m_backendDecision
Decision m_backendDecision
Definition: backendselect.h:88
BackendSelection::Create
bool Create(void) override
Definition: backendselect.cpp:80
BackendSelection::PromptForPassword
void PromptForPassword(void)
Definition: backendselect.cpp:365
kDefaultUSN
const QString kDefaultUSN
Definition: backendselect.h:25
BackendSelection::kAcceptConfigure
@ kAcceptConfigure
Definition: backendselect.h:45
BackendSelection::Load
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
Definition: backendselect.cpp:252
BackendSelection::m_loop
QEventLoop * m_loop
Definition: backendselect.h:89
kDefaultPIN
const QString kDefaultPIN
Definition: backendselect.h:24
BackendSelection::m_cancelButton
MythUIButton * m_cancelButton
Definition: backendselect.h:81
BackendSelection::m_manualButton
MythUIButton * m_manualButton
Definition: backendselect.h:79
d
static const iso6937table * d
Definition: iso6937tables.cpp:1025
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:191
kDefaultMFE
const QString kDefaultMFE
Definition: backendselect.h:23
mythscreentype.h