|
1 // Copyright (c) 2003-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 // __ACTION_INFO_BEGIN__ |
|
15 // [Action Name] |
|
16 // ConnectImap4Server |
|
17 // [Action Parameters] |
|
18 // ServiceId <input>: Value of the Imap4 service id. |
|
19 // Mtm <input>: Reference to Imap4 client MTM. |
|
20 // [Action Description] |
|
21 // Connects to the Imap4 server. |
|
22 // [APIs Used] |
|
23 // CMsvEntry::SetEntryL |
|
24 // CMsvEntrySelection::AppendL |
|
25 // CImap4ClientMtm::InvokeAsyncFunctionL |
|
26 // __ACTION_INFO_END__ |
|
27 // |
|
28 // |
|
29 |
|
30 /** |
|
31 @file |
|
32 */ |
|
33 |
|
34 |
|
35 #include "CMtfTestActionConnectImap4Server.h" |
|
36 #include "CMtfTestCase.h" |
|
37 #include "CMtfTestActionParameters.h" |
|
38 #include "MtfTestActionUtilsUser.h" |
|
39 |
|
40 #include <cemailaccounts.h> |
|
41 #include <iapprefs.h> |
|
42 |
|
43 |
|
44 #include <impcmtm.h> |
|
45 |
|
46 |
|
47 CMtfTestAction* CMtfTestActionConnectImap4Server::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
48 { |
|
49 CMtfTestActionConnectImap4Server* self = new (ELeave) CMtfTestActionConnectImap4Server(aTestCase); |
|
50 CleanupStack::PushL(self); |
|
51 self->ConstructL(aActionParameters); |
|
52 CleanupStack::Pop(); |
|
53 return self; |
|
54 } |
|
55 |
|
56 |
|
57 CMtfTestActionConnectImap4Server::CMtfTestActionConnectImap4Server(CMtfTestCase& aTestCase) |
|
58 : CMtfTestAction(aTestCase) |
|
59 { |
|
60 } |
|
61 |
|
62 |
|
63 CMtfTestActionConnectImap4Server::~CMtfTestActionConnectImap4Server() |
|
64 { |
|
65 } |
|
66 |
|
67 |
|
68 void CMtfTestActionConnectImap4Server::ExecuteActionL() |
|
69 { |
|
70 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionConnectImap4Server); |
|
71 TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0)); |
|
72 CImap4ClientMtm* paramMtm = ObtainParameterReferenceL<CImap4ClientMtm>(TestCase(),ActionParameters().Parameter(1)); |
|
73 |
|
74 // Make sure an account exists for this service id |
|
75 CEmailAccounts *emailAccounts = CEmailAccounts::NewLC(); |
|
76 TImapAccount imapAccount; |
|
77 emailAccounts->GetImapAccountL(paramServiceId, imapAccount); |
|
78 CleanupStack::PopAndDestroy(emailAccounts); |
|
79 |
|
80 paramMtm->SwitchCurrentEntryL(paramServiceId); |
|
81 |
|
82 CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; |
|
83 CleanupStack::PushL(selection); |
|
84 selection->AppendL(paramServiceId); |
|
85 TBuf8<1> param; |
|
86 iOperation = paramMtm->InvokeAsyncFunctionL(KIMAP4MTMConnect,*selection,param,iStatus); |
|
87 CleanupStack::PopAndDestroy(selection); |
|
88 CActiveScheduler::Add(this); |
|
89 SetActive(); |
|
90 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionConnectImap4Server); |
|
91 } |
|
92 |
|
93 |
|
94 void CMtfTestActionConnectImap4Server::DoCancel() |
|
95 { |
|
96 iOperation->Cancel(); |
|
97 } |
|
98 |
|
99 |
|
100 void CMtfTestActionConnectImap4Server::RunL() |
|
101 { |
|
102 TInt err = MtfTestActionUtilsUser::FinalProgressStatus(*iOperation,iStatus); |
|
103 |
|
104 delete iOperation; |
|
105 |
|
106 User::LeaveIfError(err); |
|
107 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionConnectImap4Server); |
|
108 TestCase().ActionCompletedL(*this); |
|
109 } |
|
110 |