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