static connman_bool_t tethering_create(const char *path, struct connman_technology *technology, const char *bridge, connman_bool_t enabled) { struct tethering_info *tethering = g_new0(struct tethering_info, 1); GDBusProxy *proxy; const char *method; connman_bool_t result; DBG("path %s bridge %s", path, bridge); if (bridge == NULL) return -EINVAL; proxy = g_dbus_proxy_new(client, path, "org.bluez.NetworkServer1"); if (proxy == NULL) return FALSE; tethering->technology = technology; tethering->bridge = g_strdup(bridge); tethering->enable = enabled; if (tethering->enable) method = "Register"; else method = "Unregister"; result = g_dbus_proxy_method_call(proxy, method, tethering_append, tethering_create_cb, tethering, tethering_free); g_dbus_proxy_unref(proxy); return result; }
static void pan_create(GDBusProxy *network_proxy) { const char *path = g_dbus_proxy_get_path(network_proxy); struct bluetooth_pan *pan; pan = g_try_new0(struct bluetooth_pan, 1); if (!pan) { connman_error("Out of memory creating PAN NAP"); return; } g_hash_table_replace(networks, g_strdup(path), pan); pan->btnetwork_proxy = g_dbus_proxy_ref(network_proxy); pan->btdevice_proxy = g_dbus_proxy_new(client, path, "org.bluez.Device1"); if (!pan->btdevice_proxy) { connman_error("Cannot create BT PAN watcher %s", path); g_hash_table_remove(networks, path); return; } g_dbus_proxy_set_property_watch(pan->btnetwork_proxy, btnetwork_property_change, NULL); g_dbus_proxy_set_property_watch(pan->btdevice_proxy, btdevice_property_change, NULL); DBG("pan %p %s role %s", pan, path, proxy_get_role(pan->btdevice_proxy)); pan_create_nap(pan); }
static void gis_language_page_constructed (GObject *object) { GisLanguagePage *page = GIS_LANGUAGE_PAGE (object); GisLanguagePagePrivate *priv = gis_language_page_get_instance_private (page); GDBusConnection *bus; g_type_ensure (CC_TYPE_LANGUAGE_CHOOSER); G_OBJECT_CLASS (gis_language_page_parent_class)->constructed (object); g_signal_connect (priv->language_chooser, "notify::language", G_CALLBACK (language_changed), page); /* If we're in new user mode then we're manipulating system settings */ if (gis_driver_get_mode (GIS_PAGE (page)->driver) == GIS_DRIVER_MODE_NEW_USER) { priv->permission = polkit_permission_new_sync ("org.freedesktop.locale1.set-locale", NULL, NULL, NULL); bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL); g_dbus_proxy_new (bus, G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES, NULL, "org.freedesktop.locale1", "/org/freedesktop/locale1", "org.freedesktop.locale1", priv->cancellable, (GAsyncReadyCallback) localed_proxy_ready, object); g_object_unref (bus); } gis_page_set_complete (GIS_PAGE (page), TRUE); gtk_widget_show (GTK_WIDGET (page)); }
void evd_dbus_agent_new_proxy (GObject *object, guint connection_id, GDBusProxyFlags flags, const gchar *name, const gchar *object_path, const gchar *iface_name, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GDBusConnection *conn; GSimpleAsyncResult *res; GError *error = NULL; ProxyData *proxy_data; g_return_if_fail (G_IS_OBJECT (object)); g_return_if_fail (connection_id > 0); res = g_simple_async_result_new (object, callback, user_data, evd_dbus_agent_new_proxy); if ( (conn = evd_dbus_agent_get_connection (object, connection_id, &error)) != NULL) { ObjectData *data; data = evd_dbus_agent_get_object_data (object); g_simple_async_result_set_op_res_gpointer (res, data, NULL); proxy_data = g_slice_new (ProxyData); proxy_data->obj_data = data; proxy_data->conn_id = connection_id; proxy_data->async_res = res; proxy_data->proxy = NULL; g_dbus_proxy_new (conn, flags, NULL, name, object_path, iface_name, cancellable, evd_dbus_agent_on_new_dbus_proxy, proxy_data); } else { g_simple_async_result_set_from_error (res, error); g_error_free (error); g_simple_async_result_complete_in_idle (res); g_object_unref (res); } }
static void process_introspect_node (CockpitFakeManager *self, PokeContext *poke, GDBusNodeInfo *node) { GHashTable *present = NULL; GDBusInterfaceInfo *iface; GDBusProxyFlags flags; GHashTableIter iter; GDBusProxy *proxy; gint i; if (poke->object) present = cockpit_object_proxy_interfaces (poke->object); for (i = 0; node->interfaces && node->interfaces[i] != NULL; i++) { iface = node->interfaces[i]; if (!iface->name) { g_warning ("Received interface from %s at %s without name", self->bus_name, poke->object_path); continue; } /* No proxeis for these interfaces */ if (g_str_equal (iface->name, "org.freedesktop.DBus.Properties") || g_str_equal (iface->name, "org.freedesktop.DBus.Peer") || g_str_equal (iface->name, "org.freedesktop.DBus.Introspectable")) continue; /* Already have this */ if (present && g_hash_table_remove (present, iface->name)) continue; flags = G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START; g_dbus_proxy_new (self->connection, flags, iface, self->bus_name_owner, poke->object_path, iface->name, self->cancellable, on_poke_proxy, poke); poke->outstanding++; } /* Remove any interfaces no longer in introspection data */ if (present) { g_hash_table_iter_init (&iter, present); while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&proxy)) poke->removed = g_list_prepend (poke->removed, g_object_ref (proxy)); g_hash_table_destroy (present); } process_introspect_children (self, poke->object_path, node); if (poke->outstanding == 0) poke_apply_changes_and_finish (self, poke); }
static void set_session_over_handler (GDBusConnection *bus) { g_assert (bus != NULL); g_dbus_proxy_new (bus, G_DBUS_PROXY_FLAGS_NONE, NULL, GNOME_SESSION_DBUS_NAME, GNOME_SESSION_DBUS_OBJECT, GNOME_SESSION_DBUS_INTERFACE, NULL, (GAsyncReadyCallback) got_session_proxy, NULL); watch_for_term_signal (manager); }
static struct advertisement *advertisement_create(DBusConnection *conn, DBusMessage *msg, const char *path) { struct advertisement *ad; const char *sender = dbus_message_get_sender(msg); if (!path || !g_str_has_prefix(path, "/")) return NULL; ad = new0(struct advertisement, 1); if (!ad) return NULL; ad->client = g_dbus_client_new_full(conn, sender, path, path); if (!ad->client) goto fail; ad->owner = g_strdup(sender); if (!ad->owner) goto fail; ad->path = g_strdup(path); if (!ad->path) goto fail; DBG("Adding proxy for %s", path); ad->proxy = g_dbus_proxy_new(ad->client, path, LE_ADVERTISEMENT_IFACE); if (!ad->proxy) goto fail; g_dbus_client_set_proxy_handlers(ad->client, advertisement_proxy_added, NULL, NULL, ad); ad->reg = dbus_message_ref(msg); ad->data = bt_ad_new(); if (!ad->data) goto fail; return ad; fail: advertisement_free(ad); return NULL; }
static void pk_appeared_cb (GDBusConnection *conn, const gchar *name, const gchar *owner, gpointer user_data) { GtkAppChooserOnlinePk *self = user_data; /* create the proxy */ g_dbus_proxy_new (conn, 0, NULL, "org.freedesktop.PackageKit", "/org/freedesktop/PackageKit", "org.freedesktop.PackageKit.Modify", NULL, pk_proxy_created_cb, self); g_bus_unwatch_name (self->priv->watch_id); }
static gboolean on_new_connection(GDBusServer *server, GDBusConnection *connection, gpointer data) { /* Create dbus proxy. */ g_return_val_if_fail(G_IS_DBUS_CONNECTION(connection), FALSE); g_signal_connect(connection, "closed", G_CALLBACK(on_connection_close), NULL); g_dbus_proxy_new(connection, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, NULL, NULL, VB_WEBEXTENSION_OBJECT_PATH, VB_WEBEXTENSION_INTERFACE, NULL, (GAsyncReadyCallback)on_proxy_created, NULL); return TRUE; }
static void connect_handler(DBusConnection *connection, void *user_data) { GDBusClient *client = user_data; GDBusProxy *proxy; g_print("Bluetooth connected\n"); proxy = g_dbus_proxy_new(client, "/org/bluez", "org.bluez.ProfileManager1"); if (!proxy) return; g_dbus_register_interface(connection, IAP_PATH, "org.bluez.Profile1", methods, NULL, NULL, NULL, NULL); g_dbus_proxy_method_call(proxy, "RegisterProfile", register_profile_setup, register_profile_reply, NULL, NULL); g_dbus_proxy_unref(proxy); }
static void _fcitx_client_create_ic_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) { FcitxClient* self = (FcitxClient*) user_data; if (self->priv->cancellable) { g_object_unref (self->priv->cancellable); self->priv->cancellable = NULL; } GVariant* result = g_dbus_proxy_call_finish(G_DBUS_PROXY(source_object), res, NULL); if (!result) { /* unref for _fcitx_client_phase1_finish */ g_object_unref(self); return; } gboolean enable; guint32 key1, state1, key2, state2; g_variant_get(result, "(ibuuuu)", &self->priv->id, &enable, &key1, &state1, &key2, &state2); g_variant_unref(result); sprintf(self->priv->icname, FCITX_IC_DBUS_PATH, self->priv->id); self->priv->cancellable = g_cancellable_new (); g_dbus_proxy_new( fcitx_connection_get_g_dbus_connection(self->priv->connection), G_DBUS_PROXY_FLAGS_NONE, _fcitx_client_get_clientic_info(), self->priv->servicename, self->priv->icname, FCITX_IC_DBUS_INTERFACE, self->priv->cancellable, _fcitx_client_create_ic_phase2_finished, self ); }
static void _fcitx_client_create_ic(FcitxConnection* connection, gpointer user_data) { FCITX_UNUSED(connection); fcitx_gclient_debug("_fcitx_client_create_ic"); FcitxClient *self = user_data; _fcitx_client_clean_up(self, FALSE); g_object_ref(self); self->priv->cancellable = g_cancellable_new (); g_dbus_proxy_new( fcitx_connection_get_g_dbus_connection(self->priv->connection), G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, _fcitx_client_get_interface_info(), self->priv->servicename, FCITX_IM_DBUS_PATH, FCITX_IM_DBUS_INTERFACE, self->priv->cancellable, _fcitx_client_create_ic_phase1_finished, self ); }
static int qmi_init(void) { int err = 0; DBG(""); err = sem_init(&new_device_sem, 0, 0); if(err == -1) { connman_error("Failure init semaphore, error %d", errno); return -errno; } /* Create new hash table to store all connecting devices */ qmi_hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, free_hash_values); if(qmi_hash == NULL) { connman_error("Hash table could not be created."); return -ENOMEM; } connection = connman_dbus_get_connection(); if(connection == NULL) { connman_error("D-Bus connection failed"); return -EIO; } /* Create new D-Bus client to address qmi-dbus server */ qmi_client = g_dbus_client_new( connection, QMI_SERVICE, QMI_PATH); if(qmi_client == NULL) { connman_error("D-Bus client not created"); return -EIO; } /* Create new proxy client to address qmi-dbus manager interface */ qmi_proxy_manager = g_dbus_proxy_new( qmi_client, QMI_MANAGER_PATH, QMI_MANAGER_INTERFACE); if(qmi_proxy_manager == NULL) { connman_error("QMI proxy manager not created"); g_dbus_client_unref(qmi_client); return -EIO; } /* Watch appearing qmi-dbus */ watch_service = g_dbus_add_service_watch( connection, QMI_SERVICE, on_handle_qmi_connect, on_handle_qmi_disconnect, NULL, NULL); /* Watching qmi-dbus signals */ watch_property_changed = g_dbus_add_signal_watch( connection, QMI_SERVICE, NULL, QMI_DEVICE_INTERFACE, PROPERTY_CHANGED, on_handle_property_changed, NULL, NULL); watch_state_changed = g_dbus_add_signal_watch( connection, QMI_SERVICE, NULL, QMI_DEVICE_INTERFACE, STATE_CHANGED, on_handle_state_changed, NULL, NULL); watch_technology_changed = g_dbus_add_signal_watch( connection, QMI_SERVICE, NULL, QMI_DEVICE_INTERFACE, TECHNOLOGY_CHANGED, on_handle_technology_changed, NULL, NULL); if((watch_service == 0) || (watch_property_changed == 0) || (watch_state_changed == 0) || (watch_technology_changed == 0)) { connman_error("Adding service or signal watch"); err = -EIO; goto remove; } err = connman_network_driver_register(&network_driver); if(err < 0) { connman_error("Register network driver"); goto remove; } err = connman_device_driver_register(&qmi_driver); if(err < 0) { connman_error("Register device driver"); connman_network_driver_unregister(&network_driver); goto remove; } err = connman_technology_driver_register(&tech_driver); if(err < 0) { connman_error("Register technology driver"); connman_network_driver_unregister(&network_driver); connman_device_driver_unregister(&qmi_driver); goto remove; } return 0; remove: g_dbus_remove_watch(connection, watch_service); g_dbus_remove_watch(connection, watch_property_changed); g_dbus_remove_watch(connection, watch_state_changed); g_dbus_remove_watch(connection, watch_technology_changed); g_dbus_proxy_unref(qmi_proxy_manager); g_dbus_client_unref(qmi_client); dbus_connection_unref(connection); return err; }
/** * @brief Callback qmi device open modem */ static void open_modem_callback(DBusMessage *message, void *user_data) { DBusMessageIter iter; struct qmi_data *qmi = (struct qmi_data *)user_data; gchar *help; DBG("qmi data %p DBusmessage %p", qmi, message); if(qmi == NULL) { connman_error("No QMI device"); qmi->modem_opening = FALSE; return; } if(dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) { const char *dbus_error = dbus_message_get_error_name(message); connman_error("%s", dbus_error); qmi->modem_opening = FALSE; return; } if((dbus_message_iter_init(message, &iter) == TRUE) && (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_OBJECT_PATH)) { dbus_message_iter_get_basic(&iter, &help); qmi->object_path = g_strdup(help); } else { connman_error("Return type invalid"); qmi->modem_opening = FALSE; return; } DBG("Modem opened object path %s", qmi->object_path); if(!qmi->qmi_proxy_device) { qmi->qmi_proxy_device = g_dbus_proxy_new( qmi_client, qmi->object_path, QMI_DEVICE_INTERFACE); } if(qmi->qmi_proxy_device == NULL) { connman_error("QMI proxy device not created"); /* Just return, if failure we have a memory issue, then. */ return; } g_dbus_proxy_method_call( qmi->qmi_proxy_device, GET_PROPERTIES, NULL, open_modem_get_properties_callback, qmi, NULL); }
void setup_system (GtkBuilder *dialog) { gchar *language; GDBusConnection *bus; GtkWidget *button; localed_permission = polkit_permission_new_sync ("org.freedesktop.locale1.set-locale", NULL, NULL, NULL); if (localed_permission == NULL) { GtkWidget *tab_widget, *notebook; int num; tab_widget = WID ("table3"); notebook = WID ("region_notebook"); num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab_widget); gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), num); return; } g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, localed_permission); g_signal_connect (localed_permission, "notify", G_CALLBACK (on_permission_changed), dialog); on_permission_changed (localed_permission, NULL, dialog); button = WID ("copy_settings_button"); g_signal_connect (button, "clicked", G_CALLBACK (copy_settings), dialog); locale_settings = g_settings_new ("org.gnome.system.locale"); g_signal_connect (locale_settings, "changed::region", G_CALLBACK (locale_settings_changed), dialog); g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, locale_settings); xkb_settings = g_settings_new (GKBD_KEYBOARD_SCHEMA); g_signal_connect (xkb_settings, "changed::layouts", G_CALLBACK (xkb_settings_changed), dialog); g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, xkb_settings); /* Display user settings */ language = cc_common_language_get_current_language (); system_update_language (dialog, language); g_free (language); locale_settings_changed (locale_settings, "region", dialog); xkb_settings_changed (xkb_settings, "layouts", dialog); bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL); g_dbus_proxy_new (bus, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.locale1", "/org/freedesktop/locale1", "org.freedesktop.locale1", NULL, (GAsyncReadyCallback) localed_proxy_ready, dialog); g_object_unref (bus); }
static void start_dnsmasq (NMDnsDnsmasq *self) { NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self); const char *dm_binary; const char *argv[15]; GPid pid = 0; guint idx = 0; NMBusManager *dbus_mgr; GDBusConnection *connection; if (priv->running) { /* the dnsmasq process is running. Nothing to do. */ return; } if (nm_dns_plugin_child_pid ((NMDnsPlugin *) self) > 0) { /* if we already have a child process spawned, don't do * it again. */ return; } dm_binary = nm_utils_find_helper ("dnsmasq", DNSMASQ_PATH, NULL); if (!dm_binary) { _LOGW ("could not find dnsmasq binary"); return; } argv[idx++] = dm_binary; argv[idx++] = "--no-resolv"; /* Use only commandline */ argv[idx++] = "--keep-in-foreground"; argv[idx++] = "--no-hosts"; /* don't use /etc/hosts to resolve */ argv[idx++] = "--bind-interfaces"; argv[idx++] = "--pid-file=" PIDFILE; argv[idx++] = "--listen-address=127.0.0.1"; /* Should work for both 4 and 6 */ argv[idx++] = "--cache-size=400"; argv[idx++] = "--conf-file=/dev/null"; /* avoid loading /etc/dnsmasq.conf */ argv[idx++] = "--proxy-dnssec"; /* Allow DNSSEC to pass through */ argv[idx++] = "--enable-dbus=" DNSMASQ_DBUS_SERVICE; /* dnsmasq exits if the conf dir is not present */ if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR)) argv[idx++] = "--conf-dir=" CONFDIR; argv[idx++] = NULL; nm_assert (idx <= G_N_ELEMENTS (argv)); /* And finally spawn dnsmasq */ pid = nm_dns_plugin_child_spawn (NM_DNS_PLUGIN (self), argv, PIDFILE, "bin/dnsmasq"); if (!pid) return; if ( priv->dnsmasq || priv->dnsmasq_cancellable) { /* we already have a proxy or are about to create it. * We are done. */ return; } dbus_mgr = nm_bus_manager_get (); g_return_if_fail (dbus_mgr); connection = nm_bus_manager_get_connection (dbus_mgr); g_return_if_fail (connection); priv->dnsmasq_cancellable = g_cancellable_new (); g_dbus_proxy_new (connection, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL, DNSMASQ_DBUS_SERVICE, DNSMASQ_DBUS_PATH, DNSMASQ_DBUS_SERVICE, priv->dnsmasq_cancellable, dnsmasq_proxy_cb, self); }