|
1 /* |
|
2 * Copyright (c) 2007 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 * Main plugin class |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include <e32base.h> |
|
21 |
|
22 #include "IpsSosAOSmtpAgent.h" |
|
23 #include "ipsplgsmtpoperation.h" |
|
24 #include "ipssetdataapi.h" |
|
25 |
|
26 |
|
27 #ifdef _DEBUG |
|
28 _LIT( KIpsSosAOSmtpLogicPanicLit, "AOsmtp"); |
|
29 #endif |
|
30 |
|
31 // ---------------------------------------------------------------------------- |
|
32 // ---------------------------------------------------------------------------- |
|
33 CIpsSosAOSmtpAgent* CIpsSosAOSmtpAgent::NewL( |
|
34 CMsvSession& aSession ) |
|
35 { |
|
36 FUNC_LOG; |
|
37 CIpsSosAOSmtpAgent* self = CIpsSosAOSmtpAgent::NewLC( |
|
38 aSession ); |
|
39 CleanupStack::Pop( self ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // ---------------------------------------------------------------------------- |
|
45 CIpsSosAOSmtpAgent* CIpsSosAOSmtpAgent::NewLC( |
|
46 CMsvSession& aSession ) |
|
47 { |
|
48 FUNC_LOG; |
|
49 CIpsSosAOSmtpAgent* self = new( ELeave ) CIpsSosAOSmtpAgent( |
|
50 aSession ); |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------------------------------- |
|
57 // ---------------------------------------------------------------------------- |
|
58 CIpsSosAOSmtpAgent::CIpsSosAOSmtpAgent( |
|
59 CMsvSession& aSession ) |
|
60 : CActive( EPriorityStandard ), iSession( aSession ) |
|
61 { |
|
62 FUNC_LOG; |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------------------------------- |
|
66 // ---------------------------------------------------------------------------- |
|
67 void CIpsSosAOSmtpAgent::ConstructL() |
|
68 { |
|
69 FUNC_LOG; |
|
70 CActiveScheduler::Add(this); |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // ---------------------------------------------------------------------------- |
|
75 CIpsSosAOSmtpAgent::~CIpsSosAOSmtpAgent() |
|
76 { |
|
77 FUNC_LOG; |
|
78 Cancel(); |
|
79 ReleaseInternalData( ); |
|
80 } |
|
81 |
|
82 // ---------------------------------------------------------------------------- |
|
83 // ---------------------------------------------------------------------------- |
|
84 void CIpsSosAOSmtpAgent::DoCancel() |
|
85 { |
|
86 FUNC_LOG; |
|
87 if ( iOperation && iOperation->IsActive() ) |
|
88 { |
|
89 iOperation->Cancel(); |
|
90 } |
|
91 } |
|
92 |
|
93 // ---------------------------------------------------------------------------- |
|
94 // ---------------------------------------------------------------------------- |
|
95 void CIpsSosAOSmtpAgent::RunL() |
|
96 { |
|
97 FUNC_LOG; |
|
98 if ( iStatus != KErrNone ) |
|
99 { |
|
100 iError = this->iStatus.Int(); |
|
101 } |
|
102 else |
|
103 { |
|
104 ReleaseInternalData( ); |
|
105 } |
|
106 |
|
107 } |
|
108 |
|
109 // ---------------------------------------------------------------------------- |
|
110 // ---------------------------------------------------------------------------- |
|
111 void CIpsSosAOSmtpAgent::EmptyOutboxNowL( TMsvId aMessage ) |
|
112 { |
|
113 FUNC_LOG; |
|
114 |
|
115 if ( iOperation && iOperation->IsActive() ) |
|
116 { |
|
117 __ASSERT_DEBUG(EFalse, |
|
118 User::Panic( KIpsSosAOSmtpLogicPanicLit, KErrServerBusy) ); |
|
119 // leave if not debug mode |
|
120 User::Leave( KErrServerBusy ); |
|
121 } |
|
122 CreateInternalDataL( ); |
|
123 |
|
124 iOperation->StartSendL( aMessage ); |
|
125 iStatus = KRequestPending; |
|
126 SetActive(); |
|
127 } |
|
128 |
|
129 // ---------------------------------------------------------------------------- |
|
130 // ---------------------------------------------------------------------------- |
|
131 void CIpsSosAOSmtpAgent::CreateInternalDataL( ) |
|
132 { |
|
133 FUNC_LOG; |
|
134 if ( !iOperation ) |
|
135 { |
|
136 iOperation = CIpsPlgSmtpOperation::NewL( |
|
137 iSession, EPriorityStandard, iStatus , EFalse ); |
|
138 } |
|
139 |
|
140 if ( !iSettingsApi ) |
|
141 { |
|
142 iSettingsApi = CIpsSetDataApi::NewL( iSession ); |
|
143 } |
|
144 } |
|
145 |
|
146 // ---------------------------------------------------------------------------- |
|
147 // ---------------------------------------------------------------------------- |
|
148 void CIpsSosAOSmtpAgent::ReleaseInternalData( ) |
|
149 { |
|
150 FUNC_LOG; |
|
151 if ( iOperation && iOperation->IsActive() ) |
|
152 { |
|
153 iOperation->Cancel(); |
|
154 } |
|
155 |
|
156 else if ( iOperation && !iOperation->IsActive() ) |
|
157 { |
|
158 delete iOperation; |
|
159 iOperation = NULL; |
|
160 } |
|
161 |
|
162 delete iSettingsApi; |
|
163 iSettingsApi = NULL; |
|
164 } |
|
165 |
|
166 |
|
167 //EOF |
|
168 |