kpilot Library API Documentation

pilotRecord.cc

00001 /* pilotRecord.cc                       KPilot
00002 **
00003 ** Copyright (C) 1998-2001 by Dan Pilone
00004 **
00005 ** This is a wrapper for pilot-link's general
00006 ** Pilot database structures. These records are
00007 *** just collections of bits. See PilotAppCategory
00008 ** for interpreting the bits in a meaningful way.
00009 **
00010 ** As a crufty hack, the non-inline parts of
00011 ** PilotAppCategory live in this file as well.
00012 */
00013 
00014 /*
00015 ** This program is free software; you can redistribute it and/or modify
00016 ** it under the terms of the GNU Lesser General Public License as published by
00017 ** the Free Software Foundation; either version 2.1 of the License, or
00018 ** (at your option) any later version.
00019 **
00020 ** This program is distributed in the hope that it will be useful,
00021 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00023 ** GNU Lesser General Public License for more details.
00024 **
00025 ** You should have received a copy of the GNU Lesser General Public License
00026 ** along with this program in a file called COPYING; if not, write to
00027 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00028 ** MA 02111-1307, USA.
00029 */
00030 
00031 /*
00032 ** Bug reports and questions can be sent to kde-pim@kde.org
00033 */
00034 #include "options.h"
00035 
00036 #include <string.h>
00037 
00038 #include <qtextcodec.h>
00039 
00040 // PilotAppCategory includes pilotRecord and we
00041 // provide its implementation here as well.
00042 //
00043 #include "pilotAppCategory.h"
00044 
00045 
00046 
00047 static const char *pilotRecord_id =
00048         "$Id: pilotRecord.cc,v 1.3.4.7 2003/03/10 23:06:19 adridg Exp $";
00049 
00050 /* static */ int PilotRecord::fAllocated = 0;
00051 /* static */ int PilotRecord::fDeleted = 0;
00052 
00053 /* static */ void PilotRecord::allocationInfo()
00054 {
00055 #ifdef DEBUG
00056         FUNCTIONSETUP;
00057         DEBUGKPILOT << fname
00058                 << ": Allocated " << fAllocated
00059                 << "  Deleted " << fDeleted;
00060 #endif
00061 }
00062 
00063 PilotRecord::PilotRecord(void *data, int len, int attrib, int cat,
00064         pi_uid_t uid) :
00065         fData(0L),
00066         fLen(len),
00067         fAttrib(attrib),
00068         fCat(cat),
00069         fID(uid)
00070 {
00071         FUNCTIONSETUP;
00072         fData = new char[len];
00073 
00074         memcpy(fData, data, len);
00075 
00076         fAllocated++;
00077         (void) pilotRecord_id;
00078 }
00079 
00080 PilotRecord::PilotRecord(PilotRecord * orig)
00081 {
00082         FUNCTIONSETUP;
00083         fData = new char[orig->getLen()];
00084 
00085         memcpy(fData, orig->getData(), orig->getLen());
00086         fLen = orig->getLen();
00087         fAttrib = orig->getAttrib();
00088         fCat = orig->getCat();
00089         fID = orig->getID();
00090 
00091         fAllocated++;
00092 }
00093 
00094 PilotRecord & PilotRecord::operator = (PilotRecord & orig)
00095 {
00096         FUNCTIONSETUP;
00097         if (fData)
00098                 delete[]fData;
00099         fData = new char[orig.getLen()];
00100 
00101         memcpy(fData, orig.getData(), orig.getLen());
00102         fLen = orig.getLen();
00103         fAttrib = orig.getAttrib();
00104         fCat = orig.getCat();
00105         fID = orig.getID();
00106         return *this;
00107 }
00108 
00109 void PilotRecord::setData(const char *data, int len)
00110 {
00111         FUNCTIONSETUP;
00112         if (fData)
00113                 delete[]fData;
00114         fData = new char[len];
00115 
00116         memcpy(fData, data, len);
00117         fLen = len;
00118 }
00119 
00120 
00121 /* static */ QTextCodec *PilotAppCategory::pilotCodec = 0L;
00122 
00123 static const char *latin1 = "ISO8859-1" ;
00124 // Other names of encodings are in the config dialog source
00125 
00126 /* static */ QTextCodec *PilotAppCategory::createCodec(const char *p)
00127 {
00128         FUNCTIONSETUP;
00129 
00130         if (!p) p=latin1;
00131 #ifdef DEBUG
00132         DEBUGKPILOT << ": Creating codec for " << p << endl;
00133 #endif
00134         QTextCodec *q = QTextCodec::codecForName(p);
00135         if (!q) q = QTextCodec::codecForName(latin1);
00136         pilotCodec = q;
00137         return q;
00138 }
00139 
00140 /* static */ QTextCodec *PilotAppCategory::setupPilotCodec(const QString &s)
00141 {
00142         FUNCTIONSETUP;
00143 
00144 #ifdef DEBUG
00145         DEBUGKPILOT << fname
00146                 << ": Creating codec " << s << endl;
00147 #endif
00148 
00149         const char *p = 0L;
00150         // This latin1() is OK. The names of the encodings
00151         // as shown in the table in the QTextCodec docs
00152         // are all US-ASCII.
00153         if (!s.isEmpty()) p=s.latin1();
00154         
00155         (void) PilotAppCategory::createCodec(p);
00156 
00157 #ifdef DEBUG
00158         DEBUGKPILOT << fname
00159                 << ": Got codec " << codec()->name() << endl;
00160 #endif
00161         return codec();
00162 }
00163 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:44 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001