Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed references to the boost library in remaining source and header files.
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadNickname.cpp
1 // frmContactEditor-LoadNickname.cpp - frmContactEditor load nickname 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"
21 void frmContactEditor::LoadNickname(wxString wxSPropertySeg1, wxString wxSPropertySeg2, 
22         int *NicknameCount, vCard *ContactData){
23                         
24         std::map<int, int> SplitPoints;
25         std::map<int, int> SplitLength;
26         std::map<int, int>::iterator SLiter;                    
27         wxString PropertyData;
28         wxString PropertyName;
29         wxString PropertyValue;
30         wxString PropertyTokens;
31         bool FirstToken = TRUE;
32         int intPrevValue = 10;
33         int intPref = 0;                        
34         int intType = 0;
35         long ListCtrlIndex;
36         
37         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
39         intPrevValue = 9;
40         
41         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
42         intiter != SplitPoints.end(); ++intiter){
43         
44                 SLiter = SplitLength.find(intiter->first);
45         
46                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
47                 
48                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
49                 PropertyName = PropertyElement.GetNextToken();                          
50                 PropertyValue = PropertyElement.GetNextToken();
51                 
52                 intPrevValue = intiter->second;
53                 
54                 if (PropertyName == wxT("TYPE")){
55                 
56                         if (PropertyValue == wxT("work")){
57                         
58                                 intType = 2;                                    
59                         
60                         } else if (PropertyValue == wxT("home")){
62                                 intType = 1;
63                         
64                         } else {
65                         
66                                 intType = 0;
67                         
68                         }
69                 
70                 }
71         
72         }
73         
74         // Setup blank lines for later on.
75         
76         if (intType == 0){
77         
78                 GeneralNicknamesList.insert(std::make_pair(intValueSeek, wxT("")));
79                 GeneralNicknamesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
80                 GeneralNicknamesListPID.insert(std::make_pair(intValueSeek, wxT("")));
81                 GeneralNicknamesListPref.insert(std::make_pair(intValueSeek, 0));
82                 GeneralNicknamesListTokens.insert(std::make_pair(intValueSeek, wxT("")));
83                 GeneralNicknamesListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
85         } else if (intType == 1){
86         
87                 HomeNicknamesList.insert(std::make_pair(intValueSeek, wxT("")));
88                 HomeNicknamesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
89                 HomeNicknamesListPID.insert(std::make_pair(intValueSeek, wxT("")));
90                 HomeNicknamesListPref.insert(std::make_pair(intValueSeek, 0));
91                 HomeNicknamesListTokens.insert(std::make_pair(intValueSeek, wxT("")));
92                 HomeNicknamesListLanguage.insert(std::make_pair(intValueSeek, wxT("")));                                
93         
94         } else if (intType == 2){
96                 BusinessNicknamesList.insert(std::make_pair(intValueSeek, wxT("")));
97                 BusinessNicknamesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
98                 BusinessNicknamesListPID.insert(std::make_pair(intValueSeek, wxT("")));
99                 BusinessNicknamesListPref.insert(std::make_pair(intValueSeek, 0));
100                 BusinessNicknamesListTokens.insert(std::make_pair(intValueSeek, wxT("")));
101                 BusinessNicknamesListLanguage.insert(std::make_pair(intValueSeek, wxT("")));                            
102         
103         }
104         
105         intPrevValue = 9;
106         
107         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
108         intiter != SplitPoints.end(); ++intiter){
109         
110                 SLiter = SplitLength.find(intiter->first);
111         
112                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
113                 
114                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
115                 PropertyName = PropertyElement.GetNextToken();                          
116                 PropertyValue = PropertyElement.GetNextToken();
117                 
118                 intPrevValue = intiter->second;
119                 
120                 ProcessCaptureStrings(&PropertyValue);
121                 
122                 // Process properties.
123                 
124                 size_t intPropertyValueLen = PropertyValue.Len();
125                 
126                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
127                         
128                         PropertyValue.Trim();
129                         PropertyValue.RemoveLast();
130                         
131                 }                               
132                 
133                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
134                         
135                         PropertyValue.Remove(0, 1);
136                         
137                 }                               
138                 
139                 if (PropertyName == wxT("ALTID")){
141                         if (intType == 0){ GeneralNicknamesListAltID.erase(intValueSeek); GeneralNicknamesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
142                         else if (intType == 1){ HomeNicknamesListAltID.erase(intValueSeek); HomeNicknamesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
143                         else if (intType == 2){ BusinessNicknamesListAltID.erase(intValueSeek); BusinessNicknamesListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
144                 
145                 } else if (PropertyName == wxT("PID")){
147                         if (intType == 0){ GeneralNicknamesListPID.erase(intValueSeek); GeneralNicknamesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
148                         else if (intType == 1){ HomeNicknamesListPID.erase(intValueSeek); HomeNicknamesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
149                         else if (intType == 2){ BusinessNicknamesListPID.erase(intValueSeek); BusinessNicknamesListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
150                 
151                 } else if (PropertyName == wxT("PREF")){
152                         
153                         intPref = wxAtoi(PropertyValue);
154                 
155                         if (intType == 0){ GeneralNicknamesListPref.erase(intValueSeek); GeneralNicknamesListPref.insert(std::make_pair(intValueSeek, intPref)); }
156                         else if (intType == 1){ HomeNicknamesListPref.erase(intValueSeek); HomeNicknamesListPref.insert(std::make_pair(intValueSeek, intPref)); }
157                         else if (intType == 2){ BusinessNicknamesListPref.erase(intValueSeek); BusinessNicknamesListPref.insert(std::make_pair(intValueSeek, intPref)); }
158                 
159                 } else if (PropertyName == wxT("LANGUAGE")){
160                 
161                         if (intType == 0){ GeneralNicknamesListLanguage.erase(intValueSeek); GeneralNicknamesListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
162                         else if (intType == 1){ HomeNicknamesListLanguage.erase(intValueSeek); HomeNicknamesListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
163                         else if (intType == 2){ BusinessNicknamesListLanguage.erase(intValueSeek); BusinessNicknamesListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
164                 
165                 } else {
166                 
167                         // Something else we don't know about so append
168                         // to the tokens variable.
169                 
170                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
171                 
172                                 if (FirstToken == TRUE){
173                         
174                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
175                                         FirstToken = FALSE;
176                         
177                                 } else {
178                         
179                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
180                         
181                                 }
182                 
183                         }
184                 
185                 }
186         
187         }
188         
189         // Add the data to the General/Home/Work address variables.
190         
191         ProcessCaptureStrings(&wxSPropertySeg2);
192         
193         wxListItem coldata;
195         coldata.SetId(intValueSeek);
196         coldata.SetData(intValueSeek);
197         coldata.SetText(wxSPropertySeg2);
198         
199         if (intType == 0){
200         
201                 ListCtrlIndex = lboNicknames->InsertItem(coldata);
202                 
203                 if (intPref > 0 && intPref < 101){
204                 
205                         lboNicknames->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
206                         
207                 }
208                 
209                 GeneralNicknamesList.erase(intValueSeek);
210                 GeneralNicknamesListType.erase(intValueSeek);
211                 GeneralNicknamesListTokens.erase(intValueSeek);
212                 GeneralNicknamesList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
213                 GeneralNicknamesListType.insert(std::make_pair(intValueSeek, wxT("")));
214                 GeneralNicknamesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
215         
216         } else if (intType == 1){ 
217         
218                 ListCtrlIndex = lboHomeNicknames->InsertItem(coldata);
220                 if (intPref > 0 && intPref < 101){
221                 
222                         lboHomeNicknames->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
223                         
224                 }
226                 HomeNicknamesList.erase(intValueSeek);
227                 HomeNicknamesListType.erase(intValueSeek);
228                 HomeNicknamesListTokens.erase(intValueSeek);                            
229                 HomeNicknamesList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
230                 HomeNicknamesListType.insert(std::make_pair(intValueSeek, wxT("home")));
231                 HomeNicknamesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
232         
233         } else if (intType == 2){ 
234         
235                 ListCtrlIndex = lboBusinessNicknames->InsertItem(coldata);
237                 if (intPref > 0 && intPref < 101){
238                 
239                         lboBusinessNicknames->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
240                         
241                 }
243                 BusinessNicknamesList.erase(intValueSeek);
244                 BusinessNicknamesListType.erase(intValueSeek);
245                 BusinessNicknamesListTokens.erase(intValueSeek);                                
246                 BusinessNicknamesList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
247                 BusinessNicknamesListType.insert(std::make_pair(intValueSeek, wxT("work")));
248                 BusinessNicknamesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                               
249         
250         }
252         NicknameCount++;
253         intValueSeek++; 
254                         
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