Skip to content

Commit 28d371e

Browse files
committed
Port the Backend Selection dialog to mythui. Theme needs a little work and there is no default-wide yet.
1 parent a0fcdbb commit 28d371e

File tree

8 files changed

+486
-357
lines changed

8 files changed

+486
-357
lines changed

mythtv/libs/libmyth/backendselect.cpp

Lines changed: 234 additions & 221 deletions
Large diffs are not rendered by default.
Lines changed: 57 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,85 @@
11
#ifndef __BACKENDSELECT_H__
22
#define __BACKENDSELECT_H__
33

4-
#include <QListWidget>
4+
// libmythui
5+
#include "mythscreentype.h"
6+
#include "mythuibuttonlist.h"
57

6-
#include "mythdialogs.h"
78
#include "upnpdevice.h"
89

9-
// define this to add a search button. In Nigel's testing, an extra ssdp
10-
// doesn't get any extra responses, so it is disabled by default.
11-
//#define SEARCH_BUTTON
10+
class MythUIButtonList;
11+
class MythUIButton;
1212

13+
class XmlConfiguration;
1314
struct DatabaseParams;
1415

15-
class ListBoxDevice : public QListWidgetItem
16-
{
17-
public:
16+
// TODO: The following do not belong here, but I cannot think of a better
17+
// location at this moment in time
18+
// Some common UPnP search and XML value strings
19+
const QString gBackendURI = "urn:schemas-mythtv-org:device:MasterMediaServer:1";
20+
const QString kDefaultBE = "UPnP/MythFrontend/DefaultBackend/";
21+
const QString kDefaultPIN = kDefaultBE + "SecurityPin";
22+
const QString kDefaultUSN = kDefaultBE + "USN";
1823

19-
ListBoxDevice(QListWidget *parent, const QString &name, DeviceLocation *dev)
20-
: QListWidgetItem(name, parent), m_dev(dev)
21-
{
22-
if (m_dev)
23-
m_dev->AddRef();
24-
}
24+
typedef QMap <QString, DeviceLocation*> ItemMap;
2525

26-
virtual ~ListBoxDevice()
27-
{
28-
if (m_dev)
29-
m_dev->Release();
30-
}
31-
32-
DeviceLocation *m_dev;
33-
};
26+
/**
27+
* \class BackendSelection
28+
* \brief Classes to Prompt user for a master backend.
29+
*
30+
* \author Originally based on masterselection.cpp/h by David Blain.
31+
*/
3432

35-
typedef QMap <QString, ListBoxDevice *> ItemMap;
36-
37-
38-
class BackendSelect : public MythDialog
33+
class BackendSelection : public MythScreenType
3934
{
4035
Q_OBJECT
4136

4237
public:
43-
BackendSelect(MythMainWindow *parent, DatabaseParams *params);
44-
virtual ~BackendSelect();
38+
BackendSelection(MythScreenStack *parent, DatabaseParams *params,
39+
XmlConfiguration *xmlConfig, bool exitOnFinish = false);
40+
virtual ~BackendSelection();
4541

46-
void customEvent(QEvent *e);
42+
bool Create(void);
43+
void customEvent(QEvent *event);
4744

48-
QString m_PIN;
49-
QString m_USN;
45+
static bool prompt(DatabaseParams *dbParams, XmlConfiguration *xmlConfig);
5046

47+
signals:
48+
// void
5149

5250
public slots:
53-
void Accept(QListWidgetItem *); ///< Invoked by mouse click
54-
void Accept(void); ///< Linked to the OK button
51+
void Accept(void);
52+
void Accept(MythUIButtonListItem *);
5553
void Manual(void); ///< Linked to 'Configure Manually' button
56-
#ifdef SEARCH_BUTTON
57-
void Search(void);
58-
#endif
59-
60-
61-
protected:
62-
void AddItem (DeviceLocation *dev);
63-
bool Connect (DeviceLocation *dev);
64-
void CreateUI (void);
65-
void FillListBox(void);
66-
void RemoveItem (QString URN);
67-
bool eventFilter(QObject *obj, QEvent *event);
54+
void Cancel(void); ///< Linked to 'Cancel' button
55+
void Close(void);
56+
57+
private:
58+
void Load(void);
59+
void Init(void);
60+
bool ConnectBackend(DeviceLocation *dev);
61+
void AddItem(DeviceLocation *dev);
62+
void RemoveItem(QString URN);
6863
bool TryDBfromURL(const QString &error, QString URL);
64+
void PromptForPassword(void);
6965

7066
DatabaseParams *m_DBparams;
71-
ItemMap m_devices;
72-
MythMainWindow *m_parent;
73-
QListWidget *m_backends;
67+
XmlConfiguration *m_XML;
68+
bool m_exitOnFinish;
69+
ItemMap m_devices;
70+
71+
MythUIButtonList *m_backendList;
72+
MythUIButton *m_manualButton;
73+
MythUIButton *m_saveButton;
74+
MythUIButton *m_cancelButton;
75+
//MythUIButton *m_searchButton;
76+
77+
QString m_pinCode;
78+
QString m_USN;
79+
80+
static bool m_backendChanged;
7481
};
7582

