1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadCalURI(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *CalAdrCount){
5 std::map<int, int> SplitPoints;
6 std::map<int, int> SplitLength;
7 std::map<int, int>::iterator SLiter;
10 wxString PropertyValue;
11 wxString PropertyTokens;
12 bool FirstToken = TRUE;
18 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
22 // Look for type before continuing.
24 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
25 intiter != SplitPoints.end(); ++intiter){
27 SLiter = SplitLength.find(intiter->first);
29 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
31 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
32 PropertyName = PropertyElement.GetNextToken();
33 PropertyValue = PropertyElement.GetNextToken();
35 intPrevValue = intiter->second;
37 if (PropertyName == wxT("TYPE")){
39 if (PropertyValue == wxT("work")){
43 } else if (PropertyValue == wxT("home")){
57 // Setup blank lines for later on.
59 CalendarList.insert(std::make_pair(intValueSeek, wxT("")));
60 CalendarListAltID.insert(std::make_pair(intValueSeek, wxT("")));
61 CalendarListPID.insert(std::make_pair(intValueSeek, wxT("")));
62 CalendarListPref.insert(std::make_pair(intValueSeek, 0));
63 CalendarListTokens.insert(std::make_pair(intValueSeek, wxT("")));
67 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
68 intiter != SplitPoints.end(); ++intiter){
70 SLiter = SplitLength.find(intiter->first);
72 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
74 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
75 PropertyName = PropertyElement.GetNextToken();
76 PropertyValue = PropertyElement.GetNextToken();
78 intPrevValue = intiter->second;
80 // Process properties.
82 size_t intPropertyValueLen = PropertyValue.Len();
84 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
87 PropertyValue.RemoveLast();
91 if (PropertyValue.Mid(0, 1) == wxT("\"")){
93 PropertyValue.Remove(0, 1);
97 if (PropertyName == wxT("ALTID")){
99 CalendarListAltID.erase(intValueSeek); CalendarListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
101 } else if (PropertyName == wxT("PID")){
103 CalendarListPID.erase(intValueSeek); CalendarListPID.insert(std::make_pair(intValueSeek, PropertyValue));
105 } else if (PropertyName == wxT("PREF")){
107 intPref = wxAtoi(PropertyValue);
109 CalendarListPref.erase(intValueSeek); CalendarListPref.insert(std::make_pair(intValueSeek, intPref));
111 } else if (PropertyName == wxT("MEDIATYPE")){
113 CalendarListMediatype.erase(intValueSeek); CalendarListMediatype.insert(std::make_pair(intValueSeek, PropertyValue));
117 // Something else we don't know about so append
118 // to the tokens variable.
120 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
122 if (FirstToken == TRUE){
124 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
129 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
139 // Add the data to the General/Home/Work address variables.
143 coldata.SetId(intValueSeek);
144 coldata.SetData(intValueSeek);
145 coldata.SetText(wxSPropertySeg2);
147 ListCtrlIndex = lboCalendarAddresses->InsertItem(coldata);
149 if (intPref > 0 && intPref < 101){
151 lboCalendarAddresses->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
155 CaptureString(&wxSPropertySeg2, FALSE);
157 CalendarList.erase(intValueSeek);
158 CalendarListType.erase(intValueSeek);
159 CalendarListTokens.erase(intValueSeek);
160 CalendarList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
164 CalendarListType.insert(std::make_pair(intValueSeek, wxT("")));
166 } else if (intType == 1){
168 CalendarListType.insert(std::make_pair(intValueSeek, wxT("home")));
169 lboCalendarAddresses->SetItem(ListCtrlIndex, 1, _("Home"), intPref);
171 } else if (intType == 2){
173 CalendarListType.insert(std::make_pair(intValueSeek, wxT("work")));
174 lboCalendarAddresses->SetItem(ListCtrlIndex, 1, _("Work"), intPref);
178 CalendarListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
185 void frmContactEditor::LoadCalAdrURI(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *CalReqAdrCount){
187 std::map<int, int> SplitPoints;
188 std::map<int, int> SplitLength;
189 std::map<int, int>::iterator SLiter;
190 wxString PropertyData;
191 wxString PropertyName;
192 wxString PropertyValue;
193 wxString PropertyTokens;
194 bool FirstToken = TRUE;
195 int intPrevValue = 11;
200 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
204 // Look for type before continuing.
208 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
209 intiter != SplitPoints.end(); ++intiter){
211 SLiter = SplitLength.find(intiter->first);
213 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
215 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
216 PropertyName = PropertyElement.GetNextToken();
217 PropertyValue = PropertyElement.GetNextToken();
219 intPrevValue = intiter->second;
221 if (PropertyName == wxT("TYPE")){
223 if (PropertyValue == wxT("work")){
227 } else if (PropertyValue == wxT("home")){
241 // Setup blank lines for later on.
243 CalendarRequestList.insert(std::make_pair(intValueSeek, wxT("")));
244 CalendarRequestListAltID.insert(std::make_pair(intValueSeek, wxT("")));
245 CalendarRequestListPID.insert(std::make_pair(intValueSeek, wxT("")));
246 CalendarRequestListPref.insert(std::make_pair(intValueSeek, 0));
247 CalendarRequestListTokens.insert(std::make_pair(intValueSeek, wxT("")));
251 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
252 intiter != SplitPoints.end(); ++intiter){
254 SLiter = SplitLength.find(intiter->first);
256 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
258 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
259 PropertyName = PropertyElement.GetNextToken();
260 PropertyValue = PropertyElement.GetNextToken();
262 intPrevValue = intiter->second;
264 // Process properties.
266 size_t intPropertyValueLen = PropertyValue.Len();
268 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
270 PropertyValue.Trim();
271 PropertyValue.RemoveLast();
275 if (PropertyValue.Mid(0, 1) == wxT("\"")){
277 PropertyValue.Remove(0, 1);
281 if (PropertyName == wxT("ALTID")){
283 CalendarRequestListAltID.erase(intValueSeek); CalendarRequestListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
285 } else if (PropertyName == wxT("PID")){
287 CalendarRequestListPID.erase(intValueSeek); CalendarRequestListPID.insert(std::make_pair(intValueSeek, PropertyValue));
289 } else if (PropertyName == wxT("PREF")){
291 intPref = wxAtoi(PropertyValue);
293 CalendarRequestListPref.erase(intValueSeek); CalendarRequestListPref.insert(std::make_pair(intValueSeek, intPref));
295 } else if (PropertyName == wxT("MEDIATYPE")){
297 CalendarRequestListMediatype.erase(intValueSeek); CalendarRequestListMediatype.insert(std::make_pair(intValueSeek, PropertyValue));
301 // Something else we don't know about so append
302 // to the tokens variable.
304 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
306 if (FirstToken == TRUE){
308 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
313 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
323 // Add the data to the General/Home/Work address variables.
327 coldata.SetId(intValueSeek);
328 coldata.SetData(intValueSeek);
329 coldata.SetText(wxSPropertySeg2);
331 ListCtrlIndex = lboCalendarRequestAddress->InsertItem(coldata);
333 if (intPref > 0 && intPref < 101){
335 lboCalendarRequestAddress->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
339 CaptureString(&wxSPropertySeg2, FALSE);
341 CalendarRequestList.erase(intValueSeek);
342 CalendarRequestListType.erase(intValueSeek);
343 CalendarRequestListTokens.erase(intValueSeek);
344 CalendarRequestList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
348 CalendarRequestListType.insert(std::make_pair(intValueSeek, wxT("")));
350 } else if (intType == 1){
352 CalendarRequestListType.insert(std::make_pair(intValueSeek, wxT("home")));
353 lboCalendarRequestAddress->SetItem(ListCtrlIndex, 1, _("Home"), intPref);
355 } else if (intType == 2){
357 CalendarRequestListType.insert(std::make_pair(intValueSeek, wxT("work")));
358 lboCalendarRequestAddress->SetItem(ListCtrlIndex, 1, _("Work"), intPref);
362 CalendarRequestListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));