예제 #1
0
파일: POService.cs 프로젝트: lulzzz/simias
        /// <summary>
        /// Start the PO service.
        /// </summary>
        public void Start()
        {
#if (!REMOVE_OLD_INVITATION)
            lock (typeof(POService))
            {
                if (subscriptionService == null)
                {
                    // Start the subscription thread.
                    subscriptionService = new SubscriptionService();
                }
            }
#endif
            // Get a list of all POBoxes.
            ICSList poBoxList = store.GetCollectionsByType(NodeTypes.POBoxType);
            foreach (ShallowNode sn in poBoxList)
            {
                // Add the existing POBoxes to the mapping table.
                POBox poBox = new POBox(store, sn);
                poBoxTable[poBox.ID] = poBox.Domain;

#if (!REMOVE_OLD_INVITATION)
                // Process any active subscriptions.
                ProcessWaitingSubscriptions(poBox);
#endif
            }

            poBoxSubscriber.Enabled      = true;
            invitationSubscriber.Enabled = true;
#if (!REMOVE_OLD_INVITATION)
            noAccessSubscriber.Enabled = true;
#endif
        }
예제 #2
0
파일: POBox.cs 프로젝트: lulzzz/simias
        /// <summary>
        /// POBox factory method that constructs a POBox object for the specified user in the specified domain.
        /// </summary>
        /// <param name="storeObject">The Store object that the POBox belongs to.</param>
        /// <param name="domainId">The ID of the domain that the POBox belongs to.</param>
        /// <param name="userId">The ID of the user that the POBox belongs to.</param>
        /// <returns></returns>
        public static POBox FindPOBox(Store storeObject, string domainId, string userId)
        {
            POBox poBox = null;

            // Build the name of the POBox.
            string name = "POBox:" + domainId + ":" + userId;

            // Search for the POBox.
            ICSEnumerator listEnum = storeObject.GetCollectionsByName(name).GetEnumerator() as ICSEnumerator;

            // There should only be one value returned...
            if (listEnum.MoveNext())
            {
                ShallowNode shallowNode = (ShallowNode)listEnum.Current;

                if (listEnum.MoveNext())
                {
                    // TODO: multiple values were returned ... throw an exception.
                }

                poBox = new POBox(storeObject, shallowNode);
            }

            listEnum.Dispose();
            return(poBox);
        }
예제 #3
0
파일: POManager.cs 프로젝트: lulzzz/simias
        /// <summary>
        /// Start the PO Box manager.
        /// </summary>
        public void Start()
        {
            try
            {
                lock (this)
                {
                    log.Debug("Starting PO Service: {0}", ServiceUrl);

                    // Get a list of all POBoxes.
                    ICSList poBoxList = store.GetCollectionsByType(NodeTypes.POBoxType);
                    foreach (ShallowNode sn in poBoxList)
                    {
                        // Get the domain for this POBox.
                        POBox poBox = new POBox(store, sn);
                        Simias.Storage.Domain domain = store.GetDomain(poBox.Domain);
                        //if (domain.Role == SyncRoles.Slave)
                        //{
                        // start collection managers
                        AddPOBoxManager(poBox.ID);
                        //}
                    }
                }
            }
            catch (Exception e)
            {
                log.Error(e, "Unable to start PO manager.");

                throw e;
            }
        }
