void dbus_ifc_init() { DBusError error; printf("%s()\n", __PRETTY_FUNCTION__); if(OSSO_OK != osso_rpc_set_default_cb_f(_osso, dbus_ifc_cb_default, NULL)) g_printerr("osso_rpc_set_default_cb_f failed.\n"); if(OSSO_OK != osso_rpc_set_cb_f(_osso, MM_DBUS_SERVICE, MM_DBUS_PATH, MM_DBUS_INTERFACE, dbus_ifc_controller, NULL)) g_printerr("osso_rpc_set_cb_f failed.\n"); dbus_error_init(&error); if(NULL == (_bus = dbus_bus_get(DBUS_BUS_SESSION, &error))) { g_printerr("Error getting session bus: %s: %s\n", (dbus_error_is_set(&error) ? error.name : "<no error message>"), (dbus_error_is_set(&error) ? error.message : "")); } vprintf("%s(): return\n", __PRETTY_FUNCTION__); }
int dbus_init(processor_config_t *config) { int ret = -1; LOG_DEBUG("Initing dbus..\n"); #ifdef CONFIG_MAEMOEXTS_ENABLED osso_return_t result; ASSERT_TRUE(osso_context = osso_initialize("org.p2pship.p2pship_libosso", "0.0.1", TRUE, NULL), err); /* Add handler for session bus D-BUS messages */ result = osso_rpc_set_cb_f(osso_context, "org.p2pship.p2pship_libosso", "/org/p2pship/p2pship_libosso", "org.p2pship.p2pship_libosso", dbus_req_handler, osso_context); ASSERT_TRUE(result == OSSO_OK, err); #endif ASSERT_TRUE(1, err); ret = 0; err: return ret; }
/*---------------------------------------------------------------------*/ int osso_init() { osso_return_t result; AppData *appdata; /* Initialize maemo application */ osso_context = osso_initialize( "hop_launcher", HOP_RELEASE, TRUE, NULL ); /* Check that initialization was ok */ if( osso_context == NULL ) { return OSSO_ERROR; } /* Create AppData */ appdata = g_new0( AppData, 1 ); appdata->program = program; appdata->window = win; appdata->osso_context = osso_context; /* Add handler for session bus D-BUS messages */ result = osso_rpc_set_cb_f( appdata->osso_context, OSSO_HOP_SERVICE, OSSO_HOP_OBJECT, OSSO_HOP_IFACE, dbus_req_handler, appdata ); if( result != OSSO_OK ) { g_print( "Error setting D-BUS callback (%d)\n", result ); return OSSO_ERROR; } return OSSO_OK; }
int initializeApp() { osso_return_t result; //Return value from libosso calls osso_hw_state_t stateFlags; //Stuct to indicate which hwStates we want to watch for //Setup stateFlags to monitor only inactivity (since we want to exit and free up memory if system goes inactive) stateFlags.system_inactivity_ind = TRUE; //Define signal handlers for abort/kill to clean things up incase somethign bad happens (void) signal(SIGINT,sig_leave); (void) signal(SIGTERM, sig_leave); //****************** GObject loop setup ***************// mainLoopObj = g_main_loop_new(NULL, FALSE); //Create the main loop for the app //****************** Done GObject loop setup **********// ossoAppContext = osso_initialize(DBUS_FMRADIO_SERVICE, "1.0", FALSE, NULL); if (ossoAppContext == NULL) { printf("Failed to initialize libosso!\r\n"); return 0; } //Set up DBUS listening result = osso_rpc_set_cb_f(ossoAppContext, DBUS_FMRADIO_SERVICE, DBUS_FMRADIO_PATH, DBUS_FMRADIO_INTERFACE, dbus_req_handler, NULL); //Setup inactivity monitor //Okay got the libosso setup, so establish the callback for the hardware state changes result = osso_hw_set_event_cb(ossoAppContext, &stateFlags, systemActivityChange, NULL); //Create the radio Obj radioObj = (RadioDescriptor *) malloc(sizeof(RadioDescriptor)); radioObj->radio_fd = -1; radio_open(radioObj); return 1; }