~ubuntu-branches/ubuntu/lucid/tomboy/lucid-proposed

« back to all changes in this revision

Viewing changes to Tomboy/dbus-sharp/dbus-sharp-glib/glib/GLib.cs

Tags: upstream-0.5.2
Import upstream version 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
        //FIXME: this API needs review and de-unixification. It is horrid, but gets the job done.
15
15
        public static class BusG
16
16
        {
17
 
                static bool SystemDispatch (IOChannel source, IOCondition condition, IntPtr data)
18
 
                {
19
 
                        Bus.System.Iterate ();
20
 
                        return true;
21
 
                }
22
 
 
23
 
                static bool SessionDispatch (IOChannel source, IOCondition condition, IntPtr data)
24
 
                {
25
 
                        Bus.Session.Iterate ();
26
 
                        return true;
27
 
                }
28
 
 
29
17
                static bool initialized = false;
30
18
                public static void Init ()
31
19
                {
32
20
                        if (initialized)
33
21
                                return;
34
22
 
35
 
                        Init (Bus.System, SystemDispatch);
36
 
                        Init (Bus.Session, SessionDispatch);
 
23
                        Init (Bus.System);
 
24
                        Init (Bus.Session);
 
25
                        //TODO: consider starter bus?
37
26
 
38
27
                        initialized = true;
39
28
                }
40
29
 
 
30
                public static void Init (Connection conn)
 
31
                {
 
32
                        IOFunc dispatchHandler = delegate (IOChannel source, IOCondition condition, IntPtr data) {
 
33
                                conn.Iterate ();
 
34
                                return true;
 
35
                        };
 
36
 
 
37
                        Init (conn, dispatchHandler);
 
38
                }
 
39
 
41
40
                public static void Init (Connection conn, IOFunc dispatchHandler)
42
41
                {
43
 
                        IOChannel channel = new IOChannel ((int)conn.SocketHandle);
 
42
                        IOChannel channel = new IOChannel ((int)conn.Transport.SocketHandle);
44
43
                        IO.AddWatch (channel, IOCondition.In, dispatchHandler);
45
44
                }
46
 
 
47
 
                //TODO: add public API to watch an arbitrary connection
48
45
        }
49
46
}