Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed references to the boost library in remaining source and header files.
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadLogo.cpp
1 // frmContactEditor-LoadLogo.cpp - frmContactEditor load logo subroutines.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "frmContactEditor.h"
20 #include "../common/base64.h"
22 void frmContactEditor::LoadLogo(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *LogoCount){
24         size_t intPropertyLen = wxSPropertySeg1.Len();
25         std::map<int, int> SplitPoints;
26         std::map<int, int> SplitLength;
27         std::map<int, int>::iterator SLiter;                    
28         wxString PropertyData;
29         wxString PropertyName;
30         wxString PropertyValue;
31         wxString PropertyTokens;
32         bool FirstToken = TRUE;
33         int intSplitsFound = 0;
34         int intSplitSize = 0;
35         int intPrevValue = 6;
36         int intPref = 0;                        
37         int intType = 0;
38         long ListCtrlIndex;
39         
40         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
41         
42         intPrevValue = 5;
43         
44         // Look for type before continuing.                     
45         
46         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
47         intiter != SplitPoints.end(); ++intiter){
48         
49                 SLiter = SplitLength.find(intiter->first);
50         
51                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
52                 
53                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
54                 PropertyName = PropertyElement.GetNextToken();                          
55                 PropertyValue = PropertyElement.GetNextToken();
56                 
57                 intPrevValue = intiter->second;
58                 
59                 if (PropertyName == wxT("TYPE")){
60                 
61                         if (PropertyValue == wxT("work")){
62                         
63                                 intType = 2;
64                         
65                         } else if (PropertyValue == wxT("home")){
67                                 intType = 1;
68                         
69                         } else {
70                         
71                                 intType = 0;
72                         
73                         }
74                 
75                 }
76         
77         }
78         
79         // Setup blank lines for later on.
80         
81         LogosList.insert(std::make_pair(intValueSeek, ""));
82         LogosListType.insert(std::make_pair(intValueSeek, wxT("")));
83         LogosListAltID.insert(std::make_pair(intValueSeek, wxT("")));
84         LogosListPID.insert(std::make_pair(intValueSeek, wxT("")));
85         LogosListPref.insert(std::make_pair(intValueSeek, 0));
86         LogosListPicEncType.insert(std::make_pair(intValueSeek, wxT("")));
87         LogosListPictureType.insert(std::make_pair(intValueSeek, wxT("")));                     
88         LogosListTokens.insert(std::make_pair(intValueSeek, wxT("")));
89         LogosListMediatype.insert(std::make_pair(intValueSeek, wxT("")));
91         intPrevValue = 5;
93         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
94         intiter != SplitPoints.end(); ++intiter){
95         
96                 SLiter = SplitLength.find(intiter->first);
97         
98                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
99                 
100                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
101                 PropertyName = PropertyElement.GetNextToken();                          
102                 PropertyValue = PropertyElement.GetNextToken();
103                 
104                 intPrevValue = intiter->second;
105                 
106                 // Process properties.
107                 
108                 size_t intPropertyValueLen = PropertyValue.Len();
109                 
110                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
111                         
112                         PropertyValue.Trim();
113                         PropertyValue.RemoveLast();
114                         
115                 }                               
116                 
117                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
118                         
119                         PropertyValue.Remove(0, 1);
120                         
121                 }
122                 
123                 ProcessCaptureStrings(&PropertyValue);  
124                 
125                 if (PropertyName == wxT("ALTID")){
127                         if (intType == 0){ LogosListAltID.erase(intValueSeek); LogosListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128                         else if (intType == 1){ LogosListAltID.erase(intValueSeek); LogosListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
129                         else if (intType == 2){ LogosListAltID.erase(intValueSeek); LogosListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
130                 
131                 } else if (PropertyName == wxT("PID")){
133                         if (intType == 0){ LogosListPID.erase(intValueSeek); LogosListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
134                         else if (intType == 1){ LogosListPID.erase(intValueSeek); LogosListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
135                         else if (intType == 2){ LogosListPID.erase(intValueSeek); LogosListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
136                 
137                 } else if (PropertyName == wxT("PREF")){
138                         
139                         intPref = wxAtoi(PropertyValue);
140                 
141                         if (intType == 0){ LogosListPref.erase(intValueSeek); LogosListPref.insert(std::make_pair(intValueSeek, intPref)); }
142                         else if (intType == 1){ LogosListPref.erase(intValueSeek); LogosListPref.insert(std::make_pair(intValueSeek, intPref)); }
143                         else if (intType == 2){ LogosListPref.erase(intValueSeek); LogosListPref.insert(std::make_pair(intValueSeek, intPref)); }
144                 
145                 } else if (PropertyName == wxT("MEDIATYPE")){
146                 
147                         if (intType == 0){ LogosListMediatype.erase(intValueSeek); LogosListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
148                         else if (intType == 1){ LogosListMediatype.erase(intValueSeek); LogosListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
149                         else if (intType == 2){ LogosListMediatype.erase(intValueSeek); LogosListMediatype.insert(std::make_pair(intValueSeek, PropertyValue)); }
150                 
151                 } else {
152                 
153                         // Something else we don't know about so append
154                         // to the tokens variable.
155                         
156                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
157                         
158                                 if (FirstToken == TRUE){
159                                 
160                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
161                                         FirstToken = FALSE;
162                                 
163                                 } else {
164                                 
165                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
166                                 
167                                 }
168                         
169                         }
170                 
171                 }
172         
173         }       
174         
175         intPropertyLen = wxSPropertySeg2.Len();
176         SplitPoints.clear();
177         SplitLength.clear();
178         intSplitsFound = 0;
179         intSplitSize = 0;
180         intPrevValue = 0;
181         
182         wxString wxSPhotoURI;
183         wxString wxSPhotoMIME;
184         wxString wxSPhotoEncoding;
185         wxString wxSPhotoData;
186         std::string base64enc;
187         
188         ProcessCaptureStrings(&wxSPropertySeg2);
189         
190         if (intSplitsFound == 0){
191         
192         } else {
193         
194                 std::map<int, int>::iterator striter;
195         
196                 striter = SplitLength.find(1);
197         
198                 wxStringTokenizer wSTDataType(wxSPropertySeg2.Mid(0, striter->second), wxT(":"));
199         
200                 while (wSTDataType.HasMoreTokens() == TRUE){
201                 
202                         wxSPhotoURI = wSTDataType.GetNextToken();
203                         wxSPhotoMIME = wSTDataType.GetNextToken();
204                         break;
205                 
206                 }                       
207         
208                 wxStringTokenizer wSTDataInfo(wxSPropertySeg2.Mid((striter->second + 1)), wxT(","));                    
209         
210                 while (wSTDataInfo.HasMoreTokens() == TRUE){
211                 
212                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
213                         wxSPhotoData = wSTDataInfo.GetNextToken();                                      
214                         base64enc = wxSPhotoData.mb_str();
215                         break;
216                 
217                 }
218         
219         }
220         
221         // Add the data to the General/Home/Work address variables.
222         
223         wxListItem coldata;
225         coldata.SetId(intValueSeek);
226         coldata.SetData(intValueSeek);
227         coldata.SetText(_("Picture"));
228         
229         ListCtrlIndex = lboLogos->InsertItem(coldata);
230                 
231         if (intPref > 0 && intPref < 101){
232                 
233                 lboLogos->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), intPref));
234         
235         }
236                 
237         LogosList.erase(intValueSeek);
238         LogosListType.erase(intValueSeek);
239         LogosListTokens.erase(intValueSeek);
240         LogosListPictureType.erase(intValueSeek);
241         LogosListPicEncType.erase(intValueSeek);
242         LogosList.insert(std::make_pair(intValueSeek, base64enc));
243         LogosListPictureType.insert(std::make_pair(intValueSeek, wxSPhotoMIME));
244         LogosListPicEncType.insert(std::make_pair(intValueSeek, wxSPhotoEncoding));
245         
246         if (intType == 0){
247         
248                 LogosListType.insert(std::make_pair(intValueSeek, wxT("")));
249         
250         } else if (intType == 1){
251         
252                 LogosListType.insert(std::make_pair(intValueSeek, wxT("home")));
253                 lboLogos->SetItem(ListCtrlIndex, 1, _("Home"));
254         
255         } else if (intType == 2){
256         
257                 LogosListType.insert(std::make_pair(intValueSeek, wxT("work")));
258                 lboLogos->SetItem(ListCtrlIndex, 1, _("Work"));                         
259         
260         }
261         
262         LogosListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
263         
264         LogoCount++;
265         intValueSeek++;
266                         
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