|
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 "nmframeworkadapterheaders.h" |
|
19 |
|
20 NmFwaMessageFetchingOperation::NmFwaMessageFetchingOperation( |
|
21 const NmId &mailboxId, |
|
22 const NmId &folderId, |
|
23 const NmId &messageId, |
|
24 CFSMailClient &mailClient) |
|
25 : mMailboxId(mailboxId), |
|
26 mFolderId(folderId), |
|
27 mMessageId(messageId), |
|
28 mMailClient(mailClient), |
|
29 mRequestId(0) |
|
30 |
|
31 { |
|
32 NM_FUNCTION; |
|
33 } |
|
34 |
|
35 NmFwaMessageFetchingOperation::~NmFwaMessageFetchingOperation() |
|
36 { |
|
37 NM_FUNCTION; |
|
38 |
|
39 doCancelOperation(); |
|
40 } |
|
41 |
|
42 void NmFwaMessageFetchingOperation::doRunAsyncOperation() |
|
43 { |
|
44 NM_FUNCTION; |
|
45 |
|
46 const TFSMailMsgId mailboxId(mMailboxId.pluginId32(), mMailboxId.id32()); |
|
47 const TFSMailMsgId folderId(mFolderId.pluginId32(), mFolderId.id32()); |
|
48 const TFSMailMsgId messageId(mMessageId.pluginId32(), mMessageId.id32()); |
|
49 |
|
50 CFSMailFolder *folder(NULL); |
|
51 TRAP_IGNORE(folder = mMailClient.GetFolderByUidL(mailboxId, folderId)); |
|
52 |
|
53 if (folder) { |
|
54 RArray<TFSMailMsgId> messageIds; // Cleanupstack not needed |
|
55 messageIds.Append(messageId); |
|
56 TRAPD(err, mRequestId = folder->FetchMessagesL(messageIds, EFSMsgDataStructure, *this)); |
|
57 messageIds.Close(); |
|
58 if (KErrNone != err) { |
|
59 completeOperation(NmGeneralError); |
|
60 } |
|
61 delete folder; |
|
62 folder = NULL; |
|
63 } |
|
64 else { |
|
65 completeOperation(NmNotFoundError); |
|
66 } |
|
67 } |
|
68 |
|
69 /*! |
|
70 * Complete the operation |
|
71 */ |
|
72 void NmFwaMessageFetchingOperation::doCompleteOperation() |
|
73 { |
|
74 NM_FUNCTION; |
|
75 |
|
76 mRequestId = NmNotFoundError; |
|
77 } |
|
78 |
|
79 /*! |
|
80 Cancels the async operation. \sa NmOperation |
|
81 */ |
|
82 void NmFwaMessageFetchingOperation::doCancelOperation() |
|
83 { |
|
84 NM_FUNCTION; |
|
85 |
|
86 if (mRequestId >= 0) { |
|
87 TRAP_IGNORE(mMailClient.CancelL(mRequestId)); |
|
88 mRequestId = NmNotFoundError; |
|
89 } |
|
90 } |
|
91 |
|
92 /*! |
|
93 asynchronous request response message |
|
94 |
|
95 \param aEvent plugin event description |
|
96 \param mailClient Reference to mail client object |
|
97 */ |
|
98 void NmFwaMessageFetchingOperation::RequestResponseL(TFSProgress aEvent, TInt aRequestId) |
|
99 { |
|
100 NM_FUNCTION; |
|
101 |
|
102 if (aRequestId == mRequestId) { |
|
103 if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete) { |
|
104 completeOperation(NmNoError); |
|
105 } else if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestCancelled) { |
|
106 completeOperation(NmCancelError); |
|
107 } |
|
108 } |
|
109 } |