private void menuRevert_Click(object sender, System.EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
        try
        {
     iFolderWeb ifolder = ((iFolderObject)selectedItem.Tag).iFolderWeb;
     bool IsMaster = (ifolder.CurrentUserID == ifolder.OwnerID);
     RevertiFolder revertiFolder = new RevertiFolder();
     if( !IsMaster )
      revertiFolder.removeFromServer.Text = TrayApp.Properties.Resources.AlsoRemoveMembership;
     if ( revertiFolder.ShowDialog() == DialogResult.Yes )
     {
      Invalidate();
      Update();
      Cursor.Current = Cursors.WaitCursor;
      iFolderWeb newiFolder = ifWebService.RevertiFolder(ifolder.ID);
      Win32Window.ShChangeNotify(Win32Window.SHCNE_UPDATEITEM, Win32Window.SHCNF_PATHW, ifolder.UnManagedPath, IntPtr.Zero);
      if (newiFolder != null)
      {
       acceptedFolders.Remove(newiFolder.ID);
       if ( revertiFolder.RemoveFromServer )
       {
        if( IsMaster )
        {
     string defaultiFolderID = this.simiasWebService.GetDefaultiFolder( newiFolder.DomainID );
     if( defaultiFolderID == newiFolder.ID)
     {
      this.simiasWebService.DefaultAccount( newiFolder.DomainID, null );
     }
     ifWebService.DeleteiFolder(newiFolder.DomainID, newiFolder.ID);
        }
        ifWebService.DeclineiFolderInvitation( newiFolder.DomainID, newiFolder.ID );
       }
       else
       {
        {
                         this.removeTileListViewItem((TileListViewItem)ht[newiFolder.ID]);
                         iFolderObject ifolderobj = new iFolderObject(newiFolder, iFolderState.Normal);
                         addiFolderToListView(ifolderobj);
        }
       }
      }
      lock (ht)
      {
       removeTileListViewItem( selectedItem );
      }
     }
         refreshAll();
     updateView();
     revertiFolder.Dispose();
        }
        catch (Exception ex)
        {
     Cursor.Current = Cursors.Default;
     Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(TrayApp.Properties.Resources.iFolderRevertError, TrayApp.Properties.Resources.revertErrorTitle, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
     mmb.ShowDialog();
     mmb.Dispose();
        }
        Cursor.Current = Cursors.Default;
 }
 private void menuRevert_Click(object sender, System.EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
        try
        {
     iFolderWeb ifolder = ((iFolderObject)selectedItem.Tag).iFolderWeb;
     bool IsMaster = (ifolder.CurrentUserID == ifolder.OwnerID);
         IsDomainMaster = IsMaster;
     RevertiFolder revertiFolder = new RevertiFolder();
     if( !IsMaster )
      revertiFolder.removeFromServer.Text = TrayApp.Properties.Resources.AlsoRemoveMembership;
         revertiFolder.removeFromServer.Enabled = simiasWebService.GetDomainInformation(ifolder.DomainID).Authenticated;
         if ( revertiFolder.ShowDialog() == DialogResult.Yes )
     {
      Invalidate();
      Update();
      Cursor.Current = Cursors.WaitCursor;
             if (revertiFolder.RemoveFromServer)
                  ((iFolderObject)selectedItem.Tag).iFolderState = iFolderState.RevertAndDelete;
      iFolderWeb newiFolder = ifWebService.RevertiFolder(ifolder.ID);
      Win32Window.ShChangeNotify(Win32Window.SHCNE_UPDATEITEM, Win32Window.SHCNF_PATHW, ifolder.UnManagedPath, IntPtr.Zero);
      if (newiFolder != null)
      {
       acceptedFolders.Remove(newiFolder.ID);
       if ( revertiFolder.RemoveFromServer )
       {
                     selectediFolderID = newiFolder.ID;
                     selectedDomainID = newiFolder.DomainID;
            Thread revertiFolderThread;
            revertiFolderThread = new Thread(new ThreadStart(RemoveiFolderFromServer));
            revertiFolderThread.Name = "RevertAndDeleteiFolder";
            revertiFolderThread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
            revertiFolderThread.IsBackground = true;
            revertiFolderThread.Priority = ThreadPriority.BelowNormal;
                     revertiFolderThread.Start();
       }
       else
       {
        {
                         this.removeTileListViewItem((TileListViewItem)ht[newiFolder.ID]);
                         iFolderObject ifolderobj = new iFolderObject(newiFolder, iFolderState.Normal);
                         addiFolderToListView(ifolderobj);
                         updateView();
        }
       }
      }
     }
     revertiFolder.Dispose();
        }
        catch (Exception ex)
        {
     Cursor.Current = Cursors.Default;
     Novell.iFolderCom.MyMessageBox mmb =
             new MyMessageBox(TrayApp.Properties.Resources.iFolderRevertError,
                 TrayApp.Properties.Resources.revertErrorTitle,
                 ex.Message,
                 MyMessageBoxButtons.OK,
                 MyMessageBoxIcon.Error);
     mmb.ShowDialog();
     mmb.Dispose();
        }
        Cursor.Current = Cursors.Default;
 }
 public void RevertToNormal([MarshalAs(UnmanagedType.LPWStr)] string path)
 {
     Cursor.Current = Cursors.WaitCursor;
     try
     {
         connectToWebService();
         RevertiFolder revertiFolder = new RevertiFolder();
         iFolderWeb ifolder = ifWebService.GetiFolderByLocalPath(path);
         bool IsMaster = (ifolder.CurrentUserID == ifolder.OwnerID);
         if (!IsMaster)
             revertiFolder.removeFromServer.Text = resourceManager.GetString("AlsoRemoveMembership");
         revertiFolder.removeFromServer.Enabled = simws.GetDomainInformation(ifolder.DomainID).Authenticated;
         if (revertiFolder.ShowDialog() == DialogResult.Yes)
         {
             Cursor.Current = Cursors.WaitCursor;
             if (ifWebService != null && ifolder != null)
             {
                 ifWebService.RevertiFolder(ifolder.ID);
                 if(revertiFolder.RemoveFromServer)
                 {
                     if (IsMaster)
                     {
                         ifWebService.DeleteiFolder(ifolder.DomainID, ifolder.ID);
                     }
                     else
                     {
                         ifWebService.DeclineiFolderInvitation(ifolder.DomainID, ifolder.ID);
                     }
                 }
             }
         }
         revertiFolder.Dispose();
     }
     catch (WebException e)
     {
         ifWebService = null;
         if (e.Status == WebExceptionStatus.ProtocolError)
         {
             LocalService.ClearCredentials();
         }
     }
     catch (Exception e)
     {
         Cursor.Current = Cursors.Default;
         Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(resourceManager.GetString("iFolderRevertError"),
             resourceManager.GetString("revertErrorTitle"), e.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
         mmb.ShowDialog();
         mmb.Dispose();
     }
     Cursor.Current = Cursors.Default;
 }