27
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2004 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 MMS indirect upload service.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
|
|
23 |
#include <CSendingServiceInfo.h>
|
|
24 |
#include <SendUiConsts.h>
|
|
25 |
#include <CMessageData.h>
|
|
26 |
#include <senduisingleton.h>
|
|
27 |
#include <MmsConst.h>
|
|
28 |
#include <bautils.h> // BaflUtils
|
|
29 |
#include <barsc.h> // RResourceFile
|
|
30 |
#include <f32file.h> // TParse
|
|
31 |
#include <TSendingCapabilities.h>
|
|
32 |
#include <SenduiMtmUids.h>
|
|
33 |
|
|
34 |
#include "CMmsIndirectUpload.h"
|
|
35 |
#include "SendUiOperationWait.h"
|
|
36 |
#include "SendUiFileRightsEngine.h"
|
|
37 |
#include "CSendUiAttachment.h"
|
|
38 |
|
|
39 |
#include <data_caging_path_literals.hrh>
|
|
40 |
|
|
41 |
// CONSTANTS
|
|
42 |
const TInt KMaxMmsUploadServiceCount = 4;
|
|
43 |
const TInt KMmsIndirectUploadService = 2;
|
|
44 |
const TInt KMaxServiceAddressLength = 512;
|
|
45 |
const TInt KMaxServiceNameLength = 128;
|
|
46 |
const TInt KMaxServiceMenuNameLength = 128;
|
|
47 |
|
|
48 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
49 |
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
// CMmsIndirectUpload::CMmsIndirectUpload
|
|
52 |
// C++ default constructor can NOT contain any code, that
|
|
53 |
// might leave.
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CMmsIndirectUpload::CMmsIndirectUpload( CCoeEnv& aCoeEnv, CSendUiSingleton& aSingleton )
|
|
57 |
: CSendingService( aCoeEnv, aSingleton )
|
|
58 |
{
|
|
59 |
}
|
|
60 |
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
// CMmsIndirectUpload::ConstructL
|
|
63 |
// Symbian 2nd phase constructor can leave.
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
void CMmsIndirectUpload::ConstructL()
|
|
67 |
{
|
|
68 |
ReadServiceDataL();
|
|
69 |
}
|
|
70 |
|
|
71 |
// -----------------------------------------------------------------------------
|
|
72 |
// CMmsIndirectUpload::NewL
|
|
73 |
// Two-phased constructor.
|
|
74 |
// -----------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
CMmsIndirectUpload* CMmsIndirectUpload::NewL( TSendingServiceParams* aParams )
|
|
77 |
{
|
|
78 |
CMmsIndirectUpload* self = new(ELeave) CMmsIndirectUpload( aParams->iCoeEnv, aParams->iSingleton );
|
|
79 |
|
|
80 |
CleanupStack::PushL(self);
|
|
81 |
self->ConstructL();
|
|
82 |
CleanupStack::Pop(self);
|
|
83 |
|
|
84 |
return self;
|
|
85 |
}
|
|
86 |
|
|
87 |
// Destructor
|
|
88 |
CMmsIndirectUpload::~CMmsIndirectUpload()
|
|
89 |
{
|
|
90 |
iServiceArray.ResetAndDestroy();
|
|
91 |
iServiceArray.Close();
|
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
// ---------------------------------------------------------
|
|
96 |
// CMmsIndirectUpload::ServiceProviderId
|
|
97 |
// Returns the id of the service provider.
|
|
98 |
// (other items were commented in a header).
|
|
99 |
// ---------------------------------------------------------
|
|
100 |
//
|
|
101 |
TUid CMmsIndirectUpload::ServiceProviderId() const
|
|
102 |
{
|
|
103 |
return KMmsIndirectUpload;
|
|
104 |
}
|
|
105 |
|
|
106 |
TUid CMmsIndirectUpload::TechnologyTypeId( ) const
|
|
107 |
{
|
|
108 |
return TUid::Uid( KSenduiTechnologyMmsUidValue );
|
|
109 |
}
|
|
110 |
|
|
111 |
// -----------------------------------------------------------------------------
|
|
112 |
// CMmsIndirectUpload::CreateAndSendMessageL
|
|
113 |
// Creates message to be sent and opens MMS editor.
|
|
114 |
// (other items were commented in a header).
|
|
115 |
// -----------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
void CMmsIndirectUpload::CreateAndSendMessageL(
|
|
118 |
TUid aServiceUid,
|
|
119 |
const CMessageData* aMessageData,
|
|
120 |
TBool /*aLaunchEditorEmbedded */)
|
|
121 |
{
|
|
122 |
TInt i = 0;
|
|
123 |
|
|
124 |
RSendAs sendAsSession;
|
|
125 |
User::LeaveIfError( sendAsSession.Connect() );
|
|
126 |
TInt cleanupItems(0);
|
|
127 |
CleanupClosePushL( sendAsSession );
|
|
128 |
cleanupItems++;
|
|
129 |
if ( !CheckMmsServiceAvailabilityL( sendAsSession ) )
|
|
130 |
{
|
|
131 |
CleanupStack::PopAndDestroy( &sendAsSession ); // sendAsSession
|
|
132 |
return;
|
|
133 |
}
|
|
134 |
|
|
135 |
RSendAsMessage sendAsMessage;
|
|
136 |
CleanupClosePushL( sendAsMessage );
|
|
137 |
cleanupItems++;
|
|
138 |
sendAsMessage.CreateL( sendAsSession, KSenduiMtmUniMessageUid );
|
|
139 |
// BIO type identifies MMS message as upload message.
|
|
140 |
sendAsMessage.SetBioTypeL( KUidMsgSubTypeMmsUpload );
|
|
141 |
|
|
142 |
// Set service address
|
|
143 |
for ( i=0; i < iServiceArray.Count(); i++)
|
|
144 |
{
|
|
145 |
if ( (*iServiceArray[i]).ServiceId() == aServiceUid)
|
|
146 |
{
|
|
147 |
TPtrC address = (*iServiceArray[i]).ServiceAddress();
|
|
148 |
|
|
149 |
if ( address != KNullDesC )
|
|
150 |
{
|
|
151 |
sendAsMessage.AddRecipientL(
|
|
152 |
address,
|
|
153 |
(*iServiceArray[i]).ServiceName(),
|
|
154 |
RSendAsMessage::ESendAsRecipientTo );
|
|
155 |
}
|
|
156 |
else
|
|
157 |
{
|
|
158 |
User::Leave( KErrNotFound );
|
|
159 |
}
|
|
160 |
break;
|
|
161 |
}
|
|
162 |
}
|
|
163 |
|
|
164 |
CArrayPtrFlat<CSendUiAttachment>* attachments(NULL);
|
|
165 |
|
|
166 |
// Get attachments
|
|
167 |
if ( aMessageData )
|
|
168 |
{
|
|
169 |
attachments = CSendUiAttachment::InitAttachmentArrayLCC(
|
|
170 |
aMessageData->AttachmentArray(),
|
|
171 |
aMessageData->AttachmentHandleArray(),
|
|
172 |
iCoeEnv.FsSession() );
|
|
173 |
cleanupItems += 2;
|
|
174 |
}
|
|
175 |
if ( aMessageData )
|
|
176 |
{
|
|
177 |
if ( !ValidateAttachmentsL( attachments ) )
|
|
178 |
{
|
|
179 |
// attachments, sendAsMessage, sendAsSession
|
|
180 |
CleanupStack::PopAndDestroy( cleanupItems, &sendAsSession );
|
|
181 |
return;
|
|
182 |
}
|
|
183 |
|
|
184 |
const CRichText* bodyText = aMessageData->BodyText();
|
|
185 |
if ( bodyText->DocumentLength() > 0 )
|
|
186 |
{
|
|
187 |
CSendUiAttachment* atta = CSendUiAttachment::NewLC( *bodyText, iCoeEnv.FsSession() );
|
|
188 |
attachments->AppendL( atta );
|
|
189 |
CleanupStack::Pop( atta );
|
|
190 |
}
|
|
191 |
|
|
192 |
for ( i = 0; i < attachments->Count(); i++ )
|
|
193 |
{
|
|
194 |
CSendUiOperationWait* waiter = CSendUiOperationWait::NewLC();
|
|
195 |
CSendUiAttachment& attachmentPacket = *(attachments->At(i));
|
|
196 |
|
|
197 |
if ( attachmentPacket.Type() == CSendUiAttachment::EAttachmentPath )
|
|
198 |
{
|
|
199 |
sendAsMessage.AddAttachment(
|
|
200 |
*(attachmentPacket.Path()),
|
|
201 |
attachmentPacket.MimeType(),
|
|
202 |
waiter->iStatus );
|
|
203 |
}
|
|
204 |
else
|
|
205 |
{
|
|
206 |
RFile attachment;
|
|
207 |
attachment.Duplicate( *(attachmentPacket.Handle()) );
|
|
208 |
sendAsMessage.AddAttachment(
|
|
209 |
attachment,
|
|
210 |
attachmentPacket.MimeType(),
|
|
211 |
waiter->iStatus );
|
|
212 |
}
|
|
213 |
|
|
214 |
waiter->Start( (CActive*)NULL );
|
|
215 |
CleanupStack::PopAndDestroy( waiter );
|
|
216 |
}
|
|
217 |
|
|
218 |
}
|
|
219 |
TInt attachmentCount( 0 );
|
|
220 |
if ( attachments )
|
|
221 |
{
|
|
222 |
attachmentCount = attachments->Count();
|
|
223 |
CleanupStack::PopAndDestroy( 2, attachments );
|
|
224 |
cleanupItems -= 2;
|
|
225 |
}
|
|
226 |
|
|
227 |
if ( attachmentCount > 0 )
|
|
228 |
{
|
|
229 |
sendAsMessage.LaunchEditorAndCloseL(); // sendAsMessage is closed
|
|
230 |
CleanupStack::Pop( &sendAsMessage );
|
|
231 |
}
|
|
232 |
else
|
|
233 |
{
|
|
234 |
CleanupStack::PopAndDestroy( &sendAsMessage); // sendAsMessage
|
|
235 |
}
|
|
236 |
cleanupItems--;
|
|
237 |
CleanupStack::PopAndDestroy( cleanupItems, &sendAsSession );
|
|
238 |
}
|
|
239 |
|
|
240 |
// -----------------------------------------------------------------------------
|
|
241 |
// CMmsIndirectUpload::ValidateAttachmentsL
|
|
242 |
// Validates attachments for sending. DRM protection and MMS validity are
|
|
243 |
// checked. DRM query and error note is shown if needed. Return value of
|
|
244 |
// attachment arrays contains valid attachments.
|
|
245 |
// (other items were commented in a header).
|
|
246 |
// -----------------------------------------------------------------------------
|
|
247 |
//
|
|
248 |
TBool CMmsIndirectUpload::ValidateAttachmentsL( CArrayPtrFlat<CSendUiAttachment>* aAttachments )
|
|
249 |
{
|
|
250 |
TBool continueSending( ETrue );
|
|
251 |
|
|
252 |
|
|
253 |
// Validate attachments and show query and error note if needed.
|
|
254 |
if ( aAttachments->Count() > 0 )
|
|
255 |
{
|
|
256 |
CSendUiFileRightsEngine* fileRightsEngine =
|
|
257 |
CSendUiFileRightsEngine::NewLC( iCoeEnv.FsSession() );
|
|
258 |
|
|
259 |
fileRightsEngine->ConfirmDrmFileRightsL( aAttachments );
|
|
260 |
fileRightsEngine->ConfirmMmsValidityL( aAttachments );
|
|
261 |
|
|
262 |
continueSending = fileRightsEngine->ShowDrmAndMmsInfoL( KMmsIndirectUpload );
|
|
263 |
|
|
264 |
CleanupStack::PopAndDestroy( fileRightsEngine );
|
|
265 |
}
|
|
266 |
return continueSending;
|
|
267 |
}
|
|
268 |
|
|
269 |
// -----------------------------------------------------------------------------
|
|
270 |
// CMmsIndirectUpload::PopulateServicesListL
|
|
271 |
// Populates given list with the services provided by this plugin.
|
|
272 |
// The ownership of the pointed objects remains.
|
|
273 |
// (other items were commented in a header).
|
|
274 |
// -----------------------------------------------------------------------------
|
|
275 |
//
|
|
276 |
void CMmsIndirectUpload::PopulateServicesListL(
|
|
277 |
RPointerArray<CSendingServiceInfo>& aList )
|
|
278 |
{
|
|
279 |
CleanupClosePushL( aList );
|
|
280 |
for ( TInt cc = 0; cc < iServiceArray.Count(); cc++ )
|
|
281 |
{
|
|
282 |
User::LeaveIfError( aList.Append( iServiceArray[cc] ) );
|
|
283 |
}
|
|
284 |
CleanupStack::Pop( &aList );
|
|
285 |
}
|
|
286 |
|
|
287 |
// -----------------------------------------------------------------------------
|
|
288 |
// CMmsIndirectUpload::ReadServiceDataL
|
|
289 |
// Reads service names from resource file and addresses from shared data or
|
|
290 |
// central repository.
|
|
291 |
// (other items were commented in a header).
|
|
292 |
// -----------------------------------------------------------------------------
|
|
293 |
//
|
|
294 |
void CMmsIndirectUpload::ReadServiceDataL()
|
|
295 |
{
|
|
296 |
// Read the maximum MMS message size (bytes).
|
|
297 |
TInt maxMsgSize = 0;
|
|
298 |
CRepository* mmsRepository = CRepository::NewL( KCRUidMmsEngine );
|
|
299 |
mmsRepository->Get( KMmsEngineMaximumSendSize, maxMsgSize );
|
|
300 |
delete mmsRepository;
|
|
301 |
|
|
302 |
CRepository* senduiRepository = CRepository::NewLC( KCRUidSendUi );
|
|
303 |
TInt i = 0;
|
|
304 |
// Go through services and get settings for indirect upload services.
|
|
305 |
// There can be 0-4 indirect upload services configured.
|
|
306 |
for ( i = 0; i < KMaxMmsUploadServiceCount; i++)
|
|
307 |
{
|
|
308 |
TInt serviceType = 0;
|
|
309 |
TInt err = senduiRepository->Get( KSUMmsUploadType1 + i , serviceType );
|
|
310 |
|
|
311 |
// Get settings and store those to service array.
|
|
312 |
if ( !err && serviceType == KMmsIndirectUploadService )
|
|
313 |
{
|
|
314 |
CSendingServiceInfo* serviceInfo = CSendingServiceInfo::NewL();
|
|
315 |
CleanupStack::PushL( serviceInfo );
|
|
316 |
|
|
317 |
HBufC* serviceAddress = HBufC::NewLC( KMaxServiceAddressLength );
|
|
318 |
TPtr serviceAddressPtr = serviceAddress->Des();
|
|
319 |
User::LeaveIfError( senduiRepository->Get( KSUMmsUploadAddress1 + i , serviceAddressPtr ) );
|
|
320 |
serviceInfo->SetServiceAddressL( serviceAddressPtr );
|
|
321 |
CleanupStack::PopAndDestroy( serviceAddress );
|
|
322 |
|
|
323 |
HBufC* serviceName = HBufC::NewLC( KMaxServiceNameLength );
|
|
324 |
TPtr serviceNamePtr = serviceName->Des();
|
|
325 |
User::LeaveIfError( senduiRepository->Get( KSUMmsUploadServiceName1 + i , serviceNamePtr ) );
|
|
326 |
serviceInfo->SetServiceNameL( serviceNamePtr );
|
|
327 |
CleanupStack::PopAndDestroy( serviceName );
|
|
328 |
|
|
329 |
HBufC* serviceMenuName = HBufC::NewLC( KMaxServiceMenuNameLength );
|
|
330 |
TPtr serviceMenuNamePtr = serviceMenuName->Des();
|
|
331 |
User::LeaveIfError( senduiRepository->Get( KSUMmsUploadServiceMenuName1 + i , serviceMenuNamePtr ) );
|
|
332 |
serviceInfo->SetServiceMenuNameL( serviceMenuNamePtr );
|
|
333 |
CleanupStack::PopAndDestroy( serviceMenuName );
|
|
334 |
|
|
335 |
// Set service type.
|
|
336 |
serviceInfo->SetServiceProviderId( KMmsIndirectUpload );
|
|
337 |
|
|
338 |
// Set sending capabilities.
|
|
339 |
TSendingCapabilities capabilities =
|
|
340 |
TSendingCapabilities( 0, KMaxTInt,
|
|
341 |
TSendingCapabilities::ESupportsAttachments );
|
|
342 |
|
|
343 |
serviceInfo->SetServiceCapabilities( capabilities );
|
|
344 |
|
|
345 |
TUid serviceId = KNullUid;
|
|
346 |
switch ( i )
|
|
347 |
{
|
|
348 |
case 0:
|
|
349 |
{
|
|
350 |
serviceId = KMmsUploadService1Id;
|
|
351 |
break;
|
|
352 |
}
|
|
353 |
case 1:
|
|
354 |
{
|
|
355 |
serviceId = KMmsUploadService2Id;
|
|
356 |
break;
|
|
357 |
}
|
|
358 |
case 2:
|
|
359 |
{
|
|
360 |
serviceId = KMmsUploadService3Id;
|
|
361 |
break;
|
|
362 |
}
|
|
363 |
case 3:
|
|
364 |
{
|
|
365 |
serviceId = KMmsUploadService4Id;
|
|
366 |
break;
|
|
367 |
}
|
|
368 |
default:
|
|
369 |
break;
|
|
370 |
}
|
|
371 |
serviceInfo->SetServiceId( serviceId );
|
|
372 |
|
|
373 |
iServiceArray.Append( serviceInfo );
|
|
374 |
CleanupStack::Pop( serviceInfo );
|
|
375 |
}
|
|
376 |
}
|
|
377 |
|
|
378 |
CleanupStack::PopAndDestroy( senduiRepository );
|
|
379 |
}
|
|
380 |
|
|
381 |
// -----------------------------------------------------------------------------
|
|
382 |
// CMmsIndirectUpload::CheckMmsServiceAvailabilityL
|
|
383 |
// Checks MMS service availability.
|
|
384 |
// (other items were commented in a header).
|
|
385 |
// -----------------------------------------------------------------------------
|
|
386 |
//
|
|
387 |
TBool CMmsIndirectUpload::CheckMmsServiceAvailabilityL(
|
|
388 |
RSendAs& aSendAsSession )
|
|
389 |
{
|
|
390 |
TInt i = 0;
|
|
391 |
|
|
392 |
CSendAsMessageTypes* msgTypes = CSendAsMessageTypes::NewL();
|
|
393 |
CleanupStack::PushL( msgTypes );
|
|
394 |
|
|
395 |
aSendAsSession.FilteredMessageTypesL( *msgTypes );
|
|
396 |
|
|
397 |
for ( i = 0; i < msgTypes->Count(); i++ )
|
|
398 |
{
|
|
399 |
if ( msgTypes->MessageTypeUid( i ) == KSenduiMtmMmsUid )
|
|
400 |
{
|
|
401 |
CleanupStack::PopAndDestroy( msgTypes );
|
|
402 |
return ETrue;
|
|
403 |
}
|
|
404 |
}
|
|
405 |
|
|
406 |
return EFalse;
|
|
407 |
}
|
|
408 |
|
|
409 |
// End of File
|