static gboolean cdma_poll_cb (gpointer user_data) { CdmaDeviceInfo *info = user_data; /* Kick off calls to get registration state and signal quality */ if (!info->skip_reg_poll) { dbus_g_proxy_begin_call (info->cdma_proxy, "GetRegistrationState", reg_state_reply, info, NULL, G_TYPE_INVALID); info->skip_reg_poll = FALSE; } if (!info->skip_signal_poll) { dbus_g_proxy_begin_call (info->cdma_proxy, "GetSignalQuality", signal_reply, info, NULL, G_TYPE_INVALID); info->skip_signal_poll = FALSE; } dbus_g_proxy_begin_call (info->cdma_proxy, "GetServingSystem", serving_system_reply, info, NULL, G_TYPE_INVALID); return TRUE; /* keep running until we're told to stop */ }
static void nm_supplicant_interface_add_to_supplicant (NMSupplicantInterface * self, gboolean get_only) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); NMSupplicantInfo *info; DBusGProxy *proxy; DBusGProxyCall *call; proxy = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr), WPAS_DBUS_SERVICE, WPAS_DBUS_PATH, WPAS_DBUS_INTERFACE); info = nm_supplicant_info_new (self, proxy, priv->other_pcalls); if (get_only) { call = dbus_g_proxy_begin_call (proxy, "getInterface", nm_supplicant_interface_add_cb, info, nm_supplicant_info_destroy, G_TYPE_STRING, priv->dev, G_TYPE_INVALID); } else { GHashTable *hash = g_hash_table_new (g_str_hash, g_str_equal); GValue *driver; driver = g_new0 (GValue, 1); g_value_init (driver, G_TYPE_STRING); g_value_set_string (driver, priv->is_wireless ? "wext" : "wired"); g_hash_table_insert (hash, "driver", driver); call = dbus_g_proxy_begin_call (proxy, "addInterface", nm_supplicant_interface_add_cb, info, nm_supplicant_info_destroy, G_TYPE_STRING, priv->dev, DBUS_TYPE_G_MAP_OF_VARIANT, hash, G_TYPE_INVALID); g_value_unset (driver); g_free (driver); g_hash_table_destroy (hash); } g_object_unref (proxy); nm_supplicant_info_set_call (info, call); }
void nm_supplicant_interface_disconnect (NMSupplicantInterface * self) { NMSupplicantInterfacePrivate *priv; g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (self)); priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); /* Clear and cancel all pending calls related to a prior * connection attempt. */ cancel_all_callbacks (priv->assoc_pcalls); /* Don't do anything if there is no connection to the supplicant yet. */ if (!priv->iface_proxy) return; /* Don't try to disconnect if the supplicant interface is already * disconnected. */ if (priv->con_state == NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED || priv->con_state == NM_SUPPLICANT_INTERFACE_CON_STATE_INACTIVE) { if (priv->net_proxy) { g_object_unref (priv->net_proxy); priv->net_proxy = NULL; } return; } /* Remove any network that was added by NetworkManager */ if (priv->net_proxy) { dbus_g_proxy_begin_call (priv->iface_proxy, "removeNetwork", remove_network_cb, NULL, NULL, DBUS_TYPE_G_OBJECT_PATH, dbus_g_proxy_get_path (priv->net_proxy), G_TYPE_INVALID); g_object_unref (priv->net_proxy); priv->net_proxy = NULL; } dbus_g_proxy_begin_call (priv->iface_proxy, "disconnect", disconnect_cb, NULL, NULL, G_TYPE_INVALID); }
static void set_ap_scan_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) { NMSupplicantInfo *info = (NMSupplicantInfo *) user_data; NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface); GError *err = NULL; DBusGProxyCall *call; GHashTable *config_hash; if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_INVALID)) { nm_log_warn (LOGD_SUPPLICANT, "Couldn't send AP scan mode to the supplicant interface: %s.", err->message); emit_error_helper (info->interface, err); g_error_free (err); return; } nm_log_info (LOGD_SUPPLICANT, "Config: set interface ap_scan to %d", nm_supplicant_config_get_ap_scan (priv->cfg)); info = nm_supplicant_info_new (info->interface, priv->iface_proxy, info->store); config_hash = nm_supplicant_config_get_hash (priv->cfg); call = dbus_g_proxy_begin_call (priv->iface_proxy, "AddNetwork", add_network_cb, info, nm_supplicant_info_destroy, DBUS_TYPE_G_MAP_OF_VARIANT, config_hash, G_TYPE_INVALID); g_hash_table_destroy (config_hash); nm_supplicant_info_set_call (info, call); }
static void request_bss_properties (NMSupplicantInterface *self, GPtrArray *paths) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); int i; /* Fire off a "properties" call for each returned BSSID */ for (i = 0; i < paths->len; i++) { NMSupplicantInfo *info; DBusGProxy *proxy; DBusGProxyCall *call; proxy = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr), WPAS_DBUS_SERVICE, g_ptr_array_index (paths, i), DBUS_INTERFACE_PROPERTIES); info = nm_supplicant_info_new (self, proxy, priv->other_pcalls); call = dbus_g_proxy_begin_call (proxy, "GetAll", bssid_properties_cb, info, nm_supplicant_info_destroy, G_TYPE_STRING, WPAS_DBUS_IFACE_BSS, G_TYPE_INVALID); nm_supplicant_info_set_call (info, call); g_object_unref (proxy); } }
static gboolean request_scan_results (gpointer user_data) { NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data); NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); NMSupplicantInfo *info; DBusGProxyCall *call; GTimeVal cur_time; priv->scan_results_timeout = 0; g_return_val_if_fail (priv->iface_proxy != NULL, FALSE); info = nm_supplicant_info_new (self, priv->iface_proxy, priv->other_pcalls); call = dbus_g_proxy_begin_call (priv->iface_proxy, "scanResults", scan_results_cb, info, nm_supplicant_info_destroy, G_TYPE_INVALID); nm_supplicant_info_set_call (info, call); g_get_current_time (&cur_time); priv->last_scan = cur_time.tv_sec; return FALSE; }
static void call_set_blobs (NMSupplicantInfo *info, GHashTable *orig_blobs) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface); DBusGProxyCall *call; GHashTable *blobs; blobs = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) blob_free); if (!blobs) { const char *msg = "Not enough memory to create blob table."; nm_log_warn (LOGD_SUPPLICANT, "%s", msg); g_signal_emit (info->interface, nm_supplicant_interface_signals[CONNECTION_ERROR], 0, "SendBlobError", msg); return; } g_hash_table_foreach (orig_blobs, (GHFunc) convert_blob, blobs); call = dbus_g_proxy_begin_call (priv->iface_proxy, "setBlobs", set_blobs_cb, info, nm_supplicant_info_destroy, DBUS_TYPE_G_MAP_OF_VARIANT, blobs, G_TYPE_INVALID); nm_supplicant_info_set_call (info, call); g_hash_table_destroy (blobs); }
static void set_network_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) { NMSupplicantInfo *info = (NMSupplicantInfo *) user_data; NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface); GError *err = NULL; guint tmp; if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_UINT, &tmp, G_TYPE_INVALID)) { nm_log_warn (LOGD_SUPPLICANT, "Couldn't set network config: %s.", err->message); emit_error_helper (info->interface, err); g_error_free (err); } else { DBusGProxyCall *call; info = nm_supplicant_info_new (info->interface, priv->iface_proxy, priv->assoc_pcalls); call = dbus_g_proxy_begin_call (priv->iface_proxy, "selectNetwork", select_network_cb, info, nm_supplicant_info_destroy, DBUS_TYPE_G_OBJECT_PATH, dbus_g_proxy_get_path (proxy), G_TYPE_INVALID); nm_supplicant_info_set_call (info, call); } }
gboolean nm_supplicant_interface_request_scan (NMSupplicantInterface * self) { NMSupplicantInterfacePrivate *priv; NMSupplicantInfo *info; DBusGProxyCall *call; GHashTable *hash; g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), FALSE); priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); /* Scan parameters */ hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, destroy_gvalue); g_hash_table_insert (hash, "Type", string_to_gvalue ("active")); info = nm_supplicant_info_new (self, priv->iface_proxy, priv->other_pcalls); call = dbus_g_proxy_begin_call (priv->iface_proxy, "Scan", scan_request_cb, info, nm_supplicant_info_destroy, DBUS_TYPE_G_MAP_OF_VARIANT, hash, G_TYPE_INVALID); g_hash_table_destroy (hash); nm_supplicant_info_set_call (info, call); return call != NULL; }
/** * nm_device_wifi_request_scan_simple: * @device: a #NMDeviceWifi * @callback: (scope async) (allow-none): the function to call when the call is done * @user_data: (closure): user data to pass to the callback function * * Request NM to scan for access points on the #NMDeviceWifi. This function only * instructs NM to perform scanning. Use nm_device_wifi_get_access_points() * to get available access points. **/ void nm_device_wifi_request_scan_simple (NMDeviceWifi *device, NMDeviceWifiRequestScanFn callback, gpointer user_data) { RequestScanInfo *info; GHashTable *options; NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device); g_return_if_fail (NM_IS_DEVICE_WIFI (device)); /* If a scan is in progress, just return */ if (priv->scan_call) return; options = g_hash_table_new (g_str_hash, g_str_equal); info = g_slice_new0 (RequestScanInfo); info->device = device; info->callback = callback; info->user_data = user_data; priv->scan_info = info; priv->scan_call = dbus_g_proxy_begin_call (NM_DEVICE_WIFI_GET_PRIVATE (device)->proxy, "RequestScan", request_scan_cb, info, NULL, DBUS_TYPE_G_MAP_OF_VARIANT, options, G_TYPE_INVALID); g_hash_table_unref (options); }
static void add_device_from_path (char *device_path, GUPnPNetworkManager *manager) { NMDevice *nm_device; nm_device = nm_device_new (manager, device_path); manager->priv->nm_devices = g_list_append (manager->priv->nm_devices, nm_device); dbus_g_proxy_add_signal (nm_device->device_proxy, "StateChanged", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal (nm_device->device_proxy, "StateChanged", G_CALLBACK (on_device_state_changed), nm_device, NULL); dbus_g_proxy_begin_call (nm_device->prop_proxy, "Get", get_device_state_cb, nm_device, NULL, G_TYPE_STRING, DEVICE_INTERFACE, G_TYPE_STRING, "State", G_TYPE_INVALID); }
static void method_call(DBusGProxy *proxy, const char *method, const char *path) { if (proxy == NULL) return; g_print("%s ( %s, %s )\n", method, dbus_g_proxy_get_path(proxy), path); if (path == NULL) { if (dbus_g_proxy_begin_call_with_timeout(proxy, method, method_callback, NULL, NULL, 120 * 1000, G_TYPE_INVALID) == FALSE) { g_print("Can't call method %s\n", method); g_object_unref(proxy); return; } } else { if (dbus_g_proxy_begin_call(proxy, method, method_callback, NULL, NULL, DBUS_TYPE_G_OBJECT_PATH, path, G_TYPE_INVALID) == FALSE) { g_print("Can't call method %s (%s)\n", method, path); g_object_unref(proxy); return; } } }
static void names_model_reload (NamesModel *names_model) { GtkListStore *list_store; list_store = GTK_LIST_STORE (names_model); if (names_model->pending_list_names) { dbus_g_proxy_cancel_call (names_model->driver_proxy, names_model->pending_list_names); names_model->pending_list_names = NULL; } gtk_list_store_clear (list_store); if (names_model->connection == NULL) return; names_model->pending_list_names = dbus_g_proxy_begin_call (names_model->driver_proxy, "ListNames", have_names_notify, names_model, NULL, G_TYPE_INVALID); }
void nm_modem_set_mm_enabled (NMModem *self, gboolean enabled) { NMModemPrivate *priv; g_return_if_fail (self != NULL); g_return_if_fail (NM_IS_MODEM (self)); priv = NM_MODEM_GET_PRIVATE (self); /* FIXME: For now this just toggles the ModemManager enabled state. In the * future we want to tie this into rfkill state instead so that the user can * toggle rfkill status of the WWAN modem. */ if (priv->mm_enabled != enabled) { DBusGProxy *proxy; proxy = nm_modem_get_proxy (self, MM_DBUS_INTERFACE_MODEM); dbus_g_proxy_begin_call (proxy, "Enable", set_mm_enabled_done, self, NULL, G_TYPE_BOOLEAN, enabled, G_TYPE_INVALID); /* If we are disabling the modem, stop saying that it's enabled. */ if (!enabled) update_mm_enabled (self, enabled); } }
static void modem_manager_appeared (NMModemManager *self, gboolean enumerate_devices) { NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE (self); if (priv->poke_id) { g_source_remove (priv->poke_id); priv->poke_id = 0; } nm_log_info (LOGD_MB, "modem-manager is now available"); priv->proxy = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr), MM_DBUS_SERVICE, MM_DBUS_PATH, MM_DBUS_INTERFACE); dbus_g_proxy_add_signal (priv->proxy, "DeviceAdded", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->proxy, "DeviceAdded", G_CALLBACK (modem_added), self, NULL); dbus_g_proxy_add_signal (priv->proxy, "DeviceRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->proxy, "DeviceRemoved", G_CALLBACK (modem_removed), self, NULL); if (enumerate_devices) dbus_g_proxy_begin_call (priv->proxy, "EnumerateDevices", enumerate_devices_done, self, NULL, G_TYPE_INVALID); }
void size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer user_data) { static int prev_width = -1; static int prev_height = -1; if (prev_height == -1 || prev_width == -1 || allocation->width != prev_width || allocation->height != prev_height) { prev_height = allocation->height; prev_width = allocation->width; if (g_applet->orientation == 1 || g_applet->orientation == 3) { g_applet->size = allocation->width; } else { g_applet->size = allocation->height; } if (g_applet->support != NULL && workrave_is_running()) { dbus_g_proxy_begin_call(g_applet->support, "SetSize", dbus_callback, NULL, NULL, G_TYPE_UINT, g_applet->size, G_TYPE_INVALID); } } }
int main(int argc, char *argv[]) { GError *error = NULL; DBusGConnection *connection; DBusGProxy *proxy; g_type_init(); main_loop = g_main_loop_new(NULL, TRUE); connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (connection == NULL) { g_printerr("Failed to open connection to bus: %s\n", error->message); g_error_free(error); error = NULL; exit(1); } proxy = dbus_g_proxy_new_for_name(connection, "org.freedesktop.Notifications", "/", DBUS_INTERFACE_INTROSPECTABLE); dbus_g_proxy_begin_call(proxy, "Introspect", my_callback_func, NULL, NULL, G_TYPE_INVALID); g_main_loop_run(main_loop); return 0; }
static void on_device_state_changed (DBusGProxy *proxy, guint new_state, guint old_state, guint reason, void *user_data) { NMDevice *nm_device; nm_device = (NMDevice *) user_data; if (new_state == NM_DEVICE_STATE_ACTIVATED) { dbus_g_proxy_begin_call (nm_device->prop_proxy, "Get", get_device_interface_cb, nm_device, NULL, G_TYPE_STRING, DEVICE_INTERFACE, G_TYPE_STRING, "Interface", G_TYPE_INVALID); } else if (nm_device->context != NULL) { /* For all other states we just destroy the context */ g_signal_emit_by_name (nm_device->manager, "context-unavailable", nm_device->context); g_object_unref (nm_device->context); nm_device->context = NULL; } }
static void modem_added (DBusGProxy *proxy, const char *path, gpointer user_data) { NmaBtDevice *self = NMA_BT_DEVICE (user_data); NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (self); DBusGProxy *props_proxy; g_return_if_fail (path != NULL); g_message ("%s: (%s) modem found", __func__, path); /* Create a proxy for the modem and get its properties */ props_proxy = dbus_g_proxy_new_for_name (priv->bus, MM_SERVICE, path, "org.freedesktop.DBus.Properties"); g_assert (proxy); priv->modem_proxies = g_slist_append (priv->modem_proxies, props_proxy); g_message ("%s: (%s) calling GetAll...", __func__, path); dbus_g_proxy_begin_call (props_proxy, "GetAll", modem_get_all_cb, self, NULL, G_TYPE_STRING, MM_MODEM_INTERFACE, G_TYPE_INVALID); }
static void get_device_state_cb (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) { GValue value = {0,}; GError *error = NULL; NMDevice *nm_device = (NMDevice *) user_data; if (!dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { g_warning ("Error reading property: %s\n", error->message); g_error_free (error); return; } NMDeviceState state = g_value_get_uint (&value); if (state == NM_DEVICE_STATE_ACTIVATED) { dbus_g_proxy_begin_call (nm_device->prop_proxy, "Get", get_device_interface_cb, nm_device, NULL, G_TYPE_STRING, DEVICE_INTERFACE, G_TYPE_STRING, "Interface", G_TYPE_INVALID); } g_value_unset (&value); }
void nm_secret_agent_cancel_secrets (NMSecretAgent *self, gconstpointer call) { NMSecretAgentPrivate *priv; Request *r; g_return_if_fail (self != NULL); priv = NM_SECRET_AGENT_GET_PRIVATE (self); g_return_if_fail (priv->proxy != NULL); r = g_hash_table_lookup (priv->requests, call); g_return_if_fail (r != NULL); dbus_g_proxy_cancel_call (priv->proxy, (gpointer) call); dbus_g_proxy_begin_call (priv->proxy, "CancelGetSecrets", cancel_done, g_strdup (nm_secret_agent_get_description (self)), g_free, DBUS_TYPE_G_OBJECT_PATH, r->path, G_TYPE_STRING, r->setting_name, G_TYPE_INVALID); g_hash_table_remove (priv->requests, call); }
static void loc_props_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data) { GError *error = NULL; GHashTable *props = NULL; Modem *modem = user_data; if (!dbus_g_proxy_end_call (proxy, call, &error, DBUS_TYPE_G_MAP_OF_VARIANT, &props, G_TYPE_INVALID)) { g_warning ("%s: failed to get location interface properties: (%d) %s", __func__, error ? error->code : -1, error && error->message ? error->message : "(unknown)"); g_clear_error (&error); return; } modem_properties_changed (modem->loc_proxy, MM_DBUS_LOC_INTERFACE, props, modem); g_hash_table_destroy (props); /* Now that we know the device supports location services, get basic * modem properties and start grabbing location info. */ dbus_g_proxy_begin_call (modem->props_proxy, "GetAll", modem_props_cb, modem, NULL, G_TYPE_STRING, MM_DBUS_MODEM_INTERFACE, G_TYPE_INVALID); }
static gboolean online_init (void) { DBusGConnection *conn; if (proxy) return TRUE; conn = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL); if (!conn) { g_warning ("Cannot get connection to system message bus"); return FALSE; } proxy = dbus_g_proxy_new_for_name (conn, "net.connman", "/", "net.connman.Manager"); dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_add_signal (proxy, "StateChanged", G_TYPE_STRING, NULL); dbus_g_proxy_connect_signal (proxy, "StateChanged", (GCallback)state_changed, NULL, NULL); current_state = FALSE; /* Get the current state */ dbus_g_proxy_begin_call (proxy, "GetState", got_state_cb, NULL, NULL, G_TYPE_INVALID); return TRUE; }
static gboolean inhibit (RBGPMPlugin *plugin) { GtkWindow *window; plugin->timeout_id = 0; gulong xid = 0; if (plugin->cookie != 0) { rb_debug ("Was going to inhibit gnome-session, but we already have done"); return FALSE; } if (create_dbus_proxy (plugin) == FALSE) { return FALSE; } rb_debug ("inhibiting"); g_object_ref (plugin); g_object_get (plugin->shell, "window", &window, NULL); xid = GDK_WINDOW_XWINDOW (gtk_widget_get_window (GTK_WIDGET (window))); dbus_g_proxy_begin_call (plugin->proxy, "Inhibit", (DBusGProxyCallNotify) inhibit_cb, plugin, NULL, G_TYPE_STRING, "rhythmbox", G_TYPE_UINT, xid, G_TYPE_STRING, _("Playing"), G_TYPE_UINT, 8, /* flags */ G_TYPE_INVALID); return FALSE; }
/** * nm_remote_settings_save_hostname: * @settings: the %NMRemoteSettings * @hostname: the new persistent hostname to set, or NULL to clear any existing * persistent hostname * @callback: (scope async): callback to be called when the hostname operation completes * @user_data: caller-specific data passed to @callback * * Requests that the machine's persistent hostname be set to the specified value * or cleared. * * Returns: TRUE if the request was successful, FALSE if it failed **/ gboolean nm_remote_settings_save_hostname (NMRemoteSettings *settings, const char *hostname, NMRemoteSettingsSaveHostnameFunc callback, gpointer user_data) { NMRemoteSettingsPrivate *priv; SaveHostnameInfo *info; g_return_val_if_fail (settings != NULL, FALSE); g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE); g_return_val_if_fail (hostname != NULL, FALSE); g_return_val_if_fail (callback != NULL, FALSE); priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); info = g_malloc0 (sizeof (SaveHostnameInfo)); info->settings = settings; info->callback = callback; info->callback_data = user_data; dbus_g_proxy_begin_call (priv->proxy, "SaveHostname", save_hostname_cb, info, g_free, G_TYPE_STRING, hostname ? hostname : "", G_TYPE_INVALID); return TRUE; }
static void showlog_callback(BonoboUIComponent *ui, const char *path, Bonobo_UIComponent_EventType type, const char *state, gpointer user_data) { gboolean new_state; if (state == NULL || strcmp(state, "") == 0) { /* State goes blank when component is removed; ignore this. */ return; } new_state = strcmp(state, "0") != 0; if (1) { g_applet->last_showlog_state = new_state; if (g_applet->ui != NULL && workrave_is_running()) { dbus_g_proxy_begin_call(g_applet->ui, "NetworkLog", dbus_callback, NULL, NULL, G_TYPE_BOOLEAN, new_state, G_TYPE_INVALID); } } }
static void change_orient(PanelApplet *applet, PanelAppletOrient o, gpointer data) { switch (o) { case PANEL_APPLET_ORIENT_UP: g_applet->orientation = 0; break; case PANEL_APPLET_ORIENT_RIGHT: g_applet->orientation = 1; break; case PANEL_APPLET_ORIENT_DOWN: g_applet->orientation = 2; break; case PANEL_APPLET_ORIENT_LEFT: g_applet->orientation = 3; break; } if (g_applet->support != NULL && workrave_is_running()) { dbus_g_proxy_begin_call(g_applet->support, "SetOrientation", dbus_callback, NULL, NULL, G_TYPE_UINT, g_applet->orientation, G_TYPE_INVALID); } }
/** * Take the initiative of a connection. Actual connection establishment * is reported via "peer_connected" callback, as happens with accepted * (passive) connections. * * @param *btaddr The Bluetooth address * @param data_type The data type * @param reliability The reliability of the HDP channel * @return success in initiating connection procedure * (not necessarily connection will happen) */ gboolean plugin_bluez_connect(const char *btaddr, guint16 data_type, int reliability) { const char *channel_type; const app_object *app; gboolean ok = FALSE; char *addr = g_ascii_strdown(btaddr, -1); struct device_object *dev = get_device_object_by_addr(addr); if (!dev) { DEBUG("Device %s unknown by BlueZ", btaddr); goto finally; } app = find_application_by_type(data_type); if (!app) { DEBUG("Data type %d could not be matched to any application", data_type); DEBUG("Make sure you had configured the plug-in with all" "possible data types you need to use"); goto finally; } if (app->is_sink) { if (reliability != HDP_CHANNEL_ANY) { reliability = HDP_CHANNEL_ANY; DEBUG("HDP sinks can't choose channel type") DEBUG("Defaulting channel type to Any"); } } else { if (reliability == HDP_CHANNEL_ANY) { reliability = HDP_CHANNEL_RELIABLE; DEBUG("HDP sources must define channel type, cannot use Any") DEBUG("Defaulting channel type to Reliable"); } } if (reliability == HDP_CHANNEL_RELIABLE) { channel_type = "Reliable"; } else if (reliability == HDP_CHANNEL_STREAMING) { channel_type = "Streaming"; } else if (reliability == HDP_CHANNEL_ANY) { channel_type = "Any"; } else { DEBUG("Invalid channel type, defaulting to Reliable"); // safest choice channel_type = "Reliable"; } if (dbus_g_proxy_begin_call(dev->proxy, "CreateChannel", plugin_bluez_connect_cb, NULL, NULL, DBUS_TYPE_G_OBJECT_PATH, app->path, G_TYPE_STRING, channel_type, G_TYPE_INVALID)) ok = TRUE; finally: g_free(addr); return ok; }
static int wrappee_enum_trackers(DBusGConnection *conn, DBusGProxy *proxy, void *user) { enum_trackers_state_t *state = user; dbus_g_proxy_begin_call(proxy, "GetDevices", done_enum_trackers, state, g_free, G_TYPE_INVALID); return 0; }
static void init_network_manager (GUPnPNetworkManager *manager) { GUPnPNetworkManagerPrivate *priv; DBusError derror; GMainContext *main_context; priv = manager->priv; g_object_get (manager, "main-context", &main_context, NULL); /* Do fake open to initialize types */ dbus_g_connection_open ("", NULL); dbus_error_init (&derror); priv->dbus_connection = dbus_bus_get_private (DBUS_BUS_SYSTEM, &derror); if (priv->dbus_connection == NULL) { g_message ("Failed to connect to System Bus: %s", derror.message); return; } dbus_connection_setup_with_g_main (priv->dbus_connection, main_context); priv->connection = dbus_connection_get_g_connection (priv->dbus_connection); priv->manager_proxy = dbus_g_proxy_new_for_name (priv->connection, DBUS_SERVICE_NM, MANAGER_PATH, MANAGER_INTERFACE); dbus_g_proxy_add_signal (priv->manager_proxy, "DeviceAdded", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->manager_proxy, "DeviceAdded", G_CALLBACK (on_device_added), manager, NULL); dbus_g_proxy_add_signal (priv->manager_proxy, "DeviceRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->manager_proxy, "DeviceRemoved", G_CALLBACK (on_device_removed), manager, NULL); dbus_g_proxy_begin_call (priv->manager_proxy, "GetDevices", get_devices_cb, manager, NULL, G_TYPE_INVALID); }