00001 #include "window_demo_qt.hpp" 00002 00003 #include "application_config.h" 00004 #include "client-run.h" 00005 #include "er_errors.h" 00006 #include "guilog.h" 00007 #include "kr_controller.h" 00008 00009 #include <QApplication> 00010 #include <QDebug> 00011 #include <QObject> 00012 00013 #include <QtGlobal> 00014 00015 #include <stdlib.h> // abort 00016 00017 // -------------------------------------------------- 00018 // exit functions 00019 // -------------------------------------------------- 00020 00021 // Immediate process exit. 00022 extern "C" void ExitApplication() 00023 { 00024 logt("ExitApplication"); 00025 abort(); 00026 } 00027 00028 // Orderly shutdown. This is only done via a Lua binding, and there it 00029 // is useful to be able to send a response before exiting, hence a 00030 // proper shutdown. 00031 extern "C" void ShutdownApplication() 00032 { 00033 logt("ShutdownApplication"); 00034 QApplication::quit(); 00035 } 00036 00037 // -------------------------------------------------- 00038 // main 00039 // -------------------------------------------------- 00040 00041 int main(int argc, char *argv[]) 00042 { 00043 QApplication app(argc, argv); 00044 00045 MainWindow w; 00046 00047 int errCode = cl2GlobalInit(); 00048 if (errCode) { 00049 logt("global init failed"); 00050 return 1; 00051 } 00052 00053 logg("compiled against Qt %s", QT_VERSION_STR); 00054 logg("running with Qt %s", qVersion()); 00055 00056 GError* localError = NULL; 00057 kr_Controller* controller = kr_Controller_new(&localError); 00058 if (!controller) { 00059 logt("controller init failed"); 00060 gx_txtlog_error_free(localError); 00061 return 2; 00062 } 00063 00064 if (!kr_Controller_start(controller, &localError)) { 00065 logt("controller start failed"); 00066 gx_txtlog_error_free(localError); 00067 return 3; 00068 } 00069 00070 guilog(__APP_NAME__); 00071 guilogf("variant %s", __VARIANT_NAME__); 00072 guilogf("version %s", __VERSION_STRING__); 00073 #ifdef __CERT_NAME__ 00074 guilogf("capas %s", __CERT_NAME__); 00075 #endif 00076 guilogf("compiled against Qt %s", QT_VERSION_STR); 00077 guilogf("running with Qt %s", qVersion()); 00078 guilog("Welcome."); 00079 w.show(); 00080 00081 // This invokation actually runs the controller in an event loop. 00082 try { 00083 errCode = qApp->exec(); 00084 logg("qApp->exec() returned with %d", errCode); 00085 } catch (const std::exception &ex) { 00086 logg("Qt error exception: %s", ex.what()); 00087 return 4; 00088 } 00089 00090 kr_Controller_destroy(controller); 00091 00092 // Deletes application context. 00093 cl2GlobalCleanup(); 00094 00095 return 0; 00096 } 00097 00098 /** 00099 00100 Copyright 2010 Helsinki Institute for Information Technology (HIIT) 00101 and the authors. All rights reserved. 00102 00103 Authors: Tero Hasu <tero.hasu@hut.fi> 00104 00105 Permission is hereby granted, free of charge, to any person 00106 obtaining a copy of this software and associated documentation files 00107 (the "Software"), to deal in the Software without restriction, 00108 including without limitation the rights to use, copy, modify, merge, 00109 publish, distribute, sublicense, and/or sell copies of the Software, 00110 and to permit persons to whom the Software is furnished to do so, 00111 subject to the following conditions: 00112 00113 The above copyright notice and this permission notice shall be 00114 included in all copies or substantial portions of the Software. 00115 00116 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00117 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00118 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00119 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00120 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00121 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00122 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00123 SOFTWARE. 00124 00125 **/
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:55 2011 by Doxygen 1.6.1