65 TRequestStatus& aObserverRequestStatus ) : |
66 TRequestStatus& aObserverRequestStatus ) : |
66 CMsvOperation( aMsvSession, aPriority, aObserverRequestStatus ), |
67 CMsvOperation( aMsvSession, aPriority, aObserverRequestStatus ), |
67 iSmtpMtm( NULL ), |
68 iSmtpMtm( NULL ), |
68 iOperation( NULL ), |
69 iOperation( NULL ), |
69 iSelection( NULL ), |
70 iSelection( NULL ), |
70 iMtmRegistry( NULL ) |
71 iMtmRegistry( NULL ), |
|
72 iState( EIdle ), |
|
73 iEventHandler( NULL ) |
71 { |
74 { |
72 FUNC_LOG; |
75 FUNC_LOG; |
73 } |
76 } |
74 |
77 |
75 // --------------------------------------------------------------------------- |
78 // --------------------------------------------------------------------------- |
124 // --------------------------------------------------------------------------- |
130 // --------------------------------------------------------------------------- |
125 // |
131 // |
126 void CIpsPlgSmtpOperation::RunL() |
132 void CIpsPlgSmtpOperation::RunL() |
127 { |
133 { |
128 FUNC_LOG; |
134 FUNC_LOG; |
129 |
135 |
130 |
136 switch ( iState ) |
131 if ( iState == EMovingOutbox ) |
137 { |
132 { |
138 case EMovingOutbox: |
133 delete iOperation; |
139 { |
134 iOperation = NULL; |
140 delete iOperation; |
135 iSelection->InsertL(0, iSmtpService ); |
141 iOperation = NULL; |
136 CallSendL( ); |
142 iSelection->InsertL( 0, iSmtpService ); |
137 } |
143 CallSendL(); |
138 else if ( iState == ESending ) |
144 break; |
139 { |
145 } |
140 TImSmtpProgress prog; |
146 case ESending: |
141 TPckg<TImSmtpProgress> param(prog); |
147 { |
142 param.Copy( iOperation->FinalProgress() ); |
148 TImSmtpProgress prog; |
143 |
149 TPckg<TImSmtpProgress> param(prog); |
144 CompleteObserver( prog.Error() ); |
150 param.Copy( iOperation->FinalProgress() ); |
145 } |
151 |
146 } |
152 if ( prog.Error() == KSmtpLoginRefused ) |
147 |
153 { |
|
154 // Login details are wrong. Trying to ask for password |
|
155 if ( !QueryUserPassL() ) |
|
156 { |
|
157 CompleteObserver( prog.Error() ); |
|
158 } |
|
159 } |
|
160 else if ( prog.Error() == KSmtpUnknownErr ) |
|
161 { |
|
162 // try to handle empty password problem |
|
163 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
164 CImSmtpSettings* smtpSettings = new(ELeave) CImSmtpSettings(); |
|
165 CleanupStack::PushL( smtpSettings ); |
|
166 TSmtpAccount smtpAccount; |
|
167 accounts->GetSmtpAccountL( iSmtpService, smtpAccount ); |
|
168 accounts->LoadSmtpSettingsL( smtpAccount, *smtpSettings ); |
|
169 |
|
170 if ( smtpSettings->Password().Length() == 0 ) |
|
171 { |
|
172 if ( !QueryUserPassL() ) |
|
173 { |
|
174 CompleteObserver( prog.Error() ); |
|
175 } |
|
176 } |
|
177 CleanupStack::PopAndDestroy( 2, accounts ); |
|
178 } |
|
179 else |
|
180 { |
|
181 CompleteObserver( prog.Error() ); |
|
182 } |
|
183 break; |
|
184 } |
|
185 case EQueryingDetails: |
|
186 { |
|
187 delete iOperation; |
|
188 iOperation = NULL; |
|
189 // querying pass finished - try to resend mail |
|
190 CallSendL(); |
|
191 break; |
|
192 } |
|
193 } |
|
194 } |
|
195 |
148 // --------------------------------------------------------------------------- |
196 // --------------------------------------------------------------------------- |
149 // --------------------------------------------------------------------------- |
197 // --------------------------------------------------------------------------- |
150 // |
198 // |
151 void CIpsPlgSmtpOperation::DoCancel() |
199 void CIpsPlgSmtpOperation::DoCancel() |
152 { |
200 { |
398 User::Leave( KErrBadName ); |
446 User::Leave( KErrBadName ); |
399 } |
447 } |
400 } |
448 } |
401 } |
449 } |
402 |
450 |
|
451 // --------------------------------------------------------------------------- |
|
452 // --------------------------------------------------------------------------- |
|
453 // |
|
454 void CIpsPlgSmtpOperation::SetEventHandler( TAny* aEventHandler ) |
|
455 { |
|
456 iEventHandler = aEventHandler; |
|
457 } |
|
458 |
|
459 // --------------------------------------------------------------------------- |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 TBool CIpsPlgSmtpOperation::QueryUserPassL() |
|
463 { |
|
464 if ( iEventHandler ) |
|
465 { |
|
466 CIpsPlgEventHandler* eventHandler = static_cast<CIpsPlgEventHandler*>(iEventHandler); |
|
467 TMsvEntry entry; |
|
468 TMsvId service; |
|
469 User::LeaveIfError( iMsvSession.GetEntry( iSmtpService, service, entry ) ); |
|
470 |
|
471 // ask for credentials for smtp account and wait for callback |
|
472 if ( eventHandler->QueryUsrPassL( entry.iRelatedId, this, EFalse ) ) |
|
473 { |
|
474 iState = EQueryingDetails; |
|
475 } |
|
476 else |
|
477 { |
|
478 // another operation is waiting for password |
|
479 iState = EQueryingDetailsBusy; |
|
480 } |
|
481 |
|
482 return ETrue; |
|
483 } |
|
484 |
|
485 return EFalse; |
|
486 } |
|
487 |
|
488 // --------------------------------------------------------------------------- |
|
489 // --------------------------------------------------------------------------- |
|
490 // |
|
491 void CIpsPlgSmtpOperation::CredientialsSetL( TInt aEvent ) |
|
492 { |
|
493 FUNC_LOG; |
|
494 |
|
495 if ( iState == EQueryingDetails ) |
|
496 { |
|
497 // response for our operation`s query |
|
498 if ( aEvent == EIPSSosCredientialsCancelled ) |
|
499 { |
|
500 // user canceled operation |
|
501 CompleteObserver( KErrCancel ); |
|
502 } |
|
503 |
|
504 // password has been set, continue with operation |
|
505 SetActive(); |
|
506 CompleteThis(); |
|
507 } |
|
508 else if ( iState == EQueryingDetailsBusy ) |
|
509 { |
|
510 // response for other operation`s query |
|
511 // we could try to ask for password now, |
|
512 // but decision was made to cancel operation |
|
513 CompleteObserver( KErrCancel ); |
|
514 SetActive(); |
|
515 CompleteThis(); |
|
516 } |
|
517 } |
|
518 |
403 // End of File |
519 // End of File |
404 |
520 |