Ejemplo n.º 1
0
      public bool FindSeekiFolderMembers(
 string domainID,
 ref string searchContext,
 int offset,
 int count,
 out iFolderUser[] memberList )
      {
          Member[] tempList;
             bool moreEntries = DomainProvider.FindSeekDomainMembers(
          domainID,
          ref searchContext,
          offset,
          count,
          out tempList );
             if ( ( tempList != null ) && ( tempList.Length > 0 ) )
             {
          Domain domain = Store.GetStore().GetDomain( domainID );
          memberList = new iFolderUser[ tempList.Length ];
          for ( int i = 0; i < tempList.Length; ++i )
          {
           memberList[ i ] = new iFolderUser( domain, tempList[ i ] );
          }
             }
             else
             {
          memberList = null;
             }
             return moreEntries;
      }
Ejemplo n.º 2
0
 private void createChangeEvent(iFolderWeb ifolder, iFolderUser ifolderUser, string eventData)
 {
     try
        {
     if (ifolder.HasConflicts)
     {
      if (Preferences.NotifyCollisionEnabled)
      {
       ifolderFromNotify = ifolder;
       string message = string.Format(resourceManager.GetString("collisionMessage"), ifolder.Name);
       notifyType = NotifyType.Collision;
       shellNotifyIcon.DisplayBalloonTooltip(resourceManager.GetString("actionRequiredTitle"), message, BalloonType.Info);
      }
     }
     else if (ifolder.State.Equals("Available") && eventData.Equals("NodeCreated"))
     {
      if (Preferences.NotifyShareEnabled)
      {
       ifolderFromNotify = ifolder;
       string title = string.Format(resourceManager.GetString("subscriptionTitle"), ifolder.Name);
       string message = string.Format(resourceManager.GetString("subscriptionMessage"), ifolder.Owner);
       notifyType = NotifyType.Subscription;
       shellNotifyIcon.DisplayBalloonTooltip(title, message, BalloonType.Info);
      }
     }
     else if (ifolderUser != null)
     {
      if (Preferences.NotifyJoinEnabled)
      {
       ifolderFromNotify = ifolder;
       string message = string.Format(resourceManager.GetString("newMemberMessage"),
        (ifolderUser.FN != null) && !ifolderUser.FN.Equals(string.Empty) ? ifolderUser.FN : ifolderUser.Name,
        ifolder.Name);
       notifyType = NotifyType.NewMember;
       shellNotifyIcon.DisplayBalloonTooltip(resourceManager.GetString("newMemberTitle"), message, BalloonType.Info);
      }
     }
        }
        catch {}
 }
Ejemplo n.º 3
0
 public iFolderUser AddAndInviteUser(string iFolderID,
    string MemberName,
    string GivenName,
    string FamilyName,
    string MemberID,
    string PublicKey,
    string Rights)
 {
     Store store = Store.GetStore();
        Collection col = store.GetCollectionByID(iFolderID);
        if(col == null)
     throw new Exception("Invalid iFolderID");
        Domain domain = store.GetDomain(col.Domain);
        if(domain == null)
     throw new Exception("Unable to access domain");
        Simias.Storage.Member member = domain.GetMemberByID(MemberID);
        if(member == null)
        {
     bool given;
     member = new Simias.Storage.Member( MemberName, MemberID, Access.Rights.ReadOnly );
     if ( PublicKey != null )
     {
      member.Properties.AddProperty( "PublicKey", PublicKey );
     }
     if ( GivenName != null && GivenName != "" )
     {
      member.Given = GivenName;
      given = true;
     }
     else
     {
      given = false;
     }
     if ( FamilyName != null && FamilyName != "" )
     {
      member.Family = FamilyName;
      if ( given == true )
      {
       member.FN = GivenName + " " + FamilyName;
      }
     }
     domain.Commit( member );
        }
        Access.Rights newRights;
        if(Rights == "Admin")
     newRights = Access.Rights.Admin;
        else if(Rights == "ReadOnly")
     newRights = Access.Rights.ReadOnly;
        else if(Rights == "ReadWrite")
     newRights = Access.Rights.ReadWrite;
        else
     throw new Exception("Invalid Rights Specified");
        Member membercoll = new Member(MemberName, MemberID, newRights);
        col.Commit(membercoll);
        iFolderUser user = new iFolderUser(domain, membercoll );
        return user;
 }
