Disable AudioComponent do get everything to build nicely.
[chatter.git] / Phone.cs
blob840ea4aed5bf3ab52645880e16da40262eb76357
1 using System;
2 using System.Text;
3 using Gtk;
4 using System.Diagnostics;
5 using System.Runtime.InteropServices;
7 namespace Chatter
9 public class Phone
11 [DllImport("libc")]
12 private static extern int prctl(int option, byte [] arg2, ulong arg3 , ulong arg4, ulong arg5);
14 public static void SetProcessName (string name)
16 if (prctl (15 /* PR_SET_NAME */, Encoding.ASCII.GetBytes (name + '\0'), 0, 0,
17 0) != 0)
18 Global.Logger.Warning ("Error setting process name: " + Mono.Unix.Native.Stdlib.GetLastError());
21 static Widget.ChatterIcon icon;
22 static Widget.ContactWindow contact_window;
24 public static void Main ()
26 Gtk.Application.Init ();
27 Gtk.Widget.DefaultColormap = Gdk.Screen.Default.RgbaColormap;
28 SetProcessName ("Chatter");
30 contact_window = new Widget.ContactWindow (Global.PersistientState.AccountStore, Global.ConnectionStore);
31 contact_window.Show ();
33 contact_window.TreeView.Activated += OnContactActivate;
35 icon = new Widget.ChatterIcon ();
36 icon.ButtonPress += delegate { contact_window.Visible = !contact_window.Visible; };
37 icon.Show ();
39 AccountModel [] accounts = Global.PersistientState.AccountStore.Accounts;
40 foreach (AccountModel account in accounts)
42 if (account.AutoConnect)
43 Global.ConnectionStore.Activate (account);
46 if (accounts.Length == 0)
48 Widget.LabelNotify label = new Widget.LabelNotify ("Welcome to Chatter\nTo add an account click on Edit -> Accounts");
49 contact_window.AddNotify (label);
52 try
54 Application.Run ();
56 catch (Exception e)
58 Global.Logger.Error ("Fatal: " + e);
60 finally
62 // Clean up our connection mess if bad things happen
63 // Note ctrl-c or seg fault will miss this
64 Global.Cleanup ();
68 public static void OnContactActivate (ContactModel contact)
70 Global.Logger.Debug ("Activate Contact {0}", contact.Name);
72 // The made up policy is to activate a text channel
73 contact.ConnectionModel.InitiateTextChannel (contact);
74 contact.ConversationWindow.Show ();
77 /*
78 public static Widget.ChatterIcon NotificationIcon
80 get { return icon; }
83 public static void Quit ()
85 Application.Quit ();