|
1 // Copyright (c) 2008-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 #ifndef __APP_PROTINF_BASE_H__ |
|
17 #define __APP_PROTINF_BASE_H__ |
|
18 |
|
19 #include <comms-infras/ss_subconnflow.h> |
|
20 #include <rsockethandler.h> |
|
21 #include <csocketopener.h> |
|
22 #include <appprotintf/genericcontainer.h> |
|
23 |
|
24 _LIT ( KAppProtIntfInvalidRealmId, " RealmId is invalid " ); |
|
25 |
|
26 enum TAppProtIntfPanic |
|
27 { |
|
28 KInvalidReamId |
|
29 }; |
|
30 |
|
31 // Forward declarations |
|
32 class CApplicationProtocolIntfFactory; |
|
33 |
|
34 class CApplicationProtocolIntfBase : public CFactoryObject, |
|
35 public MSocketHandlerObserver |
|
36 { |
|
37 public: |
|
38 |
|
39 inline TUint Port () const; |
|
40 virtual TUint Protocol () const =0; |
|
41 virtual ~CApplicationProtocolIntfBase (); |
|
42 |
|
43 protected: |
|
44 |
|
45 enum |
|
46 { |
|
47 ERecvFrom = 1 |
|
48 }; |
|
49 |
|
50 typedef Messages::TMessageSigVoid < ERecvFrom, ESock::TCFMessage::ERealmId > TRecvFrom; |
|
51 |
|
52 CApplicationProtocolIntfBase ( TUint aPort, TInt aProtocolType ); |
|
53 |
|
54 void JoinCompleted (); |
|
55 void PostToLink ( const Messages::TNodeCtxId& aRecipient, const Messages::TSignatureBase& aMessage ); |
|
56 void PostToLink ( const Messages::RNodeInterface& aRecipient, const Messages::TSignatureBase& aMessage ); |
|
57 void PostToAllLinks ( const Messages::TSignatureBase& aMessage ); |
|
58 |
|
59 void InitiateLinkL ( const Messages::TNodeCtxId& aSender, TUint aSockType, TUint aProtocol ); |
|
60 void HandleClientLeavingRequest ( const Messages::TNodeCtxId& aSender ); |
|
61 void CloseLink ( const Messages::TNodeId& aSender ); |
|
62 |
|
63 TInt OpenSocket ( TUint aAddrFamily, TUint aSockType, TUint aProtocol ); |
|
64 |
|
65 virtual TInt Startup () =0; |
|
66 virtual void Shutdown (); |
|
67 |
|
68 // From ANodeIdBase |
|
69 virtual void ReceivedL ( const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage ); |
|
70 |
|
71 // From MSocketHandlerObserver |
|
72 virtual void OpenComplete ( RInternalSocket& aSocket ); |
|
73 inline virtual void ConnectComplete (); |
|
74 inline virtual void AcceptComplete ( RInternalSocket& aSocket ); |
|
75 inline virtual void SendComplete ( TInt aLength ); |
|
76 inline virtual void SendToComplete ( TInt aLength ); |
|
77 inline virtual void RecvComplete ( RMBufChain& aData ); |
|
78 inline virtual void RecvFromComplete ( RMBufChain& aData, const TSockAddr& aAddr ); |
|
79 // virtual void IoctlComplete (); |
|
80 virtual void Error ( TOperation aOperation, TInt aError ); |
|
81 |
|
82 protected: |
|
83 TInt AddLink ( const Messages::TNodeId& aSender ); |
|
84 TInt RemoveLink ( const Messages::TNodeId& aSender ); |
|
85 TInt FindLink ( const Messages::TNodeId& aSender ); |
|
86 |
|
87 protected: |
|
88 RArray<Messages::RNodeInterface> iLinks; |
|
89 RSocketHandler iSocketHandler; |
|
90 RInternalSocket iSocket; |
|
91 private: |
|
92 TUint iPort; |
|
93 CSocketOpener* iSocketOpener; |
|
94 }; |
|
95 |
|
96 |
|
97 TUint CApplicationProtocolIntfBase::Port () const |
|
98 { |
|
99 return iPort; |
|
100 } |
|
101 |
|
102 void CApplicationProtocolIntfBase::ConnectComplete () |
|
103 { |
|
104 |
|
105 } |
|
106 |
|
107 void CApplicationProtocolIntfBase::AcceptComplete ( RInternalSocket& /* aSocket */ ) |
|
108 { |
|
109 } |
|
110 |
|
111 /*void CApplicationProtocolIntfBase::IoctlComplete () |
|
112 { |
|
113 } |
|
114 */ |
|
115 void CApplicationProtocolIntfBase::RecvComplete ( RMBufChain& /* aData */ ) |
|
116 { |
|
117 |
|
118 } |
|
119 |
|
120 void CApplicationProtocolIntfBase::RecvFromComplete ( RMBufChain& /* aData */, const TSockAddr& /* aAddr */ ) |
|
121 { |
|
122 |
|
123 } |
|
124 |
|
125 void CApplicationProtocolIntfBase::SendComplete ( TInt /* aLength */ ) |
|
126 { |
|
127 |
|
128 } |
|
129 |
|
130 void CApplicationProtocolIntfBase::SendToComplete ( TInt /* aLength */ ) |
|
131 { |
|
132 |
|
133 } |
|
134 |
|
135 #endif // __APP_PROTINF_BASE_H__ |