Permalink
Browse files

Add QUERY_ACTIVE_BACKENDS call to backend protocol.

This adds a new call to the backend protocol to enumerate a list of all
currently available backends, intended for use when scanning for
non-recorded content on multiple backends. This allows offline backends
to be skipped outright, rather than having to attempt connection and
wait for a timeout.

This bumps the protocol version to 72.
  • Loading branch information...
wagnerrp committed Jan 29, 2012
1 parent 7409d30 commit 7a94153c8cbd637e6b84ead48e3fedcfb94b0241
@@ -106,8 +106,8 @@ package MythTV;
# Note: as of July 21, 2010, this is actually a string, to account for proto
# versions of the form "58a". This will get used if protocol versions are
# changed on a fixes branch ongoing.
- our $PROTO_VERSION = "71";
- our $PROTO_TOKEN = "05e82186";
+ our $PROTO_VERSION = "72";
+ our $PROTO_TOKEN = "D78EFD6F";
# currentDatabaseVersion is defined in libmythtv in
# mythtv/libs/libmythtv/dbcheck.cpp and should be the current MythTV core
@@ -11,8 +11,8 @@ class MythBackend {
// MYTH_PROTO_VERSION is defined in libmyth in mythtv/libs/libmyth/mythcontext.h
// and should be the current MythTV protocol version.
- static $protocol_version = '71';
- static $protocol_token = '05e82186';
+ static $protocol_version = '72';
+ static $protocol_token = 'D78EFD6F';
// The character string used by the backend to separate records
static $backend_separator = '[]:[]';
@@ -8,8 +8,8 @@
SCHEMA_VERSION = 1293
NVSCHEMA_VERSION = 1007
MUSICSCHEMA_VERSION = 1018
-PROTO_VERSION = '71'
-PROTO_TOKEN = '05e82186'
+PROTO_VERSION = '72'
+PROTO_TOKEN = 'D78EFD6F'
BACKEND_SEP = '[]:[]'
INSTALL_PREFIX = '/usr/local'
@@ -35,8 +35,8 @@
* mythtv/bindings/python/MythTV/static.py (version number)
* mythtv/bindings/python/MythTV/mythproto.py (layout)
*/
-#define MYTH_PROTO_VERSION "71"
-#define MYTH_PROTO_TOKEN "05e82186"
+#define MYTH_PROTO_VERSION "72"
+#define MYTH_PROTO_TOKEN "D78EFD6F"
/** \brief Increment this whenever the MythTV core database schema changes.
*
@@ -50,6 +50,9 @@
*
* MythTV Python Bindings
* mythtv/bindings/python/MythTV/static.py
+ *
+ * MythTV PHP Bindings
+ * mythtv/bindings/php/MythBackend.php
*/
#define MYTH_DATABASE_VERSION "1293"
@@ -674,6 +674,10 @@ void MainServer::ProcessRequestWork(MythSocket *sock)
else
HandleFreeTuner(tokens[1].toInt(), pbs);
}
+ else if (command == "QUERY_ACTIVE_BACKENDS")
+ {
+ HandleActiveBackendsQuery(pbs);
+ }
else if (command == "QUERY_IS_ACTIVE_BACKEND")
{
if (tokens.size() != 1)
@@ -4244,6 +4248,30 @@ void MainServer::HandleRemoteEncoder(QStringList &slist, QStringList &commands,
SendResponse(pbssock, retlist);
}
+void MainServer::HandleActiveBackendsQuery(QPlaybackSock *pbs)
+{
+ QStringList retlist;
+ retlist << gCoreContext->GetHostName();
+
+ {
+ QString hostname;
+ QReadLocker rlock(&sockListLock);
+ vector<PlaybackSock*>::iterator it;
+ for (it = playbackList.begin(); it != playbackList.end(); ++it)
+ {
+ if ((*it)->isSlaveBackend())
+ {
+ hostname = (*it)->getHostname();
+ if (!retlist.contains(hostname))
+ retlist << hostname;
+ }
+ }
+ }
+
+ retlist.push_front(QString::number(retlist.size()));
+ SendResponse(pbs->getSocket(), retlist);
+}
+
void MainServer::HandleIsActiveBackendQuery(QStringList &slist,
PlaybackSock *pbs)
{
@@ -142,6 +142,7 @@ class MainServer : public QObject, public MythSocketCBs
MythSocket *socket);
void HandleDone(MythSocket *socket);
+ void HandleActiveBackendsQuery(PlaybackSock *pbs);
void HandleIsActiveBackendQuery(QStringList &slist, PlaybackSock *pbs);
bool HandleDeleteFile(QStringList &slist, PlaybackSock *pbs);
bool HandleDeleteFile(QString filename, QString storagegroup,

0 comments on commit 7a94153

Please sign in to comment.