예제 #1
0
        private resourcelists CreateResourceListsDocument()
        {
            resourcelists list = new resourcelists();
            int count = 0;

            listType[] rcs = this.GetRCSLists();
            listType[] oma = this.GetOMALists();

            list.list = new listType[rcs.Length + oma.Length + 1];
            rcs.ToList().ForEach(x => list.list[count++] = x);
            oma.ToList().ForEach(x => list.list[count++] = x);

            // Doubango List
            list.list[count] = new listType();
            list.list[count].displayname = new displaynameType();
            list.list[count].displayname.Value = "My Default Contacts";
            list.list[count].name = SpecialNames.SHARED_DOUBANGO;

            String documentUrl;
            //if(this.xcapDocumentsUris.ContainsKey())
            lock (this.xcapSelector)
            {
                this.xcapSelector.reset();
                this.xcapSelector.setAUID(XcapService.XCAP_AUID_IETF_RESOURCE_LISTS_ID);
                documentUrl = this.xcapSelector.getString();
            }
            byte[] payload = this.Serialize(list, true, true, this.GetSerializerNSFromAUID(XcapService.XCAP_AUID_IETF_RESOURCE_LISTS_ID));

            MyXcapMessage xcapMessage = this.xcapStack.PutDocument(documentUrl, payload, (uint)payload.Length, XcapService.XCAP_AUID_IETF_RESOURCE_LISTS_MIME_TYPE);
            if (xcapMessage != null && XcapService.IsSuccessCode(xcapMessage.Code))
            {
                return list;
            }
            return null;
        }
예제 #2
0
        private bool FromResouceListToContacts(resourcelists rlist)
        {
            List<Group> freshGroups = new List<Group>();
            List<Contact> freshContacts = new List<Contact>();

            foreach (listType list in rlist.list)
            {
                if (list != null && list.displayname != null && !String.IsNullOrEmpty(list.displayname.Value))
                {
                    // Group
                    Group group = this.ListToGroup(list);
                    freshGroups.Add(group);

                    // Contact
                    foreach (entryType entry in list.EntryTypes)
                    {
                        Contact contact = this.EntryToContact(entry, group.Name);
                        if (entry.prop != null)
                        {
                            foreach (DoubangoProperty property in entry.prop)
                            {
                                if (property == null || String.IsNullOrEmpty(property.name))
                                {
                                    continue;
                                }
                                switch (property.name)
                                {
                                    case DoubangoProperty.PROP_DISPLAY_NAME:
                                    case DoubangoProperty.PROP_FIRST_NAME:
                                        break;
                                }
                            }
                        }
                        freshContacts.Add(contact);
                    }
                }
            }

            // Update contacts/groups on the UI thread as CollectionView does not support changes from a thread different from the Dispatcher thread
            new Thread(new ThreadStart(delegate(){
                    this.manager.Dispatcher.Invoke(new UpdateGroupsAndContactsDelegate(this.contactService.UpdateGroupsAndContacts),
                        new object[] { freshGroups, freshContacts });
                })).Start();

            return true;
        }