Ticket #5276: zoneminder_monitor_function_v1.patch
File zoneminder_monitor_function_v1.patch, 9.1 KB (added by , 16 years ago) |
---|
-
mythzmserver/zmserver.h
147 147 void handleDeleteEventList(vector<string> tokens); 148 148 void handleGetEventDates(vector<string> tokens); 149 149 void handleRunZMAudit(void); 150 void handleSetMonitorFunction(vector<string> tokens); 150 151 151 152 bool m_debug; 152 153 int m_sock; -
mythzmserver/zmserver.cpp
55 55 #define ERROR_FILE_OPEN "Cannot open event file" 56 56 #define ERROR_INVALID_MONITOR "Invalid Monitor" 57 57 #define ERROR_INVALID_POINTERS "Cannot get shared memory pointers" 58 #define ERROR_INVALID_MONITOR_FUNCTION "Invalid Monitor Function" 58 59 59 60 MYSQL g_dbConn; 60 61 string g_zmversion = ""; … … 303 304 handleDeleteEventList(tokens); 304 305 else if (tokens[0] == "RUN_ZMAUDIT") 305 306 handleRunZMAudit(); 307 else if (tokens[0] == "SET_MONITOR_FUNCTION") 308 handleSetMonitorFunction(tokens); 306 309 else 307 310 send("UNKNOWN_COMMAND"); 308 311 } … … 1402 1405 1403 1406 return result; 1404 1407 } 1408 1409 void ZMServer::handleSetMonitorFunction(vector<string> tokens) 1410 { 1411 if (tokens.size() != 3) 1412 { 1413 sendError(ERROR_TOKEN_COUNT); 1414 return; 1415 } 1416 1417 string monitorID(tokens[1]); 1418 string function(tokens[2]); 1419 1420 if (m_debug) 1421 cout << "Updating monitor function. Monitor: " << monitorID << " to perform function: " << function << endl; 1422 1423 // Check validity of input passed to server. Does monitor exist && is function ok 1424 if (m_monitors.find(atoi(monitorID.c_str())) == m_monitors.end()) 1425 { 1426 sendError(ERROR_INVALID_MONITOR); 1427 return; 1428 } 1429 1430 if (function != "None" && function != "Monitor" && 1431 function != "Modect" && function != "Nodect" && 1432 function != "Record" && function != "Mocord") 1433 { 1434 sendError(ERROR_INVALID_MONITOR_FUNCTION); 1435 return; 1436 } 1437 1438 string sql("UPDATE Monitors "); 1439 sql += "SET Function = '" + function + "' "; 1440 sql += "WHERE Id = '" + monitorID + "'"; 1441 1442 if (mysql_query(&g_dbConn, sql.c_str())) 1443 { 1444 fprintf(stderr, "%s\n", mysql_error(&g_dbConn)); 1445 sendError(ERROR_MYSQL_QUERY); 1446 return; 1447 } 1448 1449 if (m_debug) 1450 cout << "Updating monitor function complete" << endl; 1451 1452 string outStr(""); 1453 ADD_STR(outStr, "OK") 1454 send(outStr); 1455 } 1456 -
mythzoneminder/zmconsole.cpp
177 177 { 178 178 handled = false; 179 179 } 180 else if (action == "SELECT") 181 { 182 VERBOSE(VB_GENERAL, "SELECT pressed on frontend"); 183 showMenu(); 184 } 180 185 else 181 186 handled = false; 182 187 } … … 185 190 MythThemedDialog::keyPressEvent(e); 186 191 } 187 192 193 void ZMConsole::showMenu() 194 { 195 menu = new MythPopupBox(GetMythMainWindow(),"popupMenu"); 196 197 /* QButton *temp = menu->addButton(tr("Monitor"), this, 198 SLOT(setMonitorFunction("Monitor"))); 199 menu->addButton(tr("Modect"), this, 200 SLOT(setMonitorFunction("Modect"))); 201 menu->addButton(tr("Record"), this, 202 SLOT(setMonitorFunction("Record"))); 203 menu->addButton(tr("Mocord"), this, 204 SLOT(setMonitorFunction("Mocord"))); 205 menu->addButton(tr("Nocord"), this, 206 SLOT(setMonitorFunction("Nocord"))); 207 menu->addButton(tr("None"), this, 208 SLOT(setMonitorFunction("None")));*/ 209 210 QButton *temp = menu->addButton(tr("Monitor"), this, 211 SLOT(setFunctionMonitor())); 212 menu->addButton(tr("Modect"), this, 213 SLOT(setFunctionModect())); 214 menu->addButton(tr("Record"), this, 215 SLOT(setFunctionRecord())); 216 menu->addButton(tr("Mocord"), this, 217 SLOT(setFunctionMocord())); 218 menu->addButton(tr("Nodect"), this, 219 SLOT(setFunctionNodect())); 220 menu->addButton(tr("None"), this, 221 SLOT(setFunctionNone())); 222 223 menu->addButton(tr("Cancel"), this, SLOT(cancelMenu())); 224 temp->setFocus(); 225 226 menu->ShowPopup(this, SLOT(cancelMenu())); 227 } 228 229 void ZMConsole::cancelMenu() 230 { 231 if (menu) 232 { 233 menu->deleteLater(); 234 menu=NULL; 235 } 236 } 237 238 void ZMConsole::setFunctionMonitor() 239 { 240 cancelMenu(); 241 setMonitorFunction(FUNCTION_MONITOR); 242 } 243 244 void ZMConsole::setFunctionModect() 245 { 246 cancelMenu(); 247 setMonitorFunction(FUNCTION_MODECT); 248 } 249 250 void ZMConsole::setFunctionNodect() 251 { 252 cancelMenu(); 253 setMonitorFunction(FUNCTION_NODECT); 254 } 255 256 void ZMConsole::setFunctionRecord() 257 { 258 cancelMenu(); 259 setMonitorFunction(FUNCTION_RECORD); 260 } 261 262 void ZMConsole::setFunctionMocord() 263 { 264 cancelMenu(); 265 setMonitorFunction(FUNCTION_MOCORD); 266 } 267 268 void ZMConsole::setFunctionNone() 269 { 270 cancelMenu(); 271 setMonitorFunction(FUNCTION_NONE); 272 } 273 188 274 UITextType* ZMConsole::getTextType(QString name) 189 275 { 190 276 UITextType* type = getUITextType(name); … … 284 370 updateMonitorList(); 285 371 } 286 372 } 373 374 void ZMConsole::setMonitorFunction(const QString &function) 375 { 376 if (class ZMClient *zm = ZMClient::get()) 377 { 378 zm->getMonitorList(m_monitorList); 379 380 Monitor *currentMonitor = NULL; 381 382 if (m_currentMonitor < (int) m_monitorList->size()) 383 currentMonitor = m_monitorList->at(m_currentMonitor); 384 385 if (currentMonitor == NULL) 386 { 387 VERBOSE(VB_IMPORTANT, "Monitor not found error"); 388 return; 389 } 390 391 zm->setMonitorFunction(currentMonitor->id, function); 392 updateStatus(); 393 } 394 } 395 -
mythzoneminder/zmconsole.h
40 40 void getDaemonStatus(); 41 41 void getMonitorStatus(void); 42 42 43 void setFunctionMonitor(); 44 void setFunctionModect(); 45 void setFunctionNodect(); 46 void setFunctionRecord(); 47 void setFunctionMocord(); 48 void setFunctionNone(); 49 50 void showMenu(); 51 void cancelMenu(); 52 43 53 private: 44 54 void wireUpTheme(void); 45 55 UITextType* getTextType(QString name); … … 48 58 void monitorListDown(bool page); 49 59 void monitorListUp(bool page); 50 60 61 void setMonitorFunction(const QString &function); 62 51 63 int m_currentMonitor; 52 64 int m_monitorListSize; 53 65 vector<Monitor *> *m_monitorList; 54 66 UIListType *m_monitor_list; 55 67 68 MythPopupBox *menu; 69 56 70 UITextType *m_status_text; 57 71 UITextType *m_time_text; 58 72 UITextType *m_date_text; -
mythzoneminder/zmclient.cpp
655 655 .arg(item->name).arg(item->id).arg(item->palette)); 656 656 } 657 657 } 658 659 void ZMClient::setMonitorFunction(int monitorID, const QString &function) 660 { 661 QStringList strList("SET_MONITOR_FUNCTION"); 662 strList << QString::number(monitorID); 663 strList << function; 664 665 VERBOSE(VB_GENERAL, "ZMClient::setMonitorFunction : " + strList[0] + strList[1] + strList[2]); 666 667 if (!sendReceiveStringList(strList)) 668 return; 669 670 bool bOK; 671 strList[1].toInt(&bOK); 672 if (!bOK) 673 { 674 VERBOSE(VB_IMPORTANT, "ZMClient received bad int in setMonitorFunction()"); 675 return; 676 } 677 } 678 -
mythzoneminder/zmdefines.h
19 19 #include <qstring.h> 20 20 #include <qrect.h> 21 21 22 const QString FUNCTION_MONITOR = "Monitor"; 23 const QString FUNCTION_MODECT = "Modect"; 24 const QString FUNCTION_NODECT = "Nodect"; 25 const QString FUNCTION_RECORD = "Record"; 26 const QString FUNCTION_MOCORD = "Mocord"; 27 const QString FUNCTION_NONE = "None"; 28 22 29 // event details 23 30 typedef struct 24 31 { -
mythzoneminder/zmclient.h
62 62 void getMonitorList(vector<Monitor*> *monitorList); 63 63 void getEventDates(const QString &monitorName, bool oldestFirst, 64 64 QStringList &dateList); 65 void setMonitorFunction(int monitorID, const QString &function); 65 66 66 67 private slots: 67 68 void restartConnection(void); // Try to re-establish the connection to