accessoryservices/remotecontrolfw/reference/serialbearer/inc/remconserialbearer.h
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 #ifndef REMCONSERIALBEARER_H
       
    22 #define REMCONSERIALBEARER_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <c32comm.h>
       
    26 #include <remcon/remconbearerplugin.h>
       
    27 #include <remcon/remconbearerinterface.h>
       
    28 #include <remcon/messagetype.h>
       
    29 /*#ifndef __WINS__
       
    30 #include <usbman.h>
       
    31 #endif
       
    32 */
       
    33 #include "sendobserver.h"
       
    34 #include "receiveobserver.h"
       
    35 
       
    36 class CSender;
       
    37 class CReceiver;
       
    38 
       
    39 /**
       
    40 Concrete serial bearer.
       
    41 */
       
    42 NONSHARABLE_CLASS(CRemConSerialBearer) : public CRemConBearerPlugin, 
       
    43 							public MRemConBearerInterface,
       
    44 							public MSendObserver, 
       
    45 							public MReceiveObserver
       
    46 	{
       
    47 public:
       
    48 	static CRemConSerialBearer* NewL(TBearerParams& aParams);
       
    49 	~CRemConSerialBearer();
       
    50 
       
    51 private: // from CRemConBearerPlugin
       
    52 	TAny* GetInterface(TUid aUid);
       
    53 
       
    54 private: // from MRemConBearerInterface
       
    55 	TInt GetResponse(TUid& aInterfaceUid, 
       
    56 		TUint& aTransactionId, 
       
    57 		TUint& aOperationId, 
       
    58 		RBuf8& aData, 
       
    59 		TRemConAddress& aAddr);
       
    60 	TInt SendCommand(TUid aInterfaceUid, 
       
    61 		TUint aCommand, 
       
    62 		TUint aTransactionId,  
       
    63 		RBuf8& aData, 
       
    64 		const TRemConAddress& aAddr);
       
    65 	TInt GetCommand(TUid& aInterfaceUid, 
       
    66 		TUint& aTransactionId, 
       
    67 		TUint& aCommand, 
       
    68 		RBuf8& aData, 
       
    69 		TRemConAddress& aAddr);
       
    70 	TInt SendResponse(TUid aInterfaceUid, 
       
    71 		TUint aOperationId, 
       
    72 		TUint aTransactionId, 
       
    73 		RBuf8& aData, 
       
    74 		const TRemConAddress& aAddr);
       
    75 	void ConnectRequest(const TRemConAddress& aAddr);
       
    76 	void DisconnectRequest(const TRemConAddress& aAddr);
       
    77 	void ClientStatus(TBool aControllerPresent, TBool aTargetPresent);
       
    78 	TSecurityPolicy SecurityPolicy() const;
       
    79 
       
    80 private: // from MSendObserver
       
    81 	void MsoSendComplete(TInt aError);
       
    82 
       
    83 private: // from MReceiveObserver
       
    84 	void MroReceiveComplete(TInt aError);
       
    85 
       
    86 private:
       
    87 	CRemConSerialBearer(TBearerParams& aParams);
       
    88 	void ConstructL();
       
    89 
       
    90 private: // utility
       
    91 	TInt DoSend(TUid aInterfaceUid, 
       
    92 		TUint aOperationId, 
       
    93 		RBuf8& aData, 
       
    94 		TRemConMessageType aMsgType);
       
    95 	void ConnectL();
       
    96 	void Receive();
       
    97 	void ClosePort();
       
    98 	void DoGetResponseL(TUid& aInterfaceUid, 
       
    99 		TUint& aOperationId, 
       
   100 		RBuf8& aData, 
       
   101 		TRemConAddress& aAddr);
       
   102 	void DoGetCommandL(TUid& aInterfaceUid,
       
   103 		TUint& aOperationId, 
       
   104 		RBuf8& aData, 
       
   105 		TRemConAddress& aAddr);
       
   106 
       
   107 private: // owned
       
   108 /*#ifndef __WINS__
       
   109 	RUsb iUsb;
       
   110 #endif
       
   111 */	RCommServ iCommServ;
       
   112 	RComm iComm;
       
   113 
       
   114 	CSender* iSender;
       
   115 	CReceiver* iReceiver;
       
   116 
       
   117 	// The format of a serial bearer message is:
       
   118 	// 012345678901234567890123456789
       
   119 	// 0xaaaaaaaa 0xbb XXX YYYYYYYYYY
       
   120 	// Where 
       
   121 	//	aaaaaaaa is the interface UID
       
   122 	//	bb is the operation ID
       
   123 	//	XXX is Cmd or Rsp
       
   124 	//	YYYYYYYYYY is any associated data
       
   125 	// The message is always KRemConSerialBearerMessageLength bytes long.
       
   126 	static const TUint KRemConSerialBearerMessageLength = 30;
       
   127 
       
   128 	// The message we may be currently sending.
       
   129 	TBuf8<KRemConSerialBearerMessageLength> iOutMsg;
       
   130 
       
   131 	// The message we may be currently receiving.
       
   132 	TBuf8<KRemConSerialBearerMessageLength> iInMsg;
       
   133 
       
   134 	// Last received and corrected-decoded message.
       
   135 	TUid iInterfaceUid;
       
   136 	TUint iOperationId;
       
   137 	TRemConMessageType iMsgType;
       
   138 	TBuf8<10> iData; // This is the length of the associated data in our naive 
       
   139 	// protocol.
       
   140 
       
   141 	// The ID of the current transaction- RemCon gives us this, and expects us 
       
   142 	// to remember it.
       
   143 	TUint iTransactionId;
       
   144 	};
       
   145 
       
   146 #endif // REMCONSERIALBEARER_H