Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Implemented MEMBER in frmContactEditor through ContactDataObject.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 28 Dec 2015 22:10:11 +0000 (22:10 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 28 Dec 2015 22:10:11 +0000 (22:10 +0000)
source/contacteditor/frmContactEditor-Load.cpp
source/contacteditor/frmContactEditor-LoadGroup.cpp
source/contacteditor/frmContactEditor.h

index 4049a22..ef9f4f4 100644 (file)
@@ -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<int,wxString>::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
                
index 516b1cc..674126f 100644 (file)
@@ -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<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.
@@ -247,9 +435,9 @@ void frmContactEditor::LoadMember(wxString MemberData, int *GroupCount){
 
                        GroupsList.insert(std::make_pair(intValueSeek, iter->second));
 
-               }
-
            }
+
+       }
        
        GroupCount++;
        intValueSeek++;
index 0457889..38f0de3 100644 (file)
@@ -646,6 +646,7 @@ class frmContactEditor : public frmContactEditorADT
                void LoadName(wxString *NameTitle, wxString *NameForename,
                        wxString *NameSurname, wxString *NameOtherNames, 
                        wxString *NameSuffix);
+               void LoadMember(std::map<int,wxString> *GroupsList);
        
                int intValueSeek = 1;
                bool IsGroup = FALSE;
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy