0
|
1 |
/*
|
9
|
2 |
* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
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 |
|
9
|
138 |
/**
|
|
139 |
* Gets SAT MessageHandler.
|
|
140 |
* @return MMmMessageReceiver*: pointer to SAT message handler
|
|
141 |
*/
|
|
142 |
virtual MMmMessageReceiver* SatMessHandler();
|
|
143 |
|
|
144 |
/**
|
0
|
145 |
* Sat ready indication
|
9
|
146 |
* @param TUint8: Message to be retrieved.
|
|
147 |
* @return TInt: success/failure if msg was found
|
0
|
148 |
*/
|
|
149 |
virtual TInt SatReady( TUint8 aMsg );
|
|
150 |
|
|
151 |
private:
|
|
152 |
|
|
153 |
/**
|
|
154 |
* By default EPOC constructor is private.
|
|
155 |
*/
|
|
156 |
CMmPhoNetReceiver();
|
|
157 |
|
|
158 |
/**
|
|
159 |
* Class attributes are created in ConstructL
|
|
160 |
*/
|
|
161 |
void ConstructL();
|
|
162 |
|
|
163 |
/**
|
|
164 |
* Routes received ISI message to the correct message handler
|
|
165 |
*/
|
|
166 |
void DispatchL( const TIsiReceiveC& aIsiMessage );
|
|
167 |
|
|
168 |
// Data
|
|
169 |
public:
|
|
170 |
// None
|
|
171 |
|
|
172 |
private:
|
|
173 |
|
|
174 |
// A pointer to the iscapi object
|
|
175 |
RIscApi* iPhoNet;
|
|
176 |
|
|
177 |
RArray<TMessageReceiverInfo> iMsgReceivers;
|
|
178 |
|
|
179 |
// A pointer to the called MessageReceiver object
|
|
180 |
MMmMessageReceiver* iMessageReceiver;
|
|
181 |
|
|
182 |
// a pointer to isimessage buffer
|
|
183 |
HBufC8* iMessageBuffer;
|
|
184 |
|
|
185 |
// Modifiable descriptor to isimessage buffer
|
|
186 |
TPtr8 iMessageBufferPtr;
|
|
187 |
|
|
188 |
// Needed buffer size for overly large phonet message
|
|
189 |
TUint16 iNeededBufferLength;
|
|
190 |
|
|
191 |
// A pointer to the sat message handler
|
|
192 |
MMmMessageReceiver* iSatMessHandler;
|
|
193 |
|
|
194 |
// A pointer to the stored isimessage for sat
|
|
195 |
HBufC8* iSatMessageBuffer;
|
|
196 |
};
|
|
197 |
|
|
198 |
#endif // CMMPHONETRECEIVER_H
|
|
199 |
|
|
200 |
// End of file
|