void HostReflectionHost::BootUp::_addMessageHandlers() { addHandler(OpenFileMessageHandler, handleOpenFile); addHandler(TeardownFileMessageHandler, handleTeardownFile); addHandler(FileWriteMessageHandler, handleFileWrite); addHandler(FileReadMessageHandler, handleFileRead); addHandler(KernelLaunchMessageHandler, handleKernelLaunch); }
C::List::List(const W::Address p_address, QObject* parent): C::Controller(p_address, W::Address({W::String(u"list") + counter++}), parent), data() { W::Handler* get = W::Handler::create(address + W::Address({u"get"}), this, &C::List::_h_get); W::Handler* push = W::Handler::create(address + W::Address({u"push"}), this, &C::List::_h_push); W::Handler* clear = W::Handler::create(address + W::Address({u"clear"}), this, &C::List::_h_clear); addHandler(get); addHandler(push); addHandler(clear); }
/** Associates the RequestHandlers with their URIs. * */ void RequestManager::insertDefaultHandlers(){ addHandler(reqRegister.getUri(), &reqRegister); addHandler(reqLogin.getUri(), &reqLogin); addHandler(reqEditProfile.getUri(), &reqEditProfile); addHandler(reqPossibleMatches.getUri(), &reqPossibleMatches); addHandler(reqMatches.getUri(), &reqMatches); addHandler(reqGetConversation.getUri(), &reqGetConversation); addHandler(reqSendConversation.getUri(), &reqSendConversation); addHandler(reqLike.getUri(), &reqLike); addHandler(reqDislike.getUri(), &reqDislike); addHandler(reqCheckToken.getUri(), &reqCheckToken); }
void AsyncWebServer::on(const char* uri, WebRequestMethod method, ArRequestHandlerFunction onRequest){ AsyncCallbackWebHandler* handler = new AsyncCallbackWebHandler(); handler->setUri(uri); handler->setMethod(method); handler->onRequest(onRequest); addHandler(handler); }
AsyncCallbackWebHandler& AsyncWebServer::on(const char* uri, ArRequestHandlerFunction onRequest){ AsyncCallbackWebHandler* handler = new AsyncCallbackWebHandler(); handler->setUri(uri); handler->onRequest(onRequest); addHandler(handler); return *handler; }
C::String::String(const W::Address p_address, QObject* parent): C::Controller(p_address, W::Address({W::String(u"string") + counter++}), parent), data(u"") { W::Handler* get = W::Handler::create(address + W::Address({u"get"}), this, &C::String::_h_get); addHandler(get); }
bool EventLogger::open(const char* logFileName, int maxNoFiles, long maxFileSize, unsigned int maxLogEntries) { return addHandler(new FileLogHandler(logFileName, maxNoFiles, maxFileSize, maxLogEntries)); }
void EventManager::addHandler(void (*handlerFunction)(), unsigned int period, unsigned int delay) { EventHandler* handler = static_cast<EventHandler*>(malloc(sizeof(EventHandler))); handler->callback_ = functionCallback(handlerFunction); handler->period_ = period; handler->countdown_ = delay; addHandler(handler); }
bool Logger::createSyslogHandler() { #ifdef _WIN32 return false; #else Guard g(m_handler_mutex); if (m_pSyslogHandler) return true; // Ok, already exist LogHandler* log_handler = new SysLogHandler(); if (!log_handler) return false; if (!addHandler(log_handler)) { delete log_handler; return false; } m_pSyslogHandler = log_handler; return true; #endif }
int32_t IOLoop::addSignalHandler(int signum, HandlerCallback&& handler) { sigset_t mask; sigemptyset(&mask); sigaddset(&mask, signum); // block watched signals: otherwise the default handler is called if(sigprocmask(SIG_BLOCK, &mask, 0)) { TORNADO_LOG_ERROR("sigprocmask faild err=%s", STR_ERRNO); return -1; } int32_t sfd = signalfd(-1, &mask, SFD_NONBLOCK | SFD_CLOEXEC); if(sfd < 0) { TORNADO_LOG_ERROR("signalfd faild err=%s", STR_ERRNO); return sfd; } if( addHandler(sfd, std::move(handler), IOLoop::READ) ) { TORNADO_LOG_ERROR("addHandler faild sfd=%d", sfd); removeHandler(sfd); ::close(sfd); return -1; } return sfd; }
void addBlockingHandler(const std::string& prefix, const UriHandlerFunction& handler) { BOOST_ASSERT(!running_); addHandler(prefix, boost::bind(handleAsyncConnectionSynchronously, handler, _1)); }
TextInput::TextInput(form* parent, int x, int y, int w, int h, string message):form(x,y,w,h,parent){ title = new label(this,0,30,width,30); title->text = message; text = new textBox(this,10,70,width-20,30); this->message = message; Accept = new Button(this,width-100,110,90,40); Accept->text = "Done"; Cancel = new Button(this,width-200,110,90,40); Cancel->text = "Cancel"; addHandler(event_losefocus,close); }
AsyncCallbackWebHandler& AsyncWebServer::on(const char* uri, WebRequestMethodComposite method, ArRequestHandlerFunction onRequest, ArUploadHandlerFunction onUpload){ AsyncCallbackWebHandler* handler = new AsyncCallbackWebHandler(); handler->setUri(uri); handler->setMethod(method); handler->onRequest(onRequest); handler->onUpload(onUpload); addHandler(handler); return *handler; }
KXErrorHandler::KXErrorHandler(int (*handler)(Display *, XErrorEvent *), Display *dpy) : user_handler1(NULL) , user_handler2(handler) , old_handler(XSetErrorHandler(handler_wrapper)) , first_request(XNextRequest(dpy)) , display(dpy) , was_error(false) { addHandler(); }
KXErrorHandler::KXErrorHandler(bool (*handler)(int request, int error_code, unsigned long resource_id), Display *dpy) : user_handler1(handler) , user_handler2(NULL) , old_handler(XSetErrorHandler(handler_wrapper)) , first_request(XNextRequest(dpy)) , display(dpy) , was_error(false) { addHandler(); }
bool Logger::addHandler(const BaseString &logstring, int *err, int len, char* errStr) { size_t i; Vector<BaseString> logdest; Vector<LogHandler *>loghandlers; DBUG_ENTER("Logger::addHandler"); logstring.split(logdest, ";"); for(i = 0; i < logdest.size(); i++) { DBUG_PRINT("info",("adding: %s",logdest[i].c_str())); Vector<BaseString> v_type_args; logdest[i].split(v_type_args, ":", 2); BaseString type(v_type_args[0]); BaseString params; if(v_type_args.size() >= 2) params = v_type_args[1]; LogHandler *handler = NULL; #ifndef NDB_WIN32 if(type == "SYSLOG") { handler = new SysLogHandler(); } else #endif if(type == "FILE") handler = new FileLogHandler(); else if(type == "CONSOLE") handler = new ConsoleLogHandler(); if(handler == NULL) { snprintf(errStr,len,"Could not create log destination: %s", logdest[i].c_str()); DBUG_RETURN(false); } if(!handler->parseParams(params)) { *err= handler->getErrorCode(); if(handler->getErrorStr()) strncpy(errStr, handler->getErrorStr(), len); DBUG_RETURN(false); } loghandlers.push_back(handler); } for(i = 0; i < loghandlers.size(); i++) addHandler(loghandlers[i]); DBUG_RETURN(true); /* @todo handle errors */ }
void CCBProxy::handleEvent(CCControl *n, const int handler, bool multiTouches, CCControlEvent e){ #if COCOS2D_VERSION > 0x00020100 n->addHandleOfControlEvent(handler, e); #else LuaEventHandler *h = getHandler(handler); if(!h){ h = addHandler(handler, multiTouches) ->setTypename("CCControlButton"); } n->addTargetWithActionForControlEvents(h, cccontrol_selector(LuaEventHandler::controlAction), e); #endif }
virtual bool initialize() { // root handler RestfulHandlerRef root = new RestfulHandler(); addHandler("/", root); // GET / { PathHandlerRef h = new Handler( this, &TestWebService::handleRequest); root->addHandler(h, Message::Get, 0); } // GET /(.*)/regextest/(.*) { PathHandlerRef h = new Handler( this, &TestWebService::handleRegexRequest); h->addRequestAuthenticator(new AuthHandler( this, &TestWebService::authenticate)); root->addRegexHandler("/(.*)/regextest/(.*)", h, Message::Get); } // GET /(.*)/regextest2/(.*) { DynamicObject userData; userData["foo"] = "bar"; PathHandlerRef h = new Handler( this, &TestWebService::handleRegexRequest2); h->addRequestAuthenticator(new AuthHandler( this, &TestWebService::authenticate2, userData)); root->addRegexHandler("/(.*)/regextest2/(.*)", h, Message::Get); } // GET /(.*)/regextest3/(.*) { PathHandlerRef h = new Handler( this, &TestWebService::handleRegexRequest2); // test authenticator always failing due to failed attempts by // client to authenticate ... even though anonymous is an accepted // method h->addRequestAuthenticator(new AuthHandler( this, &TestWebService::authenticate3)); h->addRequestAuthenticator(NULL); root->addRegexHandler("/(.*)/regextest3/(.*)", h, Message::Get); } return true; }
bool Logger::createFileHandler() { Guard g(m_handler_mutex); bool rc = true; if (m_pFileHandler == NULL) { m_pFileHandler = new FileLogHandler(); if (!addHandler(m_pFileHandler)) // TODO: check error code { rc = false; delete m_pFileHandler; m_pFileHandler = NULL; } } return rc; }
PrintfScreen::PrintfScreen (const char *caption, ColorEntry norm, ColorEntry sel) : mPR (norm, sel) { int w, h; // screen size // SET CONSOLE TITLE TO OUR COPYRIGHT TITLE SetConsoleTitle (caption); // Handle escape key addHandler (KB_ESC, this, (Handler) &PrintfScreen::handleKbEsc); // Build the scroller getSize (w, h); mScroller = new Scroller (*this, 0, 0, w, h); if (mScroller == 0) throw AppException (WHERE, ERR_OUT_OF_MEMORY); mScroller->setScrollable (&mPR); }
void C2DCalleeDialog::setAuthHandler() { if(cred.get() != NULL) { AmSessionEventHandlerFactory* uac_auth_f = AmPlugIn::instance()->getFactory4Seh("uac_auth"); if (uac_auth_f != NULL) { AmSessionEventHandler *h = uac_auth_f->getHandler(this); if (h != NULL ) { DBG("uac-auth enabled for new callee session.\n"); addHandler(h); } else { ERROR("uac_auth interface not accessible. " "Load uac_auth for authenticated dialout.\n"); } } } }
bool Logger::createConsoleHandler(NdbOut &out) { Guard g(m_handler_mutex); if (m_pConsoleHandler) return true; // Ok, already exist LogHandler* log_handler = new ConsoleLogHandler(out); if (!log_handler) return false; if (!addHandler(log_handler)) { delete log_handler; return false; } m_pConsoleHandler = log_handler; return true; }
bool Logger::createEventLogHandler(const char* source_name) { #ifdef _WIN32 Guard g(m_handler_mutex); LogHandler* log_handler = new EventLogHandler(source_name); if (!log_handler) return false; if (!addHandler(log_handler)) { delete log_handler; return false; } return true; #else return false; #endif }
bool Logger::createFileHandler(char*filename) { Guard g(m_handler_mutex); if (m_pFileHandler) return true; // Ok, already exist LogHandler* log_handler = new FileLogHandler(filename); if (!log_handler) return false; if (!addHandler(log_handler)) { delete log_handler; return false; } m_pFileHandler = log_handler; return true; }
LicenseScreen::LicenseScreen () : mSM (mMsgs, mnMsgs) { int w, h; // screen size // SET CONSOLE TITLE TO OUR COPYRIGHT TITLE #ifdef HERMIT_PRO SetConsoleTitle ("HERMIT PRO Licensing Information"); #else SetConsoleTitle ("HERMIT Licensing Information"); #endif // Handle escape key addHandler (KB_ESC, this, (Handler) &LicenseScreen::handleKbEsc); // Build the scroller getSize (w, h); mScroller = new Scroller (*this, 0, 0, w, h); if (mScroller == 0) throw AppException (WHERE, ERR_OUT_OF_MEMORY); mScroller->setScrollable (&mSM); }
bool Logger::createSyslogHandler() { Guard g(m_handler_mutex); bool rc = true; if (m_pSyslogHandler == NULL) { #if defined NDB_WIN32 m_pSyslogHandler = new ConsoleLogHandler(); #else m_pSyslogHandler = new SysLogHandler(); #endif if (!addHandler(m_pSyslogHandler)) // TODO: check error code { rc = false; delete m_pSyslogHandler; m_pSyslogHandler = NULL; } } return rc; }
void Connector::connected( void ) { if (!_isConnected) { if (!_onConnect.empty()) { printf( "[Connector (%p)] Connected\n", this ); _onConnect(); } _isConnected = true; // Add Keep Alive handler _keepAliveHandler = new KeepAliveHandler(); _keepAliveHandler->onKeepAliveEvent( boost::bind(&Connector::onKeepAliveEvent, this, _1) ); addHandler( connector::messages::keepAlive, _keepAliveHandler ); if (_isServer) { printf( "[Connector (%p)] Launching keep alive timer: interval=%d, retry=%d\n", this, _keepAliveInterval, _maxKeepAliveRetry ); // Launch keep alive timer .... _keepAlive=0; launchTimer( _keepAliveTimer, _keepAliveInterval, &Connector::onKeepAliveIntervalExpired ); } } }
void PaloHttpServer::enableServerInfo(int httpsPort) { addHandler("/server/info", new PaloRequestHandler(true, httpsPort)); addHandler("/server/license", new PaloRequestHandler(true, httpsPort)); addHandler("/server/licenses", new PaloRequestHandler(true, httpsPort)); }
void PaloHttpServer::addBrowserHandlers() { addHandler("/browser", new PaloBrowserHandler(templateDirectory)); addHandler("/browser/cube", new PaloBrowserHandler(templateDirectory)); addHandler("/browser/database", new PaloBrowserHandler(templateDirectory)); addHandler("/browser/dimension", new PaloBrowserHandler(templateDirectory)); addHandler("/browser/element", new PaloBrowserHandler(templateDirectory)); addHandler("/browser/rule", new PaloBrowserHandler(templateDirectory)); addHandler("/browser/analyzer", new PaloBrowserHandler(templateDirectory)); addHandler("/browser/server", new PaloBrowserHandler(templateDirectory)); addHandler("/browser/statistics", new PaloBrowserHandler(templateDirectory)); addHandler("/browser/logfile", new PaloBrowserHandler(templateDirectory)); addHandler("/browser/sessions", new PaloBrowserHandler(templateDirectory)); addHandler("/browser/jobs", new PaloBrowserHandler(templateDirectory)); }
void PaloHttpServer::addDocumentationHandlers(const string& tmpl) { const string d1 = tmpl + ".tmpl"; const string d2 = tmpl + "2.tmpl"; addHandler("/api/server/databases", new DocumentationHandler(d1, templateDirectory + "/server_databases.api")); addHandler("/api/server/info", new DocumentationHandler(d1, templateDirectory + "/server_info.api")); addHandler("/api/server/licenses", new DocumentationHandler(d1, templateDirectory + "/server_licenses.api")); addHandler("/api/server/load", new DocumentationHandler(d1, templateDirectory + "/server_load.api")); addHandler("/api/server/login", new DocumentationHandler(d2, templateDirectory + "/server_login.api")); addHandler("/api/server/logout", new DocumentationHandler(d1, templateDirectory + "/server_logout.api")); addHandler("/api/server/save", new DocumentationHandler(d1, templateDirectory + "/server_save.api")); addHandler("/api/server/shutdown", new DocumentationHandler(d1, templateDirectory + "/server_shutdown.api")); addHandler("/api/server/change_password", new DocumentationHandler(d1, templateDirectory + "/server_change_password.api")); addHandler("/api/server/user_info", new DocumentationHandler(d1, templateDirectory + "/server_user_info.api")); addHandler("/api/server/activate_license", new DocumentationHandler(d1, templateDirectory + "/server_activate_license.api")); addHandler("/api/database/create", new DocumentationHandler(d1, templateDirectory + "/database_create.api")); addHandler("/api/database/cubes", new DocumentationHandler(d1, templateDirectory + "/database_cubes.api")); addHandler("/api/database/destroy", new DocumentationHandler(d1, templateDirectory + "/database_delete.api")); addHandler("/api/database/dimensions", new DocumentationHandler(d1, templateDirectory + "/database_dimensions.api")); addHandler("/api/database/info", new DocumentationHandler(d1, templateDirectory + "/database_info.api")); addHandler("/api/database/load", new DocumentationHandler(d1, templateDirectory + "/database_load.api")); addHandler("/api/database/rename", new DocumentationHandler(d1, templateDirectory + "/database_rename.api")); addHandler("/api/database/save", new DocumentationHandler(d1, templateDirectory + "/database_save.api")); addHandler("/api/database/unload", new DocumentationHandler(d1, templateDirectory + "/database_unload.api")); addHandler("/api/dimension/clear", new DocumentationHandler(d1, templateDirectory + "/dimension_clear.api")); addHandler("/api/dimension/create", new DocumentationHandler(d1, templateDirectory + "/dimension_create.api")); addHandler("/api/dimension/cubes", new DocumentationHandler(d1, templateDirectory + "/dimension_cubes.api")); addHandler("/api/dimension/destroy", new DocumentationHandler(d1, templateDirectory + "/dimension_delete.api")); addHandler("/api/dimension/element", new DocumentationHandler(d1, templateDirectory + "/dimension_element.api")); addHandler("/api/dimension/elements", new DocumentationHandler(d1, templateDirectory + "/dimension_elements.api")); addHandler("/api/dimension/info", new DocumentationHandler(d1, templateDirectory + "/dimension_info.api")); addHandler("/api/dimension/rename", new DocumentationHandler(d1, templateDirectory + "/dimension_rename.api")); addHandler("/api/dimension/dfilter", new DocumentationHandler(d1, templateDirectory + "/dimension_dfilter.api")); addHandler("/api/cube/clear", new DocumentationHandler(d1, templateDirectory + "/cube_clear.api")); addHandler("/api/cube/clear_cache", new DocumentationHandler(d1, templateDirectory + "/cube_clear_cache.api")); addHandler("/api/cube/commit", new DocumentationHandler(d1, templateDirectory + "/cube_commit.api")); addHandler("/api/cube/create", new DocumentationHandler(d1, templateDirectory + "/cube_create.api")); addHandler("/api/cube/convert", new DocumentationHandler(d1, templateDirectory + "/cube_convert.api")); addHandler("/api/cube/destroy", new DocumentationHandler(d1, templateDirectory + "/cube_delete.api")); addHandler("/api/cube/info", new DocumentationHandler(d1, templateDirectory + "/cube_info.api")); addHandler("/api/cube/load", new DocumentationHandler(d1, templateDirectory + "/cube_load.api")); addHandler("/api/cube/lock", new DocumentationHandler(d1, templateDirectory + "/cube_lock.api")); addHandler("/api/cube/locks", new DocumentationHandler(d1, templateDirectory + "/cube_locks.api")); addHandler("/api/cube/rename", new DocumentationHandler(d1, templateDirectory + "/cube_rename.api")); addHandler("/api/cube/rollback", new DocumentationHandler(d1, templateDirectory + "/cube_rollback.api")); addHandler("/api/cube/rules", new DocumentationHandler(d1, templateDirectory + "/cube_rules.api")); addHandler("/api/cube/save", new DocumentationHandler(d1, templateDirectory + "/cube_save.api")); addHandler("/api/cube/unload", new DocumentationHandler(d1, templateDirectory + "/cube_unload.api")); addHandler("/api/element/append", new DocumentationHandler(d1, templateDirectory + "/element_append.api")); addHandler("/api/element/create", new DocumentationHandler(d1, templateDirectory + "/element_create.api")); addHandler("/api/element/create_bulk", new DocumentationHandler(d1, templateDirectory + "/element_create_bulk.api")); addHandler("/api/element/destroy", new DocumentationHandler(d1, templateDirectory + "/element_delete.api")); addHandler("/api/element/destroy_bulk", new DocumentationHandler(d1, templateDirectory + "/element_delete_bulk.api")); addHandler("/api/element/info", new DocumentationHandler(d1, templateDirectory + "/element_info.api")); addHandler("/api/element/move", new DocumentationHandler(d1, templateDirectory + "/element_move.api")); addHandler("/api/element/move_bulk", new DocumentationHandler(d1, templateDirectory + "/element_move_bulk.api")); addHandler("/api/element/rename", new DocumentationHandler(d1, templateDirectory + "/element_rename.api")); addHandler("/api/element/replace", new DocumentationHandler(d1, templateDirectory + "/element_replace.api")); addHandler("/api/element/replace_bulk", new DocumentationHandler(d1, templateDirectory + "/element_replace_bulk.api")); addHandler("/api/cell/area", new DocumentationHandler(d1, templateDirectory + "/cell_area.api")); addHandler("/api/cell/copy", new DocumentationHandler(d1, templateDirectory + "/cell_copy.api")); addHandler("/api/cell/drillthrough", new DocumentationHandler(d1, templateDirectory + "/cell_drillthrough.api")); addHandler("/api/cell/export", new DocumentationHandler(d1, templateDirectory + "/cell_export.api")); addHandler("/api/cell/goalseek", new DocumentationHandler(d1, templateDirectory + "/cell_goalseek.api")); addHandler("/api/cell/replace", new DocumentationHandler(d1, templateDirectory + "/cell_replace.api")); addHandler("/api/cell/replace_bulk", new DocumentationHandler(d1, templateDirectory + "/cell_replace_bulk.api")); addHandler("/api/cell/value", new DocumentationHandler(d1, templateDirectory + "/cell_value.api")); addHandler("/api/cell/values", new DocumentationHandler(d1, templateDirectory + "/cell_values.api")); addHandler("/api/event/begin", new DocumentationHandler(d1, templateDirectory + "/event_begin.api")); addHandler("/api/event/end", new DocumentationHandler(d1, templateDirectory + "/event_end.api")); addHandler("/api/rule/create", new DocumentationHandler(d1, templateDirectory + "/rule_create.api")); addHandler("/api/rule/destroy", new DocumentationHandler(d1, templateDirectory + "/rule_destroy.api")); addHandler("/api/rule/functions", new DocumentationHandler(d1, templateDirectory + "/rule_functions.api")); addHandler("/api/rule/info", new DocumentationHandler(d1, templateDirectory + "/rule_info.api")); addHandler("/api/rule/modify", new DocumentationHandler(d1, templateDirectory + "/rule_modify.api")); addHandler("/api/rule/parse", new DocumentationHandler(d1, templateDirectory + "/rule_parse.api")); addHandler("/api/svs/info", new DocumentationHandler(d1, templateDirectory + "/svs_info.api")); addHandler("/api/svs/restart", new DocumentationHandler(d1, templateDirectory + "/svs_restart.api")); addHandler("/api/view/calculate", new DocumentationHandler(d1, templateDirectory + "/view_calculate.api")); // browse the error codes addHandler("/api/error.html", new PaloBrowserHandler(templateDirectory)); // no browser handler addHandler("/browser", new DocumentationHandler(templateDirectory + "/no_browser.tmpl", templateDirectory + "/home.api")); }