예제 #4
0
파일: POService.cs 프로젝트: lulzzz/simias
        /// <summary>
        /// Removes all subscriptions for the collection that is contained in the event.
        /// </summary>
        /// <param name="args">Node event arguments.</param>
        private void OnCollectionNoAccess(NodeEventArgs args)
        {
            // Make sure that this is an event for a collection.
            if (args.Collection == args.ID)
            {
                // Search the POBox collections for a subscription for this collection.
                Property p = new Property(Subscription.SubscriptionCollectionIDProperty, args.ID);

                // Find all of the subscriptions for this POBox.
                ICSList list = store.GetNodesByProperty(p, SearchOp.Equal);
                foreach (ShallowNode sn in list)
                {
                    // Make sure that this node is a subscription.
                    if (sn.Type == NodeTypes.SubscriptionType)
                    {
                        // Get the collection (POBox) for this subscription.
                        POBox poBox = POBox.GetPOBoxByID(store, sn.CollectionID);
                        if (poBox != null)
                        {
                            // Delete this subscription from the POBox.
                            poBox.Commit(poBox.Delete(new Subscription(poBox, sn)));
                        }
                    }
                }
            }
        }
예제 #5
0
파일: POService.cs 프로젝트: lulzzz/simias
 /// <summary>
 /// Looks for active subscriptions in the POBox and queues them to the subscription thread.
 /// </summary>
 /// <param name="poBox">POBox to look for subscriptions in.</param>
 private void ProcessWaitingSubscriptions(POBox poBox)
 {
     foreach (ShallowNode sn in poBox)
     {
         if (sn.Type == NodeTypes.SubscriptionType)
         {
             StartSubscription(poBox, sn.ID);
         }
     }
 }
예제 #6
0
파일: POService.cs 프로젝트: lulzzz/simias
        /// <summary>
        /// Call back when PO Box is created
        /// </summary>
        /// <param name="args"></param>
        private void OnPOBoxCreated(NodeEventArgs args)
        {
            // Get the POBox that caused the event.
            POBox poBox = POBox.GetPOBoxByID(store, args.ID);

            if (poBox != null)
            {
                // Save the domain ID for this POBox.
                poBoxTable[args.ID] = poBox.Domain;
            }
        }
예제 #7
0
파일: POService.cs 프로젝트: lulzzz/simias
        /// <summary>
        /// Handles queuing of subscriptions to the subscription thread when they change.
        /// </summary>
        /// <param name="args"></param>
        private void OnSubscriptionChanged(NodeEventArgs args)
        {
            // Get the POBox for this subscription.
            POBox poBox = POBox.GetPOBoxByID(store, args.Collection);

            if (poBox != null)
            {
                StartSubscription(poBox, args.ID);
            }
            else
            {
                log.Debug("Error: OnSubscriptionChanged - Cannot find POBox {0} for subscription {1}.", args.Collection, args.ID);
            }
        }
예제 #8
0
        /// <summary>
        /// Adds subscription information to be processed if it isn't already
        /// being processed.
        /// </summary>
        /// <param name="poBox">The POBox associated with this subscription.</param>
        /// <param name="subscription">The Subscription to process.</param>
        /// <returns>True if the subscription was queued for processing. False
        /// if the subscription was already being processed.</returns>
        public bool QueueSubscription(POBox poBox, Subscription subscription)
        {
            bool exists = QueueSubscription(new SubQItem(poBox, subscription));

            // If the subscription was queued, signal the thread to process it.
            if (!exists)
            {
                log.Debug("Queued subscription {0} for processing.", subscription.ID);
                subEvent.Set();
            }
            else
            {
                log.Debug("Subscription {0} is already being processed.", subscription.ID);
            }

            return(exists);
        }
