Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Extra commit for -e command switch support.
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadGroup.cpp
1 #include "frmContactEditor.h"
2 #include "../common/dirs.h"
3 #include <wx/dir.h>
5 void frmContactEditor::LoadKind(wxString KindType){
7         if (KindType == wxT("individual")){
8                         
9                 cmbType->SetSelection(1);
10                         
11         } else if (KindType == wxT("group")){
12                         
13                 cmbType->SetSelection(2);
14                 IsGroup = TRUE;
15                         
16         } else if (KindType == wxT("org")){
17                         
18                 cmbType->SetSelection(3);
19                         
20         } else if (KindType == wxT("location")){
21                         
22                 cmbType->SetSelection(4);
23                         
24         } else {
25                         
26                 cmbType->SetSelection(0);
27                         
28         }
29                         
30         wxCommandEvent nullevent;
31                         
32         UpdateMembersTab(nullevent);
34 }
36 void frmContactEditor::LoadMember(wxString MemberData, int *GroupCount){
38         // Go through the list of contacts for the account and find the matching UID.
39         // If contact with UID doesn't match then say (unknown contact).
41         XABViewMode XVMData;
42         if (StartupEditMode == FALSE){
43                 XVMData = MainPtr->GetViewMode();
44         }
45         
46         wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
48         //wxString vcardfilenamewxs;
49         wxString vCardFilename;
50         wxString vCardFilenameFull;
51         wxString vCardDataString;
52         //wxStringTokenizer vcardfileline;
53         wxString lwxs;
54         wxString setname, setvalue;
55         //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
56         std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
57         std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
59         wxDir vcardaccdir(AccountDirFinal);
61         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
62         while(ProcFiles){
64                 if (vCardFilename.Right(4) == wxT(".vcf") || 
65                     vCardFilename.Right(4) == wxT(".VCF") || 
66                     vCardFilename.Right(5) == wxT(".vcard") || 
67                     vCardFilename.Right(5) == wxT(".VCARD")){
69                     vCard Person;
71                     vCardFilenameFull.Append(AccountDirFinal);
72                     vCardFilenameFull.Append(wxT("/"));
73                     vCardFilenameFull.Append(vCardFilename);
75                     Person.LoadFile(vCardFilenameFull);
77                     if (MemberData.Left(9) == wxT("urn:uuid:")){
79                         wxString NewPropValue;
80                         NewPropValue = MemberData.Mid(9, wxString::npos);
81                         MemberData = NewPropValue;
83                     }
85                     if (Person.MeetBaseSpecification()){
87                         wxString KindStatus = Person.Get(wxT("KIND"));
89                         if (KindStatus == wxT("group")){
91                                 vCardFilename.Clear();
92                                 vCardFilenameFull.Clear();
93                                 vCardDataString.Clear();
94                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
95                                 continue;
97                         }
99                         wxString PersonName = Person.Get(wxT("N"));
100                         wxString PersonUID = Person.Get(wxT("UID"));
101                         wxString PersonFilename = vCardFilenameFull;
102                         
103                         if (PersonUID != MemberData){
104                         
105                                 vCardFilename.Clear();
106                                 vCardFilenameFull.Clear();
107                                 vCardDataString.Clear();
108                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
109                                 continue;
110                         
111                         }
113                         //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
114                         //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
116                         if (XVMData.SortMode == 1){
118                             // Split the name into sections.
119         
120                             vCardDataString = Person.Get(wxT("N"));
122                             vCardName NameData = Person.GetName();
123     
124                             vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
125     
126                         } else if (XVMData.SortMode == 2){
127     
128                             // Split the name into sections.
129     
130                             vCardName NameData = Person.GetName();    
131     
132                             vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
133     
134                         } else if (XVMData.SortMode == 3){
135     
136                             // Check and make sure that the top most nickname is used.
137     
138                             vCardDataString = Person.Get(wxT("NICKNAME"));
139     
140                             if (vCardDataString.IsEmpty()){
141         
142                                 vCardDataString = wxT("(no nickname)");
143         
144                             }
145     
146                         } else if (XVMData.SortMode == 4){
147     
148                             vCardDataString = Person.Get(wxT("FN"));
149     
150                         }
152                         if (XVMData.AscendingMode == TRUE){
153                             vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
154                         } else {
155                             vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
156                         }
158                     } else {
160                     }
164                 }
166                 vCardFilename.Clear();
167                 vCardFilenameFull.Clear();
168                 vCardDataString.Clear();
169                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
171             }
173             if (XVMData.AscendingMode == TRUE){
175                 for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin(); 
176                 iter != vCardNamesAsc.end(); ++iter){
178                         wxListItem ItemData;
179                         
180                         ItemData.SetId(0);
181                         ItemData.SetText(iter->first);
182         
183                         lboGroups->InsertItem(ItemData);
184                         
185                         GroupsList.insert(std::make_pair(intValueSeek, iter->second));
186         
187                 }
190             } else {
192                 for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin(); 
193                 iter != vCardNamesDsc.end(); ++iter){
195                         wxListItem ItemData;
196                         
197                         ItemData.SetId(0);
198                         ItemData.SetText(iter->first);
199         
200                         lboGroups->InsertItem(ItemData);
202                         GroupsList.insert(std::make_pair(intValueSeek, iter->second));
204                 }
206             }
207         
208         GroupCount++;
209         intValueSeek++;
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