83+
Q_DECLARE_METATYPE(DeviceLocation*)
84+
7685
#endif

mythtv/libs/libmyth/mythcontext.cpp

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ using namespace std;
4848

4949
MythContext *gContext = NULL;
5050

51-
// Some common UPnP search and XML value strings
52-
const QString gBackendURI = "urn:schemas-mythtv-org:device:MasterMediaServer:1";
53-
const QString kDefaultBE = "UPnP/MythFrontend/DefaultBackend/";
54-
const QString kDefaultPIN = kDefaultBE + "SecurityPin";
55-
const QString kDefaultUSN = kDefaultBE + "USN";
56-
5751
class MythContextPrivate : public QObject
5852
{
5953
friend class MythContextSlotHandler;
@@ -941,58 +935,12 @@ int MythContextPrivate::ChooseBackend(const QString &error)
941935

942936
// Tell the user what went wrong:
943937
if (error.length())
944-
MythPopupBox::showOkPopup(GetMythMainWindow(), "DB connect failure",
945-
error);
938+
ShowOkPopup(error);
946939

947940
VERBOSE(VB_GENERAL, "Putting up the UPnP backend chooser");
948941

949-
BackendSelect *BEsel = new BackendSelect(GetMythMainWindow(), &m_DBparams);
950-
switch (BEsel->exec())
951-
{
952-
case kDialogCodeRejected:
953-
VERBOSE(VB_IMPORTANT, "User canceled database configuration");
954-
delete BEsel;
955-
return 0;
956-
957-
case kDialogCodeButton0:
958-
VERBOSE(VB_IMPORTANT, "User requested Manual Config");
959-
delete BEsel;
960-
return -1;
961-
}
962-
963-
QStringList buttons;
964-
QString message;
965-
966-
buttons += QObject::tr("Save database details");
967-
buttons += QObject::tr("Save backend details");
968-
buttons += QObject::tr("Don't Save");
969-
970-
message = QObject::tr("Save that backend or database as the default?");
971-
972-
DialogCode selected = MythPopupBox::ShowButtonPopup(
973-
GetMythMainWindow(), "Save default", message, buttons,
974-
kDialogCodeButton2);
975-
switch (selected)
976-
{
977-
case kDialogCodeButton0:
978-
if (!WriteSettingsFile(m_DBparams, true))
979-
{
980-
VERBOSE(VB_IMPORTANT, "WriteSettingsFile failed.");
981-
return -1;
982-
}
983-
// User prefers mysql.txt, so throw away default UPnP backend:
984-
m_XML->SetValue(kDefaultUSN, "");
985-
m_XML->Save();
986-
break;
987-
case kDialogCodeButton1:
988-
if (BEsel->m_PIN.length())
989-
m_XML->SetValue(kDefaultPIN, BEsel->m_PIN);
990-
m_XML->SetValue(kDefaultUSN, BEsel->m_USN);
991-
m_XML->Save();
992-
break;
993-
}
942+
BackendSelection::prompt(&m_DBparams, m_XML);
994943

995-
delete BEsel;
996944
EndTempWindow();
997945

998946
return 1;

mythtv/libs/libmythupnp/upnp.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// Created : Oct. 24, 2005
44
//
55
// Purpose : UPnp Main Class
6-
//
6+
//
77
// Copyright (c) 2005 David Blain <mythtv@theblains.net>
8-
//
9-
// This library is free software; you can redistribute it and/or
8+
//
9+
// This library is free software; you can redistribute it and/or
1010
// modify it under the terms of the GNU Lesser General Public
1111
// License as published by the Free Software Foundation; either
1212
// version 2.1 of the License, or at your option any later version of the LGPL.
@@ -132,7 +132,7 @@ bool UPnp::Initialize( QStringList &sIPAddrList, int nServicePort, HttpServer *p
132132
new SSDPExtension( m_nServicePort, m_pHttpServer->m_sSharePath));
133133

134134
// ----------------------------------------------------------------------
135-
// Add Task to keep SSDPCache purged of stale entries.
135+
// Add Task to keep SSDPCache purged of stale entries.
136136
// ----------------------------------------------------------------------
137137

138138
UPnp::g_pTaskQueue->AddTask( new SSDPCacheTask() );
@@ -214,7 +214,7 @@ void UPnp::CleanUp()
214214
g_pConfig = NULL;
215215
}
216216

