Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
2ba020c2ff6bfd75e54af0f6aaae1f5ad8eef429
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadGroup.cpp
1 // frmContactEditor-LoadGroup.cpp - frmContactEditor load group subroutines.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "frmContactEditor.h"
20 #include "../common/dirs.h"
21 #include <wx/dir.h>
23 void frmContactEditor::LoadKind(wxString KindType){
25         if (KindType == wxT("individual")){
26                         
27                 cmbType->SetSelection(1);
28                         
29         } else if (KindType == wxT("group")){
30                         
31                 cmbType->SetSelection(2);
32                 IsGroup = TRUE;
33                         
34         } else if (KindType == wxT("org")){
35                         
36                 cmbType->SetSelection(3);
37                         
38         } else if (KindType == wxT("location")){
39                         
40                 cmbType->SetSelection(4);
41                         
42         } else {
43                         
44                 cmbType->SetSelection(0);
45                         
46         }
47                         
48         wxCommandEvent nullevent;
49                         
50         UpdateMembersTab(nullevent);
52 }
54 void frmContactEditor::LoadMember(wxString MemberData, int *GroupCount){
56         // Go through the list of contacts for the account and find the matching UID.
57         // If contact with UID doesn't match then say (unknown contact).
59         XABViewMode XVMData;
60         if (StartupEditMode == FALSE){
61                 XVMData = MainPtr->GetViewMode();
62         }
63         
64         wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
66         //wxString vcardfilenamewxs;
67         wxString vCardFilename;
68         wxString vCardFilenameFull;
69         wxString vCardDataString;
70         //wxStringTokenizer vcardfileline;
71         wxString lwxs;
72         wxString setname, setvalue;
73         //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
74         std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
75         std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
77         wxDir vcardaccdir(AccountDirFinal);
79         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
80         while(ProcFiles){
82                 if (vCardFilename.Right(4) == wxT(".vcf") || 
83                     vCardFilename.Right(4) == wxT(".VCF") || 
84                     vCardFilename.Right(5) == wxT(".vcard") || 
85                     vCardFilename.Right(5) == wxT(".VCARD")){
87                     vCard Person;
89                     vCardFilenameFull.Append(AccountDirFinal);
90                     vCardFilenameFull.Append(wxT("/"));
91                     vCardFilenameFull.Append(vCardFilename);
93                     Person.LoadFile(vCardFilenameFull);
95                     if (MemberData.Left(9) == wxT("urn:uuid:")){
97                         wxString NewPropValue;
98                         NewPropValue = MemberData.Mid(9, wxString::npos);
99                         MemberData = NewPropValue;
101                     }
103                     if (Person.MeetBaseSpecification()){
105                         wxString KindStatus = Person.Get(wxT("KIND"));
107                         if (KindStatus == wxT("group")){
109                                 vCardFilename.Clear();
110                                 vCardFilenameFull.Clear();
111                                 vCardDataString.Clear();
112                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
113                                 continue;
115                         }
117                         wxString PersonName = Person.Get(wxT("N"));
118                         wxString PersonUID = Person.Get(wxT("UID"));
119                         wxString PersonFilename = vCardFilenameFull;
120                         
121                         if (PersonUID != MemberData){
122                         
123                                 vCardFilename.Clear();
124                                 vCardFilenameFull.Clear();
125                                 vCardDataString.Clear();
126                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
127                                 continue;
128                         
129                         }
131                         //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
132                         //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
134                         if (XVMData.SortMode == 1){
136                             // Split the name into sections.
137         
138                             vCardDataString = Person.Get(wxT("N"));
140                             vCardName NameData = Person.GetName();
141     
142                             vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
143     
144                         } else if (XVMData.SortMode == 2){
145     
146                             // Split the name into sections.
147     
148                             vCardName NameData = Person.GetName();    
149     
150                             vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
151     
152                         } else if (XVMData.SortMode == 3){
153     
154                             // Check and make sure that the top most nickname is used.
155     
156                             vCardDataString = Person.Get(wxT("NICKNAME"));
157     
158                             if (vCardDataString.IsEmpty()){
159         
160                                 vCardDataString = wxT("(no nickname)");
161         
162                             }
163     
164                         } else if (XVMData.SortMode == 4){
165     
166                             vCardDataString = Person.Get(wxT("FN"));
167     
168                         }
170                         if (XVMData.AscendingMode == TRUE){
171                             vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
172                         } else {
173                             vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
174                         }
176                     } else {
178                     }
182                 }
184                 vCardFilename.Clear();
185                 vCardFilenameFull.Clear();
186                 vCardDataString.Clear();
187                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
189             }
191             if (XVMData.AscendingMode == TRUE){
193                 for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin(); 
194                 iter != vCardNamesAsc.end(); ++iter){
196                         wxListItem ItemData;
197                         
198                         ItemData.SetId(0);
199                         ItemData.SetText(iter->first);
200         
201                         lboGroups->InsertItem(ItemData);
202                         
203                         GroupsList.insert(std::make_pair(intValueSeek, iter->second));
204         
205                 }
208             } else {
210                 for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin(); 
211                 iter != vCardNamesDsc.end(); ++iter){
213                         wxListItem ItemData;
214                         
215                         ItemData.SetId(0);
216                         ItemData.SetText(iter->first);
217         
218                         lboGroups->InsertItem(ItemData);
220                         GroupsList.insert(std::make_pair(intValueSeek, iter->second));
222                 }
224             }
225         
226         GroupCount++;
227         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