/// <summary>
        /// Method to instantiate and possibly connect/authenticate if
        /// all the credentials are available
        /// <summary>
        public static void CreateAccountObject(string accountname, bool connect)
        {
            string username = null;
            string password = null;
            string server;
            string port;

            // hack - for now we support "Google Talk"
            if (accountname.ToLower() != "google talk")
            {
                throw new ApplicationException(String.Format("{0} account is not configured", accountname));
            }

            // FIXME: Temporary - read our hard coded Google Talk settings
            if (!GetGoogleTalkCredentialsHack(out username, out password))
            {
                Logger.Error("Could not retrieve GoogleTalk account information from Gnome.Keyring.  Probably gonna crash!");
            }
            else
            {
                Logger.Info("Successfully retrieved GoogleTalk credentials from Gnome.Keyring for {0}.", username);
            }

            server = Preferences.Get(Preferences.GoogleTalkServer) as string;
            port   = Preferences.Get(Preferences.GoogleTalkPort) as string;

            // Check if a connection already exists to the targ account
            Banter.JabberAccount account;
            IConnection          existingConnection =
                AccountManagement.GetExistingConnection(
                    "org.freedesktop.Telepathy.ConnectionManager.gabble",
                    //Banter.ProtocolName.Jabber,
                    username);

            if (existingConnection != null)
            {
                // call Account constructor for existing connection
                account = new JabberAccount(existingConnection);
                accounts.Add(account);
            }
            else
            {
                account =
                    new Banter.JabberAccount(
                        "Google Talk",
                        Banter.ProtocolName.Jabber,
                        username,
                        password,
                        server,
                        port,
                        false,
                        true,
                        false);

                account.Default = true;
                try
                {
                    accounts.Add(account);

                    if (connect == true)
                    {
                        account.Connect(true);
                    }
                } catch (Exception es) {
                    Logger.Debug(es.Message);
                    Logger.Debug(es.StackTrace);
                } finally {
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Method to instantiate and possibly connect/authenticate if
        /// all the credentials are available
        /// <summary>
        public static void CreateAccountObject(string accountname, bool connect)
        {
            string username = null;
            string password = null;
            string server;
            string port;

            // hack - for now we support "Google Talk"
            if (accountname.ToLower() != "google talk")
            {
                throw new ApplicationException (String.Format ("{0} account is not configured", accountname));
            }

            // FIXME: Temporary - read our hard coded Google Talk settings
            if (!GetGoogleTalkCredentialsHack (out username, out password)) {
                Logger.Error ("Could not retrieve GoogleTalk account information from Gnome.Keyring.  Probably gonna crash!");
            } else {
                Logger.Info ("Successfully retrieved GoogleTalk credentials from Gnome.Keyring for {0}.", username);
            }

            server = Preferences.Get (Preferences.GoogleTalkServer) as string;
            port = Preferences.Get (Preferences.GoogleTalkPort) as string;

            // Check if a connection already exists to the targ account
            Banter.JabberAccount account;
            IConnection existingConnection =
                AccountManagement.GetExistingConnection(
                    "org.freedesktop.Telepathy.ConnectionManager.gabble",
                    //Banter.ProtocolName.Jabber,
                    username);

            if (existingConnection != null) {
                // call Account constructor for existing connection
                account = new JabberAccount (existingConnection);
                accounts.Add (account);
            } else {
                account =
                    new Banter.JabberAccount (
                            "Google Talk",
                            Banter.ProtocolName.Jabber,
                            username,
                            password,
                            server,
                            port,
                            false,
                            true,
                            false);

                account.Default = true;
                try
                {
                    accounts.Add (account);

                    if (connect == true)
                        account.Connect (true);

                } catch (Exception es){
                    Logger.Debug (es.Message);
                    Logger.Debug (es.StackTrace);
                } finally {

                }
            }
        }