Exemplo n.º 1
0
bool SkypeLowIoImpl::init()
{
    dummy_log_debug( MODULENAME, "init()" );

    MUTEX_SCOPE_LOCK( mutex_ );

    if( is_running_ )
    {
        dummy_log_error( MODULENAME, "init: already inited" );
        return false;
    }


    dbus::Threads::init_default();
    dbus::Error error;
    dbus_ = dbus::Bus::get( DBUS_BUS_SESSION, error );

    if( !dbus_.get_raw() )
    {
        dummy_log_error( MODULENAME, "%s: %s", error.get_raw().name, error.get_raw().message );
        return false;
    }

//  printf("unique name: %s\n", dbus_bus_get_unique_name(dbus_));
    dbus::Bus::add_match( dbus_, "path='/com/Skype/Client'", error );
    dbus_.add_filter( signal_filter, this, NULL );

    connect_to_skype();

    must_stop_  = false;

    thread_ = std::thread( std::bind( &SkypeLowIoImpl::thread_func, this ) );

    return true;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
	odtone::setup_crash_handler();

	// setup mih launch configurations
	po::options_description desc(odtone::mih::octet_string("MIH Usr Configuration"));
	desc.add_options()
		("help", "Display configuration options")
		(sap::kConf_File, po::value<std::string>()->default_value("networkmanager.conf"), "Configuration file")
		(sap::kConf_Receive_Buffer_Len, po::value<uint>()->default_value(4096), "Receive buffer length")
		(sap::kConf_Port, po::value<ushort>()->default_value(1234), "Listening port")
		(sap::kConf_MIH_SAP_id, po::value<std::string>()->default_value("mih_nm"), "MIH-User ID")
		(sap::kConf_MIHF_Ip, po::value<std::string>()->default_value("127.0.0.1"), "Local MIHF IP address")
		(sap::kConf_MIHF_Local_Port, po::value<ushort>()->default_value(1025), "Local MIHF communication port")
		(sap::kConf_MIH_SAP_dest, po::value<std::string>()->default_value(""), "MIHF destination")
		(nm::kConf_Settings_Path, po::value<std::string>()->default_value("./settings"),
		                          "System path for NetworkManager connection persistence")
		(nm::kConf_Version,       po::value<std::string>()->default_value("0.9.6.0"),
		                          "NetworkManager version to mimic")
		(nm::kConf_Networking_Enabled, po::value<bool>()->default_value(true),
		                               "NetworkingEnabled property initial value")
		(nm::kConf_Wireless_Enabled,   po::value<bool>()->default_value(true),
		                               "WirelessEnabled property initial value")
		(nm::kConf_Wimax_Enabled,      po::value<bool>()->default_value(true),
		                               "WirelessEnabled property initial value")
		(nm::kConf_Wwan_Enabled,       po::value<bool>()->default_value(true),
		                               "WirelessEnabled property initial value");

	odtone::mih::config cfg(desc);
	cfg.parse(argc, argv, odtone::sap::kConf_File);

	if (cfg.help()) {
		std::cerr << desc << std::endl;
		return EXIT_SUCCESS;
	}

	// setup D-Bus service
	DBus::BusDispatcher dispatcher;
	DBus::default_dispatcher = &dispatcher;

	DBus::Connection conn = DBus::Connection::SystemBus();
	conn.request_name(nm::DBUS_NAME);

	// launch the service
	boost::asio::io_service ios;
	nm::NetworkManager manager(conn, cfg, ios);

	boost::thread io(boost::bind(&boost::asio::io_service::run, &ios));

	boost::mutex m;
	while (true) {
		ios.dispatch(boost::bind(&dbus_dispatch_pending, boost::ref(dispatcher), boost::ref(m)));
		m.lock();
		dispatcher.dispatch();
	}

	return EXIT_SUCCESS;
}
Exemplo n.º 3
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;
}
Exemplo n.º 5
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();
}
Exemplo n.º 6
0
bool SkypeLowIoImpl::send__( const std::string & s )
{
    const char* command = s.c_str();
//  std::cout << "Command: " << ss.str() << endl;
    dbus::Message message( "com.Skype.API", "/com/Skype", "com.Skype.API", "Invoke" );
    message.append_args( DBUS_TYPE_STRING, &command, DBUS_TYPE_INVALID );
    return dbus_.send( message, NULL );
}
Exemplo n.º 7
0
bool SkypeLowIoImpl::shutdown__()
{
    dummy_log_trace( MODULENAME, "shutdown__()" );

    ASSERT( is_running_ );

    must_stop_  = true;

    thread_.join();

    dbus_.flush();

    return true;
}
Exemplo n.º 8
0
void SkypeLowIoImpl::thread_func()
{
    utils::set_this_thread_name( "skype_low_io" );

    dummy_log_trace( MODULENAME, "SkypeLowIoImpl::thread_func: started" );

    is_running_ = true;

    while( true )
    {
        if( must_stop_ )
            break;

        {
            MUTEX_SCOPE_LOCK( mutex_ );

            unsigned int seq = sequence_;

            dbus_.read_write_dispatch( 100 );

            if( seq != sequence_ )
            {
                if( sequence_ - seq > 1 )
                {
                    dummy_log_fatal( MODULENAME, "SkypeLowIoImpl::thread_func: missed messages" );
                    ::exit( 42 );
                }
                if( callback_ )
                    callback_->handle( response_ );
                seq = sequence_;
            }
        }

        THIS_THREAD_SLEEP_MS( 1 );
    }

    is_running_ = false;

    dummy_log_trace( MODULENAME, "SkypeLowIoImpl::thread_func: exit" );
}
Exemplo n.º 9
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);
}
Exemplo n.º 10
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;
}