/
backendselect.h
97 lines (76 loc) · 2.78 KB
/
backendselect.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef __BACKENDSELECT_H__
#define __BACKENDSELECT_H__
#include <QMutex>
// libmythui
#include "mythscreentype.h"
#include "configuration.h"
#include "upnpdevice.h"
class QEventLoop;
class MythUIButtonList;
class MythUIButton;
class DatabaseParams;
// TODO: The following do not belong here, but I cannot think of a better
// location at this moment in time
// Some common UPnP search and XML value strings
const QString gBackendURI = "urn:schemas-mythtv-org:device:MasterMediaServer:1";
const QString kDefaultDB = "Database/";
const QString kDefaultWOL = "WakeOnLAN/";
const QString kDefaultMFE = "UPnP/MythFrontend/DefaultBackend/";
const QString kDefaultPIN = kDefaultMFE + "SecurityPin";
const QString kDefaultUSN = kDefaultMFE + "USN";
using ItemMap = QMap <QString, DeviceLocation*>;
/**
* \class BackendSelection
* \brief Classes to Prompt user for a master backend.
*
* \author Originally based on masterselection.cpp/h by David Blain.
*/
class BackendSelection : public MythScreenType
{
Q_OBJECT
public:
enum Decision
{
kManualConfigure = -1,
kCancelConfigure = 0,
kAcceptConfigure = +1,
};
static Decision Prompt(
DatabaseParams *dbParams, Configuration *pConfig);
BackendSelection(MythScreenStack *parent, DatabaseParams *params,
Configuration *pConfig, bool exitOnFinish = false);
virtual ~BackendSelection();
bool Create(void) override; // MythScreenType
void Close(void) override; // MythScreenType
void customEvent(QEvent *event) override; // QObject
protected slots:
void Accept(void);
void Accept(MythUIButtonListItem *);
void Manual(void); ///< Linked to 'Configure Manually' button
void Cancel(void); ///< Linked to 'Cancel' button
private:
void Load(void) override; // MythScreenType
void Init(void) override; // MythScreenType
bool ConnectBackend(DeviceLocation *dev);
void AddItem(DeviceLocation *dev);
void RemoveItem(const QString& USN);
bool TryDBfromURL(const QString &error, QString URL);
void PromptForPassword(void);
void CloseWithDecision(Decision);
DatabaseParams *m_DBparams {nullptr};
Configuration *m_pConfig {nullptr};
bool m_exitOnFinish;
ItemMap m_devices;
MythUIButtonList *m_backendList {nullptr};
MythUIButton *m_manualButton {nullptr};
MythUIButton *m_saveButton {nullptr};
MythUIButton *m_cancelButton {nullptr};
//MythUIButton *m_searchButton {nullptr};
QString m_pinCode;
QString m_USN;
QMutex m_mutex;
Decision m_backendDecision {kCancelConfigure};
QEventLoop *m_loop {nullptr};
};
Q_DECLARE_METATYPE(DeviceLocation*)
#endif