00001 #include "ut_abs_timer_qt_epoc.hpp" 00002 00003 #include "er_errors.h" 00004 00005 #include "common/assertions.h" 00006 #include "common/epoc-time.h" 00007 00008 #include <limits.h> 00009 00010 #include <QtDebug> 00011 00012 QAbsTimer::QAbsTimer(QObject *parent) : 00013 QObject(parent) 00014 { 00015 TRAPD(errCode, 00016 iTimerAo = CTimerAo::NewL(*this, CActive::EPriorityLow)); 00017 qt_symbian_throwIfError(errCode); 00018 } 00019 00020 QAbsTimer::~QAbsTimer() 00021 { 00022 delete iTimerAo; 00023 } 00024 00025 bool QAbsTimer::isActive() const 00026 { 00027 return iTimerAo->IsActive(); 00028 } 00029 00030 void QAbsTimer::start(const QDateTime& aExpTime) 00031 { 00032 // We have no direct conversion utility, so convert via POSIX time. 00033 // Lose accuracy, though, no fractions of a second preserved. 00034 time_t unixTime = aExpTime.toUTC().toTime_t(); 00035 UnixTimeToUtcEpocTime(iAtTime, unixTime); 00036 iTimerAo->AtUTC(iAtTime); 00037 } 00038 00039 void QAbsTimer::stop() 00040 { 00041 iTimerAo->Cancel(); 00042 } 00043 00044 void QAbsTimer::HandleTimerEvent(CTimerAo *, TInt aError) 00045 { 00046 switch (aError) 00047 { 00048 case KErrNone: 00049 case KErrUnderflow: 00050 { 00051 emit timeout(); 00052 break; 00053 } 00054 case KErrAbort: // time may have changed 00055 { 00056 TTime now; 00057 now.UniversalTime(); 00058 if (now < iAtTime) { 00059 iTimerAo->AtUTC(iAtTime); 00060 } else { 00061 emit timeout(); 00062 } 00063 break; 00064 } 00065 default: // an actual error 00066 { 00067 er_log_symbian(er_FATAL, aError, "CTimerAo error"); 00068 break; 00069 } 00070 } 00071 } 00072 00073 /** 00074 00075 Copyright 2010 Helsinki Institute for Information Technology (HIIT) 00076 and the authors. All rights reserved. 00077 00078 Authors: Tero Hasu <tero.hasu@hut.fi> 00079 00080 Permission is hereby granted, free of charge, to any person 00081 obtaining a copy of this software and associated documentation files 00082 (the "Software"), to deal in the Software without restriction, 00083 including without limitation the rights to use, copy, modify, merge, 00084 publish, distribute, sublicense, and/or sell copies of the Software, 00085 and to permit persons to whom the Software is furnished to do so, 00086 subject to the following conditions: 00087 00088 The above copyright notice and this permission notice shall be 00089 included in all copies or substantial portions of the Software. 00090 00091 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00092 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00093 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00094 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00095 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00096 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00097 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00098 SOFTWARE. 00099 00100 **/
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:57 2011 by Doxygen 1.6.1