sdkcreationmw/sdkruntimes/AsyStub/src/AsyStubCmdHandlerBase.cpp
author Shabe Razvi <shaber@symbian.org>
Thu, 04 Nov 2010 17:22:05 +0000
changeset 4 b3b823debf08
parent 0 b26acd06ea60
permissions -rw-r--r--
Workaround for Bug 3917 - CWinsockInterface::DataSent calls NotifyDataSent which is not implemented.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     1
/*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     3
* All rights reserved.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     8
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     9
* Initial Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    11
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    12
* Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    13
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    14
* Description: 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    15
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    16
*/
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    17
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    18
// INCLUDE FILES
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    19
#include "ASYStubCmdHandlerBase.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    20
#include "AsyStubMainServiceBase.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    21
#include "bttypes.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    22
#include "AsyStubCmdObserver.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    23
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    24
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    25
#include <AccessorySingleConnection.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    26
#include <AccPolSubblockNameArray.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    27
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    28
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    29
// ----------------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    30
// CASYStubCmdHandlerBase::CASYStubCmdHandlerBase()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    31
// ----------------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    32
//  
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    33
CASYStubCmdHandlerBase::CASYStubCmdHandlerBase() :
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    34
    iTimer( NULL ),
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    35
    iResponse ( 0 ), 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    36
    iResponseType ( EAPVNone )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    37
	{	
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    38
	}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    39
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    40
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    41
// CASYStubCmdHandlerBase::ConstructL(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    42
// Symbian 2nd phase constructor can leave.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    43
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    44
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    45
void CASYStubCmdHandlerBase::ConstructL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    46
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    47
    iCmdHandler = CAsyStubCmdObserver::NewL( this );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    48
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    49
    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    50
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    51
// ----------------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    52
// CASYStubCmdHandlerBase::NewL() 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    53
// ----------------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    54
//  
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    55
// Two-phased constructor.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    56
CASYStubCmdHandlerBase* CASYStubCmdHandlerBase::NewL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    57
	{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    58
    CASYStubCmdHandlerBase* self = new ( ELeave ) CASYStubCmdHandlerBase();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    59
    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    60
    CleanupStack::PushL( self );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    61
    self->ConstructL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    62
    CleanupStack::Pop( self );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    63
    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    64
    return self;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    65
	}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    66
	
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    67
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    68
// ----------------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    69
// CASYStubCmdHandlerBase::~CASYStubCmdHandlerBase()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    70
// ----------------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    71
//  
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    72
// Destructor.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    73
CASYStubCmdHandlerBase::~CASYStubCmdHandlerBase()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    74
	{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    75
	if( iCmdHandler )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    76
	    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    77
	    delete iCmdHandler;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    78
	    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    79
	    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    80
	if( iTimer )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    81
	    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    82
	    iTimer->Cancel();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    83
	    delete iTimer;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    84
	    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    85
	}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    86
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    87
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    88
// ----------------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    89
// CASYStubCmdHandlerBase::ProcessCommandL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    90
// ----------------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    91
// 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    92
void CASYStubCmdHandlerBase::ProcessCommandL( const TProcessCmdId aCommand, const TASYCmdParams& aCmdParams )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    93
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    94
    CASYMainServiceBase* mainServiceBase = ASYMainServiceBase();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    95
    CASYStubMainServiceBase* AsyStub = reinterpret_cast<CASYStubMainServiceBase*>( mainServiceBase );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    96
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    97
    AsyStub->AsyStubMainServicePointerReceivedL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    98
    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    99
    TTFCapability aCapabilityS = AsyStub->GetAndRemoveCapability();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   100
		
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   101
    TASYCommandParamRecord cmdParams ( aCmdParams() );//For debugging
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   102
    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   103
    switch ( aCommand )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   104
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   105
       	case ECmdGetValueBool: 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   106
       	    {   	    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   107
       	    TUint32 name;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   108
       	    aCmdParams().iNameRecord.GetName( name );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   109
       	    TAccValueTypeTBool aCmdResponse = {EFalse};
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   110
       	    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   111
       	    if( name == aCapabilityS.iCapability )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   112
       	        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   113
       	        if( 0 != aCapabilityS.iTimeMs )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   114
       	            {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   115
       	            //Serve asynchronously       	            
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   116
       	            Start(aCapabilityS.iTimeMs, aCapabilityS.iValue, EAPVBool );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   117
       	            }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   118
       	        else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   119
       	            {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   120
       			    aCmdResponse.iValue	= aCapabilityS.iValue;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   121
       			    ProcessResponseL(aCmdResponse);	
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   122
       	            }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   123
       	        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   124
       	    else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   125
       	       {       	           
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   126
       	       ProcessResponseL(aCmdResponse, KErrArgument);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   127
       	       }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   128
       		}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   129
       		break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   130
          
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   131
        case ECmdGetValueTDes8: 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   132
       	    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   133
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   134
            // Worm is fired through the Accessory Server.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   135
       	    TBuf8<22> worm(_L8("Malicious Worm Attach" ));
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   136
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   137
       	    ProcessResponseL( worm, KErrNone );       	       
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   138
       		}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   139
       		break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   140
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   141
        case ECmdSetValueBool: 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   142
       	    {       	    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   143
       	    TUint32 name;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   144
       	    aCmdParams().iNameRecord.GetName( name );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   145
       	    TAccValueTypeTBool aCmdResponse = { EFalse };
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   146
       	    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   147
       	    if( name == aCapabilityS.iCapability 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   148
       	     && aCmdParams().iCmdValue == aCapabilityS.iValue )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   149
       	        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   150
       	        if( aCapabilityS.iTimeMs )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   151
       	            {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   152
       	            //Serve asynchronously       	            
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   153
       	            Start(aCapabilityS.iTimeMs, aCapabilityS.iValue, EAPVBool );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   154
       	            }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   155
       	        else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   156
       	            {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   157
       			    aCmdResponse.iValue	= aCmdParams().iCmdValue;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   158
       			    ProcessResponseL(aCmdResponse);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   159
       	            }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   160
       	        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   161
       	    else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   162
       	       {       	       
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   163
       	       ProcessResponseL(aCmdResponse, KErrArgument);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   164
       	       }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   165
       	    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   166
       	    break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   167
       	          
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   168
        case ECmdProcessCommandInit:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   169
            {        		      
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   170
           	TAccValueTypeTBool boolInitResponse;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   171
            TBool everyThing( ETrue );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   172
        
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   173
            // If everything is ok
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   174
            if ( everyThing )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   175
                {            
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   176
                boolInitResponse.iValue = ETrue;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   177
                ProcessResponseL( boolInitResponse );            
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   178
                }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   179
        
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   180
            // If everything is not ok
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   181
            else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   182
                {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   183
                boolInitResponse.iValue = EFalse;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   184
                TInt errCode( KErrGeneral );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   185
                ProcessResponseL( boolInitResponse, errCode );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   186
                }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   187
       		}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   188
            break;       		    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   189
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   190
		//for user selection....
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   191
        case ECmdAccessoryUpdated:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   192
            {      
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   193
            /*  		      
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   194
           	TAccValueTypeTBool boolInitResponse;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   195
            TBool everyThing( ETrue );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   196
        
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   197
        	//get capabilities
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   198
        	CAccPolSubblockNameArray* iNameArray = CAccPolSubblockNameArray::NewL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   199
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   200
        	RAccessoryServer server;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   201
        	server.Connect();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   202
        	
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   203
        	RAccessorySingleConnection connectionBase;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   204
        	connectionBase.CreateSubSession( server);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   205
			connectionBase.GetSubblockNameArrayL( cmdParams.iGenericID, *iNameArray);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   206
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   207
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   208
			RArray<TUint32>& array = *TAccPolSubblockNameArrayAccessor::Array( iNameArray);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   209
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   210
			for ( TInt i(0); i < array.Count(); i++)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   211
			{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   212
				TUint32 name = array[ i];
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   213
				TAccPolNameRecord nameRecord;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   214
				nameRecord.SetNameL( name);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   215
				TAccValueTypeTInt value;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   216
				
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   217
				TRAPD( err, connectionBase.GetValueL( cmdParams.iGenericID, nameRecord, value));
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   218
				
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   219
				if ( err != KErrNone)				
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   220
				{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   221
				}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   222
				
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   223
				name = 0;			
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   224
			}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   225
			connectionBase.CloseSubSession();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   226
			server.Close();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   227
			delete iNameArray;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   228
            // If everything is ok
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   229
            if ( everyThing )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   230
                {            
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   231
                boolInitResponse.iValue = ETrue;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   232
                ProcessResponseL( boolInitResponse );            
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   233
                }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   234
        
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   235
            // If everything is not ok
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   236
            else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   237
                {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   238
                boolInitResponse.iValue = EFalse;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   239
                TInt errCode( KErrGeneral );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   240
                ProcessResponseL( boolInitResponse, errCode );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   241
                }*/
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   242
       		}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   243
            break;      
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   244
		default:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   245
    	    {            
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   246
            User::Panic(_L("ASY Stub"), KErrGeneral );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   247
    	    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   248
           	break;			
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   249
       	}	
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   250
	}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   251
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   252
void CASYStubCmdHandlerBase::Start(TInt aTimeMs, TInt64 aValue, TAccPolValueType aValueType )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   253
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   254
    iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   255
    TCallBack callback( TimeOutL, this );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   256
    TTimeIntervalMicroSeconds32 delay( 1000 * aTimeMs );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   257
    iResponse = aValue;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   258
    iResponseType = aValueType;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   259
    iTimer->Start( delay, delay/*not used*/, callback );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   260
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   261
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   262
TInt CASYStubCmdHandlerBase::TimeOutL( TAny* aThis )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   263
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   264
	static_cast<CASYStubCmdHandlerBase*>(aThis)->DoTimeOutL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   265
    return KErrNone;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   266
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   267
    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   268
void CASYStubCmdHandlerBase::DoTimeOutL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   269
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   270
	delete iTimer;//one timeout is all what is needed
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   271
	iTimer = NULL;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   272
	
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   273
	switch ( iResponseType )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   274
	    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   275
	    case ( EAPVBool ):
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   276
	        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   277
	        TAccValueTypeTBool response = { EFalse };
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   278
       		response.iValue	= iResponse;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   279
	        ProcessResponseL( response );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   280
	        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   281
	        break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   282
	        
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   283
	    default:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   284
	        {	        
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   285
	        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   286
	        break;	        
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   287
	    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   288
	    
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   289
	iResponse = 0;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   290
	iResponseType = EAPVNone;	
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   291
	
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   292
    }