private bool HandleResourceListsEvent(short code, byte[] content) { bool result; try { if (ContactService.IsSuccessCode(code)) { resourcelists rlist = this.Deserialize(content, typeof(resourcelists)) as resourcelists; if (rlist == null || rlist.list == null) { result = false; return(result); } result = this.FromResouceListToContacts(rlist); return(result); } else if (code == 404) { } } catch (System.Exception e) { ContactService.LOG.Error("Failed to handle 'resource-lists' event", e); result = false; return(result); } result = false; return(result); }
private bool FromResouceListToContacts(resourcelists rlist) { ContactItem parent = this.addressBook; listType[] list2 = rlist.list; for (int i = 0; i < list2.Length; i++) { listType list = list2[i]; if (list != null && list.name != null) { this.GetGroupContact(list, parent); } } return(true); }
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); }
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); }