217-
}
217+
}
218218

219219
//////////////////////////////////////////////////////////////////////////////
220220
//
@@ -251,23 +251,23 @@ QString UPnp::GetResultDesc( UPnPResultCode eCode )
251251
switch( eCode )
252252
{
253253
case UPnPResult_Success : return "Success";
254-
case UPnPResult_InvalidAction : return "Invalid Action";
255-
case UPnPResult_InvalidArgs : return "Invalid Args";
256-
case UPnPResult_ActionFailed : return "Action Failed";
257-
case UPnPResult_ArgumentValueInvalid : return "Argument Value Invalid";
258-
case UPnPResult_ArgumentValueOutOfRange : return "Argument Value Out Of Range";
259-
case UPnPResult_OptionalActionNotImplemented: return "Optional Action Not Implemented";
260-
case UPnPResult_OutOfMemory : return "Out Of Memory";
261-
case UPnPResult_HumanInterventionRequired : return "Human Intervention Required";
262-
case UPnPResult_StringArgumentTooLong : return "String Argument Too Long";
263-
case UPnPResult_ActionNotAuthorized : return "Action Not Authorized";
264-
case UPnPResult_SignatureFailure : return "Signature Failure";
265-
case UPnPResult_SignatureMissing : return "Signature Missing";
266-
case UPnPResult_NotEncrypted : return "Not Encrypted";
267-
case UPnPResult_InvalidSequence : return "Invalid Sequence";
268-
case UPnPResult_InvalidControlURL : return "Invalid Control URL";
269-
case UPnPResult_NoSuchSession : return "No Such Session";
270-
case UPnPResult_MS_AccessDenied : return "Access Denied";
254+
case UPnPResult_InvalidAction : return "Invalid Action";
255+
case UPnPResult_InvalidArgs : return "Invalid Args";
256+
case UPnPResult_ActionFailed : return "Action Failed";
257+
case UPnPResult_ArgumentValueInvalid : return "Argument Value Invalid";
258+
case UPnPResult_ArgumentValueOutOfRange : return "Argument Value Out Of Range";
259+
case UPnPResult_OptionalActionNotImplemented: return "Optional Action Not Implemented";
260+
case UPnPResult_OutOfMemory : return "Out Of Memory";
261+
case UPnPResult_HumanInterventionRequired : return "Human Intervention Required";
262+
case UPnPResult_StringArgumentTooLong : return "String Argument Too Long";
263+
case UPnPResult_ActionNotAuthorized : return "Action Not Authorized";
264+
case UPnPResult_SignatureFailure : return "Signature Failure";
265+
case UPnPResult_SignatureMissing : return "Signature Missing";
266+
case UPnPResult_NotEncrypted : return "Not Encrypted";
267+
case UPnPResult_InvalidSequence : return "Invalid Sequence";
268+
case UPnPResult_InvalidControlURL : return "Invalid Control URL";
269+
case UPnPResult_NoSuchSession : return "No Such Session";
270+
case UPnPResult_MS_AccessDenied : return "Access Denied";
271271

272272
case UPnPResult_CDS_NoSuchObject : return "No Such Object";
273273
case UPnPResult_CDS_InvalidCurrentTagValue : return "Invalid CurrentTagValue";
@@ -303,18 +303,18 @@ QString UPnp::GetResultDesc( UPnPResultCode eCode )
303303
}
304304

