Skip to content

Commit

Permalink
MythZoneminder: Fix remote camera source display on the status page.
Browse files Browse the repository at this point in the history
This just updates the server to get the correct details for remote cameras. I
can't actually test this since all my cameras are local but it look correct to
me. Fixes #9695.

Signed-off-by: Paul Harrison <pharrison@mythtv.org>
  • Loading branch information
bceylon authored and Paul Harrison committed Aug 17, 2011
1 parent e4bccbc commit e7003f9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
42 changes: 28 additions & 14 deletions mythplugins/mythzoneminder/mythzmserver/zmserver.cpp
Expand Up @@ -604,7 +604,7 @@ void ZMServer::handleGetMonitorStatus(void)
MYSQL_RES *res;
MYSQL_ROW row;

string sql("SELECT id, name, type, device, channel, function, enabled "
string sql("SELECT Id, Name, Type, Device, Host, Channel, Function, Enabled "
"FROM Monitors;");
if (mysql_query(&g_dbConn, sql.c_str()))
{
Expand Down Expand Up @@ -633,14 +633,15 @@ void ZMServer::handleGetMonitorStatus(void)
string id = row[0];
string type = row[2];
string device = row[3];
string channel = row[4];
string function = row[5];
string enabled = row[6];
string host = row[4];
string channel = row[5];
string function = row[6];
string enabled = row[7];
string name = row[1];
string events = "";
string zmcStatus = "";
string zmaStatus = "";
getMonitorStatus(id, type, device, channel, function,
getMonitorStatus(id, type, device, host, channel, function,
zmcStatus, zmaStatus, enabled);
MYSQL_RES *res2;
MYSQL_ROW row2;
Expand Down Expand Up @@ -707,7 +708,7 @@ string ZMServer::runCommand(string command)
return outStr;
}

void ZMServer::getMonitorStatus(string id, string type, string device, string channel,
void ZMServer::getMonitorStatus(string id, string type, string device, string host, string channel,
string function, string &zmcStatus, string &zmaStatus,
string enabled)
{
Expand All @@ -717,12 +718,24 @@ void ZMServer::getMonitorStatus(string id, string type, string device, string ch
string command(g_binPath + "/zmdc.pl status");
string status = runCommand(command);

if (enabled == "0")
zmaStatus = device + "(" + channel + ") [-]";
else if (status.find("'zma -m " + id + "' running") != string::npos)
zmaStatus = device + "(" + channel + ") [R]";
if (type == "Local")
{
if (enabled == "0")
zmaStatus = device + "(" + channel + ") [-]";
else if (status.find("'zma -m " + id + "' running") != string::npos)
zmaStatus = device + "(" + channel + ") [R]";
else
zmaStatus = device + "(" + channel + ") [S]";
}
else
zmaStatus = device + "(" + channel + ") [S]";
{
if (enabled == "0")
zmaStatus = host + " [-]";
else if (status.find("'zma -m " + id + "' running") != string::npos)
zmaStatus = host + " [R]";
else
zmaStatus = host + " [S]";
}

if (type == "Local")
{
Expand Down Expand Up @@ -1234,7 +1247,7 @@ void ZMServer::getMonitorList(void)
m_monitors.clear();

string sql("SELECT Id, Name, Width, Height, ImageBufferCount, MaxFPS, Palette, ");
sql += " Type, Function, Enabled, Device, Controllable, TrackMotion ";
sql += " Type, Function, Enabled, Device, Host, Controllable, TrackMotion ";
sql += "FROM Monitors";

MYSQL_RES *res;
Expand Down Expand Up @@ -1268,8 +1281,9 @@ void ZMServer::getMonitorList(void)
m->function = row[8];
m->enabled = atoi(row[9]);
m->device = row[10];
m->controllable = atoi(row[11]);
m->trackMotion = atoi(row[12]);
m->host = row[11];
m->controllable = atoi(row[12]);
m->trackMotion = atoi(row[13]);
m_monitors[m->mon_id] = m;

initMonitor(m);
Expand Down
3 changes: 2 additions & 1 deletion mythplugins/mythzoneminder/mythzmserver/zmserver.h
Expand Up @@ -116,6 +116,7 @@ typedef struct
string function;
int enabled;
string device;
string host;
int image_buffer_count;
int width;
int height;
Expand Down Expand Up @@ -165,7 +166,7 @@ class ZMServer
void tokenize(const string &command, vector<string> &tokens);
void handleHello(void);
string runCommand(string command);
void getMonitorStatus(string id, string type, string device, string channel,
void getMonitorStatus(string id, string type, string device, string host, string channel,
string function, string &zmcStatus, string &zmaStatus,
string enabled);
void handleGetServerStatus(void);
Expand Down

0 comments on commit e7003f9

Please sign in to comment.