diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index a690ed6c7..58148b2b1 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -4413,3 +4413,36 @@ void Monitor::SingleImageZip( int scale) fprintf( stdout, "Content-Type: image/x-rgbz\r\n\r\n" ); fwrite( img_buffer, img_buffer_size, 1, stdout ); } + +#if ZM_PLUGINS_ON +void Monitor::DumpPluginStatus() +{ + map mapPluginGenConf; + unsigned int nNumPlugins = ThePluginManager.getPluginsGenConf(mapPluginGenConf); + bool bDoNativeDet = !config.turnoff_native_analysis && iDoNativeMotDet; + + if ( nNumPlugins == 0) + { + printf("No plugin found\n"); + return; + } + printf("%79sNATIVE DETECTION\n", " "); + printf("PLUGIN NAME%*sREGISTERED CONFIGURED ZONE ENABLED ACTIVE REQUIRE INCLUDE REINIT\n", 19, " "); + for (map::iterator it = mapPluginGenConf.begin() ; it != mapPluginGenConf.end(); ++it) + { + PluginZoneConf mapPluginZoneConf; + ThePluginManager.getPluginZoneConf( it->first, mapPluginZoneConf ); + int padLen = 34 - it->first.length(); + if(padLen < 0) padLen = 0; + printf("%s%*s%d%*s%d%*s", it->first.c_str(), padLen, " ", it->second.Registered, 10, " ", it->second.Configured, 8, " "); + for (PluginZoneConf::iterator it2 = mapPluginZoneConf.begin() ; it2 != mapPluginZoneConf.end(); ++it2) + { + if (it2 != mapPluginZoneConf.begin()) + printf("%*s", 54, " "); + bool bIsActive = it2->second.Enabled && ( !it2->second.RequireNatDet || ( it2->second.RequireNatDet && bDoNativeDet ) ); + printf("%d%*s%d%*s%d%*s%d%*s%d%*s%d\n", it2->first, 7, " ", it2->second.Enabled, 7, " ", bIsActive, 8, " ", it2->second.RequireNatDet, 7, " ", it2->second.IncludeNatDet, 6, " ", it2->second.ReInitNatDet); + } + } + ThePluginManager.getImageAnalyser().cleanupPlugins(); +} +#endif // ZM_PLUGINS_ON diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 733147293..dccaf5f29 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -410,6 +410,8 @@ public: bool DumpSettings( char *output, bool verbose ); void DumpZoneImage( const char *zone_string=0 ); + void DumpPluginStatus(); + #if ZM_HAS_V4L static int LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose purpose ); #endif // ZM_HAS_V4L diff --git a/src/zmu.cpp b/src/zmu.cpp index bc032639f..1dcfd363a 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -68,7 +68,9 @@ void Usage( int status=-1 ) fprintf( stderr, " -U, --username : When running in authenticated mode the username and\n" ); fprintf( stderr, " -P, --password : password combination of the given user\n" ); fprintf( stderr, " -A, --auth : Pass authentication hash string instead of user details\n" ); - +#if ZM_PLUGINS_ON + fprintf( stderr, " -p, --plugin-status : Display the status of detected plugins\n" ); +#endif // ZM_PLUGINS_ON exit( status ); } @@ -96,6 +98,7 @@ typedef enum { ZMU_SUSPEND = 0x00400000, ZMU_RESUME = 0x00800000, ZMU_LIST = 0x10000000, + ZMU_LIST_PLUG = 0x20000000 } Function; bool ValidateAccess( User *user, int mon_id, int function ) @@ -111,7 +114,7 @@ bool ValidateAccess( User *user, int mon_id, int function ) if ( user->getEvents() < User::PERM_VIEW ) allowed = false; } - if ( function & (ZMU_ZONES|ZMU_QUERY|ZMU_LIST) ) + if ( function & (ZMU_ZONES|ZMU_QUERY|ZMU_LIST|ZMU_LIST_PLUG) ) { if ( user->getMonitors() < User::PERM_VIEW ) allowed = false; @@ -174,6 +177,9 @@ int main( int argc, char *argv[] ) {"version", 1, 0, 'V'}, {"help", 0, 0, 'h'}, {"list", 0, 0, 'l'}, +#if ZM_PLUGINS_ON + {"list_plugins", 0, 0, 'p'}, +#endif // ZM_PLUGINS_ON {0, 0, 0, 0} }; @@ -203,7 +209,7 @@ int main( int argc, char *argv[] ) { int option_index = 0; - int c = getopt_long (argc, argv, "d:m:vsEDLurwei::S:t::fz::ancqhlB::C::H::O::U:P:A:V:", long_options, &option_index); + int c = getopt_long (argc, argv, "d:m:vsEDLurwei::S:t::fz::ancqhlpB::C::H::O::U:P:A:V:", long_options, &option_index); if (c == -1) { break; @@ -321,6 +327,11 @@ int main( int argc, char *argv[] ) case 'l': function |= ZMU_LIST; break; +#if ZM_PLUGINS_ON + case 'p': + function |= ZMU_LIST_PLUG; + break; +#endif // ZM_PLUGINS_ON case '?': Usage(); break; @@ -409,7 +420,7 @@ int main( int argc, char *argv[] ) if ( mon_id > 0 ) { - Monitor *monitor = Monitor::Load( mon_id, function&(ZMU_QUERY|ZMU_ZONES), Monitor::QUERY ); + Monitor *monitor = Monitor::Load( mon_id, function&(ZMU_QUERY|ZMU_ZONES|ZMU_LIST_PLUG), Monitor::QUERY ); if ( monitor ) { if ( verbose ) @@ -649,6 +660,12 @@ int main( int argc, char *argv[] ) have_output = true; } } +#if ZM_PLUGINS_ON + if ( function & ZMU_LIST_PLUG ) + { + monitor->DumpPluginStatus(); + } +#endif // ZM_PLUGINS_ON if ( have_output ) { printf( "\n" );