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-LoadKey.cpp
1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadKey(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *KeyCount){
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;                    
9         wxString PropertyData;
10         wxString PropertyName;
11         wxString PropertyValue;
12         wxString PropertyTokens;
13         bool FirstToken = TRUE;
14         int intSplitsFound = 0;
15         int intSplitSize = 0;
16         int intPrevValue = 5;
17         int intPref = 0;                        
18         int intType = 0;
19         long ListCtrlIndex;
20         
21         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
22         
23         intPrevValue = 4;
24         
25         // Look for type before continuing.
26         
27         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
28         intiter != SplitPoints.end(); ++intiter){
29         
30                 SLiter = SplitLength.find(intiter->first);
31         
32                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
33                 
34                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
35                 PropertyName = PropertyElement.GetNextToken();                          
36                 PropertyValue = PropertyElement.GetNextToken();
37                 
38                 intPrevValue = intiter->second;
39                 
40                 if (PropertyName == wxT("TYPE")){
41                 
42                         if (PropertyValue == wxT("work")){
43                         
44                                 intType = 2;                                    
45                         
46                         } else if (PropertyValue == wxT("home")){
48                                 intType = 1;
49                         
50                         } else {
51                         
52                                 intType = 0;
53                         
54                         }
55                 
56                 }
57         
58         }
59         
60         // Setup blank lines for later on.
61         
62         KeyList.insert(std::make_pair(intValueSeek, wxT("")));
63         KeyListAltID.insert(std::make_pair(intValueSeek, wxT("")));
64         KeyListPID.insert(std::make_pair(intValueSeek, wxT("")));
65         KeyListPref.insert(std::make_pair(intValueSeek, 0));
66         KeyListKeyType.insert(std::make_pair(intValueSeek, FALSE));
67         KeyListDataType.insert(std::make_pair(intValueSeek, wxT("")));
68         KeyListDataEncType.insert(std::make_pair(intValueSeek, wxT("")));
69         KeyListTokens.insert(std::make_pair(intValueSeek, wxT("")));
71         intPrevValue = 4;
73         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
74         intiter != SplitPoints.end(); ++intiter){
75         
76                 SLiter = SplitLength.find(intiter->first);
77         
78                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
79                 
80                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
81                 PropertyName = PropertyElement.GetNextToken();                          
82                 PropertyValue = PropertyElement.GetNextToken();
83                 
84                 intPrevValue = intiter->second;
85                 
86                 // Process properties.
87                 
88                 size_t intPropertyValueLen = PropertyValue.Len();
89                 
90                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
91                         
92                         PropertyValue.Trim();
93                         PropertyValue.RemoveLast();
94                         
95                 }                               
96                 
97                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
98                         
99                         PropertyValue.Remove(0, 1);
100                         
101                 }                               
102                 
103                 if (PropertyName == wxT("ALTID")){
105                         KeyListAltID.erase(intValueSeek); KeyListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
106                 
107                 } else if (PropertyName == wxT("PID")){
109                         KeyListPID.erase(intValueSeek); KeyListPID.insert(std::make_pair(intValueSeek, PropertyValue));
110                 
111                 } else if (PropertyName == wxT("PREF")){
112                         
113                         intPref = wxAtoi(PropertyValue);
114                 
115                         KeyListPref.erase(intValueSeek); KeyListPref.insert(std::make_pair(intValueSeek, intPref));
116                 
117                 } else {
118                 
119                         // Something else we don't know about so append
120                         // to the tokens variable.
121                         
122                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
123                         
124                                 if (FirstToken == TRUE){
125                                 
126                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
127                                         FirstToken = FALSE;
128                                 
129                                 } else {
130                                 
131                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
132                                 
133                                 }
134                         
135                         }
136                 
137                 }
138         
139         }                               
140         
141         intPropertyLen = wxSPropertySeg2.Len();
142         SplitPoints.clear();
143         SplitLength.clear();
144         intSplitsFound = 0;
145         intSplitSize = 0;
146         intPrevValue = 0;                       
147         
148         for (int i = 0; i <= intPropertyLen; i++){
150                 intSplitSize++;
151         
152                 if (wxSPropertySeg2.Mid(i, 1) == wxT(";") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
153         
154                         intSplitsFound++;
155                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
156                         
157                         if (intSplitsFound == 6){ 
158                         
159                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
160                                 break; 
161                                 
162                         } else {
163                         
164                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
165                         
166                         }
167                         
168                         intSplitSize = 0;                                       
169         
170                 }
172         }
173         
174         wxString wxSKeyURI;
175         wxString wxSKeyMIME;
176         wxString wxSKeyEncoding;
177         wxString wxSKeyData;
178         std::string base64enc;
179         
180         if (intSplitsFound == 0){
181         
182         } else {
183         
184                 std::map<int, int>::iterator striter;
185         
186                 striter = SplitLength.find(1);
187         
188                 wxStringTokenizer wSTDataType(wxSPropertySeg2.Mid(0, striter->second), wxT(":"));
189         
190                 while (wSTDataType.HasMoreTokens() == TRUE){
191                 
192                         wxSKeyURI = wSTDataType.GetNextToken();
193                         wxSKeyMIME = wSTDataType.GetNextToken();
194                         break;
195                 
196                 }                       
197         
198                 if (wxSKeyURI == wxT("data")){
199                 
200                                 wxStringTokenizer wSTDataInfo(wxSPropertySeg2.Mid((striter->second + 2)), wxT(","));                    
201         
202                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
203                 
204                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
205                                 wxSKeyData = wSTDataInfo.GetNextToken();
206                                 break;
207                 
208                         }
209                 
210                 }
211         
212         }
213         
214         // Add the data to the General/Home/Work address variables.
215         
216         wxListItem coldata;
218         coldata.SetId(intValueSeek);
219         coldata.SetData(intValueSeek);
220         
221         if (wxSKeyURI == wxT("data")){
222         
223                 if (wxSKeyMIME == wxT("application/pgp-keys")){
224         
225                         coldata.SetText(_("PGP Key"));
226                 
227                 } else {
228                 
229                         coldata.SetText(_("Key"));
230                 
231                 }
232                 
233                 KeyListDataEncType.erase(intValueSeek);
234                 KeyListKeyType.erase(intValueSeek);
235                 KeyListDataEncType.insert(std::make_pair(intValueSeek, wxSKeyEncoding));
236                 KeyListKeyType.insert(std::make_pair(intValueSeek, TRUE));
237                 
238                 KeyList.erase(intValueSeek);
239                 KeyList.insert(std::make_pair(intValueSeek, wxSKeyData));
240         
241         } else {
242         
243                 coldata.SetText(wxSPropertySeg2);
244                 
245                 KeyList.erase(intValueSeek);
246                 KeyList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
247         
248         }
249         
250         ListCtrlIndex = lboKeys->InsertItem(coldata);
251                 
252         if (intPref > 0 && intPref < 101){
253                 
254                 lboKeys->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
255         
256         }
257                 
259         KeyListType.erase(intValueSeek);
260         KeyListTokens.erase(intValueSeek);
261         KeyListDataType.erase(intValueSeek);
263         KeyListDataType.insert(std::make_pair(intValueSeek, wxSKeyMIME));
264                 
265         switch (intType){
266                 case 0: KeyListType.insert(std::make_pair(intValueSeek, wxT("")));
267                 case 1: KeyListType.insert(std::make_pair(intValueSeek, wxT("home")));
268                 case 2: KeyListType.insert(std::make_pair(intValueSeek, wxT("work")));
269         }
271         KeyListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
272         
273         KeyCount++;
274         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