|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "CMsvAttachmentWaiter.h" |
|
17 #include <mmsvattachmentmanager.h> |
|
18 #include "MSVSTORE.H" |
|
19 |
|
20 CMsvAttachmentWaiter* CMsvAttachmentWaiter::NewL() |
|
21 { |
|
22 CMsvAttachmentWaiter* self = new(ELeave) CMsvAttachmentWaiter(); |
|
23 return self; |
|
24 } |
|
25 |
|
26 CMsvAttachmentWaiter::CMsvAttachmentWaiter() |
|
27 : CActive(EPriorityStandard) |
|
28 { |
|
29 CActiveScheduler::Add(this); |
|
30 } |
|
31 |
|
32 CMsvAttachmentWaiter::~CMsvAttachmentWaiter() |
|
33 { |
|
34 Cancel(); |
|
35 delete iStore; |
|
36 } |
|
37 |
|
38 void CMsvAttachmentWaiter::StartWaitingL(TRequestStatus& aStatus, CMsvStore* aStore, MMsvAttachmentManager* aAttachmentManager) |
|
39 { |
|
40 if( IsActive() ) |
|
41 { |
|
42 aAttachmentManager->CancelRequest(); |
|
43 User::Leave(KErrInUse); |
|
44 } |
|
45 |
|
46 aStatus = KRequestPending; |
|
47 iReportStatus = &aStatus; |
|
48 iStore = aStore; |
|
49 iAttachmentManager = aAttachmentManager; |
|
50 SetActive(); |
|
51 } |
|
52 |
|
53 void CMsvAttachmentWaiter::Reset() |
|
54 { |
|
55 iReportStatus = NULL; |
|
56 iAttachmentManager = NULL; |
|
57 delete iStore; |
|
58 iStore = NULL; |
|
59 } |
|
60 |
|
61 void CMsvAttachmentWaiter::RunL() |
|
62 { |
|
63 User::LeaveIfError(iStatus.Int()); |
|
64 iStore->CommitL(); |
|
65 User::RequestComplete(iReportStatus, KErrNone); |
|
66 Reset(); |
|
67 } |
|
68 |
|
69 void CMsvAttachmentWaiter::DoCancel() |
|
70 { |
|
71 iAttachmentManager->CancelRequest(); |
|
72 User::RequestComplete(iReportStatus, KErrCancel); |
|
73 Reset(); |
|
74 } |
|
75 |
|
76 TInt CMsvAttachmentWaiter::RunError(TInt aError) |
|
77 { |
|
78 User::RequestComplete(iReportStatus, aError); |
|
79 Reset(); |
|
80 return KErrNone; |
|
81 } |