kpilot/lib
pilotAppInfo.cc
00001 /* pilotAppInfo.cc KPilot 00002 ** 00003 ** Copyright (C) 2005-2006 Adriaan de Groot <groot@kde.org> 00004 ** 00005 */ 00006 00007 /* 00008 ** This program is free software; you can redistribute it and/or modify 00009 ** it under the terms of the GNU Lesser General Public License as published by 00010 ** the Free Software Foundation; either version 2.1 of the License, or 00011 ** (at your option) any later version. 00012 ** 00013 ** This program is distributed in the hope that it will be useful, 00014 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 ** GNU Lesser General Public License for more details. 00017 ** 00018 ** You should have received a copy of the GNU Lesser General Public License 00019 ** along with this program in a file called COPYING; if not, write to 00020 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00021 ** MA 02110-1301, USA. 00022 */ 00023 00024 /* 00025 ** Bug reports and questions can be sent to kde-pim@kde.org 00026 */ 00027 00028 00029 #include "options.h" 00030 00031 #include <stdio.h> 00032 00033 #include "pilotAppInfo.h" 00034 00035 PilotAppInfoBase::PilotAppInfoBase(PilotDatabase *d) : fC(new struct CategoryAppInfo), fLen(0), fOwn(true) 00036 { 00037 FUNCTIONSETUP; 00038 int appLen = Pilot::MAX_APPINFO_SIZE; 00039 unsigned char buffer[Pilot::MAX_APPINFO_SIZE]; 00040 00041 if (!d || !d->isOpen()) 00042 { 00043 kdError() << "Bad database pointer." << endl; 00044 fLen = 0; 00045 KPILOT_DELETE( fC ); 00046 return; 00047 } 00048 fLen = appLen = d->readAppBlock(buffer,appLen); 00049 unpack_CategoryAppInfo(fC, buffer, appLen); 00050 } 00051 00052 PilotAppInfoBase::~PilotAppInfoBase() 00053 { 00054 if (fOwn) delete fC; 00055 } 00056 00057 bool PilotAppInfoBase::setCategoryName(unsigned int i, const QString &s) 00058 { 00059 if ( (i>=Pilot::CATEGORY_COUNT) || // bad category number 00060 (!categoryInfo())) // Nowhere to write to 00061 { 00062 return false; 00063 } 00064 00065 (void) Pilot::toPilot(s, categoryInfo()->name[i], Pilot::CATEGORY_SIZE - 1); 00066 return true; 00067 } 00068 00069