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