1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadGeo(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *GeoCount){
5 size_t intPropertyLen = wxSPropertySeg1.Len();
6 std::map<int, int> SplitPoints;
7 std::map<int, int> SplitLength;
8 std::map<int, int>::iterator SLiter;
10 wxString PropertyName;
11 wxString PropertyValue;
12 wxString PropertyTokens;
15 bool FirstToken = TRUE;
16 int intSplitsFound = 0;
23 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
27 // Look for type before continuing.
29 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
30 intiter != SplitPoints.end(); ++intiter){
32 SLiter = SplitLength.find(intiter->first);
34 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
36 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
37 PropertyName = PropertyElement.GetNextToken();
38 PropertyValue = PropertyElement.GetNextToken();
40 intPrevValue = intiter->second;
42 if (PropertyName == wxT("TYPE")){
44 if (PropertyValue == wxT("work")){
48 } else if (PropertyValue == wxT("home")){
62 // Setup blank lines for later on.
66 GeneralGeographyList.insert(std::make_pair(intValueSeek, wxT("")));
67 GeneralGeographyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
68 GeneralGeographyListPID.insert(std::make_pair(intValueSeek, wxT("")));
69 GeneralGeographyListPref.insert(std::make_pair(intValueSeek, 0));
70 GeneralGeographyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
72 } else if (intType == 1){
74 HomeGeographyList.insert(std::make_pair(intValueSeek, wxT("")));
75 HomeGeographyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
76 HomeGeographyListPID.insert(std::make_pair(intValueSeek, wxT("")));
77 HomeGeographyListPref.insert(std::make_pair(intValueSeek, 0));
78 HomeGeographyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
80 } else if (intType == 2){
82 BusinessGeographyList.insert(std::make_pair(intValueSeek, wxT("")));
83 BusinessGeographyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
84 BusinessGeographyListPID.insert(std::make_pair(intValueSeek, wxT("")));
85 BusinessGeographyListPref.insert(std::make_pair(intValueSeek, 0));
86 BusinessGeographyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
92 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
93 intiter != SplitPoints.end(); ++intiter){
95 SLiter = SplitLength.find(intiter->first);
97 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
99 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
100 PropertyName = PropertyElement.GetNextToken();
101 PropertyValue = PropertyElement.GetNextToken();
103 intPrevValue = intiter->second;
105 // Process properties.
107 size_t intPropertyValueLen = PropertyValue.Len();
109 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
111 PropertyValue.Trim();
112 PropertyValue.RemoveLast();
116 if (PropertyValue.Mid(0, 1) == wxT("\"")){
118 PropertyValue.Remove(0, 1);
122 ProcessCaptureStrings(&PropertyValue);
124 if (PropertyName == wxT("ALTID")){
126 if (intType == 0){ GeneralGeographyListAltID.erase(intValueSeek); GeneralGeographyListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
127 else if (intType == 1){ HomeGeographyListAltID.erase(intValueSeek); HomeGeographyListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128 else if (intType == 2){ BusinessGeographyListAltID.erase(intValueSeek); BusinessGeographyListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
130 } else if (PropertyName == wxT("PID")){
132 if (intType == 0){ GeneralGeographyListPID.erase(intValueSeek); GeneralGeographyListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
133 else if (intType == 1){ HomeGeographyListPID.erase(intValueSeek); HomeGeographyListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
134 else if (intType == 2){ BusinessGeographyListPID.erase(intValueSeek); BusinessGeographyListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
136 } else if (PropertyName == wxT("MEDIATYPE")){
138 if (intType == 0){ GeneralGeographyListMediatype.erase(intValueSeek); GeneralGeographyListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
139 else if (intType == 1){ HomeGeographyListMediatype.erase(intValueSeek); HomeGeographyListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
140 else if (intType == 2){ BusinessGeographyListMediatype.erase(intValueSeek); BusinessGeographyListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
142 } else if (PropertyName == wxT("PREF")){
144 intPref = wxAtoi(PropertyValue);
146 if (intPref > 0 && intPref < 101){
148 if (intType == 0){ GeneralGeographyListPref.erase(intValueSeek); GeneralGeographyListPref.insert(std::make_pair(intValueSeek, intPref)); }
149 else if (intType == 1){ HomeGeographyListPref.erase(intValueSeek); HomeGeographyListPref.insert(std::make_pair(intValueSeek, intPref)); }
150 else if (intType == 2){ BusinessGeographyListPref.erase(intValueSeek); BusinessGeographyListPref.insert(std::make_pair(intValueSeek, intPref)); }
156 // Something else we don't know about so append
157 // to the tokens variable.
159 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
161 if (FirstToken == TRUE){
163 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
168 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
178 // Split the address.
180 //std::map<int, int>::iterator SLiter;
181 intPropertyLen = wxSPropertySeg2.Len();
188 for (int i = 0; i <= intPropertyLen; i++){
192 if (wxSPropertySeg2.Mid(i, 1) == wxT(":") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
195 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
197 if (intSplitsFound == 1){
199 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
210 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
211 intiter != SplitPoints.end(); ++intiter){
213 if (intiter->first == 1){
217 SLiter = SplitLength.find(1);
219 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
220 GeoType = wxSPropertySeg2.Mid(0, SLiter->second);
221 intPrevValue = intiter->second;
223 GeoData = wxSPropertySeg2.Mid(intPrevValue);
229 ProcessCaptureStrings(&wxSPropertySeg2);
233 coldata.SetId(intValueSeek);
234 coldata.SetData(intValueSeek);
241 ListCtrlIndex = lboTimezones->InsertItem(coldata);
243 if (intPref > 0 && intPref < 101){
245 lboTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
251 txtGeopositioning->SetValue(GeoData);
254 GeneralGeographyList.erase(intValueSeek);
255 GeneralGeographyListType.erase(intValueSeek);
256 GeneralGeographyListTokens.erase(intValueSeek);
257 GeneralGeographyList.insert(std::make_pair(intValueSeek, GeoData));
258 GeneralGeographyListType.insert(std::make_pair(intValueSeek, wxT("")));
259 GeneralGeographyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
261 CaptureString(&GeoData, FALSE);
262 coldata.SetText(GeoData);
263 ListCtrlIndex = lboGeoposition->InsertItem(coldata);
265 if (intPref > 0 && intPref < 101){
267 lboGeoposition->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
271 } else if (intType == 1){
275 ListCtrlIndex = lboHomeTimezones->InsertItem(coldata);
277 if (intPref > 0 && intPref < 101){
279 lboHomeTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
286 txtHomeGeopositioning->SetValue(GeoData);
289 HomeGeographyList.erase(intValueSeek);
290 HomeGeographyListType.erase(intValueSeek);
291 HomeGeographyListTokens.erase(intValueSeek);
292 HomeGeographyList.insert(std::make_pair(intValueSeek, GeoData));
293 HomeGeographyListType.insert(std::make_pair(intValueSeek, wxT("home")));
294 HomeGeographyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
296 CaptureString(&GeoData, FALSE);
297 coldata.SetText(GeoData);
298 ListCtrlIndex = lboHomeGeoposition->InsertItem(coldata);
300 if (intPref > 0 && intPref < 101){
302 lboHomeGeoposition->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
306 } else if (intType == 2){
308 ListCtrlIndex = lboBusinessGeoposition->InsertItem(coldata);
312 ListCtrlIndex = lboBusinessTimezones->InsertItem(coldata);
314 if (intPref > 0 && intPref < 101){
316 lboBusinessTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
323 txtBusinessGeopositioning->SetValue(GeoData);
326 BusinessGeographyList.erase(intValueSeek);
327 BusinessGeographyListType.erase(intValueSeek);
328 BusinessGeographyListTokens.erase(intValueSeek);
329 BusinessGeographyList.insert(std::make_pair(intValueSeek, GeoData));
330 BusinessGeographyListType.insert(std::make_pair(intValueSeek, wxT("work")));
331 BusinessGeographyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
333 CaptureString(&GeoData, FALSE);
334 coldata.SetText(GeoData);
335 ListCtrlIndex = lboBusinessGeoposition->InsertItem(coldata);
337 if (intPref > 0 && intPref < 101){
339 lboBusinessGeoposition->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));