time-conduit.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00040
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 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
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
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
00120 }
00121
00122
00123
00124 void TimeConduit::syncPCToPalm()
00125 {
00126 FUNCTIONSETUP;
00127 time_t ltime;
00128 time(<ime);
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
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 }
This file is part of the documentation for kpilot Library Version 3.2.2.