/// <summary>
 /// Account Management Shutdown Thread.
 /// </summary>
 static private void ShutdownThread()
 {
     foreach (Banter.Account account in AccountManagement.GetAccounts())
     {
         account.Disconnect();
     }
 }
Beispiel #2
0
        private void OnPreferencesDialogResponse(object sender, ResponseArgs args)
        {
            PreferencesDialog dialog   = sender as PreferencesDialog;
            string            username = dialog.GoogleTalkUsername;
            string            password = dialog.GoogleTalkPassword;

//			string sipUsername = dialog.SipUsername;
//			string sipPassword = dialog.SipPassword;

            ((Gtk.Widget)sender).Destroy();
            preferencesDialog = null;

            // If the username and password fields are not null, store them.
            if (username != null && password != null)
            {
                AccountManagement.SetGoogleTalkCredentialsHack(username, password);
            }
            else
            {
                Logger.Debug("Cannot save empty credentials.  Reverting to old credential state.");
            }

/*			if (sipUsername != null && sipPassword != null) {
 *                              AccountManagement.SetSipCredentialsHack (sipUsername, sipPassword);
 *                      } else {
 *                              Logger.Debug ("Cannot save empty SIP credentials.  Reverting to old credential state.");
 *                      }
 */
            // FIXME: Remove this eventually.  It's a hack to retry starting the AccountManager assuming the user entered credentials
            if (!initialized && AccountManagement.InitializedFinished() == false)
            {
                AccountManagement.Initialize();
            }
        }
Beispiel #3
0
        private bool InitializeIdle()
        {
            Logger.Debug("Initialize_Idle - called");

            SetupTrayIcon();
            OpenSavedGroupWindows();

            //GConfPreferencesProvider prefs = new GConfPreferencesProvider ();
            //Preferences.Init (prefs);
            //Preferences.SettingChanged += CompDirApplication.SettingChanged;

            // Startup the message log store
            // Note! not persisting messages yet so don't start
            //MessageStore.Start ();

            // Startup the messaging engine
            //MessageEngine.Start ();

            // Launch the configured telepathy providers
            //TelepathyProviderFactory.Start ();

            // Start account management and authenticate to any auto-login accounts
            AccountManagement.IAmUpEvent += OnAccountManagementReadyEvent;
            AccountManagement.Initialize();

            /*
             * if ((bool) Preferences.Get (Preferences.ENABLE_TRAY_ICON))
             *      ShowTrayIcon ();
             * else
             *      ShowCompDirWindow ();
             */
            return(false);
        }
Beispiel #4
0
        internal Conversation(ProviderUser providerUser)
        {
            this.Init(
                AccountManagement.GetAccountByName(providerUser.AccountName),
                providerUser);

            this.initiated = true;
        }
Beispiel #5
0
        /// <summary>
        /// Method to remove a user's membership with the current user
        /// </summary>
        public void RemoveUser()
        {
            if (this.relationship != ProviderUserRelationship.Linked)
            {
                throw new ApplicationException("User is not in the Linked relationship state");
            }

            // Need to get the account information so we can Remove the member
            Account account = AccountManagement.GetAccountByName(this.accountName);

            account.RemoveUser(this.id, String.Empty);
            ProviderUserManager.RemoveProviderUser(this.uri, this.protocol);
        }
        /// <summary>
        /// Account Management Startup Thread.
        /// </summary>
        static private void StartupThread()
        {
            Logger.Debug("AccountManagement::StartupThread - running");

            // For now just instantiate our one default account
            AccountManagement.CreateAccountObject("Google Talk", true);

            if (IAmUpEvent != null)
            {
                IAmUpEvent();
            }

            AccountManagement.initialized = true;
        }
Beispiel #7
0
        /// <summary>
        /// Authorize a user to enable chatting
        /// the user must be in the correct relationship state to authorize
        /// </summary>
        public void Authorize(string message)
        {
            if (this.relationship != ProviderUserRelationship.ReceivedInvitation)
            {
                throw new ApplicationException("User is not in a the correct authorization state");
            }

            // Need to get the account information so we can AddMember
            // to the correct group
            Account account = AccountManagement.GetAccountByName(this.accountName);

            account.AuthorizeUser(true, this.id, message);
            this.relationship = ProviderUserRelationship.Linked;
        }
Beispiel #8
0
        private bool ShutdownIdle()
        {
            AccountManagement.Shutdown();
            Logger.Debug("Finished Disconnecting accounts");

            // Shutdown the messaging engine
            //MessageEngine.Stop ();

            // Shutdown the message log store
            //MessageStore.Stop ();

            Gtk.Main.Quit();
            //program.Quit (); // Should this be called instead?
            return(false);
        }
