|
1 /* |
|
2 * Copyright (c) 2007-2008 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 the License "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 |
|
20 #ifndef CMMPHONETRECEIVER_H |
|
21 #define CMMPHONETRECEIVER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <iscapi.h> |
|
26 |
|
27 // CONSTANTS |
|
28 // Default size for receive buffer |
|
29 const TUint KDefaultReceiveBufferSize = 16384; // 16k |
|
30 |
|
31 // MACROS |
|
32 // None |
|
33 |
|
34 // DATA TYPES |
|
35 // None |
|
36 |
|
37 // FUNCTION PROTOTYPES |
|
38 // None |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 class RIscApi; |
|
42 class TIsiReceiveC; |
|
43 |
|
44 // CLASS DECLARATION |
|
45 |
|
46 /** |
|
47 * Message receiver interface |
|
48 */ |
|
49 class MMmMessageReceiver |
|
50 { |
|
51 public: |
|
52 |
|
53 /** |
|
54 * Virtual ReceiveMessageL method. Implemented in message handlers. |
|
55 * @param const TIsiReceiveC &aIsiMessage: The received ISI message |
|
56 */ |
|
57 virtual void ReceiveMessageL( const TIsiReceiveC& /*aIsiMessage*/ ) |
|
58 { |
|
59 // no code |
|
60 } |
|
61 |
|
62 /** |
|
63 * Virtual HandleError method. Implemented in message handlers. |
|
64 * @param const TIsiReceiveC &aIsiMessage: The received ISI message |
|
65 * @param TInt aError: Error code |
|
66 */ |
|
67 virtual void HandleError( const TIsiReceiveC& /*aIsiMessage*/, |
|
68 TInt /*aError*/ ) |
|
69 { |
|
70 // no code |
|
71 } |
|
72 }; |
|
73 |
|
74 /** |
|
75 * CMmPhoNetReceiver is used for receiving ISI messages from PhoNet. |
|
76 */ |
|
77 class CMmPhoNetReceiver : public CActive |
|
78 { |
|
79 public: // Constructors and destructor |
|
80 |
|
81 /** |
|
82 * Two-phased constructor. |
|
83 * @param RIsaApi* aPn: pointer to the Phonet |
|
84 * @return CMmPhoNetReceiver*: created object |
|
85 */ |
|
86 static CMmPhoNetReceiver* NewL( RIscApi* aPn ); |
|
87 |
|
88 /** |
|
89 * Destructor. |
|
90 */ |
|
91 ~CMmPhoNetReceiver(); |
|
92 |
|
93 public: // New functions |
|
94 |
|
95 struct TMessageReceiverInfo |
|
96 { |
|
97 TInt iResource; |
|
98 TInt iMessageId; |
|
99 MMmMessageReceiver* iReceiver; |
|
100 }; |
|
101 |
|
102 /** |
|
103 * Registers message handler to CMmPhoNetReceiver |
|
104 */ |
|
105 void RegisterL( MMmMessageReceiver* aReceiver, |
|
106 TInt aResource, |
|
107 TInt aMessageId = -1 ); |
|
108 |
|
109 /** |
|
110 * When RunL leaves, RunError is called. |
|
111 * @param TInt aError: Error from RunL |
|
112 * @return TInt: KErrNone |
|
113 */ |
|
114 TInt RunError( TInt aError ); |
|
115 |
|
116 /** |
|
117 * Handles an active object’s request completion event. |
|
118 */ |
|
119 void RunL(); |
|
120 |
|
121 /** |
|
122 * Receive message from PDA phonet |
|
123 */ |
|
124 void ReceiveL( TInt aBufferSize = KDefaultReceiveBufferSize ); |
|
125 |
|
126 /** |
|
127 * Implements cancellation of an outstanding request. |
|
128 */ |
|
129 void DoCancel(); |
|
130 |
|
131 /** |
|
132 * Sets SAT MessageHandler. |
|
133 * @param MMmMessageReceiver*: pointer to SAT message handler |
|
134 * @return TInt: success/failure indication |
|
135 */ |
|
136 virtual TInt SetSatMessHandler( MMmMessageReceiver* aSatMessHandler ); |
|
137 |
|
138 /** |
|
139 * Sat ready indication |
|
140 * @param TUint8: Message to be retrieved. |
|
141 * @return TInt: success/failure if msg was found |
|
142 */ |
|
143 virtual TInt SatReady( TUint8 aMsg ); |
|
144 |
|
145 private: |
|
146 |
|
147 /** |
|
148 * By default EPOC constructor is private. |
|
149 */ |
|
150 CMmPhoNetReceiver(); |
|
151 |
|
152 /** |
|
153 * Class attributes are created in ConstructL |
|
154 */ |
|
155 void ConstructL(); |
|
156 |
|
157 /** |
|
158 * Routes received ISI message to the correct message handler |
|
159 */ |
|
160 void DispatchL( const TIsiReceiveC& aIsiMessage ); |
|
161 |
|
162 // Data |
|
163 public: |
|
164 // None |
|
165 |
|
166 private: |
|
167 |
|
168 // A pointer to the iscapi object |
|
169 RIscApi* iPhoNet; |
|
170 |
|
171 RArray<TMessageReceiverInfo> iMsgReceivers; |
|
172 |
|
173 // A pointer to the called MessageReceiver object |
|
174 MMmMessageReceiver* iMessageReceiver; |
|
175 |
|
176 // a pointer to isimessage buffer |
|
177 HBufC8* iMessageBuffer; |
|
178 |
|
179 // Modifiable descriptor to isimessage buffer |
|
180 TPtr8 iMessageBufferPtr; |
|
181 |
|
182 // Needed buffer size for overly large phonet message |
|
183 TUint16 iNeededBufferLength; |
|
184 |
|
185 // A pointer to the sat message handler |
|
186 MMmMessageReceiver* iSatMessHandler; |
|
187 |
|
188 // A pointer to the stored isimessage for sat |
|
189 HBufC8* iSatMessageBuffer; |
|
190 }; |
|
191 |
|
192 #endif // CMMPHONETRECEIVER_H |
|
193 |
|
194 // End of file |