void frmContactEditor::LoadKind(ContactKindType *KindType){
- std::cerr << *KindType << std::endl;
-
switch (*KindType){
case CONTACTKIND_INDIVIDUAL:
cmbType->SetSelection(1);
}
+void frmContactEditor::LoadMember(std::map<int,wxString> *GroupList){
+
+ // Go through the list of contacts for the account and find the matching UID.
+ // If contact with UID doesn't match then say (unknown contact).
+
+ XABViewMode XVMData;
+ if (StartupEditMode == FALSE){
+ XVMData = MainPtr->GetViewMode();
+ }
+
+ wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
+
+ //wxString vcardfilenamewxs;
+ wxString vCardFilename;
+ wxString vCardFilenameFull;
+ wxString vCardDataString;
+ //wxStringTokenizer vcardfileline;
+ wxString lwxs;
+ wxString setname, setvalue;
+ wxString MemberData;
+ bool FoundContact = FALSE;
+ //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
+ std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
+ std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
+
+ wxDir vcardaccdir(AccountDirFinal);
+
+ for (std::map<int,wxString>::iterator MemberIter = GroupList->begin();
+ MemberIter != GroupList->end();
+ MemberIter++){
+
+ MemberData = MemberIter->second;
+
+ bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
+ while(ProcFiles){
+
+ if (vCardFilename.Right(4) == wxT(".vcf") ||
+ vCardFilename.Right(4) == wxT(".VCF") ||
+ vCardFilename.Right(5) == wxT(".vcard") ||
+ vCardFilename.Right(5) == wxT(".VCARD")){
+
+ vCard Person;
+
+ vCardFilenameFull.Append(AccountDirFinal);
+ vCardFilenameFull.Append(wxT("/"));
+ vCardFilenameFull.Append(vCardFilename);
+
+ Person.LoadFile(vCardFilenameFull);
+
+ if (MemberData.Left(9) == wxT("urn:uuid:")){
+
+ wxString NewPropValue;
+ NewPropValue = MemberData.Mid(9, wxString::npos);
+ MemberData = NewPropValue;
+
+ }
+
+ if (Person.MeetBaseSpecification()){
+
+ wxString KindStatus = Person.Get(wxT("KIND"));
+
+ if (KindStatus == wxT("group")){
+
+ vCardFilename.Clear();
+ vCardFilenameFull.Clear();
+ vCardDataString.Clear();
+ ProcFiles = vcardaccdir.GetNext(&vCardFilename);
+ continue;
+
+ }
+
+ wxString PersonName = Person.Get(wxT("N"));
+ wxString PersonUID = Person.Get(wxT("UID"));
+ wxString PersonFilename = vCardFilenameFull;
+
+ if (PersonUID != MemberData){
+
+ vCardFilename.Clear();
+ vCardFilenameFull.Clear();
+ vCardDataString.Clear();
+ ProcFiles = vcardaccdir.GetNext(&vCardFilename);
+ continue;
+
+ } else {
+ FoundContact = TRUE;
+ }
+
+ //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
+ //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
+
+ if (XVMData.SortMode == 1){
+
+ // Split the name into sections.
+
+ vCardDataString = Person.Get(wxT("N"));
+
+ vCardName NameData = Person.GetName();
+
+ vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
+
+ } else if (XVMData.SortMode == 2){
+
+ // Split the name into sections.
+
+ vCardName NameData = Person.GetName();
+
+ vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
+
+ } else if (XVMData.SortMode == 3){
+
+ // Check and make sure that the top most nickname is used.
+
+ vCardDataString = Person.Get(wxT("NICKNAME"));
+
+ if (vCardDataString.IsEmpty()){
+
+ vCardDataString = wxT("(no nickname)");
+
+ }
+
+ } else if (XVMData.SortMode == 4){
+
+ vCardDataString = Person.Get(wxT("FN"));
+
+ }
+
+ if (XVMData.AscendingMode == TRUE){
+ vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
+ } else {
+ vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
+ }
+
+ } else {
+
+ }
+
+
+
+ }
+
+ vCardFilename.Clear();
+ vCardFilenameFull.Clear();
+ vCardDataString.Clear();
+ ProcFiles = vcardaccdir.GetNext(&vCardFilename);
+
+ }
+
+ if (FoundContact == FALSE){
+ if (XVMData.AscendingMode == TRUE){
+ vCardNamesAsc.insert(std::make_pair(MemberIter->second, MemberIter->second));
+ } else {
+ vCardNamesDsc.insert(std::make_pair(MemberIter->second, MemberIter->second));
+ }
+ }
+
+ if (XVMData.AscendingMode == TRUE){
+
+ for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin();
+ iter != vCardNamesAsc.end(); ++iter){
+
+ wxListItem ItemData;
+
+ ItemData.SetId(0);
+ ItemData.SetText(iter->first);
+
+ lboGroups->InsertItem(ItemData);
+
+ }
+
+
+ } else {
+
+ for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin();
+ iter != vCardNamesDsc.end(); ++iter){
+
+ wxListItem ItemData;
+
+ ItemData.SetId(0);
+ ItemData.SetText(iter->first);
+
+ lboGroups->InsertItem(ItemData);
+
+ }
+
+ }
+
+ }
+
+}
+
void frmContactEditor::LoadMember(wxString MemberData, int *GroupCount){
// Go through the list of contacts for the account and find the matching UID.
GroupsList.insert(std::make_pair(intValueSeek, iter->second));
- }
-
}
+
+ }
GroupCount++;
intValueSeek++;