kpilot/lib

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 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00007 **
00008 ** This file defines some global constants and macros for KPilot.
00009 ** In particular, KDE2 is defined when KDE2 seems to be the environment
00010 ** (is there a better way to do this?). Use of KDE2 to #ifdef sections
00011 ** of code is deprecated though.
00012 **
00013 ** Many debug functions are defined as well.
00014 */
00015 
00016 /*
00017 ** This program is free software; you can redistribute it and/or modify
00018 ** it under the terms of the GNU Lesser General Public License as published by
00019 ** the Free Software Foundation; either version 2.1 of the License, or
00020 ** (at your option) any later version.
00021 **
00022 ** This program is distributed in the hope that it will be useful,
00023 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00025 ** GNU Lesser General Public License for more details.
00026 **
00027 ** You should have received a copy of the GNU Lesser General Public License
00028 ** along with this program in a file called COPYING; if not, write to
00029 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00030 ** MA 02110-1301, USA.
00031 */
00032 
00033 /*
00034 ** Bug reports and questions can be sent to kde-pim@kde.org
00035 */
00036 
00037 // the hex edit widget is in cvs now, so we can enable it globally.
00038 // I still leave this flag here so one can always easily disable
00039 // the generic DB viewer, which uses the widget.
00040 #define USE_KHEXEDIT
00041 
00042 // Want to be as careful as possible about casting QStrings back and
00043 // forth, because of the potential for putting UTF-8 encoded data on the HH.
00044 // KHexEdit headers are not safe, though, so don't use this in general.
00045 #ifndef QT_NO_ASCII_CAST
00046 // #define QT_NO_ASCII_CAST     (1)
00047 #endif
00048 #ifndef QT_NO_CAST_ASCII
00049 // #define QT_NO_CAST_ASCII     (1)
00050 #endif
00051 
00052 
00053 // Switch _on_ debugging if it's not off.
00054 //
00055 #ifndef NDEBUG
00056 #ifndef DEBUG
00057 #define DEBUG               (1)
00058 #endif
00059 #endif
00060 
00061 // Switch on debugging explicitly. Perhaps send debug to stderr instead
00062 // of to the KDE debugging facility (it does lose some niftiness then).
00063 //
00064 #ifndef DEBUG
00065 // #define DEBUG            (1)
00066 #endif
00067 // #define DEBUG_CERR           (1)
00068 
00069 #ifdef HAVE_CONFIG_H
00070 #include "config.h"
00071 #endif
00072 
00073 #include <unistd.h>     /* For size_t for pilot-link */
00074 #include <qglobal.h>
00075 // For KDE_EXPORT with kdelibs 3.3.x
00076 #include <kdepimmacros.h>
00077 
00078 #if (QT_VERSION < 0x030200)
00079 #error "This is KPilot for KDE3.3 and won't compile with Qt < 3.2.0"
00080 #endif
00081 
00082 #ifndef KDE_VERSION
00083 #include <kdeversion.h>
00084 #endif
00085 
00086 #if !(KDE_IS_VERSION(3,3,0))
00087 #error "This is KPilot for KDE 3.3 and won't compile with KDE < 3.3.0"
00088 #endif
00089 
00090 #include "pilotLinkVersion.h"
00091 
00092 // For QString, and everything else needs it anyway.
00093 #include <qstring.h>
00094 // Dunno, really. Probably because everything needs it.
00095 #include <klocale.h>
00096 // For the debug stuff.
00097 #ifdef DEBUG
00098 #undef NDEBUG
00099 #undef NO_DEBUG
00100 #endif
00101 #include <kdebug.h>
00102 
00103 
00104 
00105 extern KDE_EXPORT int debug_level;
00106 
00107 #ifdef DEBUG
00108 #ifdef __GNUC__
00109 #define KPILOT_FNAMEDEF(l)  KPilotDepthCount fname(DEBUGAREA,l,__FUNCTION__)
00110 #else
00111 #define KPILOT_FNAMEDEF(l)  KPilotDepthCount fname(DEBUGAREA,l,__FILE__ ":" "__LINE__")
00112 #endif
00113 
00114 #define FUNCTIONSETUP       KPILOT_FNAMEDEF(1)
00115 #define FUNCTIONSETUPL(l)   KPILOT_FNAMEDEF(l)
00116 #define DEBUGAREA       0
00117 
00118 #define DEBUGAREA_KPILOT    5510
00119 #define DEBUGAREA_DAEMON    5511
00120 #define DEBUGAREA_CONDUIT   5512
00121 #define DEBUGAREA_DB        5513
00122 
00123 #ifdef DEBUG_CERR
00124 #include <iostream>
00125 #endif
00126 
00127 class KDE_EXPORT KPilotDepthCount
00128 {
00129 public:
00130     KPilotDepthCount(int area, int level, const char *s);
00131     ~KPilotDepthCount();
00132     QString indent() const;
00133     const char *name() const { return fName; } ;
00134     // if DEBUG_CERR is defined, we can't return std::cerr (by value),
00135     // since the copy constructor is private!
00136 #ifndef DEBUG_CERR
00137     inline kdbgstream debug(int area=0)
00138     { return kdDebug(debug_level >= fLevel, area); }
00139 #endif
00140 
00141 protected:
00142     static int depth;
00143     int fDepth;
00144     int fLevel;
00145     const char *fName;
00146 } ;
00147 
00148 // stderr / iostream-based debugging.
00149 //
00150 //
00151 #ifdef DEBUG_CERR
00152 #include <iostream>
00153 #define DEBUGKPILOT std::cerr
00154 #define DEBUGDAEMON std::cerr
00155 #define DEBUGCONDUIT    std::cerr
00156 #define DEBUGDB     std::cerr
00157 
00158 using namespace std;
00159 
00160 inline std::ostream& operator <<(std::ostream &o, const QString &s)
00161     { if (s.isEmpty()) return o<<"<empty>"; else return o<<s.latin1(); }
00162 inline std::ostream& operator <<(std::ostream &o, const QCString &s)
00163     { if (s.isEmpty()) return o<<"<empty>"; else return o << *s; }
00164 
00165 
00166 
00167 inline std::ostream& operator <<(std::ostream &o, const KPilotDepthCount &d)
00168     { return o << d.indent() << ' ' << d.name(); }
00169 
00170 #else
00171 
00172 // kddebug based debugging
00173 //
00174 //
00175 #define DEBUGKPILOT fname.debug(DEBUGAREA_KPILOT)
00176 #define DEBUGDAEMON fname.debug(DEBUGAREA_DAEMON)
00177 #define DEBUGCONDUIT    fname.debug(DEBUGAREA_CONDUIT)
00178 #define DEBUGDB         fname.debug(DEBUGAREA_DB)
00179 
00180 inline kdbgstream& operator <<(kdbgstream o, const KPilotDepthCount &d)
00181     { return o << d.indent() ; }
00182 
00183 #endif
00184 
00185 
00186 // no debugging at all
00187 //
00188 #else
00189 #define DEBUGSTREAM kndbgstream
00190 #define DEBUGKPILOT kndDebug()
00191 #define DEBUGDAEMON kndDebug()
00192 #define DEBUGCONDUIT    kndDebug()
00193 #define DEBUGDB         kndDebug()
00194 
00195 // With debugging turned off, FUNCTIONSETUP doesn't do anything.
00196 //
00197 //
00198 #define FUNCTIONSETUP const int fname = 0; Q_UNUSED(fname);
00199 #define FUNCTIONSETUPL(a) const int fname = a; Q_UNUSED(fname);
00200 #endif
00201 
00202 #define KPILOT_VERSION  "4.6.0 (blivit)"
00203 
00204 
00205 // Function to expand newlines in rich text to <br>\n
00206 QString rtExpand(const QString &s, bool richText=true);
00207 
00208 
00209 
00213 KDE_EXPORT QDateTime readTm(const struct tm &t);
00217 KDE_EXPORT struct tm writeTm(const QDateTime &dt);
00218 KDE_EXPORT struct tm writeTm(const QDate &dt);
00219 
00220 
00221 // Some layout macros
00222 //
00223 // SPACING is a generic distance between visual elements;
00224 // 10 seems reasonably good even at high resolutions.
00225 //
00226 //
00227 #define SPACING     (10)
00228 
00229 // Semi-Standard safe-free expression. Argument a may be evaluated more
00230 // than once though, so be careful.
00231 //
00232 //
00233 #define KPILOT_FREE(a)  { if (a) { ::free(a); a=0L; } }
00234 #define KPILOT_DELETE(a) { if (a) { delete a; a=0L; } }
00235 
00236 
00237 // This marks strings that need to be i18n()ed in future,
00238 // but cannot be done now due to message freeze. The _P
00239 // variant is to handle plurals and is wrong, but unavoidable.
00240 //
00241 //
00242 #define TODO_I18N(a)    QString::fromLatin1(a)
00243 #define TODO_I18N_P(a,b,c) ((c>1) ? a : b)
00244 
00245 // Handle some cases for QT_NO_CAST_ASCII and NO_ASCII_CAST.
00246 // Where possible in the source, known constant strings in
00247 // latin1 encoding are marked with CSL1(), to avoid gobs
00248 // of latin1() or fromlatin1() calls which might obscure
00249 // those places where the code really is translating
00250 // user data from latin1.
00251 //
00252 // The extra "" in CSL1 is to enforce that it's only called
00253 // with constant strings.
00254 //
00255 //
00256 #define CSL1(a)     QString::fromLatin1(a "")
00257 
00258 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys