Ejemplo n.º 1
0
        /// This method is called by Successful login handler, it is called before passphrase verify invocation
        /// The variable used in this method should have been captured during the ClientUpgrade Event handler
        /// This method should only be called during toggling of checkbox on prefs/account page (logout/login)
        public void ShowClientUpgradeMessageBox()
        {
            if (this.NewClientVersion == null || this.ClientUpgradeStatus == null || this.NewClientDomainID == null)
            {
                return;                 // no handler was generated/caught for ClientUpgradeAvailable
            }

            if (ClientUpgradeDialog != null)
            {
                return;                 // This dialog is already showing
            }
            if (DomainController.upgradeStatus.statusCode == StatusCodes.ServerOld)
            {
                ClientUpgradeDialog = new iFolderMsgDialog(
                    null,
                    iFolderMsgDialog.DialogType.Info,
                    iFolderMsgDialog.ButtonSet.Ok,
                    Util.GS("iFolder Server Older"),
                    Util.GS("The server is running an older version."),
                    string.Format(Util.GS("The server needs to be upgraded to be connected from this client")));
            }
            else if (DomainController.upgradeStatus.statusCode == StatusCodes.UpgradeNeeded)
            {
                ClientUpgradeDialog = new iFolderMsgDialog(
                    null,
                    iFolderMsgDialog.DialogType.Info,
                    iFolderMsgDialog.ButtonSet.AcceptDeny,
                    Util.GS("iFolder Client Upgrade"),
                    Util.GS("Would you like to download new iFolder Client?"),
                    string.Format(Util.GS("The client needs to be upgraded to be connected to the server")));
            }
            else
            {
                ClientUpgradeDialog = new iFolderMsgDialog(
                    null,
                    iFolderMsgDialog.DialogType.Info,
                    iFolderMsgDialog.ButtonSet.AcceptDeny,
                    Util.GS("iFolder Client Upgrade"),
                    Util.GS("Would you like to download new iFolder Client?"),
                    string.Format(Util.GS("A newer version \"{0}\" of the iFolder Client is available."), this.NewClientVersion));
            }

            int rc = ClientUpgradeDialog.Run();

            ClientUpgradeDialog.Hide();
            ClientUpgradeDialog.Destroy();
            ClientUpgradeDialog = null;

            if (rc == -8)
            {
                bool       bUpdateRunning = false;
                Gtk.Window win            = new Gtk.Window("");
                string     initialPath    = (string)System.IO.Path.GetTempPath();

                Debug.PrintLine(String.Format("Initial Path: {0}", initialPath));
                CopyLocation cp             = new CopyLocation(win, (string)System.IO.Path.GetTempPath());
                string       selectedFolder = "";
                int          rc1            = 0;
                do
                {
                    rc1 = cp.Run();
                    cp.Hide();
                    if (rc1 == (int)ResponseType.Ok)
                    {
                        selectedFolder = cp.iFolderPath.Trim();
                        cp.Destroy();
                        cp = null;
                        break;
                    }
                }while(rc1 == (int)ResponseType.Ok);
                if (cp != null)
                {
                    cp.Destroy();
                    cp = null;
                }
                win.Hide();
                win.Destroy();
                win = null;
                if (rc1 != (int)ResponseType.Ok)
                {
                    Debug.PrintLine("OnClientUpgradeAvailableEvent return");
                    ClientUpgradeDialog = null;
                    return;
                }
                try
                {
                    if (ifws != null)
                    {
                        Debug.PrintLine("ifws.RunClientUpdate");
                        bUpdateRunning = ifws.RunClientUpdate(this.NewClientDomainID, selectedFolder);
                    }
                }
                catch (Exception e)
                {
                    Debug.PrintLine(String.Format("ifws.RunClientUpdate exception :{0}", e.Message));
                    ClientUpgradeDialog = null;
                    return;
                }

                if (bUpdateRunning)
                {
                    ClientUpgradeDialog = new iFolderMsgDialog(
                        null,
                        iFolderMsgDialog.DialogType.Info,
                        iFolderMsgDialog.ButtonSet.Ok,
                        Util.GS("Download Complete..."),
                        Util.GS("Download Finished "),
                        string.Format(Util.GS("The new client rpm's have been downloaded.")));
                    ClientUpgradeDialog.Run();
                    ClientUpgradeDialog.Hide();
                    ClientUpgradeDialog.Destroy();
                    //	QuitiFolder();
                }
                else
                {
                    iFolderMsgDialog dialog = new iFolderMsgDialog(
                        null,
                        iFolderMsgDialog.DialogType.Error,
                        iFolderMsgDialog.ButtonSet.None,
                        Util.GS("Upgrade Failure"),
                        Util.GS("The iFolder client upgrade failed."),
                        Util.GS("Please contact your system administrator."));
                    dialog.Run();
                    dialog.Hide();
                    dialog.Destroy();
                    dialog = null;
                }

                if (DomainController.upgradeStatus.statusCode == StatusCodes.UpgradeNeeded)
                {
                    // Deny login
                    if (domainController.GetDomain(this.NewClientDomainID) != null)
                    {
                        domainController.RemoveDomain(this.NewClientDomainID, false);
                    }
                }
            }
            else             //if(rc == -9)
            {
                if (DomainController.upgradeStatus.statusCode == StatusCodes.ServerOld || DomainController.upgradeStatus.statusCode == StatusCodes.UpgradeNeeded)
                {
                    // Deny login
                    if (domainController.GetDomain(this.NewClientDomainID) != null)
                    {
                        domainController.RemoveDomain(this.NewClientDomainID, false);
                    }
                }
            }
            ClientUpgradeDialog      = null;
            this.ClientUpgradeStatus = null;
            this.NewClientVersion    = null;
            this.NewClientDomainID   = null;
        }