kfile-plugins Library API Documentation

kfile_palm.cpp

00001 /* This file is part of the KDE project 00002 * Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> 00003 * Based on the vcf plugin: 00004 * Copyright (C) 2002 Shane Wright <me@shanewright.co.uk> 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public 00008 * License as published by the Free Software Foundation version 2. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; see the file COPYING. If not, write to 00017 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 * Boston, MA 02111-1307, USA. 00019 * 00020 */ 00021 00022 #include "kfile_palm.h" 00023 00024 #include <klocale.h> 00025 #include <kgenericfactory.h> 00026 00027 #include <qfile.h> 00028 #include <qdatetime.h> 00029 #include <pi-file.h> 00030 00031 00032 typedef KGenericFactory<KPalmPlugin> PalmFactory; 00033 00034 K_EXPORT_COMPONENT_FACTORY(kfile_palm, PalmFactory( "kfile_palm" )) 00035 00036 KPalmPlugin::KPalmPlugin(QObject *parent, const char *name, 00037 const QStringList &args) 00038 00039 : KFilePlugin(parent, name, args) 00040 { 00041 KFileMimeTypeInfo* info = addMimeTypeInfo( "application/vnd.palm" ); 00042 00043 KFileMimeTypeInfo::GroupInfo* group; 00044 KFileMimeTypeInfo::ItemInfo* item; 00045 00046 group = addGroupInfo(info, "General", i18n("General Information")); 00047 item = addItemInfo(group, "Name", i18n("Name"), QVariant::String); 00048 item = addItemInfo(group, "DBType", i18n("DB Type"), QVariant::String); 00049 item = addItemInfo(group, "TypeID", i18n("Type ID"), QVariant::String); 00050 item = addItemInfo(group, "CreatorID", i18n("Creator ID"), QVariant::String); 00051 item = addItemInfo(group, "NrRecords", i18n("# of Records"), QVariant::Int); 00052 00053 group = addGroupInfo(info, "TimeStamps", i18n("Time Stamps")); 00054 item = addItemInfo(group, "CreationDate", i18n("Creation Date"), QVariant::DateTime); 00055 item = addItemInfo(group, "ModificationDate", i18n("Modification Date"), QVariant::DateTime); 00056 item = addItemInfo(group, "BackupDate", i18n("Backup Date"), QVariant::DateTime); 00057 00058 group = addGroupInfo(info, "Flags", i18n("Flags")); 00059 item = addItemInfo(group, "ReadOnly", i18n("Read-Only"), QVariant::String); 00060 item = addItemInfo(group, "MakeBackup", i18n("Make Backup"), QVariant::String); 00061 item = addItemInfo(group, "CopyProtected", i18n("Copy Protected"), QVariant::String); 00062 item = addItemInfo(group, "Reset", i18n("Reset Handheld After Installing"), QVariant::String); 00063 item = addItemInfo(group, "ExcludeFromSync", i18n("Exclude From Sync"), QVariant::String); 00064 } 00065 00066 00067 bool KPalmPlugin::readInfo( KFileMetaInfo& info, uint /*what*/ ) 00068 { 00069 int nrRec; 00070 QString tempName = info.path(); 00071 QCString fileName = QFile::encodeName(tempName); 00072 pi_file *dbFile = pi_file_open(const_cast < char *>((const char *) fileName)); 00073 if (dbFile == 0L) return false; 00074 00075 struct DBInfo dBInfo; 00076 pi_file_get_info( dbFile, &dBInfo ); 00077 pi_file_get_entries( dbFile, &nrRec ); 00078 pi_file_close(dbFile); 00079 00080 KFileMetaInfoGroup generalGroup = appendGroup(info, "General"); 00081 appendItem(generalGroup, "Name", dBInfo.name ); 00082 appendItem(generalGroup, "DBType", (dBInfo.flags & dlpDBFlagResource)?i18n("PalmOS Application"):i18n("PalmOS Record Database") ); 00083 00084 char buff[5]; 00085 set_long(buff, dBInfo.type); 00086 buff[4]='\0'; 00087 appendItem(generalGroup, "TypeID", buff ); 00088 00089 set_long(buff, dBInfo.creator); 00090 buff[4]='\0'; 00091 appendItem(generalGroup, "CreatorID", buff ); 00092 appendItem(generalGroup, "NrRecords", nrRec ); 00093 00094 00095 KFileMetaInfoGroup timeGroup = appendGroup(info, "TimeStamps"); 00096 QDateTime tm; 00097 tm.setTime_t( dBInfo.createDate ); 00098 appendItem(timeGroup, "CreationDate", tm); 00099 tm.setTime_t( dBInfo.modifyDate ); 00100 appendItem(timeGroup, "ModificationDate", tm); 00101 tm.setTime_t( dBInfo.backupDate ); 00102 appendItem(timeGroup, "BackupDate", tm); 00103 00104 KFileMetaInfoGroup flagGroup = appendGroup(info, "Flags"); 00105 appendItem(flagGroup, "ReadOnly", (dBInfo.flags & dlpDBFlagReadOnly)?i18n("Yes"):i18n("No") ); 00106 appendItem(flagGroup, "MakeBackup", (dBInfo.flags & dlpDBFlagBackup)?i18n("Yes"):i18n("No") ); 00107 appendItem(flagGroup, "CopyProtected", (dBInfo.flags & dlpDBFlagCopyPrevention)?i18n("Yes"):i18n("No") ); 00108 appendItem(flagGroup, "Reset", (dBInfo.flags & dlpDBFlagReset)?i18n("Yes"):i18n("No") ); 00109 appendItem(flagGroup, "ExcludeFromSync", (dBInfo.miscFlags & dlpDBMiscFlagExcludeFromSync)?i18n("Yes"):i18n("No") ); 00110 00111 return true; 00112 } 00113 00114 /*bool KPalmPlugin::writeInfo( const KFileMetaInfo& info ) const 00115 { 00116 // int pi_file_set_info((struct pi_file * pf, struct DBInfo * infop)); 00117 //info["tuteTextTechnical"].value("An integer").toInt() 00118 // Do the stuff with low-level functions. See lines 1119-1142 of pi-file.cc for writing, 244-273 for reading. 00119 }*/ 00120 00121 #include "kfile_palm.moc"
KDE Logo
This file is part of the documentation for kfile-plugins Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:18:34 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003