Ejemplo n.º 4
0
      public bool FindFirstSpecificiFolderMembers(
 string domainID,
 string attributeName,
 string searchString,
 iFolderSearchType operation,
 int count,
 out string searchContext,
 out iFolderUser[] memberList,
 out int totalMembers )
      {
          Member[] tempList;
             bool moreEntries =
          DomainProvider.FindFirstDomainMembers(
           domainID,
           attributeName,
           searchString,
           ( Simias.Storage.SearchOp )Enum.ToObject( typeof( Simias.Storage.SearchOp ), operation ),
           count,
           out searchContext,
           out tempList,
           out totalMembers );
             if ( ( tempList != null ) && ( tempList.Length > 0 ) )
             {
          Domain domain = Store.GetStore().GetDomain( domainID );
          memberList = new iFolderUser[ tempList.Length ];
          for ( int i = 0; i < tempList.Length; ++i )
          {
           memberList[ i ] = new iFolderUser( domain, tempList[ i ] );
          }
             }
             else
             {
          memberList = null;
             }
             return moreEntries;
      }
Ejemplo n.º 5
0
 public iFolderUser GetOwner( string iFolderID )
 {
     Store store = Store.GetStore();
        Collection col = store.GetCollectionByID(iFolderID);
        if(col == null)
     throw new Exception("Invalid iFolderID");
        Domain domain = store.GetDomain( col.Domain);
        iFolderUser user = new iFolderUser( domain, col.Owner );
        return user;
 }
Ejemplo n.º 6
0
 public iFolderUser InviteUser( string iFolderID,
   string UserID,
   string Rights)
 {
     Store store = Store.GetStore();
        Collection col = store.GetCollectionByID(iFolderID);
        if(col == null)
     throw new Exception("Invalid iFolderID");
        Domain domain = store.GetDomain(col.Domain);
        if(domain == null)
     throw new Exception("Unable to access domain");
        Simias.Storage.Member member = domain.GetMemberByID(UserID);
        if(member == null)
     throw new Exception("Invalid UserID");
        Access.Rights newRights;
        if(Rights == "Admin")
     newRights = Access.Rights.Admin;
        else if(Rights == "ReadOnly")
     newRights = Access.Rights.ReadOnly;
        else if(Rights == "ReadWrite")
     newRights = Access.Rights.ReadWrite;
        else
     throw new Exception("Invalid Rights Specified");
        POBox poBox = Simias.POBox.POBox.FindPOBox(store,
       domain.ID,
       store.GetUserIDFromDomainID(domain.ID));
        Subscription sub = poBox.CreateSubscription(col,
       col.GetCurrentMember(),
       "iFolder");
        sub.SubscriptionRights = newRights;
        sub.ToName = member.Name;
        sub.ToIdentity = UserID;
        poBox.AddMessage(sub);
        iFolderUser user = new iFolderUser( sub );
        return user;
 }
Ejemplo n.º 7
0
 public bool FindSeekiFolderMembers(string domainID, ref string searchContext, int offset, int count, out iFolderUser[] memberList)
 {
     object[] results = this.Invoke("FindSeekiFolderMembers", new object[] {
                 domainID,
                 searchContext,
                 offset,
                 count});
     searchContext = ((string)(results[1]));
     memberList = ((iFolderUser[])(results[2]));
     return ((bool)(results[0]));
 }
