int main(int argc, char **argv) { signal(SIGTERM, niam); signal(SIGINT, niam); signal(SIGALRM, niam); if (argc == 1) { std::cerr << std::endl << "Usage: " << argv[0] << " [--system] <object_path> [<destination>]" << std::endl << std::endl; } else { if (strcmp(argv[1], "--system")) { systembus = false; path = argv[1]; service = argc > 2 ? argv[2] : 0; } else { systembus = true; path = argv[2]; service = argc > 3 ? argv[3] : 0; } DBus::default_dispatcher = &dispatcher; alarm(1); dispatcher.enter(); } return 0; }
int main() { size_t i; signal(SIGTERM, niam); signal(SIGINT, niam); DBus::_init_threading(); DBus::default_dispatcher = &dispatcher; DBus::ASIOInterfaceDispatcher interface_dispatcher; DBus::InterfaceAdaptor::override_dispatcher(&interface_dispatcher); DBus::InterfaceProxy::override_dispatcher(&interface_dispatcher); DBus::PendingCall::override_dispatcher(&interface_dispatcher); interface_dispatcher.start_dispatcher(1); // increase DBus-C++ frequency new DBus::DefaultTimeout(100, false, &dispatcher); DBus::Connection conn = DBus::Connection::SessionBus(); EchoClient client(conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME); g_client = &client; pthread_t threads[THREADS]; thread_pipe_list[0] = dispatcher.add_pipe(handler1, NULL); thread_pipe_list[1] = dispatcher.add_pipe(handler2, NULL); thread_pipe_list[2] = dispatcher.add_pipe(handler3, NULL); for (i = 0; i < THREADS; ++i) { pthread_create(threads + i, NULL, greeter_thread, (void *) i); } dispatcher.enter(); cout << "terminating" << endl; for (i = 0; i < THREADS; ++i) { pthread_join(threads[i], NULL); } dispatcher.del_pipe(thread_pipe_list[0]); dispatcher.del_pipe(thread_pipe_list[1]); dispatcher.del_pipe(thread_pipe_list[2]); return 0; }
int main() { DBus::default_dispatcher = &dispatcher; DBus::Connection bus = DBus::Connection::SessionBus(); bus.request_name("com.upnp.NIUPnP"); NIUPnP niupnp(bus); dispatcher.enter(); return 0; }
int main() { signal(SIGTERM, niam); signal(SIGINT, niam); DBus::default_dispatcher = &dispatcher; DBus::Connection conn = DBus::Connection::SessionBus(); conn.request_name(PROPS_SERVER_NAME); PropsServer server(conn); dispatcher.enter(); return 0; }
void Start() { vsd::signal::setSigHandler( SIGINT, &termDbus, vsd::signal::Sigset(vsd::signal::SIGACTION::EMPTY), 0); DBus::BusDispatcher dispatcher; DBus::default_dispatcher = &dispatcher; DBus::Connection conn = DBus::Connection::SessionBus(); conn.request_name(ECHO_SERVER_NAME); EchoServer server(conn); dispatcher.enter(); }
int main() { signal(SIGTERM, niam); signal(SIGINT, niam); DBus::_init_threading(); DBus::default_dispatcher = &dispatcher; DBus::Connection conn = DBus::Connection::SessionBus(); client = new AsyncClient(conn, ASYNC_SERVER_PATH, ASYNC_SERVER_NAME); pthread_t thread; pthread_create(&thread, NULL, do_method_calls, client); dispatcher.enter(); cout << "terminating" << endl; delete client; return 0; }
int main( int argc, char **argv ) { struct arguments arguments; printf("-----------------------------------------------\n"); printf("FFADO Control DBUS service\n"); printf("Part of the FFADO project -- www.ffado.org\n"); printf("Version: %s\n", PACKAGE_VERSION); printf("(C) 2008, Pieter Palmers\n"); printf("This program comes with ABSOLUTELY NO WARRANTY.\n"); printf("-----------------------------------------------\n\n"); // check the library version const char *libversion = ffado_get_version(); const char *progversion = PACKAGE_STRING; if(strcmp(libversion, progversion) != 0) { printf("Library version mismatch. (required: %s, present: %s)\n", progversion, libversion); printf("Please run this application against the exact corresponding library\n"); printf("it was compiled for. The most common cause for this is having more\n"); printf("than one version of libffado installed.\n\n"); return exitfunction(-1); } // Default values. arguments.silent = 0; arguments.verbose = DEBUG_LEVEL_NORMAL; arguments.use_cache = 1; arguments.port = 0; arguments.node_id = 0; arguments.node_id_set = 0; // if we don't specify a node, discover all arguments.args[0] = ""; arguments.args[1] = ""; setDebugLevel(arguments.verbose); // Parse our arguments; every option seen by `parse_opt' will // be reflected in `arguments'. if ( argp_parse ( &argp, argc, argv, 0, 0, &arguments ) ) { debugError("Could not parse command line\n" ); return exitfunction(-1); } printMessage(" Discovering devices...\n"); m_deviceManager = new DeviceManager(); if ( !m_deviceManager ) { debugError("Could not allocate device manager\n" ); return exitfunction(-1); } if ( !m_deviceManager->initialize() ) { debugError("Could not initialize device manager\n" ); delete m_deviceManager; return exitfunction(-1); } if ( arguments.verbose ) { m_deviceManager->setVerboseLevel(arguments.verbose); } if ( !m_deviceManager->discover(arguments.use_cache) ) { debugError("Could not discover devices\n" ); delete m_deviceManager; return exitfunction(-1); } // add pre-update handler Util::Functor* preupdate_functor = new Util::CallbackFunctor0< void (*)() > ( &preUpdateHandler, false ); if ( !preupdate_functor ) { debugFatal( "Could not create pre-update handler\n" ); return false; } if(!m_deviceManager->registerPreUpdateNotification(preupdate_functor)) { debugError("could not register pre-update notifier"); } // add post-update handler Util::Functor* postupdate_functor = new Util::CallbackFunctor0< void (*)() > ( &postUpdateHandler, false ); if ( !postupdate_functor ) { debugFatal( "Could not create post-update handler\n" ); return false; } if(!m_deviceManager->registerPostUpdateNotification(postupdate_functor)) { debugError("could not register post-update notifier"); } signal (SIGINT, sighandler); signal (SIGTERM, sighandler); DBus::_init_threading(); // set up DBUS stuff DBus::default_dispatcher = &dispatcher; DBus::Connection conn = DBus::Connection::SessionBus(); global_conn = &conn; conn.request_name("org.ffado.Control"); // lock the control tree such that it does not get modified while we build our view m_deviceManager->lockControl(); container = new DBusControl::Container(conn, "/org/ffado/Control/DeviceManager", NULL, *m_deviceManager); // unlock the control tree since the tree is built m_deviceManager->unlockControl(); printMessage("DBUS service running\n"); printMessage("press ctrl-c to stop it & exit\n"); while(run) { debugOutput( DEBUG_LEVEL_NORMAL, "dispatching...\n"); dispatcher.enter(); debugOutput( DEBUG_LEVEL_NORMAL, " dispatcher exited...\n"); sem_wait(&run_sem); debugOutput( DEBUG_LEVEL_NORMAL, " activity handled...\n"); } if(!m_deviceManager->unregisterPreUpdateNotification(preupdate_functor)) { debugError("could not unregister pre update notifier"); } delete preupdate_functor; if(!m_deviceManager->unregisterPostUpdateNotification(postupdate_functor)) { debugError("could not unregister post update notifier"); } delete postupdate_functor; delete container; signal (SIGINT, SIG_DFL); signal (SIGTERM, SIG_DFL); printMessage("server stopped\n"); delete m_deviceManager; return exitfunction(0); }
int main(int argc, char* argv[]) { String config_name("simple"); String display_name; bool daemon = false; bool should_resident = true; //parse command options int i = 1; while (i < argc) { if (String("-l") == argv[i] || String("--list") == argv[i]) { std::cout << "\n"; std::cout << "Available Config module:\n"; // get config module list std::vector<String> config_list; scim_get_config_module_list(config_list); config_list.push_back("dummy"); std::vector<String>::iterator it = config_list.begin(); for (; it != config_list.end(); ++it) { std::cout << " " << *it << "\n"; } return 0; } else if (String("-c") == argv[i] || String("--config") == argv[i]) { if (++i >= argc) { std::cerr << "no argument for option " << argv[i-1] << "\n"; return -1; } config_name = argv[i]; } else if (String("-h") == argv[i] || String("--help") == argv[i]) { std::cout << "Usage: " << argv [0] << " [option]...\n\n" << "The options are: \n" << " --display DISPLAY Run on display DISPLAY.\n" << " -l, --list List all of available config modules.\n" << " -c, --config NAME Uses specified Config module.\n" << " -d, --daemon Run " << argv [0] << " as a daemon.\n" << " -ns, --no-stay Quit if no connected client.\n" << " -h, --help Show this help message.\n"; return 0; } else if (String("-d") == argv[i] || String("--daemon") == argv[i]) { daemon = true; } else if (String("-ns") == argv[i] || String("--no-stay") == argv[i]) { should_resident = false; } else if (String("--display") == argv[i]) { if (++i >= argc) { std::cerr << "No argument for option " << argv[i-1] << "\n"; return -1; } display_name = argv[i]; } else { std::cerr << "Invalid command line option: " << argv[i] << "\n"; return -1; } ++i; } // Make up DISPLAY env. if (display_name.length()) { setenv("DISPLAY", display_name.c_str(), 1); } if (config_name == "dummy") { _config = new DummyConfig(); } else { _config_module = new ConfigModule(config_name); if (!_config_module || !_config_module->valid()) { std::cerr << "Can not load " << config_name << " Config module.\n"; return -1; } _config = _config_module->create_config(); } if (_config.null()) { std::cerr << "Failed to create instance from " << config_name << " Config module.\n"; return -1; } signal(SIGTERM, niam); signal(SIGINT, niam); if (!initialize_panel_agent(config_name, display_name, should_resident)) { std::cerr << "Failed to initialize PanelAgent.\n"; return -1; } if (daemon) scim_daemon(); if (!run_panel_agent()) { std::cerr << "Failed to run Socket Server!\n"; return -1; } start_auto_start_helpers(); DBus::default_dispatcher = &dispatcher; DBus::Connection conn = DBus::Connection::SessionBus(); conn.request_name("org.kde.impanel.inputmethod"); panel = new Panel(conn); /// add initial helper as helper property PropertyList props; std::vector<HelperInfo>::const_iterator it = _helper_list.begin(); std::vector<HelperInfo>::const_iterator end = _helper_list.end(); while (it != end) { if ((it->option & SCIM_HELPER_STAND_ALONE) && !(it->option & SCIM_HELPER_AUTO_START)) { props.push_back(Property(String(helper_prop_prefix) + it->uuid, it->name, it->icon, it->description)); } ++it; } if (props.size()) { helper_props_map[0] = props; } dispatcher.enter(); delete panel; return 0; }