~ubuntu-branches/ubuntu/gutsy/tomboy/gutsy-updates

« back to all changes in this revision

Viewing changes to Tomboy/dbus-sharp/Bus.cs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-11-22 19:22:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20061122192217-odnb17d1ib22okof
Tags: 0.5.1-0ubuntu1
* New upstream release:
  + New Managed D-Bus/DBusSharp (Sebastian Dröge)
  + Additional search interface improvements
  + More secure wrapper script to launch Tomboy.exe
  + Fix panel and TrayIcon resizing
  + Fix 1x1 pixel TrayIcon
  + Removed old tintin image
* debian/control:
  + Update build dependencies
* debian/patches/01-dbus0.9.patch,
  debian/patches/50_tintin.patch,
  debian/patches/51_tomboy-dllmap.patch,
  debian/patches/52_external-dbus-sharp.patch,
  debian/patches/53_tomboy-tray-icon.patch:
  + Dropped, merged upstream
* debian/rules,
  debian/tomboy.desktop:
  + Use upstream's desktop file again after it was fixed now
* debian/rules:
  + DBus service file path workaround removed, it's fixed upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
namespace DBus
2
 
{
3
 
  using System;
4
 
  using System.Runtime.InteropServices;
5
 
  using System.Diagnostics;
6
 
  
7
 
  public class Bus
8
 
  {
9
 
    // Keep in sync with C
10
 
    private enum BusType 
11
 
    {
12
 
      Session = 0,
13
 
      System = 1,
14
 
      Activation = 2
15
 
    }
16
 
 
17
 
    // Don't allow instantiation
18
 
    private Bus () { }
19
 
 
20
 
    public static Connection GetSessionBus() 
21
 
    {
22
 
      return GetBus(BusType.Session);
23
 
    }
24
 
 
25
 
    public static Connection GetSystemBus()
26
 
    {
27
 
      return GetBus(BusType.System);
28
 
    }
29
 
 
30
 
    private static Connection GetBus(BusType busType) 
31
 
    {
32
 
      Error error = new Error();
33
 
      error.Init();
34
 
      
35
 
      IntPtr rawConnection = dbus_bus_get((int) busType, ref error);
36
 
      
37
 
      if (rawConnection != IntPtr.Zero) {
38
 
        Connection connection = Connection.Wrap(rawConnection);
39
 
        connection.SetupWithMain();
40
 
        dbus_connection_unref(rawConnection);
41
 
 
42
 
        return connection;
43
 
      } else {
44
 
        throw new DBusException(error);
45
 
      }
46
 
    }
47
 
 
48
 
    [DllImport ("dbus-1")]
49
 
    private extern static IntPtr dbus_bus_get (int which, ref Error error);
50
 
 
51
 
    [DllImport ("dbus-1")]
52
 
    private extern static void dbus_connection_unref (IntPtr ptr);
53
 
  }
54
 
}