static E_Gadcon_Client * _gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style) { Evas_Object *o; E_Gadcon_Client *gcc; Evas *evas; Instance *inst; char buf[4096]; inst = E_NEW (Instance, 1); inst->ci = _empris_config_item_get (id); if (!inst->ci->id) inst->ci->id = eina_stringshare_add (id); o = edje_object_add (gc->evas); snprintf (buf, sizeof (buf), "%s/empris.edj", e_module_dir_get (empris_config->module)); if (!e_theme_edje_object_set (o, "base/theme/modules/empris", "modules/empris/main")) edje_object_file_set (o, buf, "modules/empris/main"); evas_object_show (o); gcc = e_gadcon_client_new (gc, name, id, style, o); gcc->data = inst; inst->gcc = gcc; inst->empris = o; _empris_popup_create(inst, buf); evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_DOWN, _empris_cb_mouse_down, inst); evas_object_event_callback_add (inst->empris, EVAS_CALLBACK_MOUSE_IN, _empris_cb_mouse_in, inst); evas_object_event_callback_add (inst->empris, EVAS_CALLBACK_MOUSE_OUT, _empris_cb_mouse_out, inst); edje_object_signal_callback_add (o, "empris,play", "", _empris_cb_play, inst); edje_object_signal_callback_add (o, "empris,stop", "", _empris_cb_stop, inst); edje_object_signal_callback_add (o, "empris,pause", "", _empris_cb_pause, inst); edje_object_signal_callback_add (o, "empris,next", "", _empris_cb_next, inst); edje_object_signal_callback_add (o, "empris,previous", "", _empris_cb_previous, inst); inst->cb_player_track_change = e_dbus_signal_handler_add (conn, bus_name, "/Player", mpris_interface, "TrackChange", _dbus_cb_track_change, inst); inst->cb_player_status_change = e_dbus_signal_handler_add (conn, bus_name, "/Player", mpris_interface, "StatusChange", _dbus_cb_status_change, inst); _dbus_send_msg("/TrackList", "GetCurrentTrack", _dbus_cb_current_track, inst); empris_config->instances = eina_list_append (empris_config->instances, inst); return gcc; }
static void _battery_fso_on_nameowner_change(void *data, DBusMessage *msg) { DBusError err; const char *s1, *s2, *s3; dbus_error_init(&err); if(!dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &s1, DBUS_TYPE_STRING, &s2, DBUS_TYPE_STRING, &s3, DBUS_TYPE_INVALID)) return; if ((!strcmp(s1, "org.freesmartphone.odeviced")) && (conn)) { if(!strcmp(s3, "")) { printf("\n\nERROR: No Name Owner!\nSetting Capacity to 0.\n\n\n"); if(battery) { battery->charging = FALSE; battery->percent = 0; battery->got_prop = 1; _battery_device_update(); } } else { if (capacity_handler) { e_dbus_signal_handler_del(conn, capacity_handler); capacity_handler = e_dbus_signal_handler_add(conn, "org.freesmartphone.odeviced", "/org/freesmartphone/Device/PowerSupply", "org.freesmartphone.Device.PowerSupply", "Capacity", _battery_fso_on_capacity_change, data); _battery_fso_get_capacity( data ); } if (powerstatus_handler) { e_dbus_signal_handler_del(conn, powerstatus_handler); powerstatus_handler = e_dbus_signal_handler_add(conn, "org.freesmartphone.odeviced", "/org/freesmartphone/Device/PowerSupply", "org.freesmartphone.Device.PowerSupply", "PowerStatus", _battery_fso_on_powerstatus_change, data); _battery_fso_get_powerstatus( data ); } } } return; }
int _battery_fso_start(void) { conn = e_dbus_bus_get(DBUS_BUS_SYSTEM); if (!conn) return 0; /* Initiate the battery gadget */ Battery *bat; const char *udi = "FSO"; bat = _battery_battery_find( udi ); if (!bat) { bat = E_NEW(Battery, 1); if (!bat) return 0; bat->udi = eina_stringshare_add(udi); device_batteries = eina_list_append(device_batteries, bat); } battery = bat; /* Get initial status */ _battery_fso_get_capacity( bat ); _battery_fso_get_powerstatus( bat ); /* Add signal listeners for PowerSupply.Capacity and PowerSupply.PowerStatus */ if( conn ) { nameowner_handler = e_dbus_signal_handler_add(conn, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameOwnerChanged", _battery_fso_on_nameowner_change, bat); capacity_handler = e_dbus_signal_handler_add( conn, "org.freesmartphone.odeviced", "/org/freesmartphone/Device/PowerSupply", "org.freesmartphone.Device.PowerSupply", "Capacity", _battery_fso_on_capacity_change, bat ); powerstatus_handler = e_dbus_signal_handler_add( conn, "org.freesmartphone.odeviced", "/org/freesmartphone/Device/PowerSupply", "org.freesmartphone.Device.PowerSupply", "PowerStatus", _battery_fso_on_powerstatus_change, bat ); } init_time = ecore_time_get(); return 1; }
EAPI void * e_modapi_init (E_Module * m) { char buf[4096]; snprintf (buf, sizeof (buf), "%s/locale", e_module_dir_get (m)); bindtextdomain (PACKAGE, buf); bind_textdomain_codeset (PACKAGE, "UTF-8"); conf_item_edd = E_CONFIG_DD_NEW ("Empris_Config_Item", Config_Item); #undef T #undef D #define T Config_Item #define D conf_item_edd E_CONFIG_VAL (D, T, id, STR); E_CONFIG_VAL (D, T, player, STR); E_CONFIG_VAL (D, T, show_popup, UCHAR); conf_edd = E_CONFIG_DD_NEW ("Empris_Config", Config); #undef T #undef D #define T Config #define D conf_edd E_CONFIG_LIST (D, T, items, conf_item_edd); empris_config = e_config_domain_load ("module.empris", conf_edd); if (!empris_config) { Config_Item *ci; empris_config = E_NEW (Config, 1); ci = E_NEW (Config_Item, 1); ci->id = eina_stringshare_add ("0"); ci->player = eina_stringshare_add (""); ci->show_popup = 1; empris_config->items = eina_list_append (empris_config->items, ci); } empris_config->module = m; conn = e_dbus_bus_get(DBUS_BUS_SESSION); if (!conn) return NULL; cb_name_owner_changed = e_dbus_signal_handler_add (conn, fdo_bus_name, fdo_path, fdo_interface, "NameOwnerChanged", _dbus_cb_name_owner_changed, NULL); e_dbus_list_names(conn, _dbus_cb_list_names, NULL); e_gadcon_provider_register (&_gc_class); e_module_delayed_set(m, 1); return m; }
int _battery_dbus_start(void) { e_dbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM); if (!e_dbus_conn) return 0; // FIXME: e_dbus doesn't allow us to track this pending call e_hal_manager_find_device_by_capability (e_dbus_conn, "battery", _battery_dbus_find_battery, NULL); e_hal_manager_find_device_by_capability (e_dbus_conn, "ac_adapter", _battery_dbus_find_ac, NULL); battery_config->dbus.dev_add = e_dbus_signal_handler_add(e_dbus_conn, E_HAL_SENDER, E_HAL_MANAGER_PATH, E_HAL_MANAGER_INTERFACE, "DeviceAdded", _battery_dbus_dev_add, NULL); battery_config->dbus.dev_del = e_dbus_signal_handler_add(e_dbus_conn, E_HAL_SENDER, E_HAL_MANAGER_PATH, E_HAL_MANAGER_INTERFACE, "DeviceRemoved", _battery_dbus_dev_del, NULL); init_time = ecore_time_get(); return 1; }
void e_mod_kbd_device_init(void) { /* load the 'ignored' keyboard file */ _e_mod_kbd_device_ignore_load(); #ifdef HAVE_EEZE eeze_init(); watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_KEYBOARD, EEZE_UDEV_EVENT_NONE, _e_mod_kbd_device_udev_event, NULL); #else e_dbus_init(); e_hal_init(); /* try to attach to the system dbus */ if (!(_dbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM))) return; /* ask HAL for any input keyboards */ e_hal_manager_find_device_by_capability(_dbus_conn, "input.keyboard", _e_mod_kbd_device_cb_input_kbd, NULL); /* setup dbus signal handlers for when a device gets added/removed/changed */ _dev_add = e_dbus_signal_handler_add(_dbus_conn, E_HAL_SENDER, E_HAL_MANAGER_PATH, E_HAL_MANAGER_INTERFACE, "DeviceAdded", _e_mod_kbd_device_dbus_add, NULL); _dev_del = e_dbus_signal_handler_add(_dbus_conn, E_HAL_SENDER, E_HAL_MANAGER_PATH, E_HAL_MANAGER_INTERFACE, "DeviceRemoved", _e_mod_kbd_device_dbus_del, NULL); _dev_chg = e_dbus_signal_handler_add(_dbus_conn, E_HAL_SENDER, E_HAL_MANAGER_PATH, E_HAL_MANAGER_INTERFACE, "NewCapability", _e_mod_kbd_device_dbus_chg, NULL); #endif }
/** * Start Discovery of Bluetooth Devices * * call StartDiscovery() * * @param element the adapter's element. * @param cb function to call when server replies or some error happens. * @param data data to give to cb when it is called. * * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise. */ Eina_Bool e_bluez_adapter_start_discovery(E_Bluez_Element *element, E_DBus_Method_Return_Cb cb, const void *data) { const char name[] = "StartDiscovery"; EINA_SAFETY_ON_NULL_RETURN_VAL(element, EINA_FALSE); element->device_found_handler = e_dbus_signal_handler_add (e_bluez_conn, e_bluez_system_bus_name_get(), element->path, element->interface, "DeviceFound", _device_found_callback, element); return e_bluez_element_call_full (element, name, NULL, &element->_pending.start_discovery, cb, data); }