| 1 | Description: Try to fetch database info from localhost first.
|
|---|
| 2 | If the backend is bound to localhost, UPnP won't be activated, so this is
|
|---|
| 3 | an alternative way to discover the backend connectivity information.
|
|---|
| 4 |
|
|---|
| 5 | Origin: Mario Limonciello <superm1@ubuntu.com>
|
|---|
| 6 | Bug: http://svn.mythtv.org/trac/ticket/8094
|
|---|
| 7 | Bug-Ubuntu: http://bugs.debian.org/<bugnumber>
|
|---|
| 8 | Last-Update: 2010-02-19
|
|---|
| 9 |
|
|---|
| 10 | --- mythtv-0.23.0~trunk23567.orig/libs/libmyth/mythcontext.cpp
|
|---|
| 11 | +++ mythtv-0.23.0~trunk23567/libs/libmyth/mythcontext.cpp
|
|---|
| 12 | @@ -96,6 +96,7 @@ class MythContextPrivate : public QObjec
|
|---|
| 13 | bool InitUPnP(void);
|
|---|
| 14 | void DeleteUPnP(void);
|
|---|
| 15 | int ChooseBackend(const QString &error);
|
|---|
| 16 | + int TestLocal(void);
|
|---|
| 17 | int UPnPautoconf(const int milliSeconds = 2000);
|
|---|
| 18 | void StoreConnectionInfo(void);
|
|---|
| 19 | bool DefaultUPnP(QString &error);
|
|---|
| 20 | @@ -425,7 +426,10 @@ bool MythContextPrivate::FindDatabase(co
|
|---|
| 21 | // 3. Try to automatically find the single backend:
|
|---|
| 22 | if (autoSelect)
|
|---|
| 23 | {
|
|---|
| 24 | - int count = UPnPautoconf();
|
|---|
| 25 | + int count = TestLocal();
|
|---|
| 26 | +
|
|---|
| 27 | + if (count == 0)
|
|---|
| 28 | + count = UPnPautoconf();
|
|---|
| 29 |
|
|---|
| 30 | if (count == 0)
|
|---|
| 31 | failure = "No UPnP backends found";
|
|---|
| 32 | @@ -1079,6 +1083,38 @@ void MythContextPrivate::StoreConnection
|
|---|
| 33 | m_XML->Save();
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | +/*
|
|---|
| 37 | + * Test localhost for a backend
|
|---|
| 38 | + * If bound to localhost, UPnP would be disabled anyway
|
|---|
| 39 | + * Only tries the standard status port
|
|---|
| 40 | + */
|
|---|
| 41 | +
|
|---|
| 42 | +int MythContextPrivate::TestLocal(void)
|
|---|
| 43 | +{
|
|---|
| 44 | + QString host = "127.0.0.1";
|
|---|
| 45 | + int port = 6544;
|
|---|
| 46 | + bool connect = false;
|
|---|
| 47 | + if (telnet(host,port))
|
|---|
| 48 | + {
|
|---|
| 49 | + QString URL = "http://" + host + ":" + QString::number(port);
|
|---|
| 50 | + timeval ttExpires;
|
|---|
| 51 | + gettimeofday ( (&ttExpires), NULL );
|
|---|
| 52 | + DeviceLocation *device = new DeviceLocation(QString::null, QString::null, URL, ttExpires);
|
|---|
| 53 | + connect = UPnPconnect(device, QString::null);
|
|---|
| 54 | + if (!connect)
|
|---|
| 55 | + {
|
|---|
| 56 | + //Look if there is a pin in config.xml to try
|
|---|
| 57 | + XmlConfiguration *XML = new XmlConfiguration("config.xml");
|
|---|
| 58 | + QString PIN = XML->GetValue(kDefaultPIN, "");
|
|---|
| 59 | + delete XML;
|
|---|
| 60 | + connect = UPnPconnect(device, PIN);
|
|---|
| 61 | + }
|
|---|
| 62 | + device->Release();
|
|---|
| 63 | + return connect;
|
|---|
| 64 | + }
|
|---|
| 65 | + return connect;
|
|---|
| 66 | +}
|
|---|
| 67 | +
|
|---|
| 68 | /**
|
|---|
| 69 | * If there is only a single UPnP backend, use it.
|
|---|
| 70 | *
|
|---|
| 71 | @@ -1242,19 +1278,7 @@ bool MythContextPrivate::UPnPconnect(con
|
|---|
| 72 | VERBOSE(VB_UPNP, loc + error);
|
|---|
| 73 | break;
|
|---|
| 74 | }
|
|---|
| 75 | -
|
|---|
| 76 | - // This backend may have a local DB with the default user/pass/DBname.
|
|---|
| 77 | - // For whatever reason, we have failed to get anything back via UPnP,
|
|---|
| 78 | - // so we might as well try the database directly as a last resort.
|
|---|
| 79 | - URL.remove("http://");
|
|---|
| 80 | - URL.remove(QRegExp("[:/].*"));
|
|---|
| 81 | - if (URL.isEmpty())
|
|---|
| 82 | - return false;
|
|---|
| 83 | -
|
|---|
| 84 | - VERBOSE(VB_UPNP, "Trying default DB credentials at " + URL);
|
|---|
| 85 | - m_DBparams.dbHostName = URL;
|
|---|
| 86 | -
|
|---|
| 87 | - return true;
|
|---|
| 88 | + return false;
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | /// If another thread has already started WOL process, wait on them...
|
|---|