Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed CardDAV class and all uses/references.
[xestiaab/.git] / source / actmgr / frmActivityMgr.cpp
1 // frmActivityMgr.cpp - Activity Manager form.
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 "frmActivityMgr.h"
20 #include <wx/mstream.h>
21 #include <wx/file.h>
22 #include <wx/ffile.h>
23 #include <wx/tokenzr.h>
24 #include <wx/dir.h>
25 #include <wx/filefn.h>
26 #include <thread>
27 #include <list>
28 #include <curl/curl.h>
30 #include "../bitmaps.h"
31 #include "../enums.h"
32 #include "../common/preferences.h"
33 #include "../frmConflictResolution.h"
34 #include "../frmInvalidSSLCertificate.h"
35 #include "../frmMain.h"
36 #include "../common/events.h"
37 #include "../common/filename.h"
38 #include "../vcard/vcard34conv.h"
39 #include "../vcard/vcard.h"
41 DEFINE_EVENT_TYPE(ACTMGR_RESUMEPROC);
42 DEFINE_EVENT_TYPE(ACTMGR_TOGGLECONN);
43 DEFINE_EVENT_TYPE(ACTMGR_STARTTIMER);
44 DEFINE_EVENT_TYPE(ACTMGR_STOPTIMER);
45 DEFINE_EVENT_TYPE(ACTMGR_STARTPROCESSTIMER);
46 DEFINE_EVENT_TYPE(ACTMGR_STOPPROCESSTIMER);
47 DEFINE_EVENT_TYPE(ACTMGR_UPDATESTATUSLABEL);
48 DEFINE_EVENT_TYPE(ACTMGR_STARTANIMATIONTIMER);
50 BEGIN_EVENT_TABLE(frmActivityMgr, wxWindow)
51   EVT_COMMAND(wxID_ANY, ACTMGR_RESUMEPROC, frmActivityMgr::ResumeProcessing)
52   EVT_COMMAND(wxID_ANY, ACTMGR_TOGGLECONN, frmActivityMgr::ToggleConnectionStatus)
53   EVT_COMMAND(wxID_ANY, ACTMGR_STARTTIMER, frmActivityMgr::StartTimer)
54   EVT_COMMAND(wxID_ANY, ACTMGR_STOPTIMER, frmActivityMgr::StopTimer)
55   EVT_COMMAND(wxID_ANY, ACTMGR_STARTPROCESSTIMER, frmActivityMgr::StartProcessTimer)
56   EVT_COMMAND(wxID_ANY, ACTMGR_STOPPROCESSTIMER, frmActivityMgr::StopProcessTimer)
57   EVT_COMMAND(wxID_ANY, ACTMGR_UPDATESTATUSLABEL, frmActivityMgr::UpdateStatusLabel)
58   EVT_COMMAND(wxID_ANY, ACTMGR_STARTANIMATIONTIMER, frmActivityMgr::StartAnimationTimer)
59 END_EVENT_TABLE()
61 frmActivityMgr::frmActivityMgr( wxWindow* parent )
62 :
63 frmActivityMgrADT( parent )
64 {
66         wxMemoryInputStream istream(icons_activitywindow_png, sizeof(icons_activitywindow_png));
67         wxImage icons_activitywindow_pngi(istream, wxBITMAP_TYPE_PNG);
68         wxBitmap activityiconbmp(icons_activitywindow_pngi, -1);
69         wxIcon activityicon;
70         activityicon.CopyFromBitmap(activityiconbmp);
71         this->SetIcon(activityicon); 
73         wxMemoryInputStream istream2(misc_activitysleep_png, sizeof(misc_activitysleep_png));
74         wxImage misc_activitysleep_pngi(istream2, wxBITMAP_TYPE_PNG);
75         wxBitmap sleepiconbmp(misc_activitysleep_pngi, -1);
76         SleepBitmap = sleepiconbmp;
77         bmpActivity->SetBitmap(SleepBitmap);
78         ActProcessTimer.SetupPointers(this);
79         lblDetails->SetLabel(_("No activity."));
80         
81         ActListProcTimer.SetupPointers(&ActivityList, &ActivityListIndex, &ActivityListTaskDetail, 
82                                         &TasksActive, lstActivity, lblDetails, GauProgress, this, &AnimationTimer,
83                                         &ActProcessTimer, &ActivityListFinDate, &ActivityListConn);
84         
85         AnimationTimer.SetBitmap(bmpActivity);
86         AnimationTimer.SetSleepBitmap(&SleepBitmap);
87         AnimationTimer.SetupPointer(this->GetParent());
88         
89         wxListItem ColumnData;
90         ColumnData.SetId(0);
91         ColumnData.SetText(_("Activity"));
92         ColumnData.SetWidth(175);
93         lstActivity->InsertColumn(0, ColumnData);
94         
95         wxListItem ColumnData2;
96         ColumnData2.SetId(1);
97         ColumnData2.SetText(_("Account"));
98         ColumnData2.SetWidth(100);
99         lstActivity->InsertColumn(1, ColumnData2);
101         wxListItem ColumnData3;
102         ColumnData3.SetId(2);
103         ColumnData3.SetText(_("Status"));
104         ColumnData3.SetWidth(100);
105         lstActivity->InsertColumn(2, ColumnData3);
106         
107         //AnimationTimer.StartAnimation();
108         
109         // Create recovery database if it doesn't exist.
110         
111         wxString RecoveryFilename = GetRecoveryDB();
112         
113         wxFile RecoveryDB;
114         
115         if (wxFile::Exists(RecoveryFilename) == FALSE){
116         
117                 // Create the recovery database.
119                 RecoveryDB.Open(RecoveryFilename.c_str(), wxFile::write);       
120         
121                 RecoveryDB.Write(wxT("BEGIN:XAB-RECOVERYDB\r\n"), wxConvUTF8);
122                 RecoveryDB.Write(wxT("VERSION:1.0\r\n"), wxConvUTF8);
123                 RecoveryDB.Write(wxT("COMMENT:Please do not alter or delete this file. DATA LOSS IS POSSIBLE!\r\n"), wxConvUTF8);
124                 RecoveryDB.Write(wxT("END:XAB-RECOVERYDB\r\n"), wxConvUTF8);
125                 RecoveryDB.Close();
127         }
128         
129         wxFFile RecoveryDBF;
130         
131 #if wxABI_VERSION < 20900
132         RecoveryDBF.Open(RecoveryFilename.c_str(), wxT("r"));
133 #else
134         RecoveryDBF.Open(RecoveryFilename, wxT("r"));
135 #endif  
136         
137         // Load the recovery database for tasks not done.
138         
139         if (RecoveryDBF.IsOpened() == TRUE){
140         
141                 wxString wxSRecoveryDB;
142                 wxString RecoveryLine;
143         
144                 // Check if we are using wxWidgets version 2.8 or less and
145                 // execute the required command accordingly.
146         
147                 RecoveryDBF.ReadAll(&wxSRecoveryDB, wxConvAuto());
148         
149                 // Split the lines.
150         
151                 std::map<int, wxString> RecoveryFileLines;
152                 std::map<int, wxString>::iterator striter;
153         
154                 wxStringTokenizer wSTRecoveryDBLines(wxSRecoveryDB, wxT("\r\n"));
156                 int RecoveryLineSeek = 0;
158                 while (wSTRecoveryDBLines.HasMoreTokens() == TRUE){
160                         RecoveryLine = wSTRecoveryDBLines.GetNextToken();
161                         RecoveryFileLines.insert(std::make_pair(RecoveryLineSeek, RecoveryLine));
162                         RecoveryLineSeek++;             
163         
164                 }
165         
166         }
167         
170         //TestTimer.Start(50, FALSE);
173 void frmActivityMgr::OpenWindow()
175         WindowOpen = TRUE;
178 void frmActivityMgr::CloseWindow( wxCommandEvent& event )
180         WindowOpen = FALSE;
181         this->Hide();
184 void frmActivityMgr::CloseWindow( wxCloseEvent& event )
186         WindowOpen = FALSE;
187         this->Hide();
190 void frmActivityMgr::ProcessTasksThread()
192         
193         if (ProcessTasksData == FALSE){
194         
195                 return;
196         
197         }
198         
199         if (ApplicationSleepMode == TRUE){
200                 
201                 return;
202                 
203         }
204         
205         std::map<int,int>::iterator TypeIter;
206         std::map<int,wxString>::iterator StringIter;
207         std::map<int,wxString>::iterator StringDataIter;
208         std::map<int,wxString>::iterator StringURLIter;
209         std::map<int,wxString>::iterator StringDetailIter;
210         std::map<int,wxString>::iterator StringAccountIter;
211         std::map<int,wxString>::iterator StringFilenameIter;
212         std::map<int,wxString>::iterator StringFullFilenameIter;
213         std::map<int,wxString>::iterator StringTaskDetailIter;
214         std::map<int,wxString>::iterator StringETagIter;
215         std::map<int,wxString>::iterator StringETagOrigIter;
216         std::map<int,ConnectionObject*>::iterator ConnObjectIter;
217         std::map<int,ActivityMgrAccountSettings>::iterator AccountSettingsIter;
218         std::map<int,long>::iterator LongIter;
219         bool TasksFoundProc = FALSE;
220         wxString TaskDetail;
221         
222         for (std::map<int,int>::iterator iter = ActivityList.begin(); 
223          iter != ActivityList.end(); ++iter){
224          
225                 // Check for any queued tasks and start one.
226                 
227                 if (iter->second > 4){
228                         continue;
229                 }
230                 
231                 wxCommandEvent StartAnimationEvent(ACTMGR_STARTANIMATIONTIMER);
232                 
233                 wxPostEvent(this, StartAnimationEvent);
234                 
235                 // Start the animation timer if it hasn't started.
236                 
237                 ConnObjectIter = ActivityListConnObject.find(iter->first);
238                 TypeIter = ActivityListType.find(iter->first);
239                 StringETagIter = ActivityListETag.find(iter->first);
240                 StringETagOrigIter = ActivityListETagOriginal.find(iter->first);
241                 StringAccountIter = ActivityListAccount.find(iter->first);
242                 StringFilenameIter = ActivityListFilename.find(iter->first);
243                 StringFullFilenameIter = ActivityListFullFilename.find(iter->first);
244                 AccountSettingsIter = ActivityListAccSettings.find(iter->first);
245                 
246                 // Setup the CardDAV object.
247                 
248                 // 0 = Queued.
249                 // 1 = Processing.
250                 // 2 = Failed.
251                 // 3 = Stopped.
252                 // 4 = Completed.
253                 // 5 = Failed (UI Updated).
254                 // 6 = Stopped (UI Updated).
255                 // 7 = (Reserved) (UI Updated).
256                 // 8 = Completed. (UI Updated). 
257                 
258                 frmMain *frmMainPtrGet = static_cast<frmMain*>(frmMainPtr);
259                 XABPreferences PrefData(GetUserPrefDir());
260                 
261                 if (iter->second == 0){
262                         
263                         // Wait for process to finish.
265                         TasksActive = TRUE;
266                         TasksFoundProc = TRUE;
267                         wxString ETag;
268                         wxString ETagOriginal;
269                         wxString ETagServer;
270                         wxString AccountDir;
271                         wxString ContactFilename;
272                         wxString FullFilename;
273                         wxString ETagResult;
274                         bool EditMode = FALSE;
276                         iter->second = 1;
277                         
278                         // Compare the ETags and work out if a conflict has occured.
279                         
280                         if (TypeIter->second == 0){
281                         
282                                 // Add a contact.
283                                 
284                                 StringDataIter = ActivityListData.find(iter->first);
285                                 StringURLIter = ActivityListURL.find(iter->first);
286                                 
287                                 AccountDir = StringAccountIter->second;
288                                 ContactFilename = StringFilenameIter->second;
289                                 wxString AccountNameFriendly;
290                                 
291                                 int AccountID = 0;
292                                 
293                                 for (int i = 0; i < PrefData.accounts.GetCount(); i++){
294                                         
295                                         wxString AccountDirCheck = PrefData.accounts.GetAccountDirectory(i);
296                                         
297                                         AccountDirCheck.Trim();
298                                         AccountDirCheck.Append(wxT(".carddav"));
299                                         
300                                         if (AccountDirCheck == StringAccountIter->second){
301                                                 
302                                                 AccountNameFriendly = PrefData.accounts.GetAccountName(i);
303                                                 AccountID = i;
304                                                 
305                                         }
306                                         
307                                 }
308                                 
309                                 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
310                                 
311                                 ETag = StringETagIter->second;
312                                 ETagOriginal = StringETagOrigIter->second;
313                                 AccountDir = StringAccountIter->second;
314                                 ContactFilename = StringFilenameIter->second;
315                                 FullFilename = StringFullFilenameIter->second;
316                                 EditMode = ActivityListEditMode.find(iter->first)->second;
317                                 
318                                 bool KeepUpdating = true;
319                                 
320                                 while(KeepUpdating == true){
321                                         
322                                         COConnectResult ConnectResponse = ConnObjectIter->second->Connect(false);
323                                         
324                                         bool ExitLoop = false;
325                                         
326                                         while (ExitLoop == false){
327                                                 
328                                                 if (ConnObjectIter->second->SSLVerify() == COSSL_UNABLETOVERIFY){
329                                                         
330                                                         frmMainPtrGet->PauseAllTimers();
331                                                         
332 #if defined(__APPLE__)
333 #elif defined(__WIN32__)
334 #else
335         
336                                                         bool UsingSSLBypass = false;
337                                                         int SSLResult = 0;
338                                                         
339                                                         // Connect again and fetch SSL certificate information.
340                 
341                                                         ConnObjectIter->second->BypassSSLVerification(true);
342                 
343                                                         COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
345                                                         ConnObjectIter->second->BypassSSLVerification(false);
347                                                         SSLInvalidCertNotifObjString SSLICNProcData;
348                                                         
349                                                         SSLCertCollectionString certcol = ConnObjectIter->second->BuildSSLCollection();
350                                                                 
351                                                         bool *PauseMode = new bool;
352                                                         QRNotif qrn;
353                                                                 
354                                                         *PauseMode = TRUE;
355                                                         qrn.QResponse = &SSLResult;
356                                                         qrn.PausePtr = PauseMode;
357                                                                 
358                                                         SSLICNProcData.CertCollection = certcol;
359                                                         SSLICNProcData.QRNotifData = &qrn;
360                                                         SSLICNProcData.AccountName = AccountNameFriendly;
361                                                                 
362                                                         wxCommandEvent event(INVALIDSSLCERTSTRING);
363                                                         event.SetClientData(&SSLICNProcData);
364                                                         wxPostEvent(frmMainPtrGet, event);
365                                                                 
366                                                         while (*PauseMode == TRUE){
367                                                                 //nanosleep(&n1, &n2);
368                                                                 SleepFor(250000000);
369                                                         }
370                                                         
371                                                         // Process the response from the user.
372                                                         
373                                                         if (SSLResult == 1){
374                                                                 
375                                                                 // Accept the Certificate.
377                                                                 UsingSSLBypass = true;
378                                                                 ConnObjectIter->second->BypassSSLVerification(true);
379                 
380                                                                 COConnectResult TestConnectionResult = ConnObjectIter->second->Connect(true);
381                                                                 WriteServerCertificate(AccountDir, certcol);
382                                                                 
383                                                                 ConnObjectIter->second->BypassSSLVerification(false);
384                                                                 
385                                                         } else if (SSLResult == 2){
386                                                 
387                                                                 // Reject the certificate, abort the task and mark as failed.
389                                                                 iter->second = 2;
390                                                                 break;
391                                                                 
392                                                         }
393                 
394 #endif
395                                                         
396                                                         frmMainPtrGet->ResumeAllTimers();
397                                                         ExitLoop = true;
398                                                         
399                                                 } else if (ConnectResponse == COCONNECT_AUTHFAIL){
400                                                         
401                                                         ConnectResponse = ConnObjectIter->second->Connect(true);
402                                                         
403                                                         if (ConnectResponse == COCONNECT_OK){
404                                                                 
405                                                                 ExitLoop = true;
406                                                                 break;
407                                                                 
408                                                         } else {
409                                                                 
410                                                                 ExitLoop = true;                                                        
411                                                                 iter->second = 2;
412                                                                 break;
413                                                                 
414                                                         }
415                                                         
416                                                 } else if (ConnectResponse == COCONNECT_OK){
417                                                         
418                                                         ConnectResponse = ConnObjectIter->second->Connect(true);
419                                                         
420                                                         ExitLoop = true;
421                                                         break;
422                                                         
423                                                 } else {
424                                                         
425                                                         ExitLoop = true;                                                        
426                                                         iter->second = 2;
427                                                         break;
428                                                         
429                                                 }
430                                                 
431                                         }
432                                         
433                                         if (iter->second == 2 || iter->second == 3 || iter->second == 4){
434                                                 break;
435                                         }
436                                         
437 #if defined(__APPLE__)
438                                         
439                                         frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
441 #elif defined(__WIN32__)
443                                         frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
445 #else
446                                         
447                                         frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
448                                         
449 #endif
450                                         
451                                         COServerResponse AddContactResponse = ConnObjectIter->second->AddContact(StringURLIter->second.ToStdString(), 
452                                                         StringDataIter->second.ToStdString());
453                                         
454                                         if (AddContactResponse.RequestResult != COREQUEST_OK){
455                                                 iter->second = 2;
456                                                 break;
457                                         }
458                                         
459                                         // Get the entity tag for the new contact.
460                                         
461                                         COServerResponse ETagGetResponse = ConnObjectIter->second->GetServerEntityTagValue(StringURLIter->second.ToStdString());
462                                         
463                                         if (ETagGetResponse.RequestResult != COREQUEST_OK){
464                                                 iter->second = 2;
465                                                 break;
466                                         }
467                                         
468                                         std::cout << ETagGetResponse.EntityTag << std::endl;
469                                         
470                                         ETagDBPtr->UpdateETag(ContactFilename, ETagGetResponse.EntityTag, ETagGetResponse.EntityTag);
471                                         
472                                         iter->second = 4;
473                                         break;
474                                         
475                                 }
476                                 
477                         } else if (TypeIter->second == 1){
478                                 
479                                 // Update a contact.
480                                 
481                                 StringDataIter = ActivityListData.find(iter->first);
482                                 StringURLIter = ActivityListURL.find(iter->first);
483                                 
484                                 AccountDir = StringAccountIter->second;
485                                 ContactFilename = StringFilenameIter->second;
486                                 wxString AccountNameFriendly;
487                                 
488                                 int AccountID = 0;
489                                 
490                                 for (int i = 0; i < PrefData.accounts.GetCount(); i++){
491                                         
492                                         wxString AccountDirCheck = PrefData.accounts.GetAccountDirectory(i);
493                                         
494                                         AccountDirCheck.Trim();
495                                         AccountDirCheck.Append(wxT(".carddav"));
496                                         
497                                         if (AccountDirCheck == StringAccountIter->second){
498                                                 
499                                                 AccountNameFriendly = PrefData.accounts.GetAccountName(i);
500                                                 AccountID = i;
501                                                 
502                                         }
503                                         
504                                 }
505                                 
506                                 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
507                                 
508                                 ETag = StringETagIter->second;
509                                 ETagOriginal = StringETagOrigIter->second;
510                                 AccountDir = StringAccountIter->second;
511                                 ContactFilename = StringFilenameIter->second;
512                                 FullFilename = StringFullFilenameIter->second;
513                                 EditMode = ActivityListEditMode.find(iter->first)->second;
514                                 
515                                 bool KeepUpdating = true;
516                                 
517                                 while(KeepUpdating == true){
518                                         
519                                         COConnectResult ConnectResponse = ConnObjectIter->second->Connect(false);
520                                         
521                                         bool ExitLoop = false;
522                                         
523                                         while(ExitLoop == false){
524                                                 
525                                                 if (ConnObjectIter->second->SSLVerify() == COSSL_UNABLETOVERIFY){
526                                                         
527                                                         frmMainPtrGet->PauseAllTimers();
528                                                         
529 #if defined(__APPLE__)
530 #elif defined(__WIN32__)
531 #else
532         
533                                                         bool UsingSSLBypass = false;
534                                                         int SSLResult = 0;
535                                                         
536                                                         // Connect again and fetch SSL certificate information.
537                 
538                                                         ConnObjectIter->second->BypassSSLVerification(true);
539                 
540                                                         COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
542                                                         ConnObjectIter->second->BypassSSLVerification(false);
544                                                         SSLInvalidCertNotifObjString SSLICNProcData;
545                                                         
546                                                         SSLCertCollectionString certcol = ConnObjectIter->second->BuildSSLCollection();
547                                                                 
548                                                         bool *PauseMode = new bool;
549                                                         QRNotif qrn;
550                                                                 
551                                                         *PauseMode = TRUE;
552                                                         qrn.QResponse = &SSLResult;
553                                                         qrn.PausePtr = PauseMode;
554                                                                 
555                                                         SSLICNProcData.CertCollection = certcol;
556                                                         SSLICNProcData.QRNotifData = &qrn;
557                                                         SSLICNProcData.AccountName = AccountNameFriendly;
558                                                                 
559                                                         wxCommandEvent event(INVALIDSSLCERTSTRING);
560                                                         event.SetClientData(&SSLICNProcData);
561                                                         wxPostEvent(frmMainPtrGet, event);
562                                                                 
563                                                         while (*PauseMode == TRUE){
564                                                                 SleepFor(250000000);
565                                                         }
566                                                         
567                                                         // Process the response from the user.
568                                                         
569                                                         if (SSLResult == 1){
570                                                                 
571                                                                 // Accept the Certificate.
573                                                                 UsingSSLBypass = true;
574                                                                 ConnObjectIter->second->BypassSSLVerification(true);
575                 
576                                                                 COConnectResult TestConnectionResult = ConnObjectIter->second->Connect(true);
577                                                                 WriteServerCertificate(AccountDir, certcol);
578                                                                 
579                                                                 ConnObjectIter->second->BypassSSLVerification(false);
580                                                                 
581                                                         } else if (SSLResult == 2){
582                                                 
583                                                                 // Reject the certificate, abort the task and mark as failed.
585                                                                 iter->second = 2;
586                                                                 break;
587                                                                 
588                                                         }
589                 
590 #endif
591                                                         
592                                                         frmMainPtrGet->ResumeAllTimers();
593                                                         ExitLoop = true;
594                                                         
595                                                 } else if (ConnectResponse == COCONNECT_AUTHFAIL){
596                                                         
597                                                         ConnectResponse = ConnObjectIter->second->Connect(true);
598                                                         
599                                                         if (ConnectResponse == COCONNECT_OK){
600                                                                 
601                                                                 ExitLoop = true;
602                                                                 break;
603                                                                 
604                                                         } else {
605                                                                 
606                                                                 ExitLoop = true;                                                        
607                                                                 iter->second = 2;
608                                                                 break;
609                                                                 
610                                                         }
611                                                         
612                                                 } else if (ConnectResponse == COCONNECT_OK){
613                                                         
614                                                         ConnectResponse = ConnObjectIter->second->Connect(true);
615                                                         
616                                                         ExitLoop = true;
617                                                         break;
618                                                         
619                                                 } else {
620                                                         
621                                                         ExitLoop = true;                                                        
622                                                         iter->second = 2;
623                                                         break;
624                                                         
625                                                 }
626                                                 
627                                         }
628                                         
629                                         if (iter->second == 2 || iter->second == 3 || iter->second == 4){
630                                                 break;
631                                         }
632                                         
633                                         COServerResponse ETagGetResponse = ConnObjectIter->second->GetServerEntityTagValue(StringURLIter->second.ToStdString());
634                                         
635                                         if (ETagGetResponse.RequestResult != COREQUEST_OK){
636                                                 iter->second = 2;
637                                                 break;
638                                         }
639                                         
640                                         ETagServer = ETagGetResponse.EntityTag;
641                                         
642                                         // Compare the ETag with the Server ETag.
643                                         
644                                         if (ETagOriginal != ETagServer){
645                                                 
646                                                 // Server ETag is different from original ETag.
647                                                 // This is a conflict which the user will now
648                                                 // need to resolve.
649                                                 
650                                                 frmMain *frmMainPtrGet = static_cast<frmMain*>(frmMainPtr);
651                                                 
652                                                 vCard34Conv vCard34Obj;
653                                                 
654                                                 std::string ServerContactData;
655                                                 wxString wxStringServerContactData;
656                                                 vCard ClientData;
657                                                 vCard ConvertedV4Data;
658                                                 
659                                                 // Load the client data from the filename given.
660                                                 
661                                                 COServerResponse GetContactResponse = ConnObjectIter->second->GetContact(StringURLIter->second.ToStdString(),
662                                                         &ServerContactData);
663                                                 
664                                                 if (GetContactResponse.RequestResult != COREQUEST_OK){
665                                                         iter->second = 2;
666                                                         break;
667                                                 }
668                                                 
669                                                 wxStringServerContactData = wxString::FromUTF8((const char*)ServerContactData.c_str());
670                                                 
671                                                 // Process v3 version into v4 version.
672                                                 
673                                                 vCard34Obj.ConvertToV4(&wxStringServerContactData, &ConvertedV4Data);
674                                                 
675                                                 vCardConflictObj vCardProcData;
676                                                 
677                                                 vCardProcData.vCardLocalData = &ClientData;
678                                                 vCardProcData.vCardServerData = &ConvertedV4Data;
679                                                 ClientData.LoadFile(FullFilename);
680                                                 
681                                                 // Setup Conflict Resolution Dialog.
682                                                 
683                                                 // Fetch Data from Server and convert.
684                                                 
685                                                 bool *PauseMode = new bool;
686                                                 int ConflictResult;
687                                                 QRNotif qrn;
688                                                 
689                                                 *PauseMode = TRUE;
690                                                 qrn.QResponse = &ConflictResult;
691                                                 qrn.PausePtr = PauseMode;
692                                                 
693                                                 vCardProcData.QRNotifData = &qrn;
694                                                 
695                                                 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
696                                                 event.SetClientData(&vCardProcData);
697                                                 wxPostEvent(frmMainPtrGet, event);
698                                                 
699                                                 while (*PauseMode == TRUE){
700                                                         SleepFor(250000000);
701                                                 }
702                                                 
703                                                 delete PauseMode;
704                                                 PauseMode = NULL;
705                                                 
706                                                 if (ConflictResult == 0){
707                                                         
708                                                         // Decide Later.
709                                                         
710                                                         iter->second = 4;
711                                                         break;
712                                                         
713                                                 } else if (ConflictResult == 1){
714                                                         
715                                                         // Decided to use client version.
716                                                         
717                                                 } else if (ConflictResult == 2){
718                                                         
719                                                         // Decided to use server version.
720                                                         
721                                                         // Download server version.
722                                                         
723                                                         ConvertedV4Data.WriteFile(FullFilename);
724                                                         
725                                                 }
726                                                 
727                                         } else {
728                                                 
729                                                 // Upload the data to the server.
730                                                 
731                                                 COServerResponse EditContactResponse = ConnObjectIter->second->EditContact(StringURLIter->second.ToStdString(), 
732                                                         StringDataIter->second.ToStdString());
733                                         
734                                                 if (EditContactResponse.RequestResult != COREQUEST_OK){
735                                                         iter->second = 2;
736                                                         break;
737                                                 }
738                                                 
739                                         }
740                                         
741                                         ETagGetResponse = ConnObjectIter->second->GetServerEntityTagValue(StringURLIter->second.ToStdString());
742                                         
743                                         if (ETagGetResponse.RequestResult != COREQUEST_OK){
744                                                 iter->second = 2;
745                                                 break;
746                                         }
747                                         
748                                         ETagDBPtr->UpdateETag(ContactFilename, ETagGetResponse.EntityTag, ETagGetResponse.EntityTag);
749                                         
750                                         iter->second = 4;
751                                         break;
752                                         
753                                 }
754                         
755                         } else if (TypeIter->second == 2) {
756                         
757                                 // Delete the contact from the server and update the ETag DB.
758                                 
759                                 AccountDir = StringAccountIter->second;
760                                 ContactFilename = StringFilenameIter->second;
761                                 wxString AccountNameFriendly;
762                                 
763                                 int AccountID = 0;
764                                 
765                                 for (int i = 0; i < PrefData.accounts.GetCount(); i++){
766                                         
767                                         wxString AccountDirCheck = PrefData.accounts.GetAccountDirectory(i);
768                                         
769                                         AccountDirCheck.Trim();
770                                         AccountDirCheck.Append(wxT(".carddav"));
771                                         
772                                         if (AccountDirCheck == StringAccountIter->second){
773                                                 
774                                                 AccountNameFriendly = PrefData.accounts.GetAccountName(i);
775                                                 AccountID = i;
776                                                 
777                                         }
778                                         
779                                 }
780                                 
781                                 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
782                                 
783                                 bool KeepUpdating = TRUE;
784                                 
785                                 while(KeepUpdating == TRUE){
786                                 
787                                         COConnectResult ConnectResponse = ConnObjectIter->second->Connect(false);
788                                         
789                                         bool ExitLoop = FALSE;
790                                         
791                                         while (ExitLoop == FALSE){
792                                                 
793                                                 if (ConnObjectIter->second->SSLVerify() == COSSL_UNABLETOVERIFY){
794                                                         
795                                                         frmMainPtrGet->PauseAllTimers();
796                                                         
797 #if defined(__APPLE__)
798 #elif defined(__WIN32__)
799 #else
800         
801                                                         bool UsingSSLBypass = false;
802                                                         int SSLResult = 0;
803                                                         
804                                                         // Connect again and fetch SSL certificate information.
805                 
806                                                         ConnObjectIter->second->BypassSSLVerification(true);
807                 
808                                                         COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
810                                                         ConnObjectIter->second->BypassSSLVerification(false);
812                                                         SSLInvalidCertNotifObjString SSLICNProcData;
813                                                         
814                                                         SSLCertCollectionString certcol = ConnObjectIter->second->BuildSSLCollection();
815                                                                 
816                                                         bool *PauseMode = new bool;
817                                                         QRNotif qrn;
818                                                                 
819                                                         *PauseMode = TRUE;
820                                                         qrn.QResponse = &SSLResult;
821                                                         qrn.PausePtr = PauseMode;
822                                                                 
823                                                         SSLICNProcData.CertCollection = certcol;
824                                                         SSLICNProcData.QRNotifData = &qrn;
825                                                         SSLICNProcData.AccountName = AccountNameFriendly;
826                                                                 
827                                                         wxCommandEvent event(INVALIDSSLCERTSTRING);
828                                                         event.SetClientData(&SSLICNProcData);
829                                                         wxPostEvent(frmMainPtrGet, event);
830                                                                 
831                                                         while (*PauseMode == TRUE){
832                                                                 //nanosleep(&n1, &n2);
833                                                                 SleepFor(250000000);
834                                                         }
835                                                         
836                                                         // Process the response from the user.
837                                                         
838                                                         if (SSLResult == 1){
839                                                                 
840                                                                 // Accept the Certificate.
842                                                                 UsingSSLBypass = true;
843                                                                 ConnObjectIter->second->BypassSSLVerification(true);
844                 
845                                                                 COConnectResult TestConnectionResult = ConnObjectIter->second->Connect(true);
846                                                                 WriteServerCertificate(AccountDir, certcol);
847                                                                 
848                                                                 ConnObjectIter->second->BypassSSLVerification(false);
849                                                                 
850                                                         } else if (SSLResult == 2){
851                                                 
852                                                                 // Reject the certificate, abort the task and mark as failed.
854                                                                 iter->second = 2;
855                                                                 break;
856                                                                 
857                                                         }
858                 
859 #endif
860                                                         
861                                                         frmMainPtrGet->ResumeAllTimers();
862                                                         ExitLoop = true;
863                                                         
864                                                 } else if (ConnectResponse == COCONNECT_AUTHFAIL){
865                                                         
866                                                         ConnectResponse = ConnObjectIter->second->Connect(true);
867                                                         
868                                                         if (ConnectResponse == COCONNECT_OK){
869                                                                 
870                                                                 ExitLoop = true;
871                                                                 break;
872                                                                 
873                                                         } else {
874                                                                 
875                                                                 ExitLoop = true;                                                        
876                                                                 iter->second = 2;
877                                                                 break;
878                                                                 
879                                                         }
880                                                         
881                                                 } else if (ConnectResponse == COCONNECT_OK){
882                                                         
883                                                         ConnectResponse = ConnObjectIter->second->Connect(true);
884                                                         
885                                                         ExitLoop = true;
886                                                         break;
887                                                         
888                                                 } else {
889                                                         
890                                                         ExitLoop = true;                                                        
891                                                         iter->second = 2;
892                                                         break;
893                                                         
894                                                 }
895                                         
896                                         }
897                                 
898                                         if (iter->second == 2 || iter->second == 3 || iter->second == 4){
899                                                 break;
900                                         }
901                         
902 #if defined(__APPLE__)
903                                 
904                                         frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
906 #elif defined(__WIN32__)
908                                         frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
910 #else
911                                 
912                                         frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
913                                 
914 #endif
915                                         
916                                         COServerResponse DeleteContactResponse = ConnObjectIter->second->DeleteContact(ContactFilename.ToStdString());
917                                         
918                                         if (DeleteContactResponse.RequestResult != COREQUEST_OK){
919                                                 iter->second = 2;
920                                                 break;
921                                         }
922                                 
923                                         ETagDBPtr->RemoveETag(ContactFilename);
924                                 
925                                         iter->second = 4;
926                                         break;
927                                 
928                                 }
929                         
930                         } else if (TypeIter->second == 3) {
932                                 wxString AccountNameFriendly;
933         
934                                 int AccountID = 0;
936                                 for (int i = 0; i < PrefData.accounts.GetCount(); i++){
937         
938                                         wxString AccountDirCheck = PrefData.accounts.GetAccountDirectory(i);
939                 
940                                         AccountDirCheck.Trim();
941                                         AccountDirCheck.Append(wxT(".carddav"));
942         
943                                         if (AccountDirCheck == StringAccountIter->second){
944                                         
945                                                 AccountNameFriendly = PrefData.accounts.GetAccountName(i);
946                                                 AccountID = i;
947                 
948                                         }
949         
950                                 }
951                         
952                                 bool KeepUpdating = TRUE;
954                                 while (KeepUpdating == TRUE){
956                                         StringTaskDetailIter = ActivityListTaskDetail.find(iter->first);
957                         
958                                         AccountDir = StringAccountIter->second;
960                                         ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
961                                 
962                                         wxArrayString vCardAdd;
963                                         wxArrayString vCardDelete;
964                                         wxArrayString vCardList;
965                                         wxArrayString vCardUpdateLocal;
966                                         wxArrayString vCardUpdateRemote;
967                                         wxArrayString vCardUpdateLog;
968                                         std::map<wxString,wxString> vCardETag;
969                                         ContactListData ServerContactList;
970                                 
971                                         std::map<wxString,vCardDownloadDataFileClass> vCardDownloadData;
972                                 
973                                         // Get the list of vCard files locally.
974         
975                                         wxString AccountDirFinal;
976                                         wxString AccountSyncTokenFilename;
977                                         wxString SyncTokenLoad;
978         
979 #if defined(__HAIKU__)
980     
981                                             //preffilename = wxT("noo");
983 #elif defined(__WIN32__)
985                                         AccountDirFinal = GetAccountDir(AccountDir, FALSE);
986                                         AccountSyncTokenFilename = AccountDirFinal;
987                                         AccountSyncTokenFilename.Append(wxT("synctoken"));
989 #else
991                                         AccountDirFinal = GetAccountDir(AccountDir, FALSE);
992                                         AccountSyncTokenFilename = AccountDirFinal;
993                                         AccountSyncTokenFilename.Append(wxT("synctoken"));
994         
995 #endif
997                                         // Suppress Error Messages.
998                                 
999                                         wxLogNull PleaseDoNotDisturb;
1001                                         wxFFile SyncLoad;
1002                                         SyncLoad.Open(AccountSyncTokenFilename, wxT("r"));
1003                                 
1004                                         if (SyncLoad.IsOpened()){
1005                                 
1006                                                 SyncLoad.ReadAll(&SyncTokenLoad, wxMBConvUTF8());
1007                                                 SyncLoad.Close();
1008                                 
1009                                         }
1011                                         // Get a list of vCard files from the server.
1013                                         // Get the list of vCard files from the ETagDB.
1014                                 
1015                                         std::map<wxString,ETagData> ETagDBData = ETagDBPtr->GetETagData();
1016                                         
1017                                         COConnectResult ConnectResponse = ConnObjectIter->second->Connect(false);
1018                                         
1019                                         bool ExitLoop = FALSE;
1021                                         std::map<wxString,FileSyncData> *SCListData = NULL;
1022                                         
1023                                         while (ExitLoop == FALSE){                                              
1024                                                 
1025                                                 if (ConnObjectIter->second->SSLVerify() == COSSL_UNABLETOVERIFY){
1026                                                         
1027                                                         frmMainPtrGet->PauseAllTimers();
1028                                                         
1029 #if defined(__APPLE__)
1030 #elif defined(__WIN32__)
1031 #else
1032         
1033                                                         bool UsingSSLBypass = false;
1034                                                         int SSLResult = 0;
1035                                                         
1036                                                         // Connect again and fetch SSL certificate information.
1037                 
1038                                                         ConnObjectIter->second->BypassSSLVerification(true);
1039                 
1040                                                         COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
1042                                                         ConnObjectIter->second->BypassSSLVerification(false);
1044                                                         SSLInvalidCertNotifObjString SSLICNProcData;
1045                                                         
1046                                                         SSLCertCollectionString certcol = ConnObjectIter->second->BuildSSLCollection();
1047                                                                 
1048                                                         bool *PauseMode = new bool;
1049                                                         QRNotif qrn;
1050                                                                 
1051                                                         *PauseMode = TRUE;
1052                                                         qrn.QResponse = &SSLResult;
1053                                                         qrn.PausePtr = PauseMode;
1054                                                                 
1055                                                         SSLICNProcData.CertCollection = certcol;
1056                                                         SSLICNProcData.QRNotifData = &qrn;
1057                                                         SSLICNProcData.AccountName = AccountNameFriendly;
1058                                                                 
1059                                                         wxCommandEvent event(INVALIDSSLCERTSTRING);
1060                                                         event.SetClientData(&SSLICNProcData);
1061                                                         wxPostEvent(frmMainPtrGet, event);
1062                                                                 
1063                                                         while (*PauseMode == TRUE){
1064                                                                 //nanosleep(&n1, &n2);
1065                                                                 SleepFor(250000000);
1066                                                         }
1067                                                         
1068                                                         // Process the response from the user.
1069                                                         
1070                                                         if (SSLResult == 1){
1071                                                                 
1072                                                                 // Accept the Certificate.
1074                                                                 UsingSSLBypass = true;
1075                                                                 ConnObjectIter->second->BypassSSLVerification(true);
1076                 
1077                                                                 COConnectResult TestConnectionResult = ConnObjectIter->second->Connect(true);
1078                                                                 WriteServerCertificate(AccountDir, certcol);
1079                                                                 
1080                                                                 ConnObjectIter->second->BypassSSLVerification(false);
1081                                                                 
1082                                                         } else if (SSLResult == 2){
1083                                                 
1084                                                                 // Reject the certificate, abort the task and mark as failed.
1086                                                                 iter->second = 2;
1087                                                                 break;
1088                                                                 
1089                                                         }
1090                 
1091 #endif
1092                                                         
1093                                                         frmMainPtrGet->ResumeAllTimers();
1094                                                         ExitLoop = true;
1095                                                         
1096                                                 } else if (ConnectResponse == COCONNECT_AUTHFAIL){
1097                                                         
1098                                                         ConnectResponse = ConnObjectIter->second->Connect(true);
1099                                                         
1100                                                         if (ConnectResponse == COCONNECT_OK){
1101                                                                 
1102                                                                 ExitLoop = true;
1103                                                                 break;
1104                                                                 
1105                                                         } else {
1106                                                                 
1107                                                                 ExitLoop = true;                                                        
1108                                                                 iter->second = 2;
1109                                                                 break;
1110                                                                 
1111                                                         }
1112                                                         
1113                                                 } else if (ConnectResponse == COCONNECT_OK){
1114                                                         
1115                                                         ConnectResponse = ConnObjectIter->second->Connect(true);
1116                                                         
1117                                                         ExitLoop = true;
1118                                                         break;
1119                                                         
1120                                                 } else {
1121                                                         
1122                                                         ExitLoop = true;                                                        
1123                                                         iter->second = 2;
1124                                                         break;
1125                                                         
1126                                                 }
1127                                         
1128                                         }
1129                                 
1130 #if defined(__APPLE__)
1131                                         
1132                                         frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
1134 #elif defined(__WIN32__)
1136                                         frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
1138 #else
1139                                         
1140                                         frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
1141                         
1142 #endif
1143                                         
1144                                         if (iter->second == 2 || iter->second == 3 || iter->second == 4){
1145                                                 break;
1146                                         }
1147                                         
1148                                         // Look in directory and see which vCards to add and delete
1149                                 
1150                                         // In short:
1151                                         // vCard exists but not in ETagDB - Add (and upload).
1152                                         // vCard missing but in ETagDB - Delete (from server).
1153                                 
1154                                         // Start by looking for vCards that are not in the ETagDB.
1155                                 
1156                                         wxDir AccDir(AccountDirFinal);
1157                                         wxString AccDirFilename;
1158                                 
1159                                         bool ContinueProcess = AccDir.GetFirst(&AccDirFilename, wxEmptyString, wxDIR_DEFAULT);
1160                                 
1161                                         COContactList ServerContactList2 = ConnObjectIter->second->GetContactList(SyncTokenLoad.ToStdString());
1163                                         // Process the server data.
1165                                         for (std::vector<COContactData>::iterator ContactInfo = ServerContactList2.ListData.begin();
1166                                                 ContactInfo != ServerContactList2.ListData.end(); ContactInfo++){
1167                                                 
1168                                                 if (ContactInfo->Status == COCS_UPDATED){
1169                                                         
1170                                                         vCardDownloadDataFileClass vCardNewData;
1171                                                         vCardNewData.DataType = 0;
1172                                                         vCardDownloadData.insert(std::make_pair(ContactInfo->Location, vCardNewData));
1173                                                         
1174                                                 } else if (ContactInfo->Status == COCS_DELETED){
1175                                                         
1176                                                         vCardDelete.Add(ContactInfo->Location, 1);
1177                                                         
1178                                                 }
1179                                                         
1180                                         }
1181                                 
1182                                         // Look for vCards that are missing but in the ETagDB.
1183         
1184                                         for (std::map<wxString,ETagData>::iterator etagiter = ETagDBData.begin();
1185                                                 etagiter != ETagDBData.end(); etagiter++){
1186                                 
1187                                                 // Check if the vCard exists.
1188                                         
1189                                                 if (!wxFileExists(AccountDirFinal + etagiter->first)){
1190                                         
1191                                                         // vCard doesn't exist so mark for deleting.
1192                                         
1193                                                         vCardDelete.Add(etagiter->first, 1);
1194                                         
1195                                                 }
1196                                 
1197                                         }
1199                                         // Compare Server with the ETag DB. Work out which
1200                                         // needs to updated remotely and which needs to be
1201                                         // updated locally.
1203                                         for (std::vector<COContactData>::iterator ContactInfo = ServerContactList2.ListData.begin();
1204                                                 ContactInfo != ServerContactList2.ListData.end(); ContactInfo++){
1205                                                 
1206                                                 if (ETagDBData.find(ContactInfo->Location) == ETagDBData.end()){
1207                                                         continue;
1208                                                 }
1210                                                 std::map<wxString,ETagData>::iterator lociter = ETagDBData.find(ContactInfo->Location);
1211                                                 
1212                                                 ETagData etd = lociter->second;
1213                                                 
1214                                                 wxString ETagSrv = ContactInfo->Data;
1216                                                 // Check if the local ETag value has 'DELETED' set and skip
1217                                                 // checking this file if it does.
1218                                         
1219                                                 if (etd.ETagValue == "DELETED"){
1220                                                         
1221                                                         continue;
1222                                                         
1223                                                 }
1224                                                 
1225                                                 // Compare local ETag with original local ETag.
1226                                                 // If different, update to server is required.
1227                                 
1228                                                 if (etd.ETagValue != etd.ETagOrigValue){
1229                                 
1230                                                         // Check if local original ETag is different from server ETag.
1231                                                         // If it is then throw up a conflict resolution dialog.
1232                                 
1233                                                         if (etd.ETagOrigValue != ETagSrv){
1234                                         
1235                                                                 vCard34Conv vCard34Obj;
1236                                                 
1237                                                                 wxString FullFilename;
1238                                                                 vCard ClientData;
1239                                                                 vCard ConvertedV4Data;
1240                                         
1241                                                                 std::string ServerContactDataString;
1242                                                                 wxString ServerContactData;
1243                                                                 
1244                                                                 // Conflict. Bring up conflict resolution dialog.
1245                                                         
1246                                                                 // Get the server contact data for comparison.
1247                                                         
1248                                                                 ConnObjectIter->second->GetContact(ContactInfo->Location, &ServerContactDataString);
1249                                                                 ServerContactData = wxString::FromUTF8(ServerContactDataString.c_str());
1250                                                         
1251                                                                 FullFilename = CreateFilenamePath(AccountDirFinal, ContactInfo->Location);
1252                                                         
1253                                                                 // Convert it to v4.
1254                                         
1255                                                                 vCard34Obj.ConvertToV4(&ServerContactData, &ConvertedV4Data);
1256                                         
1257                                                                 vCardConflictObj vCardProcData;
1258                                         
1259                                                                 vCardProcData.vCardLocalData = &ClientData;
1260                                                                 vCardProcData.vCardServerData = &ConvertedV4Data;
1261                                                         
1262                                                                 // Load the client data from the filename given.
1263                                                         
1264                                                                 ClientData.LoadFile(FullFilename);
1265                                                         
1266                                                                 // Show dialog.
1267                                         
1268                                                                 bool *PauseMode = new bool;
1269                                                                 int ConflictResult;
1270                                                                 QRNotif qrn;
1271                                                                 frmMain *frmMainPtrGet = static_cast<frmMain*>(frmMainPtr);
1273                                                                 *PauseMode = TRUE;
1274                                                                 qrn.QResponse = &ConflictResult;
1275                                                                 qrn.PausePtr = PauseMode;
1276                                                 
1277                                                                 vCardProcData.QRNotifData = &qrn;
1278                                         
1279                                                                 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
1280                                                                 event.SetClientData(&vCardProcData);
1281                                                                 wxPostEvent(frmMainPtrGet, event);
1282                                                 
1283                                                                 while (*PauseMode == TRUE){
1284                                                                         //nanosleep(&n1, &n2);
1285                                                                         SleepFor(250000000);
1286                                                                 }
1287                                         
1288                                                                 delete PauseMode;
1289                                                                 PauseMode = NULL;
1290                                                         
1291                                                                 // If replacing local version, store copy for now.
1292                                                                 // Otherwise upload to server.
1293                                         
1294                                                                 if (ConflictResult == 0){
1295                                         
1296                                                                         // Decide Later.
1297                                         
1298                                                                         continue;
1299                                         
1300                                                                 } else if (ConflictResult == 1){
1301                                         
1302                                                                         // Decided to use client version.
1303                                         
1304                                                                         vCardUpdateLocal.Remove(ContactInfo->Location);
1305                                                                         vCardUpdateRemote.Add(ContactInfo->Location, 1);                                                                
1306                                         
1307                                                                 } else if (ConflictResult == 2){
1308                                         
1309                                                                         // Decided to use server version.
1310                                                                         // Store the converted downloaded copy for
1311                                                                         // processing later.
1313                                                                         //vCardUpdateLocal.Add(srviter->first, 1);
1314                                                                 
1315                                                                         vCardDownloadDataFileClass vCardNewData;
1316                                                                         vCardNewData.DataType = 1;
1317                                                                         vCardNewData.FileData = ConvertedV4Data.WriteString();
1319                                                                         ConvertedV4Data.WriteFile(FullFilename);
1320                                                                 
1321                                                                         vCardDownloadData.insert(std::make_pair(ContactInfo->Location, vCardNewData));  
1322                                                                 
1323                                                                 
1324                                                                 
1325                                                                 }
1326                                         
1327                                                         } else {
1328                                         
1329                                                                 // Send vCard to the server.
1330                                                 
1331                                                                 vCardUpdateRemote.Add(ContactInfo->Location, 1);
1332                                         
1333                                                         }
1334                                 
1335                                                 } else {
1336                                 
1337                                                         // Check if local ETag is different from server ETag.
1338                                                         // If different, obtain the vCard from the server.
1339                                         
1340                                                         if (etd.ETagOrigValue != ETagSrv){
1341                                         
1342                                                                 vCardUpdateLocal.Add(ContactInfo->Location, 1);
1343                                         
1344                                                         }
1345                                 
1346                                                 }
1347                                                 
1348                                         }
1349                                 
1350                                         // Process the vCards that need to be downloaded and added/overwritten.
1351                                 
1352                                         wxString vCardFilenameFinal;
1353                                         wxString vCardOutputData;
1354                                         wxString vCardInputData;
1355                                         wxString ETagFileData;
1356                                         wxFFile vCardFile;
1357                                 
1358                                         for (std::map<wxString,vCardDownloadDataFileClass>::iterator additer = vCardDownloadData.begin();
1359                                                 additer != vCardDownloadData.end(); additer++){
1360                                         
1361                                                 vCardFilenameFinal.Clear();
1362                                                 vCardInputData.Clear();
1363                                                 vCardOutputData.Clear();
1364                                                 ETagFileData.Clear();
1365                                         
1366                                                 vCardFilenameFinal = CreateFilenamePath(AccountDirFinal, additer->first);
1367                                         
1368                                                 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
1369                                         
1370                                                 if (additer->second.DataType == 0){
1371                                         
1372                                                         vCard ConvertedV4Data;
1373                                         
1374                                                         // Grab the file from the server and write the contact out.
1375                                         
1376                                                         vCard34Conv vCard34Obj;
1377                                                         
1378                                                         wxString ServerContactData;
1379                                                         std::string ServerContactDataString;
1380                                                                 
1381                                                         // Conflict. Bring up conflict resolution dialog.
1382                                                         
1383                                                         // Get the server contact data for comparison.
1384                                                         
1385                                                         ConnObjectIter->second->GetContact(additer->first.ToStdString(), &ServerContactDataString);
1386                                                         vCardInputData = wxString::FromUTF8(ServerContactDataString.c_str());
1387                                                 
1388                                                         vCard34Obj.ConvertToV4(&vCardInputData, &ConvertedV4Data);
1389                                                 
1390                                                         ConvertedV4Data.WriteFile(vCardFilenameFinal);
1391                                                 
1392                                                         // Get the server ETag.
1393                                                 
1394                                                         wxString ServerETag;
1395                                                         
1396                                                         COServerResponse ServerEntityTag = ConnObjectIter->second->GetServerEntityTagValue(additer->first.ToStdString());
1397                                                         
1398                                                         ServerETag = wxString::FromUTF8(ServerEntityTag.EntityTag.c_str());
1400                                                         // Add to the ETag Database.
1401                                                 
1402                                                         ETagDBPtr->AddETag(additer->first, ServerETag, ServerETag);
1403                                                 
1404                                                 } else if (additer->second.DataType == 1){
1405                                         
1406                                                         // Write out the contact to the account directory.
1407                                         
1408                                                         vCardFilenameFinal = CreateFilenamePath(AccountDirFinal, additer->first);
1409                                                         vCardOutputData = additer->second.FileData;
1410                                                 
1411                                                         vCardFile.Open(vCardFilenameFinal, wxT("w"));
1412                                 
1413                                                         if (vCardFile.IsOpened()){
1414                                 
1415                                                                 vCardFile.Write(vCardOutputData, wxConvAuto());
1416                                                                 vCardFile.Close();
1417                                 
1418                                                         }
1419                                                 
1420                                                         // Update the ETagDB.
1422                                                         wxString ServerETag;
1423                                                         
1424                                                         COServerResponse ServerEntityTag = ConnObjectIter->second->GetServerEntityTagValue(additer->first.ToStdString());
1425                                                         
1426                                                         ServerETag = wxString::FromUTF8(ServerEntityTag.EntityTag.c_str());
1427                                                 
1428                                                         // Add to the ETag Database.
1429                                                 
1430                                                         ETagDBPtr->AddETag(additer->first, ServerETag, ServerETag);
1431                                                                                         
1432                                                 }
1433                                         }
1434         
1435                                         // Look for vCard files which aren't in the ETagDB.
1436         
1437                                         while(ContinueProcess){
1438                                 
1439                                                 // Check and make sure that the filename ends in .vcf/.vcard
1440                                                 // Skip any file that beings with a dot.
1441                                         
1442                                                 if (AccDirFilename.Left(1) == wxT(".")){
1443                                         
1444                                                         ContinueProcess = AccDir.GetNext(&AccDirFilename);
1445                                                         continue;
1446                                         
1447                                                 }
1448                                         
1449                                                 if (AccDirFilename.Right(4) != wxT(".vcf") && 
1450                                                 AccDirFilename.Right(6) != wxT(".vcard")){
1451                                         
1452                                                         ContinueProcess = AccDir.GetNext(&AccDirFilename);
1453                                                         continue;
1454                                         
1455                                                 }
1456                                 
1457                                                 // Look in the ETagDB for the file.
1458                                         
1459                                                 bool ETagExists = ETagDBPtr->CheckETagExists(AccDirFilename);
1460                                         
1461                                                 if (ETagExists == FALSE){
1462                                         
1463                                                         // Add the vCard to the list to be added.
1464                                                 
1465                                                         vCardAdd.Add(AccDirFilename, 1);
1466                                         
1467                                                 }
1468                                         
1469                                                 ContinueProcess = AccDir.GetNext(&AccDirFilename);
1470                                 
1471                                         }
1472                                 
1473                                         // Process the vCards to add/update to the server.
1474                                 
1475                                         for (int vi = 0; vi < vCardAdd.GetCount(); vi++){
1477                                                 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
1478                                                 ETag = ETagDBPtr->GetETag(vCardAdd[vi]);
1479                                                 ETagOriginal = ETagDBPtr->GetETagOriginal(vCardAdd[vi]);
1480                                                 
1481                                                 ContactFilename = vCardAdd[vi];
1482                                                 FullFilename = CreateFilenamePath(AccountDirFinal, vCardAdd[vi]);
1484                                                 ContactFilename.Trim();
1485                         
1486                                                 if (ETag == ETagOriginal && ETagDBPtr->ETagExists(vCardAdd[vi])){
1487                         
1488                                                         // Compare the ETag with the Server ETag.
1489                                                         
1490                                                         COServerResponse ServerEntityTag = ConnObjectIter->second->GetServerEntityTagValue(vCardAdd[vi].ToStdString());
1491                                                         
1492                                                         ETagServer = wxString::FromUTF8(ServerEntityTag.EntityTag.c_str());
1493                                 
1494                                                         if (ETagOriginal != ETagServer){
1495                                 
1496                                                                 // Server ETag is different from original ETag.
1497                                                                 // This is a conflict which the user will now
1498                                                                 // need to resolve.
1499                                         
1500                                                                 frmMain *frmMainPtrGet = static_cast<frmMain*>(frmMainPtr);
1501                                         
1502                                                                 vCard34Conv vCard34Obj;
1503                                                 
1504                                                                 wxString ServerContactData;
1505                                                                 std::string ServerContactDataString;
1506                                                                 vCard ClientData;
1507                                                                 vCard ConvertedV4Data;
1508                                         
1509                                                                 // Load the client data from the filename given.
1510                                                                 
1511                                                                 COServerResponse GetContactResponse = ConnObjectIter->second->GetContact(vCardAdd[vi].ToStdString(), &ServerContactDataString);
1512                                                 
1513                                                                 ServerContactData = wxString::FromUTF8(ServerContactDataString.c_str());
1514                                                 
1515                                                                 // Process v3 version into v4 version.
1516                                                 
1517                                                                 vCard34Obj.ConvertToV4(&ServerContactData, &ConvertedV4Data);
1518                                         
1519                                                                 vCardConflictObj vCardProcData;
1520                                         
1521                                                                 vCardProcData.vCardLocalData = &ClientData;
1522                                                                 vCardProcData.vCardServerData = &ConvertedV4Data;
1523                                                                 ClientData.LoadFile(FullFilename);
1525                                                                 // Setup Conflict Resolution Dialog.
1526                                         
1527                                                                 // Fetch Data from Server and convert.
1528                                         
1529                                                                 bool *PauseMode = new bool;
1530                                                                 int ConflictResult;
1531                                                                 QRNotif qrn;
1533                                                                 *PauseMode = TRUE;                                              
1534                                                                 qrn.QResponse = &ConflictResult;
1535                                                                 qrn.PausePtr = PauseMode;
1536                                                 
1537                                                                 vCardProcData.QRNotifData = &qrn;
1538                                         
1539                                                                 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
1540                                                                 event.SetClientData(&vCardProcData);
1541                                                                 wxPostEvent(frmMainPtrGet, event);
1542                                                 
1543                                                                 while (*PauseMode == TRUE){
1544                                                                         //nanosleep(&n1, &n2);
1545                                                                         SleepFor(250000000);
1546                                                                 }
1547                                         
1548                                                                 delete PauseMode;
1549                                                                 PauseMode = NULL;
1550                                         
1551                                                                 if (ConflictResult == 0){
1552                                         
1553                                                                         // Decide Later.
1554                                         
1555                                                                         iter->second = 4;
1556                                                                         continue;
1557                                         
1558                                                                 } else if (ConflictResult == 1){
1559                                         
1560                                                                         // Decided to use client version.
1561                                         
1562                                                                         COServerResponse EditContactResponse = ConnObjectIter->second->EditContact(vCardAdd[vi].ToStdString(), ClientData.WriteString().ToStdString());
1563                                                 
1564                                                                         iter->second = 4;
1565                                         
1566                                                                 } else if (ConflictResult == 2){
1567                                         
1568                                                                         // Decided to use server version.
1569                                                 
1570                                                                         // Download server version.
1571                                                                 
1572                                                                         ConvertedV4Data.WriteFile(CreateFilenamePath(AccountDirFinal, vCardAdd[vi]));
1573                                                 
1574                                                                         iter->second = 4;
1575                                         
1576                                                                 }
1577                                 
1578                                                         } else {
1579                                 
1580                                                                 // Setup the filename for the contact being added.
1581                                                         
1582                                                                 wxString wxSFilename = CreateFilenamePath(AccountDirFinal, vCardAdd[vi]);
1583                                                                 wxString wxSCardData;
1584                                                                 wxString TaskData;
1585                                                         
1586                                                                 // Load the data from the file.
1587                                                         
1588                                                                 wxFFile wxFCard;
1589                                                                 wxFCard.Open(wxSFilename, wxT("r"));
1590                                 
1591                                                                 if (wxFCard.IsOpened()){
1592                                 
1593                                                                         wxFCard.ReadAll(&wxSCardData, wxConvAuto());
1594                                                                         wxFCard.Close();
1595                                 
1596                                                                 }
1597                                                         
1598                                                                 // Convert the data to v3.
1599                                                         
1600                                                                 vCard34Conv vCard34Obj;
1601                                                         
1602                                                                 vCard34Obj.ConvertToV3(wxSFilename, &TaskData);
1604                                                                 // Upload the data to the server.
1605                                                                 
1606                                                                 COServerResponse AddContactResponse = ConnObjectIter->second->AddContact(vCardAdd[vi].ToStdString(), TaskData.ToStdString());
1607                                                         
1608                                                                 // Get the Server ETag and put it in the ETag database.
1610                                                                 COServerResponse EntityTagResponse = ConnObjectIter->second->GetServerEntityTagValue(vCardAdd[vi].ToStdString());
1611                                                                 
1612                                                                 ETagServer = wxString::FromUTF8(EntityTagResponse.EntityTag.c_str());
1613                                 
1614                                                                 ETagDBPtr->AddETag(vCardAdd[vi], ETagServer, ETagServer);
1615                                 
1616                                                         }
1617                         
1618                                                 } else {
1619                         
1620                                                         if (ETagOriginal != ETagServer){
1621                                 
1622                                                                 // Server ETag is different from original ETag.
1623                                                                 // This is a conflict which the user will now
1624                                                                 // need to resolve.
1625                                         
1626                                                                 frmMain *frmMainPtrGet = (frmMain *)frmMainPtr;
1627                                         
1628                                                                 vCard34Conv vCard34Obj;
1629                                                 
1630                                                                 std::string ServerContactDataString;
1631                                                                 wxString ServerContactData;
1632                                                                 vCard ClientData;
1633                                                                 vCard ConvertedV4Data;
1634                                         
1635                                                                 // Load the client data from the filename given.
1636                                         
1637                                                                 COServerResponse GetContactResponse = ConnObjectIter->second->GetContact(vCardAdd[vi].ToStdString(), &ServerContactDataString);
1638                                                 
1639                                                                 ServerContactData = wxString::FromUTF8(ServerContactDataString.c_str());
1640                                                                 
1641                                                                 ClientData.LoadFile(FullFilename);
1642                                                 
1643                                                                 // Process v3 version into v4 version.
1644                                                 
1645                                                                 vCard34Obj.ConvertToV4(&ServerContactData, &ConvertedV4Data);
1646                                         
1647                                                                 vCardConflictObj vCardProcData;
1648                                         
1649                                                                 vCardProcData.vCardLocalData = &ClientData;
1650                                                                 vCardProcData.vCardServerData = &ConvertedV4Data;
1651                                         
1652                                                                 bool *PauseMode = new bool;
1653                                                                 int ConflictResult;
1654                                                                 QRNotif qrn;
1656                                                                 *PauseMode = TRUE;                                              
1657                                                                 qrn.QResponse = &ConflictResult;
1658                                                                 qrn.PausePtr = PauseMode;
1659                                                 
1660                                                                 vCardProcData.QRNotifData = &qrn;
1661                                         
1662                                                                 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
1663                                                                 event.SetClientData(&vCardProcData);
1664                                                                 wxPostEvent(frmMainPtrGet, event);
1666                                                                 while (*PauseMode == TRUE){
1667                                                                         SleepFor(250000000);
1668                                                                 }
1669                                         
1670                                                                 delete PauseMode;
1671                                                                 PauseMode = NULL;
1672                                         
1673                                                                 if (ConflictResult == 0){
1674                                         
1675                                                                         // Decide Later.
1676                                         
1677                                                                         iter->second = 4;
1678                                                                         continue;
1679                                         
1680                                                                 } else if (ConflictResult == 1){
1681                                         
1682                                                                         // Decided to use client version.
1683                                                                 
1684                                                                         COServerResponse EditContactResponse = ConnObjectIter->second->EditContact(vCardAdd[vi].ToStdString(), ClientData.WriteString().ToStdString());
1685                                                 
1686                                                                         iter->second = 4;
1687                                         
1688                                                                 } else if (ConflictResult == 2){
1689                                         
1690                                                                         // Decided to use server version.
1691                                                 
1692                                                                         // Write server version to file.
1693                                                                 
1694                                                                         ConvertedV4Data.WriteFile(CreateFilenamePath(AccountDirFinal, vCardAdd[vi]));
1695                                                 
1696                                                                         iter->second = 4;
1697                                         
1698                                                                 }
1699                                 
1700                                                         } else {
1701                                 
1702                                                                 // Setup the filename for the contact being added.
1703                                                         
1704                                                                 wxString wxSFilename = CreateFilenamePath(AccountDirFinal, vCardAdd[vi]);
1705                                                                 wxString wxSCardData;
1706                                                                 wxString TaskData;
1707                                                         
1708                                                                 // Load the data from the file.
1709                                                         
1710                                                                 wxFFile wxFCard;
1711                                                                 wxFCard.Open(wxSFilename, wxT("r"));
1712                                 
1713                                                                 if (wxFCard.IsOpened()){
1714                                 
1715                                                                         wxFCard.ReadAll(&wxSCardData, wxConvAuto());
1716                                                                         wxFCard.Close();
1717                                 
1718                                                                 }
1719                                                         
1720                                                                 // Convert the data to v3.
1721                                                         
1722                                                                 vCard34Conv vCard34Obj;
1723                                                         
1724                                                                 vCard34Obj.ConvertToV3(wxSFilename, &TaskData);
1726                                                                 // Upload the data to the server.
1727                                                                 
1728                                                                 COServerResponse AddContactResponse = ConnObjectIter->second->AddContact(vCardAdd[vi].ToStdString(), TaskData.ToStdString());
1729                                                         
1730                                                                 // Get the Server ETag and put it in the ETag database.
1731                                                         
1732                                                                 COServerResponse EntityTagResponse = ConnObjectIter->second->GetServerEntityTagValue(vCardAdd[vi].ToStdString());
1733                                 
1734                                                                 ETagDBPtr->AddETag(vCardAdd[vi], ETagServer, ETagServer);
1735                                 
1736                                                         }
1737                                         
1738                                                 }
1740                                         }                       
1741                                 
1742                                         // Process the vCards to delete locally.
1743                                 
1744                                         for (int vi = 0; vi < vCardDelete.GetCount(); vi++){
1746                                                 if (!wxRemoveFile(CreateFilenamePath(AccountDirFinal, vCardDelete[vi]))){
1748                                                 } else {
1749                                         
1750                                                         ETagDBPtr->RemoveETag(vCardDelete[vi]);
1751                                         
1752                                                 }
1754                                         }
1755                                 
1756                                         // Process the vCards to delete from the server.
1757                                 
1758                                         std::map<wxString,wxString> *ETagFilenameMap = ETagDBPtr->GetFilenamePointer();
1759                                         std::list<wxString> DeleteList;
1760                                 
1761                                         for (std::map<wxString,wxString>::iterator deliter = ETagFilenameMap->begin();
1762                                                 deliter != ETagFilenameMap->end(); deliter++){
1763                                 
1764                                                 // Look through the ETagDB and find contacts which are marked as DELETED.
1765                                         
1766                                                 if (deliter->second == wxT("DELETED")){
1768                                                         ConnObjectIter->second->DeleteContact(deliter->first.ToStdString());
1769                                         
1770                                                         // Delete the ETag as the file has now been deleted.
1771                                         
1772                                                         DeleteList.push_back(deliter->first);
1773                                         
1774                                                 }
1775                                 
1776                                         }
1777                                         
1778                                         for (std::list<wxString>::iterator removeetagiter = DeleteList.begin();
1779                                                 removeetagiter != DeleteList.end(); removeetagiter++){
1780                                         
1781                                                 ETagDBPtr->RemoveETag(*removeetagiter);
1782                                                 
1783                                         }
1784                                 
1785                                         // Write out the update server sync token.
1787                                         wxString ServerSyncToken = wxString::FromUTF8(ServerContactList2.SyncToken.c_str());
1788                                 
1789                                         ServerSyncToken.Trim();
1790                                 
1791                                         if (!ServerSyncToken.IsEmpty()){
1792                                 
1793                                                 wxFFile SyncWrite;
1794                                                 SyncWrite.Open(AccountSyncTokenFilename, wxT("w"));
1795                                 
1796                                                 if (SyncWrite.IsOpened()){
1797                                 
1798                                                         SyncWrite.Write(ServerSyncToken, wxConvAuto());
1799                                                         SyncWrite.Close();
1800                                 
1801                                                 }
1802                                 
1803                                         }
1804                                 
1805                                         // Check for another sync token. If there is another 
1806                                         // sync token then repeat this. If token matches then stop processing.
1807                                 
1808                                         if (SyncTokenLoad == ServerSyncToken){
1809                                         
1810                                                 KeepUpdating = FALSE;
1811                                         
1812                                         }
1813                                         
1814                                 }
1815                                 
1816                                 // Mark as completed.
1817                         
1818                                 wxString AccountNameFinal;
1819                                 AccountNameFinal = PrefData.accounts.GetAccountDirectory(AccountID);
1820                                 AccountNameFinal.Append(wxT(".carddav"));
1821                                 
1822                                 wxCommandEvent reloadevent(RELOADCONTACTLIST);
1823                                 reloadevent.SetString(AccountNameFinal);
1824                                 wxPostEvent(this->GetParent(), reloadevent);
1825                                 
1826                                 iter->second = 4;
1827                                 continue;
1828                         
1829                         } else {
1830                         
1831                                 // Update the data to the server.
1833                                 iter->second = 4;
1834                                 continue;
1835                         
1836                         }
1838                         while (iter->second == 1){
1840                                 SleepFor(125000000);
1841         
1842                         }
1843                         
1844                         break;
1845                         
1846                 }
1848         }
1849         
1850         if (TasksFoundProc == FALSE){
1851         
1852                 TasksActive = FALSE;
1853                 ProcessTasksData = FALSE;
1854         
1855         } else {
1857                 wxCommandEvent eventp(ACTMGR_STARTTIMER);
1858                 wxPostEvent(this, eventp);
1859         
1860         }
1861         
1862         wxCommandEvent event(ACTMGR_STARTPROCESSTIMER);
1863         wxPostEvent(this, event);
1867 void frmActivityMgr::ProcessTasks()
1869         
1870         std::thread ProcessThread(&frmActivityMgr::ProcessTasksThread, this);
1871         ProcessThread.detach();
1875 void frmActivityMgr::SetupPointers(wxETagProcessTimer *ETagTmrPtrInc, void *frmMainPtrInc)
1878         ETagTmrPtr = ETagTmrPtrInc;
1879         
1880         frmMainPtr = frmMainPtrInc;
1884 void frmActivityMgr::ResumeProcessing(wxCommandEvent &event){
1886         QRNotif *qrn = (QRNotif *)event.GetClientData(); 
1887         
1888         int *QRes = qrn->QResponse;
1890         *qrn->PausePtr = FALSE;
1892         *QRes = event.GetInt();
1893         
1896 void frmActivityMgr::ToggleConnectionStatus( wxCommandEvent &event ){
1898         wxCommandEvent connevent(CONNSTAT_UPDATE);
1899         
1900         if (ApplicationSleepMode == FALSE){
1901         
1902                 connevent.SetInt(1);
1903                 ApplicationSleepMode = TRUE;
1904                 mnuSleepMode->Check(true);
1905         
1906         } else {
1907         
1908                 connevent.SetInt(0);
1909                 ApplicationSleepMode = FALSE;
1910                 mnuSleepMode->Check(false);
1911                 
1912                 wxCommandEvent event(ACTMGR_STARTTIMER);
1913                 wxPostEvent(this, event);
1915                 wxCommandEvent eventp(ACTMGR_STARTPROCESSTIMER);
1916                 wxPostEvent(this, eventp);
1917         
1918         }
1920         wxPostEvent(GetParent(), connevent);
1924 void frmActivityMgr::SleepMode( wxCommandEvent &event ){
1925         
1926         wxCommandEvent connevent(ACTMGR_TOGGLECONN);
1927         
1928         wxPostEvent(this, connevent);
1929         
1932 void frmActivityMgr::WriteServerCertificate(wxString AccountName, SSLCertCollection SSLCertInc){
1934         wxString ServerCertFinal;
1936         // Get the Cert section of the certificate and write it to the file.
1938         ServerCertFinal = GetAccountDir(AccountName, TRUE);
1940         wxFile CertFile;
1941         
1942         std::map<int, SSLCertData>::iterator SSLCDIter = SSLCertInc.SSLCollection.find(0);
1943         std::multimap<wxString,wxString>::iterator SSLDataIter = SSLCDIter->second.CertData.find(wxT("Cert"));
1944         
1945         CertFile.Open(ServerCertFinal, wxFile::write);  
1946         
1947         CertFile.Write(SSLDataIter->second, wxConvUTF8);
1948         CertFile.Close();
1952 void frmActivityMgr::WriteServerCertificate(wxString AccountName, SSLCertCollectionString SSLCertInc){
1954         wxString ServerCertFinal;
1956         // Get the Cert section of the certificate and write it to the file.
1958         ServerCertFinal = GetAccountDir(AccountName, TRUE);
1960         wxFile CertFile;
1961         
1962         std::map<int, SSLCertDataString>::iterator SSLCDIter = SSLCertInc.SSLCollection.find(0);
1963         std::multimap<string,string>::iterator SSLDataIter = SSLCDIter->second.CertData.find("Cert");
1964         
1965         CertFile.Open(ServerCertFinal, wxFile::write);  
1966         
1967         CertFile.Write(SSLDataIter->second, wxConvUTF8);
1968         CertFile.Close();
1972 void frmActivityMgr::StartTimer(wxCommandEvent& event){
1974         ActListProcTimer.Start(1000, FALSE);
1978 void frmActivityMgr::StopTimer(wxCommandEvent& event){
1980         ActListProcTimer.Stop();
1984 void frmActivityMgr::StartProcessTimer(wxCommandEvent& event){
1986         ActProcessTimer.Start(1000, FALSE);
1990 void frmActivityMgr::StopProcessTimer(wxCommandEvent& event){
1992         ActProcessTimer.Stop();
1996 void frmActivityMgr::StartAnimationTimer(wxCommandEvent& event){
1997         
1998         AnimationTimer.StartAnimation();
1999         
2002 void frmActivityMgr::UpdateStatusLabel(wxCommandEvent& event){
2004         ActivityMgrLabelUpdate *actmgrudata = (ActivityMgrLabelUpdate*)event.GetClientData();
2005         
2006         if (actmgrudata != NULL){
2007         
2008                 lstActivity->SetItem(actmgrudata->ItemIndex, 2, actmgrudata->ItemLabel);
2009         
2010                 delete actmgrudata;
2011                 actmgrudata = NULL;
2012         
2013         }
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