1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadURL(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *URLCount){
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.
61 GeneralWebsiteList.insert(std::make_pair(intValueSeek, wxT("")));
62 GeneralWebsiteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
63 GeneralWebsiteListPID.insert(std::make_pair(intValueSeek, wxT("")));
64 GeneralWebsiteListPref.insert(std::make_pair(intValueSeek, 0));
65 GeneralWebsiteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
67 } else if (intType == 1){
69 HomeWebsiteList.insert(std::make_pair(intValueSeek, wxT("")));
70 HomeWebsiteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
71 HomeWebsiteListPID.insert(std::make_pair(intValueSeek, wxT("")));
72 HomeWebsiteListPref.insert(std::make_pair(intValueSeek, 0));
73 HomeWebsiteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
75 } else if (intType == 2){
77 BusinessWebsiteList.insert(std::make_pair(intValueSeek, wxT("")));
78 BusinessWebsiteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
79 BusinessWebsiteListPID.insert(std::make_pair(intValueSeek, wxT("")));
80 BusinessWebsiteListPref.insert(std::make_pair(intValueSeek, 0));
81 BusinessWebsiteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
87 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
88 intiter != SplitPoints.end(); ++intiter){
90 SLiter = SplitLength.find(intiter->first);
92 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
94 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
95 PropertyName = PropertyElement.GetNextToken();
96 PropertyValue = PropertyElement.GetNextToken();
98 intPrevValue = intiter->second;
100 // Process properties.
102 size_t intPropertyValueLen = PropertyValue.Len();
104 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
106 PropertyValue.Trim();
107 PropertyValue.RemoveLast();
111 if (PropertyValue.Mid(0, 1) == wxT("\"")){
113 PropertyValue.Remove(0, 1);
117 ProcessCaptureStrings(&PropertyValue);
119 if (PropertyName == wxT("ALTID")){
121 if (intType == 0){ GeneralWebsiteListAltID.erase(intValueSeek); GeneralWebsiteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
122 else if (intType == 1){ HomeWebsiteListAltID.erase(intValueSeek); HomeWebsiteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
123 else if (intType == 2){ BusinessWebsiteListAltID.erase(intValueSeek); BusinessWebsiteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
125 } else if (PropertyName == wxT("PID")){
127 if (intType == 0){ GeneralWebsiteListPID.erase(intValueSeek); GeneralWebsiteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128 else if (intType == 1){ HomeWebsiteListPID.erase(intValueSeek); HomeWebsiteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
129 else if (intType == 2){ BusinessWebsiteListPID.erase(intValueSeek); BusinessWebsiteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
131 } else if (PropertyName == wxT("PREF")){
133 intPref = wxAtoi(PropertyValue);
135 if (intType == 0){ GeneralWebsiteListPref.erase(intValueSeek); GeneralWebsiteListPref.insert(std::make_pair(intValueSeek, intPref)); }
136 else if (intType == 1){ HomeWebsiteListPref.erase(intValueSeek); HomeWebsiteListPref.insert(std::make_pair(intValueSeek, intPref)); }
137 else if (intType == 2){ BusinessWebsiteListPref.erase(intValueSeek); BusinessWebsiteListPref.insert(std::make_pair(intValueSeek, intPref)); }
139 } else if (PropertyName == wxT("MEDIATYPE")){
141 if (intType == 0){ GeneralWebsiteListMediatype.erase(intValueSeek); GeneralWebsiteListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
142 else if (intType == 1){ HomeWebsiteListMediatype.erase(intValueSeek); HomeWebsiteListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
143 else if (intType == 2){ BusinessWebsiteListMediatype.erase(intValueSeek); BusinessWebsiteListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
147 // Something else we don't know about so append
148 // to the tokens variable.
150 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
152 if (FirstToken == TRUE){
154 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
159 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
169 // Add the data to the General/Home/Work address variables.
171 ProcessCaptureStrings(&wxSPropertySeg2);
175 coldata.SetId(intValueSeek);
176 coldata.SetData(intValueSeek);
177 coldata.SetText(wxSPropertySeg2);
181 ListCtrlIndex = lboWebsites->InsertItem(coldata);
183 if (intPref > 0 && intPref < 101){
185 lboWebsites->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
189 GeneralWebsiteList.erase(intValueSeek);
190 GeneralWebsiteListType.erase(intValueSeek);
191 GeneralWebsiteListTokens.erase(intValueSeek);
192 GeneralWebsiteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
193 GeneralWebsiteListType.insert(std::make_pair(intValueSeek, wxT("")));
194 GeneralWebsiteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
196 } else if (intType == 1){
198 ListCtrlIndex = lboHomeWebsites->InsertItem(coldata);
200 if (intPref > 0 && intPref < 101){
202 lboHomeWebsites->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
206 HomeWebsiteList.erase(intValueSeek);
207 HomeWebsiteListType.erase(intValueSeek);
208 HomeWebsiteListTokens.erase(intValueSeek);
209 HomeWebsiteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
210 HomeWebsiteListType.insert(std::make_pair(intValueSeek, wxT("home")));
211 HomeWebsiteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
213 } else if (intType == 2){
215 ListCtrlIndex = lboBusinessWebsites->InsertItem(coldata);
217 if (intPref > 0 && intPref < 101){
219 lboBusinessWebsites->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
223 BusinessWebsiteList.erase(intValueSeek);
224 BusinessWebsiteListType.erase(intValueSeek);
225 BusinessWebsiteListTokens.erase(intValueSeek);
226 BusinessWebsiteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
227 BusinessWebsiteListType.insert(std::make_pair(intValueSeek, wxT("work")));
228 BusinessWebsiteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));