Ejemplo n.º 8
0
 public iFolderUser GetiFolderUserFromNodeID(string CollectionID,
      string NodeID)
 {
     iFolderUser ifolderUser = null;
        Store store = Store.GetStore();
        Collection col = store.GetCollectionByID(CollectionID);
        if(col != null)
        {
     Node node = col.GetNodeByID(NodeID);
     if(node != null)
     {
      Domain domain = store.GetDomain( col.Domain );
      if (col.IsBaseType(node, NodeTypes.MemberType))
      {
       ifolderUser = new iFolderUser( domain, new Member( node ) );
      }
      else if (col.IsType(node, typeof( Subscription ).Name))
      {
       ifolderUser = new iFolderUser( new Subscription( node ) );
      }
     }
        }
        return ifolderUser;
 }
Ejemplo n.º 9
0
 public bool FindFirstiFolderMembers(string domainID, int count, out string searchContext, out iFolderUser[] memberList, out int totalMembers)
 {
     object[] results = this.Invoke("FindFirstiFolderMembers", new object[] {
                 domainID,
                 count});
     searchContext = ((string)(results[1]));
     memberList = ((iFolderUser[])(results[2]));
     totalMembers = ((int)(results[3]));
     return ((bool)(results[0]));
 }
Ejemplo n.º 10
0
 public bool FindFirstSpecificiFolderMembers(string domainID, string attributeName, string searchString, iFolderSearchType operation, int count, out string searchContext, out iFolderUser[] memberList, out int totalMembers)
 {
     object[] results = this.Invoke("FindFirstSpecificiFolderMembers", new object[] {
                 domainID,
                 attributeName,
                 searchString,
                 operation,
                 count});
     searchContext = ((string)(results[1]));
     memberList = ((iFolderUser[])(results[2]));
     totalMembers = ((int)(results[3]));
     return ((bool)(results[0]));
 }
Ejemplo n.º 11
0
 private ListViewItem addiFolderUserToListView(iFolderUser ifolderUser)
 {
     ListViewItem lvitem;
        lock (subscrHT)
        {
     lvitem = (ListViewItem)subscrHT[ifolderUser.ID];
     if (lvitem == null)
     {
      bool addItem = true;
      ListViewItem lvi;
      lock (userIDHT)
      {
       lvi = (ListViewItem)userIDHT[ifolderUser.UserID];
       if (lvi != null)
       {
        if (!ifolderUser.State.Equals(member))
        {
     addItem = false;
     try
     {
      connectToWebService();
      ifWebService.RemoveiFolderUser(currentiFolder.ID, ifolderUser.UserID);
     }
     catch
     {
     }
        }
        else if (!((ShareListMember)lvi.Tag).iFolderUser.State.Equals(member))
        {
     lvi.Remove();
     subscrHT.Remove(((ShareListMember)lvi.Tag).iFolderUser.ID);
     userIDHT.Remove(ifolderUser.UserID);
        }
       }
      }
      if (addItem)
      {
       ShareListMember slMember = new ShareListMember();
       slMember.iFolderUser = ifolderUser;
       string[] items = new string[3];
       items[0] = (ifolderUser.FN != null) && !ifolderUser.FN.Equals(string.Empty) ? ifolderUser.FN : ifolderUser.Name;
       items[1] = stateToString(ifolderUser.State, ifolderUser.IsOwner);
       int imageIndex = 1;
       items[2] = rightsToString(ifolderUser.Rights);
       if ((currentUser != null) && currentUser.UserID.Equals(ifolderUser.UserID))
       {
        imageIndex = 0;
       }
       else if ((ifolderUser.State != null) && !ifolderUser.State.Equals(member))
       {
        imageIndex = 2;
       }
       lvitem = new ListViewItem(items, imageIndex);
       if (ifolderUser.State.Equals(inviting))
       {
        slMember.Added = true;
       }
       else
       {
        subscrHT.Add(slMember.iFolderUser.ID, lvitem);
       }
       lvitem.Tag = slMember;
       lock (userIDHT)
       {
        bool duplicateName = false;
        foreach (ListViewItem item in userIDHT.Values)
        {
     if (lvitem.SubItems[0].Text.ToLower().Equals(item.SubItems[0].Text.ToLower()))
     {
      duplicateName = true;
      ShareListMember slm = (ShareListMember)item.Tag;
      item.SubItems[0].Text = string.Format("{0} ({1})", slm.iFolderUser.FN, slm.iFolderUser.Name);
     }
        }
        if (duplicateName)
        {
     lvitem.SubItems[0].Text = string.Format("{0} ({1})", ifolderUser.FN, ifolderUser.Name);
        }
        shareWith.Items.Add(lvitem);
        userIDHT[slMember.iFolderUser.UserID] = lvitem;
       }
      }
     }
        }
        return lvitem;
 }
