author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 09:45:25 +0300 | |
changeset 52 | 12db4185673b |
parent 31 | ebfee66fde93 |
permissions | -rw-r--r-- |
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
31 | 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 |
||
17 |
#include <msventry.h> |
|
18 |
#include <miut_err.h> |
|
19 |
#include <imapcmds.h> |
|
20 |
||
21 |
#include "cimapprotocolcontroller.h" |
|
22 |
#include "cimapupsresponsewaiter.h" |
|
23 |
#include "cimapsettings.h" |
|
24 |
||
25 |
/** |
|
26 |
Construction method |
|
27 |
@return a new instance of CImapUpsResponseWaiter |
|
28 |
*/ |
|
29 |
CImapUpsResponseWaiter* CImapUpsResponseWaiter::NewL(CMsvServerEntry& aServerEntry, CImapProtocolController& aImapProtocolController) |
|
30 |
{ |
|
31 |
return new(ELeave)CImapUpsResponseWaiter(aServerEntry, aImapProtocolController); |
|
32 |
} |
|
33 |
||
34 |
/** |
|
35 |
Default constructor. |
|
36 |
*/ |
|
37 |
CImapUpsResponseWaiter::CImapUpsResponseWaiter(CMsvServerEntry& aServerEntry, CImapProtocolController& aImapProtocolController) |
|
38 |
:CMsgActive(EPriorityStandard), iServerEntry(aServerEntry), iImapProtocolController(aImapProtocolController) |
|
39 |
{ |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
40 |
iImapSettings = CImapSettings::NewL(iServerEntry); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
41 |
CActiveScheduler::Add(this); |
31 | 42 |
} |
43 |
||
44 |
/** |
|
45 |
Destructor. |
|
46 |
*/ |
|
47 |
CImapUpsResponseWaiter::~CImapUpsResponseWaiter() |
|
48 |
{ |
|
49 |
Cancel(); |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
50 |
delete iImapSettings; |
31 | 51 |
iUpsSubsession.Close(); |
52 |
iUpsSession.Close(); |
|
53 |
} |
|
54 |
||
55 |
/** |
|
56 |
Connect to UPS server and check if the client thread has the capability to check to the |
|
57 |
imap server. |
|
58 |
@param aEntrySelection The CMsvEntrySelection containg the imap serviceID. |
|
59 |
@param aCommand The Imap command(KIMAP4MTMConnect OR KIMAP4MTMConnectAndSynchronise). |
|
60 |
||
61 |
@param aClientThread The Rthread of the client application. |
|
62 |
@param aHasCapability TBool indicating if the client has passes the server's check on capability. |
|
63 |
@param aStatus TRequestStatus of the Active Object. |
|
64 |
@return void. |
|
65 |
*/ |
|
66 |
void CImapUpsResponseWaiter::AuthoriseAndConnectL(CMsvEntrySelection& aEntrySelection, TInt aCommand, TThreadId aClientThreadId, TBool aHasCapability, TRequestStatus& aStatus) |
|
67 |
{ |
|
68 |
__ASSERT_DEBUG(iState==EIMAP4MTMDisConnected, User::Invariant()); |
|
69 |
||
70 |
if(aCommand == KIMAP4MTMConnect) |
|
71 |
{ |
|
72 |
iState = EIMAP4MTMConnect; |
|
73 |
} |
|
74 |
else if(aCommand == KIMAP4MTMConnectAndSynchronise) |
|
75 |
{ |
|
76 |
iState = EIMAP4MTMConnectAndSynchronise; |
|
77 |
} |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
78 |
|
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
79 |
iEntrySelection = &aEntrySelection; |
31 | 80 |
|
81 |
iDecision = EUpsDecNo; |
|
82 |
||
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
83 |
if( iImapSettings->SettingsLoaded() == EFalse) |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
84 |
{ |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
85 |
iImapSettings->LoadSettingsL(iServerEntry.Entry().Id()); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
86 |
} |
31 | 87 |
|
88 |
// Connect to UPS service..... |
|
89 |
User::LeaveIfError(iUpsSession.Connect()); |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
90 |
|
31 | 91 |
RThread clientThread; |
92 |
User::LeaveIfError(clientThread.Open(aClientThreadId)); |
|
93 |
CleanupClosePushL(clientThread); |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
94 |
|
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
95 |
User::LeaveIfError(iUpsSubsession.Initialise(iUpsSession, clientThread)); |
31 | 96 |
CleanupStack::PopAndDestroy(&clientThread); |
97 |
||
98 |
iStatus=KRequestPending; |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
99 |
iUpsSubsession.Authorise(aHasCapability, KUidIMAPService, iImapSettings->ServerAddress(), iDecision, iStatus); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
100 |
|
31 | 101 |
Queue(aStatus); |
102 |
SetActive(); |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
103 |
|
31 | 104 |
} |
105 |
||
106 |
||
107 |
void CImapUpsResponseWaiter::DoRunL() |
|
108 |
{ |
|
109 |
User::LeaveIfError(iStatus.Int()); |
|
110 |
if(iDecision != EUpsDecYes && iDecision != EUpsDecSessionYes) |
|
111 |
{ |
|
112 |
Complete(KErrPermissionDenied); |
|
113 |
return; |
|
114 |
} |
|
115 |
switch (iState) |
|
116 |
{ |
|
117 |
case EIMAP4MTMConnect: |
|
118 |
{ |
|
119 |
iState = EIMAP4MTMConnected; |
|
120 |
iImapProtocolController.ConnectL(iStatus, *iEntrySelection); |
|
121 |
SetActive(); |
|
122 |
}break; |
|
123 |
case EIMAP4MTMConnectAndSynchronise: |
|
124 |
{ |
|
125 |
iState = EIMAP4MTMConnected; |
|
126 |
iImapProtocolController.ConnectAndSynchroniseL(iStatus, *iEntrySelection); |
|
127 |
SetActive(); |
|
128 |
}break; |
|
129 |
case EIMAP4MTMConnected: |
|
130 |
{ |
|
131 |
Complete(iStatus.Int()); |
|
132 |
iState=EIMAP4MTMDisConnected; |
|
133 |
}break; |
|
134 |
default: |
|
135 |
{ |
|
136 |
__ASSERT_DEBUG(iState==EIMAP4MTMDisConnected, User::Invariant()); |
|
137 |
break; |
|
138 |
} |
|
139 |
} |
|
140 |
} |
|
141 |
||
142 |
||
143 |
void CImapUpsResponseWaiter::DoCancel() |
|
144 |
{ |
|
145 |
iUpsSubsession.CancelPrompt(); |
|
146 |
iImapProtocolController.CancelAndCleanup(); |
|
147 |
CMsgActive::DoCancel(); |
|
148 |
} |