Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Split frmContactEditor-Load.cpp into 24 files to make it more manageable.
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadURL.cpp
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;                    
8         wxString PropertyData;
9         wxString PropertyName;
10         wxString PropertyValue;
11         wxString PropertyTokens;
12         bool FirstToken = TRUE;
13         int intPrevValue = 5;
14         int intPref = 0;                        
15         int intType = 0;
16         long ListCtrlIndex;
17         
18         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
19         
20         intPrevValue = 4;
21         
22         // Look for type before continuing.
23         
24         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
25         intiter != SplitPoints.end(); ++intiter){
26         
27                 SLiter = SplitLength.find(intiter->first);
28         
29                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
30                 
31                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
32                 PropertyName = PropertyElement.GetNextToken();                          
33                 PropertyValue = PropertyElement.GetNextToken();
34                 
35                 intPrevValue = intiter->second;
36                 
37                 if (PropertyName == wxT("TYPE")){
38                 
39                         if (PropertyValue == wxT("work")){
40                         
41                                 intType = 2;                                    
42                         
43                         } else if (PropertyValue == wxT("home")){
45                                 intType = 1;
46                         
47                         } else {
48                         
49                                 intType = 0;
50                         
51                         }
52                 
53                 }
54         
55         }
56         
57         // Setup blank lines for later on.
58         
59         if (intType == 0){
60         
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){
68         
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("")));
74         
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("")));
82         
83         }
84         
85         intPrevValue = 4;
86         
87         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
88         intiter != SplitPoints.end(); ++intiter){
89         
90                 SLiter = SplitLength.find(intiter->first);
91         
92                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
93                 
94                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
95                 PropertyName = PropertyElement.GetNextToken();                          
96                 PropertyValue = PropertyElement.GetNextToken();
97                 
98                 intPrevValue = intiter->second;
99                 
100                 // Process properties.
101                 
102                 size_t intPropertyValueLen = PropertyValue.Len();
103                 
104                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
105                         
106                         PropertyValue.Trim();
107                         PropertyValue.RemoveLast();
108                         
109                 }                               
110                 
111                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
112                         
113                         PropertyValue.Remove(0, 1);
114                         
115                 }
116                 
117                 ProcessCaptureStrings(&PropertyValue);          
118                 
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)); }
124                 
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)); }
130                 
131                 } else if (PropertyName == wxT("PREF")){
132                         
133                         intPref = wxAtoi(PropertyValue);
134                 
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)); }
138                 
139                 } else if (PropertyName == wxT("MEDIATYPE")){
140                 
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)); }
144                 
145                 } else {
146                 
147                         // Something else we don't know about so append
148                         // to the tokens variable.
149                 
150                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
151                 
152                                 if (FirstToken == TRUE){
153                         
154                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
155                                         FirstToken = FALSE;
156                         
157                                 } else {
158                         
159                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
160                         
161                                 }
162                 
163                         }
164                 
165                 }
166         
167         }
168         
169         // Add the data to the General/Home/Work address variables.
170         
171         ProcessCaptureStrings(&wxSPropertySeg2);
172         
173         wxListItem coldata;
175         coldata.SetId(intValueSeek);
176         coldata.SetData(intValueSeek);
177         coldata.SetText(wxSPropertySeg2);
178         
179         if (intType == 0){
180         
181                 ListCtrlIndex = lboWebsites->InsertItem(coldata);
182                 
183                 if (intPref > 0 && intPref < 101){
184                 
185                         lboWebsites->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
186                         
187                 }
188                 
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));
195         
196         } else if (intType == 1){ 
197         
198                 ListCtrlIndex = lboHomeWebsites->InsertItem(coldata);
200                 if (intPref > 0 && intPref < 101){
201                 
202                         lboHomeWebsites->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
203                         
204                 }
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));
212         
213         } else if (intType == 2){ 
214         
215                 ListCtrlIndex = lboBusinessWebsites->InsertItem(coldata);
217                 if (intPref > 0 && intPref < 101){
218                 
219                         lboBusinessWebsites->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
220                         
221                 }
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));                         
229         
230         }
231         
232         URLCount++;
233         intValueSeek++;
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy