Esempio n. 1
0
        public Client(string[] args)
        {
            Log.Information ("Starting Synapse");

            try {
                PlatformHacks.SetProcessName("synapse");
            } catch (Exception ex) {
                Console.WriteLine("[WARNING] Failed to set process name: " + ex.Message);
            }

            GLib.Global.ProgramName = "Synapse";
            Gtk.Application.Init();

            m_App = new QApplication(args);
            m_App.QuitOnLastWindowClosed = false;
            m_App.ApplicationName = "Synapse";
            m_App.ApplicationVersion = "0.1";

            InitQtWebKit.InitSmoke();

            m_ResourceFileEngineHandler = new ResourceFileEngineHandler();
            m_AvatarFileEngineHandler = new AvatarFileEngineHandler();

            Application.Initialize(this);

            if (Application.Debugging) {
                QtTraceListener listener = new QtTraceListener();
                listener.TraceOutputOptions = TraceOptions.Callstack;
                Debug.Listeners.Add(listener);
                Debug.Listeners.Add(new ConsoleTraceListener());
                Debug.WriteLine("Debug Mode On");
            }

            AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;

            if (!Application.CommandLine.Contains("disable-dbus")) {
                try {
                    NDesk.DBus.BusG.Init();
                } catch (Exception ex) {
                    Console.Error.WriteLine("Failed to initialize DBUS: " + ex);
                }
            } else {
                Console.WriteLine("DBus disabled by request.");
            }

            // XXX: I dont like all of these being here.
            ServiceManager.RegisterService<Synapse.Xmpp.Services.XmppService>();
            ServiceManager.RegisterService<Synapse.Xmpp.Services.AccountService>();
            ServiceManager.RegisterService<Synapse.QtClient.OctyService>();
            ServiceManager.RegisterService<Synapse.Xmpp.Services.ShoutService>();
            ServiceManager.RegisterService<Synapse.Xmpp.Services.GeoService>();
            ServiceManager.RegisterService<GuiService>();

            QWebSettings.GlobalSettings().SetAttribute(QWebSettings.WebAttribute.DeveloperExtrasEnabled, true);
            QWebSettings.GlobalSettings().SetAttribute(QWebSettings.WebAttribute.PluginsEnabled, true);

            if (Application.CommandLine.Contains ("uninstalled"))
                ConversationWidget.ThemesDirectory = Path.Combine(Environment.CurrentDirectory, "themes");
            else
                ConversationWidget.ThemesDirectory = Path.Combine(Paths.InstalledApplicationData, "themes");

            Application.Run();

            QApplication.Invoke(delegate {
                /* Create the UI */
                Gui.MainWindow = new MainWindow();
                Gui.TrayIcon = new TrayIcon(m_App);
                Gui.TabbedChatsWindow = new TabbedChatsWindow();

                OnStarted();

                Gui.TrayIcon.Show();

                Gui.MainWindow.Show();
            });

            QApplication.Exec();
        }
Esempio n. 2
0
        public Client(string[] args)
        {
            Log.Information("Starting Synapse");

            try {
                PlatformHacks.SetProcessName("synapse");
            } catch (Exception ex) {
                Console.WriteLine("[WARNING] Failed to set process name: " + ex.Message);
            }

            GLib.Global.ProgramName = "Synapse";
            Gtk.Application.Init();

            m_App = new QApplication(args);
            m_App.QuitOnLastWindowClosed = false;
            m_App.ApplicationName        = "Synapse";
            m_App.ApplicationVersion     = "0.1";

            InitQtWebKit.InitSmoke();

            m_ResourceFileEngineHandler = new ResourceFileEngineHandler();
            m_AvatarFileEngineHandler   = new AvatarFileEngineHandler();

            Application.Initialize(this);

            if (Application.Debugging)
            {
                QtTraceListener listener = new QtTraceListener();
                listener.TraceOutputOptions = TraceOptions.Callstack;
                Debug.Listeners.Add(listener);
                Debug.Listeners.Add(new ConsoleTraceListener());
                Debug.WriteLine("Debug Mode On");
            }

            AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;

            if (!Application.CommandLine.Contains("disable-dbus"))
            {
                try {
                    NDesk.DBus.BusG.Init();
                } catch (Exception ex) {
                    Console.Error.WriteLine("Failed to initialize DBUS: " + ex);
                }
            }
            else
            {
                Console.WriteLine("DBus disabled by request.");
            }

            // XXX: I dont like all of these being here.
            ServiceManager.RegisterService <Synapse.Xmpp.Services.XmppService>();
            ServiceManager.RegisterService <Synapse.Xmpp.Services.AccountService>();
            ServiceManager.RegisterService <Synapse.QtClient.OctyService>();
            ServiceManager.RegisterService <Synapse.Xmpp.Services.ShoutService>();
            ServiceManager.RegisterService <Synapse.Xmpp.Services.GeoService>();
            ServiceManager.RegisterService <GuiService>();

            QWebSettings.GlobalSettings().SetAttribute(QWebSettings.WebAttribute.DeveloperExtrasEnabled, true);
            QWebSettings.GlobalSettings().SetAttribute(QWebSettings.WebAttribute.PluginsEnabled, true);

            if (Application.CommandLine.Contains("uninstalled"))
            {
                ConversationWidget.ThemesDirectory = Path.Combine(Environment.CurrentDirectory, "themes");
            }
            else
            {
                ConversationWidget.ThemesDirectory = Path.Combine(Paths.InstalledApplicationData, "themes");
            }

            Application.Run();

            QApplication.Invoke(delegate {
                /* Create the UI */
                Gui.MainWindow        = new MainWindow();
                Gui.TrayIcon          = new TrayIcon(m_App);
                Gui.TabbedChatsWindow = new TabbedChatsWindow();

                OnStarted();

                Gui.TrayIcon.Show();

                Gui.MainWindow.Show();
            });

            QApplication.Exec();
        }