Exemplo n.º 1
0
 private bool acceptiFolder(iFolderWeb ifolder, string path, out bool added, bool mergeFolder)
 {
     bool download = false;
     bool result = true;
     bool repeatFlag = false;
     added = true;
     if (GetDriveType(Path.GetPathRoot(path)) == DRIVE_FIXED)
     {
         if (Win32Security.AccessAllowed(path))
         {
             try
             {
                 if (ifolder.encryptionAlgorithm == null || ifolder.encryptionAlgorithm == "")
                 {
                     download = true;
                 }
                 else
                 {
                     string passphrasecheck = null;
                     passphrasecheck = simiasWebService.GetPassPhrase(ifolder.DomainID);
                     if (passphrasecheck == null || passphrasecheck == "")
                     {
                         VerifyPassphraseDialog vpd = new VerifyPassphraseDialog(ifolder.DomainID, simiasWebService);
                         vpd.ShowDialog();
                         download = vpd.PassphraseStatus;
                     }
                     else
                     {
                         download = true;
                     }
                 }
                 if (download)
                 {
                     Cursor = Cursors.WaitCursor;
                     if (mergeFolder == true)
                     {
             string mergediFolder = path;
             if(System.IO.Path.GetFileName(mergediFolder) != ifolder.Name)
             {
              throw new Exception("FolderDoesNotExist");
             }
                         if (Directory.Exists(mergediFolder) == false)
                         {
                             throw new Exception("PathDoesNotExist");
                         }
                         if (ifWebService.IsiFolder(mergediFolder) == true)
                         {
                             throw new Exception("AtOrInsideCollectionPath");
                         }
                         ifWebService.MergeiFolder(ifolder.DomainID, ifolder.ID, mergediFolder);
                         Cursor = Cursors.Default;
                     }
                     else
                     {
                          DirectoryInfo di = new DirectoryInfo(path);
                         if (di.Name == ifolder.Name)
                         {
                             path = Directory.GetParent(path).ToString();
                         }
                         if( System.IO.Directory.Exists( Path.Combine(path,ifolder.Name)) )
                         {
                             MyMessageBox mmb = new MyMessageBox(Resources.OkMergeCancel,Resources.Folderexists, String.Empty, MyMessageBoxButtons.OKCancel, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button1);
                       if (mmb.ShowDialog() == DialogResult.OK)
                 {
                                 ifWebService.MergeiFolder(ifolder.DomainID, ifolder.ID, Path.Combine(path, ifolder.Name));
                             }
                             else
                                 return false;
                }
                   else
                       ifWebService.AcceptiFolderInvitation(ifolder.DomainID, ifolder.ID, path);
                         Cursor = Cursors.Default;
                     }
                 }
                 else
                 {
                     result = true;
                     added = false;
                 }
             }
             catch (Exception ex)
             {
                 Cursor = Cursors.Default;
                 added = false;
                 MyMessageBox mmb;
                 if (ex.Message.IndexOf("260") != -1)
                 {
                     mmb = new MyMessageBox("The iFolder path is too long for the File System. Download failed", "Path Too Long", string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                     mmb.ShowDialog();
                     repeatFlag = true;
                 }
                 else if (ex.Message.IndexOf("PathExists") != -1)
                 {
                     mmb = new MyMessageBox(TrayApp.Properties.Resources.pathExistsError, TrayApp.Properties.Resources.pathInvalidErrorTitle, string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                     mmb.ShowDialog();
                 }
                 else if (ex.Message.IndexOf("AtOrInsideStorePath") != -1)
                 {
                     mmb = new MyMessageBox(TrayApp.Properties.Resources.pathInStoreError, TrayApp.Properties.Resources.pathInvalidErrorTitle, string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                     mmb.ShowDialog();
                 }
                 else if (ex.Message.IndexOf("AtOrInsideCollectionPath") != -1)
                 {
                     mmb = new MyMessageBox(TrayApp.Properties.Resources.pathIniFolderError, TrayApp.Properties.Resources.pathInvalidErrorTitle, string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                     mmb.ShowDialog();
                 }
                 else if (ex.Message.IndexOf("IncludesWinDirPath") != -1)
                 {
                     mmb = new MyMessageBox(TrayApp.Properties.Resources.pathIncludesWinDirError, TrayApp.Properties.Resources.pathInvalidErrorTitle, string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                     mmb.ShowDialog();
                 }
                 else if (ex.Message.IndexOf("IncludesProgFilesPath") != -1)
                 {
                     mmb = new MyMessageBox(TrayApp.Properties.Resources.PathIncludesProgFilesDirError, TrayApp.Properties.Resources.pathInvalidErrorTitle, string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                     mmb.ShowDialog();
                 }
                 else if (ex.Message.IndexOf("PathDoesNotExist") != -1)
                 {
                     mmb = new MyMessageBox(TrayApp.Properties.Resources.PathDoesNotExist, TrayApp.Properties.Resources.pathInvalidErrorTitle, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                     mmb.ShowDialog();
                 }
                 else if (ex.Message.IndexOf("FolderDoesNotExist") != -1)
                 {
                     mmb = new MyMessageBox(TrayApp.Properties.Resources.FolderDoesNotExistError, TrayApp.Properties.Resources.FolderDoesNotExistErrorTitle, TrayApp.Properties.Resources.FolderDoesNotExistErrorDesc, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                     mmb.ShowDialog();
                 }
                 else
                 {
                     mmb = new MyMessageBox(TrayApp.Properties.Resources.acceptError, string.Empty, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                     mmb.ShowDialog();
                 }
                 if (!repeatFlag)
                     result = false;
             }
         }
         else
         {
             result = false;
             MyMessageBox mmb = new MyMessageBox(TrayApp.Properties.Resources.accessDenied, string.Empty, string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
             mmb.ShowDialog();
         }
     }
     else
     {
         MessageBox.Show(TrayApp.Properties.Resources.networkPath, TrayApp.Properties.Resources.pathInvalidErrorTitle);
         result = false;
     }
     return result;
 }
Exemplo n.º 2
0
 private bool DownloadiFolder(iFolderWeb defaultiFolder)
 {
     bool status = false;
     if (defaultiFolder.encryptionAlgorithm == null || defaultiFolder.encryptionAlgorithm == "")
     {
         status = true;
     }
     else
     {
         string passphrasecheck = null;
         passphrasecheck = simws.GetPassPhrase(domainInfo.ID);
         if (passphrasecheck == null || passphrasecheck == "")
         {
             VerifyPassphraseDialog vpd = new VerifyPassphraseDialog(domainInfo.ID, this.simws);
             vpd.ShowDialog();
             status = vpd.PassphraseStatus;
         }
         else
         {
             status = true;
         }
     }
     if (status == true)
     {
         try
         {
             string downloadpath = this.LocationEntry.Text;
             DirectoryInfo di = new DirectoryInfo(downloadpath);
             if (di.Name == defaultiFolder.Name)
             {
                 downloadpath = Directory.GetParent(this.LocationEntry.Text).ToString();
                 di = new DirectoryInfo(downloadpath);
             }
             di.Create();
             iFolderWeb ifolder = null;
             if (System.IO.Directory.Exists(Path.Combine(downloadpath, defaultiFolder.Name)))
             {
                 MyMessageBox mmb = new MyMessageBox(resManager.GetString("selectoption"), resManager.GetString("alreadyexists"), String.Empty, MyMessageBoxButtons.OKCancel, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button1);
                 if (mmb.ShowDialog() == DialogResult.OK)
                 {
                     ifolder = this.ifws.MergeiFolder(defaultiFolder.DomainID, defaultiFolder.ID, Path.Combine(downloadpath, defaultiFolder.Name));
                 }
                 else
                     return false;
             }
             else
                 ifolder = this.ifws.AcceptiFolderInvitation(defaultiFolder.DomainID, defaultiFolder.ID, downloadpath);
             AccountWizard wiz = (AccountWizard)this.Parent;
             if (ifolder != null && wiz != null)
             {
                 wiz.GlobalProps.AddiFolderToAcceptediFolders(ifolder, null, downloadpath);
             }
             wiz.UpdateDisplay(ifolder, Path.Combine(downloadpath, ifolder.Name));
         }
         catch (Exception ex)
         {
             DisplayErrorMesg(ex);
             return false;
         }
         return true;
     }
     else return status;
 }
Exemplo n.º 3
0
 private iFolderWeb CreateDefaultiFolder( bool shared)
 {
     try
        {
     DirectoryInfo di = new DirectoryInfo( this.LocationEntry.Text );
     di.Create();
        }
        catch( Exception ex)
        {
     DisplayErrorMesg(ex);
     return null;
        }
        if( shared)
        {
     iFolderWeb ifolder = null;
     try
     {
             ifolder = this.ifws.CreateiFolderInDomainEncr(this.LocationEntry.Text, domainInfo.ID, this.SecureSync.Checked,null,null);
     }
     catch( Exception ex)
     {
      DisplayErrorMesg(ex);
      return null;
     }
     return ifolder;
        }
        else
        {
     string algorithm = "BlowFish";
     bool passPhraseStatus = false;
     bool passphraseStatus = false;
     try
     {
      passphraseStatus = simws.IsPassPhraseSet(domainInfo.ID);
     }
     catch(Exception ex)
     {
      return null;
     }
     if(passphraseStatus == true)
     {
      string passphrasecheck = null;
      passphrasecheck = simws.GetPassPhrase(domainInfo.ID);
      if( passphrasecheck == null || passphrasecheck =="")
      {
       VerifyPassphraseDialog vpd = new VerifyPassphraseDialog(domainInfo.ID, this.simws);
       vpd.ShowDialog();
       passPhraseStatus = vpd.PassphraseStatus;
      }
      else
      {
       passPhraseStatus = true;
      }
     }
     else
     {
      EnterPassphraseDialog enterPassPhrase= new EnterPassphraseDialog(domainInfo.ID, this.simws,this.ifws);
      enterPassPhrase.ShowDialog();
      passPhraseStatus = enterPassPhrase.PassphraseStatus;
     }
     if( passPhraseStatus == true)
     {
      string Passphrase = simws.GetPassPhrase(domainInfo.ID);
      iFolderWeb ifolder = null;
      try
      {
       ifolder = this.ifws.CreateiFolderInDomainEncr(this.LocationEntry.Text, domainInfo.ID,this.SecureSync.Checked, algorithm, Passphrase);
      }
      catch( Exception ex)
      {
       DisplayErrorMesg(ex);
       return null;
      }
      return ifolder;
     }
        }
        return null;
 }
Exemplo n.º 4
0
 private void connectToServer()
 {
     if ( this.domainInfo != null )
        {
     if ( password == null )
     {
      connectResult = authenticate();
     }
     else
     {
      connectResult = login();
     }
        }
        else
        {
     connectResult = initialConnect();
        }
     if (connectResult)
     {
         try
         {
             bool serverOld = false;
             bool res = FormsTrayApp.ClientUpdates(domainInfo.ID, out serverOld);
             if (res == false)
             {
                 try
                 {
                     simiasWebService.LeaveDomain(domainInfo.ID, false);
                 }
                 catch { }
                 if (serverOld == false)
                 {
                     if (!autoAccountEnabled)
                     {
                         MessageBox.Show(resourceManager.GetString("UpgradeNeededMsg"), resourceManager.GetString("DisableLoginMsg"), MessageBoxButtons.OK);
                     }
                     else
                     {
                         FormsTrayApp.log.Info(resourceManager.GetString("UpgradeNeededMsg"));
                     }
                     connectResult = false;
                 }
             }
         }
         catch (Exception ex)
         {
             FormsTrayApp.log.Info("Error in webservice {0}", ex.ToString());
             if (ex.Message.IndexOf("timed out") != -1)
                 if (FormsTrayApp.UpgradeProgress())
                     FormsTrayApp.ShutdownForms();
         }
     }
        if( connectResult)
        {
     bool passPhraseStatus = false;
     bool passphraseStatus = false;
     int policy =0;
     if( this.ifWebService != null )
     {
             try
             {
                 policy = this.ifWebService.GetSecurityPolicy(this.domainInfo.ID);
             }
             catch (Exception ex)
             {
                 FormsTrayApp.log.Debug(ex.Message, ex.StackTrace);
             }
     }
     if( policy %2==0 || this.ifWebService == null)
     {
      BeginInvoke( this.connectDoneDelegate );
      return;
     }
     try
     {
      passphraseStatus = this.simiasWebService.IsPassPhraseSet(this.domainInfo.ID);
     }
     catch(Exception ex)
     {
      MessageBox.Show( resourceManager.GetString("IsPassphraseSetException") + ex.Message);
      BeginInvoke( this.connectDoneDelegate );
      return;
     }
     if(passphraseStatus == true)
     {
      string passphrasecheck = null;
      if( this.simiasWebService.GetRememberOption(this.domainInfo.ID) == true )
      {
       passphrasecheck = this.simiasWebService.GetPassPhrase(this.domainInfo.ID);
      }
      if( passphrasecheck == null || passphrasecheck =="")
      {
       VerifyPassphraseDialog vpd = new VerifyPassphraseDialog(this.domainInfo.ID, this.simiasWebService);
       vpd.ShowDialog();
       passPhraseStatus = vpd.PassphraseStatus;
      }
      else
      {
       passPhraseStatus = true;
      }
     }
     else
     {
      EnterPassphraseDialog enterPassPhrase= new EnterPassphraseDialog(this.domainInfo.ID, this.simiasWebService, this.ifWebService);
      enterPassPhrase.ShowDialog();
      passPhraseStatus = enterPassPhrase.PassphraseStatus;
     }
     if( passPhraseStatus == false)
     {
     }
        }
        BeginInvoke( this.connectDoneDelegate );
 }
Exemplo n.º 5
0
 /// <summary>
 /// Create Default iFolder
 /// </summary>
 /// <param name="shared">true if shared else encryoted</param>
 private iFolderWeb CreateDefaultiFolder(bool shared)
 {
     try
     {
         DirectoryInfo di = new DirectoryInfo(this.LocationEntry.Text);
         di.Create();
     }
     catch (Exception ex)
     {
         // Unable to create the folder
         DisplayErrorMesg(ex);
         return(null);
     }
     if (shared)
     {
         iFolderWeb ifolder = null;
         try
         {
             //ifolder = this.ifws.CreateiFolderInDomain(this.LocationEntry.Text, this.domainInfo.ID);
             ifolder = this.ifws.CreateiFolderInDomainEncr(this.LocationEntry.Text, domainInfo.ID, this.SecureSync.Checked, null, null);
         }
         catch (Exception ex)
         {
             DisplayErrorMesg(ex);
             return(null);
         }
         return(ifolder);
     }
     else
     {
         string algorithm        = "BlowFish";
         bool   passPhraseStatus = false;
         bool   passphraseStatus = false;
         try
         {
             passphraseStatus = simws.IsPassPhraseSet(domainInfo.ID);
         }
         catch (Exception)
         {
             //	MessageBox.Show("Unable to contact the server.");
             return(null);
         }
         if (passphraseStatus == true)
         {
             // if passphrase not given during login
             string passphrasecheck = null;
             passphrasecheck = simws.GetPassPhrase(domainInfo.ID);
             if (passphrasecheck == null || passphrasecheck == "")
             {
                 VerifyPassphraseDialog vpd = new VerifyPassphraseDialog(domainInfo.ID, this.simws);
                 vpd.ShowDialog();
                 passPhraseStatus = vpd.PassphraseStatus;
             }
             else
             {
                 passPhraseStatus = true;
             }
         }
         else
         {
             // Passphrase not enterd at the time of login...
             EnterPassphraseDialog enterPassPhrase = new EnterPassphraseDialog(domainInfo.ID, this.simws, this.ifws);
             enterPassPhrase.ShowDialog();
             passPhraseStatus = enterPassPhrase.PassphraseStatus;
         }
         if (passPhraseStatus == true)
         {
             // check for passphrase existence and display corresponding dialogs.
             string     Passphrase = simws.GetPassPhrase(domainInfo.ID);
             iFolderWeb ifolder    = null;
             try
             {
                 ifolder = this.ifws.CreateiFolderInDomainEncr(this.LocationEntry.Text, domainInfo.ID, this.SecureSync.Checked, algorithm, Passphrase);
             }
             catch (Exception ex)
             {
                 DisplayErrorMesg(ex);
                 return(null);
             }
             return(ifolder);
         }
     }
     return(null);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Download iFolder
        /// </summary>
        /// <param name="defaultiFolder"></param>
        private bool DownloadiFolder(iFolderWeb defaultiFolder)
        {
            bool status = false;

            if (defaultiFolder.encryptionAlgorithm == null || defaultiFolder.encryptionAlgorithm == "")
            {
                // unencrypted...
                status = true;
            }
            else
            {
                // encrypted.. Check for passphrase
                string passphrasecheck = null;
                passphrasecheck = simws.GetPassPhrase(domainInfo.ID);
                if (passphrasecheck == null || passphrasecheck == "")
                {
                    VerifyPassphraseDialog vpd = new VerifyPassphraseDialog(domainInfo.ID, this.simws);
                    vpd.ShowDialog();
                    status = vpd.PassphraseStatus;
                }
                else
                {
                    status = true;
                }
            }
            if (status == true)
            {
                try
                {
                    string        downloadpath = this.LocationEntry.Text;
                    DirectoryInfo di           = new DirectoryInfo(downloadpath);
                    if (di.Name == defaultiFolder.Name)
                    {
                        downloadpath = Directory.GetParent(this.LocationEntry.Text).ToString();
                        di           = new DirectoryInfo(downloadpath);
                    }

                    di.Create();
                    iFolderWeb ifolder = null;
                    if (System.IO.Directory.Exists(Path.Combine(downloadpath, defaultiFolder.Name)))
                    {
                        MyMessageBox mmb = new MyMessageBox(resManager.GetString("selectoption"), resManager.GetString("alreadyexists"), String.Empty, MyMessageBoxButtons.OKCancel, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button1);
                        if (mmb.ShowDialog() == DialogResult.OK)
                        {
                            ifolder = this.ifws.MergeiFolder(defaultiFolder.DomainID, defaultiFolder.ID, Path.Combine(downloadpath, defaultiFolder.Name));
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        ifolder = this.ifws.AcceptiFolderInvitation(defaultiFolder.DomainID, defaultiFolder.ID, downloadpath);
                    }
                    AccountWizard wiz = (AccountWizard)this.Parent;
                    if (ifolder != null && wiz != null)
                    {
                        wiz.GlobalProps.AddiFolderToAcceptediFolders(ifolder, null, downloadpath);
                    }
                    wiz.UpdateDisplay(ifolder, Path.Combine(downloadpath, ifolder.Name));
                }
                catch (Exception ex)
                {
                    DisplayErrorMesg(ex);
                    return(false);
                }
                return(true);
            }
            else
            {
                return(status);
            }
        }