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"))){
68 // Print out the list of help commands.
74 if (XABArgs.Found(wxT("v"))){
76 // Print out the version number.
78 wxPuts(XSDAB_VERSION);
83 wxInitAllImageHandlers();
85 if (XABArgs.Found(wxT("s"))){
87 // Open up the search window.
89 frmSearch *frmSearchPtr = new frmSearch( NULL );
90 frmSearchPtr->Show(true);
91 frmSearchPtr->SetSearchMode(true);
96 if (XABArgs.Found(wxT("e"), &wxSContactFilename)){
98 // Check if the filename exists.
100 wxFileName contactfile(wxSContactFilename);
102 if (!contactfile.FileExists()){
104 wxMessageBox(_("The file with the filename given does not exist."), _("Error loading contact"), wxICON_ERROR);
109 // Check if file is in the user's Xestia Address Book data storage
110 // path. If it is, refuse to open it.
112 wxString UserDir = GetUserDir();
113 long UserDirLength = UserDir.Len();
115 if (UserDir == contactfile.GetFullPath().Mid(0, UserDirLength)){
117 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);
122 wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
123 wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
124 wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
126 contacticon.CopyFromBitmap(contacticonbmp);
128 // Get the filename of the selected contact.
130 frmContactEditor *ContactEditor = new frmContactEditor( NULL );
131 ContactEditor->SetupHeaders();
132 ContactEditor->SetMode(TRUE);
133 ContactEditor->LoadContact(wxSContactFilename);
134 ContactEditor->SetIcon(contacticon);
135 ContactEditor->Show(true);
137 SetTopWindow(ContactEditor);
143 // Setup default settings and accounts if they don't exist.
146 SetupDefaultSettings();
147 SetupDefaultAddressBook();
149 wxMemoryInputStream istream(bigimgs_appicon48_png, sizeof(bigimgs_appicon_png));
150 wxImage bigimgs_appicon48i(istream, wxBITMAP_TYPE_PNG);
151 wxBitmap appiconbmp(bigimgs_appicon48i, -1);
154 appicon.CopyFromBitmap(appiconbmp);
155 frmMain *frame = new frmMain( NULL );
157 frmActivityMgr *frameActMgr = new frmActivityMgr ( frame );
158 frame->SetupPointers(frameActMgr);
160 frame->SetIcon(appicon);