telephonyserverplugins/common_tsy/commontsy/src/mmutility/CMmPrivateUtility.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 //  INCLUDE FILES
       
    19 #include "CMmPrivateUtility.h"
       
    20 #include "MmTsy_conf.h"
       
    21 #include "CMmCommonStaticUtility.h"
       
    22 #include "cmmphonetsy.h"
       
    23 #include "cmmcalltsy.h"
       
    24 #include "Cmmpacketcontexttsy.h"
       
    25 #include <f32file.h>
       
    26 
       
    27 // ======== LOCAL FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // MmTsyPanic
       
    31 // Panic method for MM TSY. NOTE! TRAP's can't handle this but Panic goes 
       
    32 // through them. Use this method only when Panic is absolutely necessary.
       
    33 // (other items were commented in a header).
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 void MmTsyPanic( TMmTsyError aError ) 
       
    37     {
       
    38     _LIT( KPanicCategory, "MM TSY PANIC" );
       
    39     User::Panic( KPanicCategory, aError );
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // MmTsyPanic
       
    44 // Leave method for MM TSY. TRAP's will handle these cases.
       
    45 // (other items were commented in a header).
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 void MmTsyLeaveL( TMmTsyError aError )
       
    49     {
       
    50     User::Leave( aError );
       
    51     }
       
    52     
       
    53 // ======== MEMBER FUNCTIONS ========
       
    54 
       
    55 
       
    56 CNetNetworkAvailableInfo::CNetNetworkAvailableInfo() : CBase()
       
    57     {
       
    58     }
       
    59 
       
    60 CNetNetworkAvailableInfo::~CNetNetworkAvailableInfo()
       
    61     {
       
    62     }
       
    63 
       
    64 CListReadAllAttempt* CListReadAllAttempt::NewL(
       
    65     RMobilePhone::TClientId* aId )
       
    66     {
       
    67     CListReadAllAttempt* read = new ( ELeave ) CListReadAllAttempt( aId );
       
    68     CleanupStack::PushL( read );
       
    69     read->ConstructL();
       
    70     CleanupStack::Pop();
       
    71     return read;
       
    72     }
       
    73 
       
    74 CListReadAllAttempt::CListReadAllAttempt(
       
    75     RMobilePhone::TClientId* aId ) : CBase()
       
    76     {
       
    77     iClient.iSessionHandle = aId->iSessionHandle;
       
    78     iClient.iSubSessionHandle = aId->iSubSessionHandle;
       
    79     iListBuf = NULL;
       
    80     }
       
    81 
       
    82 void CListReadAllAttempt::ConstructL()
       
    83     {
       
    84     }
       
    85 
       
    86 CListReadAllAttempt::~CListReadAllAttempt()
       
    87     {
       
    88     delete iListBuf;
       
    89     }
       
    90 
       
    91 CAcquireEntry* CAcquireEntry::NewL(
       
    92     const TTsyReqHandle aTsyReqHandle )
       
    93     {
       
    94     return new ( ELeave ) CAcquireEntry( aTsyReqHandle );
       
    95     }
       
    96 
       
    97 CAcquireEntry::CAcquireEntry(
       
    98     const TTsyReqHandle aTsyReqHandle )
       
    99     {
       
   100     iTsyReqHandle = aTsyReqHandle;
       
   101     }
       
   102 
       
   103 CAcquireEntry::~CAcquireEntry()
       
   104     { 
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CAcquireEntry::Deque
       
   109 // 
       
   110 // (other items were commented in a header).
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CAcquireEntry::Deque()
       
   114     {
       
   115     iLink.Deque();
       
   116     iLink.iPrev = iLink.iNext = NULL;
       
   117     }
       
   118 
       
   119 CAcquireOwnerList* CAcquireOwnerList::NewL()
       
   120     {
       
   121     CAcquireOwnerList* ac = new ( ELeave ) CAcquireOwnerList();
       
   122     CleanupStack::PushL( ac );
       
   123     ac->ConstructL();
       
   124     CleanupStack::Pop();
       
   125     return ac;
       
   126     }
       
   127 
       
   128 CAcquireOwnerList::CAcquireOwnerList()
       
   129     {
       
   130     }
       
   131 
       
   132 void CAcquireOwnerList::ConstructL()
       
   133     {
       
   134     iAcquireList.SetOffset( _FOFF ( CAcquireEntry, iLink ) );
       
   135     }
       
   136 
       
   137 CAcquireOwnerList::~CAcquireOwnerList()
       
   138     { 
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // CAcquireOwnerList::FindByTsyReqHandle
       
   143 // loop through entries in the iAcquireList and return pointer to  
       
   144 // CAcquireEntry object
       
   145 // (other items were commented in a header).
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 CAcquireEntry* CAcquireOwnerList::FindByTsyReqHandle(
       
   149     const TTsyReqHandle aTsyReqHandle )
       
   150     {
       
   151     CAcquireEntry* entry;
       
   152     TDblQueIter<CAcquireEntry> iter( iAcquireList );
       
   153     while( entry = iter++, entry != NULL )
       
   154         {
       
   155         if( entry->iTsyReqHandle == aTsyReqHandle )
       
   156             return entry;
       
   157         }
       
   158     return NULL;
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // CAcquireOwnerList::Remove
       
   163 // delete the entry
       
   164 // (other items were commented in a header).
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 void CAcquireOwnerList::Remove(
       
   168     CAcquireEntry* aEntry )
       
   169     {
       
   170     aEntry->Deque();
       
   171     delete aEntry;
       
   172     }
       
   173 
       
   174 CHeartbeatRunner* CHeartbeatRunner::NewL( CMmCallTsy* aMmCall, CMmPhoneTsy* aMmPhone ) 
       
   175     {
       
   176     CHeartbeatRunner* runner = new ( ELeave ) CHeartbeatRunner;
       
   177     CleanupStack::PushL( runner );
       
   178     runner->iMmCall = aMmCall;
       
   179     runner->iMmPhone = aMmPhone;    
       
   180     runner->ConstructL();
       
   181     CleanupStack::Pop();
       
   182     return runner;
       
   183     }
       
   184 
       
   185 CHeartbeatRunner::CHeartbeatRunner()
       
   186     {
       
   187     }
       
   188 
       
   189 void CHeartbeatRunner::ConstructL()
       
   190     {
       
   191     // neutral priority, 0
       
   192     iHeartbeat = CHeartbeat::NewL( CActive::EPriorityStandard );
       
   193     iActive = EFalse; 
       
   194     iStartTime = 0;
       
   195     iAirTimeDuration = EFalse;
       
   196     iPreviousNumberOfBeats = 0;
       
   197     }
       
   198 
       
   199 CHeartbeatRunner::~CHeartbeatRunner()
       
   200     {
       
   201     if ( iHeartbeat )
       
   202         {
       
   203         //stop calling Beat...
       
   204         iHeartbeat->Cancel();
       
   205         }
       
   206 
       
   207     delete iHeartbeat;
       
   208     }
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // CHeartbeatRunner::Start
       
   212 // Starts timer.
       
   213 // (other items were commented in a header).
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 void CHeartbeatRunner::Start()
       
   217     {
       
   218     //Check if active 
       
   219     if ( !iActive ) 
       
   220         {
       
   221         //Initialize iStartime
       
   222         iStartTime.UniversalTime();
       
   223         //Timer tick is on the second 
       
   224         iHeartbeat->Start( ETwelveOClock, this );
       
   225         //Set flag to indicate that timer is active
       
   226         iActive = ETrue;
       
   227         //Set flag to indicate that air time duration counter is not started
       
   228         iAirTimeDuration = EFalse;
       
   229         }
       
   230     }
       
   231 
       
   232 // ---------------------------------------------------------------------------
       
   233 // CHeartbeatRunner::StartAirTimeDuration
       
   234 // Starts AirTimeDuration timer.
       
   235 // (other items were commented in a header).
       
   236 // ---------------------------------------------------------------------------
       
   237 //
       
   238 void CHeartbeatRunner::StartAirTimeDuration()
       
   239     {
       
   240     //Check if active 
       
   241     if ( !iActive ) 
       
   242         { 
       
   243         //Initialize iStartime
       
   244         iStartTime.UniversalTime();
       
   245         //Timer tick is on the second 
       
   246         iHeartbeat->Start( ETwelveOClock, this );
       
   247         //Set flag to indicate that timer is active
       
   248         iActive = ETrue;
       
   249         //Set flag to indicate that air time duration counter is started
       
   250         iAirTimeDuration = ETrue;
       
   251         }
       
   252     }
       
   253 
       
   254 // ---------------------------------------------------------------------------
       
   255 // CHeartbeatRunner::Stop
       
   256 // Stops timer
       
   257 // (other items were commented in a header).
       
   258 // ---------------------------------------------------------------------------
       
   259 //
       
   260 TBool CHeartbeatRunner::Stop()
       
   261     {
       
   262     TBool ret = iActive;
       
   263 
       
   264     //Check if active 
       
   265     if ( iActive ) 
       
   266         { 
       
   267         // Save the number of beats
       
   268         iPreviousNumberOfBeats = NumberOfBeats();
       
   269         //Reset iStartTime
       
   270         iStartTime = 0;
       
   271         //Cancel beat method calling 
       
   272         iHeartbeat->Cancel(); 
       
   273         //Set flag to indicate that timer is not active
       
   274         iActive = EFalse;
       
   275         }
       
   276 
       
   277     return ret;
       
   278     }
       
   279 
       
   280 // ---------------------------------------------------------------------------
       
   281 // CHeartbeatRunner::Beat
       
   282 // Beat is called once every second. If iMmCall is not null
       
   283 // (timer is used for calculating the duration of a call), the method
       
   284 // CompleteNotifyCallDurationChange is called (other items were commented in a header).
       
   285 // ---------------------------------------------------------------------------
       
   286 //
       
   287 void CHeartbeatRunner::Beat()
       
   288     {
       
   289     // if iMmCall is not null, this timer is used to count the duration of a 
       
   290     // call
       
   291     if ( iMmCall )
       
   292         {
       
   293         //complete notify duration change, 1 sec gone
       
   294         iMmCall->CompleteNotifyCallDurationChange();
       
   295         }
       
   296         
       
   297     if ( iMmPhone )
       
   298         {
       
   299         //complete notify duration change, 10 sec gone
       
   300         if ( NumberOfBeats() % iMmPhone->KLifeTimeUpdateInterval == 0 )
       
   301         	{        	
       
   302         	iMmPhone->CompleteNotifyCallDurationChange();
       
   303         	}
       
   304         }                
       
   305     }
       
   306 
       
   307 // ---------------------------------------------------------------------------
       
   308 // CHeartbeatRunner::NumberOfBeats
       
   309 // Returns number of beats from the previous Start of the timer.
       
   310 // (other items were commented in a header).
       
   311 // ---------------------------------------------------------------------------
       
   312 //
       
   313 TInt CHeartbeatRunner::NumberOfBeats()
       
   314     {
       
   315     if(iActive)
       
   316     	{
       
   317     	TTime currentTime;
       
   318     	currentTime.UniversalTime();
       
   319     	TTimeIntervalSeconds secondsFromStart( 0 );
       
   320     	currentTime.SecondsFrom( iStartTime, secondsFromStart );
       
   321     	return secondsFromStart.Int();
       
   322     	}
       
   323     return iPreviousNumberOfBeats;
       
   324     }
       
   325 
       
   326 // ---------------------------------------------------------------------------
       
   327 // CHeartbeatRunner::Synchronize
       
   328 // Implementation of MBeating::Synchronize. Since the number of beats are calculated
       
   329 // by using start and actual current times, there is no need for synchronization.
       
   330 // (other items were commented in a header).
       
   331 // ---------------------------------------------------------------------------
       
   332 //
       
   333 void CHeartbeatRunner::Synchronize()
       
   334     {
       
   335     // do nothing 
       
   336     }
       
   337 
       
   338 // ---------------------------------------------------------------------------
       
   339 // CHeartbeatRunner::GetTimerStartTime
       
   340 // Returns the starting time of the timer as a TTime pointer
       
   341 // (other items were commented in a header).
       
   342 // ---------------------------------------------------------------------------
       
   343 //
       
   344 TTime* CHeartbeatRunner::GetTimerStartTime()
       
   345     {
       
   346     return &iStartTime;
       
   347     }
       
   348 
       
   349 //  End of File