|
1 /* |
|
2 * Copyright (c) 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 "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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMMSPLATFORMSERVICES60IMPL_H |
|
20 #define CMMSPLATFORMSERVICES60IMPL_H |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <msvids.h> |
|
24 #include <mtclreg.h> |
|
25 #include <mmsclient.h> |
|
26 #include <mmsapplicationadapter.h> |
|
27 |
|
28 #include "monitor.h" |
|
29 #include "functionserver.h" |
|
30 #include "cmmsmessageinformation.h" |
|
31 #include "cjavammsmessagehandler.h" |
|
32 #include "mmsplatformservice.h" |
|
33 |
|
34 using namespace java::push; |
|
35 using namespace java::util; |
|
36 _LIT8(KSlash, "/"); |
|
37 |
|
38 const TInt KArrayGranularity = 2; |
|
39 const TInt KSlashLength = 1; |
|
40 |
|
41 // CLASS DECLARATION |
|
42 /** |
|
43 * to create and send the MMS messages |
|
44 * |
|
45 * |
|
46 * |
|
47 */ |
|
48 namespace java |
|
49 { |
|
50 namespace wma |
|
51 { |
|
52 |
|
53 class CMMSPlatformServiceS60Impl: public CActive, |
|
54 public MMSPlatformService, |
|
55 public FunctionServer, |
|
56 public MMsvSessionObserver, |
|
57 public MMsvEntryObserver |
|
58 { |
|
59 public: |
|
60 |
|
61 /** |
|
62 * Destructor. |
|
63 */ |
|
64 virtual ~CMMSPlatformServiceS60Impl(); |
|
65 |
|
66 static CMMSPlatformServiceS60Impl* New(JNIEnv& aJni, jobject aPeer, |
|
67 const bool aServerConnection, |
|
68 const std::wstring& aUri, |
|
69 ConnectionListener* aListener); |
|
70 /** |
|
71 * Sends a multimedia message to its recipients. |
|
72 * @param aJni JNI environment |
|
73 * @param jbyteArray message byte array |
|
74 * @param aOffset |
|
75 * @param aLength message length |
|
76 * @param aDestination destination address |
|
77 * @return int status of the send functionality. |
|
78 */ |
|
79 int send(JNIEnv& aJni, jbyteArray aJavaBuffer, int aOffset, int aLength, |
|
80 jstring aDestination); |
|
81 |
|
82 /** |
|
83 * Retrieves the first message from the queue. |
|
84 * @param aJni JNI environment |
|
85 * @return A byte array containing the first multimedia message received |
|
86 */ |
|
87 jbyteArray retrieveMessage(JNIEnv& aJni); |
|
88 /** |
|
89 * closes the connection |
|
90 */ |
|
91 void closeConnection(JNIEnv& aJni, jobject aPeer); |
|
92 |
|
93 int getNumberOfMessages(); |
|
94 |
|
95 int getError(); |
|
96 |
|
97 private: |
|
98 /** |
|
99 * C++ default constructor. |
|
100 * @param aServerConnection for handling server connection |
|
101 * @param aServerApplicationId to register for incoming messages |
|
102 * @return |
|
103 */ |
|
104 CMMSPlatformServiceS60Impl(const bool aServerConnection, |
|
105 HBufC* aServerApplicationId, ConnectionListener* aListener); |
|
106 // From FunctionServer |
|
107 virtual void vmAttached(); |
|
108 |
|
109 //From FunctionServer |
|
110 virtual void doServerSideInit(); |
|
111 /** |
|
112 * Notifies java side send about the status of sending mms message |
|
113 * @param aJni - Jni interface pointer |
|
114 * @param aPeer - Jni object reference |
|
115 * @param aError - status of send functionality |
|
116 */ |
|
117 void NotifySend(JNIEnv& aJni, jobject aPeer, int aError); |
|
118 /** |
|
119 * Send the Message |
|
120 * @param aMidMessageInformation contain the message information and |
|
121 * attachments |
|
122 * @return |
|
123 */ |
|
124 |
|
125 void SendMultiPartMessageL(); |
|
126 |
|
127 /** |
|
128 * From MMsvSessionObserver |
|
129 * @param aEvent: Event type |
|
130 * @param aArg1: contain different values for different aEvent |
|
131 * @param aArg2: contain different values for different aEvent |
|
132 * @param aArg3: contain different values for different aEvent |
|
133 * @return |
|
134 */ |
|
135 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, |
|
136 TAny* aArg3); |
|
137 |
|
138 /** |
|
139 * Clears the message send array. If there is some message that is not |
|
140 * send yet.Delete it and do not send the messages. |
|
141 * |
|
142 * @return |
|
143 */ |
|
144 void ClearSendMessageArray(); |
|
145 /** |
|
146 * ReceivedMessage |
|
147 * get the received message |
|
148 * |
|
149 * @param aMessageId: Received message Id |
|
150 * |
|
151 * @return CMidMessageInformation: received message |
|
152 */ |
|
153 CMMSMessageInformation* ReceivedMessage(TMsvId aMessageId); |
|
154 |
|
155 /** |
|
156 * NotifyReceivedMessageL |
|
157 * Get the URL check for the register folder. If already register |
|
158 * then check for the messages in the register folder. If there are messages |
|
159 * in the folder then send notification to the connection for the messages. |
|
160 * |
|
161 * |
|
162 * @return |
|
163 */ |
|
164 |
|
165 void NotifyReceivedMessageL(); |
|
166 |
|
167 /** |
|
168 * HandleEntryEventL |
|
169 * From MMsvEntryObserver |
|
170 * |
|
171 * @param aEvent: TMsv entry event |
|
172 * @param aArg1: |
|
173 * @param aArg2: |
|
174 * @param aArg3: |
|
175 * |
|
176 * @return |
|
177 */ |
|
178 void HandleEntryEventL(TMsvEntryEvent aEvent, TAny* aArg1, TAny* aArg2, |
|
179 TAny* aArg3); |
|
180 |
|
181 /** |
|
182 * ScanRegisterFolderAndNotifyL |
|
183 * Scan the register folder and Notify the listener. |
|
184 * |
|
185 * |
|
186 * @return |
|
187 */ |
|
188 void ScanRegisterFolderAndNotifyL(); |
|
189 |
|
190 /** |
|
191 * create MMS messsage in draft folder. |
|
192 * |
|
193 * |
|
194 * @return TMsvId: Id of the newly created message. |
|
195 */ |
|
196 TMsvId CreateMessageL(); |
|
197 |
|
198 /** |
|
199 * Load the message by TMsvId |
|
200 * |
|
201 * @param aMessageEntry: |
|
202 * |
|
203 * @return |
|
204 */ |
|
205 void LoadMessageL(TMsvId aMessageEntry); |
|
206 |
|
207 /** |
|
208 * Set the subject of newly created MMS message. |
|
209 * |
|
210 * @param aSubject: |
|
211 * |
|
212 * @return |
|
213 */ |
|
214 void SetSubjectL(const TDesC& aSubject); |
|
215 |
|
216 /** |
|
217 * add receipient addresses by type to the newly created message. |
|
218 * |
|
219 * @param aAddress: |
|
220 * @param aAddressType: |
|
221 * |
|
222 * @return |
|
223 */ |
|
224 void AddRecipientL(const TDesC& aAddress, TMmsRecipients aAddressType); |
|
225 |
|
226 /** |
|
227 * add attachment by name to the newly created MMS message. |
|
228 * |
|
229 * @param aFileName: |
|
230 * @param aMimeType: |
|
231 * |
|
232 * @return |
|
233 */ |
|
234 void AddAttchmentL(TDesC& aFileName, TDesC8& aMimeType); |
|
235 |
|
236 /** |
|
237 * Set application-id in the newly created message. |
|
238 * |
|
239 * @param aApplicationId: |
|
240 * |
|
241 * @return |
|
242 */ |
|
243 void SetApplicationIdL(const TDesC& aApplicationId); |
|
244 |
|
245 /** |
|
246 * Set reply-to -application-id in the newly created message. |
|
247 * |
|
248 * @param aReplyToApplicationId: |
|
249 * |
|
250 * @return |
|
251 */ |
|
252 void SetReplyToApplicationIdL(const TDesC& aReplyToApplicationId); |
|
253 |
|
254 /** |
|
255 * Set the date of the newly created message. |
|
256 * |
|
257 * @param aLong: |
|
258 * |
|
259 * @return |
|
260 */ |
|
261 void SetMessageSendDate(TInt64& aLong); |
|
262 |
|
263 /** |
|
264 * Set the setting of the newly created message. |
|
265 * |
|
266 * |
|
267 * @return |
|
268 */ |
|
269 void SetMessageSettingL(); |
|
270 |
|
271 /** |
|
272 * create and send the MMS messge from CMidMessageInformation |
|
273 * |
|
274 * @param aMidMessageInformation: |
|
275 * |
|
276 * @return |
|
277 */ |
|
278 // send MMS message from send array |
|
279 void SendMmsMessageL(CMMSMessageInformation* aMessageInformation); |
|
280 |
|
281 /** |
|
282 * Read the message Setting of received message. |
|
283 * |
|
284 * |
|
285 * @return |
|
286 */ |
|
287 void ReadSettingL(); |
|
288 |
|
289 /** |
|
290 * Delete the message by TMsvId |
|
291 * |
|
292 * @param aMsvId: |
|
293 * |
|
294 * @return |
|
295 */ |
|
296 void DeleteMmsMessageL(TMsvId aMsvId); |
|
297 |
|
298 /** |
|
299 * Read the newly received message. Client connection should not call |
|
300 * this method.It will panic if invoked on client connection |
|
301 * |
|
302 * @param aMsvId: |
|
303 * |
|
304 * @return |
|
305 */ |
|
306 void ReceiveMessageL(TMsvId aMsvId); |
|
307 |
|
308 /** |
|
309 * Send the message from by TMsvId |
|
310 * |
|
311 * @param aSendMmsMsgId: |
|
312 * |
|
313 * @return |
|
314 */ |
|
315 void SendMmsMessageL(TMsvId aSendMmsMsgId); |
|
316 |
|
317 /** |
|
318 * close the connection |
|
319 * |
|
320 * |
|
321 * @return |
|
322 */ |
|
323 void Close(); |
|
324 /** |
|
325 * add attachment to newly created entry in the message store. |
|
326 * |
|
327 * @param aMidMessageInformation: |
|
328 * |
|
329 * @return |
|
330 */ |
|
331 void AddAttachmentsL(CMMSMessageInformation* aMessageInformation); |
|
332 |
|
333 /** |
|
334 * During construction of this method create the send message array. |
|
335 * |
|
336 * |
|
337 * @return |
|
338 */ |
|
339 void CreateSendMessageArrayL(); |
|
340 |
|
341 /** |
|
342 * Clear and Destroy the message send array. If there is some message |
|
343 * that is not send yet. Delete it and do not send the messages. |
|
344 * |
|
345 * |
|
346 * @return |
|
347 */ |
|
348 void ClearAndDestroySendMessageArray(); |
|
349 |
|
350 /** |
|
351 * Delete the message of given Id. |
|
352 * |
|
353 * @param aMsvId: Id of the messagethat should be deleted. |
|
354 * |
|
355 * @return |
|
356 */ |
|
357 void DeleteSentMessageL(TMsvId aMsvId); |
|
358 |
|
359 /** |
|
360 * Received the message one by one. |
|
361 * |
|
362 * @param aMsvId: Id of the message that is received in the device. |
|
363 * |
|
364 * @return |
|
365 */ |
|
366 void DoReceiveMessageL(TMsvId aMsvId); |
|
367 |
|
368 /** |
|
369 * ReadAttachmentsL |
|
370 * Read the attachmnets and add it to aMidMessageInformation |
|
371 * |
|
372 * @param aMidMessageInformation: |
|
373 * |
|
374 * @return |
|
375 */ |
|
376 void ReadAttachmentsL(CMMSMessageInformation& aMessageInformation); |
|
377 |
|
378 /** |
|
379 * Read data from the attached files |
|
380 * |
|
381 * @param aRFile: Handle of the file to read the data from |
|
382 * @param aDataArray: Copy the data to the dataArray |
|
383 * |
|
384 * @return |
|
385 */ |
|
386 void ReadDataFromAttachFileL(RFile& aRFile, TDesC8*& aDataArray); |
|
387 /** |
|
388 * Sends notifications towards java about the number of messages arrived. |
|
389 * |
|
390 * @param aDescription |
|
391 * @param messages |
|
392 */ |
|
393 void NotifyJava(const TDesC& aDescription, int aMessages); |
|
394 |
|
395 protected: |
|
396 |
|
397 /** |
|
398 * default Symbian 2nd phase constructor |
|
399 * @return |
|
400 */ |
|
401 void ConstructL(); |
|
402 void mmsRequestComplete(int result); |
|
403 /** |
|
404 * from CActive |
|
405 * |
|
406 * |
|
407 * @return |
|
408 */ |
|
409 void RunL(); |
|
410 |
|
411 /** |
|
412 * from CActive |
|
413 * |
|
414 * |
|
415 * @return |
|
416 */ |
|
417 void DoCancel(); |
|
418 |
|
419 /** |
|
420 * from CActive |
|
421 * |
|
422 * @param aError: error value |
|
423 * |
|
424 * @return TInt |
|
425 */ |
|
426 TInt RunError(TInt aError); |
|
427 |
|
428 private: |
|
429 // flag used to indicate that 'send' operation is ongoing |
|
430 bool mIsSending; |
|
431 |
|
432 //flag used to indicate Client/Server connection |
|
433 bool mServerConnection; |
|
434 |
|
435 int mError; |
|
436 //number of new messages |
|
437 int mNewMessages; |
|
438 |
|
439 // handle to the file system |
|
440 RFs mRFs; |
|
441 |
|
442 RArray<TMsvId> mSendTMsvIdArray; |
|
443 |
|
444 // array containing the IDs of the received MMS messages |
|
445 RArray<TMsvId> mReceivedMMSIDs; |
|
446 |
|
447 //message sent callback method id |
|
448 jmethodID mSendCallBackMethodId; |
|
449 |
|
450 // The delivery date |
|
451 TTime mMessageDeliveryDate; |
|
452 |
|
453 TMmsMessagePriority mMmsMessagePriority; |
|
454 |
|
455 //Own the mServerApplicationId |
|
456 HBufC* mServerApplicationId; |
|
457 |
|
458 // buffer to be used when sending |
|
459 CBufFlat* mSendBuf; |
|
460 |
|
461 //Own the mSession |
|
462 CMsvSession* mSession; |
|
463 |
|
464 //Own the mMmsClient |
|
465 CMmsClientMtm* mMmsClient; |
|
466 |
|
467 //Own the mServerMmsMtm |
|
468 CMmsClientMtm* mServerMmsMtm; |
|
469 |
|
470 CMsvEntry* mRegisterCMsvEntry; |
|
471 |
|
472 //listener to be notified for an incoming message |
|
473 ConnectionListener* mMessageListener; |
|
474 |
|
475 //Own the ClientMtmRegistry |
|
476 CClientMtmRegistry* mClientMtmRegistry; |
|
477 |
|
478 CJavaMMSMessageHandler* mMessageHandler; |
|
479 |
|
480 //Own the mMmsApplicationAdapter |
|
481 CMmsApplicationAdapter* mMmsApplicationAdapter; |
|
482 |
|
483 //Own the mSendMsgArray |
|
484 CArrayPtrSeg<CMMSMessageInformation>* mSendMsgArray; |
|
485 |
|
486 // Own the mReceivedMsgArray |
|
487 CArrayPtrSeg<CMMSMessageInformation>* mReceivedMsgArray; |
|
488 |
|
489 }; |
|
490 |
|
491 inline int CMMSPlatformServiceS60Impl::getError() |
|
492 { |
|
493 return mError; |
|
494 } |
|
495 /////////////////////////////////////////////////////////// |
|
496 } //namespace wma |
|
497 } //namespace java |
|
498 #endif // CMMSPLATFORMSERVICES60IMPL_H |
|
499 // End of File |