Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Split frmContactEditor-Load.cpp into 24 files to make it more manageable.
[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 = MainPtr->GetViewMode();
42         
43         wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
45         //wxString vcardfilenamewxs;
46         wxString vCardFilename;
47         wxString vCardFilenameFull;
48         wxString vCardDataString;
49         //wxStringTokenizer vcardfileline;
50         wxString lwxs;
51         wxString setname, setvalue;
52         //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
53         std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
54         std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
56         wxDir vcardaccdir(AccountDirFinal);
58         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
59         while(ProcFiles){
61                 if (vCardFilename.Right(4) == wxT(".vcf") || 
62                     vCardFilename.Right(4) == wxT(".VCF") || 
63                     vCardFilename.Right(5) == wxT(".vcard") || 
64                     vCardFilename.Right(5) == wxT(".VCARD")){
66                     vCard Person;
68                     vCardFilenameFull.Append(AccountDirFinal);
69                     vCardFilenameFull.Append(wxT("/"));
70                     vCardFilenameFull.Append(vCardFilename);
72                     Person.LoadFile(vCardFilenameFull);
74                     if (MemberData.Left(9) == wxT("urn:uuid:")){
76                         wxString NewPropValue;
77                         NewPropValue = MemberData.Mid(9, wxString::npos);
78                         MemberData = NewPropValue;
80                     }
82                     if (Person.MeetBaseSpecification()){
84                         wxString KindStatus = Person.Get(wxT("KIND"));
86                         if (KindStatus == wxT("group")){
88                                 vCardFilename.Clear();
89                                 vCardFilenameFull.Clear();
90                                 vCardDataString.Clear();
91                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
92                                 continue;
94                         }
96                         wxString PersonName = Person.Get(wxT("N"));
97                         wxString PersonUID = Person.Get(wxT("UID"));
98                         wxString PersonFilename = vCardFilenameFull;
99                         
100                         if (PersonUID != MemberData){
101                         
102                                 vCardFilename.Clear();
103                                 vCardFilenameFull.Clear();
104                                 vCardDataString.Clear();
105                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
106                                 continue;
107                         
108                         }
110                         //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
111                         //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
113                         if (XVMData.SortMode == 1){
115                             // Split the name into sections.
116         
117                             vCardDataString = Person.Get(wxT("N"));
119                             vCardName NameData = Person.GetName();
120     
121                             vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
122     
123                         } else if (XVMData.SortMode == 2){
124     
125                             // Split the name into sections.
126     
127                             vCardName NameData = Person.GetName();    
128     
129                             vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
130     
131                         } else if (XVMData.SortMode == 3){
132     
133                             // Check and make sure that the top most nickname is used.
134     
135                             vCardDataString = Person.Get(wxT("NICKNAME"));
136     
137                             if (vCardDataString.IsEmpty()){
138         
139                                 vCardDataString = wxT("(no nickname)");
140         
141                             }
142     
143                         } else if (XVMData.SortMode == 4){
144     
145                             vCardDataString = Person.Get(wxT("FN"));
146     
147                         }
149                         if (XVMData.AscendingMode == TRUE){
150                             vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
151                         } else {
152                             vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
153                         }
155                     } else {
157                     }
161                 }
163                 vCardFilename.Clear();
164                 vCardFilenameFull.Clear();
165                 vCardDataString.Clear();
166                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
168             }
170             if (XVMData.AscendingMode == TRUE){
172                 for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin(); 
173                 iter != vCardNamesAsc.end(); ++iter){
175                         wxListItem ItemData;
176                         
177                         ItemData.SetId(0);
178                         ItemData.SetText(iter->first);
179         
180                         lboGroups->InsertItem(ItemData);
181                         
182                         GroupsList.insert(std::make_pair(intValueSeek, iter->second));
183         
184                 }
187             } else {
189                 for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin(); 
190                 iter != vCardNamesDsc.end(); ++iter){
192                         wxListItem ItemData;
193                         
194                         ItemData.SetId(0);
195                         ItemData.SetText(iter->first);
196         
197                         lboGroups->InsertItem(ItemData);
199                         GroupsList.insert(std::make_pair(intValueSeek, iter->second));
201                 }
203             }
204         
205         GroupCount++;
206         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