Ejemplo n.º 12
0
 private void updateListViewItem(ListViewItem lvi)
 {
     ShareListMember slMember = (ShareListMember)lvi.Tag;
        lvi.SubItems[0].Text = slMember.Name;
        lvi.SubItems[1].Text = stateToString(slMember.iFolderUser.State, slMember.iFolderUser.IsOwner);
        lvi.SubItems[2].Text = rightsToString(slMember.iFolderUser.Rights);
        if (slMember.iFolderUser.UserID.Equals(currentUser.UserID))
        {
     currentUser = slMember.iFolderUser;
     lvi.ImageIndex = 0;
     add.Enabled = currentUser.Rights.Equals("Admin");
     access.Enabled = access.Enabled ? add.Enabled : false;
     remove.Enabled = remove.Enabled ? add.Enabled : false;
     menuFullControl.Enabled = menuReadWrite.Enabled = menuReadOnly.Enabled =
      menuFullControl.Enabled ? add.Enabled : false;
     if (slMember.iFolderUser.IsOwner && !ownerLvi.Equals(lvi))
     {
      setLimit.Visible = limitEdit.Visible = true;
      limitLabel.Visible = limit.Visible = false;
      ownerLvi.SubItems[1].Text = resourceManager.GetString("user");
      ownerLvi = lvi;
     }
        }
        else
        {
     lvi.ImageIndex = slMember.iFolderUser.State.Equals(member) ? 1 : 2;
        }
 }
