1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadTimeZone(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *TZCount){
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;
13 bool FirstToken = TRUE;
14 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.
64 GeneralTZList.insert(std::make_pair(intValueSeek, wxT("")));
65 GeneralTZListAltID.insert(std::make_pair(intValueSeek, wxT("")));
66 GeneralTZListPID.insert(std::make_pair(intValueSeek, wxT("")));
67 GeneralTZListPref.insert(std::make_pair(intValueSeek, 0));
68 GeneralTZListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
69 GeneralTZListTokens.insert(std::make_pair(intValueSeek, wxT("")));
71 } else if (intType == 1){
73 HomeTZList.insert(std::make_pair(intValueSeek, wxT("")));
74 HomeTZListAltID.insert(std::make_pair(intValueSeek, wxT("")));
75 HomeTZListPID.insert(std::make_pair(intValueSeek, wxT("")));
76 HomeTZListPref.insert(std::make_pair(intValueSeek, 0));
77 HomeTZListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
78 HomeTZListTokens.insert(std::make_pair(intValueSeek, wxT("")));
80 } else if (intType == 2){
82 BusinessTZList.insert(std::make_pair(intValueSeek, wxT("")));
83 BusinessTZListAltID.insert(std::make_pair(intValueSeek, wxT("")));
84 BusinessTZListPID.insert(std::make_pair(intValueSeek, wxT("")));
85 BusinessTZListPref.insert(std::make_pair(intValueSeek, 0));
86 BusinessTZListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
87 BusinessTZListTokens.insert(std::make_pair(intValueSeek, wxT("")));
93 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
94 intiter != SplitPoints.end(); ++intiter){
96 SLiter = SplitLength.find(intiter->first);
98 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
100 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
101 PropertyName = PropertyElement.GetNextToken();
102 PropertyValue = PropertyElement.GetNextToken();
104 intPrevValue = intiter->second;
106 size_t intPropertyValueLen = PropertyValue.Len();
108 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
110 PropertyValue.Trim();
111 PropertyValue.RemoveLast();
115 if (PropertyValue.Mid(0, 1) == wxT("\"")){
117 PropertyValue.Remove(0, 1);
121 ProcessCaptureStrings(&PropertyValue);
123 // Process properties.
125 if (PropertyName == wxT("ALTID")){
127 if (intType == 0){ GeneralTZListAltID.erase(intValueSeek); GeneralTZListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128 else if (intType == 1){ HomeTZListAltID.erase(intValueSeek); HomeTZListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
129 else if (intType == 2){ BusinessTZListAltID.erase(intValueSeek); BusinessTZListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
131 } else if (PropertyName == wxT("PID")){
133 if (intType == 0){ GeneralTZListPID.erase(intValueSeek); GeneralTZListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
134 else if (intType == 1){ HomeTZListPID.erase(intValueSeek); HomeTZListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
135 else if (intType == 2){ BusinessTZListPID.erase(intValueSeek); BusinessTZListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
137 } else if (PropertyName == wxT("MEDIATYPE")){
139 if (intType == 0){ GeneralTZListMediatype.erase(intValueSeek); GeneralTZListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
140 else if (intType == 1){ HomeTZListMediatype.erase(intValueSeek); HomeTZListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
141 else if (intType == 2){ BusinessTZListMediatype.erase(intValueSeek); BusinessTZListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
143 } else if (PropertyName == wxT("PREF")){
145 intPref = wxAtoi(PropertyValue);
147 if (intPref > 0 && intPref < 101){
149 if (intType == 0){ GeneralTZListPref.erase(intValueSeek); GeneralTZListPref.insert(std::make_pair(intValueSeek, intPref)); }
150 else if (intType == 1){ HomeTZListPref.erase(intValueSeek); HomeTZListPref.insert(std::make_pair(intValueSeek, intPref)); }
151 else if (intType == 2){ BusinessTZListPref.erase(intValueSeek); BusinessTZListPref.insert(std::make_pair(intValueSeek, intPref)); }
157 // Something else we don't know about so append
158 // to the tokens variable.
160 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
162 if (FirstToken == TRUE){
164 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
169 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
179 // Split the address.
181 //std::map<int, int>::iterator SLiter;
182 intPropertyLen = wxSPropertySeg2.Len();
189 for (int i = 0; i <= intPropertyLen; i++){
193 if (wxSPropertySeg2.Mid(i, 1) == wxT(";") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
196 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
198 if (intSplitsFound == 6){
200 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
205 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
215 // Add the data to the General/Home/Work address variables.
217 ProcessCaptureStrings(&wxSPropertySeg2);
221 coldata.SetId(intValueSeek);
222 coldata.SetData(intValueSeek);
223 coldata.SetText(wxSPropertySeg2);
227 ListCtrlIndex = lboTimezones->InsertItem(coldata);
229 if (intPref > 0 && intPref < 101){
231 lboTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
235 GeneralTZList.erase(intValueSeek);
236 GeneralTZListType.erase(intValueSeek);
237 GeneralTZListTokens.erase(intValueSeek);
238 GeneralTZList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
239 GeneralTZListType.insert(std::make_pair(intValueSeek, wxT("")));
240 GeneralTZListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
242 } else if (intType == 1){
244 ListCtrlIndex = lboHomeTimezones->InsertItem(coldata);
246 if (intPref > 0 && intPref < 101){
248 lboHomeTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
252 HomeTZList.erase(intValueSeek);
253 HomeTZListType.erase(intValueSeek);
254 HomeTZListTokens.erase(intValueSeek);
255 HomeTZList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
256 HomeTZListType.insert(std::make_pair(intValueSeek, wxT("home")));
257 HomeTZListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
259 } else if (intType == 2){
261 ListCtrlIndex = lboBusinessTimezones->InsertItem(coldata);
263 if (intPref > 0 && intPref < 101){
265 lboBusinessTimezones->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
269 BusinessTZList.erase(intValueSeek);
270 BusinessTZListType.erase(intValueSeek);
271 BusinessTZListTokens.erase(intValueSeek);
272 BusinessTZList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
273 BusinessTZListType.insert(std::make_pair(intValueSeek, wxT("work")));
274 BusinessTZListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));