Skip to content

Commit

Permalink
Add QUERY_ACTIVE_BACKENDS call to backend protocol.
Browse files Browse the repository at this point in the history
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 7a94153
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
4 changes: 2 additions & 2 deletions mythtv/bindings/perl/MythTV.pm
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mythtv/bindings/php/MythBackend.php
Expand Up @@ -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 = '[]:[]';
Expand Down
4 changes: 2 additions & 2 deletions mythtv/bindings/python/MythTV/static.py
Expand Up @@ -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'

Expand Down
7 changes: 5 additions & 2 deletions mythtv/libs/libmythbase/mythversion.h
Expand Up @@ -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.
*
Expand All @@ -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"

Expand Down
28 changes: 28 additions & 0 deletions mythtv/programs/mythbackend/mainserver.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions mythtv/programs/mythbackend/mainserver.h
Expand Up @@ -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,
Expand Down

0 comments on commit 7a94153

Please sign in to comment.