|
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: Functional implentation of message management service. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CHTIMESSAGESSERVICEPLUGINHANDLER_H |
|
20 #define CHTIMESSAGESSERVICEPLUGINHANDLER_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <msvapi.h> |
|
25 #include <HtiServicePluginInterface.h> |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CClientMtmRegistry; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 /** |
|
34 * Functional implentation of message management service. |
|
35 */ |
|
36 class CMessageMgmntHandler : public CBase, |
|
37 public MMsvSessionObserver |
|
38 { |
|
39 public: |
|
40 |
|
41 static CMessageMgmntHandler* NewL(); |
|
42 |
|
43 // Interface implementation |
|
44 void ProcessMessageL( const TDesC8& aMessage, |
|
45 THtiMessagePriority aPriority ); |
|
46 |
|
47 virtual ~CMessageMgmntHandler(); |
|
48 |
|
49 void SetDispatcher( MHtiDispatcher* aDispatcher ); |
|
50 |
|
51 enum TFolder |
|
52 { |
|
53 EAllFolders = 0x00, |
|
54 EInbox, |
|
55 EDrafts, |
|
56 ESent, |
|
57 EOutbox, |
|
58 ENumberOfFolders, // this must always be the last one |
|
59 }; |
|
60 |
|
61 enum TMessageType |
|
62 { |
|
63 EAllMessageTypes = 0x00, |
|
64 ESMS, |
|
65 EMMS, |
|
66 ESmartMessage, |
|
67 EEmail, |
|
68 EIrMessage, |
|
69 EBtMessage, |
|
70 EAudioMessage, |
|
71 EEmailPOP3, |
|
72 EEmailIMAP4, |
|
73 ENumberOfMessageTypes, // this must always be the last one |
|
74 }; |
|
75 |
|
76 private: |
|
77 |
|
78 CMessageMgmntHandler(); |
|
79 void ConstructL(); |
|
80 |
|
81 private: // helpers |
|
82 |
|
83 void HandleCreateSmsL( const TDesC8& aData ); |
|
84 void HandleCreateMmsL( const TDesC8& aData ); |
|
85 void HandleCreateEmailL( const TDesC8& aData ); |
|
86 void HandleCreateObexMsgL( const TDesC8& aData, TUid aMtmUid, TUid aMsgTypeUid ); |
|
87 void HandleCreateSmartMsgL( const TDesC8& aData ); |
|
88 |
|
89 void HandleDeleteMessageL( const TDesC8& aData ); |
|
90 void HandleDeleteMessagesL( const TDesC8& aData ); |
|
91 void HandleDeleteFromAllFoldersL( TMessageType aType ); |
|
92 void HandleDeleteAllMessageTypesL( TFolder aFolder ); |
|
93 void HandleDeleteFromFolderByTypeL( TFolder aFolder, TMessageType aType ); |
|
94 |
|
95 void SendOkMsgL( const TDesC8& aData ); |
|
96 void SendErrorMessageL( TInt aError, const TDesC8& aDescription ); |
|
97 |
|
98 TBool ValidateAddSmsCommand( const TDesC8& aData ); |
|
99 TBool ValidateAddMmsOrAddEmailCommand( const TDesC8& aData ); |
|
100 TBool ValidateAddObexMsgCommand( const TDesC8& aData ); |
|
101 TBool ValidateAddSmartMsgCommand( const TDesC8& aData ); |
|
102 |
|
103 HBufC16* ExtractDesLC( const TDesC8& aUtf8Data, TInt& aPosition, TInt aSizeBytes ); |
|
104 HBufC8* ExtractDes8LC( const TDesC8& aUtf8Data, TInt& aPosition, TInt aSizeBytes ); |
|
105 TMsvId MapFolderToIdL( TFolder aFolder ); |
|
106 TUid MapMessageTypeToUidL( TMessageType aType ); |
|
107 |
|
108 private: // from MMsvSessionObserver |
|
109 |
|
110 void HandleSessionEventL( TMsvSessionEvent aEvent, |
|
111 TAny* aArg1, |
|
112 TAny* aArg2, |
|
113 TAny* aArg3 ); |
|
114 |
|
115 private: |
|
116 |
|
117 MHtiDispatcher* iDispatcher; // referenced |
|
118 CMsvSession* iSession; |
|
119 CClientMtmRegistry* iMtmReg; |
|
120 }; |
|
121 |
|
122 |
|
123 |
|
124 // CLASS DECLARATION |
|
125 /** |
|
126 * Helper class to wait the async requests. |
|
127 */ |
|
128 class CWaiter : public CActive |
|
129 { |
|
130 public: |
|
131 static CWaiter* NewL( TInt aPriority = EPriorityStandard ); |
|
132 static CWaiter* NewLC( TInt aPriority = EPriorityStandard ); |
|
133 ~CWaiter(); |
|
134 |
|
135 void StartAndWait(); |
|
136 TInt Result() const; |
|
137 |
|
138 private: |
|
139 CWaiter( TInt aPriority ); |
|
140 |
|
141 // from CActive |
|
142 void RunL(); |
|
143 void DoCancel(); |
|
144 |
|
145 private: |
|
146 CActiveSchedulerWait iWait; |
|
147 TInt iResult; |
|
148 }; |
|
149 |
|
150 #endif // CHTIMESSAGESSERVICEPLUGINHANDLER_H |