5 #include <wx/mstream.h>
6 #include <wx/cmdline.h>
8 #include <wx/filename.h>
11 #include "contacteditor/frmContactEditor.h"
15 #include "frmActivityMgr.h"
16 #include "frmSearch.h"
17 #include "common/timers.h"
18 #include "common/defaults.h"
19 #include "common/dirs.h"
21 class XestiaABApp: public wxApp
23 virtual bool OnInit();
26 IMPLEMENT_APP(XestiaABApp);
28 bool XestiaABApp::OnInit()
34 locale.Init(wxLANGUAGE_DEFAULT, wxLOCALE_LOAD_DEFAULT);
36 #if defined(__WIN32__)
38 // Check that the minimum version of Xestia Common Components is installed on the system.
40 #include <xestiaccdll.h>
42 if (!CheckXCCVersion(1, 0, 0)){
43 MessageBox(0, L"The version of Xestia Common Components installed is an older version not supported by this version of Xestia Address Book.\n\nPlease visit http://xestia.co.uk/commoncomponents and follow the page instructions to download the version required.", L"Older version of Xestia Common Components installed", MB_OK|MB_ICONSTOP);
49 static const wxCmdLineEntryDesc g_cmdLineDesc [] =
51 { wxCMD_LINE_SWITCH, wxT_2("h"), wxT_2("help"), wxTRANSLATE("Displays help on command line parameters"),
52 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
53 { wxCMD_LINE_OPTION, wxT_2("e"), wxT_2("edit"), wxTRANSLATE("Edit a vCard 4.0 formatted contact"),
54 wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
55 { wxCMD_LINE_SWITCH, wxT_2("s"), wxT_2("search"), wxTRANSLATE("Display the search window instead of starting normally"),
56 wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
57 { wxCMD_LINE_SWITCH, wxT_2("v"), wxT_2("version"), wxTRANSLATE("Displays version number"),
58 wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
62 wxString wxSContactFilename;
63 wxCmdLineParser XABArgs (g_cmdLineDesc, argc, argv);
66 if (XABArgs.Found(wxT("h"))){
72 if (XABArgs.Found(wxT("v"))){
74 wxPuts(XSDAB_VERSION);
79 wxInitAllImageHandlers();
81 if (XABArgs.Found(wxT("s"))){
83 // Open up the search window.
85 frmSearch *frmSearchPtr = new frmSearch( NULL );
86 frmSearchPtr->Show(true);
87 frmSearchPtr->SetSearchMode(true);
92 if (XABArgs.Found(wxT("e"), &wxSContactFilename)){
94 // Check if the filename exists.
96 wxFileName contactfile(wxSContactFilename);
98 if (!contactfile.FileExists()){
100 wxMessageBox(_("The file with the filename given does not exist."), _("Error loading contact"), wxICON_ERROR);
105 // Check if file is in the user's Xestia Address Book data storage
106 // path. If it is, refuse to open it.
108 wxString UserDir = GetUserDir();
109 long UserDirLength = UserDir.Len();
111 if (UserDir == contactfile.GetFullPath().Mid(0, UserDirLength)){
113 wxMessageBox(_("The file with the filename given is in the directories that Xestia Address Book stores it's data and cannot be opened directly."), _("Error loading contact"), wxICON_ERROR);
118 wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
119 wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
120 wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
122 contacticon.CopyFromBitmap(contacticonbmp);
124 // Get the filename of the selected contact.
126 frmContactEditor *ContactEditor = new frmContactEditor( NULL );
127 ContactEditor->SetupHeaders();
128 ContactEditor->SetMode(TRUE);
129 ContactEditor->LoadContact(wxSContactFilename);
130 //ContactEditor->SetupContact(ActiveAccount);
131 ContactEditor->SetIcon(contacticon);
132 ContactEditor->Show(true);
134 SetTopWindow(ContactEditor);
140 // Setup default settings and accounts if they don't exist.
143 SetupDefaultSettings();
144 SetupDefaultAddressBook();
146 //wxImage::AddHandler(new wxPNGHandler);
147 wxMemoryInputStream istream(bigimgs_appicon48_png, sizeof(bigimgs_appicon_png));
148 wxImage bigimgs_appicon48i(istream, wxBITMAP_TYPE_PNG);
149 wxBitmap appiconbmp(bigimgs_appicon48i, -1);
152 appicon.CopyFromBitmap(appiconbmp);
153 frmMain *frame = new frmMain( NULL );
155 frmActivityMgr *frameActMgr = new frmActivityMgr ( frame );
156 frame->SetupPointers(frameActMgr);
158 frame->SetIcon(appicon);