Bibletime – a bible study tool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. /*********
  2. *
  3. * This file is part of BibleTime's source code, http://www.bibletime.info/.
  4. *
  5. * Copyright 1999-2006 by the BibleTime developers.
  6. * The BibleTime source code is licensed under the GNU General Public License version 2.0.
  7. *
  8. **********/
  9. /* $Header: /cvsroot/bibletime/bibletime/bibletime/main.cpp,v 1.144 2007/10/26 21:19:27 eelik Exp $ */
  10. /* $Revision: 1.144 $ */
  11. //standard includes
  12. #include <stdlib.h>
  13. #include <stdio.h>
  14. #include <signal.h>
  15. //own includes
  16. #include "bibletimeapp.h"
  17. #include "bibletime.h"
  18. #include "config.h"
  19. //util includes
  20. #include "util/scoped_resource.h"
  21. #include "util/cresmgr.h"
  22. //frontend includes
  23. #include "frontend/kstartuplogo.h"
  24. #include "frontend/cbtconfig.h"
  25. //TQt includes
  26. #include <tqdir.h>
  27. //KDE includes
  28. #include <tdecmdlineargs.h>
  29. #include <kcrash.h>
  30. #include <tdeglobal.h>
  31. #include <tdeapplication.h>
  32. #include <kstandarddirs.h>
  33. #include <kinstance.h>
  34. #include <tdeaboutdata.h>
  35. #include <tdelocale.h>
  36. bool showDebugMessages = false;
  37. BibleTime* bibletime_ptr = 0;
  38. void myMessageOutput( TQtMsgType type, const char *msg ) {
  39. //we use this messagehandler to switch debugging off in final releases
  40. switch ( type ) {
  41. case TQtDebugMsg:
  42. if (showDebugMessages) { //only show messages if they are enabled!
  43. fprintf( stderr,"(BibleTime %s) Debug: %s\n",VERSION, msg );
  44. }
  45. break;
  46. case TQtWarningMsg:
  47. //if (showDebugMessages) //comment out for releases so users don't get our debug warnings
  48. fprintf( stderr,"(BibleTime %s) WARNING: %s\n",VERSION, msg );
  49. break;
  50. case TQtFatalMsg:
  51. fprintf( stderr,"(BibleTime %s) _FATAL_: %s\nPlease visit http://bugs.pearsoncomputing.net and report this bug!",VERSION, msg );
  52. abort(); // dump core on purpose
  53. }
  54. }
  55. extern "C" {
  56. static void setSignalHandler(void (*handler)(int));
  57. // Crash recovery signal handler
  58. static void signalHandler(int sigId) {
  59. setSignalHandler(SIG_DFL);
  60. fprintf(stderr, "*** BibleTime got signal %d (Exiting)\n", sigId);
  61. // try to cleanup all windows
  62. if (CBTConfig::get(CBTConfig::crashedLastTime)) {
  63. //crashed this time and the execution before this one, probably a bug which occurs every time
  64. CBTConfig::set(CBTConfig::crashedTwoTimes, true);
  65. }
  66. else {
  67. //try to restore next time.
  68. CBTConfig::set(CBTConfig::crashedLastTime, true);
  69. }
  70. if (bibletime_ptr) {
  71. bibletime_ptr->saveSettings();
  72. fprintf(stderr, "*** Saving seemed to be successful. If restoring does not work on next startup please use the option --ignore-session\n");
  73. }
  74. ::exit(-1); //exit BibleTime
  75. }
  76. // Crash recovery signal handler
  77. static void crashHandler(int sigId) {
  78. setSignalHandler(SIG_DFL);
  79. fprintf(stderr, "*** BibleTime got signal %d (Crashing). Trying to save settings.\n", sigId);
  80. if (CBTConfig::get(CBTConfig::crashedLastTime)) {
  81. // crashed this time and the execution before this one,
  82. // probably a bug which occurs every time
  83. CBTConfig::set(CBTConfig::crashedTwoTimes, true);
  84. }
  85. else {
  86. //try to restore next time.
  87. CBTConfig::set(CBTConfig::crashedLastTime, true);
  88. }
  89. if (bibletime_ptr) {
  90. bibletime_ptr->saveSettings();
  91. fprintf(stderr, "*** Saving seemed to be successful. If restoring does not work on next startup please use the option --ignore-session\n");
  92. }
  93. // Return to DrKonqi.
  94. }
  95. static void setSignalHandler(void (*handler)(int)) {
  96. signal(SIGKILL, handler);
  97. signal(SIGTERM, handler);
  98. signal(SIGHUP, handler);
  99. TDECrash::setEmergencySaveFunction(crashHandler);
  100. }
  101. }
  102. int main(int argc, char* argv[]) {
  103. tqInstallMsgHandler( myMessageOutput );
  104. //create about data for this application
  105. static TDECmdLineOptions options[] =
  106. {
  107. {"debug", I18N_NOOP("Enable debug messages"),0},
  108. {"ignore-session", I18N_NOOP("Ignore the startup session that was saved when BibleTime was closed the last time."),0},
  109. {"open-default-bible <key>", I18N_NOOP("Open the standard Bible with the given key. Use <random> to open at a random position."),0},
  110. //{"install-local <path>", I18N_NOOP("Open the SwordSetup dialog to install works from <path>"),0},
  111. {0,0,0}
  112. };
  113. TDEAboutData aboutData(
  114. PACKAGE,
  115. "BibleTime",
  116. VERSION,
  117. I18N_NOOP("Bible study tool for Trinity"),
  118. TDEAboutData::License_GPL_V2,
  119. I18N_NOOP("(c)1999-2010, The BibleTime Team and The Trinity Project"),
  120. I18N_NOOP("BibleTime is an easy to use but powerful Bible study tool for Trinity.\nIt is a fork of the main BibleTime project in order to provide a native Trinity application.\n\nThe BibleTime project is looking for developers and translators.\nIf you'd like to join their team, please send an email to info@bibletime.info."),
  121. "http://www.bibletime.info/",
  122. "trinity-devel@lists.pearsoncomputing.net"
  123. );
  124. /***********************************************
  125. * Active developers (sorted by last name) *
  126. ************************************************/
  127. // Project coordination
  128. aboutData.addAuthor("Joachim Ansorg", I18N_NOOP("Project coordinator"), "nospam@joachim-ansorg.de", "http://www.joachim-ansorg.de/");
  129. // Second main developer
  130. aboutData.addAuthor("Martin Gruner", I18N_NOOP("Frontend, backend"), "mg.pub@gmx.net", "");
  131. // artwork
  132. aboutData.addAuthor("James Ots", I18N_NOOP("Crystal icons, crystal startlogo, webpage"), "me@jamesots.com", "http://www.jamesots.com");
  133. // Trinity project maintainer
  134. aboutData.addAuthor("Timothy Pearson", I18N_NOOP("Trinity project maintainer"), "kb9vqf@pearsoncomputing.net", "http://trinity.pearsoncomputing.net");
  135. //inactiv
  136. /***********************************************
  137. * Credits (sorted by last name) *
  138. ************************************************/
  139. // Update to the Romanian GUI translation
  140. aboutData.addCredit("Horatiu Alexe", I18N_NOOP("Romanian translation"), "");
  141. //highcolor icons, startlogo for BT <= 1.4
  142. aboutData.addCredit("David Blue", I18N_NOOP("High contrast template"), "davidslists@gmx.net");
  143. //helped out with the installation manager
  144. aboutData.addCredit("Tim Brodie", I18N_NOOP("Installation manager"),"tbrodie@displayworksinc.com", "");
  145. //first set of icons and the first startup logos
  146. aboutData.addCredit("Timothy R. Butler", I18N_NOOP("Icons, startlogo"), "tbutler@uninetsolutions.com", "http://www.uninetsolutions.com");
  147. //GUI improvements
  148. aboutData.addCredit("Jim Campbell", I18N_NOOP("GUI"), "jdc.email@gmail.com", "");
  149. //Indexed search, gui improvements
  150. aboutData.addCredit("Lee Carpenter", I18N_NOOP("GUI, instant search"),"Lee Carpenter <elc@carpie.net>", "http://www.carpie.net");
  151. //Translations into Traditional and Simplified Chinese
  152. aboutData.addCredit("Chun-shek Chan", I18N_NOOP("GUI translations into Traditional and Simplified Chinese"), "chunshek@gmail.com", "");
  153. //Binary packages of CLucene, BibleTime and Sword for Fedore, SUSE, Mandriva
  154. aboutData.addCredit("Jeremy Erickson", I18N_NOOP("Binary packages"), "", "");
  155. //Started the Crosswire porject, also contributed some code
  156. aboutData.addCredit("Troy A. Griffits", I18N_NOOP("Founder of the Sword project"), "scribe@crosswire.org", "http://www.crosswire.org/");
  157. //Sponsored many years the www.bibletime.de domain!
  158. aboutData.addCredit("Thomas Hagedorn", I18N_NOOP("Sponsored our internet domain for many years"), "tom@theta-consulting.de", "");
  159. //He provided us with the Bible Study HowTo
  160. aboutData.addCredit("Bob Harman", I18N_NOOP("Bible Study HowTo"), "ncc@ncchampton.org", "");
  161. // and / or search for multiple words, other fixes and improvements
  162. aboutData.addCredit("Nikolay Igotti", I18N_NOOP("Search dialog enhancements"), "olonho@hotmail.com", "");
  163. // Language codes iso639-1, iso639-2 and SIL language codes
  164. aboutData.addCredit("SIL International", I18N_NOOP("Language codes and names"), "", "http://www.ethnologue.com/iso639");
  165. //Patch for the mag delay (2007-03-22)
  166. aboutData.addCredit("Eeli Kaikkonen", I18N_NOOP("GUI improvements"),"eekaikko@mail.student.oulu.fi", "");
  167. //Update the the Finnish GUI translation
  168. aboutData.addCredit("Ilpo Kantonen", I18N_NOOP("Finnish translation"),"", "");
  169. //Smaller frontend enhancements
  170. aboutData.addCredit("Chris Kujawa", I18N_NOOP("Frontend"),"christopher.kujawa@verizon.net", "");
  171. //Update to the Czech GUI translation
  172. aboutData.addCredit("Pavel Lauko", I18N_NOOP("Czech translation"),"", "");
  173. //Smaller searchdialog enhancements
  174. aboutData.addCredit("Mark Lybarger", I18N_NOOP("Searchdialog"), "mlybarge@insight.rr.com","");
  175. //Polish GUI translation update
  176. aboutData.addCredit("Piotr Markiewicz", I18N_NOOP("Polish translation"), "pmarki@o2.pl", "");
  177. //Smaller frontend enhancements
  178. aboutData.addCredit("Luke Mauldin", I18N_NOOP("Frontend"), "lukeskyfly@txk.net", "");
  179. //translated parts of the russian website files
  180. aboutData.addCredit("Igor Rykhlin", I18N_NOOP("Russian website translation"), "", "");
  181. // update to the Spanish website translation
  182. aboutData.addCredit("Gabriel Pérez", I18N_NOOP("Spanish website translation updates"), "", "");
  183. //Update to the russian website translation
  184. aboutData.addCredit("Igor Plisco", I18N_NOOP("Update to the russian website translation"), "", "");
  185. // handbook documentation
  186. aboutData.addCredit("Fred Saalbach", I18N_NOOP("Documentation"), "saalbach@sybercom.net", "");
  187. // Original Russian website translator
  188. aboutData.addCredit("Vlad Savitsky", I18N_NOOP("Russian website translation"), "", "");
  189. // comitted search in default bible, opened modules, other smaller things
  190. aboutData.addCredit("Gary Sims", I18N_NOOP("Search dialog enhancements"), "gary@garysims.co.uk", "");
  191. // Very helpful testing
  192. aboutData.addCredit("Wolfgang Stradner", I18N_NOOP("Very helpful and detailed testing"), "wolfgang_stradner@wycliffe.org", "");
  193. //The first lead developer
  194. aboutData.addCredit("Torsten Uhlmann", I18N_NOOP("The first lead developer"), "", "");
  195. //Update of the dutch website translation
  196. aboutData.addCredit("Johan van der Lingen", I18N_NOOP("Translation updates for the Dutch GUI, the website and the handbook"), "", "");
  197. //French handbook translation
  198. aboutData.addCredit("Jean Van Schaftingen", I18N_NOOP("French handbook translation"), "", "");
  199. //scoped_ptr and related classes
  200. aboutData.addCredit("David White", I18N_NOOP("Helpful source code additions"), "", "http://www.wesnoth.org/");
  201. //Translated the GUI into Russian
  202. aboutData.addCredit("Dmitry Yurevich", I18N_NOOP("Translated the GUI into Russian"), "", "");
  203. //The new keychooser for Bible modules
  204. aboutData.addCredit("Mark Zealey", I18N_NOOP("New Bible key choosers"), "mspam@zealey.org", "");
  205. //Update to the Spanish GUI translation
  206. aboutData.addCredit("Esteban Zeller", I18N_NOOP("Spanish translation"), "", "");
  207. //special message so the translator get his credits in the about box, don't remove this!
  208. TQString dummy = I18N_NOOP("_: NAME OF TRANSLATORS\nYour names"); //translator's name
  209. dummy = I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails"); //translators eMail
  210. TDECmdLineArgs::init(argc, argv, &aboutData);
  211. TDECmdLineArgs::addCmdLineOptions( options );
  212. BibleTimeApp app;
  213. TDEGlobal::dirs()->addResourceType("BT_pic", "share/apps/bibletime/pics");
  214. TDEGlobal::dirs()->addResourceType("BT_DisplayTemplates", "share/apps/bibletime/display-templates");
  215. TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
  216. // A binary option (on / off)
  217. if (args->isSet("debug")) {
  218. showDebugMessages = true;
  219. }
  220. if (kapp->isRestored()) {
  221. // tqWarning("Restoring BibleTime");
  222. //RESTORE( BibleTime );
  223. int n = 1;
  224. while (TDEMainWindow::canBeRestored(n)){
  225. if (TDEMainWindow::classNameOfToplevel(n) == TQString("BibleTime")) {
  226. bibletime_ptr = new BibleTime;
  227. bibletime_ptr->restore(n);
  228. }
  229. n++;
  230. }
  231. bibletime_ptr->restoreWorkspace();
  232. }
  233. else {
  234. const bool showIt = CBTConfig::get(CBTConfig::logo);
  235. if(showIt) {
  236. TDEStartupLogo::createSplash();
  237. TDEStartupLogo::showSplash();
  238. TDEStartupLogo::setStatusMessage( i18n("Starting BibleTime") + TQString("...") );
  239. }
  240. setSignalHandler(signalHandler);
  241. // compatibility stuff for 1.3, needs to be moved to better place later
  242. if (CBTConfig::get(CBTConfig::bibletimeVersion) != VERSION) {
  243. TDEStandardDirs stdDirs;
  244. TQDir dir(stdDirs.saveLocation("data", "bibletime/"));
  245. if (!dir.exists("sessions/") && dir.exists("profiles/")) { //only old dir exists
  246. dir.rename("profiles", "sessions");
  247. }
  248. }
  249. bibletime_ptr = new BibleTime();
  250. // a new BibleTime version was installed (maybe a completely new installation)
  251. if (CBTConfig::get(CBTConfig::bibletimeVersion) != VERSION) {
  252. TDEStartupLogo::hideSplash();
  253. CBTConfig::set(CBTConfig::bibletimeVersion, VERSION);
  254. bibletime_ptr->slotSettingsOptions();
  255. }
  256. //The tip of the day
  257. if (CBTConfig::get(CBTConfig::tips)) {
  258. TDEStartupLogo::hideSplash();
  259. bibletime_ptr->slotHelpTipOfDay();
  260. }
  261. // restore the workspace and process command line options
  262. app.setMainWidget(bibletime_ptr);
  263. bibletime_ptr->show();
  264. bibletime_ptr->processCommandline(); //must be done after the bibletime window is visible
  265. if (showIt) {
  266. TDEStartupLogo::hideSplash();
  267. TDEStartupLogo::deleteSplash();
  268. }
  269. }
  270. const int ret = app.exec();
  271. delete bibletime_ptr;
  272. return ret;
  273. }