Thanks.
But no luck yet. Now it is segfaulting at OpenSessionWithParameters call.
I am using vala 0.5.6.
am I missing something else?
using GLib;
public class Sessiondb.Main : Object {
private const string CK_NAME = "org.freedesktop.ConsoleKit";
private const string CK_PATH = "/org/freedesktop/ConsoleKit";
private const string CK_INTERFACE = "org.freedesktop.ConsoleKit";
private const string CK_MANAGER_PATH =
"/org/freedesktop/ConsoleKit/Manager";
private const string CK_MANAGER_INTERFACE =
"org.freedesktop.ConsoleKit.Manager";
private const string CK_SEAT_INTERFACE =
"org.freedesktop.ConsoleKit.Seat";
private const string CK_SESSION_INTERFACE =
"org.freedesktop.ConsoleKit.Session";
private dynamic DBus.Object ckmanager;
public Main () {
}
public struct Test {
public string key;
public Value? value ;
Test (string a, Value? b){
key = a;
value = b;
}
}
public void run () {
try {
var conn = DBus.Bus.get (DBus.BusType.SYSTEM);
this.ckmanager = conn.get_object ("org.freedesktop.ConsoleKit",
"/org/freedesktop/ConsoleKit/Manager",
"org.freedesktop.ConsoleKit.Manager");
Value sessiontype2 = Value (typeof(string));
sessiontype2.set_string ("sessiondb");
Test sessiontype = Test ("session-type", sessiontype2);
Test[] parameters = {sessiontype};
stderr.printf ("parameters[0].key = %s\n", parameters[0].key);
stderr.printf ("parameters[0].value.get_string() = %s\n",
parameters[0].value.get_string());
stderr.printf ("Executing OpenSessionWithParameters\n");
string cookie = this.ckmanager.OpenSessionWithParameters
(parameters);
stderr.printf ("finished: %s \n", cookie);
} catch (Error e) {
stderr.printf ("Oops: %s\n", e.message);
}
}
static int main (string[] args) {
var main = new Main ();
main.run ();
return 0;
}
}
Thanks
2009/2/19 Frederik Sdun <[email protected]>
> Hi,
>
> the siganture a(sv) is an array of structs with a string and a value,
> not a Dict/HashTable. A hashtable has the signature a{av}.
>
> Regards, Frederik
>
> Am Donnerstag, den 19.02.2009, 00:32 -0300 schrieb Marcelo Boveto Shima:
> > Hello!
> >
> > I am trying to invoke some ConsoleKit methods and I succeed on
> > almost every method, but not OpenSessionWithParameters.
> > It has the signature a(sv) (1). I don´t know what I am doing wrong.
> > I created a method with the same signature and it worked.
> >
> > It works with python/dbus.
> >
> > The code is:
> > using GLib;
> >
> > public class Sessiondb.Main : Object {
> > private const string CK_NAME = "org.freedesktop.ConsoleKit";
> > private const string CK_PATH = "/org/freedesktop/ConsoleKit";
> > private const string CK_INTERFACE = "org.freedesktop.ConsoleKit";
> > private const string CK_MANAGER_PATH =
> > "/org/freedesktop/ConsoleKit/Manager";
> > private const string CK_MANAGER_INTERFACE =
> > "org.freedesktop.ConsoleKit.Manager";
> > private const string CK_SEAT_INTERFACE =
> > "org.freedesktop.ConsoleKit.Seat";
> > private const string CK_SESSION_INTERFACE =
> > "org.freedesktop.ConsoleKit.Session";
> >
> > private dynamic DBus.Object ckmanager;
> >
> > public Main () {
> > }
> > public void run () {
> > try {
> > var conn = DBus.Bus.get (DBus.BusType.SYSTEM);
> >
> > this.ckmanager = conn.get_object
> > ("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager",
> > "org.freedesktop.ConsoleKit.Manager");
> >
> > HashTable<string,Value?> parameters = new
> > HashTable<string,Value?>(str_hash,str_equal);
> >
> > Value sessiontype = Value (typeof(string));
> > sessiontype.set_string ("sessiondb");
> > parameters.insert("session-type" , sessiontype);
> >
> > string cookie = ckmanager.OpenSessionWithParameters
> > (parameters);
> >
> > stderr.printf ("finished: %s \n", cookie);
> >
> > } catch (Error e) {
> > stderr.printf ("Oops: %s\n", e.message);
> > }
> > }
> > static int main (string[] args) {
> > var main = new Main ();
> > main.run ();
> > return 0;
> > }
> > }
> >
> >
> > The error is Method "OpenSessionWithParameters" with signature "a{sv}"
> > on interface "org.freedesktop.ConsoleKit.Manager" doesn't exist.
> >
> > Thanks
> > Shima.
> >
> > (1)
> >
> http://people.freedesktop.org/~mccann/doc/ConsoleKit/ConsoleKit.html#Manager.OpenSessionWithParameters<http://people.freedesktop.org/%7Emccann/doc/ConsoleKit/ConsoleKit.html#Manager.OpenSessionWithParameters>
> > _______________________________________________
> > Vala-list mailing list
> > [email protected]
> > http://mail.gnome.org/mailman/listinfo/vala-list
>
> _______________________________________________
> Vala-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/vala-list
>
>
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list