/* Copyright (C) 2016-2020, Dirk Krause SPDX-License-Identifier: BSD-3-Clause */ /* WARNING: This file was generated by the dkct program (see http://dktools.sourceforge.net/ for details). Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: WxpqdicApp.cpt */ /** @file WxpqdicApp.cpp The WxpqdicApp module. */ #line 81 "WxpqdicApp.cpt" #include "wxpqdic.h" #line 87 "WxpqdicApp.cpt" /** Localized wxChar texts. */ static wxChar const * wxpqdic_texts[] = { /* 0 */ wxT("File"), /* 1 */ wxT("Quit"), /* 2 */ wxT("Exit the application"), /* 3 */ wxT("Help"), /* 4 */ wxT("About"), /* 5 */ wxT("Show version information"), /* 6 */ wxT("Contents"), /* 7 */ wxT("Open table of contents"), /* 8 */ wxT("Ready"), /* 9 */ wxT("Copyright (c) "), /* 10 */ wxT("About "), /* 11 */ wxT("This program uses the following libraries:"), /* 12 */ wxT("See:"), /* 13 */ wxT("Limit: "), /* 14 */ wxT("unlimited"), /* 15 */ wxT("Used: "), /* 16 */ wxT("00000000"), /* 17 */ wxT("Personal print account: "), /* 18 */ wxT("Printing allowed: "), /* 19 */ wxT("YES"), /* 20 */ wxT("NO"), /* 21 */ wxT("Waiting for response from server."), /* 22 */ wxT("View"), /* 23 */ wxT("Update"), /* 24 */ wxT("Update information in Window"), /* 25 */ wxT("Update"), /* 26 */ wxT("Exit"), /* 27 */ wxT("unknown"), /* 28 */ wxT("Failed to send request!"), /* 29 */ wxT("No response from server!"), /* 30 */ wxT("Command line"), /* 31 */ wxT("Failed to parse command line, illegal options used!"), /* 32 */ wxT("Insufficient memory"), /* 33 */ wxT("A memory allocation failed due to insufficient memory!"), /* 34 */ wxT("Illegal host name"), /* 35 */ wxT("Failed to convert host name to portable string!"), /* 36 */ wxT("Missing host name"), /* 37 */ wxT("No host name specified! Please use\n-h host\nto specify the remote host."), /* 38 */ wxT("Illegal queue name"), /* 39 */ wxT("Failed to convert queue name to 8 bit character string!"), /* 40 */ wxT("Missing queue name"), /* 41 */ wxT("No queue name specified! Please use\n-q queue\n to specify the queue name."), /* 42 */ wxT("Illegal remote port"), /* 43 */ wxT("Remote port number out of 16 bit range!"), /* 44 */ wxT("Remote port number 0 can not be used!"), /* 45 */ wxT("Illegal user name"), /* 46 */ wxT("Failed to convert user name to 8 bit character string!"), /* 47 */ wxT("No user name"), /* 48 */ wxT("User name not found!"), /* 49 */ wxT("Illegal local port"), /* 50 */ wxT("Local port number out of 16 bit range!"), /* 51 */ wxT("Local port number 0 can not be used!"), /* 52 */ wxT("Bug"), /* 53 */ wxT("Failed to construct request string!"), /* 54 */ wxT("Numeric overflow"), /* 55 */ wxT("A numeric overflow occured in size calculation!"), /* 56 */ wxT("Network error"), /* 57 */ wxT("Failed to create communication socket!"), /* 58 */ wxT("Error"), /* 59 */ wxT("An unknown error occured during setup!"), NULL #line 284 "WxpqdicApp.cpt" }; /** Non-localized wxChar texts. */ static wxChar const * wxpqdic_nl_wx[] = { /* 0 */ wxT("wxpqdic"), /* 1 */ wxT("4.3.0"), /* 2 */ wxT("Dirk Krause"), /* 3 */ wxT("DKrause"), /* 4 */ wxT("aaaaa"), /* 5 */ wxT(""), /* 6 */ wxT(""), /* 7 */ wxT(" "), /* 8 */ wxT("\n"), /* 9 */ wxT("DK tools, wxWidgets, libpng, libjpeg, libtiff, zlib."), /* 10 */ wxT("http://sourceforge.net/p/dktools/wiki/Home/"), /* 11 */ wxT("http://www.wxwidgets.org"), /* 12 */ wxT("http://www.libpng.org/pub/png/libpng.html"), /* 13 */ wxT("http://www.ijg.org"), /* 14 */ wxT("http://www.remotesensing.org/libtiff"), /* 15 */ wxT("http://www.zlib.net"), /* 16 */ wxT("UTF-8"), /* 17 */ wxT("utf8"), /* 18 */ wxT("Error"), /* 19 */ wxT("Not enough memory (RAM)!"), NULL #line 351 "WxpqdicApp.cpt" }; /** Non-localized dkChar texts. */ static dkChar const * wxpqdic_nl_dk[] = { /* 0 */ dkT("dktools"), /* 1 */ dkT("wxpqdc.str"), /* 2 */ dkT("wxpqdic.chm"), /* 3 */ dkT("wxpqdic.htb"), NULL #line 376 "WxpqdicApp.cpt" }; /** Implementation of the wxApp functionality. */ #if wxCHECK_VERSION(3,0,0) wxIMPLEMENT_APP(WxpqdicApp); #else IMPLEMENT_APP(WxpqdicApp) #endif bool WxpqdicApp::OnInit() { WxpqdicFrame *frame = NULL; wxChar const * const *localizedTexts = NULL; wxPNGHandler *phPng = NULL; wxXPMHandler *phXpm = NULL; wxICOHandler *phIco = NULL; wxArchiveFSHandler *phArchiveFS = NULL; bool back = false; #line 402 "WxpqdicApp.cpt" #line 403 "WxpqdicApp.cpt" /* Initialize members. */ pAh = NULL; pHc = NULL; /* __CHANGE__ 009: Initialize further members here. */ bSocketsInitialized = false; /* Set up application helper object. */ pAh = new Dk4WxApplicationHelper(); if (NULL == pAh) { ShowMemoryErrorMessage(); goto finished; } if (!(pAh->Initialize(argv[0], wxpqdic_nl_wx[3], wxpqdic_nl_dk[0]))) { #line 422 "WxpqdicApp.cpt" goto finished; } /* Add image and file system handlers for online help. */ phPng = new wxPNGHandler(); if (NULL != phPng) { wxImage::AddHandler(phPng); } else { ShowMemoryErrorMessage(); goto finished; } /* CLANG STATIC ANALYSIS COMPLAINS ABOUT A POTENTIAL MEMORY LEAK, because phPng is set using the new operator but there is no matching delete. The handler object is deleted from within wxImage destructor, there is no memory leak. */ phXpm = new wxXPMHandler(); if (NULL != phXpm) { wxImage::AddHandler(phXpm); } else { ShowMemoryErrorMessage(); goto finished; } /* CLANG STATIC ANALYSIS COMPLAINS ABOUT A POTENTIAL MEMORY LEAK, because phXpm is set using the new operator but there is no matching delete. The handler object is deleted from within wxImage destructor, there is no memory leak. */ phIco = new wxICOHandler(); if (NULL != phIco) { wxImage::AddHandler(phIco); } else { ShowMemoryErrorMessage(); goto finished; } /* CLANG STATIC ANALYSIS COMPLAINS ABOUT A POTENTIAL MEMORY LEAK, because phIco is set using the new operator but there is no matching delete. The handler object is deleted from within wxImage destructor, there is no memory leak. */ phArchiveFS = new wxArchiveFSHandler(); if (NULL != phArchiveFS) { wxFileSystem::AddHandler(phArchiveFS); } else { ShowMemoryErrorMessage(); goto finished; } /* CLANG STATIC ANALYSIS COMPLAINS ABOUT A POTENTIAL MEMORY LEAK, because phArchiveFs is set using the new operator but there is no matching delete. The handler object is deleted from within wxFileSystem destructor, there is no memory leak. */ /* Set up help controller. */ pHc = new Dk4WxHelpController(); if (NULL == pHc) { ShowMemoryErrorMessage(); goto finished; } if (!(pHc->Initialize(pAh, wxpqdic_nl_dk[2], wxpqdic_nl_dk[3]))) { #line 496 "WxpqdicApp.cpt" goto finished; } /* Attempt to get localized texts in the users preferred language. */ localizedTexts = pAh->GetStringTable(wxpqdic_nl_dk[1], wxpqdic_texts); if(!(localizedTexts)) { localizedTexts = wxpqdic_texts; } /* Initialize socket sub system. */ dk4error_init(&sockerr); if (DK4_SOCKET_RESULT_SUCCESS == dk4socket_up(&sockerr)) { bSocketsInitialized = true; } /* Create and show frame. */ frame = new WxpqdicFrame( WxpqdicFrame_MainWindow, pAh, pHc, argc, argv, localizedTexts, wxpqdic_nl_wx, wxpqdic_nl_dk, bSocketsInitialized, &sockerr ); if(!(frame)) { ShowMemoryErrorMessage(); goto finished; } /* Show frame and indicate success. */ frame->RestorePosition(); frame->Show(); back = true; /* Release resources if initialization failed. */ finished: if(!(back)) { if (NULL != pHc) { pHc->Cleanup(); delete(pHc); pHc = NULL; } if (NULL != pAh) { pAh->Cleanup(); delete(pAh); pAh = NULL; } } #line 552 "WxpqdicApp.cpt" #if 0 if(!(back)) { #line 555 "WxpqdicApp.cpt" } #endif return back; } int WxpqdicApp::OnExit() { int back = 0; #line 567 "WxpqdicApp.cpt" /* __CHANGE__ 009: Release resources allocated by further members. */ if (bSocketsInitialized) { dk4socket_down(NULL); } /* Release resources. */ if (NULL != pHc) { pHc->Cleanup(); delete(pHc); pHc = NULL; } if (NULL != pAh) { pAh->Cleanup(); delete(pAh); pAh = NULL; } #line 585 "WxpqdicApp.cpt" #line 586 "WxpqdicApp.cpt" return back; } void WxpqdicApp::ShowMemoryErrorMessage(void) { const wxChar *s_title = NULL; const wxChar *s_text = NULL; if (NULL != pAh) { s_title = pAh->GetBasicString(6); s_text = pAh->GetBasicString(7); } if (NULL == s_title) { s_title = wxpqdic_nl_wx[18]; } if (NULL == s_text) { s_text = wxpqdic_nl_wx[19]; } wxMessageBox(s_text, s_title, (wxOK | wxCENTRE | wxICON_ERROR)); }