UserAf::UserAf( JSON & i_object): af::User(), AfNodeSrv( this) { jsonRead( i_object); }
void RenderAf::v_action( Action & i_action) { const JSON & operation = (*i_action.data)["operation"]; if( operation.IsObject()) { std::string type; af::jr_string("type", type, operation); if( type == "exit") { if( false == isOnline()) return; appendLog("Exit by " + i_action.author); exitClient("exit", i_action.jobs, i_action.monitors); return; } else if( type == "launch_cmd") { if( false == isOnline()) return; std::string cmd; if( af::jr_string("cmd", cmd, operation)) { bool exit = false; af::jr_bool("exit", exit, operation); if( exit ) appendLog("Launch command and exit request by " + i_action.author + "\n" + cmd); else appendLog("Launch command request by " + i_action.author + "\n" + cmd); launchAndExit( cmd, exit, i_action.jobs, i_action.monitors); } else { appendLog("Launch command exit request by " + i_action.author + "has no 'cmd'"); } return; } else if( type == "eject_tasks") { if( false == isBusy()) return; appendLog("Task(s) ejected by " + i_action.author); ejectTasks( i_action.jobs, i_action.monitors, af::TaskExec::UPEject); return; } else if( type == "eject_tasks_keep_my") { if( false == isBusy()) return; appendLog("Task(s) ejected keeping own by " + i_action.author); ejectTasks( i_action.jobs, i_action.monitors, af::TaskExec::UPEject, &i_action.user_name); return; } else if( type == "delete") { if( isOnline() ) return; appendLog( std::string("Deleted by ") + i_action.author); offline( NULL, 0, i_action.monitors, true); //AFCommon::QueueDBDelItem( this); return; } else if( type == "reboot") { if( false == isOnline() ) return; appendLog( std::string("Reboot computer by ") + i_action.author); exitClient("reboot", i_action.jobs, i_action.monitors); return; } else if( type == "shutdown") { if( false == isOnline() ) return; appendLog( std::string("Shutdown computer by ") + i_action.author); exitClient("shutdown", i_action.jobs, i_action.monitors); return; } else if( type == "wol_sleep") wolSleep( i_action.monitors); else if( type == "wol_wake") wolWake( i_action.monitors); else if( type == "service") { af::RegExp service_mask; bool enable; af::jr_regexp("name", service_mask, operation); af::jr_bool("enable", enable, operation); for (int i = 0 ; i < m_host.getServicesNum() ; ++i) { std::string service = m_host.getServiceName(i); if( service_mask.match( service)) setService( service, enable); } } else if( type == "restore_defaults") { m_max_tasks = -1; m_capacity = -1; m_services_disabled.clear(); disableServices(); // Dirty check exists in that function } else { appendLog("Unknown operation \"" + type + "\" by " + i_action.author); return; } appendLog("Operation \"" + type + "\" by " + i_action.author); i_action.monitors->addEvent( af::Monitor::EVT_renders_change, m_id); store(); return; } const JSON & params = (*i_action.data)["params"]; if( params.IsObject()) jsonRead( params, &i_action.log); if( i_action.log.size() ) { store(); i_action.monitors->addEvent( af::Monitor::EVT_renders_change, m_id); } }