Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed unused variables, using correct types and converting as needed.
[xestiaab/.git] / source / frmMain.cpp
1 #include <iostream>
2 #include <algorithm>
3 #include <vector>
4 #include <thread>
6 #include <wx/wx.h>
7 #include <wx/tokenzr.h>
8 #include <wx/icon.h>
9 #include <wx/mstream.h>
10 #include <wx/fs_mem.h>
11 #include <wx/ffile.h>
12 #include <wx/filesys.h>
13 #include <wx/dir.h>
14 #include <wx/stdpaths.h>
15 #include <wx/fileconf.h>
16 //#include <boost/filesystem/fstream.hpp>
18 // Include the forms.
20 #include "frmMain.h"
21 #include "frmAbout.h"
22 #include "frmPreferences.h"
23 #include "frmNewAccount.h"
24 #include "frmActivityMgr.h"
25 #include "frmContact.h"
26 #include "frmConflictResolution.h"
27 #include "frmInvalidSSLCertificate.h"
28 #include "frmSearch.h"
29 #include "frmSSLCertificate.h"
30 #include "frmUpdate.h"
31 #include "bitmaps.h"
33 #include "common/preferences.h"
34 #include "common/getcontactinfo.h"
35 #include "common/events.h"
36 #include "common/dirs.h"
37 #include "vcard/vcard.h"
38 #include "carddav/carddav.h"
39 #include "contacteditor/frmContactEditor.h"
40 #include "import/import.h"
41 #include "export/export.h"
42 #include "widgets/XABAccountView.h"
44 #include "version.h"
46 //extern const wxEventType MyHaremEvent = wxNewEventType();
48 //#define CE_UPDATECONTACTLIST 7700
49 //#define CE_UPDATEACCOUNTLIST 7701
51 DEFINE_EVENT_TYPE(CE_UPDATECONTACTLIST);
52 DEFINE_EVENT_TYPE(CE_UPDATEACCOUNTLIST);
53 DEFINE_EVENT_TYPE(SE_UPDATECONTACTNOTIF);
54 DEFINE_EVENT_TYPE(CE_OPENCONTACT);
55 DEFINE_EVENT_TYPE(CE_EDITCONTACT);
56 DEFINE_EVENT_TYPE(CE_REVEALCONTACT);
57 DEFINE_EVENT_TYPE(CE_REMOVECONTACT);
58 DEFINE_EVENT_TYPE(CE_REMOVESEARCH);
59 DEFINE_EVENT_TYPE(SYNC_EMPTYSERVER);
60 DEFINE_EVENT_TYPE(ACTMGR_START);
61 DEFINE_EVENT_TYPE(ACTMGR_SHUFFLE);
62 DEFINE_EVENT_TYPE(ACTMGR_STOP);
63 DEFINE_EVENT_TYPE(WINDOW_ADD);
64 DEFINE_EVENT_TYPE(WINDOW_EDIT);
65 //DEFINE_EVENT_TYPE(WINDOW_DELETE);
66 DEFINE_EVENT_TYPE(WINDOW_CLOSE);
67 DEFINE_EVENT_TYPE(CONNSTAT_UPDATE);
68 DEFINE_EVENT_TYPE(INVALIDSSLCERT);
69 DEFINE_EVENT_TYPE(GETSELECTEDLIST);
70 DEFINE_EVENT_TYPE(SYNCACCOUNT);
72 BEGIN_EVENT_TABLE(frmMain, wxFrame)
73 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, frmMain::ConflictResolution)
74 EVT_COMMAND(wxID_ANY, CE_UPDATECONTACTLIST, frmMain::UpdateContactList)
75 EVT_COMMAND(wxID_ANY, CE_UPDATEACCOUNTLIST, frmMain::UpdateAccountList)
76 EVT_COMMAND(wxID_ANY, SE_UPDATECONTACTNOTIF, frmMain::UpdateSearchContactLists)
77 EVT_COMMAND(wxID_ANY, CE_OPENCONTACT, frmMain::OpenContactInfo)
78 EVT_COMMAND(wxID_ANY, CE_EDITCONTACT, frmMain::ShowContactEditorEdit)
79 EVT_COMMAND(wxID_ANY, CE_REVEALCONTACT, frmMain::RevealContact)
80 EVT_COMMAND(wxID_ANY, CE_REMOVESEARCH, frmMain::RemoveContactsWindowPointer)
81 EVT_COMMAND(wxID_ANY, SYNC_EMPTYSERVER, frmMain::EmptyServerDialog)
82 EVT_COMMAND(wxID_ANY, ACTMGR_START, frmMain::ActivityIconStart)
83 EVT_COMMAND(wxID_ANY, ACTMGR_SHUFFLE, frmMain::ActivityIconShuffle)
84 EVT_COMMAND(wxID_ANY, ACTMGR_STOP, frmMain::ActivityIconStop)
85 EVT_COMMAND(wxID_ANY, WINDOW_ADD, frmMain::WindowAdd)
86 EVT_COMMAND(wxID_ANY, WINDOW_EDIT, frmMain::WindowEdit)
87 EVT_COMMAND(wxID_ANY, WINDOW_CLOSE, frmMain::WindowDelete)
88 EVT_COMMAND(wxID_ANY, CONNSTAT_UPDATE, frmMain::UpdateConnectionStatus)
89 EVT_COMMAND(wxID_ANY, INVALIDSSLCERT, frmMain::InvalidSSLCertificate)
90 EVT_COMMAND(wxID_ANY, GETSELECTEDLIST, frmMain::GetSelectedList)
91 EVT_COMMAND(wxID_ANY, SYNCACCOUNT, frmMain::SyncAccount)
92 END_EVENT_TABLE()
94 frmMain::frmMain( wxWindow* parent )
95 :
96 frmMainADT( parent )
97 {
98     
99     // Setup the account icons.
100     
101     wxMemoryInputStream astream(icons_accinet_png, sizeof(icons_accinet_png));
102     wxMemoryInputStream bstream(icons_acclocal_png, sizeof(icons_acclocal_png));
103     wxMemoryInputStream cstream(icons_accgroup_png, sizeof(icons_accgroup_png));
104     wxMemoryInputStream dstream(icons_accnone_png, sizeof(icons_accnone_png));
105     
106     wxImage icons_accinet_png(astream, wxBITMAP_TYPE_PNG);
107     wxBitmap AccInet(icons_accinet_png, -1);
108     wxIcon wxIAccInet;
109     wxIAccInet.CopyFromBitmap(AccInet);
110     
111     wxImage icons_acclocal_png(bstream, wxBITMAP_TYPE_PNG);
112     wxBitmap AccNIcon(icons_acclocal_png, -1);
113     wxIcon wxIAccNIcon;
114     wxIAccNIcon.CopyFromBitmap(AccNIcon);
115     
116     wxImage icons_accgroup_png(cstream, wxBITMAP_TYPE_PNG);
117     wxBitmap AccGrp(icons_accgroup_png, -1);
118     wxIcon wxIAccGrp;
119     wxIAccGrp.CopyFromBitmap(AccGrp);
120     
121     wxImage icons_accnone_png(dstream, wxBITMAP_TYPE_PNG);
122     wxBitmap AccNone(icons_accnone_png, -1);
123     wxIcon wxIAccNone;
124     wxIAccNone.CopyFromBitmap(AccNone);
125     
126     AccountID = AccImgList->Add(wxIAccNIcon);
127     AccountNetID = AccImgList->Add(wxIAccInet);
128     AccountGrpID = AccImgList->Add(wxIAccGrp);
129     AccountNoneID = AccImgList->Add(wxIAccNone);
130     
131     bmpIcon->SetIcon(AccImgList->GetIcon(AccountNoneID));
132     
133     // Setup the status bar icons.
134     
135     // SSL icons.
136     
137     wxMemoryInputStream sslstream(icons_ssl_png, sizeof(icons_ssl_png));
138     wxMemoryInputStream sslwarningstream(icons_sslwarning_png, sizeof(icons_sslwarning_png));
139     wxMemoryInputStream nosslstream(icons_nossl_png, sizeof(icons_nossl_png));
140     
141     wxImage icons_ssl_png(sslstream, wxBITMAP_TYPE_PNG);
142     imgSSL = new wxBitmap(icons_ssl_png, -1);
143     
144     wxImage icons_sslwarning_png(sslwarningstream, wxBITMAP_TYPE_PNG);
145     imgSSLWarning = new wxBitmap(icons_sslwarning_png, -1);
146     
147     wxImage icons_nossl_png(nosslstream, wxBITMAP_TYPE_PNG);
148     imgNoSSL = new wxBitmap(icons_nossl_png, -1);
149     
150     // Activity Icon.
151     
152     wxMemoryInputStream act1(icons_act1_png, sizeof(icons_act1_png));
153     wxMemoryInputStream act2(icons_act2_png, sizeof(icons_act2_png));
154     wxMemoryInputStream act3(icons_act3_png, sizeof(icons_act3_png));
155     wxMemoryInputStream act4(icons_act4_png, sizeof(icons_act4_png));
156     wxMemoryInputStream actsleep(icons_actsleep_png, sizeof(icons_actsleep_png));
157     
158     wxImage icons_actsleep_png(actsleep, wxBITMAP_TYPE_PNG);
159     imgActIconSleep = new wxBitmap (icons_actsleep_png, -1);
160     
161     wxImage icons_act1_png(act1, wxBITMAP_TYPE_PNG);
162     imgActIcon1 = new wxBitmap (icons_act1_png, -1);
163     wxIcon wxIAct1icon;
164     wxIAct1icon.CopyFromBitmap(*imgActIcon1);
165     
166     wxImage icons_act2_png(act2, wxBITMAP_TYPE_PNG);
167     imgActIcon2 = new wxBitmap (icons_act2_png, -1);
168     wxIcon wxIAct2icon;
169     wxIAct2icon.CopyFromBitmap(*imgActIcon2);
170     
171     wxImage icons_act3_png(act3, wxBITMAP_TYPE_PNG);
172     imgActIcon3 = new wxBitmap (icons_act3_png, -1);
173     wxIcon wxIAct3icon;
174     wxIAct3icon.CopyFromBitmap(*imgActIcon3);
175     
176     wxImage icons_act4_png(act4, wxBITMAP_TYPE_PNG);
177     imgActIcon4 = new wxBitmap (icons_act4_png, -1);
178     wxIcon wxIAct4icon;
179     wxIAct4icon.CopyFromBitmap(*imgActIcon4);
180     
181     // Online/Offline icons.
182     
183     wxMemoryInputStream onlinestream(icons_online_png, sizeof(icons_online_png));
184     wxMemoryInputStream offlinestream(icons_offline_png, sizeof(icons_offline_png));
185     
186     wxImage icons_online_png(onlinestream, wxBITMAP_TYPE_PNG);
187     imgOnline = new wxBitmap(icons_online_png, -1);
188     
189     wxImage icons_offline_png(offlinestream, wxBITMAP_TYPE_PNG);
190     imgOffline = new wxBitmap(icons_offline_png, -1);
191     
192     // Setup the account view.
193     
194     AccCtrl->SetPopupControl(treAccounts);
195     AccCtrl->SetPopupMaxHeight(175);
196     AccCtrl->SetPopupMinWidth(250);
197     treAccounts->AssignImageList(AccImgList);
198     //bmpIcon->Hide();
199     
200     /*wxStaticBitmap* BeepBoop = new wxStaticBitmap(AccCtrl, wxID_ANY, wxNullBitmap, wxPoint(AccTextCtrlSize.GetX() + 3, AccTextCtrlSize.GetY() + 2), wxDefaultSize, 0);
201      
202      icons_accgroup_png.SetMask(new wxMask(icons_accgroup_png, wxSystemSettings::GetColour(wxSYS_COLOUR_BACKGROUND)));
203      
204      BeepBoop->SetBackgroundColour(AccCtrl->GetBackgroundColour());
205      BeepBoop->SetBitmap(icons_accgroup_png);*/
206     
207     //szrContactList->Insert(0, XABV2, 1, wxEXPAND | wxALL, 0);
208     
209     /*AccControl->UseAltPopupWindow();
210      AccControl->SetPopupControl(treAccounts);
211      AccControl->SetPopupMaxHeight(175);
212      
213      treAccounts->AssignImageList(AccImgList);
214      szrContactList->Insert(0, AccControl, 1, wxEXPAND|wxALL, 0);
215      szrAccList->Add(AccIcon, 0, wxLEFT|wxTOP|wxEXPAND, 3);
216      
217      */
218     
219     //szrContactList->Layout();
220     //szrContactList->RecalcSizes();
221     
222     wxListItem ColumnData;
223     ColumnData.SetId(0);
224     ColumnData.SetText(wxT("Name0"));
225     ColumnData.SetWidth(320);
226     lstContacts->InsertColumn(0, ColumnData);
227     
228     //Connect(wxID_ANY, ContactConflictCmdEnv,
229     //  ContactConflictEventHandler(frmMain::ConflictResolution), NULL, this);
230     
231     //Connect(wxID_ANY, MyFooCommandEvent,
232     //  MyFooEventHandler(frmMain::DoSomething), NULL, this);
233     
234     //Bind(ContactConflictCmdEnv, ContactConflictEventHandler(frmMain::ConflictResolution), this, wxID_ANY);
235     
236     treAccounts->Connect(wxEVT_LEFT_DCLICK, wxTreeEventHandler(frmMain::LoadContactList), NULL, this);
237     treAccounts->Connect(wxEVT_TREE_SEL_CHANGED, wxTreeEventHandler(frmMain::LoadContactList), NULL, this);
238     
239 #if defined(__HAIKU__)
240     
241 #elif defined(__WIN32__)
242     
243     int stbBottomData [4] = { -1, 8, 8, 8 };
244     
245 #else
246     
247     int stbBottomData [4] = { -1, 20, 20, 20 };
248     
249 #endif
250     
251     stbBottom->SetFieldsCount(4, stbBottomData);
252     stbBottom->SetMinHeight(16);
253     
254     wxRect rectOnline;
255     wxRect rectSSL;
256     wxRect rectActivity;
257     stbBottom->GetFieldRect(1, rectOnline);
258     stbBottom->GetFieldRect(2, rectSSL);
259     stbBottom->GetFieldRect(3, rectActivity);
260     
261     SSLToolTip = new wxToolTip(wxT(""));
262     
263     imgConnStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectOnline.GetX()),(rectOnline.GetY())), wxDefaultSize, 0 );
264     imgConnStatus->SetBitmap(*imgOnline);
265     imgConnStatus->Connect( wxEVT_LEFT_DCLICK, wxCommandEventHandler( frmMain::ToggleConnectionStatus ), NULL, this );
266     
267     imgSSLStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectSSL.GetX()),(rectSSL.GetY())), wxDefaultSize, 0 );
268     imgSSLStatus->SetBitmap(*imgNoSSL);
269     imgSSLStatus->SetToolTip(SSLToolTip);
270     imgSSLStatus->Connect( wxEVT_LEFT_DCLICK, wxCommandEventHandler( frmMain::ShowSSLCertificates ), NULL, this );
271     
272     imgActivityStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectActivity.GetX()),(rectActivity.GetY())), wxDefaultSize, 0);
273     imgActivityStatus->SetBitmap(*imgActIconSleep);
274     imgActivityStatus->Connect( wxEVT_LEFT_DCLICK, wxCommandEventHandler( frmMain::ShowActivityWindow ), NULL, this );
275     
276     // Setup the window menu.
277     
278     // By default should be:
279     
280     // Contact windows:
281     // (none)
282     // (horizontal line)
283     // Contact editor windows:
284     // (none)
285     // (horizontal line)
286     // Search windows:
287     // (none)
288     
289     mnuContactWindows = new wxMenuItem( mnuManage, wxID_ANY, wxString( _("Contact windows:") ), wxEmptyString, wxITEM_NORMAL );
290     mnuWindow->Append( mnuContactWindows );
291     
292     mnuWindow->AppendSeparator();
293     
294     mnuContactEditorWindows = new wxMenuItem( mnuManage, wxID_ANY, wxString( _("Contact editor windows:") ), wxEmptyString, wxITEM_NORMAL );
295     mnuWindow->Append( mnuContactEditorWindows );
296     
297     mnuWindow->AppendSeparator();
298     
299     mnuSearchWindows = new wxMenuItem( mnuManage, wxID_ANY, wxString( wxT("Search windows:") ), wxEmptyString, wxITEM_NORMAL );
300     mnuWindow->Append( mnuSearchWindows );
301     
302 #if defined(__WIN32__)
303     
304     wxFont fontstyle;
305     fontstyle.Bold();
306     
307     mnuContactWindows->SetFont(fontstyle);
308     mnuContactEditorWindows->SetFont(fontstyle);
309     mnuSearchWindows->SetFont(fontstyle);
310     
311 #else
312     
313     mnuContactWindows->Enable(FALSE);
314     mnuContactEditorWindows->Enable(FALSE);
315     mnuSearchWindows->Enable(FALSE);
316     
317 #endif
318     
319     // Hide unimplemented functions.
320     
321     mnuMain->Remove(3);
322     
325 void frmMain::QuitApp( wxCommandEvent& event )
327     //-------------------------------------------------------------------
328     // frmMain::QuitApp: Quits the application by simply closing this
329     // window which causes the exit as frmMain is the main window.
330     //
331     // wxCommandEvent   Accepts a referenced event command.
332     //-------------------------------------------------------------------
333     
334     //Go through the windows and close each one (be it search
335     //or contact editor). Abort if user wants to cancel.
336     
337     // Close the contact editor windows.
338     
339     // Close the contact windows.
340     
341     // Close the search windows.
342     
343     // Write out the ETag databases.
344     
345     // Save Preferences: Save the window position if that option is enabled.
346     
347     wxString SetFilename = GetUserPrefDir();
348     
349 #if defined(__HAIKU__)
350     
351     
352     
353 #elif defined(__WIN32__)
354     
355     SetFilename.Append(wxT("settings"));
356     
357 #else
358     
359     // *nix OSes
360     
361     SetFilename.Append(wxT("settings"));
362     
363 #endif
364     
365     wxFileConfig *cfgfile = new wxFileConfig("", "", SetFilename);
366     
367     bool SaveWindowPos = FALSE;
368     wxString SaveWindowInc;
369     cfgfile->Read(wxT("SaveWindowPosition"), &SaveWindowInc);
370     
371     if (SaveWindowInc == wxT("true")){
372         
373         SaveWindowPos = TRUE;
374         
375     }
376     
377     if (SaveWindowPos == TRUE){
378         
379         wxRect frmMainPos = this->GetRect();
380         
381         cfgfile->Write(wxT("WindowPositionX"), frmMainPos.GetX());
382         cfgfile->Write(wxT("WindowPositionY"), frmMainPos.GetY());
383         cfgfile->Write(wxT("WindowPositionHeight"), frmMainPos.GetHeight());
384         cfgfile->Write(wxT("WindowPositionWidth"), frmMainPos.GetWidth());
385         
386         
387     }
388     
389     delete cfgfile;
390     cfgfile = NULL;
391     
392     //Everything closed... exit.
393     
394     std::exit(0);
395     
398 void frmMain::QuitApp()
400     //-------------------------------------------------------------------
401     // frmMain::QuitApp: Quits the application by simply closing this
402     // window which causes the exit as frmMain is the main window.
403     //
404     // wxCommandEvent   Accepts a referenced event command.
405     //-------------------------------------------------------------------
406     
407     Close();
408     
411 void frmMain::ShowActivityWindow( wxCommandEvent& event )
413     
414     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
415     frameActMgr->OpenWindow();
416     frameActMgr->Show();
417     
420 void frmMain::ShowAboutWindow( wxCommandEvent& event )
422     //-------------------------------------------------------------------
423     // frmMain::ShowAboutWindow: Shows the About window as a modal
424     // dialog and then cleans up when finished.
425     //
426     // wxCommandEvent   Accepts a referenced event command.
427     //-------------------------------------------------------------------
428     
429     frmAbout *frameAbout = new frmAbout ( this );
430     frameAbout->SetupAboutWindow();
431     frameAbout->ShowModal();
432     delete frameAbout;
433     frameAbout = NULL;
434     
437 void frmMain::OpenPreferences( wxCommandEvent& event)
439     //-------------------------------------------------------------------
440     // frmMain::ShowAboutWindow: Opens the Preferences window as a modal
441     // dialog and then cleans up when finished.
442     //
443     // wxCommandEvent   Accepts a referenced event command.
444     //-------------------------------------------------------------------
445     
446     ReloadAccounts = FALSE;
447     
448     frmPreferences *framePreferences = new frmPreferences ( this );
449     framePreferences->SetupPointers(&ReloadAccounts);
450     framePreferences->ShowModal();
451     delete framePreferences;
452     framePreferences = NULL;
453     
454     if (ReloadAccounts == TRUE){
455         
456         // Reload the accounts as a change has been made within
457         // the application.
458         
459         this->LoadPreferences();
460         
461     }
462     
465 void frmMain::OpenNewABDialog( wxCommandEvent& event)
467     //-------------------------------------------------------------------
468     // frmMain::ShowAboutWindow: Opens the Preferences window as a modal
469     // dialog and then cleans up when finished.
470     //
471     // wxCommandEvent   Accepts a referenced event command.
472     //-------------------------------------------------------------------
473     
474     ReloadAccounts = FALSE;
475     
476     frmNewAccount *frameNewAccount = new frmNewAccount ( this );
477     frameNewAccount->SetupPointers(&ReloadAccounts);
478     frameNewAccount->ShowModal();
479     delete frameNewAccount;
480     frameNewAccount = NULL;
481     
482     if (ReloadAccounts == TRUE){
483         
484         // Reload the accounts as a change has been made within
485         // the application.
486         
487         this->LoadPreferences();
488         
489     }
490     
493 void frmMain::LoadContactList( wxTreeEvent& event )
495     
496     // Clear all existing variables.
497     
498     lstContacts->DeleteAllItems();
499     
500     treAccounts->SetAccount();
501     
502     wxTreeItemIdValue cookie;
503     wxTreeItemId next = treAccounts->GetRootItem();
504     wxString AccountName;
505     wxString AccountDir, AccountType, AccountDirFinal, AccountTypeFinal;
506     wxString AccountDirCmb;
507     long selectedaccount = 0;
508     
509     wxTreeItemId selectedChild = treAccounts->GetSelection();
510     wxTreeItemId nextChild;
511     
512     wxTreeItemId ActiveItemId = treAccounts->GetFocusedItem();
513     int ActiveItemIcon = treAccounts->GetItemImage(ActiveItemId, wxTreeItemIcon_Normal);
514     
515     int SCImg = treAccounts->GetItemImage(selectedChild);
516     int AccountIndex = 0;
517     
518     bmpIcon->SetIcon(AccImgList->GetIcon(SCImg));
519     
520     for (int i = 0; i < prefaccounts.GetCount(); i++){
521         
522         if (ActiveItemIcon == 2){
523             
524             std::multimap<wxTreeItemId, int>::iterator AGTiter = AccountGroupTreeId.find(ActiveItemId);
525             std::multimap<int, int>::iterator AGLiter = AccountGroupList.find(AGTiter->second);
526             int ActiveAccountG = AGLiter->second;
527             
528             if (i == ActiveAccountG){
529                 
530                 AccountDir.Append(prefaccounts.GetAccountDirectory(i));
531                 AccountType.Append(prefaccounts.GetAccountType(i));
532                 
533                 AccountDir.Trim();
534                 AccountType.Trim();
535                 
536                 if (AccountType == wxT("CardDAV")){
537                     AccountTypeFinal.Append(wxT("carddav"));
538                 }
539                 else if (AccountType == wxT("Local")){
540                     imgSSLStatus->SetBitmap(*imgOffline);
541                     SSLToolTip->SetTip(wxT("SSL status is not applicable for this account"));
542                     AccountTypeFinal.Append(wxT("local"));
543                 }
544                 
545                 AccountIndex = i;
546                 break;
547                 
548             }
549             
550         }
551         
552         if (!nextChild){
553             nextChild = treAccounts->GetFirstChild(next, cookie);
554         }
555         else {
556             nextChild = treAccounts->GetNextSibling(nextChild);
557         }
558         
559         AccountName = treAccounts->GetItemText(nextChild);
560         
561         if (nextChild == selectedChild){
562             AccountDir.Append(prefaccounts.GetAccountDirectory(i));
563             AccountType.Append(prefaccounts.GetAccountType(i));
564             
565             AccountDir.Trim();
566             AccountType.Trim();
567             
568             if (AccountType == wxT("CardDAV")){
569                 AccountTypeFinal.Append(wxT("carddav"));
570             }
571             else if (AccountType == wxT("Local")){
572                 SSLToolTip->SetTip(wxT("SSL status is not applicable for this account"));
573                 AccountTypeFinal.Append(wxT("local"));
574             }
575             
576             AccountIndex = i;
577             
578         }
579         
580     }
581     
582     if (selectedaccount >= prefaccounts.GetCount()){
583         
584         // The account selected isn't there so return.
585         
586         RevealWait = FALSE;
587         
588         return;
589         
590     }
591     
592     // Open the directory and get the list of .vcf files
593     // in that directory.
594     
595     ActiveAccount = AccountDir + wxT(".") + AccountTypeFinal;
596     ActiveAccountType = AccountType;
597     
598     SetupSSLStatus(AccountIndex);
599     
600     AccountDirFinal.Clear();
601     AccountDirFinal = GetAccountDir(AccountDir + wxT(".") + AccountTypeFinal, FALSE);
602     
603     ContactsFileIndex.Clear();
604     
605     //wxString vcardfilenamewxs;
606     wxString vCardFilename;
607     wxString vCardFilenameFull;
608     wxString vCardDataString;
609     wxStringTokenizer vcardfileline;
610     wxString lwxs;
611     wxString setname, setvalue;
612     //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
613     std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
614     std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
615     long ContactIndex = 1;
616     long ContactSeekPoint = 0;
617     
618     wxDir vcardaccdir(AccountDirFinal);
619     
620     // Get the wxTreeItemId and image icon and compare it to the list.
621     
622     if (ActiveItemIcon == AccountGrpID){
623         
624         // It's a group so load the file containing the group and
625         // get the members of the group.
626         
627         vCard Group;
628         wxString UIDCode;
629         
630         std::multimap<wxTreeItemId, int>::iterator AGTiter = AccountGroupTreeId.find(ActiveItemId);
631         std::multimap<int, wxString>::iterator AGFiter = AccountGroupFilename.find(AGTiter->second);
632         //std::multimap<wxTreeItemId, int>::iterator AGFiter = AccountGroupTreeId.find(ActiveItemId);
633         
634         Group.LoadFile(AGFiter->second);
635         
636         ArrayvCardOutData vCardMember = Group.GetByPartial(wxT("MEMBER"));
637         
638         for (int i = 0; i < vCardMember.PropCount; i++){
639             
640             vCardMember.PropValues[i].Trim();
641             if (vCardMember.PropValues[i].Left(9) == wxT("urn:uuid:")){
642                 
643                 wxString NewPropValue;
644                 NewPropValue = vCardMember.PropValues[i].Mid(9, wxString::npos);
645                 vCardMember.PropValues[i] = NewPropValue;
646                 
647             }
648             
649             
650         }
651         
652         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
653         while(ProcFiles){
654             
655             if (vCardFilename.Right(4) == wxT(".vcf") ||
656                 vCardFilename.Right(4) == wxT(".VCF") ||
657                 vCardFilename.Right(5) == wxT(".vcard") ||
658                 vCardFilename.Right(5) == wxT(".VCARD")){
659                 
660                 vCard Person;
661                 bool FoundMember = FALSE;
662                 
663                 vCardFilenameFull.Append(AccountDirFinal);
664                 vCardFilenameFull.Append(wxT("/"));
665                 vCardFilenameFull.Append(vCardFilename);
666                 
667                 Person.LoadFile(vCardFilenameFull);
668                 
669                 UIDCode = Person.Get(wxT("UID"));
670                 
671                 for (int i = 0; i < vCardMember.PropCount; i++){
672                     
673                     if (vCardMember.PropValues[i] == UIDCode){
674                         
675                         FoundMember = TRUE;
676                         
677                     }
678                     
679                 }
680                 
681                 if (FoundMember == FALSE){
682                     
683                     vCardFilename.Clear();
684                     vCardFilenameFull.Clear();
685                     vCardDataString.Clear();
686                     ProcFiles = vcardaccdir.GetNext(&vCardFilename);
687                     continue;
688                     
689                 }
690                 
691                 if (Person.MeetBaseSpecification()){
692                     
693                     if (SortMode == 1){
694                         
695                         // Split the name into sections.
696                         
697                         vCardDataString = Person.Get(wxT("N"));
698                         
699                         vCardName NameData = Person.GetName();
700                         
701                         vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
702                         
703                     } else if (SortMode == 2){
704                         
705                         // Split the name into sections.
706                         
707                         vCardName NameData = Person.GetName();
708                         
709                         vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
710                         
711                     } else if (SortMode == 3){
712                         
713                         // Check and make sure that the top most nickname is used.
714                         
715                         vCardDataString = Person.Get(wxT("NICKNAME"));
716                         
717                         if (vCardDataString.IsEmpty()){
718                             
719                             vCardDataString = wxT("(no nickname)");
720                             
721                         }
722                         
723                     } else if (SortMode == 4){
724                         
725                         vCardDataString = Person.Get(wxT("FN"));
726                         
727                     }
728                     
729                     if (AscendingMode == TRUE){
730                         vCardNamesAsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
731                     } else {
732                         vCardNamesDsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
733                     }
734                     
735                 } else {
736                     
737                 }
738                 
739             }
740             
741             vCardFilename.Clear();
742             vCardFilenameFull.Clear();
743             vCardDataString.Clear();
744             ProcFiles = vcardaccdir.GetNext(&vCardFilename);
745         }
746         
747     } else {
748         
749         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
750         while(ProcFiles){
751             
752             if (vCardFilename.Right(4) == wxT(".vcf") ||
753                 vCardFilename.Right(4) == wxT(".VCF") ||
754                 vCardFilename.Right(5) == wxT(".vcard") ||
755                 vCardFilename.Right(5) == wxT(".VCARD")){
756                 
757                 vCard Person;
758                 
759                 vCardFilenameFull.Append(AccountDirFinal);
760                 vCardFilenameFull.Append(wxT("/"));
761                 vCardFilenameFull.Append(vCardFilename);
762                 
763                 Person.LoadFile(vCardFilenameFull);
764                 
765                 if (Person.MeetBaseSpecification()){
766                     
767                     if (SortMode == 1){
768                         
769                         // Split the name into sections.
770                         
771                         vCardDataString = Person.Get(wxT("N"));
772                         
773                         vCardName NameData = Person.GetName();
774                         
775                         vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
776                         
777                     } else if (SortMode == 2){
778                         
779                         // Split the name into sections.
780                         
781                         vCardName NameData = Person.GetName();
782                         
783                         vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
784                         
785                     } else if (SortMode == 3){
786                         
787                         // Check and make sure that the top most nickname is used.
788                         
789                         vCardDataString = Person.Get(wxT("NICKNAME"));
790                         
791                         if (vCardDataString.IsEmpty()){
792                             
793                             vCardDataString = wxT("(no nickname)");
794                             
795                         }
796                         
797                     } else if (SortMode == 4){
798                         
799                         vCardDataString = Person.Get(wxT("FN"));
800                         
801                     }
802                     
803                     if (AscendingMode == TRUE){
804                         vCardNamesAsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
805                     } else {
806                         vCardNamesDsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
807                     }
808                     
809                 } else {
810                     
811                 }
812                 
813             }
814             
815             vCardFilename.Clear();
816             vCardFilenameFull.Clear();
817             vCardDataString.Clear();
818             ProcFiles = vcardaccdir.GetNext(&vCardFilename);
819         }
820         
821     }
822     
823     // Sort the data.
824     
825     // Insert the data into the control.
826     
827     if (AscendingMode == TRUE){
828         for (std::map<wxString, wxString>::iterator iter = vCardNamesAsc.begin();
829              iter != vCardNamesAsc.end(); ++iter){
830             
831             wxListItem ContactInfo;
832             
833             ContactInfo.SetId(0);
834             ContactInfo.SetText(_("Mooo"));
835             ContactInfo.SetData(ContactSeekPoint);
836             ContactIndex = lstContacts->InsertItem(ContactInfo);
837             
838             lstContacts->SetItem(ContactIndex, 0, iter->first);
839             ContactsFileIndex.Insert(iter->second, ContactSeekPoint);
840             ContactSeekPoint++;
841             
842         }
843         
844     } else {
845         
846         for (std::map<wxString, wxString>::iterator iter = vCardNamesDsc.begin();
847              iter != vCardNamesDsc.end(); ++iter){
848             
849             wxListItem ContactInfo;
850             
851             ContactInfo.SetId(0);
852             ContactInfo.SetText(_("Mooo"));
853             ContactInfo.SetData(ContactSeekPoint);
854             ContactIndex = lstContacts->InsertItem(ContactInfo);
855             
856             lstContacts->SetItem(ContactIndex, 0, iter->first);
857             ContactsFileIndex.Insert(iter->second, ContactSeekPoint);
858             ContactSeekPoint++;
859             
860         }
861         
862     }
863     
866 void frmMain::ShowContactInfo( wxListEvent& event )
868     
869     long intSelected = -1;
870     long ContactSeekNum = -1;
871     
872     //    intSelected = lstContacts->GetSelection();
873     
874     // Check if several contacts have been selected.
875     
876     int ContactTotal = 0;
877     
878     for (;;){
879         
880         intSelected = lstContacts->GetNextItem(intSelected,
881                                                wxLIST_NEXT_ALL,
882                                                wxLIST_STATE_SELECTED);
883         
884         if (intSelected == -1){
885             
886             break;
887             
888         }
889         
890         ContactTotal++;
891         
892     }
893     
894     if (ContactTotal == 0){
895         htmContactData->SetPage(wxT(""));
896         return;
897     }
898     
899     if (ContactTotal > 1){
900         
901         htmContactData->SetPage(wxString::Format(wxT("%i contacts selected."), ContactTotal));
902         ActiveFilename.Clear();
903         return;
904         
905     }
906     
907     intSelected = lstContacts->GetNextItem(intSelected,
908                                            wxLIST_NEXT_ALL,
909                                            wxLIST_STATE_SELECTED);
910     
911     ContactSeekNum = lstContacts->GetItemData(intSelected);
912     
913     wxFFile ContactFile;
914     wxString wxSContactString;
915     wxString ContactLine;
916     vCard Person;
917     
918     size_t ContactLineLen;
919     bool ExtraLineSeek = FALSE;
920     int QuoteBreakPoint = 0;
921     
922     bool PropertyFind = FALSE;
923     bool QuoteMode = FALSE;
924     
925     wxString wxSPropertyNextLine;
926     wxString wxSProperty;
927     wxString wxSPropertySeg1;
928     wxString wxSPropertySeg2;
929     
930     // Check if we are using wxWidgets version 2.8 or less and
931     // execute the required command accordingly.
932     
933 #if wxABI_VERSION < 20900
934     ContactFile.Open(ContactsFileIndex[ContactSeekNum].c_str(), wxT("r"));
935 #else
936     ContactFile.Open(ContactsFileIndex[ContactSeekNum], wxT("r"));
937 #endif
938     
939     if (ContactFile.IsOpened() == FALSE){
940         
941         return;
942         
943     }
944     
945     ContactFile.ReadAll(&wxSContactString, wxConvAuto());
946     
947     // Split the lines.
948     
949     std::map<int, wxString> ContactFileLines;
950     std::map<int, wxString>::iterator striter;
951     
952     wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
953     
954     int ContactLineSeek = 0;
955     
956     while (wSTContactFileLines.HasMoreTokens() == TRUE){
957         
958         ContactLine = wSTContactFileLines.GetNextToken();
959         ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
960         ContactLineSeek++;
961         
962     }
963     
964     if (ContactSeekNum < 0){
965         return;
966     }
967     
968     for (std::map<int, wxString>::iterator iter = ContactFileLines.begin();
969          iter != ContactFileLines.end(); ++iter){
970         
971         // Find the colon which splits the start bit from the data part.
972         
973         ContactLine = iter->second;
974         
975         while (ExtraLineSeek == TRUE){
976             
977             // Check if there is extra data on the next line
978             // (indicated by space or tab at the start) and add data.
979             
980             iter++;
981             
982             if (iter == ContactFileLines.end()){
983                 
984                 iter--;
985                 break;
986                 
987             }
988             
989             wxSPropertyNextLine = iter->second;
990             
991             
992             if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
993                 
994                 wxSPropertyNextLine.Remove(0, 1);
995                 //wxSPropertyNextLine.Trim(FALSE);
996                 //ContactLine.Trim();
997                 ContactLine.Append(wxSPropertyNextLine);
998                 
999             } else {
1000                 
1001                 iter--;
1002                 ExtraLineSeek = FALSE;
1003                 
1004             }
1005             
1006         }
1007         
1008         ContactLineLen = ContactLine.Len();
1009         
1010         // Make sure we are not in quotation mode.
1011         // Make sure colon does not have \ or \\ before it.
1012         
1013         for (int i = 0; i <= ContactLineLen; i++){
1014             
1015             if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
1016                 
1017                 PropertyFind = FALSE;
1018                 
1019             } else if (PropertyFind == TRUE){
1020                 
1021                 wxSProperty.Append(ContactLine.Mid(i, 1));
1022                 
1023             }
1024             
1025             if (ContactLine.Mid(i, 1) == wxT("\"")){
1026                 
1027                 if (QuoteMode == TRUE){
1028                     
1029                     QuoteMode = FALSE;
1030                     
1031                 } else {
1032                     
1033                     QuoteMode = TRUE;
1034                     
1035                 }
1036                 
1037             }
1038             
1039             if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
1040                 
1041                 QuoteBreakPoint = i;
1042                 break;
1043                 
1044             }
1045             
1046         }
1047         
1048         // Split that line at the point into two variables (ignore the colon).
1049         
1050         wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
1051         wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
1052         
1053         // Insert both into the vCard data file.
1054         
1055         Person.AddRaw(wxSPropertySeg1, wxSPropertySeg2);
1056         
1057         QuoteMode = FALSE;
1058         PropertyFind = TRUE;
1059         ExtraLineSeek = TRUE;
1060         ContactLineLen = 0;
1061         QuoteBreakPoint = 0;
1062         ContactLine.Clear();
1063         wxSProperty.Clear();
1064         
1065     }
1066     
1067     OldSessionID = SessionID;
1068     SessionID = wxString::Format(wxT("%i"), rand() % 32768);
1069     LoadContactData(&Person, htmContactData, SessionID, OldSessionID, &MemoryFileList);
1070     ActiveFilename = ContactsFileIndex[ContactSeekNum];
1071     
1074 void frmMain::ShowContactEditorNew( wxCommandEvent& event )
1076     
1077     // Check if there is an account selected and if not
1078     // return immediately.
1079     
1080     if (ActiveAccount.IsEmpty()){
1081         
1082         return;
1083         
1084     }
1085     
1086     // Add Pointer to SetupPointers for the ETagDB.
1087     
1088     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1089     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1090     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1091     wxIcon contacticon;
1092     contacticon.CopyFromBitmap(contacticonbmp);
1093     
1094     frmContactEditor *ContactEditor = new frmContactEditor( this );
1095     
1096     WindowMenuItemID++;
1097     
1098     ContactEditor->SetUID(WindowMenuItemID);
1099     
1100     WindowData *WData = new WindowData;
1101     
1102     WData->DataType = 1;
1103     WData->WindowPointer = (void*)ContactEditor;
1104     WData->WindowID = WindowMenuItemID;
1105     
1106     wxCommandEvent addevent(WINDOW_ADD);
1107     addevent.SetClientData(WData);
1108     wxPostEvent(this, addevent);
1109     
1110     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1111     ContactEditor->SetupHeaders();
1112     ContactEditor->SetupContact(ActiveAccount);
1113     ContactEditor->SetIcon(contacticon);
1114     ContactEditor->SetupPointers(frameActMgr, &ETagProcTimer, this);
1115     ContactEditor->Show(true);
1116     
1119 void frmMain::ShowContactEditorEdit( wxCommandEvent& event )
1121     
1122     // Check if there is an account selected and if not
1123     // return immediately.
1124     
1125     int DataCheck = event.GetInt();
1126     
1127     if (ActiveAccount.IsEmpty() && DataCheck == 0){
1128         
1129         return;
1130         
1131     }
1132     
1133     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1134     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1135     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1136     wxIcon contacticon;
1137     contacticon.CopyFromBitmap(contacticonbmp);
1138     
1139     // Check if a contact has been selected.
1140     
1141     long intSelected = -1;
1142     long intContactSeekNum = -1;
1143     
1144     //    intSelected = lstContacts->GetSelection();
1145     
1146     intSelected = lstContacts->GetNextItem(intSelected,
1147                                            wxLIST_NEXT_ALL,
1148                                            wxLIST_STATE_SELECTED);
1149     
1150     if (intSelected == -1){
1151         return;
1152     }
1153     
1154     intContactSeekNum = lstContacts->GetItemData(intSelected);
1155     
1156     // Get the filename of the selected contact.
1157     
1158     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1159     frmContactEditor *ContactEditor = new frmContactEditor( this );
1160     
1161     WindowMenuItemID++;
1162     
1163     ContactEditor->SetUID(WindowMenuItemID);
1164     
1165     WindowData *WData = new WindowData;
1166     
1167     WData->DataType = 1;
1168     WData->WindowPointer = (void*)ContactEditor;
1169     WData->WindowID = WindowMenuItemID;
1170     
1171     wxCommandEvent addevent(WINDOW_ADD);
1172     addevent.SetClientData(WData);
1173     wxPostEvent(this, addevent);
1174     
1175     ContactEditor->SetupPointers(frameActMgr, &ETagProcTimer, this);
1176     ContactEditor->SetupHeaders();
1177     
1178     // Check if pointer is NULL (not from the search forms) or not.
1179     
1180     if (DataCheck == 0){
1181         
1182         ContactEditor->LoadContact(ContactsFileIndex[intContactSeekNum]);
1183         ContactEditor->SetupContact(ActiveAccount);
1184         
1185     } else {
1186         
1187         UCNotif *uc = (UCNotif*)event.GetClientData();
1188         
1189         if (!uc){
1190             
1191             ContactEditor->SetupContact(ActiveAccount);
1192             ContactEditor->LoadContact(ContactsFileIndex[intContactSeekNum]);
1193             
1194         } else {
1195             
1196             ContactEditor->SetupContact(uc->ContactAccount);
1197             ContactEditor->LoadContact(uc->ContactFilename);
1198             
1199             delete uc;
1200             uc = NULL;
1201             
1202             
1203         }
1204         
1205     }
1206     
1207     ContactEditor->SetIcon(contacticon);
1208     ContactEditor->Show(true);
1209     
1212 void frmMain::RefreshAddressBook( wxCommandEvent& event ){
1213     
1214     // TODO: Check Account Type.
1215     
1216     if (!ActiveAccount.IsEmpty()){
1217         
1218         frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1219         frameActMgr->AddTask(3, wxT(""), ActiveAccount,
1220                              wxT(""), wxT(""), wxT(""), wxT(""));
1221         
1222     }
1223     
1226 void frmMain::OpenContactInfo( wxListEvent& event )
1228     
1229     wxStringTokenizer vcardfileline;
1230     std::string l;
1231     wxString lwxs;
1232     wxString setname, setvalue;
1233     vCard Person;
1234     wxString nextchar;
1235     
1236     long intSelected = -1;
1237     long intContactSeekNum = -1;
1238     
1239     intSelected = lstContacts->GetNextItem(intSelected,
1240                                            wxLIST_NEXT_ALL,
1241                                            wxLIST_STATE_SELECTED);
1242     
1243     intContactSeekNum = lstContacts->GetItemData(intSelected);
1244     
1245     if (intContactSeekNum == -1){
1246         return;
1247     }
1248     
1249     Person.LoadFile(ContactsFileIndex[intContactSeekNum]);
1250     
1251     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1252     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1253     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1254     wxIcon contacticon;
1255     contacticon.CopyFromBitmap(contacticonbmp);
1256     
1257     frmContact *Contact = new frmContact( this );
1258     
1259     // Add to window list.
1260     
1261     WindowMenuItemID++;
1262     
1263     Contact->SetUID(WindowMenuItemID);
1264     
1265     WindowData *WData = new WindowData;
1266     
1267     WData->DataType = 0;
1268     WData->WindowPointer = (void*)Contact;
1269     WData->WindowID = WindowMenuItemID;
1270     
1271     wxCommandEvent addevent(WINDOW_ADD);
1272     addevent.SetClientData(WData);
1273     wxPostEvent(this, addevent);
1274     
1275     Contact->SetupPointers(&MemoryFileList);
1276     Contact->SetupContactData(&Person);
1277     
1278     Contact->SetIcon(contacticon);
1279     Contact->Show(true);
1280     
1283 void frmMain::OpenContactInfo( wxCommandEvent& event )
1285     
1286     UCNotif *uc = (UCNotif*)event.GetClientData();
1287     
1288     wxStringTokenizer vcardfileline;
1289     std::string l;
1290     wxString lwxs;
1291     wxString setname, setvalue;
1292     vCard Person;
1293     wxString nextchar;
1294     //std::fstream vcardfile;
1295     
1296     Person.LoadFile(uc->ContactFilename);
1297     
1298     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1299     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1300     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1301     wxIcon contacticon;
1302     contacticon.CopyFromBitmap(contacticonbmp);
1303     
1304     frmContact *Contact = new frmContact( this );
1305     
1306     // Add to window list.
1307     
1308     WindowMenuItemID++;
1309     
1310     Contact->SetUID(WindowMenuItemID);
1311     
1312     WindowData *WData = new WindowData;
1313     
1314     WData->DataType = 0;
1315     WData->WindowPointer = (void*)Contact;
1316     WData->WindowID = WindowMenuItemID;
1317     
1318     wxCommandEvent addevent(WINDOW_ADD);
1319     addevent.SetClientData(WData);
1320     wxPostEvent(this, addevent);
1321     
1322     Contact->SetupPointers(&MemoryFileList);
1323     Contact->SetupContactData(&Person);
1324     
1325     Contact->SetIcon(contacticon);
1326     Contact->Show(true);
1327     
1331 void frmMain::LoadPreferences( wxActivateEvent& event)
1333     this->LoadPreferences();
1336 void frmMain::LoadPreferences(){
1337     
1338     // Load the preferences.
1339     
1340     wxString preffilename = GetUserPrefDir();
1341     
1342     XABPreferences preferences(preffilename);
1343     
1344     // Setup the main window position (if needed).
1345     
1346     bool SaveWindowPos = preferences.GetBoolData(wxT("SaveWindowPosition"));
1347     bool HideLocalABs = preferences.GetBoolData(wxT("HideLocalAddressBooks"));
1348     
1349     if (SaveWindowPos == TRUE){
1350         
1351         this->SetSize(preferences.GetMainWindowData());
1352         
1353     }
1354     
1355     treAccounts->DeleteAllItems();
1356     
1357     wxTreeItemId RootNode = treAccounts->AddRoot(wxT("Root Item"), AccountNoneID);
1358     
1359     // Stop all account timers and remove the accounts.
1360     
1361     for (std::map<wxString, wxAccountSyncTimer*>::iterator iter = AccountSyncTimers.begin();
1362          iter != AccountSyncTimers.end(); iter++){
1363         
1364         wxAccountSyncTimer *AccTmrPtr = iter->second;
1365         AccTmrPtr->Stop();
1366         
1367         delete AccTmrPtr;
1368         AccTmrPtr = NULL;
1369         
1370     }
1371     
1372     AccountSyncTimers.clear();
1373     
1374     /*
1375      for (int i = (preferences.accounts.GetCount() - 1); i > 0; --i){
1376      treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i));
1377      }
1378      */
1379     
1380     wxString AccDir;
1381     wxString AccDirFull;
1382     wxString AccDirFullSfx;
1383     wxString AccName;
1384     wxString AccDirFinal;
1385     AccountAccDirList.clear();
1386     AccountGroupList.clear();
1387     AccountGroupFilename.clear();
1388     AccountGroupTreeId.clear();
1389     wxTreeItemId AccountTreeId;
1390     wxTreeItemId GroupTreeId;
1391     int intGroupID = 0;
1392     
1393     for (int i = 0; i < preferences.accounts.GetCount(); i++){
1394         
1395         if ((preferences.accounts.GetAccountType(i) == wxT("Local") ||
1396              preferences.accounts.GetAccountType(i) == wxT("local")) && HideLocalABs == TRUE){
1397             
1398             continue;
1399             
1400         }
1401         
1402         if (preferences.accounts.GetAccountDirectory(i).IsEmpty()){
1403             
1404             continue;
1405             
1406         }
1407         
1408         AccDir = preferences.accounts.GetAccountDirectory(i);
1409         AccDirFull = preferences.accounts.GetAccountDirectory(i);
1410         AccDirFull.Trim();
1411         AccDirFull.Append(wxT("."));
1412         AccDirFullSfx.Append(preferences.accounts.GetAccountType(i));
1413         AccDirFullSfx.LowerCase();
1414         AccDirFullSfx.Trim();
1415         AccDirFull.Append(AccDirFullSfx);
1416         AccName = preferences.accounts.GetAccountName(i);
1417         AccName.Trim();
1418         AccountAccDirList.insert(std::make_pair(i, AccDirFull));
1419         
1420         if (preferences.accounts.GetAccountType(i) == wxT("CardDAV") ||
1421             preferences.accounts.GetAccountType(i) == wxT("carddav")){
1422             
1423             // Check if the directory exists before doing anything.
1424             
1425             
1426             
1427             // Add a new timer using the existing account details.
1428             
1429             wxAccountSyncTimer *ActTmrPtr = new wxAccountSyncTimer;
1430             
1431             ActTmrPtr->SetupData(AccDirFull, AccName);
1432             ActTmrPtr->SetupPointers(this, ActMgrPtr, ETagProcTimer.GetPointer(AccDirFull));
1433             ActTmrPtr->Start((int)(preferences.accounts.GetAccountRefresh(i) * 1000));
1434             ActTmrPtr->SetOwner(this);
1435             ActTmrPtr->Notify();
1436             
1437             // Add the timer to the list of timers.
1438             
1439             AccountSyncTimers.insert(std::make_pair(AccDirFull, ActTmrPtr));
1440             
1441             AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountNetID, -1);
1442             
1443         } else {
1444             
1445             AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountID, -1);
1446             
1447         }
1448         
1449         // Go through the account directory and find contact files with
1450         // 'KIND:group' set and add them to the list of groups for the account.
1451         
1452         AccDirFinal = GetAccountDir(AccDirFull, FALSE);
1453         
1454         wxDir vcardaccdir(AccDirFinal);
1455         
1456         wxString vCardFilename;
1457         wxString vCardDataString;
1458         wxString vCardFilenameFull;
1459         //bool ProcFiles = FALSE;
1460         
1461         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
1462         while(ProcFiles){
1463             
1464             if (vCardFilename.Right(4) == wxT(".vcf") ||
1465                 vCardFilename.Right(4) == wxT(".VCF") ||
1466                 vCardFilename.Right(5) == wxT(".vcard") ||
1467                 vCardFilename.Right(5) == wxT(".VCARD")){
1468                 
1469                 vCard Person;
1470                 
1471                 vCardFilenameFull.Append(AccDirFinal);
1472                 vCardFilenameFull.Append(wxT("/"));
1473                 vCardFilenameFull.Append(vCardFilename);
1474                 
1475                 Person.LoadFile(vCardFilenameFull);
1476                 
1477                 if (Person.MeetBaseSpecification()){
1478                     
1479                     vCardDataString = Person.Get(wxT("KIND"));
1480                     
1481                     if (vCardDataString == wxT("group")){
1482                         
1483                         // The vCard kind is a group. Add to the account's group list.
1484                         
1485                         GroupTreeId = treAccounts->AppendItem(AccountTreeId, Person.Get(wxT("FN")), AccountGrpID, -1);
1486                         treAccounts->SetItemHasChildren(AccountTreeId, TRUE);
1487                         AccountGroupList.insert(std::make_pair(intGroupID, i));
1488                         AccountGroupFilename.insert(std::make_pair(intGroupID, vCardFilenameFull));
1489                         AccountGroupTreeId.insert(std::make_pair(GroupTreeId, intGroupID));
1490                         
1491                     }
1492                     
1493                     intGroupID++;
1494                     
1495                 } else {
1496                     
1497                 }
1498                 
1499             }
1500             
1501             vCardFilename.Clear();
1502             vCardFilenameFull.Clear();
1503             vCardDataString.Clear();
1504             ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1505             
1506         }
1507         
1508         // Clearup for next account.
1509         
1510         AccDir.clear();
1511         AccDirFull.clear();
1512         AccDirFullSfx.clear();
1513         AccDirFinal.clear();
1514         AccName.clear();
1515         
1516     }
1517     
1518     // Load the account settings as they are needed for connecting
1519     // to the servers.
1520     
1521     prefaccounts = preferences.accounts;
1522     
1525 void frmMain::ConflictResolution(wxCommandEvent& event){
1526     
1527     frmConflictResolution *frameCR = new frmConflictResolution ( this );
1528     vCardConflictObj *vCardConfObj = (vCardConflictObj*)event.GetClientData();
1529     vCard *ClientDataPtr = vCardConfObj->vCardLocalData;
1530     vCard *ServerDataPtr = vCardConfObj->vCardServerData;
1531     //vCard *ServerDataPtr = vCardConfObj->vCardServerData;
1532     //wxString Moo = ClientDataPtr->WriteString();
1533     //vCard *ServerDataPtr = vCardConfObj->vCardServerData;
1534     frameCR->LoadData(ClientDataPtr, ServerDataPtr, &MemoryFileList);
1535     //frameCR->LoadData(vCardConfObj->vCardLocalData, vCardConfObj->vCardServerData, &MemoryFileList);
1536     frameCR->ShowModal();
1537     
1538     int FinalConflictResult = frameCR->GetResult();
1539     
1540     wxCommandEvent event2(ACTMGR_RESUMEPROC);
1541     event2.SetClientData(vCardConfObj->QRNotifData);
1542     event2.SetInt(FinalConflictResult);
1543     
1544     delete frameCR;
1545     frameCR = NULL;
1546     
1547     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1548     wxPostEvent(frameActMgr, event2);
1549     
1552 void frmMain::UpdateContactList(wxCommandEvent& event){
1553     
1554     UCNotif *ucd = (UCNotif*)event.GetClientData();
1555     
1556     // Check if the active account is being displayed in the
1557     // main window. If not, skip and delete the data.
1558     
1559     long longSelected = -1;
1560     int intSelectedData = 0;
1561     
1562     if (ActiveAccount == ucd->ContactAccount){
1563         
1564         // Look at the list of contacts and if it matches the
1565         // filename then update the name.
1566         
1567         for (;;){
1568             
1569             longSelected = lstContacts->GetNextItem(longSelected,
1570                                                     wxLIST_NEXT_ALL,
1571                                                     wxLIST_STATE_DONTCARE);
1572             
1573             if (longSelected == -1){
1574                 
1575                 break;
1576                 
1577             }
1578             
1579             intSelectedData = (int)lstContacts->GetItemData(longSelected);
1580             
1581             if (ucd->ContactFilename == ContactsFileIndex[intSelectedData]){
1582                 
1583                 // Work out which sorting mode we are in.
1584                 
1585                 if (SortMode == 1){
1586                     
1587                     // First Name, Last Name.
1588                     
1589                     lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Forename + wxT(" ") + ucd->ContactNameArray.Surname);
1590                     
1591                 } else if (SortMode == 2){
1592                     
1593                     // Last Name, First Name.
1594                     
1595                     lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Surname + wxT(", ") + ucd->ContactNameArray.Forename);
1596                     
1597                 } else if (SortMode == 3){
1598                     
1599                     // Nickname.
1600                     
1601                     lstContacts->SetItem(longSelected, 0, ucd->ContactNickname);
1602                     
1603                 } else if (SortMode == 4){
1604                     
1605                     // Display As.
1606                     
1607                     lstContacts->SetItem(longSelected, 0, ucd->ContactName);
1608                     
1609                 }
1610                 
1611                 
1612             }
1613             
1614             // If the filename is the one loaded into the
1615             // browser control, then update this too.
1616             
1617             if (ActiveFilename == ContactsFileIndex[intSelectedData]){
1618                 
1619                 wxListEvent nullevent;
1620                 ShowContactInfo(nullevent);
1621                 
1622             }
1623             
1624         }
1625         
1626     }
1627     
1628     for (std::map<int, void*>::iterator WindowIter = WindowListPointers.begin();
1629          WindowIter != WindowListPointers.end(); WindowIter++){
1630         
1631         if (WindowListType[WindowIter->first] != 0){
1632             
1633             continue;
1634             
1635         }
1636         
1637         frmContact *frmContactPtr = static_cast<frmContact*>(WindowIter->second);
1638         
1639         if (frmContactPtr->GetFilename() == ucd->ContactFilename){
1640             
1641             vCard UpdatedPerson;
1642             UpdatedPerson.LoadFile(ucd->ContactFilename);
1643             frmContactPtr->SetupContactData(&UpdatedPerson);
1644             
1645         }
1646         
1647     }
1648     
1649     // Send message to search window controller subroutine and
1650     // pass that notification onto the search windows.
1651     
1652     // Setup the new pointer to use the existing UCNotif without
1653     // deleting it.
1654     
1655     UCNotif *ucd2 = ucd;
1656     
1657     wxCommandEvent sup(SE_UPDATECONTACTNOTIF);
1658     sup.SetClientData(ucd2);
1659     wxPostEvent(this, sup);
1660     
1661     // Clear up the unused pointer.
1662     
1663     ucd = NULL;
1664     
1667 void frmMain::UpdateAccountList(wxCommandEvent& event){
1668     
1671 void frmMain::SetupPointers(void *ActMgrPtrInc){
1672     
1673     ActMgrPtr = ActMgrPtrInc;
1674     
1677 void frmMain::SetupForm(){
1678     
1679     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1680     frameActMgr->SetupPointers(&ETagProcTimer, this);
1681     
1682     // Setup the contact information icons for later.
1683     
1684     wxFileSystem::AddHandler(new wxMemoryFSHandler);
1685     wxImage ciicon_png;
1686     //wxBitmap ciicon;
1687     
1688     wxMemoryInputStream ciptostream(icons_cipto_png, sizeof(icons_cipto_png));
1689     ciicon_png.LoadFile(ciptostream, wxBITMAP_TYPE_PNG);
1690     wxMemoryFSHandler::AddFile(wxT("cipto.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1691     
1692     wxMemoryInputStream cilogstream(icons_cilog_png, sizeof(icons_cilog_png));
1693     ciicon_png.LoadFile(cilogstream, wxBITMAP_TYPE_PNG);
1694     wxMemoryFSHandler::AddFile(wxT("cilog.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1695     
1696     wxMemoryInputStream cisndstream(icons_cisnd_png, sizeof(icons_cisnd_png));
1697     ciicon_png.LoadFile(cisndstream, wxBITMAP_TYPE_PNG);
1698     wxMemoryFSHandler::AddFile(wxT("cisnd.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1699     
1700     wxMemoryInputStream cikeystream(icons_cikey_png, sizeof(icons_cikey_png));
1701     ciicon_png.LoadFile(cikeystream, wxBITMAP_TYPE_PNG);
1702     wxMemoryFSHandler::AddFile(wxT("cikey.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1703     
1704     wxMemoryInputStream civenstream(icons_civen_png, sizeof(icons_civen_png));
1705     ciicon_png.LoadFile(civenstream, wxBITMAP_TYPE_PNG);
1706     wxMemoryFSHandler::AddFile(wxT("civen.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1707     
1708     wxMemoryInputStream ciextstream(icons_ciext_png, sizeof(icons_ciext_png));
1709     ciicon_png.LoadFile(ciextstream, wxBITMAP_TYPE_PNG);
1710     wxMemoryFSHandler::AddFile(wxT("ciext.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1711     
1712     LoadPreferences();
1713     
1716 void frmMain::UpdateSearchContactLists(wxCommandEvent& event){
1717     
1718     // Go through each of the search windows and
1719     // send the required notification to update the
1720     // contact information.
1721     
1722     // Get the event notification data.
1723     
1724     UCNotif *ucd = (UCNotif*)event.GetClientData();
1725     
1726     // Process each search window giving the new details.
1727     
1728     for (std::map<void*,wxString>::iterator switer = SearchWindowList.begin();
1729          switer != SearchWindowList.end(); switer++){
1730         
1731         // Duplicate the event notification data.
1732         
1733         UCNotif *ucd2 = new UCNotif;
1734         
1735         ucd2->ContactAccount = ucd->ContactAccount;
1736         ucd2->ContactFilename = ucd->ContactFilename;
1737         ucd2->ContactName = ucd->ContactName;
1738         ucd2->ContactNickname = ucd->ContactNickname;
1739         ucd2->ContactNameArray = ucd->ContactNameArray;
1740         
1741         // Pass the data to the search window for processing.
1742         
1743         frmSearch *frameSCH = static_cast<frmSearch*>(switer->first);
1744         wxCommandEvent schupdate(SE_UPDATERESULT);
1745         schupdate.SetClientData(ucd2);
1746         wxPostEvent(frameSCH, schupdate);
1747         
1748         // Clear up the pointer prior to variable deletion.
1749         
1750         frameSCH = NULL;
1751         
1752     }
1753     
1754     delete ucd;
1755     ucd = NULL;
1756     
1759 void frmMain::OpenFindContactsWindow(wxCommandEvent& event){
1760     
1761     WindowMenuItemID++;
1762     
1763     frmSearch *frameSCH = new frmSearch ( this );
1764     frameSCH->SetUID(WindowMenuItemID);
1765     frameSCH->Show(true);
1766     
1767     WindowData *WData = new WindowData;
1768     
1769     WData->DataType = 2;
1770     WData->WindowPointer = (void*)frameSCH;
1771     WData->WindowID = WindowMenuItemID;
1772     
1773     wxCommandEvent addevent(WINDOW_ADD);
1774     addevent.SetClientData(WData);
1775     wxPostEvent(this, addevent);
1776     
1777     // Add pointer to the list of open search windows.
1778     
1779     SearchWindowList.insert(std::make_pair(frameSCH, wxT("Search")));
1780     
1781     WData = NULL;
1782     
1785 void frmMain::RemoveContactsWindowPointer(wxCommandEvent& event){
1786     
1787     //frmSearch *frameSCH = static_cast<frmSearch*>(ActMgrPtr);
1788     void *frameSCH = (void*)event.GetClientData();
1789     
1790     SearchWindowList.erase(frameSCH);
1791     
1792     frameSCH = NULL;
1793     
1796 void frmMain::RemoveContactEditorWindowPointer(wxCommandEvent& event){
1797     
1798     void *frameSCH = (void*)event.GetClientData();
1799     
1800     SearchWindowList.erase(frameSCH);
1801     
1802     frameSCH = NULL;
1803     
1806 void frmMain::UpdateWindowList(wxCommandEvent& event){
1807     
1808     // Update the Window List.
1809     
1810     // Delete the existing items in the window menu.
1811     
1812     // Get the list of contacts.
1813     
1814     // Insert a separator.
1815     
1816     // Get the list of search windows.
1817     
1820 void frmMain::RevealContact(wxCommandEvent& event){
1821     
1822     UCNotif *uc = (UCNotif*)event.GetClientData();
1823     
1824     // Switch the account to the one passed.
1825     
1826     wxTreeItemIdValue cookie;
1827     wxTreeItemId next = treAccounts->GetRootItem();
1828     wxTreeItemId nextChild;
1829     
1830     for (int i = 0; i < prefaccounts.GetCount(); i++){
1831         
1832         if (!nextChild){
1833             nextChild = treAccounts->GetFirstChild(next, cookie);
1834         } else {
1835             nextChild = treAccounts->GetNextSibling(nextChild);
1836         }
1837         
1838         //AccountName = treAccounts->GetItemText(nextChild);
1839         
1840         if (uc->ContactAccount == AccountAccDirList[i]){
1841             
1842             //AccControl->();
1843             treAccounts->SelectItem(nextChild, TRUE);
1844             AccCtrl->SetText(treAccounts->GetItemText(nextChild));
1845             
1846         }
1847         
1848     }
1849     
1850     // Switch the contact to the one passed.
1851     
1852     long longSelected = -1;
1853     int intSelectedData = 0;
1854     
1855     for (;;){
1856         
1857         longSelected = lstContacts->GetNextItem(longSelected,
1858                                                 wxLIST_NEXT_ALL,
1859                                                 wxLIST_STATE_DONTCARE);
1860         
1861         if (longSelected == -1){
1862             
1863             break;
1864             
1865         }
1866         
1867         intSelectedData = (int)lstContacts->GetItemData(longSelected);
1868         
1869         // Compare the filename with the one received.
1870         // If they match then select it.
1871         
1872         if (ContactsFileIndex[intSelectedData] == uc->ContactFilename){
1873             
1874             // Select.
1875             
1876             lstContacts->SetItemState(longSelected, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
1877             lstContacts->EnsureVisible(longSelected);
1878             
1879             break;
1880             
1881         }
1882         
1883     }
1884     
1887 void frmMain::DeleteContact(wxCommandEvent& event){
1888     
1889     // Check if a contact is selected.
1890     
1891     long intSelected = -1;
1892     long intContactSeekNum = -1;
1893     wxString wxSContactName;
1894     
1895     intSelected = lstContacts->GetNextItem(intSelected,
1896                                            wxLIST_NEXT_ALL,
1897                                            wxLIST_STATE_SELECTED);
1898     
1899     if (intSelected == -1){
1900         return;
1901     }
1902     
1903     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1904     
1905     // Get the item data of the contact.
1906     
1907     intContactSeekNum = lstContacts->GetItemData(intSelected);
1908     
1909     // Get the name of the contact.
1910     
1911     wxSContactName = lstContacts->GetItemText(intSelected);
1912     
1913     // Display a message confirming if the contact should
1914     // be deleted.
1915     
1916     int QuestionResponse;
1917     
1918     QuestionResponse = wxMessageBox(_("Are you sure you want to delete this contact?"), _("Delete contact"), wxYES_NO, this);
1919     
1920     if (QuestionResponse == wxNO){
1921         
1922         // Exit the subroutine
1923         
1924         return;
1925         
1926     }
1927     
1928     // Delete the contact.
1929     
1930     if (!wxRemoveFile(ContactsFileIndex[intContactSeekNum])){
1931         
1932         wxMessageBox(_("Unable to delete the contact."), _("Cannot delete contact"), wxOK, this);
1933         return;
1934         
1935     }
1936     
1937     // Remove the contact from the list.
1938     
1939     lstContacts->DeleteItem(intSelected);
1940     
1941     // Update the search windows, removing the deleted
1942     // contact.
1943     
1944     UCNotif *ucd = new UCNotif;
1945     
1946     ucd->ContactAccount = ActiveAccount;
1947     ucd->ContactFilename = ContactsFileIndex[intContactSeekNum];
1948     
1949     for (std::map<void*,wxString>::iterator switer = SearchWindowList.begin();
1950          switer != SearchWindowList.end(); switer++){
1951         
1952         // Duplicate the event notification data.
1953         
1954         UCNotif *ucd2 = new UCNotif;
1955         
1956         ucd2->ContactAccount = ucd->ContactAccount;
1957         ucd2->ContactFilename = ucd->ContactFilename;
1958         
1959         // Pass the data to the search window for processing.
1960         
1961         frmSearch *frameSCH = static_cast<frmSearch*>(switer->first);
1962         wxCommandEvent schdelete(SE_DELETERESULT);
1963         schdelete.SetClientData(ucd2);
1964         wxPostEvent(frameSCH, schdelete);
1965         
1966         // Clear up the pointer prior to variable deletion.
1967         
1968         frameSCH = NULL;
1969         ucd2 = NULL;
1970         
1971     }
1972     
1973     // Clear the wxHTMLWindow.
1974     
1975     wxString EmptyPage = wxT("");
1976     
1977     htmContactData->SetPage(EmptyPage);
1978     
1979     wxStringTokenizer wSTFilename(ContactsFileIndex[intContactSeekNum], wxT("/"));
1980     
1981     wxString wxSplitFilename;
1982     wxString wxSDataURL;
1983     
1984     while(wSTFilename.HasMoreTokens()){
1985         
1986         wxSplitFilename = wSTFilename.GetNextToken();
1987         
1988     }
1989     
1990     if (ActiveAccountType == wxT("CardDAV") || ActiveAccountType == wxT("carddav")){
1991         
1992         // Update the ETagDB and mark it as deleted.
1993         
1994         ETagDB *ETagDBPtr = ETagProcTimer.GetPointer(ActiveAccount);
1995         
1996         ETagDBPtr->UpdateETag(wxSplitFilename, wxT("DELETED"));
1997         
1998         // Get the Data URL.
1999         
2000         wxTreeItemIdValue cookie;
2001         wxTreeItemId next = treAccounts->GetRootItem();
2002         
2003         wxTreeItemId selectedChild = treAccounts->GetSelection();
2004         wxTreeItemId nextChild;
2005         
2006         for (int i = 0; i < prefaccounts.GetCount(); i++){
2007             
2008             if (!nextChild){
2009                 nextChild = treAccounts->GetFirstChild(next, cookie);
2010             }
2011             else {
2012                 nextChild = treAccounts->GetNextSibling(nextChild);
2013             }
2014             
2015             if (nextChild == selectedChild){
2016                 wxSDataURL = prefaccounts.GetAccountDirPrefix(i) + wxT("/") + wxSplitFilename;
2017                 
2018             }
2019             
2020         }
2021         
2022         // Add task to the activity monitor to delete the contact.
2023         
2024         frameActMgr->AddTask(2, wxSContactName, ActiveAccount, wxSDataURL, wxSplitFilename, ContactsFileIndex[intContactSeekNum], wxT(""));
2025         
2026     }
2027     
2028     // Clear the variable. Don't delete as it will mess things up.
2029     
2030     ContactsFileIndex[intContactSeekNum] = wxT("");
2031     
2032     delete ucd;
2033     ucd = NULL;
2034     
2037 void frmMain::EmptyServerDialog(wxCommandEvent& event){
2038     
2039     QRNotif *qrn = (QRNotif *)event.GetClientData();
2040     
2041     int QResponse = wxMessageBox(_("The list of contacts on the server is empty. Upload all locally stored contacts for this account now?"), _("No contacts on server"), wxYES_NO, this);
2042     
2043     if (QResponse == wxNO){
2044         
2045         return;
2046     
2047     }
2048     
2049     wxCommandEvent event2(ACTMGR_RESUMEPROC);
2050     event2.SetInt(*qrn->QResponse);
2051     event2.SetClientData(qrn->PausePtr);
2052     
2053     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
2054     
2055     wxPostEvent(frameActMgr, event2);
2056     
2059 void frmMain::DeleteContactSync(wxString &Account, wxString &Filename){
2060     
2061     // Remove the contact from the window after syncronising.
2062     
2063     // Check which account is currently active in the window.
2064     // If it is different from the one passed to this subroutine then
2065     // exit from the subroutine.
2066     
2067     if (Account != ActiveAccount){
2068         return;
2069     }
2070     
2071     long longSelected = -1;
2072     int intSelectedData = 0;
2073     
2074     for (;;){
2075         
2076         longSelected = lstContacts->GetNextItem(longSelected,
2077                                                 wxLIST_NEXT_ALL,
2078                                                 wxLIST_STATE_DONTCARE);
2079         
2080         if (longSelected == -1){
2081             
2082             break;
2083             
2084         }
2085         
2086         intSelectedData = (int)lstContacts->GetItemData(longSelected);
2087         
2088         // Compare the filename with the one received.
2089         // If they match then select it.
2090         
2091         if (ContactsFileIndex[intSelectedData] == Filename){
2092             
2093             // Remove the contact from the window.
2094             
2095             lstContacts->DeleteItem(intSelectedData);
2096             
2097             // Check if contact is the selected contact in the HTML window and
2098             // if it is then clear the window.
2099             
2100             if (ActiveFilename == Filename){
2101                 
2102                 wxString EmptyPage = wxT("");
2103                 htmContactData->SetPage(EmptyPage);
2104                 
2105             }
2106             
2107             break;
2108             
2109         }
2110         
2111     }
2112     
2117 void frmMain::SortFNLN( wxCommandEvent& event ) {
2118     
2119     wxTreeEvent NullEvent;
2120     SortMode = 1;
2121     LoadContactList(NullEvent);
2122     
2125 void frmMain::SortLNFN( wxCommandEvent& event ) {
2126     
2127     wxTreeEvent NullEvent;
2128     SortMode = 2;
2129     LoadContactList(NullEvent);
2130     
2133 void frmMain::SortNickname( wxCommandEvent& event ) {
2134     
2135     wxTreeEvent NullEvent;
2136     SortMode = 3;
2137     LoadContactList(NullEvent);
2138     
2141 void frmMain::SortDisplayAs( wxCommandEvent& event ) {
2142     
2143     wxTreeEvent NullEvent;
2144     SortMode = 4;
2145     LoadContactList(NullEvent);
2146     
2149 void frmMain::SortAscending( wxCommandEvent& event ) {
2150     
2151     wxTreeEvent NullEvent;
2152     AscendingMode = TRUE;
2153     LoadContactList(NullEvent);
2154     
2157 void frmMain::SortDescending( wxCommandEvent& event ) {
2158     
2159     wxTreeEvent NullEvent;
2160     AscendingMode = FALSE;
2161     LoadContactList(NullEvent);
2162     
2165 void frmMain::ToggleStatusBar( wxCommandEvent& event ) {
2166     
2167     if (stbBottom->IsShown() == TRUE){
2168         
2169         stbBottom->Hide();
2170         
2171     } else {
2172         
2173         stbBottom->Show();
2174         
2175     }
2176     
2177     this->Layout();
2178     
2181 void frmMain::ActivityIconStart( wxCommandEvent& event ){
2182     
2183     // Display the activity icon.
2184     
2185     imgActivityStatus->SetBitmap(*imgActIcon1);
2186     ActivityIconStatus = 0;
2187     
2190 void frmMain::ActivityIconShuffle( wxCommandEvent& event ){
2191     
2192     switch (ActivityIconStatus){
2193             
2194         case 0:
2195             imgActivityStatus->SetBitmap(*imgActIcon1);
2196             ActivityIconStatus = 1;
2197             break;
2198         case 1:
2199             imgActivityStatus->SetBitmap(*imgActIcon2);
2200             ActivityIconStatus = 2;
2201             break;
2202         case 2:
2203             imgActivityStatus->SetBitmap(*imgActIcon3);
2204             ActivityIconStatus = 3;
2205             break;
2206         case 3:
2207             imgActivityStatus->SetBitmap(*imgActIcon4);
2208             ActivityIconStatus = 0;
2209             break;
2210         default:
2211             ActivityIconStatus = 0;
2212             
2213     }
2214     
2217 void frmMain::ActivityIconStop( wxCommandEvent& event ){
2218     
2219     // Display the sleep icon.
2220     
2221     imgActivityStatus->SetBitmap(*imgActIconSleep);
2222     
2225 void frmMain::UpdateSBIconPlacement( wxSizeEvent& event ){
2226     
2227     if (imgConnStatus == 0 || imgSSLStatus == 0 || imgActivityStatus == 0){
2228         
2229         return;
2230         
2231     }
2232     
2233     wxRect rectOnline;
2234     wxRect rectSSL;
2235     wxRect rectActivity;
2236     stbBottom->GetFieldRect(1, rectOnline);
2237     stbBottom->GetFieldRect(2, rectSSL);
2238     stbBottom->GetFieldRect(3, rectActivity);
2239     
2240     imgConnStatus->Move(rectOnline.GetX(),rectOnline.GetY());
2241     imgSSLStatus->Move(rectSSL.GetX(),rectSSL.GetY());
2242     imgActivityStatus->Move(rectActivity.GetX(),rectActivity.GetY());
2243     
2246 XABViewMode frmMain::GetViewMode(){
2247     
2248     XABViewMode xvm;
2249     
2250     xvm.SortMode = SortMode;
2251     xvm.AscendingMode = AscendingMode;
2252     
2253     return xvm;
2254     
2257 void frmMain::WindowAdd( wxCommandEvent &event ){
2258     
2259     WindowData *WData = (WindowData*)event.GetClientData();
2260     
2261     size_t pos;
2262     
2263     if (WData->DataType == 0){
2264         
2265         // Contact Window
2266         
2267         int intID = mnuContactWindows->GetId();
2268         
2269         mnuWindow->FindChildItem(intID, &pos);
2270         wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, wxT("Contact Window #") + wxString::Format(wxT("%i"), WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2271         mnuNewItem->SetId(WData->WindowID);
2272         WindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2273         WindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2274         WindowListType.insert(std::make_pair(WData->WindowID, 0));
2275         mnuWindow->Insert((pos + 1), mnuNewItem);
2276         this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactWindow));
2277         
2278     } else if (WData->DataType == 1){
2279         
2280         // Contact Editor Window
2281         
2282         int intID = mnuContactEditorWindows->GetId();
2283         
2284         mnuWindow->FindChildItem(intID, &pos);
2285         wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, wxT("Contact Editor Window #") + wxString::Format(wxT("%i"), WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2286         mnuNewItem->SetId(WData->WindowID);
2287         WindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2288         WindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2289         WindowListType.insert(std::make_pair(WData->WindowID, 1));
2290         mnuWindow->Insert((pos + 1), mnuNewItem);
2291         this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactEditorWindow));
2292         
2293     } else if (WData->DataType == 2){
2294         
2295         // Search Window
2296         
2297         int intID = mnuSearchWindows->GetId();
2298         
2299         mnuWindow->FindChildItem(intID, &pos);
2300         wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, wxT("Search Window #") + wxString::Format(wxT("%i"), WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2301         mnuNewItem->SetId(WData->WindowID);
2302         WindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2303         WindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2304         WindowListType.insert(std::make_pair(WData->WindowID, 2));
2305         mnuWindow->Insert((pos + 1), mnuNewItem);
2306         this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowSearchWindow));
2307         
2308     }
2309     
2310     delete WData;
2311     WData = NULL;
2312     
2315 void frmMain::WindowEdit( wxCommandEvent &event ){
2316     
2317     WindowData *WData = (WindowData*)event.GetClientData();
2318     
2319     if (WData->DataType == 0){
2320         
2321         // Get the window title and use that.
2322         
2323         frmContact *frmContactPtr = static_cast<frmContact*>(WData->WindowPointer);
2324         
2325         wxString WindowTitle = frmContactPtr->GetTitle();
2326         
2327         std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID);
2328         
2329         MenuIter->second->SetItemLabel(WindowTitle);
2330         
2331         //mnuWindow->FindChildItem(intID, &pos);
2332         //wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, WindowTitle, WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2333         //mnuNewItem->SetId(WData->WindowID);
2334         //ContactWindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2335         //ContactWindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2336         //mnuWindow->Insert((pos + 1), mnuNewItem);
2337         //this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactWindow));
2338         
2339     } else if (WData->DataType == 1){
2340         
2341         // Get the window title and use that.
2342         
2343         frmContactEditor *frmCEPtr = static_cast<frmContactEditor*>(WData->WindowPointer);
2344         
2345         wxString WindowTitle = frmCEPtr->GetTitle();
2346         
2347         std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID);
2348         
2349         if (WindowTitle.IsEmpty()){
2350             
2351             MenuIter->second->SetItemLabel(_("Unnamed Contact"));
2352             
2353         } else {
2354             
2355             MenuIter->second->SetItemLabel(WindowTitle);
2356             
2357         }
2358         
2359         //mnuWindow->FindChildItem(intID, &pos);
2360         //wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, WindowTitle, WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2361         //mnuNewItem->SetId(WData->WindowID);
2362         //ContactEditorWindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2363         //ContactEditorWindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2364         //mnuWindow->Insert((pos + 1), mnuNewItem);
2365         //this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactEditorWindow));
2366         
2367     }
2368     
2369     delete WData;
2370     WData = NULL;
2371     
2374 void frmMain::WindowDelete( wxCommandEvent &event ){
2375     
2376     WindowData *WData = (WindowData*)event.GetClientData();
2377     
2378     std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID);
2379     
2380     mnuWindow->Remove(MenuIter->second);
2381     
2382     delete MenuIter->second;
2383     MenuIter->second = NULL;
2384     
2385     WindowListPointersMenu.erase(WData->WindowID);
2386     WindowListPointers.erase(WData->WindowID);
2387     WindowListType.erase(WData->WindowID);
2388     
2389     delete WData;
2390     WData = NULL;
2391     
2394 void frmMain::ShowContactWindow( wxCommandEvent &event ){
2395     
2396     std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
2397     
2398     frmContact *frmContactPtr = static_cast<frmContact*>(WindowIter->second);
2399     
2400     frmContactPtr->Show();
2401     frmContactPtr->Raise();
2402     
2405 void frmMain::ShowContactEditorWindow( wxCommandEvent &event ){
2406     
2407     std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
2408     
2409     frmContactEditor *frmCEPtr = static_cast<frmContactEditor*>(WindowIter->second);
2410     
2411     frmCEPtr->Show();
2412     frmCEPtr->Raise();
2413     
2416 void frmMain::ShowSearchWindow( wxCommandEvent &event ){
2417     
2418     // Look through the Search Window List Pointers, grab the
2419     // window point and show the window.
2420     
2421     std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
2422     
2423     frmSearch *frmSearchPtr = static_cast<frmSearch*>(WindowIter->second);
2424     
2425     frmSearchPtr->Show();
2426     frmSearchPtr->Raise();
2427     
2430 void frmMain::ToggleConnectionStatus( wxCommandEvent &event ){
2431     
2432     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
2433     wxCommandEvent toggconn(ACTMGR_TOGGLECONN);
2434     wxPostEvent(frameActMgr, toggconn);
2435     
2438 void frmMain::ShowSSLCertificates( wxCommandEvent &event ){
2439     
2440     // Check the account type before continuing.
2441     
2442     wxString SeekAccount;
2443     wxString AccTypeLower;
2444     wxString AccType;
2445     bool AccountSSL;
2446     std::map<int, SSLCertCollection>::iterator SSLColIter;
2447     
2448     for (int i = 0; i < prefaccounts.GetCount(); i++){
2449         
2450         SeekAccount.Append(prefaccounts.GetAccountDirectory(i));
2451         AccType.Append(prefaccounts.GetAccountType(i));
2452         AccountSSL = prefaccounts.GetAccountSSL(i);
2453         AccTypeLower = AccType.MakeLower();
2454         SeekAccount.Append(wxT("."));
2455         SeekAccount.Append(AccTypeLower);
2456         
2457         if (SeekAccount == ActiveAccount){
2458             
2459             if (AccTypeLower == wxT("local")){
2460                 
2461                 return;
2462                 
2463             }
2464             
2465             if (AccountSSL == false){
2466                 
2467                 return;
2468                 
2469             }
2470             
2471             SSLColIter = AccountSSLData.find(i);
2472             
2473             SSLCertCollection SSLCertInfo = SSLColIter->second;
2474             
2475             frmSSLCertificate *frameSSLCert = new frmSSLCertificate ( this );
2476             frameSSLCert->StartCertFrom(0);
2477             frameSSLCert->SetupCerts(SSLCertInfo);
2478             frameSSLCert->ShowModal();
2479             
2480             delete frameSSLCert;
2481             frameSSLCert = NULL;
2482             
2483         }
2484         
2485         SeekAccount.Clear();
2486         AccTypeLower.Clear();
2487         AccType.clear();
2488         
2489     }
2490     
2493 void frmMain::ShowSSLInfo( wxCommandEvent &event ){
2494     
2495     // Check the account type before continuing.
2496     
2499 void frmMain::HideSSLInfo( wxCommandEvent &event ){
2500     
2501     // Check the account type before continuing.
2502     
2505 void frmMain::UpdateConnectionStatus( wxCommandEvent &event ){
2506     
2507     if (event.GetInt() == 0){
2508         
2509         imgConnStatus->SetBitmap(*imgOnline);
2510         
2511     } else {
2512         
2513         imgConnStatus->SetBitmap(*imgOffline);
2514         
2515     }   
2516     
2519 void frmMain::SetupSSLStatus( int AccountID ){
2520     
2521     // Check if account ID given is
2522     // the active account and if not, do nothing.
2523     
2524     wxString AccType;
2525     wxString AccTypeLower;
2526     
2527     AccType = prefaccounts.GetAccountType(AccountID);
2528     AccTypeLower = AccType.MakeLower();
2529     
2530     wxString AccountIDName = prefaccounts.GetAccountDirectory(AccountID) + wxT(".") +
2531                                 AccTypeLower;
2532     
2533     if (AccountIDName != ActiveAccount){
2534         
2535         return;
2536         
2537     }
2538     
2539     // Check if the account has SSL enabled.
2540     
2541     bool SSLInUse = prefaccounts.GetAccountSSL(AccountID);
2542     
2543     if (SSLInUse == FALSE){
2544         
2545         SSLToolTip->SetTip(wxT("SSL is not enabled for this account"));
2546         imgSSLStatus->SetBitmap(*imgNoSSL);
2547         
2548     } else {
2549         
2550         // Get the SSL Collection Data.
2551         
2552         std::map<int,int>::iterator SSLResultIter = AccountSSLResult.find(AccountID);
2553         
2554         if (SSLResultIter->second == 1){
2555             
2556             imgSSLStatus->SetBitmap(*imgSSLWarning);
2557             SSLToolTip->SetTip(wxT("Invalid certificate(s) received for '") + 
2558                                prefaccounts.GetAccountName(AccountID) +
2559                                wxT("' (Connection denied by user)\n\nDouble click for more information."));
2560             
2561             
2562         } else if (SSLResultIter->second == 0){
2563             
2564             imgSSLStatus->SetBitmap(*imgSSL);
2565             SSLToolTip->SetTip(wxT("Account '") + 
2566                                prefaccounts.GetAccountName(AccountID) +
2567                                wxT("' secured using SSL\n\nDouble click for more information."));
2568             
2569         }
2570         
2571     }
2572     
2575 void frmMain::InvalidSSLCertificate( wxCommandEvent &event ){
2576     
2577     frmInvalidSSLCertificate *frameISC = new frmInvalidSSLCertificate ( this );
2578     SSLInvalidCertNotifObj *SSLICNObj = (SSLInvalidCertNotifObj*)event.GetClientData();
2579     SSLCertCollection SSLCCData = SSLICNObj->CertCollection;
2580     wxString AccountName = SSLICNObj->AccountName;
2581     frameISC->LoadData(SSLCCData, AccountName);
2582     frameISC->ShowModal();
2583     
2584     int FinalConflictResult = frameISC->GetResult();
2585     
2586     wxCommandEvent event2(ACTMGR_RESUMEPROC);
2587     event2.SetClientData(SSLICNObj->QRNotifData);
2588     event2.SetInt(FinalConflictResult);
2589     
2590     delete frameISC;
2591     frameISC = NULL;
2592     
2593     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);      
2594     wxPostEvent(frameActMgr, event2);
2597 void frmMain::PauseAllTimers(){
2598     
2599     for (std::map<wxString, wxAccountSyncTimer*>::iterator ASTiter = AccountSyncTimers.begin(); 
2600          ASTiter != AccountSyncTimers.end(); ASTiter++){
2601         
2602         ASTiter->second->Stop();
2603         
2604     }
2605     
2608 void frmMain::ResumeAllTimers(){
2609     
2610     for (std::map<wxString, wxAccountSyncTimer*>::iterator ASTiter = AccountSyncTimers.begin(); 
2611          ASTiter != AccountSyncTimers.end(); ASTiter++){
2612         
2613         ASTiter->second->Start();
2614         
2615     }
2616     
2619 void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollection SSLCertInc){
2620     
2621     // Delete existing data.
2622     
2623     AccountSSLData.erase(AccountID);
2624     AccountSSLResult.erase(AccountID);
2625     
2626     // Insert new data.
2627     
2628     AccountSSLData.insert(std::make_pair(AccountID, SSLCertInc));
2629     AccountSSLResult.insert(std::make_pair(AccountID, SSLStatus));
2630     
2633 void frmMain::CheckUpdates( wxCommandEvent& event ){
2634     
2635     frmUpdate *frameUpdate = new frmUpdate ( this );
2636     frameUpdate->FetchData();
2637     frameUpdate->ShowModal();
2638     
2641 void frmMain::OpenImportDialog( wxCommandEvent& event ){
2642     
2643     // Run the import contacts system.
2644     
2645     ImportRun(this);
2646     
2649 void frmMain::OpenExportDialog( wxCommandEvent& event ){
2650     
2651     // Check if an account and at least one contact is selected
2652     // before continuing.
2653     
2654     wxArrayString ArrData;
2655     
2656     if (ActiveAccount.IsEmpty()){
2657         
2658         return;
2659         
2660     }
2661     
2662     int ContactSelected = 0;
2663     int ContactsCollected = 0;
2664     long longSelected = -1;
2665     
2666     for (;;){
2667         
2668         longSelected = lstContacts->GetNextItem(longSelected, 
2669                                                 wxLIST_NEXT_ALL,
2670                                                 wxLIST_STATE_SELECTED);
2671         
2672         if (longSelected == -1){
2673             
2674             break;
2675             
2676         }
2677         
2678         int FileID = (int)lstContacts->GetItemData(longSelected);
2679         
2680         ArrData.Insert(ContactsFileIndex[FileID],
2681                        ContactsCollected, 1);
2682         
2683         ContactSelected++;
2684         
2685     }
2686     
2687     if (ContactSelected == 0){
2688         
2689         return;
2690         
2691     }
2692     
2693     // Run the export contacts system.
2694     
2695     ExportRun(this, &ArrData);
2696     
2699 void frmMain::GetListControl(wxListCtrl *lstContactsPtr, 
2700                              wxArrayString *ContactsFileIndexPtr){
2701     
2702     lstContactsPtr = lstContacts;
2703     ContactsFileIndexPtr = &ContactsFileIndex;
2704     
2707 void frmMain::GetSelectedList( wxCommandEvent& event ){
2708     
2709     // Get the array of contact filenames. 
2710     
2711     wxArrayString *ArrData = (wxArrayString*)event.GetClientData();
2712     
2713     // Process them into an array of files.     
2714     
2715     long longSelected = -1;
2716     int ContactsCollected = 0;
2717     wxString ContactFilename;
2718     
2719     for (;;){
2720         
2721         longSelected = lstContacts->GetNextItem(longSelected, 
2722                                                 wxLIST_NEXT_ALL,
2723                                                 wxLIST_STATE_SELECTED);
2724         
2725         if (longSelected == -1){
2726             
2727             break;
2728             
2729         }
2730         
2731         // Get the file information and add to the list.
2732         
2733         int FileID = (int)lstContacts->GetItemData(longSelected);
2734         
2735         ArrData->Insert(ContactsFileIndex[FileID],
2736                         ContactsCollected, 1);
2737         
2738         ContactsCollected++;
2739         ContactFilename.Clear();        
2740         
2741     }
2742     
2743     event.SetInt(1);
2744     
2747 void frmMain::SyncAccount( wxCommandEvent& event ){
2748     
2749     wxString *AccNameInc = (wxString*)event.GetClientData();
2750     
2751     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
2752     frameActMgr->AddTask(3, wxT(""), *AccNameInc, 
2753                          wxT(""), wxT(""), wxT(""), wxT(""));
2754     
2757 void frmMain::ShowHelp( wxCommandEvent& event ){
2758     
2759     // Based on the operating system, work out where 
2760     // the documentation should be.
2761     
2762     //#ifdef __APPLE__
2763     
2764 #if defined(__HAIKU__)
2765     
2766 #elif defined(__WIN32__)
2767     
2768     
2769     
2770 #else
2771     
2772     if (wxFileExists("/usr/share/doc/xestiaab/index.html")){
2773         
2774         wxLaunchDefaultBrowser(wxT("file:///usr/share/doc/xestiaab/index.html"));
2775         return;
2776         
2777 #if XSDAB_RELEASE == 0
2778         
2779     } else if (wxFileExists("/usr/local/share/doc/xestiaab/index.html")){
2780         
2781         wxLaunchDefaultBrowser(wxT("file:///usr/local/share/doc/xestiaab/index.html"));
2782         return;
2783         
2784 #endif 
2785         
2786     }
2787     
2788 #endif
2789     
2790 #if XSDAB_RELEASE == 0
2791     
2792     wxMessageBox(_("The help documentation is not available.\n\nYou can view the documentation that came with your source package."), _("Help documentation missing!"));
2793     
2794 #else
2795     
2796     wxMessageBox(_("The help documentation is not available in the usual locations on the system. Please visit http://documentation.xestia.co.uk/xestiaab/ for documentation"), _("Help documentation missing!"));
2797     
2798 #endif
2799     
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