tsrc/public/basic/atextpluginapitest/src/pluginstub.cpp
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2007 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 "pluginstub.h"
       
    20 
       
    21 enum TTestCase
       
    22     {
       
    23     EEventAT,
       
    24     EEventExtClose,
       
    25     };
       
    26     
       
    27 const TInt KFirstTimeout = 15000000;  
       
    28 const TInt KRestTimeout = 2000000;  
       
    29 
       
    30 CAtExtPluginStub* CAtExtPluginStub::NewL()
       
    31     {
       
    32     CAtExtPluginStub* self = new (ELeave) CAtExtPluginStub();
       
    33     CleanupStack::PushL(self);
       
    34     self->ConstructL();
       
    35     CleanupStack::Pop(self);
       
    36     return self;
       
    37     }
       
    38 
       
    39 CAtExtPluginStub::~CAtExtPluginStub()
       
    40 	{
       
    41 	delete iActive;
       
    42 	iTimer.Close();
       
    43 	}
       
    44 
       
    45 void CAtExtPluginStub::HandleCommand( const TDesC8& aCmd, RBuf8& aReply )
       
    46 	{
       
    47     HandleCommandCompleted(KErrNone);
       
    48     }
       
    49 
       
    50 void CAtExtPluginStub::RequestCompletedL(CGenericActive& aActive)
       
    51     {
       
    52     TInt err = aActive.RequestStatus().Int();
       
    53     switch (aActive.RequestId())
       
    54         {
       
    55         case EEventAT:
       
    56             {
       
    57             _LIT8(KAT, "\r\n+AT : 0\r\n");
       
    58             SendUnsolicitedResult(KAT);
       
    59             StartTimer(KRestTimeout, EEventExtClose);
       
    60             break;
       
    61             }
       
    62         case EEventExtClose:
       
    63             {
       
    64             delete this;
       
    65             }
       
    66         }
       
    67     }
       
    68 
       
    69 void CAtExtPluginStub::CancelRequest(CGenericActive& /*aActive*/)
       
    70     {
       
    71     iTimer.Cancel();
       
    72     }
       
    73 
       
    74 TInt CAtExtPluginStub::HandleRunError(TInt /*aErr*/)
       
    75     {
       
    76     return KErrNone;
       
    77     }
       
    78 
       
    79 CAtExtPluginStub::CAtExtPluginStub() : CATExtPluginBase()
       
    80     {
       
    81     }
       
    82      
       
    83 void CAtExtPluginStub::ConstructL()
       
    84     {
       
    85     iActive = CGenericActive::NewL(*this, CActive::EPriorityStandard, EEventAT);
       
    86     iTimer.CreateLocal();
       
    87     StartTimer(KFirstTimeout, EEventAT);
       
    88    	}
       
    89 
       
    90 
       
    91 void CAtExtPluginStub::StartTimer(TInt aTimeout, TInt aId)
       
    92     {
       
    93     iActive->SetRequestId(aId);
       
    94     iTimer.After(iActive->RequestStatus(), aTimeout);
       
    95     iActive->GoActive();
       
    96    	}
       
    97     
       
    98 //  End of File