webservices/wsstar/wsstarplugin/src/wsstarcredentialobserver.cpp
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2009 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 
       
    20 
       
    21 
       
    22 #include "sendebug.h"
       
    23 #include "senlogger.h"
       
    24 #include "wsstarcredentialobserver.h"
       
    25 const TInt64 KHalfHour = 1000000 *60*30; //2;//30;  2 minutes instead 30
       
    26 CWSStarCredentialObserver::CWSStarCredentialObserver(CWSStarServiceSession* aSession, RFileLogger* aLogger) : CTimer( EPriorityStandard )// Standard priority
       
    27 {
       
    28     iSession = aSession;
       
    29     iLogger = aLogger; 
       
    30 }
       
    31 
       
    32 CWSStarCredentialObserver* CWSStarCredentialObserver::NewLC(CWSStarServiceSession* aSession, RFileLogger* aLogger)
       
    33 {
       
    34 	CWSStarCredentialObserver* self = new ( ELeave ) CWSStarCredentialObserver(aSession, aLogger);
       
    35 	CleanupStack::PushL( self );
       
    36 	self->ConstructL();
       
    37 	return self;
       
    38 }
       
    39 
       
    40 CWSStarCredentialObserver* CWSStarCredentialObserver::NewL(CWSStarServiceSession* aSession, RFileLogger* aLogger)
       
    41 {
       
    42 	CWSStarCredentialObserver* self = CWSStarCredentialObserver::NewLC(aSession, aLogger);
       
    43 	CleanupStack::Pop(); // self;
       
    44 	return self;
       
    45 }
       
    46 
       
    47 void CWSStarCredentialObserver::ConstructL()
       
    48 {
       
    49 	CTimer::ConstructL() ;	// Initialize timer
       
    50 	CActiveScheduler::Add( this );				// Add to scheduler
       
    51           iRunned = EFalse;
       
    52 }
       
    53 
       
    54 CWSStarCredentialObserver::~CWSStarCredentialObserver()
       
    55 {
       
    56     TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSStarCredentialObserver::~ - ");   
       
    57 	Cancel(); // Cancel any request, if outstanding
       
    58 	TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"                        - cancelled");   
       
    59 	
       
    60 }
       
    61 
       
    62 //void CWSStarCredentialObserver::Start(const TTime &aTime)
       
    63 void CWSStarCredentialObserver::Start(const TTimeIntervalMicroSeconds& aDiff) 
       
    64 {
       
    65     if (iRunned)
       
    66         {
       
    67         TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSStarCredentialObserver::Start - cancelled");   
       
    68         Cancel();
       
    69         }
       
    70         
       
    71     iRestTime = aDiff.Int64();
       
    72     StartCount();
       
    73     iRunned = ETrue;
       
    74 }
       
    75 void CWSStarCredentialObserver::StartCount() 
       
    76 {
       
    77     if (iRestTime > KHalfHour) 
       
    78         {
       
    79         TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KNormalLogLevel, _L8("CWSStarCredentialObserver::start - START only half hour  = %Ld microsec"), KHalfHour));
       
    80         After((TInt)KHalfHour);
       
    81         iRestTime = iRestTime - KHalfHour;
       
    82         }
       
    83     else
       
    84         {
       
    85         TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KNormalLogLevel, _L8("CWSStarCredentialObserver::start - START rest = %Ld microsec"), iRestTime));
       
    86         After((TInt)iRestTime);
       
    87         iRestTime = 0;
       
    88         }
       
    89 }
       
    90 
       
    91 
       
    92 void CWSStarCredentialObserver::RunL()
       
    93 {
       
    94     if (!iRestTime )
       
    95         {
       
    96         iRunned = EFalse;
       
    97         HBufC8* error(NULL);
       
    98         iSession->SessionContext()->Update(WSStarContextKeys::KOnlySharing, EFalse); 
       
    99         iSession->SessionContext()->Update(WSStarContextKeys::KReAuthNeededFromCredObserv, ETrue);
       
   100         TInt retVal = iSession->RevalidateMobileTicketIfExpiredL( error );
       
   101         iSession->SessionContext()->Update(WSStarContextKeys::KReAuthNeededFromCredObserv, EFalse);
       
   102         delete error;
       
   103         error = NULL;    
       
   104         }
       
   105     else
       
   106         {
       
   107         StartCount();
       
   108         }
       
   109 }
       
   110 
       
   111 RFileLogger* CWSStarCredentialObserver::Log() const
       
   112     {
       
   113     return iLogger;
       
   114     }