public void OnEnableAccountToggled(object o, EventArgs args)
        {
            if (EnableAccountButton.HasFocus)
            {
                if (EnableAccountButton.Active != domain.Active)
                {
                    try
                    {
                        if (EnableAccountButton.Active)
                        {
                            domainController.ActivateDomain(domain.ID);
                        }
                        else
                        {
                            domainController.InactivateDomain(domain.ID);

                            // Also cause this account to be logged out
//							domainController.LogoutDomain(domain.ID);
//							domain.Authenticated = false;
                        }
                    }
                    catch (Exception e)
                    {
                        string header;
                        string message;

                        if (EnableAccountButton.Active)
                        {
                            header  = Util.GS("Could not enable this account");
                            message = Util.GS("There was an error enabling this account.");
                        }
                        else
                        {
                            header  = Util.GS("Could not disable this account");
                            message = Util.GS("There was an error disabling this account.");
                        }

                        // FIXME: Register this as a modal window
                        iFolderMsgDialog dg = new iFolderMsgDialog(
                            this,
                            iFolderMsgDialog.DialogType.Error,
                            iFolderMsgDialog.ButtonSet.Ok,
                            "",
                            header,
                            message,
                            e.Message);
                        dg.Run();
                        dg.Hide();
                        dg.Destroy();

                        // Change the toggle button back to its original value
                        EnableAccountButton.Toggled -= new EventHandler(OnEnableAccountToggled);
                        EnableAccountButton.Active   = !EnableAccountButton.Active;
                        EnableAccountButton.Toggled -= new EventHandler(OnEnableAccountToggled);
                    }
                }
            }
        }
Exemple #2
0
        private void OnlineToggled(object o, ToggledArgs args)
        {
            // Disable the ability for the user to toggle the checkbox
            onlineToggleButton.Activatable = false;

            TreeIter iter;
            TreePath path = new TreePath(args.Path);

            if (AccTreeStore.GetIter(out iter, path))
            {
                string            domainID = (string)AccTreeStore.GetValue(iter, 0);
                DomainInformation dom      = domainController.GetDomain(domainID);
                IDomainProviderUI provider = domainProviderUI.GetProviderForID(domainID);
                if (provider != null)
                {
                    // FIXME: Add some functionality into the provider interface so we know what to do instead of just inactivating the account
                    if (dom.Active)
                    {
                        domainController.InactivateDomain(dom.ID);
                    }
                    else
                    {
                        domainController.ActivateDomain(dom.ID);
                    }
                }
                else
                {
                    if (dom != null)
                    {
                        if (!dom.Authenticated)
                        {
                            LoginDomain(dom);
                        }
                        else
                        {
                            LogoutDomain(dom);
                        }
                    }
                }
                UpdateDomainStatus(dom.ID);
            }

            // Reenable the ability for the user to toggle the checkbox
            onlineToggleButton.Activatable = true;
        }