Beispiel #9
0
        /// <summary>
        /// Method to revoke an outstanding invitation
        /// </summary>
        public void RevokeInvitation()
        {
            if (this.relationship != ProviderUserRelationship.SentInvitation)
            {
                throw new ApplicationException("User is not in the SentInvitation relationship state");
            }

            // Need to get the account information so we can AddMember
            // to the correct group
            Account account = AccountManagement.GetAccountByName(this.accountName);

            account.RemoveUser(this.id, String.Empty);
            this.relationship = ProviderUserRelationship.Unknown;
            ProviderUserManager.RemoveProviderUser(this.uri, this.protocol);
        }
Beispiel #10
0
        /// <summary>
        /// Deny a user who is requesting authorization to chat
        /// </summary>
        public void DenyAuthorization(string message)
        {
            if (this.relationship != ProviderUserRelationship.ReceivedInvitation)
            {
                throw new ApplicationException("User is not in the ReceivedInvitation state");
            }

            // Need to get the account information so we can AddMember
            // to the correct group
            Account account = AccountManagement.GetAccountByName(this.accountName);

            account.AuthorizeUser(false, this.id, message);
            this.relationship = ProviderUserRelationship.Unknown;

            ProviderUserManager.RemoveProviderUser(this.uri, this.protocol);
        }
Beispiel #11
0
        // <summary>
        // Temporary hack to determine whether we have non-empty fields for
        // server, port, username, and password for a GoogleTalk account.
        // </summary>
        static private bool AccountInformationFilled()
        {
            string username;
            string password;

            if (!AccountManagement.GetGoogleTalkCredentialsHack(out username, out password))
            {
                Logger.Debug("Could not get GoogleTalk credentials from GNOME Keyring.");
                return(false);
            }

            if (username == null || username.Trim().Length == 0)
            {
                Logger.Debug("GoogleTalk Username is empty");
                return(false);
            }

            if (password == null || password.Trim().Length == 0)
            {
                Logger.Debug("GoogleTalk Password is empty");
                return(false);
            }

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

            if (server == null || server.Trim().Length == 0)
            {
                Logger.Debug("GoogleTalk Server Address is empty");
                return(false);
            }

            if (port == null || port.Trim().Length == 0)
            {
                Logger.Debug("GoogleTalk Server Port is empty");
                return(false);
            }

            // Everything appears to have a value
            return(true);
        }
Beispiel #12
0
        private void OnAddPersonClicked(object sender, EventArgs args)
        {
            HIGMessageDialog dialog =
                new HIGMessageDialog(this, Gtk.DialogFlags.DestroyWithParent,
                                     Gtk.MessageType.Question,
                                     Gtk.ButtonsType.OkCancel,
                                     Catalog.GetString("Banter - Add person"),
                                     Catalog.GetString("Invite a new person"),
                                     Catalog.GetString("Enter the email address of the person you'd like to add."));

            Gtk.Entry emailEntry = new Entry();
            emailEntry.ActivatesDefault = true;
            dialog.ExtraWidget          = emailEntry;

            int returnCode = dialog.Run();

            if (returnCode == (int)Gtk.ResponseType.Ok)
            {
                string emailAddress = emailEntry.Text.Trim();
                // do stuff to add the new person

                Account account = null;
                foreach (Account acc in AccountManagement.GetAccounts())
                {
                    account = acc;
                    break;
                }

                if (account != null)
                {
                    account.InviteUser(emailAddress);
                }

                //Logger.Debug("FIXME: Add code to invite the person {0}", emailAddress);
            }

            dialog.Destroy();
        }
Beispiel #13
0
        void DialogRealized(object sender, EventArgs args)
        {
            // Load the stored preferences
            // Set the username and password if one exists
            string username;
            string password;

            if (AccountManagement.GetGoogleTalkCredentialsHack(out username, out password))
            {
                usernameEntry.Text = username;
                passwordEntry.Text = password;
            }
            else
            {
                usernameEntry.Text = Catalog.GetString("*****@*****.**");
            }

/*			if (AccountManagement.GetSipCredentialsHack (out username, out password)) {
 *                              sipUsernameEntry.Text = username;
 *                              sipPasswordEntry.Text = password;
 *                      } else {
 *                              sipUsernameEntry.Text = Catalog.GetString ("*****@*****.**");
 *                      }
 */     }
Beispiel #14
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 {
                }
            }
        }