Re: Call AddConnection DBus
- From: Dan Williams <dcbw redhat com>
- To: rain blue <b123114 gmail com>
- Cc: networkmanager-list gnome org
- Subject: Re: Call AddConnection DBus
- Date: Tue, 28 Sep 2010 16:35:10 -0500
On Mon, 2010-09-27 at 16:48 +0800, rain blue wrote:
> Dear,
> I found this type. But it will occur error.
> i will check it. Thanks everyone.
There's various code inside nm-applet that does this, but the easiest
way to do it is probably to (assuming an Ethernet connection):
#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
#define DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT))
NMConnection *connection;
NMSettingConnection *s_con;
NMSettingWired *s_wired;
char *uuid;
GHashTable *hash;
/* Create a new connection object */
connection = nm_connection_new ();
/* Build up the 'connection' Setting */
s_con = (NMSettingConnection *) nm_setting_connection_new ();
uuid = nm_utils_uuid_generate ();
g_object_set (G_OBJECT (s_con),
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_ID, "Test connection",
NULL);
g_free (uuid);
nm_connection_add_setting (connection, NM_SETTING (s_con));
/* Build up the 'wired' Setting */
s_wired = (NMSettingWired *) nm_setting_wired_new ();
nm_connection_add_setting (connection, NM_SETTING (s_wired));
hash = nm_connection_to_hash (connection);
dbus_g_proxy_call (proxy, "AddConnection", &error,
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
G_TYPE_INVALID);
g_hash_table_destroy (hash);
g_object_unref (connection);
>
> dbus_g_type_get_map("GHashTable",
> G_TYPE_STRING, dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
> G_TYPE_VALUE));
> /* ------------------------------------------ */
> g_type_init ();
> p_source_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM,
> &p_source_error);
> if (!p_source_bus)
> printf ("Couldn't connect to session bus");
>
>
> p_source_object = dbus_g_proxy_new_for_name
> (p_source_bus,
>
> "org.freedesktop.NetworkManagerSystemSettings",
>
> "/org/freedesktop/NetworkManagerSettings",
>
> "org.freedesktop.NetworkManagerSettings");
> if (!p_source_object)
> printf ("Failed to get name owner");
>
>
> if (!dbus_g_proxy_call (p_source_object,
> "AddConnection", &p_source_error, , s_con, G_TYPE_INVALID,
> G_TYPE_INVALID))
>
> ^^
>
> What is it G_type a{sa{sv}} that i need input?
>
> Or could not use c code to add?
> Thanks
> blue
>
>
> _______________________________________________
> networkmanager-list mailing list
> networkmanager-list gnome org
> http://mail.gnome.org/mailman/listinfo/networkmanager-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]