options.h
00001 #ifndef _KPILOT_OPTIONS_H 00002 #define _KPILOT_OPTIONS_H 00003 /* options.h KPilot 00004 ** 00005 ** Copyright (C) 1998-2001,2002,2003 by Dan Pilone 00006 ** 00007 ** This file defines some global constants and macros for KPilot. 00008 ** In particular, KDE2 is defined when KDE2 seems to be the environment 00009 ** (is there a better way to do this?). Use of KDE2 to #ifdef sections 00010 ** of code is deprecated though. 00011 ** 00012 ** Many debug functions are defined as well. 00013 */ 00014 00015 /* 00016 ** This program is free software; you can redistribute it and/or modify 00017 ** it under the terms of the GNU Lesser General Public License as published by 00018 ** the Free Software Foundation; either version 2.1 of the License, or 00019 ** (at your option) any later version. 00020 ** 00021 ** This program is distributed in the hope that it will be useful, 00022 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 ** GNU Lesser General Public License for more details. 00025 ** 00026 ** You should have received a copy of the GNU Lesser General Public License 00027 ** along with this program in a file called COPYING; if not, write to 00028 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00029 ** MA 02111-1307, USA. 00030 */ 00031 00032 /* 00033 ** Bug reports and questions can be sent to kde-pim@kde.org 00034 */ 00035 00036 00037 00038 // #define QT_NO_ASCII_CAST (1) 00039 // #define QT_NO_CAST_ASCII (1) 00040 00041 00042 #ifdef HAVE_CONFIG_H 00043 #include "config.h" 00044 #endif 00045 00046 #ifndef QT_VERSION 00047 #include <qglobal.h> 00048 #endif 00049 00050 #if (QT_VERSION < 223) 00051 #error "This is KPilot for KDE2 and won't compile with Qt < 2.2.3" 00052 #endif 00053 00054 #ifndef KDE_VERSION 00055 #include <kdeversion.h> 00056 #endif 00057 00058 #if KDE_VERSION > 289 00059 #define KDE3 00060 #undef KDE2 00061 #else 00062 #undef KDE3 00063 #define KDE2 00064 #endif 00065 00066 // Turn ON as much debugging as possible with -DDEBUG -DDEBUG_CERR 00067 // Some systems have changed kdWarning() and kdDebug() into nops, 00068 // so DEBUG_CERR changes them into cerr again. Odd and disturbing. 00069 // 00070 00071 00072 #ifdef DEBUG_CERR 00073 #define DEBUGFUNC cerr 00074 #else 00075 #define DEBUGFUNC kdDebug() 00076 #endif 00077 00078 // For ostream 00079 #include <iostream> 00080 // For QString, and everything else needs it anyway. 00081 #include <qstring.h> 00082 // Dunno, really. Probably because everything needs it. 00083 #include <klocale.h> 00084 // For the debug stuff. 00085 #include <kdebug.h> 00086 00087 using namespace std; 00088 00089 // KPilot will move towards the *standard* way of doing 00090 // debug messages soon. This means that we need some 00091 // debug areas. 00092 // 00093 // 00094 #define KPILOT_AREA 5510 00095 #define DAEMON_AREA 5511 00096 #define CONDUIT_AREA 5512 00097 #define LIBPILOTDB_AREA 5513 00098 00099 #ifdef DEBUG_CERR 00100 #define DEBUGSTREAM ostream 00101 #define DEBUGKPILOT cerr 00102 #define DEBUGDAEMON cerr 00103 #define DEBUGCONDUIT cerr 00104 #define DEBUGDB cerr 00105 #else 00106 #define DEBUGSTREAM kdbgstream 00107 #define DEBUGKPILOT kdDebug(KPILOT_AREA) 00108 #define DEBUGDAEMON kdDebug(DAEMON_AREA) 00109 #define DEBUGCONDUIT kdDebug(CONDUIT_AREA) 00110 #define DEBUGDB kdDebug(LIBPILOTDB_AREA) 00111 #endif 00112 00113 #define KPILOT_VERSION "4.3.10 (BRANCH)" 00114 00115 // * KPilot debugging code looks like: 00116 // 00117 // DEBUGKPILOT << fname << ": Creating dialog window." << endl; 00118 // 00119 // This uses KDE's debug areas (accessible through kdebugdialog) 00120 // to keep track of what to print. No extra #if or if(), since the 00121 // global NDEBUG flag changes all the kdDebug() calls into nops and 00122 // the compiler optimizes them away. There are four DEBUG* macros, 00123 // defined above. Use the areas *_AREA in calls to kdWarning() or 00124 // kdError() to make sure the right output is generated. 00125 00126 00127 extern int debug_level; 00128 extern const char *debug_spaces; 00129 00130 class KCmdLineOptions; 00131 extern KCmdLineOptions *debug_options; 00132 00133 #ifdef DEBUG 00134 // Both old and new-style debugging suggest (insist?) that 00135 // every function be started with the macro FUNCTIONSETUP, 00136 // which outputs function and line information on every call. 00137 // 00138 // 00139 #ifdef __GNUC__ 00140 #define KPILOT_FNAMEDEF static const char *fname=__FUNCTION__ 00141 #define KPILOT_LOCNDEF debug_spaces+(::strlen(fname)) \ 00142 << "(" << __FILE__ << ":" << \ 00143 __LINE__ << ")\n" 00144 #else 00145 #define KPILOT_FNAMEDEF static const char *fname=__FILE__ ":" "__LINE__" 00146 #define KPILOT_LOCNDEF "\n" 00147 #endif 00148 00149 #define FUNCTIONSETUP KPILOT_FNAMEDEF; \ 00150 if (debug_level) { DEBUGFUNC << \ 00151 fname << KPILOT_LOCNDEF ; } 00152 #define FUNCTIONSETUPL(l) KPILOT_FNAMEDEF; \ 00153 if (debug_level>l) { DEBUGFUNC << \ 00154 fname << KPILOT_LOCNDEF; } 00155 00156 class KConfig; 00157 00158 // Next all kinds of specialty debugging functions, 00159 // added in an ad-hoc fashion. 00160 // 00161 // 00162 QString qstringExpansion(const QString &); 00163 QString charExpansion(const char *); 00164 00165 #else 00166 // With debugging turned off, FUNCTIONSETUP doesn't do anything. 00167 // In particular it doesn't give functions a local variable fname, 00168 // like FUNCTIONSETUP does in the debugging case. Since code like 00169 // 00170 // DEBUGKPILOT << fname << ": Help! I'm descructing" << endl; 00171 // 00172 // is still visible in KPilot (it isn't all bracketed by #ifdef DEBUG 00173 // and it doesn't *need* to be, that's the whole point of kdDebug()) 00174 // we still need *something* with the name fname. So we'll declare a 00175 // single extern fname here. 00176 // 00177 // fname gets a weird type that is 00178 // incompatible with kdWarning() and kdError(), leading to warnings 00179 // if you mix them. Use k_funcinfo instead. 00180 // 00181 // 00182 #define FUNCTIONSETUP 00183 #define FUNCTIONSETUPL(a) 00184 #endif 00185 00186 class KConfig; 00187 00188 // Next all kinds of specialty debugging functions, 00189 // added in an ad-hoc fashion. 00190 // 00191 // 00192 QString qstringExpansion(const QString &); 00193 QString charExpansion(const char *); 00194 00195 // class QStringList; 00196 // ostream& operator <<(ostream&,const QStringList &); 00197 // kdbgstream& operator <<(kdbgstream&,const QStringList &); 00198 00199 00200 // Some layout macros 00201 // 00202 // SPACING is a generic distance between visual elements; 00203 // 10 seems reasonably good even at high resolutions. 00204 // 00205 // 00206 #define SPACING (10) 00207 00208 // Semi-Standard safe-free expression. Argument a may be evaluated more 00209 // than once though, so be careful. 00210 // 00211 // 00212 #define KPILOT_FREE(a) { if (a) { ::free(a); a=0L; } } 00213 #define KPILOT_DELETE(a) { if (a) { delete a; a=0L; } } 00214 00215 00216 // This marks strings that need to be i18n()ed in future, 00217 // but cannot be done now due to message freeze. 00218 // 00219 // 00220 #define TODO_I18N(a) QString::fromLatin1(a) 00221 00222 // Handle some cases for QT_NO_CAST_ASCII and NO_ASCII_CAST. 00223 // Where possible in the source, known constant strings in 00224 // latin1 encoding are marked with CSL1(), to avoid gobs 00225 // of latin1() or fromlatin1() calls which might obscure 00226 // those places where the code really is translating 00227 // user data from latin1. 00228 // 00229 // The extra "" in CSL1 is to enforce that it's only called 00230 // with constant strings. 00231 // 00232 // 00233 #define CSL1(a) QString::fromLatin1(a "") 00234 00235 #endif