1 #include "frmActivityMgr.h"
2 #include <wx/mstream.h>
5 #include <wx/tokenzr.h>
13 #include "common/preferences.h"
14 #include "frmConflictResolution.h"
15 #include "frmInvalidSSLCertificate.h"
17 #include "common/events.h"
18 #include "common/filename.h"
19 #include "common/dirs.h"
20 #include "vcard/vcard34conv.h"
21 #include "vcard/vcard.h"
24 #ifndef FRMACTIVITYMGR_H
25 #define FRMACTIVITYMGR_H
27 DEFINE_EVENT_TYPE(ACTMGR_RESUMEPROC);
28 DEFINE_EVENT_TYPE(ACTMGR_TOGGLECONN);
29 DEFINE_EVENT_TYPE(ACTMGR_STARTTIMER);
30 DEFINE_EVENT_TYPE(ACTMGR_STOPTIMER);
31 DEFINE_EVENT_TYPE(ACTMGR_STARTPROCESSTIMER);
32 DEFINE_EVENT_TYPE(ACTMGR_STOPPROCESSTIMER);
34 BEGIN_EVENT_TABLE(frmActivityMgr, wxWindow)
35 EVT_COMMAND(wxID_ANY, ACTMGR_RESUMEPROC, frmActivityMgr::ResumeProcessing)
36 EVT_COMMAND(wxID_ANY, ACTMGR_TOGGLECONN, frmActivityMgr::ToggleConnectionStatus)
37 EVT_COMMAND(wxID_ANY, ACTMGR_STARTTIMER, frmActivityMgr::StartTimer)
38 EVT_COMMAND(wxID_ANY, ACTMGR_STOPTIMER, frmActivityMgr::StopTimer)
39 EVT_COMMAND(wxID_ANY, ACTMGR_STARTPROCESSTIMER, frmActivityMgr::StartProcessTimer)
40 EVT_COMMAND(wxID_ANY, ACTMGR_STOPPROCESSTIMER, frmActivityMgr::StopProcessTimer)
43 frmActivityMgr::frmActivityMgr( wxWindow* parent )
45 frmActivityMgrADT( parent )
48 wxMemoryInputStream istream(icons_activitywindow_png, sizeof(icons_activitywindow_png));
49 wxImage icons_activitywindow_pngi(istream, wxBITMAP_TYPE_PNG);
50 wxBitmap activityiconbmp(icons_activitywindow_pngi, -1);
52 activityicon.CopyFromBitmap(activityiconbmp);
53 this->SetIcon(activityicon);
55 wxMemoryInputStream istream2(misc_activitysleep_png, sizeof(misc_activitysleep_png));
56 wxImage misc_activitysleep_pngi(istream2, wxBITMAP_TYPE_PNG);
57 wxBitmap sleepiconbmp(misc_activitysleep_pngi, -1);
58 SleepBitmap = sleepiconbmp;
59 bmpActivity->SetBitmap(SleepBitmap);
60 ActProcessTimer.SetupPointers(this);
61 lblDetails->SetLabel(_("No activity."));
63 ActListProcTimer.SetupPointers(&ActivityList, &ActivityListIndex, &ActivityListTaskDetail,
64 &TasksActive, lstActivity, lblDetails, GauProgress, this, &AnimationTimer,
65 &ActProcessTimer, &ActivityListFinDate);
67 AnimationTimer.SetBitmap(bmpActivity);
68 AnimationTimer.SetSleepBitmap(&SleepBitmap);
69 AnimationTimer.SetupPointer(this->GetParent());
71 wxListItem ColumnData;
73 ColumnData.SetText(_("Activity"));
74 ColumnData.SetWidth(175);
75 lstActivity->InsertColumn(0, ColumnData);
77 wxListItem ColumnData2;
79 ColumnData2.SetText(_("Account"));
80 ColumnData2.SetWidth(100);
81 lstActivity->InsertColumn(1, ColumnData2);
83 wxListItem ColumnData3;
85 ColumnData3.SetText(_("Status"));
86 ColumnData3.SetWidth(100);
87 lstActivity->InsertColumn(2, ColumnData3);
89 //AnimationTimer.StartAnimation();
91 // Create recovery database if it doesn't exist.
93 wxString RecoveryFilename = GetRecoveryDB();
97 if (wxFile::Exists(RecoveryFilename) == FALSE){
99 // Create the recovery database.
101 RecoveryDB.Open(RecoveryFilename.c_str(), wxFile::write);
103 RecoveryDB.Write(wxT("BEGIN:XAB-RECOVERYDB\r\n"), wxConvUTF8);
104 RecoveryDB.Write(wxT("VERSION:1.0\r\n"), wxConvUTF8);
105 RecoveryDB.Write(wxT("COMMENT:Please do not alter or delete this file. DATA LOSS IS POSSIBLE!\r\n"), wxConvUTF8);
106 RecoveryDB.Write(wxT("END:XAB-RECOVERYDB\r\n"), wxConvUTF8);
113 #if wxABI_VERSION < 20900
114 RecoveryDBF.Open(RecoveryFilename.c_str(), wxT("r"));
116 RecoveryDBF.Open(RecoveryFilename, wxT("r"));
119 // Load the recovery database for tasks not done.
121 if (RecoveryDBF.IsOpened() == TRUE){
123 wxString wxSRecoveryDB;
124 wxString RecoveryLine;
126 // Check if we are using wxWidgets version 2.8 or less and
127 // execute the required command accordingly.
129 RecoveryDBF.ReadAll(&wxSRecoveryDB, wxConvAuto());
133 std::map<int, wxString> RecoveryFileLines;
134 std::map<int, wxString>::iterator striter;
136 wxStringTokenizer wSTRecoveryDBLines(wxSRecoveryDB, wxT("\r\n"));
138 int RecoveryLineSeek = 0;
140 while (wSTRecoveryDBLines.HasMoreTokens() == TRUE){
142 RecoveryLine = wSTRecoveryDBLines.GetNextToken();
143 RecoveryFileLines.insert(std::make_pair(RecoveryLineSeek, RecoveryLine));
152 //TestTimer.Start(50, FALSE);
155 int frmActivityMgr::AddTask(int TaskType, wxString TaskDetail, wxString TaskAccount,
156 wxString TaskURL, wxString TaskFilename, wxString TaskFullFilename,
165 coldata.SetId(ActivityTaskID);
166 coldata.SetData(ActivityTaskID);
168 AnimationTimer.StartAnimation();
170 // Get the preferences file.
172 wxString PrefFilename = GetUserPrefDir();
174 XABPreferences PrefData(PrefFilename);
176 wxString AccountName;
178 wxString AccountAddress;
180 wxString AccountUsername;
181 wxString AccountPassword;
182 bool AccountSSL = FALSE;
183 wxString AccountPrefix;
185 // Look for the account and get the friendly name for the account.
187 for (int i = 0; i < PrefData.accounts.GetCount(); i++){
189 AccountDir = PrefData.accounts.GetAccountDirectory(i);
192 AccountDir.Append(wxT(".carddav"));
194 if (AccountDir == TaskAccount){
196 AccountName = PrefData.accounts.GetAccountName(i);
197 AccountAddress = PrefData.accounts.GetAccountAddress(i);
198 AccountPort = PrefData.accounts.GetAccountPort(i);
199 AccountUsername = PrefData.accounts.GetAccountUsername(i);
200 AccountPassword = PrefData.accounts.GetAccountPassword(i);
201 AccountPrefix = PrefData.accounts.GetAccountDirPrefix(i);
202 AccountSSL = PrefData.accounts.GetAccountSSL(i);
205 AccountAddress.Trim();
206 //AccountPort.Trim();
207 AccountUsername.Trim();
208 AccountPassword.Trim();
209 AccountPrefix.Trim();
216 CardDAVConn.SetupConnection(AccountAddress, AccountPort, AccountUsername, AccountPassword, AccountSSL, AccountPrefix, AccountDir);
217 CardDAVConn.SetupVariables(&ActivityList, ActivityTaskID);
218 CardDAVConn.SetupResultBools(&BlankBool, &BlankBool);
221 // 0 - Add a contact.
222 // 1 - Update a contact.
223 // 2 - Delete a contact.
224 // 3 - Account syncronisation.
228 coldata.SetText(_("Adding Contact '") + TaskDetail + _("'"));
229 itemindex = lstActivity->InsertItem(coldata);
231 lstActivity->SetItem(itemindex, 1, AccountName);
232 lstActivity->SetItem(itemindex, 2, _("Queued"));
234 CardDAVConn.SetUploadMode(TRUE);
235 CardDAVConn.SetupData(wxT("PUT"), TaskURL, TaskData);
237 // Setup all of the task details.
239 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
241 ActivityListType.insert(std::make_pair(ActivityTaskID, 0));
242 ActivityListData.insert(std::make_pair(ActivityTaskID, TaskData));
243 ActivityListConn.insert(std::make_pair(ActivityTaskID, CardDAVConn));
244 ActivityListIndex.insert(std::make_pair(ActivityTaskID, itemindex));
245 ActivityListTaskDetail.insert(std::make_pair(ActivityTaskID, TaskDetail));
246 ActivityListAccount.insert(std::make_pair(ActivityTaskID, TaskAccount));
247 ActivityListFilename.insert(std::make_pair(ActivityTaskID, TaskFilename));
248 ActivityListFullFilename.insert(std::make_pair(ActivityTaskID, TaskFullFilename));
250 ActivityListETag.insert(std::make_pair(ActivityTaskID, ETagDBPtr->GetETag(TaskFilename)));
251 ActivityListETagOriginal.insert(std::make_pair(ActivityTaskID, ETagDBPtr->GetETagOriginal(TaskFilename)));
252 ActivityList.insert(std::make_pair(ActivityTaskID, 0));
254 } else if (TaskType == 1){
256 coldata.SetText(_("Updating Contact '") + TaskDetail + _("'"));
257 itemindex = lstActivity->InsertItem(coldata);
259 lstActivity->SetItem(itemindex, 1, AccountName);
260 lstActivity->SetItem(itemindex, 2, _("Queued"));
262 CardDAVConn.SetUploadMode(TRUE);
263 CardDAVConn.SetupData(wxT("PUT"), TaskURL, TaskData);
264 CardDAVConn.SetEditMode(TRUE);
266 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
268 ActivityListType.insert(std::make_pair(ActivityTaskID, 1));
269 ActivityListData.insert(std::make_pair(ActivityTaskID, TaskData));
270 ActivityListConn.insert(std::make_pair(ActivityTaskID, CardDAVConn));
271 ActivityListIndex.insert(std::make_pair(ActivityTaskID, itemindex));
272 ActivityListTaskDetail.insert(std::make_pair(ActivityTaskID, TaskDetail));
273 ActivityListAccount.insert(std::make_pair(ActivityTaskID, TaskAccount));
274 ActivityListFilename.insert(std::make_pair(ActivityTaskID, TaskFilename));
275 ActivityListFullFilename.insert(std::make_pair(ActivityTaskID, TaskFullFilename));
277 ActivityListETag.insert(std::make_pair(ActivityTaskID, ETagDBPtr->GetETag(TaskFilename)));
278 ActivityListETagOriginal.insert(std::make_pair(ActivityTaskID, ETagDBPtr->GetETagOriginal(TaskFilename)));
279 ActivityList.insert(std::make_pair(ActivityTaskID, 0));
281 } else if (TaskType == 2){
283 coldata.SetText(_("Deleting Contact '") + TaskDetail + _("'"));
284 itemindex = lstActivity->InsertItem(coldata);
286 lstActivity->SetItem(itemindex, 1, AccountName);
287 lstActivity->SetItem(itemindex, 2, _("Queued"));
289 // TODO: Pass the ETagDB for the account to the connection.
291 ActivityList.insert(std::make_pair(ActivityTaskID, 0));
292 ActivityListType.insert(std::make_pair(ActivityTaskID, 2));
293 ActivityListData.insert(std::make_pair(ActivityTaskID, TaskData));
294 ActivityListAccount.insert(std::make_pair(ActivityTaskID, TaskAccount));
295 ActivityListConn.insert(std::make_pair(ActivityTaskID, CardDAVConn));
296 ActivityListFilename.insert(std::make_pair(ActivityTaskID, TaskFilename));
297 ActivityListIndex.insert(std::make_pair(ActivityTaskID, itemindex));
299 } else if (TaskType == 3){
301 coldata.SetText(_("Syncronising All Contacts"));
302 itemindex = lstActivity->InsertItem(coldata);
304 lstActivity->SetItem(itemindex, 1, AccountName);
305 lstActivity->SetItem(itemindex, 2, _("Queued"));
307 ActivityList.insert(std::make_pair(ActivityTaskID, 0));
308 ActivityListType.insert(std::make_pair(ActivityTaskID, 3));
309 ActivityListData.insert(std::make_pair(ActivityTaskID, TaskData));
310 ActivityListConn.insert(std::make_pair(ActivityTaskID, CardDAVConn));
311 ActivityListTaskDetail.insert(std::make_pair(ActivityTaskID, AccountPrefix));
312 ActivityListAccount.insert(std::make_pair(ActivityTaskID, TaskAccount));
313 ActivityListIndex.insert(std::make_pair(ActivityTaskID, itemindex));
317 ProcessTasksData = TRUE;
319 if (!ActProcessTimer.IsRunning()) {
321 wxCommandEvent event(ACTMGR_STARTTIMER);
322 wxPostEvent(this, event);
324 wxCommandEvent eventp(ACTMGR_STARTPROCESSTIMER);
325 wxPostEvent(this, eventp);
327 //ActProcessTimer.Start(1000, FALSE);
328 //ActListProcTimer.Start(1000, FALSE);
332 // Update the recovery database.
334 return ActivityTaskID;
338 void frmActivityMgr::RemoveTask(){
340 // Remove task from the recovery database.
344 void frmActivityMgr::StopTask( wxCommandEvent& event ){
346 // Check if activity has been completed already before stopping.
348 long longSelected = -1;
349 int intSelectedData = 0;
351 longSelected = lstActivity->GetNextItem(longSelected,
353 wxLIST_STATE_SELECTED);
355 intSelectedData = (int)lstActivity->GetItemData(longSelected);
357 if (longSelected == -1){
361 std::map<int,CardDAV>::iterator CDAVter;
363 CDAVter = ActivityListConn.find(intSelectedData);
365 CDAVter->second.Abort();
367 lstActivity->SetItem(longSelected, 2, _("Stopped"));
371 void frmActivityMgr::StopAllTasks( wxCommandEvent& event ){
373 // Check if activity has been completed already before stopping.
375 // TODO: Look through for '1' and stop the running task(s).
377 long longSelected = -1;
378 int intSelectedData = 0;
380 longSelected = lstActivity->GetNextItem(longSelected,
382 wxLIST_STATE_SELECTED);
384 intSelectedData = (int)lstActivity->GetItemData(longSelected);
386 if (longSelected == -1){
390 std::map<int,CardDAV>::iterator CDAVter;
392 CDAVter = ActivityListConn.find(intSelectedData);
394 CDAVter->second.Abort();
396 lstActivity->SetItem(longSelected, 2, _("Stopped"));
397 AnimationTimer.StopAnimation();
398 bmpActivity->SetBitmap(SleepBitmap);
399 lblDetails->SetLabel(_("No activity."));
403 void frmActivityMgr::RetryTask( wxCommandEvent& event ){
405 // Check if activity has been completed already before retrying.
407 long longSelected = -1;
408 int intSelectedData = 0;
410 longSelected = lstActivity->GetNextItem(longSelected,
412 wxLIST_STATE_SELECTED);
414 intSelectedData = (int)lstActivity->GetItemData(longSelected);
416 if (longSelected == -1){
420 std::map<int,CardDAV>::iterator CDAVter;
422 CDAVter = ActivityListConn.find(intSelectedData);
426 //CDAVter->second.Abort();
428 std::map<int,int>::iterator Iter;
429 Iter = ActivityList.find(intSelectedData);
433 AnimationTimer.StartAnimation();
435 if (!ActProcessTimer.IsRunning()) {
437 ActProcessTimer.Start(150, FALSE);
438 ActListProcTimer.Start(150, FALSE);
442 //lstActivity->SetItem(longSelected, 2, _("Processing..."));
446 void frmActivityMgr::OpenWindow()
451 void frmActivityMgr::CloseWindow( wxCommandEvent& event )
457 void frmActivityMgr::ProcessTasksThread()
460 if (ProcessTasksData == FALSE){
466 std::map<int,int>::iterator TypeIter;
467 std::map<int,wxString>::iterator StringIter;
468 std::map<int,wxString>::iterator StringDetailIter;
469 std::map<int,wxString>::iterator StringAccountIter;
470 std::map<int,wxString>::iterator StringFilenameIter;
471 std::map<int,wxString>::iterator StringFullFilenameIter;
472 std::map<int,wxString>::iterator StringTaskDetailIter;
473 std::map<int,wxString>::iterator StringETagIter;
474 std::map<int,wxString>::iterator StringETagOrigIter;
475 std::map<int,CardDAV>::iterator CardDAVIter;
476 std::map<int,long>::iterator LongIter;
477 bool TasksFoundProc = FALSE;
480 for (std::map<int,int>::iterator iter = ActivityList.begin();
481 iter != ActivityList.end(); ++iter){
483 // Check for any queued tasks and start one.
485 if (iter->second > 4){
489 CardDAVIter = ActivityListConn.find(iter->first);
490 TypeIter = ActivityListType.find(iter->first);
491 StringETagIter = ActivityListETag.find(iter->first);
492 StringETagOrigIter = ActivityListETagOriginal.find(iter->first);
493 StringAccountIter = ActivityListAccount.find(iter->first);
494 StringFilenameIter = ActivityListFilename.find(iter->first);
495 StringFullFilenameIter = ActivityListFullFilename.find(iter->first);
502 // 5 = Failed (UI Updated).
503 // 6 = Stopped (UI Updated).
504 // 7 = (Reserved) (UI Updated).
505 // 8 = Completed. (UI Updated).
507 if (iter->second == 0){
509 //CardDAVIter->second.
511 // Wait for process to finish.
514 TasksFoundProc = TRUE;
516 wxString ETagOriginal;
519 wxString ContactFilename;
520 wxString FullFilename;
525 if (TypeIter->second == 1){
526 CardDAVIter->second.GetServerETagValueThread();
527 ETagServer = CardDAVIter->second.ETagValueResult();
530 // Compare the ETags and work out if a conflict has occured.
532 if (TypeIter->second == 1){
534 ETag = StringETagIter->second;
535 ETagOriginal = StringETagOrigIter->second;
536 AccountDir = StringAccountIter->second;
537 ContactFilename = StringFilenameIter->second;
538 FullFilename = StringFullFilenameIter->second;
540 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
542 if (ETag == ETagOriginal){
544 // Compare the ETag with the Server ETag.
546 if (ETagOriginal != ETagServer){
548 // Server ETag is different from original ETag.
549 // This is a conflict which the user will now
555 frmMain *frmMainPtrGet = static_cast<frmMain*>(frmMainPtr);
557 vCard34Conv vCard34Obj;
559 wxString ServerContactData;
561 vCard ConvertedV4Data;
563 // Load the client data from the filename given.
565 CardDAVIter->second.GetServerContactData();
566 ServerContactData = CardDAVIter->second.GetPageData();
568 // Process v3 version into v4 version.
570 vCard34Obj.ConvertToV4(&ServerContactData, &ConvertedV4Data);
572 vCardConflictObj vCardProcData;
574 vCardProcData.vCardLocalData = &ClientData;
575 vCardProcData.vCardServerData = &ConvertedV4Data;
576 ClientData.LoadFile(FullFilename);
578 //ContactConflictEvent event(ContactConflictCmdEnv);
579 //event.SetData(ContactFilename, Moo1, Moo2);
581 //wxPostEvent(frmMainPtrGet, event);
583 // Setup Conflict Resolution Dialog.
585 // Fetch Data from Server and convert.
587 bool *PauseMode = new bool;
592 qrn.QResponse = &ConflictResult;
593 qrn.PausePtr = PauseMode;
595 vCardProcData.QRNotifData = &qrn;
597 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
598 event.SetClientData(&vCardProcData);
599 wxPostEvent(frmMainPtrGet, event);
604 n1.tv_nsec = 250000000L;*/
606 while (*PauseMode == TRUE){
607 //nanosleep(&n1, &n2);
614 //intResult = frmMainPtrGet->ShowConflictDialog(&Moo1, &Moo2);
616 if (ConflictResult == 0){
623 } else if (ConflictResult == 1){
625 // Decided to use client version.
627 CardDAVIter->second.ProcessData();
631 } else if (ConflictResult == 2){
633 // Decided to use server version.
635 // Download server version.
637 ConvertedV4Data.WriteFile(FullFilename);
646 // Update the data to the server.
648 CardDAVIter->second.ProcessData();
654 if (ETagOriginal != ETagServer){
656 // Server ETag is different from original ETag.
657 // This is a conflict which the user will now
660 frmMain *frmMainPtrGet = (frmMain *)frmMainPtr;
662 //ContactConflictEvent event(ContactConflictCmdEnv);
663 //event.SetData(ContactFilename, Moo1, Moo2);
665 vCard34Conv vCard34Obj;
667 wxString ServerContactData;
669 vCard ConvertedV4Data;
671 // Load the client data from the filename given.
673 CardDAVIter->second.GetServerContactData();
674 ServerContactData = CardDAVIter->second.GetPageData();
675 ClientData.LoadFile(FullFilename);
677 // Process v3 version into v4 version.
679 vCard34Obj.ConvertToV4(&ServerContactData, &ConvertedV4Data);
681 vCardConflictObj vCardProcData;
683 vCardProcData.vCardLocalData = &ClientData;
684 vCardProcData.vCardServerData = &ConvertedV4Data;
686 bool *PauseMode = new bool;
691 qrn.QResponse = &ConflictResult;
692 qrn.PausePtr = PauseMode;
694 vCardProcData.QRNotifData = &qrn;
696 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
697 event.SetClientData(&vCardProcData);
698 wxPostEvent(frmMainPtrGet, event);
703 n1.tv_nsec = 250000000L;*/
705 while (*PauseMode == TRUE){
706 //nanosleep(&n1, &n2);
713 //intResult = frmMainPtrGet->ShowConflictDialog(&Moo1, &Moo2);
715 if (ConflictResult == 0){
722 } else if (ConflictResult == 1){
724 // Decided to use client version.
726 CardDAVIter->second.ProcessData();
727 //ETagServer = CardDAVIter->second.GetServerETagValueThread();
728 //ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer);
732 } else if (ConflictResult == 2){
734 // Decided to use server version.
736 // Write server version to file.
738 ConvertedV4Data.WriteFile(FullFilename);
746 // Update the data to the server.
748 CardDAVIter->second.ProcessData();
754 // Update the ETag DB.
756 CardDAVIter->second.GetServerETagValueThread();
757 ETagServer = CardDAVIter->second.ETagValueResult();
758 ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer);
762 } else if (TypeIter->second == 2) {
764 // Delete the contact from the server and update the ETag DB.
766 AccountDir = StringAccountIter->second;
767 ContactFilename = StringFilenameIter->second;
769 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
771 CardDAVIter->second.SetUploadMode(FALSE);
772 CardDAVIter->second.SetupData(wxT("DELETE"), ContactFilename, wxT(""));
773 //CardDAVIter->second.SetServerFilename();
774 CardDAVIter->second.ProcessData();
775 ETagDBPtr->RemoveETag(ContactFilename);
779 } else if (TypeIter->second == 3) {
781 frmMain *frmMainPtrGet = static_cast<frmMain*>(frmMainPtr);
783 wxString AccountNameFriendly;
784 wxString PrefFilename = GetUserPrefDir();
786 XABPreferences PrefData(PrefFilename);
789 for (int i = 0; i < PrefData.accounts.GetCount(); i++){
791 wxString AccountDirCheck = PrefData.accounts.GetAccountDirectory(i);
793 AccountDirCheck.Trim();
794 AccountDirCheck.Append(wxT(".carddav"));
796 if (AccountDirCheck == StringAccountIter->second){
798 AccountNameFriendly = PrefData.accounts.GetAccountName(i);
805 bool KeepUpdating = TRUE;
807 while (KeepUpdating == TRUE){
809 StringTaskDetailIter = ActivityListTaskDetail.find(iter->first);
811 AccountDir = StringAccountIter->second;
813 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
815 wxArrayString vCardAdd;
816 wxArrayString vCardDelete;
817 wxArrayString vCardList;
818 wxArrayString vCardUpdateLocal;
819 wxArrayString vCardUpdateRemote;
820 wxArrayString vCardUpdateLog;
821 std::map<wxString,wxString> vCardETag;
822 ContactListData ServerContactList;
824 std::map<wxString,vCardDownloadDataFileClass> vCardDownloadData;
825 //wxArrayString vCardDownload;
826 //std::map<wxString,wxString> vCardDownloadData;
828 // Get the list of vCard files locally.
830 wxString AccountDirFinal;
831 wxString AccountSyncTokenFilename;
832 wxString SyncTokenLoad;
834 #if defined(__HAIKU__)
836 //preffilename = wxT("noo");
838 #elif defined(__WIN32__)
840 AccountDirFinal = GetAccountDir(AccountDir, FALSE);
841 AccountSyncTokenFilename = AccountDirFinal;
842 AccountSyncTokenFilename.Append(wxT("synctoken"));
846 AccountDirFinal = GetAccountDir(AccountDir, FALSE);
847 AccountSyncTokenFilename = AccountDirFinal;
848 AccountSyncTokenFilename.Append(wxT("synctoken"));
852 // Suppress Error Messages.
854 wxLogNull PleaseDoNotDisturb;
857 SyncLoad.Open(AccountSyncTokenFilename, wxT("r"));
859 if (SyncLoad.IsOpened()){
861 SyncLoad.ReadAll(&SyncTokenLoad, wxMBConvUTF8());
866 // Get a list of vCard files from the server.
868 // Get the list of vCard files from the ETagDB.
870 std::map<wxString,ETagData> ETagDBData = ETagDBPtr->GetETagData();
872 CardDAV CardDAVInstance = CardDAVIter->second;
874 bool ExitLoop = FALSE;
876 std::map<wxString,FileSyncData> *SCListData = NULL;
878 while (ExitLoop == FALSE){
880 //ServerContactList = CardDAVInstance.GetContactList(SyncTokenLoad.ToUTF8());
881 ServerContactList = CardDAVIter->second.GetContactList(SyncTokenLoad.ToUTF8());
883 // Create a pointer for the std::map<wxString,FileSyncData>.
885 SCListData = &ServerContactList.ListData;
887 // Check if any errors have occured whilst getting the data.
889 int ErrorCode = CardDAVIter->second.GetResultCode();
893 if (ErrorCode == 60 || ErrorCode == 51){
895 // Invalid SSL certificate so bring up a dialog to the user
896 // explaining what has happened and the options available.
898 // Stop all the timers.
900 frmMainPtrGet->PauseAllTimers();
902 // Setup the data to be sent in the wxPostEvent command.
904 SSLInvalidCertNotifObj SSLICNProcData;
906 bool *PauseMode = new bool;
911 qrn.QResponse = &SSLResult;
912 qrn.PausePtr = PauseMode;
914 SSLICNProcData.CertCollection = CardDAVIter->second.GetCertificateData();
915 SSLICNProcData.QRNotifData = &qrn;
916 SSLICNProcData.AccountName = AccountNameFriendly;
918 wxCommandEvent event(INVALIDSSLCERT);
919 event.SetClientData(&SSLICNProcData);
920 wxPostEvent(frmMainPtrGet, event);
924 // Fall asleep until we get an response.
927 n1.tv_nsec = 250000000L;*/
929 while (*PauseMode == TRUE){
930 //nanosleep(&n1, &n2);
934 // Process the response from the user.
938 // Accept the certificate. Write the certificate into the account
939 // directory (as server.crt) - will overwrite old certificate.
941 frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, CardDAVIter->second.GetCertificateData());
942 WriteServerCertificate(AccountDir, CardDAVIter->second.GetCertificateData());
944 } else if (SSLResult == 2){
946 // Reject the certificate, abort the task and mark as failed.
948 frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, CardDAVIter->second.GetCertificateData());
954 // Resume all the timers.
956 frmMainPtrGet->ResumeAllTimers();
973 if (iter->second == 2 || iter->second == 3 || iter->second == 4){
977 frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, CardDAVIter->second.GetCertificateData());
979 // Look in directory and see which vCards to add and delete
982 // vCard exists but not in ETagDB - Add (and upload).
983 // vCard missing but in ETagDB - Delete (from server).
985 // Start by looking for vCards that are not in the ETagDB.
987 wxDir AccDir(AccountDirFinal);
988 wxString AccDirFilename;
990 bool ContinueProcess = AccDir.GetFirst(&AccDirFilename, wxEmptyString, wxDIR_DEFAULT);
992 // Process the server data.
994 if (SCListData != NULL){
996 for (std::map<wxString, FileSyncData>::iterator fsiter = SCListData->begin();
997 fsiter != SCListData->end(); fsiter++){
999 // Check the mode of the file before adding.
1001 // Get the HTTP status of the file from the list.
1003 FileSyncData fsd = fsiter->second;
1005 if (fsd.DataFlag == 1){
1007 // Added or modified contact.
1009 //vCardAdd.Add(fsiter->first, 1);
1011 vCardDownloadDataFileClass vCardNewData;
1012 vCardNewData.DataType = 0;
1013 vCardDownloadData.insert(std::make_pair(fsiter->first, vCardNewData));
1015 //} else if (fsd.DataFlag == 1){
1017 // Contact has been modified on the server.
1019 // vCardUpdateLocal.Add(fsiter->first, 1);
1022 else if (fsd.DataFlag == 2){
1024 // Contact has been deleted.
1026 vCardDelete.Add(fsiter->first, 1);
1034 // Look for vCards that are missing but in the ETagDB.
1036 for (std::map<wxString,ETagData>::iterator etagiter = ETagDBData.begin();
1037 etagiter != ETagDBData.end(); etagiter++){
1039 // Check if the vCard exists.
1041 if (!wxFileExists(AccountDirFinal + etagiter->first)){
1043 // vCard doesn't exist so mark for deleting.
1045 vCardDelete.Add(etagiter->first, 1);
1051 // Compare Server with the ETag DB. Work out which
1052 // needs to updated remotely and which needs to be
1055 for (std::map<wxString,FileSyncData>::iterator srviter = SCListData->begin();
1056 srviter != SCListData->end(); srviter++){
1058 if (ETagDBData.find(srviter->first) == ETagDBData.end()){
1062 std::map<wxString,ETagData>::iterator lociter = ETagDBData.find(srviter->first);
1064 ETagData etd = lociter->second;
1065 FileSyncData fsd = srviter->second;
1067 wxString ETagSrv = fsd.ETagData;
1069 // Compare local ETag with original local ETag.
1070 // If different, update to server is required.
1072 if (etd.ETagValue != etd.ETagOrigValue){
1074 // Check if local original ETag is different from server ETag.
1075 // If it is then throw up a conflict resolution dialog.
1077 if (etd.ETagOrigValue != ETagSrv){
1079 vCard34Conv vCard34Obj;
1081 wxString ServerContactData;
1082 wxString FullFilename;
1084 vCard ConvertedV4Data;
1086 // Conflict. Bring up conflict resolution dialog.
1088 // Get the server contact data for comparison.
1090 CardDAVIter->second.SetServerFilename(srviter->first);
1091 CardDAVIter->second.GetServerContactData();
1092 ServerContactData = CardDAVIter->second.GetPageData();
1094 FullFilename = CreateFilenamePath(AccountDirFinal, srviter->first);
1096 // Convert it to v4.
1098 vCard34Obj.ConvertToV4(&ServerContactData, &ConvertedV4Data);
1100 vCardConflictObj vCardProcData;
1102 vCardProcData.vCardLocalData = &ClientData;
1103 vCardProcData.vCardServerData = &ConvertedV4Data;
1105 // Load the client data from the filename given.
1107 ClientData.LoadFile(FullFilename);
1111 bool *PauseMode = new bool;
1114 frmMain *frmMainPtrGet = static_cast<frmMain*>(frmMainPtr);
1117 qrn.QResponse = &ConflictResult;
1118 qrn.PausePtr = PauseMode;
1120 vCardProcData.QRNotifData = &qrn;
1122 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
1123 event.SetClientData(&vCardProcData);
1124 wxPostEvent(frmMainPtrGet, event);
1129 n1.tv_nsec = 250000000L;*/
1131 while (*PauseMode == TRUE){
1132 //nanosleep(&n1, &n2);
1133 SleepFor(250000000);
1139 // If replacing local version, store copy for now.
1140 // Otherwise upload to server.
1142 if (ConflictResult == 0){
1148 } else if (ConflictResult == 1){
1150 // Decided to use client version.
1152 vCardUpdateLocal.Remove(srviter->first);
1153 vCardUpdateRemote.Add(srviter->first, 1);
1155 } else if (ConflictResult == 2){
1157 // Decided to use server version.
1158 // Store the converted downloaded copy for
1159 // processing later.
1161 //vCardUpdateLocal.Add(srviter->first, 1);
1163 vCardDownloadDataFileClass vCardNewData;
1164 vCardNewData.DataType = 1;
1165 vCardNewData.FileData = ConvertedV4Data.WriteString();
1167 ConvertedV4Data.WriteFile(FullFilename);
1169 vCardDownloadData.insert(std::make_pair(srviter->first, vCardNewData));
1177 // Send vCard to the server.
1179 vCardUpdateRemote.Add(srviter->first, 1);
1185 // Check if local ETag is different from server ETag.
1186 // If different, obtain the vCard from the server.
1188 if (etd.ETagOrigValue != ETagSrv){
1190 vCardUpdateLocal.Add(srviter->first, 1);
1198 // Process the vCards that need to be downloaded and added/overwritten.
1200 wxString vCardFilenameFinal;
1201 wxString vCardOutputData;
1202 wxString vCardInputData;
1203 wxString ETagFileData;
1206 for (std::map<wxString,vCardDownloadDataFileClass>::iterator additer = vCardDownloadData.begin();
1207 additer != vCardDownloadData.end(); additer++){
1209 vCardFilenameFinal.Clear();
1210 vCardInputData.Clear();
1211 vCardOutputData.Clear();
1212 ETagFileData.Clear();
1214 vCardFilenameFinal = CreateFilenamePath(AccountDirFinal, additer->first);
1216 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
1218 if (additer->second.DataType == 0){
1220 vCard ConvertedV4Data;
1222 // Grab the file from the server and write the contact out.
1224 vCard34Conv vCard34Obj;
1226 CardDAVIter->second.SetServerFilename(additer->first);
1227 CardDAVIter->second.GetServerContactData();
1228 vCardInputData = CardDAVIter->second.GetPageData();
1230 vCard34Obj.ConvertToV4(&vCardInputData, &ConvertedV4Data);
1232 ConvertedV4Data.WriteFile(vCardFilenameFinal);
1234 // Update the ETagDB.
1236 //vCardFile.Open(vCardFilenameFinal, wxT("w"));
1238 //if (vCardFile.IsOpened()){
1240 // vCardFile.Write(vCardOutputData, wxConvAuto());
1241 // vCardFile.Close();
1245 // Get the server ETag.
1247 wxString ServerETag;
1248 CardDAVIter->second.GetServerETagValueThread();
1249 ServerETag = CardDAVIter->second.ETagValueResult();
1251 // Add to the ETag Database.
1253 ETagDBPtr->AddETag(additer->first, ServerETag, ServerETag);
1255 } else if (additer->second.DataType == 1){
1257 // Write out the contact to the account directory.
1259 vCardFilenameFinal = CreateFilenamePath(AccountDirFinal, additer->first);
1260 vCardOutputData = additer->second.FileData;
1262 vCardFile.Open(vCardFilenameFinal, wxT("w"));
1264 if (vCardFile.IsOpened()){
1266 vCardFile.Write(vCardOutputData, wxConvAuto());
1271 // Update the ETagDB.
1273 wxString ServerETag;
1274 CardDAVIter->second.GetServerETagValueThread();
1275 ServerETag = CardDAVIter->second.ETagValueResult();
1277 // Add to the ETag Database.
1279 ETagDBPtr->AddETag(additer->first, ServerETag, ServerETag);
1284 // Look for vCard files which aren't in the ETagDB.
1286 while(ContinueProcess){
1288 // Check and make sure that the filename ends in .vcf/.vcard
1289 // Skip any file that beings with a dot.
1291 if (AccDirFilename.Left(1) == wxT(".")){
1293 ContinueProcess = AccDir.GetNext(&AccDirFilename);
1298 if (AccDirFilename.Right(4) != wxT(".vcf") &&
1299 AccDirFilename.Right(6) != wxT(".vcard")){
1301 ContinueProcess = AccDir.GetNext(&AccDirFilename);
1306 // Look in the ETagDB for the file.
1308 bool ETagExists = ETagDBPtr->CheckETagExists(AccDirFilename);
1310 if (ETagExists == FALSE){
1312 // Add the vCard to the list to be added.
1314 vCardAdd.Add(AccDirFilename, 1);
1318 ContinueProcess = AccDir.GetNext(&AccDirFilename);
1322 // Process the vCards to add/update to the server.
1324 for (int vi = 0; vi < vCardAdd.GetCount(); vi++){
1326 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
1327 ETag = ETagDBPtr->GetETag(vCardAdd[vi]);
1328 ETagOriginal = ETagDBPtr->GetETagOriginal(vCardAdd[vi]);
1329 ContactFilename = vCardAdd[vi];
1330 FullFilename = CreateFilenamePath(AccountDirFinal, vCardAdd[vi]);
1332 ContactFilename.Trim();
1334 if (ETag == ETagOriginal){
1336 // Compare the ETag with the Server ETag.
1338 if (ETagOriginal != ETagServer){
1340 // Server ETag is different from original ETag.
1341 // This is a conflict which the user will now
1344 frmMain *frmMainPtrGet = static_cast<frmMain*>(frmMainPtr);
1346 vCard34Conv vCard34Obj;
1348 wxString ServerContactData;
1350 vCard ConvertedV4Data;
1352 // Load the client data from the filename given.
1354 CardDAVIter->second.GetServerContactData();
1355 ServerContactData = CardDAVIter->second.GetPageData();
1357 // Process v3 version into v4 version.
1359 vCard34Obj.ConvertToV4(&ServerContactData, &ConvertedV4Data);
1361 vCardConflictObj vCardProcData;
1363 vCardProcData.vCardLocalData = &ClientData;
1364 vCardProcData.vCardServerData = &ConvertedV4Data;
1365 ClientData.LoadFile(FullFilename);
1367 //ContactConflictEvent event(ContactConflictCmdEnv);
1368 //event.SetData(ContactFilename, Moo1, Moo2);
1370 //wxPostEvent(frmMainPtrGet, event);
1372 // Setup Conflict Resolution Dialog.
1374 // Fetch Data from Server and convert.
1376 bool *PauseMode = new bool;
1381 qrn.QResponse = &ConflictResult;
1382 qrn.PausePtr = PauseMode;
1384 vCardProcData.QRNotifData = &qrn;
1386 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
1387 event.SetClientData(&vCardProcData);
1388 wxPostEvent(frmMainPtrGet, event);
1393 n1.tv_nsec = 250000000L;*/
1395 while (*PauseMode == TRUE){
1396 //nanosleep(&n1, &n2);
1397 SleepFor(250000000);
1403 //intResult = frmMainPtrGet->ShowConflictDialog(&Moo1, &Moo2);
1405 if (ConflictResult == 0){
1412 } else if (ConflictResult == 1){
1414 // Decided to use client version.
1416 CardDAVIter->second.ProcessData();
1420 } else if (ConflictResult == 2){
1422 // Decided to use server version.
1424 // Download server version.
1426 ConvertedV4Data.WriteFile(CreateFilenamePath(AccountDirFinal, vCardAdd[vi]));
1434 // Setup the filename for the contact being added.
1436 wxString wxSFilename = CreateFilenamePath(AccountDirFinal, vCardAdd[vi]);
1437 wxString wxSCardData;
1441 // Load the data from the file.
1444 wxFCard.Open(wxSFilename, wxT("r"));
1446 if (wxFCard.IsOpened()){
1448 wxFCard.ReadAll(&wxSCardData, wxConvAuto());
1453 // Convert the data to v3.
1455 vCard34Conv vCard34Obj;
1457 vCard34Obj.ConvertToV3(wxSFilename, &TaskData);
1459 // Setup the URL address.
1461 //TaskURL = StringTaskDetailIter->second + wxT("/") + vCardAdd[vi];
1463 // Upload the data to the server.
1465 CardDAVIter->second.SetUploadMode(TRUE);
1466 CardDAVIter->second.SetupData(wxT("PUT"), vCardAdd[vi], TaskData);
1467 CardDAVIter->second.ProcessData();
1469 // Get the Server ETag and put it in the ETag database.
1471 CardDAVIter->second.SetServerFilename(vCardAdd[vi]);
1472 CardDAVIter->second.GetServerETagValueThread();
1473 ETagServer = CardDAVIter->second.ETagValueResult();
1475 ETagDBPtr->AddETag(vCardAdd[vi], ETagServer, ETagServer);
1481 if (ETagOriginal != ETagServer){
1483 // Server ETag is different from original ETag.
1484 // This is a conflict which the user will now
1487 frmMain *frmMainPtrGet = (frmMain *)frmMainPtr;
1489 //ContactConflictEvent event(ContactConflictCmdEnv);
1490 //event.SetData(ContactFilename, Moo1, Moo2);
1492 vCard34Conv vCard34Obj;
1494 wxString ServerContactData;
1496 vCard ConvertedV4Data;
1498 // Load the client data from the filename given.
1500 CardDAVIter->second.GetServerContactData();
1501 ServerContactData = CardDAVIter->second.GetPageData();
1502 ClientData.LoadFile(FullFilename);
1504 // Process v3 version into v4 version.
1506 vCard34Obj.ConvertToV4(&ServerContactData, &ConvertedV4Data);
1508 vCardConflictObj vCardProcData;
1510 vCardProcData.vCardLocalData = &ClientData;
1511 vCardProcData.vCardServerData = &ConvertedV4Data;
1513 bool *PauseMode = new bool;
1518 qrn.QResponse = &ConflictResult;
1519 qrn.PausePtr = PauseMode;
1521 vCardProcData.QRNotifData = &qrn;
1523 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
1524 event.SetClientData(&vCardProcData);
1525 wxPostEvent(frmMainPtrGet, event);
1530 n1.tv_nsec = 250000000L;*/
1532 while (*PauseMode == TRUE){
1533 //nanosleep(&n1, &n2);
1534 SleepFor(250000000);
1540 //intResult = frmMainPtrGet->ShowConflictDialog(&Moo1, &Moo2);
1542 if (ConflictResult == 0){
1549 } else if (ConflictResult == 1){
1551 // Decided to use client version.
1553 CardDAVIter->second.ProcessData();
1554 //ETagServer = CardDAVIter->second.GetServerETagValueThread();
1555 //ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer);
1559 } else if (ConflictResult == 2){
1561 // Decided to use server version.
1563 // Write server version to file.
1565 ConvertedV4Data.WriteFile(CreateFilenamePath(AccountDirFinal, vCardAdd[vi]));
1573 // Setup the filename for the contact being added.
1575 wxString wxSFilename = CreateFilenamePath(AccountDirFinal, vCardAdd[vi]);
1576 wxString wxSCardData;
1580 // Load the data from the file.
1583 wxFCard.Open(wxSFilename, wxT("r"));
1585 if (wxFCard.IsOpened()){
1587 wxFCard.ReadAll(&wxSCardData, wxConvAuto());
1592 // Convert the data to v3.
1594 vCard34Conv vCard34Obj;
1596 vCard34Obj.ConvertToV3(wxSFilename, &TaskData);
1598 // Setup the URL address.
1600 //TaskURL = StringTaskDetailIter->second + wxT("/") + vCardAdd[vi];
1602 // Upload the data to the server.
1604 CardDAVIter->second.SetUploadMode(TRUE);
1605 CardDAVIter->second.SetupData(wxT("PUT"), vCardAdd[vi], TaskData);
1606 CardDAVIter->second.ProcessData();
1608 // Get the Server ETag and put it in the ETag database.
1610 CardDAVIter->second.SetServerFilename(vCardAdd[vi]);
1611 CardDAVIter->second.GetServerETagValueThread();
1612 ETagServer = CardDAVIter->second.ETagValueResult();
1615 ETagDBPtr->AddETag(vCardAdd[vi], ETagServer, ETagServer);
1623 // Process the vCards to delete locally.
1625 for (int vi = 0; vi < vCardDelete.GetCount(); vi++){
1627 if (!wxRemoveFile(CreateFilenamePath(AccountDirFinal, vCardDelete[vi]))){
1631 ETagDBPtr->RemoveETag(vCardDelete[vi]);
1637 // Process the vCards to delete from the server.
1639 std::map<wxString,wxString> *ETagFilenameMap = ETagDBPtr->GetFilenamePointer();
1642 for (std::map<wxString,wxString>::iterator deliter = ETagFilenameMap->begin();
1643 deliter != ETagFilenameMap->end(); deliter++){
1645 // Look through the ETagDB and find contacts which are marked as DELETED.
1647 if (deliter->second == wxT("DELETED")){
1649 CardDAVIter->second.SetUploadMode(FALSE);
1650 CardDAVIter->second.SetupData(wxT("DELETE"), deliter->first, wxT(""));
1651 CardDAVIter->second.ProcessData();
1653 // Delete the ETag as the file has now been deleted.
1655 ETagDBPtr->RemoveETag(deliter->first);
1661 // Write out the update server sync token.
1663 wxString ServerSyncToken = ServerContactList.SyncToken;
1665 ServerSyncToken.Trim();
1667 if (!ServerSyncToken.IsEmpty()){
1670 SyncWrite.Open(AccountSyncTokenFilename, wxT("w"));
1672 if (SyncWrite.IsOpened()){
1674 SyncWrite.Write(ServerSyncToken, wxConvAuto());
1681 // Check for another sync token. If there is another
1682 // sync token then repeat this. If token matches then stop processing.
1684 if (SyncTokenLoad == ServerSyncToken){
1686 KeepUpdating = FALSE;
1692 // Mark as completed.
1699 // Update the data to the server.
1701 CardDAVIter->second.ProcessData();
1708 n1.tv_nsec = 250000000L;*/
1710 while (iter->second == 1){
1712 SleepFor(250000000);
1713 //nanosleep(&n1, &n2);
1717 if ((iter->second == 4 && TypeIter->second == 0) ||
1718 (iter->second == 8 && TypeIter->second == 0)){
1720 AccountDir = StringAccountIter->second;
1721 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
1723 CardDAVIter->second.GetServerETagValueThread();
1724 ETagServer = CardDAVIter->second.ETagValueResult();
1725 ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer);
1729 if ((iter->second == 4 && TypeIter->second == 1) ||
1730 (iter->second == 8 && TypeIter->second == 1)){
1732 AccountDir = StringAccountIter->second;
1733 ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
1735 CardDAVIter->second.GetServerETagValueThread();
1736 ETagServer = CardDAVIter->second.ETagValueResult();
1737 ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer);
1747 if (TasksFoundProc == FALSE){
1749 TasksActive = FALSE;
1750 ProcessTasksData = FALSE;
1754 wxCommandEvent eventp(ACTMGR_STARTTIMER);
1755 wxPostEvent(this, eventp);
1757 //AnimationTimer.StartAnimation();
1758 //ActListProcTimer.Start();
1762 wxCommandEvent event(ACTMGR_STARTPROCESSTIMER);
1763 wxPostEvent(this, event);
1765 //ActProcessTimer.Start();
1769 void frmActivityMgr::ProcessTasks()
1772 std::thread ProcessThread(&frmActivityMgr::ProcessTasksThread, this);
1773 ProcessThread.detach();
1777 void frmActivityMgr::SetupPointers(wxETagProcessTimer *ETagTmrPtrInc, void *frmMainPtrInc)
1780 ETagTmrPtr = ETagTmrPtrInc;
1782 frmMainPtr = frmMainPtrInc;
1786 void frmActivityMgr::ResumeProcessing(wxCommandEvent &event){
1788 QRNotif *qrn = (QRNotif *)event.GetClientData();
1790 int *QRes = qrn->QResponse;
1792 *qrn->PausePtr = FALSE;
1794 *QRes = event.GetInt();
1798 int frmActivityMgr::GetTaskStatus(int intTaskID){
1802 if (ActivityList.find(intTaskID) == ActivityList.end()){
1808 std::map<int,int>::iterator taskiter = ActivityList.find(intTaskID);
1809 intResult = taskiter->second;
1815 void frmActivityMgr::ToggleConnectionStatus( wxCommandEvent &event ){
1817 wxCommandEvent connevent(CONNSTAT_UPDATE);
1819 if (SleepMode == FALSE){
1821 connevent.SetInt(1);
1826 connevent.SetInt(0);
1831 wxPostEvent(GetParent(), connevent);
1835 void frmActivityMgr::WriteServerCertificate(wxString AccountName, SSLCertCollection SSLCertInc){
1837 wxString ServerCertFinal;
1839 // Get the Cert section of the certificate and write it to the file.
1841 ServerCertFinal = GetAccountDir(AccountName, TRUE);
1845 std::map<int, SSLCertData>::iterator SSLCDIter = SSLCertInc.SSLCollection.find(0);
1846 std::multimap<wxString,wxString>::iterator SSLDataIter = SSLCDIter->second.CertData.find(wxT("Cert"));
1848 CertFile.Open(ServerCertFinal, wxFile::write);
1850 CertFile.Write(SSLDataIter->second, wxConvUTF8);
1855 void frmActivityMgr::StartTimer(wxCommandEvent& event){
1857 ActListProcTimer.Start(1000, FALSE);
1861 void frmActivityMgr::StopTimer(wxCommandEvent& event){
1863 ActListProcTimer.Stop();
1867 void frmActivityMgr::StartProcessTimer(wxCommandEvent& event){
1869 ActProcessTimer.Start(1000, FALSE);
1873 void frmActivityMgr::StopProcessTimer(wxCommandEvent& event){
1875 ActProcessTimer.Stop();