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