From 72333f7096a54d703f6d5e7a2489bf7a3a4126e1 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 28 Dec 2015 22:10:11 +0000 Subject: [PATCH] Implemented MEMBER in frmContactEditor through ContactDataObject. --- .../contacteditor/frmContactEditor-Load.cpp | 8 +- .../frmContactEditor-LoadGroup.cpp | 196 +++++++++++++++++- source/contacteditor/frmContactEditor.h | 1 + 3 files changed, 199 insertions(+), 6 deletions(-) diff --git a/source/contacteditor/frmContactEditor-Load.cpp b/source/contacteditor/frmContactEditor-Load.cpp index 4049a22..ef9f4f4 100644 --- a/source/contacteditor/frmContactEditor-Load.cpp +++ b/source/contacteditor/frmContactEditor-Load.cpp @@ -161,6 +161,10 @@ bool frmContactEditor::LoadContact(wxString Filename){ LoadName(&ContactEditorData.NameTitle, &ContactEditorData.NameForename, &ContactEditorData.NameSurname, &ContactEditorData.NameOtherNames, &ContactEditorData.NameSuffix); + + // Process the group members (MEMBER) (frmContactEditor-LoadGroup.cpp) + + LoadMember(&ContactEditorData.GroupsList); for (std::map::iterator iter = ContactFileLines.begin(); iter != ContactFileLines.end(); ++iter){ @@ -269,13 +273,13 @@ bool frmContactEditor::LoadContact(wxString Filename){ LoadKind(wxSPropertySeg2); - }*/ else if (wxSProperty == wxT("MEMBER")){ + }/* else if (wxSProperty == wxT("MEMBER")){ // See frmContactEditor-LoadGroup.cpp LoadMember(wxSPropertySeg2, &GroupCount); - } else if (wxSProperty == wxT("FN")){ + }*/ else if (wxSProperty == wxT("FN")){ // See frmContactEditor-LoadName.cpp diff --git a/source/contacteditor/frmContactEditor-LoadGroup.cpp b/source/contacteditor/frmContactEditor-LoadGroup.cpp index 516b1cc..674126f 100644 --- a/source/contacteditor/frmContactEditor-LoadGroup.cpp +++ b/source/contacteditor/frmContactEditor-LoadGroup.cpp @@ -22,8 +22,6 @@ void frmContactEditor::LoadKind(ContactKindType *KindType){ - std::cerr << *KindType << std::endl; - switch (*KindType){ case CONTACTKIND_INDIVIDUAL: cmbType->SetSelection(1); @@ -79,6 +77,196 @@ void frmContactEditor::LoadKind(wxString KindType){ } +void frmContactEditor::LoadMember(std::map *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>; + std::multimap> vCardNamesAsc; + std::multimap> vCardNamesDsc; + + wxDir vcardaccdir(AccountDirFinal); + + for (std::map::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::iterator iter = vCardNamesAsc.begin(); + iter != vCardNamesAsc.end(); ++iter){ + + wxListItem ItemData; + + ItemData.SetId(0); + ItemData.SetText(iter->first); + + lboGroups->InsertItem(ItemData); + + } + + + } else { + + for (std::map::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. @@ -247,9 +435,9 @@ void frmContactEditor::LoadMember(wxString MemberData, int *GroupCount){ GroupsList.insert(std::make_pair(intValueSeek, iter->second)); - } - } + + } GroupCount++; intValueSeek++; diff --git a/source/contacteditor/frmContactEditor.h b/source/contacteditor/frmContactEditor.h index 0457889..38f0de3 100644 --- a/source/contacteditor/frmContactEditor.h +++ b/source/contacteditor/frmContactEditor.h @@ -646,6 +646,7 @@ class frmContactEditor : public frmContactEditorADT void LoadName(wxString *NameTitle, wxString *NameForename, wxString *NameSurname, wxString *NameOtherNames, wxString *NameSuffix); + void LoadMember(std::map *GroupsList); int intValueSeek = 1; bool IsGroup = FALSE; -- 2.39.5