1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadNote(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *NoteCount){
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 GeneralNoteList.insert(std::make_pair(intValueSeek, wxT("")));
62 GeneralNoteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
63 GeneralNoteListPID.insert(std::make_pair(intValueSeek, wxT("")));
64 GeneralNoteListPref.insert(std::make_pair(intValueSeek, 0));
65 GeneralNoteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
66 GeneralNoteListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
68 } else if (intType == 1){
70 HomeNoteList.insert(std::make_pair(intValueSeek, wxT("")));
71 HomeNoteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
72 HomeNoteListPID.insert(std::make_pair(intValueSeek, wxT("")));
73 HomeNoteListPref.insert(std::make_pair(intValueSeek, 0));
74 HomeNoteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
75 HomeNoteListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
77 } else if (intType == 2){
79 BusinessNoteList.insert(std::make_pair(intValueSeek, wxT("")));
80 BusinessNoteListAltID.insert(std::make_pair(intValueSeek, wxT("")));
81 BusinessNoteListPID.insert(std::make_pair(intValueSeek, wxT("")));
82 BusinessNoteListPref.insert(std::make_pair(intValueSeek, 0));
83 BusinessNoteListTokens.insert(std::make_pair(intValueSeek, wxT("")));
84 BusinessNoteListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
90 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
91 intiter != SplitPoints.end(); ++intiter){
93 SLiter = SplitLength.find(intiter->first);
95 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
97 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
98 PropertyName = PropertyElement.GetNextToken();
99 PropertyValue = PropertyElement.GetNextToken();
101 intPrevValue = intiter->second;
103 // Process properties.
105 size_t intPropertyValueLen = PropertyValue.Len();
107 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
109 PropertyValue.Trim();
110 PropertyValue.RemoveLast();
114 if (PropertyValue.Mid(0, 1) == wxT("\"")){
116 PropertyValue.Remove(0, 1);
120 ProcessCaptureStrings(&PropertyValue);
122 if (PropertyName == wxT("ALTID")){
124 if (intType == 0){ GeneralNoteListAltID.erase(intValueSeek); GeneralNoteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
125 else if (intType == 1){ HomeNoteListAltID.erase(intValueSeek); HomeNoteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
126 else if (intType == 2){ BusinessNoteListAltID.erase(intValueSeek); BusinessNoteListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128 } else if (PropertyName == wxT("PID")){
130 if (intType == 0){ GeneralNoteListPID.erase(intValueSeek); GeneralNoteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
131 else if (intType == 1){ HomeNoteListPID.erase(intValueSeek); HomeNoteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
132 else if (intType == 2){ BusinessNoteListPID.erase(intValueSeek); BusinessNoteListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
134 } else if (PropertyName == wxT("PREF")){
136 intPref = wxAtoi(PropertyValue);
138 if (intType == 0){ GeneralNoteListPref.erase(intValueSeek); GeneralNoteListPref.insert(std::make_pair(intValueSeek, intPref)); }
139 else if (intType == 1){ HomeNoteListPref.erase(intValueSeek); HomeNoteListPref.insert(std::make_pair(intValueSeek, intPref)); }
140 else if (intType == 2){ BusinessNoteListPref.erase(intValueSeek); BusinessNoteListPref.insert(std::make_pair(intValueSeek, intPref)); }
142 } else if (PropertyName == wxT("LANGUAGE")){
144 if (intType == 0){ GeneralNoteListLanguage.erase(intValueSeek); GeneralNoteListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
145 else if (intType == 1){ HomeNoteListLanguage.erase(intValueSeek); HomeNoteListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
146 else if (intType == 2){ BusinessNoteListLanguage.erase(intValueSeek); BusinessNoteListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
150 // Something else we don't know about so append
151 // to the tokens variable.
153 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
155 if (FirstToken == TRUE){
157 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
162 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
172 // Add the data to the General/Home/Work address variables.
174 ProcessCaptureStrings(&wxSPropertySeg2);
178 coldata.SetId(intValueSeek);
179 coldata.SetData(intValueSeek);
183 GeneralNoteList.erase(intValueSeek);
184 GeneralNoteListType.erase(intValueSeek);
185 GeneralNoteListTokens.erase(intValueSeek);
186 GeneralNoteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
187 GeneralNoteListType.insert(std::make_pair(intValueSeek, wxT("")));
188 GeneralNoteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
190 //CaptureString(&wxSPropertySeg2, FALSE);
192 coldata.SetText(wxSPropertySeg2);
194 ListCtrlIndex = lboNotes->InsertItem(coldata);
196 if (intPref > 0 && intPref < 101){
198 lboNotes->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
202 } else if (intType == 1){
204 HomeNoteList.erase(intValueSeek);
205 HomeNoteListType.erase(intValueSeek);
206 HomeNoteListTokens.erase(intValueSeek);
207 HomeNoteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
208 HomeNoteListType.insert(std::make_pair(intValueSeek, wxT("home")));
209 HomeNoteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
211 CaptureString(&wxSPropertySeg2, FALSE);
213 coldata.SetText(wxSPropertySeg2);
215 ListCtrlIndex = lboHomeNotes->InsertItem(coldata);
217 if (intPref > 0 && intPref < 101){
219 lboHomeNotes->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
223 } else if (intType == 2){
225 BusinessNoteList.erase(intValueSeek);
226 BusinessNoteListType.erase(intValueSeek);
227 BusinessNoteListTokens.erase(intValueSeek);
228 BusinessNoteList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
229 BusinessNoteListType.insert(std::make_pair(intValueSeek, wxT("work")));
230 BusinessNoteListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
232 CaptureString(&wxSPropertySeg2, FALSE);
234 coldata.SetText(wxSPropertySeg2);
236 ListCtrlIndex = lboBusinessNotes->InsertItem(coldata);
238 if (intPref > 0 && intPref < 101){
240 lboBusinessNotes->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));