1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadFN(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *FNCount,
4 bool *FNProcessed, vCard *ContactData){
6 size_t intPropertyLen = wxSPropertySeg1.Len();
7 std::map<int, int> SplitPoints;
8 std::map<int, int> SplitLength;
9 std::map<int, int>::iterator SLiter;
10 wxString PropertyData;
11 wxString PropertyName;
12 wxString PropertyValue;
13 wxString PropertyTokens;
14 bool FirstToken = TRUE;
15 int intSplitsFound = 0;
21 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
25 // Look for type before continuing.
27 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
28 intiter != SplitPoints.end(); ++intiter){
30 SLiter = SplitLength.find(intiter->first);
32 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
34 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
35 PropertyName = PropertyElement.GetNextToken();
36 PropertyValue = PropertyElement.GetNextToken();
38 intPrevValue = intiter->second;
40 if (PropertyName == wxT("TYPE")){
42 if (PropertyValue == wxT("work")){
46 } else if (PropertyValue == wxT("home")){
60 // Setup blank lines for later on.
62 FullNamesList.insert(std::make_pair(intValueSeek, wxT("")));
63 FullNamesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
64 FullNamesListPID.insert(std::make_pair(intValueSeek, wxT("")));
65 FullNamesListPref.insert(std::make_pair(intValueSeek, 0));
66 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("")));
67 FullNamesListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
68 FullNamesListTokens.insert(std::make_pair(intValueSeek, wxT("")));
72 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
73 intiter != SplitPoints.end(); ++intiter){
75 SLiter = SplitLength.find(intiter->first);
77 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
79 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
80 PropertyName = PropertyElement.GetNextToken();
81 PropertyValue = PropertyElement.GetNextToken();
83 ProcessCaptureStrings(&PropertyValue);
85 intPrevValue = intiter->second;
87 // Process properties.
89 if (PropertyName == wxT("ALTID")){
91 FullNamesListAltID.erase(intValueSeek); FullNamesListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
93 } else if (PropertyName == wxT("PID")){
95 FullNamesListPID.erase(intValueSeek); FullNamesListPID.insert(std::make_pair(intValueSeek, PropertyValue));
97 } else if (PropertyName == wxT("PREF")){
99 intPref = wxAtoi(PropertyValue);
101 if (intPref > 0 && intPref < 101){
103 FullNamesListPref.erase(intValueSeek); FullNamesListPref.insert(std::make_pair(intValueSeek, intPref));
107 } else if (PropertyName == wxT("LANG")){
109 FullNamesListLanguage.erase(intValueSeek); FullNamesListLanguage.insert(std::make_pair(intValueSeek, PropertyValue));
113 // Something else we don't know about so append
114 // to the tokens variable.
116 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
118 if (FirstToken == TRUE){
120 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
125 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
135 // Split the address.
137 //std::map<int, int>::iterator SLiter;
138 intPropertyLen = wxSPropertySeg2.Len();
145 for (int i = 0; i <= intPropertyLen; i++){
149 if (wxSPropertySeg2.Mid(i, 1) == wxT(":") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
152 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
154 if (intSplitsFound == 1){
156 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
167 // Add the data to the General/Home/Work address variables.
173 coldata.SetId(intValueSeek);
174 coldata.SetData(intValueSeek);
175 coldata.SetText(IMPPType);
179 //ProcessCaptureStrings(wxsPropertySeg2);
181 ProcessCaptureStrings(&wxSPropertySeg2);
183 FullNamesList.erase(intValueSeek);
184 FullNamesListType.erase(intValueSeek);
185 FullNamesListTokens.erase(intValueSeek);
186 FullNamesList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
187 FullNamesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
191 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("")));
193 } else if (intType == 1){
195 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("home")));
197 } else if (intType == 2){
199 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("work")));
203 if (*FNProcessed == FALSE){
205 NameDisplayAs = wxSPropertySeg2;
206 cmbDisplayAs->SetValue(ContactData->Convert(wxSPropertySeg2, TRUE));
216 void frmContactEditor::LoadN(wxString wxSPropertySeg1, wxString wxSPropertySeg2, bool *NameProcessed,
219 size_t intPropertyLen = wxSPropertySeg1.Len();
220 std::map<int, int> SplitPoints;
221 std::map<int, int> SplitLength;
222 std::map<int, int>::iterator SLiter;
223 wxString PropertyData;
224 wxString PropertyName;
225 wxString PropertyValue;
226 wxString PropertyTokens;
227 bool FirstToken = TRUE;
228 int intSplitsFound = 0;
229 int intSplitSize = 0;
230 int intPrevValue = 3;
231 int intSplitSeek = 0;
233 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
235 // Look for type before continuing.
239 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
240 intiter != SplitPoints.end(); ++intiter){
242 SLiter = SplitLength.find(intiter->first);
244 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
246 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
247 PropertyName = PropertyElement.GetNextToken();
248 PropertyValue = PropertyElement.GetNextToken();
250 intPrevValue = intiter->second;
256 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
257 intiter != SplitPoints.end(); ++intiter){
259 SLiter = SplitLength.find(intiter->first);
261 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
263 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
264 PropertyName = PropertyElement.GetNextToken();
265 PropertyValue = PropertyElement.GetNextToken();
267 ProcessCaptureStrings(&PropertyValue);
269 intPrevValue = intiter->second;
271 // Process properties.
273 if (PropertyName == wxT("ALTID")){
275 NameAltID = PropertyValue;
277 } else if (PropertyName == wxT("LANG")){
279 NameLanguage = PropertyValue;
281 } else if (PropertyName == wxT("SORT-AS")){
283 NameDisplayAs = PropertyValue;
287 // Something else we don't know about so append
288 // to the tokens variable.
290 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
292 if (FirstToken == TRUE){
294 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
299 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
309 intPropertyLen = wxSPropertySeg2.Len();
317 for (int i = 0; i <= intPropertyLen; i++){
321 if (wxSPropertySeg2.Mid(i, 1) == wxT(";") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
324 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
326 if (intSplitsFound == 4){
328 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
333 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
343 // Split the data into several parts.
345 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
346 intiter != SplitPoints.end(); ++intiter){
348 if (intiter->first == 1){
350 // Deal with family name.
352 SLiter = SplitLength.find(1);
354 txtSurname->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
356 intPrevValue = intiter->second;
357 NameSurname = wxSPropertySeg2.Mid(0, SLiter->second);
359 } else if (intiter->first == 2){
361 // Deal with given names.
363 SLiter = SplitLength.find(2);
365 txtForename->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
366 intPrevValue = intiter->second;
367 NameForename = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
369 } else if (intiter->first == 3){
371 // Deal with additional names.
373 SLiter = SplitLength.find(3);
375 txtOtherNames->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
376 intPrevValue = intiter->second;
377 NameOtherNames = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
379 } else if (intiter->first == 4){
381 // Deal with honorifix prefixes and suffixes.
383 SLiter = SplitLength.find(4);
385 txtTitle->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
386 intPrevValue = intiter->second;
387 NameTitle = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
389 txtSuffix->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
390 NameSuffix = wxSPropertySeg2.Mid(intPrevValue);
396 NameTokens = PropertyTokens;
397 *NameProcessed = TRUE;