kpilot Library API Documentation

time-conduit.cc

00001 /* time-conduit.cc KPilot 00002 ** 00003 ** Copyright (C) 2002-2003 by Reinhold Kainhofer 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 General Public License as published by 00010 ** the Free Software Foundation; either version 2 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 General Public License for more details. 00017 ** 00018 ** You should have received a copy of the GNU General Public License 00019 ** along with this program in a file called COPYING; if not, write to 00020 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00021 ** MA 02111-1307, USA. 00022 */ 00023 00024 /* 00025 ** Bug reports and questions can be sent to kde-pim@kde.org. 00026 */ 00027 00028 #include "options.h" 00029 00030 #include <time.h> 00031 00032 #include <kconfig.h> 00033 #include <kdebug.h> 00034 00035 #include "time-factory.h" 00036 #include "time-conduit.moc" 00037 00038 00039 // Something to allow us to check what revision 00040 // the modules are that make up a binary distribution. 00041 const char *Time_conduit_id = 00042 "$Id: time-conduit.cc,v 1.14 2003/06/23 22:28:39 adridg Exp $"; 00043 00044 00045 00046 00047 TimeConduit::TimeConduit(KPilotDeviceLink * o, 00048 const char *n, 00049 const QStringList & a) : 00050 ConduitAction(o, n, a), 00051 fDirection(0) 00052 { 00053 FUNCTIONSETUP; 00054 #ifdef DEBUG 00055 DEBUGCONDUIT<<Time_conduit_id<<endl; 00056 #endif 00057 fConduitName=i18n("Time"); 00058 } 00059 00060 00061 00062 TimeConduit::~TimeConduit() 00063 { 00064 FUNCTIONSETUP; 00065 } 00066 00067 00068 00069 void TimeConduit::readConfig() 00070 { 00071 FUNCTIONSETUP; 00072 KConfigGroupSaver g(fConfig, TimeConduitFactory::group()); 00073 fDirection = fConfig->readNumEntry(TimeConduitFactory::direction(),DIR_PCToPalm); 00074 } 00075 00076 00077 /* virtual */ bool TimeConduit::exec() 00078 { 00079 FUNCTIONSETUP; 00080 DEBUGCONDUIT<<Time_conduit_id<<endl; 00081 00082 if (!fConfig) 00083 { 00084 kdWarning() << k_funcinfo << ": No config file was set!" << endl; 00085 return false; 00086 } 00087 00088 readConfig(); 00089 00090 switch (fDirection) 00091 { 00092 case DIR_PCToPalm: 00093 emit logMessage(i18n("Setting the clock on the handheld")); 00094 // fHandle->addSyncLogEntry(i18n("Setting the clock on the handheld")); 00095 syncPCToPalm(); 00096 break; 00097 case DIR_PalmToPC: 00098 emit logMessage(i18n("Setting the clock on the PC from the time on the handheld")); 00099 // fHandle->addSyncLogEntry(i18n("Setting the clock on the PC from the time on the handheld")); 00100 syncPalmToPC(); 00101 break; 00102 default: 00103 emit logError(i18n("Unknown setting for time synchronization.")); 00104 kdWarning() << k_funcinfo << ": unknown sync direction "<<fDirection<<endl; 00105 return false; 00106 } 00107 emit syncDone(this); 00108 return true; 00109 } 00110 00111 void TimeConduit::syncPalmToPC() 00112 { 00113 FUNCTIONSETUP; 00114 QDateTime pdaTime=fHandle->getTime(); 00115 #ifdef DEBUG 00116 DEBUGCONDUIT<<fname<<": syncing time "<<pdaTime.toString()<<" to the PC"<<endl; 00117 #endif 00118 emit logError(i18n("The system clock was not adjusted to %1 (not implemented)").arg(pdaTime.toString())); 00119 // TODO: Set the system time from this QDateTime 00120 } 00121 00122 00123 00124 void TimeConduit::syncPCToPalm() 00125 { 00126 FUNCTIONSETUP; 00127 time_t ltime; 00128 time(&ltime); 00129 QDateTime time=QDateTime::currentDateTime(); 00130 00131 long int major=fHandle->majorVersion(), minor=fHandle->minorVersion(); 00132 00133 if (major==3 && (minor==25 || minor==30)) 00134 { 00135 emit logMessage(i18n("PalmOS 3.25 and 3.3 do not support setting the system time. Skipping the time conduit...")); 00136 return; 00137 } 00138 00139 // fHandle->setTime(QDateTime::currentDateTime()); 00140 fHandle->setTime(ltime); 00141 #ifdef DEBUG 00142 time.setTime_t(ltime); 00143 DEBUGCONDUIT<<fname<<": synced time "<<time.toString()<<" to the handheld"<<endl; 00144 #endif 00145 }
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:49 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003