Ejemplo n.º 13
0
 private void refreshData()
 {
     newOwnerLvi = null;
     int tmpSyncVal = 0;
        Cursor = Cursors.WaitCursor;
        updateDiskQuotaDisplay();
        lastSync.Text = currentiFolder.LastSyncTime;
        syncInterval.Value = (decimal)currentiFolder.SyncInterval;
        autoSync.Checked = currentiFolder.SyncInterval != Timeout.Infinite;
        switch (currentiFolder.Role)
        {
     case "Master":
      syncUnits.Visible = autoSync.Visible = syncInterval.Visible = true;
      syncNow.Enabled = false;
      syncLabel.Text = resourceManager.GetString("syncLabel.Text");
      break;
     case "Slave":
      syncUnits.Visible = autoSync.Visible = syncInterval.Visible = false;
      syncNow.Enabled = true;
      string units;
             if (currentiFolder.EffectiveSyncInterval <= 0)
             {
                 try
                 {
                     tmpSyncVal = ifWebService.GetDefaultSyncInterval();
                 }
                 catch { }
             }
             else
             {
                 tmpSyncVal = currentiFolder.EffectiveSyncInterval;
             }
             decimal syncValue = ConvertSecondsToTimeUnit(tmpSyncVal, out units);
      syncLabel.Text = string.Format(resourceManager.GetString("slaveSyncInterval"), syncValue, resourceManager.GetString(units));
      break;
        }
        try
        {
     SyncSize syncSize = ifWebService.CalculateSyncSize(currentiFolder.ID);
     objectCount.Text = syncSize.SyncNodeCount.ToString();
        }
        catch
        {
     if (currentiFolder.Role.Equals("Master"))
     {
      objectCount.Text = "0";
     }
     else
     {
      objectCount.Text = resourceManager.GetString("unknown");
     }
        }
        shareWith.Items.Clear();
        shareWith.BeginUpdate();
        try
        {
     lock (subscrHT)
     {
      subscrHT.Clear();
     }
     lock (userIDHT)
     {
      userIDHT.Clear();
     }
     connectToWebService();
     iFolderUser[] ifolderUsers = ifWebService.GetiFolderUsers(currentiFolder.ID);
     foreach (iFolderUser ifolderUser in ifolderUsers)
     {
      if (ifolderUser.UserID.Equals(currentiFolder.CurrentUserID))
      {
       currentUser = ifolderUser;
      }
      ListViewItem lvitem = addiFolderUserToListView(ifolderUser);
      if (ifolderUser.UserID.Equals(currentiFolder.OwnerID))
      {
       ownerLvi = lvitem;
      }
     }
     shareWith.Items[0].Selected = true;
        }
        catch (WebException ex)
        {
     MyMessageBox mmb = new MyMessageBox(resourceManager.GetString("memberReadError"), resourceManager.GetString("errorTitle"), ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
     mmb.ShowDialog();
     if (ex.Status == WebExceptionStatus.ConnectFailure)
     {
      ifWebService = null;
     }
        }
        catch (Exception ex)
        {
     MyMessageBox mmb = new MyMessageBox(resourceManager.GetString("memberReadError"), resourceManager.GetString("errorTitle"), ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
     mmb.ShowDialog();
        }
        shareWith.EndUpdate();
        add.Enabled = currentUser != null ? currentUser.Rights.Equals("Admin") : false;
        if( this.currentiFolder.encryptionAlgorithm != null && this.currentiFolder.encryptionAlgorithm != "")
        {
     this.add.Enabled = false;
        }
        setLimit.Visible = limitEdit.Visible = false;
     limitLabel.Visible = limit.Visible = !setLimit.Visible;
     this.ssl.Enabled = currentUser != null ? currentUser.UserID.Equals(currentiFolder.OwnerID) : false;
     if (this.DomainUrl.StartsWith(Uri.UriSchemeHttps))
     {
         this.ssl.Checked = true;
         this.ssl.Enabled = false;
     }
        Cursor = Cursors.Default;
 }
Ejemplo n.º 14
0
 private void nodeEvent(iFolderWeb ifolder, iFolderUser ifolderUser, string eventData)
 {
     try
        {
     if (ifolder != null)
     {
      currentiFolder = ifolder;
     }
     else if (ifolderUser != null)
     {
      ListViewItem lvi;
      lock (subscrHT)
      {
       lvi = (ListViewItem)subscrHT[ifolderUser.ID];
      }
      if (lvi != null)
      {
       ShareListMember slMember = (ShareListMember)lvi.Tag;
       slMember.iFolderUser = ifolderUser;
       lvi.Tag = slMember;
       updateListViewItem(lvi);
      }
      else if (eventData.Equals("NodeCreated"))
      {
       addiFolderUserToListView(ifolderUser);
      }
     }
     else
     {
      lock (subscrHT)
      {
       ListViewItem lvi = (ListViewItem)subscrHT[eventData];
       if (lvi != null)
       {
        lvi.Remove();
        subscrHT.Remove(eventData);
        lock (userIDHT)
        {
     ListViewItem lvitem = (ListViewItem)userIDHT[((ShareListMember)lvi.Tag).iFolderUser.UserID];
     if ((lvitem != null) && (subscrHT[((ShareListMember)lvitem.Tag).iFolderUser.ID] == null))
     {
      userIDHT.Remove(((ShareListMember)lvi.Tag).iFolderUser.UserID);
     }
        }
       }
      }
     }
        }
        catch
        {
        }
 }
Ejemplo n.º 15
0
 private int removedListContains(iFolderUser ifolderUser)
 {
     int index = -1;
        lock (removedList)
        {
     for (int i=0; i < removedList.Count; i++)
     {
      if (((iFolderUser)removedList[i]).UserID.Equals(ifolderUser.UserID))
      {
       index = i;
       break;
      }
     }
        }
        return index;
 }