#include <wx/wx.h>
#include <wx/cmdline.h>
#include <wx/config.h>
#include "wpassgen.h"
#include "enctain.h"
#include "common/myintl.h"
#include "locale/de.h"
#include "locale/wxstd/de.h"
static MyLocaleMemoryCatalog cryptote_catalogs[] =
{
{ _T("de"), NULL, locale_de_mo, sizeof(locale_de_mo), locale_de_mo_uncompressed },
{ NULL, NULL, NULL, 0, 0 }
};
static MyLocaleMemoryCatalog wxstd_catalogs[] =
{
{ _T("de"), NULL, locale_wxstd_de_mo, sizeof(locale_wxstd_de_mo), locale_wxstd_de_mo_uncompressed },
{ NULL, NULL, NULL, 0, 0 }
};
class App : public wxApp
{
private:
class WPassGen* wmain;
MyLocale* locale;
Enctain::LibraryInitializer enctain_init;
public:
virtual bool OnInit()
{
wxLog::SetActiveTarget(new wxLogStderr);
SetAppName(_T("CryptoTE"));
SetVendorName(_T("idlebox.net"));
locale = new MyLocale(wxLANGUAGE_DEFAULT, wxLOCALE_CONV_ENCODING);
if (!locale->AddCatalogFromMemory(_T("cryptote"), cryptote_catalogs) ||
!locale->AddCatalogFromMemory(_T("wxstd"), wxstd_catalogs))
{
delete locale;
locale = new MyLocale(wxLANGUAGE_ENGLISH, wxLOCALE_CONV_ENCODING);
if (!locale->AddCatalogFromMemory(_T("cryptote"), cryptote_catalogs) ||
!locale->AddCatalogFromMemory(_T("wxstd"), wxstd_catalogs))
{
wxLogError(_T("Could not load message catalog for system or English language."));
return false;
}
}
if (!wxApp::OnInit()) return false;
wxImage::AddHandler(new wxPNGHandler());
wxLog::SetActiveTarget(NULL);
wmain = new WPassGen(NULL, true);
SetTopWindow(wmain);
wxConfigBase* cfg = wxConfigBase::Get();
wmain->LoadSettings(cfg);
wmain->Show();
return true;
}
virtual void OnInitCmdLine(wxCmdLineParser& parser)
{
parser.AddSwitch(_T("h"), _T("help"),
_T("Display help for the command line parameters."),
wxCMD_LINE_OPTION_HELP);
parser.AddOption(_T("L"), _T("lang"),
_T("Set language for messages. Example: de or de_DE."),
wxCMD_LINE_VAL_STRING, 0);
}
virtual bool OnCmdLineParsed(wxCmdLineParser& parser)
{
wxLog::SetActiveTarget(new wxLogStderr);
wxString langtext;
if ( parser.Found(_T("L"), &langtext) )
{
const wxLanguageInfo* langinfo = wxLocale::FindLanguageInfo(langtext);
if (!langinfo) {
wxLogError(_("Invalid language identifier specified with --lang."));
return false;
}
if (locale) delete locale;
locale = new MyLocale;
if (!locale->Init(langinfo->Language, wxLOCALE_CONV_ENCODING)) {
wxLogError(_("This language is not supported by the program."));
return false;
}
if (!locale->AddCatalogFromMemory(_T("cryptote"), cryptote_catalogs))
{
wxLogError(_("This language is not supported by the program."));
return false;
}
if (!locale->AddCatalogFromMemory(_T("wxstd"), wxstd_catalogs))
{
wxLogError(_("This language is not supported by the program."));
return false;
}
}
wxLog::SetActiveTarget(NULL);
return true;
}
virtual int OnExit()
{
return 0;
}
};
IMPLEMENT_APP(App)