Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial import of code already done for Xestia Address Book
[xestiaab/.git] / source / main.cpp
1 #include <stdlib.h>
3 #include <wx/wx.h>
4 #include <wx/icon.h>
5 #include <wx/mstream.h>
6 #include <wx/cmdline.h>
7 #include <wx/wxprec.h>
8 #include <wx/filename.h>
9 #include <curl/curl.h>
11 #include "contacteditor/frmContactEditor.h"
12 #include "frmMain.h"
13 #include "bitmaps.h"
14 #include "version.h"
15 #include "frmActivityMgr.h"
16 #include "common/timers.h"
17 #include "common/defaults.h"
19 class XestiaABApp: public wxApp
20 {
21     virtual bool OnInit();
22 };
24 IMPLEMENT_APP(XestiaABApp);
26 bool XestiaABApp::OnInit()
27 {
29         // Check that on Win32 systems that.
31 #if defined(__WIN32__)
33 #include <xestiacc.h>
35         XCCVer XCCRequiredVer;
36         XCCRequiredVer.MajorVer = 1;
37         XCCRequiredVer.MinorVer = 0;
39         XCCVer XCCRetrievedVer = GetXCCLibraryVersion();
41         if (XCCRetrievedVer < XCCRequiredVer){
42                 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);
43                 this->Exit();
44         }
46 #endif
48     static const wxCmdLineEntryDesc g_cmdLineDesc [] =
49     {
50          { wxCMD_LINE_SWITCH, wxT_2("h"), wxT_2("help"), wxTRANSLATE("Displays help on command line parameters"),
51              wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
52          { wxCMD_LINE_OPTION, wxT_2("e"), wxT_2("edit"), wxTRANSLATE("Edit a vCard 4.0 formatted contact"),
53              wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, 
54          { wxCMD_LINE_SWITCH, wxT_2("s"), wxT_2("search"), wxTRANSLATE("Display the search window instead of starting normally"),
55              wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
56          { wxCMD_LINE_SWITCH, wxT_2("v"), wxT_2("version"), wxTRANSLATE("Displays version number"),
57              wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
58          { wxCMD_LINE_NONE }
59     };
61     wxString wxSContactFilename;
62     wxCmdLineParser XABArgs (g_cmdLineDesc, argc, argv);
63     XABArgs.Parse();
64     
65     if (XABArgs.Found(wxT("h"))){
66     
67         return false;
68     
69     }
70     
71     if (XABArgs.Found(wxT("v"))){
72     
73         exit(0);
74     
75     }
76     
77     wxInitAllImageHandlers();
78     
79     if (XABArgs.Found(wxT("e"), &wxSContactFilename)){
80         
81         // Check if the filename exists.
82         
83         //wxImage::AddHandler(new wxPNGHandler);
85         wxFileName contactfile(wxSContactFilename);
86         
87         if (!contactfile.FileExists()){
88         
89                 return false;
90         
91         }
92         
93         curl_global_init(CURL_GLOBAL_ALL);
94         
95         wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
96         wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
97         wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
98         wxIcon contacticon;
99         contacticon.CopyFromBitmap(contacticonbmp); 
101         // Get the filename of the selected contact.
103         frmContactEditor *ContactEditor = new frmContactEditor( NULL );
104         ContactEditor->SetupHeaders();    
105         ContactEditor->LoadContact(wxSContactFilename);
106         //ContactEditor->SetupContact(ActiveAccount);
107         ContactEditor->SetIcon(contacticon);
108         ContactEditor->Show(true);
109         
110         SetTopWindow(ContactEditor);
111         
112         return true;
113     
114     }
115     
116     // Setup default settings and accounts if they don't exist.
117     
118     SetupDirectories();
119     SetupDefaultSettings();
120     SetupDefaultAddressBook();
122     //wxImage::AddHandler(new wxPNGHandler); 
123     wxMemoryInputStream istream(bigimgs_appicon48_png, sizeof(bigimgs_appicon_png));
124     wxImage bigimgs_appicon48i(istream, wxBITMAP_TYPE_PNG);
125     wxBitmap appiconbmp(bigimgs_appicon48i, -1);    
126     wxIcon appicon;
127     
128     appicon.CopyFromBitmap(appiconbmp);
129     frmMain *frame = new frmMain( NULL );
130         frame->Show(true);
131     frmActivityMgr *frameActMgr = new frmActivityMgr ( frame );
132     frame->SetupPointers(frameActMgr);
133     frame->SetupForm();
134     frame->SetIcon(appicon);
135    
136     SetTopWindow(frame);
137    
138     return true;
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