Re: [Vala] Segmentation fault with d-bus and networkmanager



I think I found the problem, I logged dbus-monitor parameters that are
passed and I compared with those who are sent when I create the network
manually this is the difference:

Manualy mode:

   array [
...
            dict entry(
               string "ssid"
               variant                   array of bytes "foobar"
            )
...
   ]

with vala code:

   array [
...
            dict entry(
               string "ssid"
               variant                   array of bytes [
                     66 6f 6f 62 61 72 00
                  ]
            )
...
   ]

I set this parameter in this way:
...
HashTable<string,Variant> s_wifi = new HashTable<string,Variant>(str_hash,
str_equal);
s_wifi.insert("ssid", new Variant.bytestring("foobar"));
...

And most strange is that the connection is created O_o

How do I may set that parameter?

2011/10/3 Jose Luis Navarro <jlnavarro111 gmail com>

Goog point I'm going to try it.
Thanks


2011/10/1 JM <interflug1 gmx net>

I recommend using dbus-monitor from one terminal and start your program
from a second. Then (after your program crashed) stop dbus-monitor and
find the message sent by your program and check if the containing data
was packaged according to the specification of NetworkManager.
regards


Hi,

I'm trying to create a new wifi connection by d-bus but I get
"Segmentation
fault" with following code. What am I doing wrong?
Vala version: 0.13.4.6-33e1
Thanks,

/*
valac --pkg gio-2.0 create.vala
*/

[DBus (name = "org.freedesktop.NetworkManagerSettings")]
interface NMSettings : Object {
    public abstract ObjectPath AddConnection (HashTable<string,
HashTable<string,Variant>> hs) throws IOError;
}

int main (string[] args) {

var uuid = "cabfaf9e-4043-4afb-8506-0e6f4a225636";

HashTable<string,Variant> s_con = new
HashTable<string,Variant>(str_hash,
str_equal);
s_con.insert("id", new Variant.string("My AdHoc"));
s_con.insert("uuid", new Variant.string(uuid));
s_con.insert("type", new Variant.string("802-11-wireless"));
s_con.insert("name", new Variant.string("connection"));
s_con.insert("autoconnect", new Variant.boolean(false));

HashTable<string,Variant> s_wifi = new
HashTable<string,Variant>(str_hash,
str_equal);
s_wifi.insert("ssid", new Variant.bytestring("foobar"));
s_wifi.insert("mode", new Variant.string("adhoc"));
s_wifi.insert("security", new
Variant.string("802-11-wireless-security"));
s_wifi.insert("name", new Variant.string("802-11-wireless"));

HashTable<string,Variant> s_wsec = new
HashTable<string,Variant>(str_hash,
str_equal);
s_wsec.insert("key-mgmt", new Variant.string("none"));
s_wsec.insert("wep-key0", new
Variant.string("0123456789abcdef0123456789"));
s_wsec.insert("name", new Variant.string("802-11-wireless-security"));

HashTable<string,Variant> s_ip4 = new
HashTable<string,Variant>(str_hash,
str_equal);
s_ip4.insert("method", new Variant.string("link-local"));
s_ip4.insert("name", new Variant.string("ipv4"));

HashTable<string, HashTable<string,Variant>> con = new HashTable<string,
HashTable<string,Variant>>(str_hash, str_equal);
con.insert("connection", s_con);
con.insert("802-11-wireless", s_wifi);
con.insert("802-11-wireless-security", s_wsec);
con.insert("ipv4", s_ip4);

    try {

        NMSettings nm_set = Bus.get_proxy_sync (BusType.SYSTEM,
"org.freedesktop.NetworkManagerSystemSettings",
"/org/freedesktop/NetworkManagerSettings");
 var obj_path = nm_set.AddConnection(con);

    } catch (IOError e) {
        stderr.printf ("%s\n", e.message);
        return 1;
    }

    return 0;
}
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list


_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]