예제 #9
0
파일: POService.cs 프로젝트: lulzzz/simias
        /// <summary>
        /// Queues the subscription to the subscription thread queue to start it processing.
        /// </summary>
        /// <param name="poBox">POBox that contains the subscription.</param>
        /// <param name="subscriptionID">The Node ID for the subscription.</param>
        private void StartSubscription(POBox poBox, string subscriptionID)
        {
            // See if this POBox belongs to an old domain.
            Domain domain = store.GetDomain(poBox.Domain);

            if ((domain != null) && (domain.SupportsNewInvitation == false))
            {
                // Get the subscription node.
                Subscription subscription = poBox.GetNodeByID(subscriptionID) as Subscription;
                if (subscription != null)
                {
                    switch (subscription.SubscriptionState)
                    {
                    // invited (master)
                    case SubscriptionStates.Invited:
                        if (subscription.Originator == store.LocalDomain)
                        {
                            subscriptionService.QueueSubscription(poBox, subscription);
                        }
                        break;

                    // replied (slave)
                    case SubscriptionStates.Replied:
                        subscriptionService.QueueSubscription(poBox, subscription);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    log.Debug("Error: OnSubscriptionChanged - Cannot find subscription {0} in POBox {1}.", subscriptionID, poBox.ID);
                }
            }
            else
            {
                if (domain == null)
                {
                    log.Debug("Error: OnSubscriptionChanged - Cannot find domain {0}", poBox.Domain);
                }
            }
        }
예제 #10
0
파일: POBox.cs 프로젝트: lulzzz/simias
        /// <summary>
        /// POBox factory method that constructs a POBox object for the specified user in the specified domain.
        /// </summary>
        /// <param name="storeObject">The Store object that the POBox belongs to.</param>
        /// <param name="domainId">The ID of the domain that the POBox belongs to.</param>
        /// <param name="userId">The ID of the user that the POBox belongs to.</param>
        /// <returns></returns>
        public static POBox GetPOBox(Store storeObject, string domainId, string userId)
        {
            POBox poBox = FindPOBox(storeObject, domainId, userId);

            if (poBox == null)
            {
                // If the POBox cannot be found, create it.
                // Build the name of the POBox.
                string name = "POBox:" + domainId + ":" + userId;
                poBox = new POBox(storeObject, name, domainId);

                Domain domain  = storeObject.GetDomain(domainId);
                Member current = domain.GetMemberByID(userId);

                Member member = new Member(current.Name, current.UserID, Access.Rights.ReadWrite);
                member.IsOwner = true;

                poBox.Commit(new Node[] { poBox, member });
            }

            return(poBox);
        }
예제 #11
0
파일: POBox.cs 프로젝트: lulzzz/simias
        /// <summary>
        /// Removes the subscription for this collection from the specified member.
        /// </summary>
        /// <param name="member">Member to remove subscription from.</param>
        public static void RemoveSubscriptionByMember(string domainID, string collectionID, string userID)
        {
            Store store = Store.GetStore();

#if (!REMOVE_OLD_INVITATION)
            Domain domain = store.GetDomain(domainID);
            if ((domain != null) && (domain.SupportsNewInvitation == true))
            {
#endif
            // Get the member's POBox.
            POBox poBox = POBox.FindPOBox(store, domainID, userID);
            if (poBox != null)
            {
                ICSList subList = poBox.Search(Subscription.SubscriptionCollectionIDProperty, collectionID, SearchOp.Equal);
                if (subList.Count > 0)
                {
                    foreach (ShallowNode sn in subList)
                    {
                        // No need to process further invitation events. The collection cannot be deleted
                        // by removing its members, because the owner of the collection can never be deleted.
                        Subscription subscription = new Subscription(poBox, sn);
                        subscription.CascadeEvents = false;
                        poBox.Commit(poBox.Delete(subscription));
                        log.Debug("RemoveSubscriptionByMember - Removed subscription {0} from member {1}.", sn.ID, userID);
                    }
                }
                else
                {
                    log.Debug("RemoveSubscriptionByMember - No subscriptions found for member {0}.", userID);
                }
            }
            else
            {
                log.Debug("RemoveSubscriptionByMember - Cannot find POBox for member {0}.", userID);
            }
#if (!REMOVE_OLD_INVITATION)
        }
#endif
        }
예제 #12
0
        /// <summary>
        /// Create a proxy for collection
        /// </summary>
        /// <param name="poBox">POBox</param>
        /// <param name="subscription">Subscription</param>
        /// <returns>True if successfull, else false</returns>
        private bool CreateCollectionProxy(POBox poBox, Subscription subscription)
        {
            bool createdProxy = false;

            // Refresh the subscription.
            subscription = poBox.Refresh(subscription) as Subscription;

            // See if the member Node ID is specified yet.
            if (subscription.ToMemberNodeID != null)
            {
                // Check to make sure the collection proxy doesn't already exist.
                if (poBox.StoreReference.GetCollectionByID(subscription.SubscriptionCollectionID) == null)
                {
                    // create slave stub
                    subscription.CreateSlave(poBox.StoreReference);
                    log.Debug("  created collection proxy.");
                }

                createdProxy = true;
            }

            return(createdProxy);
        }
예제 #13
0
 /// <summary>
 /// Initializes an instance of the object.
 /// </summary>
 /// <param name="poBox">The POBox associated with this subscription.</param>
 /// <param name="subscription">The subscription to be serviced.</param>
 public SubQItem(POBox poBox, Subscription subscription)
 {
     this.poBox        = poBox;
     this.subscription = subscription;
     this.processTime  = DateTime.Now;
 }
예제 #14
0
        /// <summary>
        /// Handle when delivered
        /// </summary>
        /// <param name="poBox">POBox reference</param>
        /// <param name="subscription">subscription </param>
        /// <returns>True if successfull, else false</returns>
        private bool DoDelivered(POBox poBox, Subscription subscription)
        {
            bool         result    = false;
            POBoxService poService = new POBoxService();

            log.Debug("  calling the PO Box server to get subscription state");
            log.Debug("  domainID: " + subscription.DomainID);
            log.Debug("  fromID:   " + subscription.FromIdentity);
            log.Debug("  SubID:    " + subscription.MessageID);

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

            if (poUri != null)
            {
                poService.Url = poUri.ToString() + poServiceLabel;
                log.Debug("  connecting to the Post Office Service : " + poService.Url);
            }
            else
            {
                log.Debug("  Could not resolve the PO Box location for: " + subscription.FromIdentity);
                return(result);
            }

            try
            {
                WebState webState =
                    new WebState(
                        subscription.DomainID,
                        subscription.SubscriptionCollectionID,
                        subscription.ToIdentity);

                webState.InitializeWebClient(poService, subscription.DomainID);
            }
            catch (NeedCredentialsException)
            {
                log.Debug("  no credentials - back to sleep");
                return(result);
            }

            try
            {
                SubscriptionInformation subInfo =
                    poService.GetSubscriptionInfo(
                        subscription.DomainID,
                        subscription.FromIdentity,
                        subscription.MessageID,
                        subscription.SubscriptionCollectionID);

                switch (subInfo.Status)
                {
                case POBoxStatus.Success:
                {
                    log.Debug("  subInfo.FromName: " + subInfo.FromName);
                    log.Debug("  subInfo.ToName: " + subInfo.ToName);
                    log.Debug("  subInfo.State: " + subInfo.State.ToString());
                    log.Debug("  subInfo.Disposition: " + subInfo.Disposition.ToString());

                    if (subInfo.Disposition == ( int )SubscriptionDispositions.Accepted)
                    {
                        log.Debug("  creating collection...");

                        // Check to make sure the collection proxy doesn't already exist.
                        if (poBox.StoreReference.GetCollectionByID(subscription.SubscriptionCollectionID) == null)
                        {
                            SubscriptionDetails details = new SubscriptionDetails();
                            details.DirNodeID   = subInfo.DirNodeID;
                            details.DirNodeName = subInfo.DirNodeName;

                            subscription.SubscriptionRights = (Access.Rights)subInfo.AccessRights;
                            subscription.AddDetails(details);
                            poBox.Commit(subscription);

                            // create slave stub
                            subscription.ToMemberNodeID = subInfo.ToNodeID;
                            subscription.CreateSlave(poBox.StoreReference);
                        }

                        // acknowledge the message which removes the originator's subscription.
                        SubscriptionMsg subMsg   = subscription.GenerateSubscriptionMessage();
                        POBoxStatus     wsStatus = poService.AckSubscription(subMsg);
                        if ((wsStatus == POBoxStatus.Success) ||
                            (wsStatus == POBoxStatus.AlreadyAccepted))
                        {
                            // done with the subscription - move to local subscription to the ready state
                            log.Debug("  moving subscription to ready state.");
                            subscription.SubscriptionState = SubscriptionStates.Ready;
                            poBox.Commit(subscription);
                            result = true;
                        }
                        else
                        {
                            log.Debug("  failed acknowledging a subscription");
                            log.Debug("  status = {0}", wsStatus.ToString());
                            log.Debug("  deleting the local subscription");

                            poBox.Commit(poBox.Delete(subscription));
                            result = true;
                        }
                    }
                    break;
                }

                case POBoxStatus.AlreadyAccepted:
                {
                    log.Debug("  the subscription has already been accepted by another client.");
                    result = CreateCollectionProxy(poBox, subscription);
                    break;
                }

                case POBoxStatus.InvalidState:
                {
                    log.Debug("  invalid state");
                    break;
                }

                default:
                {
                    log.Debug("  server error = {0}. Deleting subscription.", subInfo.Status.ToString());
                    poBox.Commit(poBox.Delete(subscription));
                    result = true;
                    break;
                }
                }
            }
            catch (Exception e)
            {
                log.Error("  DoDelivered failed with an exception");
                log.Error(e.Message);
                log.Error(e.StackTrace);
            }

            return(result);
        }
예제 #15
0
        /// <summary>
        /// Do Replied for the invitation
        /// </summary>
        /// <param name="poBox">POBox from which reply will go </param>
        /// <param name="subscription">Subscription</param>
        /// <returns>True if successfull else false</returns>
        private bool DoReplied(POBox poBox, Subscription subscription)
        {
            log.Debug("DoReplied");
            log.Debug("  calling the PO Box server to accept/reject subscription");
            log.Debug("  domainID: " + subscription.DomainID);
            log.Debug("  fromID:   " + subscription.FromIdentity);
            log.Debug("  toID:     " + subscription.ToIdentity);
            log.Debug("  SubID:    " + subscription.MessageID);

            bool         result    = false;
            POBoxService poService = new POBoxService();
            POBoxStatus  wsStatus  = POBoxStatus.UnknownError;

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

            if (poUri != null)
            {
                poService.Url = poUri.ToString() + poServiceLabel;
                log.Debug("  connecting to the Post Office Service : " + poService.Url);
            }
            else
            {
                log.Debug("  could not resolve the PO Box location for: " + subscription.FromIdentity);
                return(result);
            }

            try
            {
                WebState webState =
                    new WebState(
                        subscription.DomainID,
                        subscription.SubscriptionCollectionID,
                        subscription.ToIdentity);

                webState.InitializeWebClient(poService, subscription.DomainID);
            }
            catch (NeedCredentialsException)
            {
                log.Debug("  no credentials - back to sleep");
                return(result);
            }

            // Add a new member to the domain if one doesn't exist already.  This is needed
            // for Workgroup Domains.  If the user doesn't exist, the upcoming call to
            // ResolvePOBoxLocation will fail.
            Domain domain = Store.GetStore().GetDomain(subscription.DomainID);

            if (domain.ConfigType == Domain.ConfigurationType.Workgroup)
            {
                Member member = domain.GetMemberByName(subscription.FromName);
                if (member == null)
                {
                    log.Debug("  added workgroup member {0}", subscription.FromName);
                    member = new Member(subscription.FromName, subscription.FromIdentity, subscription.SubscriptionRights);
                    domain.Commit(member);
                }
            }

            try
            {
                if (subscription.SubscriptionDisposition == SubscriptionDispositions.Accepted)
                {
                    log.Debug("  disposition is accepted!");

                    SubscriptionMsg subMsg = subscription.GenerateSubscriptionMessage();
                    wsStatus = poService.AcceptedSubscription(subMsg);
                    switch (wsStatus)
                    {
                    case POBoxStatus.Success:
                    {
                        log.Debug("  successfully accepted subscription.");
                        subscription.SubscriptionState = SubscriptionStates.Delivered;
                        poBox.Commit(subscription);
                        break;
                    }

                    case POBoxStatus.NotPosted:
                    {
                        log.Debug("  waiting for subscription to be posted.");
                        break;
                    }

                    case POBoxStatus.AlreadyAccepted:
                    {
                        log.Debug("  subscription already accepted from a different client.");
                        result = CreateCollectionProxy(poBox, subscription);
                        break;
                    }

                    case POBoxStatus.AlreadyDeclined:
                    case POBoxStatus.UnknownCollection:
                    case POBoxStatus.UnknownSubscription:
                    case POBoxStatus.UnknownPOBox:
                    case POBoxStatus.UnknownIdentity:
                    {
                        log.Debug("  failed accepting a subscription");
                        log.Debug("  status = {0}", wsStatus.ToString());
                        log.Debug("  deleting the local subscription");

                        // Delete the subscription and return true so the thread
                        // controlling the subscription will die off.
                        poBox.Commit(poBox.Delete(subscription));
                        result = true;
                        break;
                    }

                    default:
                    {
                        log.Debug("  failed Accepting a subscription.  Status: " + wsStatus.ToString());
                        break;
                    }
                    }
                }
                else if (subscription.SubscriptionDisposition == SubscriptionDispositions.Declined)
                {
                    log.Debug("  disposition is declined");

                    SubscriptionMsg subMsg = subscription.GenerateSubscriptionMessage();
                    wsStatus = poService.DeclinedSubscription(subMsg);
                    switch (wsStatus)
                    {
                    case POBoxStatus.Success:
                    {
                        // This subscription is done!
                        log.Debug("  successfully declined subscription {0}", subscription.ID);
                        result = true;
                        break;
                    }

                    case POBoxStatus.AlreadyAccepted:
                    {
                        log.Debug("  subscription already accepted from a different client.");

                        // If the collection has already been accepted on another client, we cannot
                        // automatically accept it here because we don't know where to root the
                        // the collection in the file system.
                        result = true;
                        break;
                    }

                    case POBoxStatus.AlreadyDeclined:
                    case POBoxStatus.UnknownIdentity:
                    case POBoxStatus.UnknownCollection:
                    case POBoxStatus.UnknownPOBox:
                    {
                        log.Debug("  failed declining a subscription");
                        log.Debug("  status = {0}", wsStatus.ToString());
                        log.Debug("  deleting the local subscription");

                        // Delete the subscription and return true so the thread
                        // controlling the subscription will die off.
                        poBox.Commit(poBox.Delete(subscription));
                        result = true;
                        break;
                    }

                    default:
                    {
                        log.Debug("  failed declining a subscription.  Status: " + wsStatus.ToString());
                        break;
                    }
                    }
                }
            }
            catch (Exception e)
            {
                log.Error("  DoReplied failed updating originator's PO box");
                log.Error(e.Message);
                log.Error(e.StackTrace);
            }

            return(result);
        }
예제 #16
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);
        }
 private void InitGlade()
 {
     Glade.XML gxml =
     new Glade.XML (Util.GladePath("collection-properties.glade"),
     "SharingVBox",
     null);
        gxml.Autoconnect (this);
        if(SharingVBox == null)
     Console.WriteLine("SharingVBox didn't load correctly");
        if( pobox == null)
        {
     pobox = Simias.POBox.POBox.GetPOBox(collection.StoreReference,
        collection.StoreReference.DefaultDomain);
        }
        Init_Page();
 }