305305
//////////////////////////////////////////////////////////////////////////////
306-
//
306+
//
307307
//////////////////////////////////////////////////////////////////////////////
308308

309-
void UPnp::FormatErrorResponse( HTTPRequest *pRequest,
309+
void UPnp::FormatErrorResponse( HTTPRequest *pRequest,
310310
UPnPResultCode eCode,
311311
const QString &msg )
312312
{
313313
QString sMsg( msg );
314314

315315
if (pRequest != NULL)
316316
{
317-
QString sDetails = "";
317+
QString sDetails = "";
318318

319319
if (pRequest->m_bSOAPRequest)
320320
sDetails = "<UPnPResult xmlns=\"urn:schemas-upnp-org:control-1-0\">";
@@ -327,12 +327,12 @@ void UPnp::FormatErrorResponse( HTTPRequest *pRequest,
327327
.arg( eCode )
328328
.arg( HTTPRequest::Encode( sMsg ) );
329329

330-
if (pRequest->m_bSOAPRequest)
330+
if (pRequest->m_bSOAPRequest)
331331
sDetails += "</UPnPResult>";
332332

333333

334334
pRequest->FormatErrorResponse ( true, // -=>TODO: Should make this dynamic
335-
"UPnPResult",
335+
"UPnPResult",
336336
sDetails );
337337
}
338338
else

mythtv/programs/mythfrontend/mediarenderer.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/////////////////////////////////////////////////////////////////////////////
22
// Program Name: mediarenderer.cpp
3-
//
3+
//
44
// Purpose - uPnp Media Renderer main Class
5-
//
5+
//
66
// Created By : David Blain Created On : Jan. 15, 2007
7-
// Modified By : Modified On:
8-
//
7+
// Modified By : Modified On:
8+
//
99
/////////////////////////////////////////////////////////////////////////////
1010

1111
#include "mediarenderer.h"
@@ -24,7 +24,7 @@
2424
//
2525
/////////////////////////////////////////////////////////////////////////////
2626

27-
MediaRenderer::MediaRenderer()
27+
MediaRenderer::MediaRenderer()
2828
{
2929
VERBOSE(VB_UPNP, "MediaRenderer::Begin" );
3030

@@ -51,6 +51,7 @@ MediaRenderer::MediaRenderer()
5151
// exit(BACKEND_BUGGY_EXIT_NO_BIND_STATUS);
5252
delete m_pHttpServer;
5353
m_pHttpServer = NULL;
54+
InitializeSSDPOnly();
5455
return;
5556
}
5657

@@ -92,7 +93,7 @@ MediaRenderer::MediaRenderer()
9293
"http-get:*:video/nupplevideo:*,"
9394
"http-get:*:video/x-ms-wmv:*";
9495
// ------------------------------------------------------------------
95-
// Register the MythFEXML protocol...
96+
// Register the MythFEXML protocol...
9697
// ------------------------------------------------------------------
9798
VERBOSE(VB_UPNP, "MediaRenderer::Registering MythFEXML Service." );
9899
m_pHttpServer->RegisterExtension( new MythFEXML( RootDevice(),

0 commit comments

Comments
 (0)