|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <mmsvattachmentmanager.h> |
|
19 #include "btmsgviewerutils.h" |
|
20 |
|
21 |
|
22 CBtMsgViewerUtils* CBtMsgViewerUtils::NewL() |
|
23 { |
|
24 CBtMsgViewerUtils* me = new (ELeave) CBtMsgViewerUtils(); |
|
25 CleanupStack::PushL(me); |
|
26 me->ConstructL(); |
|
27 CleanupStack::Pop(me); |
|
28 return me; |
|
29 } |
|
30 |
|
31 CBtMsgViewerUtils::CBtMsgViewerUtils() |
|
32 { |
|
33 |
|
34 } |
|
35 |
|
36 void CBtMsgViewerUtils::ConstructL() |
|
37 { |
|
38 iMsvSession = CMsvSession::OpenSyncL(*this); |
|
39 } |
|
40 |
|
41 CBtMsgViewerUtils::~CBtMsgViewerUtils() |
|
42 { |
|
43 if ( iMsvSession ) |
|
44 { |
|
45 delete iMsvSession; |
|
46 } |
|
47 } |
|
48 |
|
49 HBufC* CBtMsgViewerUtils::GetMessagePath(TInt aMessageId, TInt aError) |
|
50 { |
|
51 HBufC* fileName = NULL; |
|
52 TRAP(aError, fileName = HBufC::NewL(KMaxPath)); |
|
53 if(aError < KErrNone) |
|
54 { |
|
55 return fileName; |
|
56 } |
|
57 |
|
58 TRAP(aError, GetMessagePathL(fileName->Des(), aMessageId)); |
|
59 return fileName; |
|
60 } |
|
61 |
|
62 void CBtMsgViewerUtils::GetMessagePathL(TPtr aMsgPath, const TInt aMessageId) |
|
63 { |
|
64 CMsvEntry* messageEntry = iMsvSession->GetEntryL(aMessageId); |
|
65 CleanupStack::PushL(messageEntry); |
|
66 |
|
67 CMsvEntry* attachmentEntry = iMsvSession->GetEntryL((*messageEntry)[0].Id()); |
|
68 CleanupStack::PushL(attachmentEntry); |
|
69 |
|
70 CMsvStore* store = attachmentEntry->EditStoreL(); |
|
71 CleanupStack::PushL(store); |
|
72 |
|
73 //get file handle for the attachment & the complete path of the file |
|
74 RFile attachmentFile; |
|
75 attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0); |
|
76 attachmentFile.FullName(aMsgPath); |
|
77 attachmentFile.Close(); |
|
78 |
|
79 //mark attachment as Read |
|
80 TMsvEntry attachEntry = attachmentEntry->Entry(); |
|
81 attachEntry.SetUnread(EFalse); |
|
82 attachmentEntry->ChangeL(attachEntry); |
|
83 |
|
84 CleanupStack::PopAndDestroy(store); |
|
85 CleanupStack::PopAndDestroy(attachmentEntry); |
|
86 CleanupStack::PopAndDestroy(messageEntry); |
|
87 } |
|
88 |
|
89 void CBtMsgViewerUtils::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, |
|
90 TAny* aArg2, TAny* aArg3) |
|
91 { |
|
92 (void) aEvent; |
|
93 (void) aArg1; |
|
94 (void) aArg2; |
|
95 (void) aArg3; |
|
96 } |
|
97 |
|
98 |
|
99 |