Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added comments to describe functions in frmUpdate
[xestiaab/.git] / source / search / frmSearch-process.cpp
1 // frmSearch-process.cpp - Search process 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 "frmSearch.h"
20 #include "../common/preferences.h"
21 #include "../common/dirs.h"
22 #include "../vcard/vcard.h"
24 void frmSearch::SearchContactsThread(){
26         // Go through each account and find contacts based on the
27         // matched settings.
28         
29         std::map<wxString,bool>::iterator SAiter;
30         std::map<wxString,wxString>::iterator SAPiter;
31         int intResultFound = 0;
32         
33         for (std::map<wxString, wxString>::iterator SALiter = SearchAccountsNames.begin(); 
34                 SALiter != SearchAccountsNames.end();
35                 SALiter++){
36         
37                 // Double check that we are searching in this account.
38                 // If not, skip to the next one.
39                 
40                 SAiter = SearchAccounts.find(SALiter->first);
41                 SAPiter = SearchAccountsPaths.find(SAiter->first);
42                 
43                 
44                 if (SAiter->second == FALSE){
45                 
46                         // Not looking in this account. Go to next account.
47                 
48                         continue;
49                 
50                 }
51                 
52                 wxCommandEvent sbupdate (SE_SBUPDATE);
53                 
54                 wxString *SBData = new wxString;
55                 *SBData = _("Searching ") + SALiter->second + _("...");
56                 
57                 sbupdate.SetClientData(SBData);         
58                 wxPostEvent(this, sbupdate);
59                 
60                 if (StopMode == FALSE){
61                 
62                         wxCommandEvent sbstop (SE_SBUPDATE);
63                 
64                         wxString *SBStopStr = new wxString;
65                         *SBStopStr = _("Search stopped.");
66                 
67                         sbstop.SetClientData(SBStopStr);                
68                         wxPostEvent(this, sbstop);
69                         return;
70                 
71                 }
72                 
73                 // Get the list of contact files and process each
74                 // one of them.
75                 
76                 wxString AccountDir = GetAccountDir(SAPiter->second, FALSE);
77                 
78                 wxString vcardfilenamewxs;
79                 wxStringTokenizer vcardfileline;
80                 wxString lwxs;
81                 wxString setname, setvalue;
82                 long ContactIndex = 1;
83                 long ContactSeekPoint = 0;
84                 wxString vCardFilename;
85                 wxString vCardFilenameFull;
86                 
87                 if (wxDirExists(AccountDir)){
88                 
89                         wxDir vcardaccdir(AccountDir);
90                 
91                         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
92                         while(ProcFiles){
94                                 if (StopMode == FALSE){
96                                         wxCommandEvent sbstop(SE_SBUPDATE);
98                                         wxString *SBStopStr = new wxString;
99                                         *SBStopStr = _("Search stopped.");
101                                         sbstop.SetClientData(SBStopStr);
102                                         wxPostEvent(this, sbstop);
103                                         return;
105                                 }
107                                 if (vCardFilename.Right(4) == wxT(".vcf") || 
108                                         vCardFilename.Right(4) == wxT(".VCF") || 
109                                         vCardFilename.Right(5) == wxT(".vcard") || 
110                                         vCardFilename.Right(5) == wxT(".VCARD")){
111         
112                                         vCard Person;           
113                                         vCardFilenameFull.Append(AccountDir);
114                                         vCardFilenameFull.Append(vCardFilename);
116                                         Person.LoadFile(vCardFilenameFull);
117                 
118                                         vcardfilenamewxs = vCardFilenameFull;
120                                         // Check if file has version 4.0, first name (FN)
121                                         // begin and end vCard portions.
122                 
123                                         // Don't search unless these conditions have been met.          
124                 
125                                         if (Person.MeetBaseSpecification()){
126                 
127                                                 // Go through each of the search settings and check
128                                                 // if they match with contact details.
129                                         
130                                                 // If it matches then add to the search results.
131                                         
132                                                 int SelOpt = 0;
133                                                 bool chkOpt = FALSE;
134                                                 wxString StrOpt;
135                                                 int StrOptLen = 0;
136                                                 ArrayvCardOutData ArrayData;
137                                                 ArrayvCardOutData NicknameArrayData;
138                                                 vCardName NameArray = Person.GetName();
139                                                 wxString ContactFinalNickname;
140                                                 NicknameArrayData = Person.GetByPartial(wxT("NICKNAME"));
141                                         
142                                                 if (NicknameArrayData.PropCount != 0){
143                                                         ContactFinalNickname = NicknameArrayData.PropValues[0];
144                                                 }               
145                                         
146                                                 for (std::map<int, void*>::iterator siter = SearchFrames.begin();
147                                                 siter != SearchFrames.end(); siter++){
148                                         
149                                                         // Get the settings from the form.
150                                                 
151                                                         XABSearchPanel *XABSPPtr = static_cast<XABSearchPanel*>(siter->second);
152                                                 
153                                                         // Get Selected Option and Setting.
154                                                 
155                                                         SelOpt = XABSPPtr->GetSelectionOption();
156                                                 
157                                                         if (SelOpt < 12){
158                                                 
159                                                                 StrOpt = XABSPPtr->GetStringSetting();
160                                                                 StrOptLen = StrOpt.Len();
161                                                 
162                                                                 if (SelOpt == 0 || SelOpt == 4 || SelOpt == 8){
163                                                 
164                                                                         // Matching string that beings with...
165                                                                 
166                                                                         // Double check the std::map inserts for each section.
167                                                                 
168                                                                         if (SelOpt == 0){
169                                                                 
170                                                                                 // Get the forename from the first N.
171                                                                 
172                                                                                 if (NameArray.Forename.Mid(0, StrOptLen) == StrOpt){
173                                                                         
174                                                                                         if (CheckDuplicate(vcardfilenamewxs,
175                                                                                                 SAPiter->second, 
176                                                                                                 &SearchResultAccount,
177                                                                                                 &SearchResultFilename) == TRUE){
178                                                                                 
179                                                                                                 SelOpt = 0;
180                                                                                                 chkOpt = FALSE;
181                                                                                                 StrOpt.Clear();
182                                                                                                 StrOptLen = 0;
183                                                                                                 ArrayData.PropData.Clear();
184                                                                                                 ArrayData.PropValues.Clear();
185                                                                                                 ArrayData.PropCount = 0;
186                                                                                                 continue;
187                                                                                         
188                                                                                         }
189                                                                         
190                                                                                         SRNotif *sradd = new SRNotif;
191                                                                                         sradd->ContactName = NameArray;
192                                                                                         sradd->ContactNickname = ContactFinalNickname;
193                                                                                         sradd->ContactAccount = SAPiter->second;
194                                                                                         sradd->ContactAccountName = SALiter->second;
195                                                                                         sradd->ContactFullFilename = vcardfilenamewxs;
196                                                                                         sradd->SearchResultID = intResultFound;
197                                                                         
198                                                                                         SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
199                                                                                         SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
200                                                                         
201                                                                                         intResultFound++;
202                                                                         
203                                                                                         wxCommandEvent sraddenv(SE_ADDRESULT);
204                                                                                         sraddenv.SetClientData(sradd);
205                                                                                         wxPostEvent(this, sraddenv);
206                                                                         
207                                                                                 }
208                                                                 
209                                                                         } else if (SelOpt == 4){
210                                                                 
211                                                                                 if (NameArray.Surname.Mid(0, StrOptLen) == StrOpt){
212                                                                         
213                                                                                         if (CheckDuplicate(vcardfilenamewxs,
214                                                                                                 SAPiter->second, 
215                                                                                                 &SearchResultAccount,
216                                                                                                 &SearchResultFilename) == TRUE){
217                                                                                 
218                                                                                                 SelOpt = 0;
219                                                                                                 chkOpt = FALSE;
220                                                                                                 StrOpt.Clear();
221                                                                                                 StrOptLen = 0;
222                                                                                                 ArrayData.PropData.Clear();
223                                                                                                 ArrayData.PropValues.Clear();
224                                                                                                 ArrayData.PropCount = 0;
225                                                                                                 continue;
226                                                                                         
227                                                                                         }
228                                                                         
229                                                                                         SRNotif *sradd = new SRNotif;
230                                                                                         sradd->ContactName = NameArray;
231                                                                                         sradd->ContactNickname = ContactFinalNickname;
232                                                                                         sradd->ContactAccount = SAPiter->second;
233                                                                                         sradd->ContactAccountName = SALiter->second;
234                                                                                         sradd->ContactFullFilename = vcardfilenamewxs;
235                                                                                         sradd->SearchResultID = intResultFound;
236                                                                         
237                                                                                         SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
238                                                                                         SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
239                                                                         
240                                                                                         intResultFound++;
241                                                                         
242                                                                                         wxCommandEvent sraddenv(SE_ADDRESULT);
243                                                                                         sraddenv.SetClientData(sradd);
244                                                                                         wxPostEvent(this, sraddenv);
245                                                                         
246                                                                                 }
247                                                                 
248                                                                         } else if (SelOpt == 8){
249                                                                 
250                                                                                 wxString NicknameData;
251                                                                         
252                                                                                 for (int i = 0; i < NicknameArrayData.PropCount; i++){
253                                                                         
254                                                                                         NicknameData = NicknameArrayData.PropValues[i];
256                                                                                         if (NicknameData.Mid(0, StrOptLen) == StrOpt){
257                                                                                 
258                                                                                                 if (CheckDuplicate(vcardfilenamewxs,
259                                                                                                         SAPiter->second, 
260                                                                                                         &SearchResultAccount,
261                                                                                                         &SearchResultFilename) == TRUE){
262                                                                                 
263                                                                                                         SelOpt = 0;
264                                                                                                         chkOpt = FALSE;
265                                                                                                         StrOpt.Clear();
266                                                                                                         StrOptLen = 0;
267                                                                                                         ArrayData.PropData.Clear();
268                                                                                                         ArrayData.PropValues.Clear();
269                                                                                                         ArrayData.PropCount = 0;
270                                                                                                         continue;
271                                                                                         
272                                                                                                 }
273                                                                                 
274                                                                                                 SRNotif *sradd = new SRNotif;
275                                                                                                 sradd->ContactName = NameArray;
276                                                                                                 sradd->ContactNickname = ContactFinalNickname;
277                                                                                                 sradd->ContactAccount = SAPiter->second;
278                                                                                                 sradd->ContactAccountName = SALiter->second;
279                                                                                                 sradd->ContactFullFilename = vcardfilenamewxs;
280                                                                                                 sradd->SearchResultID = intResultFound;
281                                                                         
282                                                                                                 SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
283                                                                                                 SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
284                                                                         
285                                                                                                 intResultFound++;
286                                                                         
287                                                                                                 wxCommandEvent sraddenv(SE_ADDRESULT);
288                                                                                                 sraddenv.SetClientData(sradd);
289                                                                                                 wxPostEvent(this, sraddenv);
290                                                                                         
291                                                                                                 break;
292                                                                                 
293                                                                                         }
294                                                                 
295                                                                                 }
296                                                                 
297                                                                         }
298                                                 
299                                                                 } else if (SelOpt == 1 || SelOpt == 5 || SelOpt == 9){
300                                                 
301                                                                         // Matching string that ends with...
302                                                                 
303                                                                         if (SelOpt == 1){
304                                                                 
305                                                                                 // Check the forename.
306                                                                         
307                                                                                 if (NameArray.Forename.Right(StrOptLen) == StrOpt){
308                                                                         
309                                                                                         if (CheckDuplicate(vcardfilenamewxs,
310                                                                                                 SAPiter->second, 
311                                                                                                 &SearchResultAccount,
312                                                                                                 &SearchResultFilename) == TRUE){
313                                                                                 
314                                                                                                 SelOpt = 0;
315                                                                                                 chkOpt = FALSE;
316                                                                                                 StrOpt.Clear();
317                                                                                                 StrOptLen = 0;
318                                                                                                 ArrayData.PropData.Clear();
319                                                                                                 ArrayData.PropValues.Clear();
320                                                                                                 ArrayData.PropCount = 0;
321                                                                                                 continue;
322                                                                                         
323                                                                                         }
324                                                                         
325                                                                                         SRNotif *sradd = new SRNotif;
326                                                                                         sradd->ContactName = NameArray;
327                                                                                         sradd->ContactNickname = ContactFinalNickname;
328                                                                                         sradd->ContactAccount = SAPiter->second;
329                                                                                         sradd->ContactAccountName = SALiter->second;
330                                                                                         sradd->ContactFullFilename = vcardfilenamewxs;
331                                                                                         sradd->SearchResultID = intResultFound;
332                                                                         
333                                                                                         SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
334                                                                                         SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
335                                                                         
336                                                                                         intResultFound++;
337                                                                         
338                                                                                         wxCommandEvent sraddenv(SE_ADDRESULT);
339                                                                                         sraddenv.SetClientData(sradd);
340                                                                                         wxPostEvent(this, sraddenv);
341                                                                         
342                                                                                 }
343                                                                 
344                                                                         } else if (SelOpt == 5){
345                                                                 
346                                                                                 if (NameArray.Surname.Right(StrOptLen) == StrOpt){
347                                                                         
348                                                                                         if (CheckDuplicate(vcardfilenamewxs,
349                                                                                                 SAPiter->second, 
350                                                                                                 &SearchResultAccount,
351                                                                                                 &SearchResultFilename) == TRUE){
352                                                                                 
353                                                                                                 SelOpt = 0;
354                                                                                                 chkOpt = FALSE;
355                                                                                                 StrOpt.Clear();
356                                                                                                 StrOptLen = 0;
357                                                                                                 ArrayData.PropData.Clear();
358                                                                                                 ArrayData.PropValues.Clear();
359                                                                                                 ArrayData.PropCount = 0;
360                                                                                                 continue;
361                                                                                         
362                                                                                         }
363                                                                         
364                                                                                         SRNotif *sradd = new SRNotif;
365                                                                                         sradd->ContactName = NameArray;
366                                                                                         sradd->ContactNickname = ContactFinalNickname;
367                                                                                         sradd->ContactAccount = SAPiter->second;
368                                                                                         sradd->ContactAccountName = SALiter->second;
369                                                                                         sradd->ContactFullFilename = vcardfilenamewxs;
370                                                                                         sradd->SearchResultID = intResultFound;
371                                                                         
372                                                                                         SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
373                                                                                         SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
374                                                                         
375                                                                                         intResultFound++;
376                                                                         
377                                                                                         wxCommandEvent sraddenv(SE_ADDRESULT);
378                                                                                         sraddenv.SetClientData(sradd);
379                                                                                         wxPostEvent(this, sraddenv);
380                                                                         
381                                                                                 }
382                                                                 
383                                                                         } else if (SelOpt == 9){
384                                                                 
385                                                                                 wxString NicknameData;
386                                                                         
387                                                                                 for (int i = 0; i < NicknameArrayData.PropCount; i++){
388                                                                         
389                                                                                         NicknameData = NicknameArrayData.PropValues[i];
390                                                                                         NicknameData.Trim();
392                                                                                         if (NicknameData.Right(StrOptLen) == StrOpt){
393                                                                                 
394                                                                                                 if (CheckDuplicate(vcardfilenamewxs,
395                                                                                                         SAPiter->second, 
396                                                                                                         &SearchResultAccount,
397                                                                                                         &SearchResultFilename) == TRUE){
398                                                                                 
399                                                                                                         SelOpt = 0;
400                                                                                                         chkOpt = FALSE;
401                                                                                                         StrOpt.Clear();
402                                                                                                         StrOptLen = 0;
403                                                                                                         ArrayData.PropData.Clear();
404                                                                                                         ArrayData.PropValues.Clear();
405                                                                                                         ArrayData.PropCount = 0;
406                                                                                                         continue;
407                                                                                         
408                                                                                                 }
409                                                                                 
410                                                                                                 SRNotif *sradd = new SRNotif;
411                                                                                                 sradd->ContactName = NameArray;
412                                                                                                 sradd->ContactNickname = ContactFinalNickname;
413                                                                                                 sradd->ContactAccount = SAPiter->second;
414                                                                                                 sradd->ContactAccountName = SALiter->second;
415                                                                                                 sradd->ContactFullFilename = vcardfilenamewxs;
416                                                                                                 sradd->SearchResultID = intResultFound;
417                                                                         
418                                                                                                 SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
419                                                                                                 SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
420                                                                         
421                                                                                                 intResultFound++;
422                                                                         
423                                                                                                 wxCommandEvent sraddenv(SE_ADDRESULT);
424                                                                                                 sraddenv.SetClientData(sradd);
425                                                                                                 wxPostEvent(this, sraddenv);
426                                                                                         
427                                                                                                 break;
428                                                                                 
429                                                                                         }
430                                                                 
431                                                                                 }
432                                                                 
433                                                                         }
434                                                 
435                                                                 } else if (SelOpt == 2 || SelOpt == 6 || SelOpt == 10){
436                                                 
437                                                                         // Matching string that contains...
438                                                 
439                                                                         if (SelOpt == 2){
440                                                                 
441                                                                                 if (NameArray.Forename.Find(StrOpt) != wxNOT_FOUND){
442                                                                         
443                                                                                         if (CheckDuplicate(vcardfilenamewxs,
444                                                                                                 SAPiter->second, 
445                                                                                                 &SearchResultAccount,
446                                                                                                 &SearchResultFilename) == TRUE){
447                                                                                 
448                                                                                                 SelOpt = 0;
449                                                                                                 chkOpt = FALSE;
450                                                                                                 StrOpt.Clear();
451                                                                                                 StrOptLen = 0;
452                                                                                                 ArrayData.PropData.Clear();
453                                                                                                 ArrayData.PropValues.Clear();
454                                                                                                 ArrayData.PropCount = 0;
455                                                                                                 continue;
456                                                                                         
457                                                                                         }
458                                                                         
459                                                                                         SRNotif *sradd = new SRNotif;
460                                                                                         sradd->ContactName = NameArray;
461                                                                                         sradd->ContactNickname = ContactFinalNickname;
462                                                                                         sradd->ContactAccount = SAPiter->second;
463                                                                                         sradd->ContactAccountName = SALiter->second;
464                                                                                         sradd->ContactFullFilename = vcardfilenamewxs;
465                                                                                         sradd->SearchResultID = intResultFound;
466                                                                         
467                                                                                         SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
468                                                                                         SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
469                                                                         
470                                                                                         intResultFound++;
471                                                                         
472                                                                                         wxCommandEvent sraddenv(SE_ADDRESULT);
473                                                                                         sraddenv.SetClientData(sradd);
474                                                                                         wxPostEvent(this, sraddenv);
475                                                                         
476                                                                                 }
477                                                                 
478                                                                         } else if (SelOpt == 6){
479                                                                 
480                                                                                 if (NameArray.Surname.Find(StrOpt) != wxNOT_FOUND){
481                                                                         
482                                                                                         if (CheckDuplicate(vcardfilenamewxs,
483                                                                                                 SAPiter->second, 
484                                                                                                 &SearchResultAccount,
485                                                                                                 &SearchResultFilename) == TRUE){
486                                                                                 
487                                                                                                 SelOpt = 0;
488                                                                                                 chkOpt = FALSE;
489                                                                                                 StrOpt.Clear();
490                                                                                                 StrOptLen = 0;
491                                                                                                 ArrayData.PropData.Clear();
492                                                                                                 ArrayData.PropValues.Clear();
493                                                                                                 ArrayData.PropCount = 0;
494                                                                                                 continue;
495                                                                                         
496                                                                                         }
497                                                                         
498                                                                                         SRNotif *sradd = new SRNotif;
499                                                                                         sradd->ContactName = NameArray;
500                                                                                         sradd->ContactNickname = ContactFinalNickname;
501                                                                                         sradd->ContactAccount = SAPiter->second;
502                                                                                         sradd->ContactAccountName = SALiter->second;
503                                                                                         sradd->ContactFullFilename = vcardfilenamewxs;
504                                                                                         sradd->SearchResultID = intResultFound;
505                                                                         
506                                                                                         SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
507                                                                                         SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
508                                                                         
509                                                                                         intResultFound++;
510                                                                         
511                                                                                         wxCommandEvent sraddenv(SE_ADDRESULT);
512                                                                                         sraddenv.SetClientData(sradd);
513                                                                                         wxPostEvent(this, sraddenv);
514                                                                         
515                                                                                 }
516                                                                 
517                                                                         } else if (SelOpt == 10){
518                                                                 
519                                                                                 wxString NicknameData;
520                                                                         
521                                                                                 for (int i = 0; i < NicknameArrayData.PropCount; i++){
522                                                                         
523                                                                                         NicknameData = NicknameArrayData.PropValues[i];
524                                                                                         NicknameData.Trim();
526                                                                                         if (NicknameData.Find(StrOpt) != wxNOT_FOUND){
527                                                                                 
528                                                                                                 if (CheckDuplicate(vcardfilenamewxs,
529                                                                                                         SAPiter->second, 
530                                                                                                         &SearchResultAccount,
531                                                                                                         &SearchResultFilename) == TRUE){
532                                                                                 
533                                                                                                         SelOpt = 0;
534                                                                                                         chkOpt = FALSE;
535                                                                                                         StrOpt.Clear();
536                                                                                                         StrOptLen = 0;
537                                                                                                         ArrayData.PropData.Clear();
538                                                                                                         ArrayData.PropValues.Clear();
539                                                                                                         ArrayData.PropCount = 0;
540                                                                                                         continue;
541                                                                                         
542                                                                                                 }
543                                                                                 
544                                                                                                 SRNotif *sradd = new SRNotif;
545                                                                                                 sradd->ContactName = NameArray;
546                                                                                                 sradd->ContactNickname = ContactFinalNickname;
547                                                                                                 sradd->ContactAccount = SAPiter->second;
548                                                                                                 sradd->ContactAccountName = SALiter->second;
549                                                                                                 sradd->ContactFullFilename = vcardfilenamewxs;
550                                                                                                 sradd->SearchResultID = intResultFound;
551                                                                         
552                                                                                                 SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
553                                                                                                 SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
554                                                                         
555                                                                                                 intResultFound++;
556                                                                         
557                                                                                                 wxCommandEvent sraddenv(SE_ADDRESULT);
558                                                                                                 sraddenv.SetClientData(sradd);
559                                                                                                 wxPostEvent(this, sraddenv);
560                                                                                         
561                                                                                                 break;
562                                                                                 
563                                                                                         }
564                                                                 
565                                                                                 }
566                                                                 
567                                                                         }
568                                                 
569                                                                 } else if (SelOpt == 3 || SelOpt == 7 || SelOpt == 11){
570                                                 
571                                                                         // Matching String that doesn't contain...
572                                                 
573                                                                         if (SelOpt == 3){
574                                                                 
575                                                                                 // Process the nickname data.
576                                                                 
577                                                                                 if (NameArray.Forename.Find(StrOpt) == wxNOT_FOUND){
578                                                                         
579                                                                                         if (CheckDuplicate(vcardfilenamewxs,
580                                                                                                 SAPiter->second, 
581                                                                                                 &SearchResultAccount,
582                                                                                                 &SearchResultFilename) == TRUE){
583                                                                                 
584                                                                                                 SelOpt = 0;
585                                                                                                 chkOpt = FALSE;
586                                                                                                 StrOpt.Clear();
587                                                                                                 StrOptLen = 0;
588                                                                                                 ArrayData.PropData.Clear();
589                                                                                                 ArrayData.PropValues.Clear();
590                                                                                                 ArrayData.PropCount = 0;
591                                                                                                 continue;
592                                                                                         
593                                                                                         }
594                                                                         
595                                                                                         SRNotif *sradd = new SRNotif;
596                                                                                         sradd->ContactName = NameArray;
597                                                                                         sradd->ContactNickname = ContactFinalNickname;
598                                                                                         sradd->ContactAccount = SAPiter->second;
599                                                                                         sradd->ContactAccountName = SALiter->second;
600                                                                                         sradd->ContactFullFilename = vcardfilenamewxs;
601                                                                                         sradd->SearchResultID = intResultFound;
602                                                                         
603                                                                                         SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
604                                                                                         SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
605                                                                         
606                                                                                         intResultFound++;
607                                                                         
608                                                                                         wxCommandEvent sraddenv(SE_ADDRESULT);
609                                                                                         sraddenv.SetClientData(sradd);
610                                                                                         wxPostEvent(this, sraddenv);
611                                                                         
612                                                                                 }
613                                                                 
614                                                                         } else if (SelOpt == 7){
615                                                                 
616                                                                                 if (!NameArray.Surname.Find(StrOpt) == wxNOT_FOUND){
617                                                                         
618                                                                                         if (CheckDuplicate(vcardfilenamewxs,
619                                                                                                 SAPiter->second, 
620                                                                                                 &SearchResultAccount,
621                                                                                                 &SearchResultFilename) == TRUE){
622                                                                                 
623                                                                                                 SelOpt = 0;
624                                                                                                 chkOpt = FALSE;
625                                                                                                 StrOpt.Clear();
626                                                                                                 StrOptLen = 0;
627                                                                                                 ArrayData.PropData.Clear();
628                                                                                                 ArrayData.PropValues.Clear();
629                                                                                                 ArrayData.PropCount = 0;
630                                                                                                 continue;
631                                                                                         
632                                                                                         }
633                                                                         
634                                                                                         SRNotif *sradd = new SRNotif;
635                                                                                         sradd->ContactName = NameArray;
636                                                                                         sradd->ContactNickname = ContactFinalNickname;
637                                                                                         sradd->ContactAccount = SAPiter->second;
638                                                                                         sradd->ContactAccountName = SALiter->second;
639                                                                                         sradd->ContactFullFilename = vcardfilenamewxs;
640                                                                                         sradd->SearchResultID = intResultFound;
641                                                                         
642                                                                                         SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
643                                                                                         SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
644                                                                         
645                                                                                         intResultFound++;
646                                                                         
647                                                                                         wxCommandEvent sraddenv(SE_ADDRESULT);
648                                                                                         sraddenv.SetClientData(sradd);
649                                                                                         wxPostEvent(this, sraddenv);
650                                                                         
651                                                                                 }
652                                                                 
653                                                                         } else if (SelOpt == 11){
654                                                                 
655                                                                                 wxString NicknameData;
656                                                                         
657                                                                                 for (int i = 0; i < NicknameArrayData.PropCount; i++){
658                                                                         
659                                                                                         NicknameData = NicknameArrayData.PropValues[i];
660                                                                                         NicknameData.Trim();
662                                                                                         if (NicknameData.Find(StrOpt) == wxNOT_FOUND){
663                                                                                 
664                                                                                                 if (CheckDuplicate(vcardfilenamewxs,
665                                                                                                         SAPiter->second, 
666                                                                                                         &SearchResultAccount,
667                                                                                                         &SearchResultFilename) == TRUE){
668                                                                                 
669                                                                                                         SelOpt = 0;
670                                                                                                         chkOpt = FALSE;
671                                                                                                         StrOpt.Clear();
672                                                                                                         StrOptLen = 0;
673                                                                                                         ArrayData.PropData.Clear();
674                                                                                                         ArrayData.PropValues.Clear();
675                                                                                                         ArrayData.PropCount = 0;
676                                                                                                         continue;
677                                                                                         
678                                                                                                 }
679                                                                                 
680                                                                                                 SRNotif *sradd = new SRNotif;
681                                                                                                 sradd->ContactName = NameArray;
682                                                                                                 sradd->ContactNickname = ContactFinalNickname;
683                                                                                                 sradd->ContactAccount = SAPiter->second;
684                                                                                                 sradd->ContactAccountName = SALiter->second;
685                                                                                                 sradd->ContactFullFilename = vcardfilenamewxs;
686                                                                                                 sradd->SearchResultID = intResultFound;
687                                                                         
688                                                                                                 SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
689                                                                                                 SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
690                                                                         
691                                                                                                 intResultFound++;
692                                                                         
693                                                                                                 wxCommandEvent sraddenv(SE_ADDRESULT);
694                                                                                                 sraddenv.SetClientData(sradd);
695                                                                                                 wxPostEvent(this, sraddenv);
696                                                                                         
697                                                                                                 break;
698                                                                                 
699                                                                                         }
700                                                                 
701                                                                                 }
702                                                                 
703                                                                         }
704                                                 
705                                                                 }
706                                                 
707                                                         } else {
709                                                                 chkOpt = XABSPPtr->GetCheckboxSetting();
710                                                         
711                                                                 if (SelOpt == 12){
712                                                         
713                                                                         // Search should check if it has a photo or not.
714                                                         
715                                                                         ArrayData = Person.GetByPartial(wxT("PHOTO"));
716                                                         
717                                                                         if ((ArrayData.PropCount >= 1 &&
718                                                                         chkOpt == TRUE) || 
719                                                                         (ArrayData.PropCount == 0 &&
720                                                                         chkOpt == FALSE)){
721                                                                 
722                                                                                 if (CheckDuplicate(vcardfilenamewxs,
723                                                                                         SAPiter->second, 
724                                                                                         &SearchResultAccount,
725                                                                                         &SearchResultFilename) == TRUE){
726                                                                         
727                                                                                         SelOpt = 0;
728                                                                                         chkOpt = FALSE;
729                                                                                         StrOpt.Clear();
730                                                                                         StrOptLen = 0;
731                                                                                         ArrayData.PropData.Clear();
732                                                                                         ArrayData.PropValues.Clear();
733                                                                                         ArrayData.PropCount = 0;
734                                                                                         continue;
735                                                                                 
736                                                                                 }
737                                                                 
738                                                                                 SRNotif *sradd = new SRNotif;
739                                                                 
740                                                                                 sradd->ContactName = NameArray;
741                                                                                 sradd->ContactNickname = ContactFinalNickname;
742                                                                                 sradd->ContactAccount = SAPiter->second;
743                                                                                 sradd->ContactAccountName = SALiter->second;
744                                                                                 sradd->ContactFullFilename = vcardfilenamewxs;
745                                                                                 sradd->SearchResultID = intResultFound;
746                                                                         
747                                                                                 SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
748                                                                                 SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
749                                                                         
750                                                                                 intResultFound++;
751                                                                         
752                                                                                 wxCommandEvent sraddenv(SE_ADDRESULT);
753                                                                                 sraddenv.SetClientData(sradd);
754                                                                                 wxPostEvent(this, sraddenv);
755                                                                 
756                                                                         }
757                                                         
758                                                                 } else if (SelOpt == 13){
759                                                         
760                                                                         // Search should check if it has a logo or not.
761                                                                 
762                                                                         ArrayData = Person.GetByPartial(wxT("LOGO"));
763                                                         
764                                                                         if ((ArrayData.PropCount >= 1 &&
765                                                                         chkOpt == TRUE) || 
766                                                                         (ArrayData.PropCount == 0 &&
767                                                                         chkOpt == FALSE)){
768                                                                 
769                                                                                 if (CheckDuplicate(vcardfilenamewxs,
770                                                                                         SAPiter->second, 
771                                                                                         &SearchResultAccount,
772                                                                                         &SearchResultFilename) == TRUE){
773                                                                         
774                                                                                         SelOpt = 0;
775                                                                                         chkOpt = FALSE;
776                                                                                         StrOpt.Clear();
777                                                                                         StrOptLen = 0;
778                                                                                         ArrayData.PropData.Clear();
779                                                                                         ArrayData.PropValues.Clear();
780                                                                                         ArrayData.PropCount = 0;
781                                                                                         continue;
782                                                                                 
783                                                                                 }
784                                                                 
785                                                                                 SRNotif *sradd = new SRNotif;
786                                                                 
787                                                                                 sradd->ContactName = NameArray;
788                                                                                 sradd->ContactNickname = ContactFinalNickname;
789                                                                                 sradd->ContactAccount = SAPiter->second;
790                                                                                 sradd->ContactAccountName = SALiter->second;
791                                                                                 sradd->ContactFullFilename = vcardfilenamewxs;
792                                                                                 sradd->SearchResultID = intResultFound;
793                                                                         
794                                                                                 SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
795                                                                                 SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
796                                                                         
797                                                                                 intResultFound++;
798                                                                         
799                                                                                 wxCommandEvent sraddenv(SE_ADDRESULT);
800                                                                                 sraddenv.SetClientData(sradd);
801                                                                                 wxPostEvent(this, sraddenv);
802                                                                 
803                                                                         }
804                                                         
805                                                                 } else if (SelOpt == 14){
806                                                         
807                                                                         // Search should check if it has sound or not.
808                                                                 
809                                                                         ArrayData = Person.GetByPartial(wxT("SOUND"));
810                                                         
811                                                                         if ((ArrayData.PropCount >= 1 &&
812                                                                         chkOpt == TRUE) || 
813                                                                         (ArrayData.PropCount == 0 &&
814                                                                         chkOpt == FALSE)){
815                                                                 
816                                                                                 if (CheckDuplicate(vcardfilenamewxs,
817                                                                                         SAPiter->second, 
818                                                                                         &SearchResultAccount,
819                                                                                         &SearchResultFilename) == TRUE){
820                                                                         
821                                                                                         SelOpt = 0;
822                                                                                         chkOpt = FALSE;
823                                                                                         StrOpt.Clear();
824                                                                                         StrOptLen = 0;
825                                                                                         ArrayData.PropData.Clear();
826                                                                                         ArrayData.PropValues.Clear();
827                                                                                         ArrayData.PropCount = 0;
828                                                                                         continue;
829                                                                                 
830                                                                                 }
831                                                                 
832                                                                                 SRNotif *sradd = new SRNotif;
833                                                                 
834                                                                                 sradd->ContactName = NameArray;
835                                                                                 sradd->ContactNickname = ContactFinalNickname;
836                                                                                 sradd->ContactAccount = SAPiter->second;
837                                                                                 sradd->ContactAccountName = SALiter->second;
838                                                                                 sradd->ContactFullFilename = vcardfilenamewxs;
839                                                                                 sradd->SearchResultID = intResultFound;
840                                                                         
841                                                                                 SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount));
842                                                                                 SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename));
843                                                                         
844                                                                                 intResultFound++;
845                                                                         
846                                                                                 wxCommandEvent sraddenv(SE_ADDRESULT);
847                                                                                 sraddenv.SetClientData(sradd);
848                                                                                 wxPostEvent(this, sraddenv);
849                                                                 
850                                                                         }
851                                                         
852                                                                 }
853                                                 
854                                                         }
855                                         
856                                                         SelOpt = 0;
857                                                         chkOpt = FALSE;
858                                                         StrOpt.Clear();
859                                                         StrOptLen = 0;
860                                                         ArrayData.PropData.Clear();
861                                                         ArrayData.PropValues.Clear();
862                                                         ArrayData.PropCount = 0;
863                                                                                                 
864                                                 }
865                 
866                                         } else {
867                 
868                                         }
869                 
870                                 }
872                                 vCardFilename.Clear();
873                                 vCardFilenameFull.Clear();
874                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
875           
876                         }
877         
878                 } else {
880                 }
881                 
882         }
883         
884         // Finished searching... clear up.
885         
886         wxCommandEvent sbfinstr (SE_SBUPDATE);
887                 
888         wxString *SBFinish = new wxString;
889         
890         if (intResultFound == 0){
891         
892                 *SBFinish = _("No contacts found.");
893         
894         } else if (intResultFound == 1){
895         
896                 *SBFinish = _("1 contact found.");
897         
898         } else {
899         
900                 *SBFinish = wxString::Format(wxT("%i"), intResultFound) + _(" contacts found.");
901         
902         }
903                 
904         sbfinstr.SetClientData(SBFinish);
905         wxPostEvent(this, sbfinstr);
907         wxCommandEvent sbfinish (SE_SEARCHFINISHED);
908         wxPostEvent(this, sbfinish);
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