Пример #1
0
/*
 *              public iFolderUser(Simias.Storage.Member member)
 *              {
 *                      this.Name = member.Name;
 *                      this.UserID = member.UserID;
 *                      this.Rights = member.Rights.ToString();
 *                      this.ID = member.ID;
 *                      this.State = "Member";
 *                      this.IsOwner = member.IsOwner;
 *              }
 */

        /// <summary>
        /// </summary>
        /// <param name="domain"></param>
        /// <param name="member"></param>
        public iFolderUser(Simias.Storage.Domain domain, Simias.Storage.Member member)
        {
            this.Name    = member.Name;
            this.UserID  = member.UserID;
            this.ID      = member.ID;
            this.State   = "Member";
            this.IsOwner = member.IsOwner;
            this.Rights  = member.Rights.ToString();

            if (member.Given != null)
            {
                this.Surname   = member.Family;
                this.FirstName = member.Given;
                this.FN        = member.FN;
            }
            else
            {
                if (domain != null)
                {
                    Simias.Storage.Member dMember = domain.GetMemberByID(member.UserID);
                    if (dMember != null)
                    {
                        this.Surname   = dMember.Family;
                        this.FirstName = dMember.Given;
                        this.FN        = dMember.FN;
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public iFolderWeb(Subscription subscription)
        {
            this.DomainID        = subscription.DomainID;
            this.Name            = subscription.SubscriptionCollectionName;
            this.ID              = subscription.ID;
            this.CollectionID    = subscription.SubscriptionCollectionID;
            this.Description     = subscription.CollectionDescription;
            this.IsSubscription  = true;
            this.EnumeratedState = (int)subscription.SubscriptionState;
            this.Owner           = subscription.FromName;
            Domain domain = Store.GetStore().GetDomain(subscription.DomainID);

            if (domain != null)
            {
                Simias.Storage.Member member = domain.GetMemberByID(subscription.FromIdentity);
                if (member != null)
                {
                    this.Owner = member.FN;
                }
            }

            this.OwnerID           = subscription.FromIdentity;
            this.CurrentUserRights = subscription.SubscriptionRights.ToString();

            if ((subscription.SubscriptionState ==
                 SubscriptionStates.Ready) ||
                (subscription.SubscriptionState ==
                 SubscriptionStates.Received))
            {
                this.State = "Available";
            }
            else if (subscription.SubscriptionState ==
                     SubscriptionStates.Replied)
            {
                this.State = "WaitConnect";
            }
            else if (subscription.SubscriptionState ==
                     SubscriptionStates.Delivered)
            {
                this.State = "WaitSync";
            }

/*			else if(	(subscription.SubscriptionState ==
 *                                                              SubscriptionStates.Replied) ||
 *                                              (subscription.SubscriptionState ==
 *                                                              SubscriptionStates.Delivered) ||
 *                                              (subscription.SubscriptionState ==
 *                                                              SubscriptionStates.Pending) ||
 *                                              (subscription.SubscriptionState ==
 *                                                              SubscriptionStates.Responded) ||
 *                                              (subscription.SubscriptionState ==
 *                                                              SubscriptionStates.Acknowledged) )
 */
            else
            {
                this.State = "Unknown";
            }
        }
Пример #3
0
/*
 *              public iFolderUser(Simias.Storage.Member member,
 *                                                      Novell.AddressBook.Contact contact)
 *              {
 *                      if(contact != null)
 *                      {
 *                              Novell.AddressBook.Name name;
 *
 *                              name = contact.GetPreferredName();
 *                              if(name != null)
 *                              {
 *                                      this.Surname = name.Family;
 *                                      this.FirstName = name.Given;
 *                              }
 *                              this.FN = contact.FN;
 *                      }
 *
 *                      this.Name = member.Name;
 *                      this.UserID = member.UserID;
 *                      this.ID = member.ID;
 *                      this.State = "Member";
 *                      this.IsOwner = member.IsOwner;
 *                      this.Rights = member.Rights.ToString();
 *              }
 */
        /// <summary>
        /// </summary>
        /// <param name="sub"></param>
        public iFolderUser(Simias.POBox.Subscription sub)
        {
            this.Name   = sub.ToName;
            this.UserID = sub.ToIdentity;

            // Need to get the member for first and last name
            Simias.Storage.Domain domain = Store.GetStore().GetDomain(sub.DomainID);
            if (domain != null)
            {
                Simias.Storage.Member simMem = domain.GetMemberByID(sub.ToIdentity);
                if (simMem != null)
                {
                    this.Surname   = simMem.Family;
                    this.FirstName = simMem.Given;
                    this.FN        = simMem.FN;
                }
            }

            this.Rights    = sub.SubscriptionRights.ToString();
            this.ID        = sub.ID;
            this.iFolderID = sub.SubscriptionCollectionID;
            this.State     = "Invited";
            this.IsOwner   = false;

            if (sub.SubscriptionState ==
                Simias.POBox.SubscriptionStates.Invited)
            {
                this.State = "WaitSync";
            }
            else if (sub.SubscriptionState ==
                     Simias.POBox.SubscriptionStates.Posted)
            {
                this.State = "Invited";
            }
            else if (sub.SubscriptionState ==
                     Simias.POBox.SubscriptionStates.Pending)
            {
                this.State = "AccessRequest";
            }
            else if (sub.SubscriptionState ==
                     Simias.POBox.SubscriptionStates.Responded)
            {
                if (sub.SubscriptionDisposition ==
                    Simias.POBox.SubscriptionDispositions.Declined)
                {
                    this.State = "Declined";
                }
                else
                {
                    this.State = "Unknown";
                }
            }
            else
            {
                this.State = "Unknown";
            }
        }
Пример #4
0
        /// <summary>
        /// WebMethod that gets the DiskSpaceQuota for a given member
        /// </summary>
        /// <param name = "UserID">
        /// The ID of the member to get the DiskSpaceQuota
        /// </param>
        /// <returns>
        /// DiskSpaceQuota for the specified member
        /// </returns>
        public static DiskSpace GetMemberDiskSpace(string UserID)
        {
            long   limit             = 0;
            long   UsedSpaceOnServer = 0;
            Store  store             = Store.GetStore();
            Domain domain            = store.GetDomainForUser(UserID);

            Simias.Policy.Rule rule = null;
            if (domain == null)
            {
                throw new Exception("Unable to access domain");
            }

            Simias.Storage.Member simMem = domain.GetMemberByID(UserID);
            if (simMem == null)
            {
                throw new Exception("Invalid UserID");
            }
            Property DiskLimitProp     = simMem.Properties.GetSingleProperty(Simias.Policy.DiskSpaceQuota.DiskSpaceQuotaPolicyID);
            Property DiskSpaceUsedProp = simMem.Properties.GetSingleProperty(Simias.Policy.DiskSpaceQuota.UsedDiskSpaceOnServer);

            if (DiskLimitProp != null)
            {
                if (DiskLimitProp.Type == Syntax.String)
                {
                    rule = new Simias.Policy.Rule(DiskLimitProp.Value as string);
                }
                else
                {
                    rule = new Simias.Policy.Rule(DiskLimitProp.Value);
                }
                limit = (long)rule.Operand;
            }

            if (DiskSpaceUsedProp != null)
            {
                UsedSpaceOnServer = (long)DiskSpaceUsedProp.Value;
            }
            return(new DiskSpace(UsedSpaceOnServer, limit));

            /*Simias.DomainServices.DomainAgent da = new Simias.DomainServices.DomainAgent();
             * long spaceUsed = da.GetDomainDiskSpaceForMember( UserID, out limit );
             * return new DiskSpace( spaceUsed, limit );*/
        }
Пример #5
0
        /// <summary>
        /// WebMethod that sets the disk space limit for a member
        /// </summary>
        /// <param name = "UserID">
        /// The ID of the member to set the disk space limit
        /// </param>
        /// <param name = "limit"></param>
        public static void SetUserDiskSpaceLimit(string UserID, long limit)
        {
            Store store = Store.GetStore();

            Domain domain = store.GetDomainForUser(UserID);

            if (domain == null)
            {
                throw new Exception("Unable to access domain");
            }

            Simias.Storage.Member simMem = domain.GetMemberByID(UserID);
            if (simMem == null)
            {
                throw new Exception("Invalid UserID");
            }

            Simias.Policy.DiskSpaceQuota.Set(simMem, limit);
        }
Пример #6
0
        /// <summary>
        /// CollectionInfo from DiscoveryFrameWork
        /// </summary>
        public iFolderWeb(CollectionInfo c)
        {
            this.DomainID     = c.DomainID;
            this.Name         = c.Name;
            this.ID           = c.ID;
            this.CollectionID = c.CollectionID;
            this.Description  = c.Description;

            // TODO : Remove the following  line when cleaning up POBox.
            this.IsSubscription  = true;
            this.EnumeratedState = (int)SubscriptionStates.Ready;
            this.Owner           = c.OwnerFullName;
            this.CurrentUserID   = c.MemberUserID;

            Domain domain = Store.GetStore().GetDomain(c.DomainID);

            if (domain != null)
            {
                Simias.Storage.Member member = domain.GetMemberByID(c.OwnerID);
                if (member != null)
                {
                    this.Owner = member.FN;
                }
            }

            this.OwnerID = c.OwnerID;
//			this.CurrentUserRights = "Admin";
            this.CurrentUserRights = c.UserRights;

            this.State = "WaitSync";
            if (c.encryptionAlgorithm != null)
            {
                this.encryptionAlgorithm = c.encryptionAlgorithm;
            }
            else
            {
                this.encryptionAlgorithm = "";
            }
            this.MigratediFolder = c.MigratediFolder;
            this.iFolderSize     = c.Size;
        }
Пример #7
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;
 }
Пример #8
0
        /// <summary>
        /// Invite the subscription to POBox
        /// </summary>
        /// <param name="poBox">POBox to which subscription to be added</param>
        /// <param name="subscription">Subscription to be invited to POBox</param>
        /// <returns>True if successfull else false</returns>
        private bool DoInvited(POBox poBox, Subscription subscription)
        {
            bool  result = false;
            Store store  = Store.GetStore();

            log.Debug("SubscriptionThread::DoInvited called");
            POBoxService poService = new POBoxService();

            // Resolve the PO Box location for the invitee
            Uri poUri = DomainProvider.ResolvePOBoxLocation(subscription.DomainID, subscription.ToIdentity);

            if (poUri != null)
            {
                poService.Url = poUri.ToString() + poServiceLabel;
                log.Debug("Calling POService::Invite at: " + poService.Url);
            }
            else
            {
                log.Error("  Could not resolve the PO Box location for: " + subscription.FromIdentity);
                return(result);
            }

            //
            // If the Domain Type is "ClientServer" credentials are needed for
            // posting an invitation.  In workgroup, credentials aren't needed.
            //

            Domain domain = store.GetDomain(subscription.DomainID);

            if (domain.ConfigType == Simias.Storage.Domain.ConfigurationType.ClientServer)
            {
                try
                {
                    WebState webState = new WebState(subscription.DomainID, subscription.FromIdentity);
                    webState.InitializeWebClient(poService, domain.ID);
                }
                catch (NeedCredentialsException)
                {
                    log.Debug("  no credentials - back to sleep");
                    return(result);
                }
            }

            //
            // Make sure the shared collection has sync'd to the server before inviting
            //

            Collection cSharedCollection = store.GetCollectionByID(subscription.SubscriptionCollectionID);

            if (cSharedCollection == null)
            {
                return(result);
            }

            if (cSharedCollection.Role == SyncRoles.Slave && cSharedCollection.MasterIncarnation == 0)
            {
                log.Debug(
                    "Failed POBoxService::Invite - collection: {0} hasn't sync'd to the server yet",
                    subscription.SubscriptionCollectionID);

                return(result);
            }

            //
            // Make sure the subscription node has sync'd up to the server as well
            //

            if (poBox.Role == SyncRoles.Slave)
            {
                Node cNode = poBox.Refresh(subscription);
                if (cNode.MasterIncarnation == 0)
                {
                    log.Debug(
                        "Failed POBoxService::Invite - inviter's subscription {0} hasn't sync'd to the server yet",
                        subscription.MessageID);

                    return(result);
                }
            }

            // Remove location of the POBox service
            log.Debug("Connecting to the Post Office Service : " + poService.Url);

            try
            {
                // Set the remote state to received.
                // And post the subscription to the server.
                Simias.Storage.Member me = poBox.GetCurrentMember();
                subscription.FromIdentity = me.UserID;
                subscription.FromName     = me.Name;

                // Make sure that this user has sufficient rights to send this invitation.
                Simias.Storage.Member me2 = cSharedCollection.GetMemberByID(me.UserID);
                if ((me2 == null) || (me2.Rights != Access.Rights.Admin))
                {
                    // The user did not have sufficient rights to send this invitation.
                    // Delete the subscription and don't try to send it anymore.
                    log.Info("User {0} did not have sufficient rights to share collection {1}", me.Name, cSharedCollection.Name);
                    poBox.Commit(poBox.Delete(subscription));
                    return(true);
                }

                POBoxStatus status = poService.Invite(subscription.GenerateSubscriptionMessage());
                if (status == POBoxStatus.Success)
                {
                    log.Debug("Successfully invited {0} to collection {1}.", subscription.FromName, subscription.SubscriptionCollectionName);
                    subscription.SubscriptionState = SubscriptionStates.Posted;
                    poBox.Commit(subscription);
                    result = true;
                }
                else if (status == POBoxStatus.InvalidAccessRights)
                {
                    // The user did not have sufficient rights to send this invitation.
                    // Delete the subscription and don't try to send it anymore.
                    log.Info("User {0} did not have sufficient rights to share collection {1}", me.Name, cSharedCollection.Name);
                    poBox.Commit(poBox.Delete(subscription));
                    result = true;
                }
                else if (status == POBoxStatus.UnknownIdentity)
                {
                    // The invited user no longer exists on the server roster
                    // possibly due to scoping changes by the administrator
                    log.Info("User {0} does not exist in the server domain", me.Name);
                    poBox.Commit(poBox.Delete(subscription));
                    result = true;
                }
                else
                {
                    log.Debug("Failed the remote invite call -  Status: " + status.ToString());
                }
            }
            catch
            {
                log.Debug("Failed POBoxService::Invite - target: " + poService.Url);
            }

            return(result);
        }
Пример #9
0
        /// <summary>
        /// Used by server to validate the signature using PPK.
        /// </summary>
        /// <param name="domainId"></param>
        /// <param name="memberId"></param>
        /// <param name="signed"></param>
        /// <param name="ctx"></param>
        static public void VerifyWithPPK(string domainId, string memberId, byte[] signed, HttpContext ctx)
        {
            Simias.Authentication.Session simiasSession;
            Simias.Storage.Domain         domain = null;
            Simias.Storage.Member         member = null;
            Store store = Store.GetStore();

            ctx.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            domain = store.GetDomain(domainId);
            if (domain == null)
            {
                ctx.Response.StatusCode        = 500;
                ctx.Response.StatusDescription = "Invalid Domain";
                ctx.ApplicationInstance.CompleteRequest();
                return;
            }

            member = domain.GetMemberByID(memberId);
            if (member == null)
            {
                ctx.Response.StatusCode        = 500;
                ctx.Response.StatusDescription = "Invalid Member";
                ctx.ApplicationInstance.CompleteRequest();
                return;
            }

            if (ctx.Session == null)
            {
                // Must have a session.
                ctx.Response.StatusCode = 401;
                ctx.Response.AddHeader(
                    "WWW-Authenticate",
                    String.Concat("Basic realm=\"", domain.Name, "\""));

                ctx.ApplicationInstance.CompleteRequest();
                return;
            }

            simiasSession = ctx.Session[sessionTag] as Simias.Authentication.Session;
            if (simiasSession != null)
            {
                ctx.User = simiasSession.User;
            }

            if (ctx.User.Identity.IsAuthenticated == false)
            {
                // Validate signature.
                string nonce      = (string)ctx.Session[NonceKey];
                byte[] nonceBytes = Nonce.GetBytes(nonce);
                if (member.PublicKey.VerifyData(nonceBytes, new SHA1CryptoServiceProvider(), signed))
                {
                    simiasSession          = new Simias.Authentication.Session();
                    simiasSession.MemberID = member.UserID;
                    simiasSession.Requests++;
                    ctx.Session[sessionTag] = simiasSession;

                    // Setup a principal
                    simiasSession.User =
                        new GenericPrincipal(
                            new GenericIdentity(
                                member.UserID,
                                PpkType),
                            hostRoles);

                    ctx.User = simiasSession.User;
                    Thread.CurrentPrincipal = ctx.User;

                    // Set the last login time for the user.
                    SetLastLoginTime(domain, member);
                }
                else
                {
                    // Failed
                    ctx.Response.StatusCode = 401;
                    ctx.Response.AddHeader(
                        "WWW-Authenticate",
                        String.Concat("Basic realm=\"", domain.Name, "\""));
                    ctx.ApplicationInstance.CompleteRequest();
                    return;
                }
            }
            else
            {
                simiasSession.Requests++;
                Thread.CurrentPrincipal = ctx.User;
                member = domain.GetMemberByID(simiasSession.MemberID);
            }
        }
Пример #10
0
        /// <summary>
        /// Summary description for Http
        /// </summary>
        /// <param name="domainID"></param>
        /// <param name="ctx"></param>
        static public Simias.Storage.Member GetMember(string domainID, HttpContext ctx)
        {
            Simias.Authentication.Session simiasSession;
            Simias.Authentication.Status  status;
            Simias.Storage.Domain         domain = null;
            Simias.Storage.Member         member = null;
            Store store = Store.GetStore();

            ctx.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            //
            // Look for the special domain ID header in the request.  If the
            // header doesn't exist use the default domain
            //

            if ((domainID != null) && (domainID != String.Empty))
            {
                domain = store.GetDomain(domainID);
            }

            if (domain == null)
            {
                ctx.Response.StatusCode        = 500;
                ctx.Response.StatusDescription = "Invalid Domain";
                ctx.ApplicationInstance.CompleteRequest();
                return(null);
            }

            if (ctx.Session != null)
            {
                simiasSession = ctx.Session[sessionTag] as Simias.Authentication.Session;
                if (simiasSession != null)
                {
                    ctx.User = simiasSession.User;
                }

                if (ctx.User.Identity.IsAuthenticated == false)
                {
                    status = DomainProvider.Authenticate(domain, ctx);
                    if (status.statusCode != StatusCodes.Success &&
                        status.statusCode != StatusCodes.SuccessInGrace)
                    {
                        Simias.Authentication.Http.SetResponseHeaders(ctx, status);
                        if (ctx.Response.StatusCode == 401)
                        {
                            ctx.Response.AddHeader(
                                "WWW-Authenticate",
                                String.Concat("Basic realm=\"", domain.Name, "\""));
                        }

                        ctx.ApplicationInstance.CompleteRequest();
                        return(null);
                    }

                    // Authentication modules are required to set the member's
                    // userID on successful authentication - let's make sure
                    if (status.UserID == null || status.UserID == "")
                    {
                        ctx.Response.StatusCode        = 500;
                        ctx.Response.StatusDescription = "Unknown UserID";
                        ctx.ApplicationInstance.CompleteRequest();
                        return(null);
                    }

                    member = domain.GetMemberByID(status.UserID);
                    if (member == null)
                    {
                        ctx.Response.StatusCode        = 500;
                        ctx.Response.StatusDescription = "Unknown Member in Domain";
                        ctx.ApplicationInstance.CompleteRequest();
                        return(null);
                    }

                    if (status.statusCode == StatusCodes.SuccessInGrace ||
                        status.statusCode == StatusCodes.Success)
                    {
                        Simias.Authentication.Http.SetResponseHeaders(ctx, status);
                    }

                    simiasSession          = new Simias.Authentication.Session();
                    simiasSession.MemberID = member.UserID;
                    simiasSession.Requests++;
                    ctx.Session[sessionTag] = simiasSession;

                    // Setup a principal
                    simiasSession.User =
                        new GenericPrincipal(
                            new GenericIdentity(
                                member.UserID,
                                "Basic authentication"),
                            rolesArray);

                    ctx.User = simiasSession.User;
                    Thread.CurrentPrincipal = ctx.User;

                    // Set the last login time for the user.
                    SetLastLoginTime(domain, member);
                }
                else
                {
                    simiasSession.Requests++;
                    Thread.CurrentPrincipal = ctx.User;
                    member = domain.GetMemberByID(simiasSession.MemberID);
                }
            }
            else
            {
                // No session exists so "authenticate" every request
                status = DomainProvider.Authenticate(domain, ctx);
                if (status.statusCode != StatusCodes.Success &&
                    status.statusCode != StatusCodes.SuccessInGrace)
                {
                    Simias.Authentication.Http.SetResponseHeaders(ctx, status);
                    if (ctx.Response.StatusCode == 401)
                    {
                        ctx.Response.AddHeader(
                            "WWW-Authenticate",
                            String.Concat("Basic realm=\"", domain.Name, "\""));
                    }

                    ctx.ApplicationInstance.CompleteRequest();
                    return(null);
                }

                // Authentication modules are required to set the member's
                // userID on successful authentication - let's make sure
                if (status.UserID == null || status.UserID == "")
                {
                    ctx.Response.StatusCode        = 500;
                    ctx.Response.StatusDescription = "Unknown UserID-2";
                    ctx.ApplicationInstance.CompleteRequest();
                    return(null);
                }

                member = domain.GetMemberByID(status.UserID);
                if (member == null)
                {
                    ctx.Response.StatusCode        = 500;
                    ctx.Response.StatusDescription = "Unknown Member in Domain-2";
                    ctx.ApplicationInstance.CompleteRequest();
                    return(null);
                }

                // Setup a principal
                ctx.User =
                    new GenericPrincipal(
                        new GenericIdentity(
                            member.UserID,
                            "Basic authentication"),
                        rolesArray);

                Thread.CurrentPrincipal = ctx.User;

                // Set the last login time for the user.
                SetLastLoginTime(domain, member);
            }

            return(member);
        }
Пример #11
0
 internal static void UpdatePublicSharediFolderMembers(Simias.Storage.Collection col, GaimBuddy[] buddies)
 {
     Simias.Storage.Domain domain = GaimDomain.GetDomain();
        if (domain == null) return;
        Hashtable subscribedUserIDs = new Hashtable();
        Store store = Store.GetStore();
        Simias.POBox.POBox poBox =
     Simias.POBox.POBox.FindPOBox(store, domain.ID, store.GetUserIDFromDomainID(domain.ID));
        ICSList poList = poBox.Search(
     Simias.POBox.Subscription.SubscriptionCollectionIDProperty,
     col.ID,
     SearchOp.Equal);
        foreach(Simias.Storage.ShallowNode sNode in poList)
        {
     Simias.POBox.Subscription sub = new Simias.POBox.Subscription(poBox, sNode);
     if (sub.SubscriptionState == Simias.POBox.SubscriptionStates.Ready)
     {
      if (poBox.StoreReference.GetCollectionByID(
       sub.SubscriptionCollectionID) != null)
      {
       continue;
      }
     }
     subscribedUserIDs[sub.ToIdentity] = sub.ToIdentity;
     log.Debug("Added {0} to subscribedUserIDs", sub.ToName);
        }
        foreach (GaimBuddy buddy in buddies)
        {
     string[] machineNames = buddy.MachineNames;
     foreach (string machineName in machineNames)
     {
      Member member = FindBuddyInDomain(domain, buddy, machineName);
      if (member != null)
      {
       if (subscribedUserIDs[member.UserID] == null)
       {
        InviteUser(poBox, col, member);
       }
      }
      else
      {
       string memberName = buddy.GetSimiasMemberName(machineName);
       string memberUserID = buddy.GetSimiasUserID(machineName);
       if (memberName != null && memberUserID != null)
       {
        member = new Simias.Storage.Member(
        memberName,
        memberUserID,
        Simias.Storage.Access.Rights.ReadOnly );
        string alias = buddy.Alias;
        if (alias != null)
        {
     member.FN = string.Format("{0} ({1})", alias, machineName);
        }
        domain.Commit( member );
        log.Debug("Added new Gaim Domain Member in Simias: {0} ({1})", buddy.Name, machineName);
        InviteUser(poBox, col, member);
       }
      }
     }
        }
 }
Пример #12
0
 internal static void PruneOldMembers(Simias.Storage.Domain domain, GaimBuddy[] buddies)
 {
     ICSList memberList = domain.GetMemberList();
        foreach(ShallowNode sNode in memberList)
        {
     Simias.Storage.Member member =
      new Simias.Storage.Member(domain, sNode);
     if (member.IsOwner) continue;
     if (!IsMemberInBuddyList(member, buddies))
     {
      domain.Commit(domain.Delete(member));
     }
        }
 }