From 66abbed5e08370412b81be1628590898ceeeb604 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 29 May 2021 19:05:31 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- conduits/sysinfoconduit/CMakeLists.txt | 4 +- conduits/sysinfoconduit/Makefile.am | 6 +- conduits/sysinfoconduit/sysinfo-conduit.cc | 611 ---------------------------- conduits/sysinfoconduit/sysinfo-conduit.cpp | 611 ++++++++++++++++++++++++++++ conduits/sysinfoconduit/sysinfo-factory.cc | 43 -- conduits/sysinfoconduit/sysinfo-factory.cpp | 43 ++ conduits/sysinfoconduit/sysinfo-setup.cc | 198 --------- conduits/sysinfoconduit/sysinfo-setup.cpp | 198 +++++++++ 8 files changed, 857 insertions(+), 857 deletions(-) delete mode 100644 conduits/sysinfoconduit/sysinfo-conduit.cc create mode 100644 conduits/sysinfoconduit/sysinfo-conduit.cpp delete mode 100644 conduits/sysinfoconduit/sysinfo-factory.cc create mode 100644 conduits/sysinfoconduit/sysinfo-factory.cpp delete mode 100644 conduits/sysinfoconduit/sysinfo-setup.cc create mode 100644 conduits/sysinfoconduit/sysinfo-setup.cpp (limited to 'conduits/sysinfoconduit') diff --git a/conduits/sysinfoconduit/CMakeLists.txt b/conduits/sysinfoconduit/CMakeLists.txt index 10f85e5..36a3172 100644 --- a/conduits/sysinfoconduit/CMakeLists.txt +++ b/conduits/sysinfoconduit/CMakeLists.txt @@ -16,8 +16,8 @@ link_directories( ##### conduit_sysinfo (kpart) ################### tde_add_kpart( conduit_sysinfo AUTOMOC - SOURCES sysinfoSettings.kcfgc sysinfo-factory.cc sysinfo-setup.cc - sysinfo-conduit.cc sysinfo-setup_dialog.ui + SOURCES sysinfoSettings.kcfgc sysinfo-factory.cpp sysinfo-setup.cpp + sysinfo-conduit.cpp sysinfo-setup_dialog.ui LINK kpilot-shared tdeui-shared tdeio-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/conduits/sysinfoconduit/Makefile.am b/conduits/sysinfoconduit/Makefile.am index f77d086..be840c2 100644 --- a/conduits/sysinfoconduit/Makefile.am +++ b/conduits/sysinfoconduit/Makefile.am @@ -11,9 +11,9 @@ service_DATA = sysinfo_conduit.desktop kde_module_LTLIBRARIES = conduit_sysinfo.la conduit_sysinfo_la_SOURCES = sysinfoSettings.kcfgc \ - sysinfo-factory.cc \ - sysinfo-setup.cc \ - sysinfo-conduit.cc \ + sysinfo-factory.cpp \ + sysinfo-setup.cpp \ + sysinfo-conduit.cpp \ sysinfo-setup_dialog.ui conduit_sysinfo_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) $(PISOCK_LIB) $(LIB_TQT) -ltdecore -ltdeio -ltdeui conduit_sysinfo_la_LIBADD = ../../lib/libkpilot.la $(LIB_TDEUI) $(LIB_TDEIO) diff --git a/conduits/sysinfoconduit/sysinfo-conduit.cc b/conduits/sysinfoconduit/sysinfo-conduit.cc deleted file mode 100644 index 08c0f14..0000000 --- a/conduits/sysinfoconduit/sysinfo-conduit.cc +++ /dev/null @@ -1,611 +0,0 @@ -/* KPilot -** -** Copyright (C) 2003 by Reinhold Kainhofer -** -*/ - -/* -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program in a file called COPYING; if not, write to -** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -** MA 02110-1301, USA. -*/ - -/* -** Bug reports and questions can be sent to kde-pim@kde.org. -*/ - -#include "options.h" - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include "sysinfo-factory.h" -#include "sysinfo-conduit.moc" -#include "sysinfoSettings.h" - -const TQString SysInfoConduit::defaultpage = CSL1("KPilot System Information Page\n" -"==============================\n" -"(Kpilot was unable to find the correct template file, \n" -"so this simple template was used.)\n\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"\n" -"------------------------------------------------------------\n" -"Page created by the KPilot System Information conduit.\n" -""); - - - /** possible fields in the templates are: - * - hardware - * - user - * - memory - * - storage - * - dblist - * - recnumber - * - syncinfo - * - pcversion - * - palmversion - * - debug - */ - - -// Something to allow us to check what revision -// the modules are that make up a binary distribution. - -extern "C" -{ - -unsigned long version_conduit_sysinfo = Pilot::PLUGIN_API; - -} - - - -SysInfoConduit::SysInfoConduit(KPilotLink * o, - const char *n, - const TQStringList & a) : - ConduitAction(o, n, a) -{ - FUNCTIONSETUP; - fConduitName=i18n("System Information"); -} - - - -SysInfoConduit::~SysInfoConduit() -{ - FUNCTIONSETUP; -} - - - -void SysInfoConduit::readConfig() -{ - fOutputFile = SysinfoSettings::outputFile(); - fOutputType = (eOutputTypeEnum) SysinfoSettings::outputFormat(); - fTemplateFile = SysinfoSettings::templateFile(); - fHardwareInfo = SysinfoSettings::hardwareInfo(); - fUserInfo = SysinfoSettings::userInfo(); - fMemoryInfo = SysinfoSettings::memoryInfo(); - fStorageInfo = SysinfoSettings::storageInfo(); - fDBList = SysinfoSettings::databaseList(); - fRecordNumber = SysinfoSettings::recordNumbers(); - fSyncInfo = SysinfoSettings::syncInfo(); - fKDEVersion = SysinfoSettings::kDEVersion(); - fPalmOSVersion = SysinfoSettings::palmOSVersion(); - fDebugInfo = SysinfoSettings::debugInformation(); -} - - -/* virtual */ bool SysInfoConduit::exec() -{ - FUNCTIONSETUP; - - readConfig(); - - TQTimer::singleShot(0, this, TQT_SLOT(hardwareInfo())); - return true; -} - -void SysInfoConduit::hardwareInfo() -{ - FUNCTIONSETUP; - if (fHardwareInfo) { - TQString unknown = i18n("unknown"); - - /* Retrieve values for - * - #deviceid# - * - #devicename# - * - #devicemodel# - * - #manufactorer# - * - #devicetype# - */ - KPilotSysInfo sysinfo = fHandle->getSysInfo(); - fValues[CSL1("deviceid")] = TQString::fromLatin1(sysinfo.getProductID()); - - const KPilotCard *device = fHandle->getCardInfo(); - if (device) - { - fValues[CSL1("devicename")] = TQString::fromLatin1(device->getCardName()); - fValues[CSL1("devicemodel")] = unknown; // TODO - fValues[CSL1("manufacturer")] = TQString::fromLatin1(device->getCardManufacturer()); - } - else - { - fValues[CSL1("devicename")] = unknown; - fValues[CSL1("devicemodel")] = unknown; - fValues[CSL1("manufacturer")] = unknown; - } - - fValues[CSL1("devicetype")] = unknown; - - KPILOT_DELETE(device); - keepParts.append(CSL1("hardware")); - } else removeParts.append(CSL1("hardware")); - TQTimer::singleShot(0, this, TQT_SLOT(userInfo())); -} - -void SysInfoConduit::userInfo() -{ - FUNCTIONSETUP; - if (fUserInfo) - { - /* Retrieve values for - * - #username# - * - #uid# - */ - KPilotUser user=fHandle->getPilotUser(); - fValues[CSL1("username")] = user.name(); - if (user.passwordLength()>0) - { - fValues[CSL1("pw")] = i18n("Password set"); - } - else - { - fValues[CSL1("pw")] = i18n("No password set"); - } - fValues[CSL1("uid")] = TQString::number(user.data()->userID); - fValues[CSL1("viewerid")] = TQString::number(user.data()->viewerID); - keepParts.append(CSL1("user")); - } - else - { - removeParts.append(CSL1("user")); - } - TQTimer::singleShot(0, this, TQT_SLOT(memoryInfo())); -} - -void SysInfoConduit::memoryInfo() -{ - FUNCTIONSETUP; - if (fMemoryInfo) { - /* Retrieve values for - * - #rom# - * - #totalmem# - * - #freemem# - */ - const KPilotCard *device = fHandle->getCardInfo(); - if (device) - { - fValues[CSL1("rom")] = TQString::number(device->getRomSize()/1024); - fValues[CSL1("totalmem")] = TQString::number(device->getRamSize()/1024); - fValues[CSL1("freemem")] = TQString::number(device->getRamFree()/1024); - } - keepParts.append(CSL1("memory")); - } else removeParts.append(CSL1("memory")); - TQTimer::singleShot(0, this, TQT_SLOT(storageInfo())); -} - -void SysInfoConduit::storageInfo() -{ - FUNCTIONSETUP; - if (fStorageInfo) { - /* Retrieve values for - * - $cards$ - */ - const KPilotCard *device = fHandle->getCardInfo(1); - if (device) { - fValues[CSL1("cards")] = CSL1("%1 (%2, %3 kB of %3 kB free)") - .arg(TQString::fromLatin1(device->getCardName())) - .arg(TQString::fromLatin1(device->getCardManufacturer())) - .arg(device->getRamFree()/1024) - .arg(device->getRamSize()/1024); - KPILOT_DELETE(device); - } else { - fValues[CSL1("cards")] = i18n("No Cards available via pilot-link"); - } - keepParts.append(CSL1("storage")); - } else removeParts.append(CSL1("storage")); - TQTimer::singleShot(0, this, TQT_SLOT(dbListInfo())); -} - -void SysInfoConduit::dbListInfo() -{ - FUNCTIONSETUP; - if (fDBList) { - /* Retrieve values for - * - #dblist(structure)# - */ - dblist=deviceLink()->getDBList(); - keepParts.append(CSL1("dblist")); - } else removeParts.append(CSL1("dblist")); - TQTimer::singleShot(0, this, TQT_SLOT(recNumberInfo())); -} - -void SysInfoConduit::recNumberInfo() -{ - FUNCTIONSETUP; - if (fRecordNumber) { - /* Retrieve values for - * - #addresses# - * - #events# - * - #todos# - * - #memos# - */ - PilotDatabase *fDatabase = 0L; - TQString ERROR = CSL1("ERROR"); - fValues[CSL1("addresses")] = ERROR; - fValues[CSL1("events")] = ERROR; - fValues[CSL1("todos")] = ERROR; - fValues[CSL1("memos")] = ERROR; - fDatabase = deviceLink()->database(CSL1("AddressDB")); - if (fDatabase) { - fValues[CSL1("addresses")] = TQString::number(fDatabase->recordCount()); - KPILOT_DELETE(fDatabase); - } - fDatabase = deviceLink()->database(CSL1("DatebookDB")); - if (fDatabase) { - fValues[CSL1("events")] = TQString::number(fDatabase->recordCount()); - KPILOT_DELETE(fDatabase); - } - fDatabase = deviceLink()->database(CSL1("ToDoDB")); - if (fDatabase) { - fValues[CSL1("todos")] = TQString::number(fDatabase->recordCount()); - KPILOT_DELETE(fDatabase); - } - fDatabase = deviceLink()->database(CSL1("MemoDB")); - if (fDatabase) { - fValues[CSL1("memos")] = TQString::number(fDatabase->recordCount()); - KPILOT_DELETE(fDatabase); - } - keepParts.append(CSL1("records")); - } else removeParts.append(CSL1("records")); - TQTimer::singleShot(0, this, TQT_SLOT(syncInfo())); -} - -void SysInfoConduit::syncInfo() -{ - FUNCTIONSETUP; - if (fSyncInfo) { - /* Retrieve values for - * - #lastsync# - * - #lastsuccsync# - * - #lastsyncpc# - */ - KPilotUser user = deviceLink()->getPilotUser(); - time_t lastsync = user.getLastSyncDate(); - TQDateTime qlastsync; - qlastsync.setTime_t(lastsync); - fValues[CSL1("lastsync")] = qlastsync.toString(Qt::LocalDate); - lastsync = user.getLastSuccessfulSyncDate(); - qlastsync.setTime_t(lastsync); - fValues[CSL1("lastsuccsync")] = qlastsync.toString(Qt::LocalDate); - fValues[CSL1("lastsyncpc")] = TQString::number(user.getLastSyncPC()); - keepParts.append(CSL1("sync")); - } else removeParts.append(CSL1("sync")); - TQTimer::singleShot(0, this, TQT_SLOT(pcVersionInfo())); -} - -void SysInfoConduit::pcVersionInfo() -{ - FUNCTIONSETUP; - if (fKDEVersion) { - /* Retrieve values for - * - #os# - * - #qt# - * - #kde# - * - #kpilot# - * - #pilotlink# - */ - fValues[CSL1("kpilot")] = TQString::fromLatin1(KPILOT_VERSION); - fValues[CSL1("kde")] = i18n("unknown"); - fValues[CSL1("qt")] = i18n("unknown"); - fValues[CSL1("os")] = i18n("unknown"); - fValues[CSL1("hostname")] = i18n("unknown"); - struct utsname name; - if (uname (&name) >= 0) { - fValues[CSL1("os")] = CSL1("%1 %3, %5") - .arg(TQString::fromLatin1(name.sysname)) - .arg(TQString::fromLatin1(name.release)) - .arg(TQString::fromLatin1(name.machine)); - fValues[CSL1("hostname")] = CSL1("%2").arg(TQString::fromLatin1(name.nodename)); - } -#ifdef TDE_VERSION_STRING - fValues[CSL1("kde")] = TQString::fromLatin1(TDE_VERSION_STRING); -#endif -#ifdef TQT_VERSION_STR - fValues[CSL1("qt")] = TQString::fromLatin1(TQT_VERSION_STR); -#endif - fValues[CSL1("pilotlink")] = CSL1("%1.%2.%3%4") - .arg(PILOT_LINK_VERSION) - .arg(PILOT_LINK_MAJOR) - .arg(PILOT_LINK_MINOR) -#ifdef PILOT_LINK_PATCH - .arg(TQString::fromLatin1(PILOT_LINK_PATCH)); -#else - .arg(TQString()); -#endif - keepParts.append(CSL1("pcversion")); - } else removeParts.append(CSL1("pcversion")); - TQTimer::singleShot(0, this, TQT_SLOT(palmVersionInfo())); -} - -void SysInfoConduit::palmVersionInfo() -{ - FUNCTIONSETUP; - if (fPalmOSVersion) { - /* Retrieve values for - * - #palmos# - */ -/* fValues["palmos"] = TQString("PalmOS %1.%2 (compat %3.%4)") - .arg(fHandle->getSysInfo()->getMajorVersion()) - .arg(fHandle->getSysInfo()->getMinorVersion()) - .arg(fHandle->getSysInfo()->getCompatMajorVersion()) - .arg(fHandle->getSysInfo()->getCompatMinorVersion());*/ - KPilotSysInfo i = deviceLink()->getSysInfo(); - fValues[CSL1("palmos")] = CSL1("PalmOS %1.%2").arg(i.getMajorVersion()).arg(i.getMinorVersion()); - - keepParts.append(CSL1("palmversion")); - } else removeParts.append(CSL1("palmversion")); - TQTimer::singleShot(0, this, TQT_SLOT(debugInfo())); -} - -void SysInfoConduit::debugInfo() -{ - FUNCTIONSETUP; - if (fDebugInfo) { - /* Retrieve values for - * - #debug# - */ - fValues[CSL1("debug")] = i18n("No debug data"); - keepParts.append(CSL1("debug")); - } else removeParts.append(CSL1("debug")); - TQTimer::singleShot(0, this, TQT_SLOT(writeFile())); -} - -void SysInfoConduit::writeFile() -{ - FUNCTIONSETUP; - - fValues[CSL1("date")] = TQDateTime::currentDateTime().toString(Qt::LocalDate); - - TQString output; - // Open the template file - TQString templatefile; - switch(fOutputType) - { - case eOutputText: - templatefile=locate("data", CSL1("kpilot/sysinfoconduit/Template.txt")); - break; - case eOutputTemplate: - templatefile=fTemplateFile; - break; - case eOutputHTML: - default: - templatefile=locate("data", CSL1("kpilot/sysinfoconduit/Template.html")); - break; - } - - // Read in the template, close the file - bool loaded=false; - if (!templatefile.isEmpty()){ -#ifdef DEBUG - DEBUGKPILOT<<"Loading template file "<").arg(*it).arg(*it)); - re.setMinimal(true); - output.remove(re); - } - for ( TQStringList::Iterator it = keepParts.begin(); it != keepParts.end(); ++it ) { - TQRegExp re(CSL1("").arg(*it).arg(*it)); - re.setMinimal(true); - output.replace(re, CSL1("\\1")); - } - - // Do a loop through all keys in fValues - TQMap::Iterator it; - for ( it = fValues.begin(); it != fValues.end(); ++it ) { - output.replace(CSL1("#%1#").arg(it.key()), it.data()); - } - - // Insert the list of databases - TQRegExp re(CSL1("#dblist\\[(.*)\\]#")); - re.setMinimal(true); - while (re.search(output)>=0){ - TQString dbstring; - TQString subpatt=re.cap(1); - for (KPilotLink::DBInfoList::ConstIterator i = dblist.begin(); i != dblist.end(); ++i ) { - DBInfo dbi = *i; - TQString newpatt(subpatt); - char tmpchr[5]; - ::memset(&tmpchr[0], 0, 5); - /* Patterns for the dblist argument: - * %0 .. Database name - * %1 .. type - * %2 .. creator - * %3 .. index - * %4 .. flags - * %5 .. miscFlags - * %6 .. version - * %7 .. createDate - * %8 .. modifyDate - * %9 .. backupDate - */ - newpatt.replace(CSL1("%0"), TQString::fromLatin1(dbi.name)); - set_long(&tmpchr[0],dbi.type); - newpatt.replace(CSL1("%1"), TQString::fromLatin1(tmpchr)); - set_long(&tmpchr[0],dbi.creator); - newpatt.replace(CSL1("%2"), TQString::fromLatin1(tmpchr)); - newpatt.replace(CSL1("%3"), TQString::number(dbi.index)); - newpatt.replace(CSL1("%4"), TQString::number(dbi.flags)); - newpatt.replace(CSL1("%5"), TQString::number(dbi.miscFlags)); - newpatt.replace(CSL1("%6"), TQString::number(dbi.version)); - TQDateTime tm; - tm.setTime_t(dbi.createDate); - newpatt.replace(CSL1("%7"), tm.toString(Qt::LocalDate)); - tm.setTime_t(dbi.modifyDate); - newpatt.replace(CSL1("%8"), tm.toString(Qt::LocalDate)); - tm.setTime_t(dbi.backupDate); - newpatt.replace(CSL1("%9"), tm.toString(Qt::LocalDate)); - - dbstring.append(newpatt); - } - // Now, just replace the whole found pattern by the string we just constructed. - output.replace(re.cap(0), dbstring); - } - - // Write out the result - TQFile outfile(fOutputFile); -#ifdef DEBUG - DEBUGKPILOT << fname << ": Writing file <" << fOutputFile << ">" << endl; -#endif - if (fOutputFile.isEmpty() || (!outfile.open(IO_WriteOnly)) ) { - TQFileInfo fi(TQDir::home(), CSL1("KPilotSysInfo.")+TQFileInfo(templatefile).extension() ); - fOutputFile=fi.absFilePath(); - WARNINGKPILOT << "Unable to open output file, using " << fOutputFile << " instead." << endl; - emit logMessage(i18n("Unable to open output file, using %1 instead.").arg(fOutputFile)); - outfile.setName(fOutputFile); - if (!outfile.open(IO_WriteOnly)) { - WARNINGKPILOT<< "Unable to open " << fOutputFile << endl; - emit logError(i18n("Unable to open %1").arg(fOutputFile)); - TQTimer::singleShot(0, this, TQT_SLOT(cleanup())); - return; - } - } - - // Finally, write the actual text out to the file. - TQTextStream outstream(&outfile); - outstream< + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include "sysinfo-factory.h" +#include "sysinfo-conduit.moc" +#include "sysinfoSettings.h" + +const TQString SysInfoConduit::defaultpage = CSL1("KPilot System Information Page\n" +"==============================\n" +"(Kpilot was unable to find the correct template file, \n" +"so this simple template was used.)\n\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"------------------------------------------------------------\n" +"Page created by the KPilot System Information conduit.\n" +""); + + + /** possible fields in the templates are: + * - hardware + * - user + * - memory + * - storage + * - dblist + * - recnumber + * - syncinfo + * - pcversion + * - palmversion + * - debug + */ + + +// Something to allow us to check what revision +// the modules are that make up a binary distribution. + +extern "C" +{ + +unsigned long version_conduit_sysinfo = Pilot::PLUGIN_API; + +} + + + +SysInfoConduit::SysInfoConduit(KPilotLink * o, + const char *n, + const TQStringList & a) : + ConduitAction(o, n, a) +{ + FUNCTIONSETUP; + fConduitName=i18n("System Information"); +} + + + +SysInfoConduit::~SysInfoConduit() +{ + FUNCTIONSETUP; +} + + + +void SysInfoConduit::readConfig() +{ + fOutputFile = SysinfoSettings::outputFile(); + fOutputType = (eOutputTypeEnum) SysinfoSettings::outputFormat(); + fTemplateFile = SysinfoSettings::templateFile(); + fHardwareInfo = SysinfoSettings::hardwareInfo(); + fUserInfo = SysinfoSettings::userInfo(); + fMemoryInfo = SysinfoSettings::memoryInfo(); + fStorageInfo = SysinfoSettings::storageInfo(); + fDBList = SysinfoSettings::databaseList(); + fRecordNumber = SysinfoSettings::recordNumbers(); + fSyncInfo = SysinfoSettings::syncInfo(); + fKDEVersion = SysinfoSettings::kDEVersion(); + fPalmOSVersion = SysinfoSettings::palmOSVersion(); + fDebugInfo = SysinfoSettings::debugInformation(); +} + + +/* virtual */ bool SysInfoConduit::exec() +{ + FUNCTIONSETUP; + + readConfig(); + + TQTimer::singleShot(0, this, TQT_SLOT(hardwareInfo())); + return true; +} + +void SysInfoConduit::hardwareInfo() +{ + FUNCTIONSETUP; + if (fHardwareInfo) { + TQString unknown = i18n("unknown"); + + /* Retrieve values for + * - #deviceid# + * - #devicename# + * - #devicemodel# + * - #manufactorer# + * - #devicetype# + */ + KPilotSysInfo sysinfo = fHandle->getSysInfo(); + fValues[CSL1("deviceid")] = TQString::fromLatin1(sysinfo.getProductID()); + + const KPilotCard *device = fHandle->getCardInfo(); + if (device) + { + fValues[CSL1("devicename")] = TQString::fromLatin1(device->getCardName()); + fValues[CSL1("devicemodel")] = unknown; // TODO + fValues[CSL1("manufacturer")] = TQString::fromLatin1(device->getCardManufacturer()); + } + else + { + fValues[CSL1("devicename")] = unknown; + fValues[CSL1("devicemodel")] = unknown; + fValues[CSL1("manufacturer")] = unknown; + } + + fValues[CSL1("devicetype")] = unknown; + + KPILOT_DELETE(device); + keepParts.append(CSL1("hardware")); + } else removeParts.append(CSL1("hardware")); + TQTimer::singleShot(0, this, TQT_SLOT(userInfo())); +} + +void SysInfoConduit::userInfo() +{ + FUNCTIONSETUP; + if (fUserInfo) + { + /* Retrieve values for + * - #username# + * - #uid# + */ + KPilotUser user=fHandle->getPilotUser(); + fValues[CSL1("username")] = user.name(); + if (user.passwordLength()>0) + { + fValues[CSL1("pw")] = i18n("Password set"); + } + else + { + fValues[CSL1("pw")] = i18n("No password set"); + } + fValues[CSL1("uid")] = TQString::number(user.data()->userID); + fValues[CSL1("viewerid")] = TQString::number(user.data()->viewerID); + keepParts.append(CSL1("user")); + } + else + { + removeParts.append(CSL1("user")); + } + TQTimer::singleShot(0, this, TQT_SLOT(memoryInfo())); +} + +void SysInfoConduit::memoryInfo() +{ + FUNCTIONSETUP; + if (fMemoryInfo) { + /* Retrieve values for + * - #rom# + * - #totalmem# + * - #freemem# + */ + const KPilotCard *device = fHandle->getCardInfo(); + if (device) + { + fValues[CSL1("rom")] = TQString::number(device->getRomSize()/1024); + fValues[CSL1("totalmem")] = TQString::number(device->getRamSize()/1024); + fValues[CSL1("freemem")] = TQString::number(device->getRamFree()/1024); + } + keepParts.append(CSL1("memory")); + } else removeParts.append(CSL1("memory")); + TQTimer::singleShot(0, this, TQT_SLOT(storageInfo())); +} + +void SysInfoConduit::storageInfo() +{ + FUNCTIONSETUP; + if (fStorageInfo) { + /* Retrieve values for + * - $cards$ + */ + const KPilotCard *device = fHandle->getCardInfo(1); + if (device) { + fValues[CSL1("cards")] = CSL1("%1 (%2, %3 kB of %3 kB free)") + .arg(TQString::fromLatin1(device->getCardName())) + .arg(TQString::fromLatin1(device->getCardManufacturer())) + .arg(device->getRamFree()/1024) + .arg(device->getRamSize()/1024); + KPILOT_DELETE(device); + } else { + fValues[CSL1("cards")] = i18n("No Cards available via pilot-link"); + } + keepParts.append(CSL1("storage")); + } else removeParts.append(CSL1("storage")); + TQTimer::singleShot(0, this, TQT_SLOT(dbListInfo())); +} + +void SysInfoConduit::dbListInfo() +{ + FUNCTIONSETUP; + if (fDBList) { + /* Retrieve values for + * - #dblist(structure)# + */ + dblist=deviceLink()->getDBList(); + keepParts.append(CSL1("dblist")); + } else removeParts.append(CSL1("dblist")); + TQTimer::singleShot(0, this, TQT_SLOT(recNumberInfo())); +} + +void SysInfoConduit::recNumberInfo() +{ + FUNCTIONSETUP; + if (fRecordNumber) { + /* Retrieve values for + * - #addresses# + * - #events# + * - #todos# + * - #memos# + */ + PilotDatabase *fDatabase = 0L; + TQString ERROR = CSL1("ERROR"); + fValues[CSL1("addresses")] = ERROR; + fValues[CSL1("events")] = ERROR; + fValues[CSL1("todos")] = ERROR; + fValues[CSL1("memos")] = ERROR; + fDatabase = deviceLink()->database(CSL1("AddressDB")); + if (fDatabase) { + fValues[CSL1("addresses")] = TQString::number(fDatabase->recordCount()); + KPILOT_DELETE(fDatabase); + } + fDatabase = deviceLink()->database(CSL1("DatebookDB")); + if (fDatabase) { + fValues[CSL1("events")] = TQString::number(fDatabase->recordCount()); + KPILOT_DELETE(fDatabase); + } + fDatabase = deviceLink()->database(CSL1("ToDoDB")); + if (fDatabase) { + fValues[CSL1("todos")] = TQString::number(fDatabase->recordCount()); + KPILOT_DELETE(fDatabase); + } + fDatabase = deviceLink()->database(CSL1("MemoDB")); + if (fDatabase) { + fValues[CSL1("memos")] = TQString::number(fDatabase->recordCount()); + KPILOT_DELETE(fDatabase); + } + keepParts.append(CSL1("records")); + } else removeParts.append(CSL1("records")); + TQTimer::singleShot(0, this, TQT_SLOT(syncInfo())); +} + +void SysInfoConduit::syncInfo() +{ + FUNCTIONSETUP; + if (fSyncInfo) { + /* Retrieve values for + * - #lastsync# + * - #lastsuccsync# + * - #lastsyncpc# + */ + KPilotUser user = deviceLink()->getPilotUser(); + time_t lastsync = user.getLastSyncDate(); + TQDateTime qlastsync; + qlastsync.setTime_t(lastsync); + fValues[CSL1("lastsync")] = qlastsync.toString(Qt::LocalDate); + lastsync = user.getLastSuccessfulSyncDate(); + qlastsync.setTime_t(lastsync); + fValues[CSL1("lastsuccsync")] = qlastsync.toString(Qt::LocalDate); + fValues[CSL1("lastsyncpc")] = TQString::number(user.getLastSyncPC()); + keepParts.append(CSL1("sync")); + } else removeParts.append(CSL1("sync")); + TQTimer::singleShot(0, this, TQT_SLOT(pcVersionInfo())); +} + +void SysInfoConduit::pcVersionInfo() +{ + FUNCTIONSETUP; + if (fKDEVersion) { + /* Retrieve values for + * - #os# + * - #qt# + * - #kde# + * - #kpilot# + * - #pilotlink# + */ + fValues[CSL1("kpilot")] = TQString::fromLatin1(KPILOT_VERSION); + fValues[CSL1("kde")] = i18n("unknown"); + fValues[CSL1("qt")] = i18n("unknown"); + fValues[CSL1("os")] = i18n("unknown"); + fValues[CSL1("hostname")] = i18n("unknown"); + struct utsname name; + if (uname (&name) >= 0) { + fValues[CSL1("os")] = CSL1("%1 %3, %5") + .arg(TQString::fromLatin1(name.sysname)) + .arg(TQString::fromLatin1(name.release)) + .arg(TQString::fromLatin1(name.machine)); + fValues[CSL1("hostname")] = CSL1("%2").arg(TQString::fromLatin1(name.nodename)); + } +#ifdef TDE_VERSION_STRING + fValues[CSL1("kde")] = TQString::fromLatin1(TDE_VERSION_STRING); +#endif +#ifdef TQT_VERSION_STR + fValues[CSL1("qt")] = TQString::fromLatin1(TQT_VERSION_STR); +#endif + fValues[CSL1("pilotlink")] = CSL1("%1.%2.%3%4") + .arg(PILOT_LINK_VERSION) + .arg(PILOT_LINK_MAJOR) + .arg(PILOT_LINK_MINOR) +#ifdef PILOT_LINK_PATCH + .arg(TQString::fromLatin1(PILOT_LINK_PATCH)); +#else + .arg(TQString()); +#endif + keepParts.append(CSL1("pcversion")); + } else removeParts.append(CSL1("pcversion")); + TQTimer::singleShot(0, this, TQT_SLOT(palmVersionInfo())); +} + +void SysInfoConduit::palmVersionInfo() +{ + FUNCTIONSETUP; + if (fPalmOSVersion) { + /* Retrieve values for + * - #palmos# + */ +/* fValues["palmos"] = TQString("PalmOS %1.%2 (compat %3.%4)") + .arg(fHandle->getSysInfo()->getMajorVersion()) + .arg(fHandle->getSysInfo()->getMinorVersion()) + .arg(fHandle->getSysInfo()->getCompatMajorVersion()) + .arg(fHandle->getSysInfo()->getCompatMinorVersion());*/ + KPilotSysInfo i = deviceLink()->getSysInfo(); + fValues[CSL1("palmos")] = CSL1("PalmOS %1.%2").arg(i.getMajorVersion()).arg(i.getMinorVersion()); + + keepParts.append(CSL1("palmversion")); + } else removeParts.append(CSL1("palmversion")); + TQTimer::singleShot(0, this, TQT_SLOT(debugInfo())); +} + +void SysInfoConduit::debugInfo() +{ + FUNCTIONSETUP; + if (fDebugInfo) { + /* Retrieve values for + * - #debug# + */ + fValues[CSL1("debug")] = i18n("No debug data"); + keepParts.append(CSL1("debug")); + } else removeParts.append(CSL1("debug")); + TQTimer::singleShot(0, this, TQT_SLOT(writeFile())); +} + +void SysInfoConduit::writeFile() +{ + FUNCTIONSETUP; + + fValues[CSL1("date")] = TQDateTime::currentDateTime().toString(Qt::LocalDate); + + TQString output; + // Open the template file + TQString templatefile; + switch(fOutputType) + { + case eOutputText: + templatefile=locate("data", CSL1("kpilot/sysinfoconduit/Template.txt")); + break; + case eOutputTemplate: + templatefile=fTemplateFile; + break; + case eOutputHTML: + default: + templatefile=locate("data", CSL1("kpilot/sysinfoconduit/Template.html")); + break; + } + + // Read in the template, close the file + bool loaded=false; + if (!templatefile.isEmpty()){ +#ifdef DEBUG + DEBUGKPILOT<<"Loading template file "<").arg(*it).arg(*it)); + re.setMinimal(true); + output.remove(re); + } + for ( TQStringList::Iterator it = keepParts.begin(); it != keepParts.end(); ++it ) { + TQRegExp re(CSL1("").arg(*it).arg(*it)); + re.setMinimal(true); + output.replace(re, CSL1("\\1")); + } + + // Do a loop through all keys in fValues + TQMap::Iterator it; + for ( it = fValues.begin(); it != fValues.end(); ++it ) { + output.replace(CSL1("#%1#").arg(it.key()), it.data()); + } + + // Insert the list of databases + TQRegExp re(CSL1("#dblist\\[(.*)\\]#")); + re.setMinimal(true); + while (re.search(output)>=0){ + TQString dbstring; + TQString subpatt=re.cap(1); + for (KPilotLink::DBInfoList::ConstIterator i = dblist.begin(); i != dblist.end(); ++i ) { + DBInfo dbi = *i; + TQString newpatt(subpatt); + char tmpchr[5]; + ::memset(&tmpchr[0], 0, 5); + /* Patterns for the dblist argument: + * %0 .. Database name + * %1 .. type + * %2 .. creator + * %3 .. index + * %4 .. flags + * %5 .. miscFlags + * %6 .. version + * %7 .. createDate + * %8 .. modifyDate + * %9 .. backupDate + */ + newpatt.replace(CSL1("%0"), TQString::fromLatin1(dbi.name)); + set_long(&tmpchr[0],dbi.type); + newpatt.replace(CSL1("%1"), TQString::fromLatin1(tmpchr)); + set_long(&tmpchr[0],dbi.creator); + newpatt.replace(CSL1("%2"), TQString::fromLatin1(tmpchr)); + newpatt.replace(CSL1("%3"), TQString::number(dbi.index)); + newpatt.replace(CSL1("%4"), TQString::number(dbi.flags)); + newpatt.replace(CSL1("%5"), TQString::number(dbi.miscFlags)); + newpatt.replace(CSL1("%6"), TQString::number(dbi.version)); + TQDateTime tm; + tm.setTime_t(dbi.createDate); + newpatt.replace(CSL1("%7"), tm.toString(Qt::LocalDate)); + tm.setTime_t(dbi.modifyDate); + newpatt.replace(CSL1("%8"), tm.toString(Qt::LocalDate)); + tm.setTime_t(dbi.backupDate); + newpatt.replace(CSL1("%9"), tm.toString(Qt::LocalDate)); + + dbstring.append(newpatt); + } + // Now, just replace the whole found pattern by the string we just constructed. + output.replace(re.cap(0), dbstring); + } + + // Write out the result + TQFile outfile(fOutputFile); +#ifdef DEBUG + DEBUGKPILOT << fname << ": Writing file <" << fOutputFile << ">" << endl; +#endif + if (fOutputFile.isEmpty() || (!outfile.open(IO_WriteOnly)) ) { + TQFileInfo fi(TQDir::home(), CSL1("KPilotSysInfo.")+TQFileInfo(templatefile).extension() ); + fOutputFile=fi.absFilePath(); + WARNINGKPILOT << "Unable to open output file, using " << fOutputFile << " instead." << endl; + emit logMessage(i18n("Unable to open output file, using %1 instead.").arg(fOutputFile)); + outfile.setName(fOutputFile); + if (!outfile.open(IO_WriteOnly)) { + WARNINGKPILOT<< "Unable to open " << fOutputFile << endl; + emit logError(i18n("Unable to open %1").arg(fOutputFile)); + TQTimer::singleShot(0, this, TQT_SLOT(cleanup())); + return; + } + } + + // Finally, write the actual text out to the file. + TQTextStream outstream(&outfile); + outstream<; -} - -} diff --git a/conduits/sysinfoconduit/sysinfo-factory.cpp b/conduits/sysinfoconduit/sysinfo-factory.cpp new file mode 100644 index 0000000..61990f8 --- /dev/null +++ b/conduits/sysinfoconduit/sysinfo-factory.cpp @@ -0,0 +1,43 @@ +/* SysInfo-factory.cpp KPilot +** +** Copyright (C) 2003 by Reinhold Kainhofer +** +** This file defines the factory for the SysInfo-conduit plugin. +*/ + +/* +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "options.h" +#include "pluginfactory.h" + +#include "sysinfo-conduit.h" +#include "sysinfo-setup.h" + +extern "C" +{ + +void *init_conduit_sysinfo() +{ + return new ConduitFactory; +} + +} diff --git a/conduits/sysinfoconduit/sysinfo-setup.cc b/conduits/sysinfoconduit/sysinfo-setup.cc deleted file mode 100644 index 647d1f6..0000000 --- a/conduits/sysinfoconduit/sysinfo-setup.cc +++ /dev/null @@ -1,198 +0,0 @@ -/* SysInfo-setup.cc KPilot -** -** Copyright (C) 2003 by Reinhold Kainhofer -** -** This file defines the setup dialog for the SysInfo-conduit plugin. -*/ - -/* -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program in a file called COPYING; if not, write to -** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -** MA 02110-1301, USA. -*/ - -/* -** Bug reports and questions can be sent to kde-pim@kde.org -*/ - -#include "options.h" - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "sysinfo-setup_dialog.h" - -#include "sysinfo-factory.h" -#include "sysinfo-setup.h" -#include "sysinfoSettings.h" - - -typedef struct { const char *name; bool (*accessor)(); void (*mutator)(bool); } sysinfoEntry_t; - -const sysinfoEntry_t sysinfoEntries[] = -{ - { I18N_NOOP("HardwareInfo"), SysinfoSettings::hardwareInfo, SysinfoSettings::setHardwareInfo }, - { I18N_NOOP("UserInfo"), SysinfoSettings::userInfo, SysinfoSettings::setUserInfo }, - { I18N_NOOP("MemoryInfo"), SysinfoSettings::memoryInfo, SysinfoSettings::setMemoryInfo }, - { I18N_NOOP("StorageInfo"), SysinfoSettings::storageInfo, SysinfoSettings::setStorageInfo }, - { I18N_NOOP("DatabaseList"), SysinfoSettings::databaseList, SysinfoSettings::setDatabaseList }, - { I18N_NOOP("RecordNumbers"), SysinfoSettings::recordNumbers, SysinfoSettings::setRecordNumbers}, - { I18N_NOOP("SyncInfo"), SysinfoSettings::syncInfo, SysinfoSettings::setSyncInfo }, - { I18N_NOOP("KDEVersion"), SysinfoSettings::kDEVersion, SysinfoSettings::setKDEVersion }, - { I18N_NOOP("PalmOSVersion"), SysinfoSettings::palmOSVersion, SysinfoSettings::setPalmOSVersion }, - { I18N_NOOP("DebugInformation"), SysinfoSettings::debugInformation, SysinfoSettings::setDebugInformation }, - { 0L, 0L, 0L } -} ; - - -/* -** The TQCheckListItems used in the list of parts to print have -** several text fields with special meanings. -** 0: The text displayed in the list. -** 1: The index of the item in the sysinfoEntries array. -** 2: This string is empty if the part was originally not checked, -** and non-empty (probably "1") if the part was originally checked. -** This is used to detect changes in the configuration. -** We introduce some defines for these numbers. -*/ - -#define PART_NAME (0) -#define PART_KEY (1) -#define PART_SETTING (2) - -/* -** This is a convenience define to update an item's "original setting". -*/ -#define updateSetting(i) { TQCheckListItem *ubbu=(i); \ - ubbu->setText(PART_SETTING,(ubbu->isOn() ? CSL1("1") : TQString())); } - - -SysInfoWidgetConfig::SysInfoWidgetConfig(TQWidget *w, const char *n) : - ConduitConfigBase(w,n), - fConfigWidget(new SysInfoWidget(w)) -{ - FUNCTIONSETUP; - - TDEAboutData *fAbout = new TDEAboutData("SysInfoConduit", - I18N_NOOP("KPilot System Information conduit"), - KPILOT_VERSION, - I18N_NOOP("Retrieves System, Hardware, and User Info from the Handheld and stores them to a file."), - TDEAboutData::License_GPL, - "(C) 2003, Reinhold Kainhofer"); - fAbout->addAuthor("Reinhold Kainhofer", - I18N_NOOP("Primary Author"), "reinhold@kainhofer.com", "http://reinhold.kainhofer.com/"); - - ConduitConfigBase::addAboutPage(fConfigWidget->tabWidget,fAbout); - fWidget=fConfigWidget; - - TQObject::connect(fConfigWidget->fOutputFile,TQT_SIGNAL(textChanged(const TQString&)), - this,TQT_SLOT(modified())); - TQObject::connect(fConfigWidget->fTemplateFile,TQT_SIGNAL(textChanged(const TQString&)), - this,TQT_SLOT(modified())); - TQObject::connect(fConfigWidget->fOutputType,TQT_SIGNAL(clicked(int)), - this,TQT_SLOT(modified())); - fConduitName=i18n("System Information"); -} - -void SysInfoWidgetConfig::commit() -{ - FUNCTIONSETUP; - - SysinfoSettings::setOutputFile( - fConfigWidget->fOutputFile->url() ); - SysinfoSettings::setTemplateFile( - fConfigWidget->fTemplateFile->url() ); - SysinfoSettings::setOutputFormat( - fConfigWidget->fOutputType->id(fConfigWidget->fOutputType->selected())); - - TQListViewItem *i = fConfigWidget->fPartsList->firstChild(); - TQCheckListItem *ci = dynamic_cast(i); - while(ci) - { -#ifdef DEBUG - DEBUGKPILOT << fname << ": Saving " << ci->text(PART_NAME) - << (ci->isOn() ? " on" : " off") << endl; -#endif - int index=ci->text(PART_KEY).toInt(); - if (0<=index && index<=10) - { - const sysinfoEntry_t *p = sysinfoEntries+index; - p->mutator(ci->isOn()); - } - updateSetting(ci); - i=i->nextSibling(); - ci = dynamic_cast(i); - } - SysinfoSettings::self()->writeConfig(); - unmodified(); -} - -void SysInfoWidgetConfig::load() -{ - FUNCTIONSETUP; - SysinfoSettings::self()->readConfig(); - - const sysinfoEntry_t *p = sysinfoEntries; - TQCheckListItem *i = 0L; - while (p && p->name) - { - i = new TQCheckListItem(fConfigWidget->fPartsList,i18n(p->name),TQCheckListItem::CheckBox); - // by default let the sysinfo conduit write out all available information - i->setOn( p->accessor() ); - i->setText(PART_KEY, TQString::number(p-sysinfoEntries)); // store index there - updateSetting(i); -#ifdef DEBUG - DEBUGKPILOT << fname << ": Loaded " << p->name - << (i->isOn() ? " on" : " off") << endl; -#endif - - p++; - } - fConfigWidget->fOutputFile->setURL( SysinfoSettings::outputFile() ); - fConfigWidget->fTemplateFile->setURL( SysinfoSettings::templateFile() ); - fConfigWidget->fOutputType->setButton( SysinfoSettings::outputFormat() ); - unmodified(); -} - -/* virtual */ bool SysInfoWidgetConfig::isModified() const -{ - FUNCTIONSETUP; - if (fModified) return true; - - TQListViewItem *i = fConfigWidget->fPartsList->firstChild(); - TQCheckListItem *ci = dynamic_cast(i); - - while(ci) - { - bool current = ci->isOn(); - bool original = !ci->text(PART_SETTING).isEmpty(); -#ifdef DEBUG - DEBUGKPILOT << fname << ": Checking " << ci->text(PART_KEY) - << " was " << (original ? " on" : " off") - << " now " << (current ? " on" : " off") << endl; -#endif - - if (current!=original) return true; - i=i->nextSibling(); - ci = dynamic_cast(i); - } - return false; -} diff --git a/conduits/sysinfoconduit/sysinfo-setup.cpp b/conduits/sysinfoconduit/sysinfo-setup.cpp new file mode 100644 index 0000000..70676e4 --- /dev/null +++ b/conduits/sysinfoconduit/sysinfo-setup.cpp @@ -0,0 +1,198 @@ +/* SysInfo-setup.cpp KPilot +** +** Copyright (C) 2003 by Reinhold Kainhofer +** +** This file defines the setup dialog for the SysInfo-conduit plugin. +*/ + +/* +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "options.h" + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "sysinfo-setup_dialog.h" + +#include "sysinfo-factory.h" +#include "sysinfo-setup.h" +#include "sysinfoSettings.h" + + +typedef struct { const char *name; bool (*accessor)(); void (*mutator)(bool); } sysinfoEntry_t; + +const sysinfoEntry_t sysinfoEntries[] = +{ + { I18N_NOOP("HardwareInfo"), SysinfoSettings::hardwareInfo, SysinfoSettings::setHardwareInfo }, + { I18N_NOOP("UserInfo"), SysinfoSettings::userInfo, SysinfoSettings::setUserInfo }, + { I18N_NOOP("MemoryInfo"), SysinfoSettings::memoryInfo, SysinfoSettings::setMemoryInfo }, + { I18N_NOOP("StorageInfo"), SysinfoSettings::storageInfo, SysinfoSettings::setStorageInfo }, + { I18N_NOOP("DatabaseList"), SysinfoSettings::databaseList, SysinfoSettings::setDatabaseList }, + { I18N_NOOP("RecordNumbers"), SysinfoSettings::recordNumbers, SysinfoSettings::setRecordNumbers}, + { I18N_NOOP("SyncInfo"), SysinfoSettings::syncInfo, SysinfoSettings::setSyncInfo }, + { I18N_NOOP("KDEVersion"), SysinfoSettings::kDEVersion, SysinfoSettings::setKDEVersion }, + { I18N_NOOP("PalmOSVersion"), SysinfoSettings::palmOSVersion, SysinfoSettings::setPalmOSVersion }, + { I18N_NOOP("DebugInformation"), SysinfoSettings::debugInformation, SysinfoSettings::setDebugInformation }, + { 0L, 0L, 0L } +} ; + + +/* +** The TQCheckListItems used in the list of parts to print have +** several text fields with special meanings. +** 0: The text displayed in the list. +** 1: The index of the item in the sysinfoEntries array. +** 2: This string is empty if the part was originally not checked, +** and non-empty (probably "1") if the part was originally checked. +** This is used to detect changes in the configuration. +** We introduce some defines for these numbers. +*/ + +#define PART_NAME (0) +#define PART_KEY (1) +#define PART_SETTING (2) + +/* +** This is a convenience define to update an item's "original setting". +*/ +#define updateSetting(i) { TQCheckListItem *ubbu=(i); \ + ubbu->setText(PART_SETTING,(ubbu->isOn() ? CSL1("1") : TQString())); } + + +SysInfoWidgetConfig::SysInfoWidgetConfig(TQWidget *w, const char *n) : + ConduitConfigBase(w,n), + fConfigWidget(new SysInfoWidget(w)) +{ + FUNCTIONSETUP; + + TDEAboutData *fAbout = new TDEAboutData("SysInfoConduit", + I18N_NOOP("KPilot System Information conduit"), + KPILOT_VERSION, + I18N_NOOP("Retrieves System, Hardware, and User Info from the Handheld and stores them to a file."), + TDEAboutData::License_GPL, + "(C) 2003, Reinhold Kainhofer"); + fAbout->addAuthor("Reinhold Kainhofer", + I18N_NOOP("Primary Author"), "reinhold@kainhofer.com", "http://reinhold.kainhofer.com/"); + + ConduitConfigBase::addAboutPage(fConfigWidget->tabWidget,fAbout); + fWidget=fConfigWidget; + + TQObject::connect(fConfigWidget->fOutputFile,TQT_SIGNAL(textChanged(const TQString&)), + this,TQT_SLOT(modified())); + TQObject::connect(fConfigWidget->fTemplateFile,TQT_SIGNAL(textChanged(const TQString&)), + this,TQT_SLOT(modified())); + TQObject::connect(fConfigWidget->fOutputType,TQT_SIGNAL(clicked(int)), + this,TQT_SLOT(modified())); + fConduitName=i18n("System Information"); +} + +void SysInfoWidgetConfig::commit() +{ + FUNCTIONSETUP; + + SysinfoSettings::setOutputFile( + fConfigWidget->fOutputFile->url() ); + SysinfoSettings::setTemplateFile( + fConfigWidget->fTemplateFile->url() ); + SysinfoSettings::setOutputFormat( + fConfigWidget->fOutputType->id(fConfigWidget->fOutputType->selected())); + + TQListViewItem *i = fConfigWidget->fPartsList->firstChild(); + TQCheckListItem *ci = dynamic_cast(i); + while(ci) + { +#ifdef DEBUG + DEBUGKPILOT << fname << ": Saving " << ci->text(PART_NAME) + << (ci->isOn() ? " on" : " off") << endl; +#endif + int index=ci->text(PART_KEY).toInt(); + if (0<=index && index<=10) + { + const sysinfoEntry_t *p = sysinfoEntries+index; + p->mutator(ci->isOn()); + } + updateSetting(ci); + i=i->nextSibling(); + ci = dynamic_cast(i); + } + SysinfoSettings::self()->writeConfig(); + unmodified(); +} + +void SysInfoWidgetConfig::load() +{ + FUNCTIONSETUP; + SysinfoSettings::self()->readConfig(); + + const sysinfoEntry_t *p = sysinfoEntries; + TQCheckListItem *i = 0L; + while (p && p->name) + { + i = new TQCheckListItem(fConfigWidget->fPartsList,i18n(p->name),TQCheckListItem::CheckBox); + // by default let the sysinfo conduit write out all available information + i->setOn( p->accessor() ); + i->setText(PART_KEY, TQString::number(p-sysinfoEntries)); // store index there + updateSetting(i); +#ifdef DEBUG + DEBUGKPILOT << fname << ": Loaded " << p->name + << (i->isOn() ? " on" : " off") << endl; +#endif + + p++; + } + fConfigWidget->fOutputFile->setURL( SysinfoSettings::outputFile() ); + fConfigWidget->fTemplateFile->setURL( SysinfoSettings::templateFile() ); + fConfigWidget->fOutputType->setButton( SysinfoSettings::outputFormat() ); + unmodified(); +} + +/* virtual */ bool SysInfoWidgetConfig::isModified() const +{ + FUNCTIONSETUP; + if (fModified) return true; + + TQListViewItem *i = fConfigWidget->fPartsList->firstChild(); + TQCheckListItem *ci = dynamic_cast(i); + + while(ci) + { + bool current = ci->isOn(); + bool original = !ci->text(PART_SETTING).isEmpty(); +#ifdef DEBUG + DEBUGKPILOT << fname << ": Checking " << ci->text(PART_KEY) + << " was " << (original ? " on" : " off") + << " now " << (current ? " on" : " off") << endl; +#endif + + if (current!=original) return true; + i=i->nextSibling(); + ci = dynamic_cast(i); + } + return false; +} -- cgit v1.2.1