|
1 /* |
|
2 * Copyright (c) 2002-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: Implementation for Client side API |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <s32mem.h> |
|
22 #include <e32cmn.h> |
|
23 #include <AiwGenericParam.h> |
|
24 |
|
25 #include "NewFileServiceClient.h" |
|
26 #include "RNewFileServiceClient.h" |
|
27 #include "CNewFileServiceClientImpl.h" |
|
28 |
|
29 #include <VoiceRecorderUID.h> |
|
30 #include <CcorUiConstants.h> |
|
31 #include <avkon.hrh> |
|
32 |
|
33 |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
|
35 |
|
36 // ---------------------------------------------------------------------------- |
|
37 // NewFileServiceFactory::NewClientL |
|
38 // |
|
39 // ---------------------------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C CNewFileServiceClient* NewFileServiceFactory::NewClientL() |
|
42 { |
|
43 return CNewFileServiceClientImpl::NewL(); |
|
44 } |
|
45 |
|
46 |
|
47 // ---------------------------------------------------------------------------- |
|
48 // CNewFileServiceClientImpl::NewL |
|
49 // |
|
50 // ---------------------------------------------------------------------------- |
|
51 // |
|
52 CNewFileServiceClientImpl* CNewFileServiceClientImpl::NewL() |
|
53 { |
|
54 CNewFileServiceClientImpl* self = |
|
55 new( ELeave )CNewFileServiceClientImpl; |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop(); |
|
59 return self; |
|
60 } |
|
61 |
|
62 |
|
63 // ---------------------------------------------------------------------------- |
|
64 // CNewFileServiceClientImpl::~CNewFileServiceClientImpl |
|
65 // |
|
66 // ---------------------------------------------------------------------------- |
|
67 // |
|
68 CNewFileServiceClientImpl::~CNewFileServiceClientImpl() |
|
69 { |
|
70 delete iServerAppMonitor; |
|
71 iClient.Close(); |
|
72 if(iClient.iError == KErrAbort) |
|
73 { |
|
74 iClient.iError = 0; |
|
75 MAknServerAppExitObserver::HandleServerAppExit(EAknCmdExit); |
|
76 } |
|
77 } |
|
78 |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // CNewFileServiceClientImpl::ConstructL |
|
82 // |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 void CNewFileServiceClientImpl::ConstructL() |
|
86 { |
|
87 iClient.SetFileServiceClient(this); |
|
88 } |
|
89 |
|
90 |
|
91 // ---------------------------------------------------------------------------- |
|
92 // CNewFileServiceClientImpl::NewFileL |
|
93 // |
|
94 // ---------------------------------------------------------------------------- |
|
95 // |
|
96 TBool CNewFileServiceClientImpl::NewFileL( CDesCArray& aFileNames, |
|
97 CAiwGenericParamList* aParams, |
|
98 TNewServiceFileType aFileType, |
|
99 TBool aMultipleFiles ) |
|
100 { |
|
101 TUid uid( KNullUid ); |
|
102 |
|
103 switch ( aFileType ) |
|
104 { |
|
105 case ENewFileServiceAudio: |
|
106 { |
|
107 uid = TUid::Uid( KVoiceRecorderAppUID3 ); |
|
108 break; |
|
109 } |
|
110 |
|
111 case ENewFileServiceVideo: |
|
112 case ENewFileServiceImage: |
|
113 { |
|
114 uid = KUidCamcorder; |
|
115 break; |
|
116 } |
|
117 default: |
|
118 { |
|
119 User::Leave( KErrNotSupported ); |
|
120 } |
|
121 }; |
|
122 |
|
123 return NewFileL( uid, aFileNames, aParams, aFileType, aMultipleFiles ); |
|
124 } |
|
125 |
|
126 |
|
127 // ---------------------------------------------------------------------------- |
|
128 // CNewFileServiceClientImpl::HandleServerAppExit |
|
129 // |
|
130 // ---------------------------------------------------------------------------- |
|
131 // |
|
132 void CNewFileServiceClientImpl::HandleServerAppExit(TInt aReason) |
|
133 { |
|
134 #ifdef _DEBUG |
|
135 RDebug::Print( _L("CNewFileServiceClientImpl::HandleServerAppExit") ); |
|
136 #endif |
|
137 iClient.Close(); |
|
138 MAknServerAppExitObserver::HandleServerAppExit(aReason); |
|
139 } |
|
140 |
|
141 |
|
142 // ---------------------------------------------------------------------------- |
|
143 // CNewFileServiceClientImpl::NewFileL |
|
144 // |
|
145 // ---------------------------------------------------------------------------- |
|
146 // |
|
147 TBool CNewFileServiceClientImpl::NewFileL( TUid aApplicationUid, |
|
148 CDesCArray& aFileNames, |
|
149 CAiwGenericParamList* aParams, |
|
150 TNewServiceFileType aFileType, |
|
151 TBool aMultipleFiles ) |
|
152 { |
|
153 iClient.ConnectChainedAppL( aApplicationUid ); |
|
154 |
|
155 if ( !iServerAppMonitor ) |
|
156 { |
|
157 iServerAppMonitor = CApaServerAppExitMonitor::NewL( iClient, *this, |
|
158 CActive::EPriorityStandard ); |
|
159 } |
|
160 |
|
161 HBufC8* serializedParams = SerializeGenericParamListLC( aParams ); |
|
162 TBool ret = iClient.NewFileL( aFileNames, serializedParams, |
|
163 aFileType, aMultipleFiles ); |
|
164 CleanupStack::PopAndDestroy(); // serializedParams |
|
165 return ret; |
|
166 } |
|
167 |
|
168 |
|
169 // ---------------------------------------------------------------------------- |
|
170 // CNewFileServiceClientImpl::NewFileL |
|
171 // |
|
172 // ---------------------------------------------------------------------------- |
|
173 // |
|
174 TBool CNewFileServiceClientImpl::NewFileL( RFile& aFileHandle, |
|
175 CAiwGenericParamList* aParams, |
|
176 TNewServiceFileType aFileType ) |
|
177 { |
|
178 TUid uid( KNullUid ); |
|
179 |
|
180 switch ( aFileType ) |
|
181 { |
|
182 case ENewFileServiceAudio: |
|
183 { |
|
184 uid = TUid::Uid( KVoiceRecorderAppUID3 ); |
|
185 break; |
|
186 } |
|
187 |
|
188 case ENewFileServiceVideo: |
|
189 case ENewFileServiceImage: |
|
190 { |
|
191 uid = KUidCamcorder; |
|
192 break; |
|
193 } |
|
194 default: |
|
195 { |
|
196 User::Leave( KErrNotSupported ); |
|
197 } |
|
198 }; |
|
199 |
|
200 return NewFileL( uid, aFileHandle, aParams, aFileType ); |
|
201 } |
|
202 |
|
203 |
|
204 // ---------------------------------------------------------------------------- |
|
205 // CNewFileServiceClientImpl::NewFileL |
|
206 // |
|
207 // ---------------------------------------------------------------------------- |
|
208 // |
|
209 TBool CNewFileServiceClientImpl::NewFileL( TUid aApplicationUid, |
|
210 RFile& aFileHandle, |
|
211 CAiwGenericParamList* aParams, |
|
212 TNewServiceFileType aFileType ) |
|
213 { |
|
214 |
|
215 iClient.ConnectChainedAppL( aApplicationUid ); |
|
216 |
|
217 if ( !iServerAppMonitor ) |
|
218 { |
|
219 iServerAppMonitor = CApaServerAppExitMonitor::NewL( iClient, *this, |
|
220 CActive::EPriorityStandard ); |
|
221 } |
|
222 |
|
223 HBufC8* serializedParams = SerializeGenericParamListLC( aParams ); |
|
224 TBool ret = iClient.NewFileL( aFileHandle, serializedParams, aFileType ); |
|
225 |
|
226 CleanupStack::PopAndDestroy(); // serializedParams |
|
227 |
|
228 return ret; |
|
229 } |
|
230 |
|
231 |
|
232 // ---------------------------------------------------------------------------- |
|
233 // CNewFileServiceClientImpl::SerializeGenericParamListLC |
|
234 // |
|
235 // ---------------------------------------------------------------------------- |
|
236 // |
|
237 HBufC8* CNewFileServiceClientImpl::SerializeGenericParamListLC( |
|
238 CAiwGenericParamList* aParams ) |
|
239 { |
|
240 if ( !aParams ) |
|
241 { |
|
242 HBufC8* dummy = HBufC8::NewLC( 0 ); // return dummy |
|
243 return dummy; |
|
244 } |
|
245 |
|
246 TInt size( aParams->Size() ); |
|
247 HBufC8* serialized = HBufC8::NewLC( size ); |
|
248 TPtr8 ptr = serialized->Des(); |
|
249 RDesWriteStream stream( ptr ); |
|
250 aParams->ExternalizeL( stream ); |
|
251 stream.Close(); |
|
252 return serialized; |
|
253 } |
|
254 |
|
255 // End of File |