Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
516b1ccdbe0621693d47506d4a2c82647977f9d2
[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(ContactKindType *KindType){
25         std::cerr << *KindType << std::endl;
27         switch (*KindType){
28                 case CONTACTKIND_INDIVIDUAL:
29                         cmbType->SetSelection(1);
30                         break;
31                 case CONTACTKIND_GROUP:
32                         cmbType->SetSelection(2);
33                         break;
34                 case CONTACTKIND_ORGANISATION:
35                         cmbType->SetSelection(3);
36                         break;
37                 case CONTACTKIND_LOCATION:
38                         cmbType->SetSelection(4);
39                         break;
40                 case CONTACTKIND_NONE:
41                         cmbType->SetSelection(0);
42                         break;
43         }
44                         
45         wxCommandEvent nullevent;
46                         
47         UpdateMembersTab(nullevent);
49 }
51 void frmContactEditor::LoadKind(wxString KindType){
53         if (KindType == wxT("individual")){
54                         
55                 cmbType->SetSelection(1);
56                         
57         } else if (KindType == wxT("group")){
58                         
59                 cmbType->SetSelection(2);
60                 IsGroup = TRUE;
61                         
62         } else if (KindType == wxT("org")){
63                         
64                 cmbType->SetSelection(3);
65                         
66         } else if (KindType == wxT("location")){
67                         
68                 cmbType->SetSelection(4);
69                         
70         } else {
71                         
72                 cmbType->SetSelection(0);
73                         
74         }
75                         
76         wxCommandEvent nullevent;
77                         
78         UpdateMembersTab(nullevent);
80 }
82 void frmContactEditor::LoadMember(wxString MemberData, int *GroupCount){
84         // Go through the list of contacts for the account and find the matching UID.
85         // If contact with UID doesn't match then say (unknown contact).
87         XABViewMode XVMData;
88         if (StartupEditMode == FALSE){
89                 XVMData = MainPtr->GetViewMode();
90         }
91         
92         wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
94         //wxString vcardfilenamewxs;
95         wxString vCardFilename;
96         wxString vCardFilenameFull;
97         wxString vCardDataString;
98         //wxStringTokenizer vcardfileline;
99         wxString lwxs;
100         wxString setname, setvalue;
101         //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
102         std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
103         std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
105         wxDir vcardaccdir(AccountDirFinal);
107         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
108         while(ProcFiles){
110                 if (vCardFilename.Right(4) == wxT(".vcf") || 
111                     vCardFilename.Right(4) == wxT(".VCF") || 
112                     vCardFilename.Right(5) == wxT(".vcard") || 
113                     vCardFilename.Right(5) == wxT(".VCARD")){
115                     vCard Person;
117                     vCardFilenameFull.Append(AccountDirFinal);
118                     vCardFilenameFull.Append(wxT("/"));
119                     vCardFilenameFull.Append(vCardFilename);
121                     Person.LoadFile(vCardFilenameFull);
123                     if (MemberData.Left(9) == wxT("urn:uuid:")){
125                         wxString NewPropValue;
126                         NewPropValue = MemberData.Mid(9, wxString::npos);
127                         MemberData = NewPropValue;
129                     }
131                     if (Person.MeetBaseSpecification()){
133                         wxString KindStatus = Person.Get(wxT("KIND"));
135                         if (KindStatus == wxT("group")){
137                                 vCardFilename.Clear();
138                                 vCardFilenameFull.Clear();
139                                 vCardDataString.Clear();
140                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
141                                 continue;
143                         }
145                         wxString PersonName = Person.Get(wxT("N"));
146                         wxString PersonUID = Person.Get(wxT("UID"));
147                         wxString PersonFilename = vCardFilenameFull;
148                         
149                         if (PersonUID != MemberData){
150                         
151                                 vCardFilename.Clear();
152                                 vCardFilenameFull.Clear();
153                                 vCardDataString.Clear();
154                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
155                                 continue;
156                         
157                         }
159                         //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
160                         //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
162                         if (XVMData.SortMode == 1){
164                             // Split the name into sections.
165         
166                             vCardDataString = Person.Get(wxT("N"));
168                             vCardName NameData = Person.GetName();
169     
170                             vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
171     
172                         } else if (XVMData.SortMode == 2){
173     
174                             // Split the name into sections.
175     
176                             vCardName NameData = Person.GetName();    
177     
178                             vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
179     
180                         } else if (XVMData.SortMode == 3){
181     
182                             // Check and make sure that the top most nickname is used.
183     
184                             vCardDataString = Person.Get(wxT("NICKNAME"));
185     
186                             if (vCardDataString.IsEmpty()){
187         
188                                 vCardDataString = wxT("(no nickname)");
189         
190                             }
191     
192                         } else if (XVMData.SortMode == 4){
193     
194                             vCardDataString = Person.Get(wxT("FN"));
195     
196                         }
198                         if (XVMData.AscendingMode == TRUE){
199                             vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
200                         } else {
201                             vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
202                         }
204                     } else {
206                     }
210                 }
212                 vCardFilename.Clear();
213                 vCardFilenameFull.Clear();
214                 vCardDataString.Clear();
215                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
217             }
219             if (XVMData.AscendingMode == TRUE){
221                 for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin(); 
222                 iter != vCardNamesAsc.end(); ++iter){
224                         wxListItem ItemData;
225                         
226                         ItemData.SetId(0);
227                         ItemData.SetText(iter->first);
228         
229                         lboGroups->InsertItem(ItemData);
230                         
231                         GroupsList.insert(std::make_pair(intValueSeek, iter->second));
232         
233                 }
236             } else {
238                 for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin(); 
239                 iter != vCardNamesDsc.end(); ++iter){
241                         wxListItem ItemData;
242                         
243                         ItemData.SetId(0);
244                         ItemData.SetText(iter->first);
245         
246                         lboGroups->InsertItem(ItemData);
248                         GroupsList.insert(std::make_pair(intValueSeek, iter->second));
250                 }
252             }
253         
254         GroupCount++;
255         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