1 /* |
|
2 * Copyright (c) 2009 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 "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: Provides IM sending and receiving services. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CSIMPLEIMCONVERSATION_H |
|
20 #define C_CSIMPLEIMCONVERSATION_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <ximpbase.h> |
|
24 #include <ximpcontextobserver.h> |
|
25 #include <ximprequestcompleteevent.h> |
|
26 #include <protocolimconversation.h> |
|
27 #include <simpleinstantmsgobserver.h> |
|
28 #include <simpleinstantmessage.h> |
|
29 |
|
30 class CIMCacheFactory; |
|
31 class MIMCacheUpdater; |
|
32 class MPresencePluginConnectionObs; |
|
33 class MSimpleConnection; |
|
34 class MProtocolImDataHost; |
|
35 class MXIMPIdentity; |
|
36 |
|
37 /** |
|
38 * This class is used for sending and receiving instant messages. |
|
39 * A client sends the message and waits for notification of send process |
|
40 * success. Client is notified with |
|
41 * MPresencePluginConnectionObs::CompleteReq(). |
|
42 * |
|
43 * There can be only one message in the sending que at the time. |
|
44 * Otherwise DoSendMessageL() method leaves with KErrInUse. |
|
45 * |
|
46 * Messages received from the other end are handled in this class and |
|
47 * delivered to the client. Client gets messages through |
|
48 * MProtocolImConversationDataHost::HandleNewTextMessageL(). |
|
49 * |
|
50 * @lib simpleimplugin.dll |
|
51 * @since S60 v5.1 |
|
52 */ |
|
53 NONSHARABLE_CLASS( CSimpleImConversation ) : public CBase, |
|
54 public MProtocolImConversation, |
|
55 public MSimpleInstantMsgObserver |
|
56 { |
|
57 |
|
58 public: |
|
59 |
|
60 /** |
|
61 * Two-phased constructor. |
|
62 * |
|
63 * @param aObs Callback for complete requests. |
|
64 * @param aConn Simple engine connection. |
|
65 */ |
|
66 static CSimpleImConversation* NewL( |
|
67 MPresencePluginConnectionObs& aObs, MSimpleConnection& aConn, |
|
68 TUint aServiceId ); |
|
69 |
|
70 /** |
|
71 * Destructor. |
|
72 */ |
|
73 virtual ~CSimpleImConversation(); |
|
74 |
|
75 public: |
|
76 |
|
77 /** |
|
78 * Sets current IM data host. |
|
79 * |
|
80 * @since S60 v5.1 |
|
81 * @param aHost IM data host. |
|
82 */ |
|
83 void SetHost( MProtocolImDataHost& aHost ); |
|
84 |
|
85 public: //from MXIMPBase |
|
86 |
|
87 /** |
|
88 * From MXIMPBase. |
|
89 * @see MXIMPBase. |
|
90 */ |
|
91 TAny* GetInterface( |
|
92 TInt32 aInterfaceId, |
|
93 TIfGetOps aOptions ); |
|
94 |
|
95 /** |
|
96 * From MXIMPBase. |
|
97 * @see MXIMPBase. |
|
98 */ |
|
99 const TAny* GetInterface( |
|
100 TInt32 aInterfaceId, |
|
101 TIfGetOps aOptions ) const; |
|
102 |
|
103 /** |
|
104 * From MXIMPBase. |
|
105 * @see MXIMPBase. |
|
106 */ |
|
107 TInt32 GetInterfaceId() const; |
|
108 |
|
109 public: // From MProtocolImConversation |
|
110 |
|
111 /** |
|
112 * From MProtocolImConversation. |
|
113 * @see MProtocolImConversation. |
|
114 */ |
|
115 void DoSendMessageL( |
|
116 const MImConversationInfo& aImMessage, |
|
117 TXIMPRequestId aReqId ); |
|
118 |
|
119 /** |
|
120 * From MProtocolImConversation. |
|
121 * @see MProtocolImConversation. |
|
122 */ |
|
123 void DoForwardMessageL( |
|
124 const MImConversationInfo& aImMessage, |
|
125 TXIMPRequestId aReqId); |
|
126 |
|
127 /** |
|
128 * From MProtocolImConversation. |
|
129 * @see MProtocolImConversation. |
|
130 */ |
|
131 void DoSendMessageToGroupL( |
|
132 const MImConversationInfo& aImMessage, |
|
133 const TDesC* aGroupId,TXIMPRequestId aReqId ); |
|
134 |
|
135 /** |
|
136 * From MProtocolImConversation. |
|
137 * @see MProtocolImConversation. |
|
138 */ |
|
139 TXIMPRequestId DoBlockUsersL( |
|
140 const MDesCArray* aUserIds, |
|
141 TXIMPRequestId aReqId); |
|
142 |
|
143 /** |
|
144 * From MProtocolImConversation. |
|
145 * @see MProtocolImConversation. |
|
146 */ |
|
147 TXIMPRequestId DoUnBlockUsersL( |
|
148 const MDesCArray* aUserIds, |
|
149 TXIMPRequestId aReqId ); |
|
150 |
|
151 /** |
|
152 * From MProtocolImConversation. |
|
153 * @see MProtocolImConversation. |
|
154 */ |
|
155 void DoGetBlockedListRequestL( |
|
156 const MXIMPIdentity& aImMessageId, |
|
157 TXIMPRequestId aReqId ); |
|
158 |
|
159 /** |
|
160 * From MProtocolImConversation. |
|
161 * @see MProtocolImConversation. |
|
162 */ |
|
163 void DoGetMessageListL( |
|
164 const MXIMPIdentity& aImMessageId, |
|
165 const TDesC* aGroupId, |
|
166 const TInt aMessageCount, |
|
167 TBool aDeliveryReportWanted, |
|
168 TXIMPRequestId aReqId); |
|
169 |
|
170 /** |
|
171 * From MProtocolImConversation. |
|
172 * @see MProtocolImConversation. |
|
173 */ |
|
174 void DoRejectMessageL( |
|
175 const MXIMPIdentity& aImMessageId, |
|
176 const TDesC& aMessageID, |
|
177 TXIMPRequestId aReqId ); |
|
178 |
|
179 public: // From MSimpleInstantMsgObserver |
|
180 |
|
181 /** |
|
182 * From MSimpleInstantMsgObserver. |
|
183 * @see MSimpleInstantMsgObserver. |
|
184 */ |
|
185 void SendInstantMsgReqComplete( TInt aOpid, TInt aStatus ); |
|
186 |
|
187 /** |
|
188 * From MSimpleInstantMsgObserver. |
|
189 * @see MSimpleInstantMsgObserver. |
|
190 */ |
|
191 void HandleReceiveTextMessage( TPtrC8 aFrom, TPtrC8 aContent ); |
|
192 |
|
193 private: // constructor and the Symbian second-phase constructor |
|
194 |
|
195 CSimpleImConversation( MPresencePluginConnectionObs& aObs, |
|
196 MSimpleConnection& aConn, |
|
197 TUint aServiceId ); |
|
198 |
|
199 void ConstructL( ); |
|
200 |
|
201 private: |
|
202 |
|
203 /** |
|
204 * Calls MXIMPProtocolConnectionHost callback. |
|
205 * |
|
206 * @since S60 v5.1 |
|
207 * @param aStatus Error status. |
|
208 */ |
|
209 void CompleteXimpReq( TInt aStatus ); |
|
210 |
|
211 /** |
|
212 * Leaveable version of HandleReceiveTextMessage. |
|
213 * |
|
214 * @see MSimpleInstantMsgObserver |
|
215 */ |
|
216 void DoHandleReceiveTextMessageL( TPtrC8 aFrom, TPtrC8 aContent ); |
|
217 |
|
218 /** |
|
219 * Resolves username to be used. |
|
220 * |
|
221 * @since S60 v5.1 |
|
222 * @param aServiceId Service identifier. |
|
223 * @param aUserName On return contains resolved user name. |
|
224 */ |
|
225 void ResolveUsernameL( TUint aServiceId, RBuf& aUserName ) const; |
|
226 |
|
227 /** |
|
228 * Creates IM cache updater if not yet created. |
|
229 * |
|
230 * @since S60 v5.1 |
|
231 */ |
|
232 void CreateImCacheUpdaterIfNeededL(); |
|
233 |
|
234 private: // Data |
|
235 |
|
236 /** |
|
237 * XIMP Plugin connection observer. |
|
238 * Not own. |
|
239 */ |
|
240 MPresencePluginConnectionObs* iConnectionObs; |
|
241 |
|
242 /** |
|
243 * SIMPLE engine connection. |
|
244 * Not Own. |
|
245 */ |
|
246 MSimpleConnection* iConnection; |
|
247 |
|
248 /** |
|
249 * Instant message handler instance. |
|
250 * Own. |
|
251 */ |
|
252 MSimpleInstantMessage* iImHandler; |
|
253 |
|
254 /** |
|
255 * Request identifier. |
|
256 */ |
|
257 TXIMPRequestId iXimpId; |
|
258 |
|
259 /** |
|
260 * Current request status; completed or not. |
|
261 */ |
|
262 TBool iCompleted; |
|
263 |
|
264 /** |
|
265 * Protocol IM data host. |
|
266 * Not own. |
|
267 */ |
|
268 MProtocolImDataHost* iHost; |
|
269 |
|
270 /** |
|
271 * IM cache factory. |
|
272 * Own. |
|
273 */ |
|
274 CIMCacheFactory* iImCacheFactory; |
|
275 |
|
276 /** |
|
277 * IM cache updater. |
|
278 * Owned by factory. |
|
279 */ |
|
280 MIMCacheUpdater* iImCacheUpdater; |
|
281 |
|
282 /** |
|
283 * ServiceId of current |
|
284 * service |
|
285 */ |
|
286 TUint iServiceId; |
|
287 |
|
288 }; |
|
289 |
|
290 #endif // C_CSIMPLEIMCONVERSATION_H |
|