|
1 /* |
|
2 * Copyright (c) 2006 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: Harvester Server Session |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMPXHARVESTERSESSION_H |
|
20 #define CMPXHARVESTERSESSION_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32cons.h> |
|
24 #include <f32file.h> |
|
25 #include <s32mem.h> |
|
26 |
|
27 #include "mpxharvesterengineobserver.h" |
|
28 #include "mpxhvsmsg.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CMPXHarvesterServer; |
|
32 class CMPXHarvesterEngine; |
|
33 class CMPXMedia; |
|
34 |
|
35 /** |
|
36 * Harvester server session |
|
37 */ |
|
38 NONSHARABLE_CLASS( CMPXHarvesterSession ) : public CSession2, |
|
39 public MMPXHarvesterEngineObserver |
|
40 { |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Two-phased constructor. Leaves on failure. |
|
45 * |
|
46 * @param aServer server object |
|
47 * @param aEngine engine object |
|
48 * @return The constructed object |
|
49 */ |
|
50 static CMPXHarvesterSession* NewL(CMPXHarvesterServer& aServer, |
|
51 CMPXHarvesterEngine& aEngine); |
|
52 |
|
53 /** |
|
54 * C++ constructor |
|
55 * |
|
56 * @param aServer server object |
|
57 * @param aEngine engine object |
|
58 */ |
|
59 CMPXHarvesterSession(CMPXHarvesterServer& aServer, |
|
60 CMPXHarvesterEngine& aEngine); |
|
61 |
|
62 /** |
|
63 * Destructor |
|
64 */ |
|
65 ~CMPXHarvesterSession(); |
|
66 |
|
67 private: // From base classes |
|
68 |
|
69 /** |
|
70 * From CSession2 |
|
71 * Service request |
|
72 * @param aMessage message object |
|
73 */ |
|
74 void ServiceL(const RMessage2& aMessage); |
|
75 |
|
76 /** |
|
77 * From MMPXHarvesterEngineObserver |
|
78 * Handles the completion of an import event |
|
79 */ |
|
80 void HandleImportCompleteL( CMPXMedia* aMedia, TInt aErr, |
|
81 RHvsMsg* aMsg ); |
|
82 |
|
83 /** |
|
84 * From MMPXHarvesterEngineObserver |
|
85 * Handles the completion of an import event |
|
86 */ |
|
87 void HandleExportCompleteL( CMPXMedia* aMedia, TInt aErr, |
|
88 RHvsMsg* aMsg ); |
|
89 |
|
90 /** |
|
91 * From MMPXHarvesterEngineObserver |
|
92 * Handles the completion of an async msg with error |
|
93 */ |
|
94 void CompleteTask( RHvsMsg* aMsg, TInt aErr ); |
|
95 |
|
96 private: |
|
97 /** |
|
98 * Dispatch message |
|
99 * |
|
100 * @param aMessage message object |
|
101 */ |
|
102 void DispatchMessageL(const RMessage2& aMessage); |
|
103 |
|
104 /** |
|
105 * Scan the FS for files |
|
106 */ |
|
107 void DoScanL(); |
|
108 |
|
109 /** |
|
110 * Cancel the scan (if executing) |
|
111 */ |
|
112 void DoCancelScan(); |
|
113 |
|
114 /** |
|
115 * Shutdown the harvester (for testing memory leaks) |
|
116 * Testing ONLY |
|
117 */ |
|
118 void DoShutdown(); |
|
119 |
|
120 /** |
|
121 * Handles addition of a file (iDes) to the harvester |
|
122 * @param aMsg message containing the item to add |
|
123 */ |
|
124 void DoAddFileL( RHvsMsg* aMsg ); |
|
125 |
|
126 /** |
|
127 * Decode the IPC message to add a media |
|
128 * @param aMessage, message to decode |
|
129 * @return, collection ID of the media |
|
130 */ |
|
131 TInt DoAddMediaPropL( const RMessage2& aMessage ); |
|
132 |
|
133 /** |
|
134 * Handles media creation for a file |
|
135 * @param aMsg message containing the item |
|
136 */ |
|
137 void DoGetMediaL( RHvsMsg* aMsg ); |
|
138 |
|
139 /** |
|
140 * Decode the IPC message to get a collection id |
|
141 * @param aMessage, message to decode |
|
142 * @return, collection ID of the file |
|
143 */ |
|
144 TInt DoGetColUidL( const RMessage2& aMessage ); |
|
145 |
|
146 /** |
|
147 * Removes multiple songs from the harvester db |
|
148 * @param aMessage message to decode |
|
149 */ |
|
150 void DoRemoveMultipleFilesL( const RMessage2& aMessage ); |
|
151 |
|
152 /** |
|
153 * Update a file according to new information |
|
154 * @param aMessage message to decode |
|
155 */ |
|
156 void DoUpdateFileL( const RMessage2& aMessage ); |
|
157 |
|
158 /** |
|
159 * Rename a file according to new information |
|
160 * @param aMessage message to decode |
|
161 */ |
|
162 void DoRenameFileL( const RMessage2& aMessage ); |
|
163 |
|
164 /** |
|
165 * Set the message as async and add it to the message list |
|
166 * @param aMessage message to decode |
|
167 * @param aOp operation id |
|
168 */ |
|
169 RHvsMsg* SetAsyncL( const RMessage2& aMessage, TMPXHarvesterServerOp aOp ); |
|
170 |
|
171 /** |
|
172 * Complete and remove an RHvsMsg |
|
173 * @param aMessage message to decode |
|
174 * @param aErr error code to complete operation |
|
175 */ |
|
176 void CompleteMessage( RHvsMsg*& aMessage, TInt aErr ); |
|
177 |
|
178 /* |
|
179 * Helper methods for transferring variable sized arrays and objects |
|
180 */ |
|
181 |
|
182 /** |
|
183 * Reads a descriptor from the message, allocated into iDes |
|
184 * |
|
185 * @param aMessage message object |
|
186 * @param aMsgSlot message slot |
|
187 * @return the result descriptor |
|
188 */ |
|
189 const TDesC& ReadDesL(const RMessage2& aMessage,TInt aMsgSlot); |
|
190 |
|
191 private: |
|
192 |
|
193 /** |
|
194 * 2nd phase constructor |
|
195 */ |
|
196 void ConstructL(); |
|
197 |
|
198 private: |
|
199 |
|
200 CMPXHarvesterServer& iServer; // not owned |
|
201 CMPXHarvesterEngine& iEngine; // not owned |
|
202 |
|
203 HBufC* iDes; |
|
204 HBufC8* iDes8; |
|
205 CBufBase* iBuffer; |
|
206 |
|
207 RPointerArray<RHvsMsg> iMessages; |
|
208 CMPXMedia* iMedia; |
|
209 }; |
|
210 |
|
211 #endif // CMPXHARVESTERSESSION_H |
|
212 |