private void OnClientUpgradeAvailableEvent(object sender, DomainClientUpgradeAvailableEventArgs args)
 {
     this.ClientUpgradeStatus = DomainController.upgradeStatus;
                 this.NewClientVersion = args.NewClientVersion;
        this.NewClientDomainID = args.DomainID;
 }
 private void CheckForUpdate( string domainID )
 {
     string serverVersion = null;
        UpgradeResult status = UpgradeResult.Unknown;
        try
        {
     status = (UpgradeResult)this.ifws.CheckForUpdate(domainID, out serverVersion);
        }
        catch(Exception ex)
        {
     Debug.PrintLine(String.Format("Exception: {0}", ex.Message));
     status = UpgradeResult.Latest;
        }
        DomainClientUpgradeAvailableEventArgs args;
        switch( status)
        {
     case UpgradeResult.Latest:
       break;
     case UpgradeResult.UpgradeNeeded:
       DomainController.upgradeStatus.statusCode = StatusCodes.UpgradeNeeded;
       args =
     new DomainClientUpgradeAvailableEventArgs(
      domainID, serverVersion);
      DomainClientUpgradeAvailable(this, args);
       break;
     case UpgradeResult.ServerOld:
       DomainController.upgradeStatus.statusCode = StatusCodes.ServerOld;
       args =
     new DomainClientUpgradeAvailableEventArgs(
      domainID, serverVersion);
      DomainClientUpgradeAvailable(this, args);
       break;
     case UpgradeResult.UpgradeAvailable:
       args =
     new DomainClientUpgradeAvailableEventArgs(
      domainID, serverVersion);
      DomainClientUpgradeAvailable(this, args);
       break;
     case UpgradeResult.Unknown:
       DomainController.upgradeStatus.statusCode = StatusCodes.Unknown;
       break;
     default:
       break;
        }
 }
 private void OnClientUpgradeAvailableEvent(object sender, DomainClientUpgradeAvailableEventArgs args)
 {
     if (ClientUpgradeDialog != null)
     return;
        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."), args.NewClientVersion));
        }
        int rc = ClientUpgradeDialog.Run();
        ClientUpgradeDialog.Hide();
        ClientUpgradeDialog.Destroy();
        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();
     win.Hide();
     win.Destroy();
     if( rc1 != (int) ResponseType.Ok)
     {
      Debug.PrintLine("OnClientUpgradeAvailableEvent return");
      ClientUpgradeDialog = null;
      return;
     }
     try
     {
      if(ifws !=null)
      {
       Debug.PrintLine("ifws.RunClientUpdate");
       bUpdateRunning = ifws.RunClientUpdate(args.DomainID, 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();
     }
     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 )
     {
      if( domainController.GetDomain(args.DomainID) != null)
       domainController.RemoveDomain(args.DomainID, false);
     }
        }
        else
        {
     if(DomainController.upgradeStatus.statusCode == StatusCodes.ServerOld || DomainController.upgradeStatus.statusCode == StatusCodes.UpgradeNeeded )
     {
      if( domainController.GetDomain(args.DomainID) != null)
       domainController.RemoveDomain(args.DomainID, false);
     }
        }
        ClientUpgradeDialog = null;
 }
 public void CheckForUpdate( string domainID )
 {
     string serverVersion = null;
        UpgradeResult status = UpgradeResult.Unknown;
        try
        {
     status = (UpgradeResult)this.ifws.CheckForUpdate(domainID, out serverVersion);
     string clientVersion = Util.Version();
     Version versionClient = new Version(clientVersion);
     Version versionServer = new Version(serverVersion);
     if(status == UpgradeResult.UpgradeAvailable)
     {
      if (((versionClient.Major == versionServer.Major) && (versionClient.Minor < versionServer.Minor)) || (versionClient.Major < versionServer.Major))
      {
       status = UpgradeResult.UpgradeAvailable;
      }
      else
      {
       status = UpgradeResult.Latest;
      }
      if((versionClient.Major == versionServer.Major ) && (versionClient.Minor == versionServer.Minor))
      {
       if (((versionClient.Build == versionServer.Build) && (versionClient.Revision < versionServer.Revision)) || (versionClient.Build < versionServer.Build))
       {
        status = UpgradeResult.UpgradeAvailable;
       }
       else
       {
        status = UpgradeResult.Latest;
       }
      }
     }
        }
        catch(Exception ex)
        {
     Debug.PrintLine(String.Format("Exception: {0}", ex.Message));
     status = UpgradeResult.Latest;
        }
        DomainClientUpgradeAvailableEventArgs args;
        switch( status)
        {
     case UpgradeResult.Latest:
       break;
     case UpgradeResult.UpgradeNeeded:
       DomainController.upgradeStatus.statusCode = StatusCodes.UpgradeNeeded;
       args =
     new DomainClientUpgradeAvailableEventArgs(
      domainID, serverVersion);
      DomainClientUpgradeAvailable(this, args);
       break;
     case UpgradeResult.ServerOld:
       DomainController.upgradeStatus.statusCode = StatusCodes.ServerOld;
       args =
     new DomainClientUpgradeAvailableEventArgs(
      domainID, serverVersion);
      DomainClientUpgradeAvailable(this, args);
       break;
     case UpgradeResult.UpgradeAvailable:
       args =
     new DomainClientUpgradeAvailableEventArgs(
      domainID, serverVersion);
      DomainClientUpgradeAvailable(this, args);
       break;
     case UpgradeResult.Unknown:
       DomainController.upgradeStatus.statusCode = StatusCodes.Unknown;
       break;
     default:
       break;
        }
 }