accessoryservices/remotecontrolfw/client/intermediate/src/interfacebase.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2004-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  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 #include <bluetooth/logger.h>
       
    22 #include <remcon/remconinterfacebase.h>
       
    23 #include <remconinterfaceselector.h>
       
    24 #include "interfacebaseextension.h"
       
    25 
       
    26 #ifdef __FLOG_ACTIVE
       
    27 _LIT8(KLogComponent, LOG_COMPONENT_REMCON_IF_BASE);
       
    28 #endif
       
    29 
       
    30 EXPORT_C CRemConInterfaceBase::~CRemConInterfaceBase()
       
    31 	{
       
    32 	LOG_FUNC	
       
    33 	
       
    34 	delete iExtension;
       
    35 	}
       
    36 
       
    37 EXPORT_C CRemConInterfaceBase::CRemConInterfaceBase(TUid aInterfaceUid, 
       
    38 													TUint aMaxLength,
       
    39 													CRemConInterfaceSelector& aInterfaceSelector,
       
    40 													TRemConClientType aType)
       
    41  :	iInterfaceUid(aInterfaceUid),
       
    42 	iMaxLength(aMaxLength),
       
    43 	iType(aType),
       
    44 	iInterfaceSelector(aInterfaceSelector)
       
    45 	{
       
    46 	LOG_FUNC
       
    47 	
       
    48 	if ( aType != ERemConClientTypeController && aType != ERemConClientTypeTarget )
       
    49 		{
       
    50 		LOG(_L("Panicking with RemConIfSel / ERemConIfSelUndefinedClientType"));
       
    51 		User::Panic(KRemConIfSelPanicCat, ERemConIfSelUndefinedClientType);
       
    52 		}
       
    53 	}
       
    54 
       
    55 EXPORT_C void CRemConInterfaceBase::BaseConstructL()
       
    56 	{
       
    57 	iInterfaceSelector.RegisterInterfaceL(*this);
       
    58 	}
       
    59 
       
    60 EXPORT_C void CRemConInterfaceBase::BaseConstructL(RRemConInterfaceFeatures& aRemConInterfaceFeatures)
       
    61 	{
       
    62 	iInterfaceSelector.RegisterInterfaceL(*this, aRemConInterfaceFeatures);
       
    63 	}
       
    64 
       
    65 EXPORT_C void CRemConInterfaceBase::BaseConstructL(RRemConInterfaceFeatures& aRemConInterfaceFeatures, TBool aBulkInterface)
       
    66 	{
       
    67 	iExtension = new(ELeave) CRemConInterfaceBaseExtension();
       
    68 	iExtension->SetBulk(aBulkInterface);
       
    69 	BaseConstructL(aRemConInterfaceFeatures);
       
    70 	}
       
    71 
       
    72 EXPORT_C CRemConInterfaceSelector& CRemConInterfaceBase::InterfaceSelector()
       
    73 	{
       
    74 	return iInterfaceSelector;
       
    75 	}
       
    76 
       
    77 EXPORT_C TInt CRemConInterfaceBase::Cancel()
       
    78 	{
       
    79 	TRemConMessageType msgType = ERemConResponse;
       
    80 	if ( iType == ERemConClientTypeController )
       
    81 		{
       
    82 		msgType = ERemConCommand;
       
    83 		}
       
    84 		
       
    85 	//Ignore Return code because
       
    86 	// a) It'll mostly be other than KErrNone because the server has terminated, in which
       
    87 	//    case the original async request will have completed with the error anyway!
       
    88 	// b) It's meaningless to the client whatever the return code is.
       
    89 	(void)InterfaceSelector().SendCancel(msgType);
       
    90 	
       
    91 	return KErrNone;
       
    92 	}
       
    93 
       
    94 TUid CRemConInterfaceBase::InterfaceUid() const
       
    95 	{
       
    96 	return iInterfaceUid;
       
    97 	}
       
    98 
       
    99 TUint CRemConInterfaceBase::MaxLength() const
       
   100 	{
       
   101 	return iMaxLength;
       
   102 	}
       
   103 
       
   104 TRemConClientType CRemConInterfaceBase::Type() const
       
   105 	{
       
   106 	return iType;
       
   107 	}
       
   108 
       
   109 TBool CRemConInterfaceBase::Bulk() const
       
   110 	{
       
   111 	return iExtension && iExtension->Bulk();
       
   112 	}
       
   113 
       
   114 TBool CRemConInterfaceBase::Target(TRemConClientType aType)
       
   115 	{
       
   116 	return aType == ERemConClientTypeTarget;
       
   117 	}
       
   118