javaextensions/midppush/pushregistryplugin/src/pushtimerutils.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "pushtimerutils.h"
       
    20 #include "logger.h"
       
    21 #include "pushconstant.h"
       
    22 #include "pushtimercontainer.h"
       
    23 #include "pusherrorcodes.h"
       
    24 #include "pushexception.h"
       
    25 #include "javauid.h"
       
    26 
       
    27 using namespace java::push;
       
    28 using namespace java::util;
       
    29 using namespace java::captain;
       
    30 
       
    31 /**
       
    32  *
       
    33  */
       
    34 bool PushTimerUtils::isTimerExpired(PushTimerListener& aListener,const Uid& aUid,
       
    35                                     const JavaTime& aAlarmTime,
       
    36                                     TimerServerInterface& aTimerInterface)
       
    37 {
       
    38     JELOG2(EJavaPush);
       
    39     JavaTime currentTime;
       
    40     aTimerInterface.getCurrentJavaTime(currentTime);
       
    41 
       
    42     if (true == isTimeOlderThanTwoWeeks(aTimerInterface,currentTime,aAlarmTime))
       
    43     {
       
    44         aListener.deleteAlarm(aUid);
       
    45         return true;
       
    46     }
       
    47     else if ((true == aTimerInterface.isLess(aAlarmTime,currentTime))
       
    48              || (true == aTimerInterface.isEqual(aAlarmTime,currentTime)))
       
    49     {
       
    50         aListener.timerExpired(aUid,aAlarmTime.getTime());
       
    51         return true;
       
    52     }
       
    53     return false;
       
    54 }
       
    55 
       
    56 /**
       
    57  *
       
    58  */
       
    59 bool PushTimerUtils::isTimeOlderThanTwoWeeks(TimerServerInterface& aTimerInterface,
       
    60         const JavaTime& aCurrentTime,
       
    61         const JavaTime& aAlarmTime)
       
    62 {
       
    63     JELOG2(EJavaPush);
       
    64 
       
    65     long long tmpTime = aCurrentTime.getTime() - TWO_WEEKS_IN_MILLI_SECS;
       
    66     JavaTime twoWeeksAgoTime(tmpTime);
       
    67     if (true == aTimerInterface.isLess(aAlarmTime,twoWeeksAgoTime))
       
    68         return true;
       
    69     return false;
       
    70 }
       
    71