24 #include <cemailaccounts.h> |
24 #include <cemailaccounts.h> |
25 #include <etelmm.h> |
25 #include <etelmm.h> |
26 #include <iapprefs.h> |
26 #include <iapprefs.h> |
27 #include <imapset.h> |
27 #include <imapset.h> |
28 #include <mtmuibas.h> |
28 #include <mtmuibas.h> |
29 #include <senduiconsts.h> |
29 #include <SendUiConsts.h> |
30 #include <pop3set.h> |
30 #include <pop3set.h> |
31 #include <smtpset.h> |
31 #include <smtpset.h> |
32 #include <txtrich.h> |
32 #include <txtrich.h> |
33 |
33 |
34 #include <HtiDispatcherInterface.h> |
34 #include <HtiDispatcherInterface.h> |
35 #include <HTILogging.h> |
35 #include <HtiLogging.h> |
36 #include "HtiMessagesServicePlugin.h" |
36 #include "HtiMessagesServicePlugin.h" |
37 #include "HtiMailboxHandler.h" |
37 #include "HtiMailboxHandler.h" |
38 |
38 |
39 // EXTERNAL DATA STRUCTURES |
39 // EXTERNAL DATA STRUCTURES |
40 |
40 |
582 // Deletes a mailbox. |
582 // Deletes a mailbox. |
583 // ---------------------------------------------------------------------------- |
583 // ---------------------------------------------------------------------------- |
584 void CHtiMailboxHandler::HandleDeleteMailboxL( const TDesC8& aData ) |
584 void CHtiMailboxHandler::HandleDeleteMailboxL( const TDesC8& aData ) |
585 { |
585 { |
586 HTI_LOG_FUNC_IN( "CHtiMailboxHandler::HandleDeleteMailboxL" ); |
586 HTI_LOG_FUNC_IN( "CHtiMailboxHandler::HandleDeleteMailboxL" ); |
587 // Deprecated |
587 |
588 aData.Size(); |
588 // Delete by name - name should be unique |
589 User::Leave( KErrNotSupported ); |
589 TInt nameLength = aData[0]; |
|
590 if ( nameLength > KEmailAccountNameSize || nameLength == 0 || |
|
591 aData.Length() != ( nameLength + 1 ) ) |
|
592 { |
|
593 User::Leave( KErrArgument ); |
|
594 } |
|
595 |
|
596 TBuf<KEmailAccountNameSize> accountName; |
|
597 accountName.Copy( aData.Mid( 1, nameLength ) ); |
|
598 HTI_LOG_FORMAT( "Searching account with name: %S", &accountName ); |
|
599 |
|
600 TSmtpAccount smtpAcc; |
|
601 User::LeaveIfError( FindSmtpAccount( accountName, smtpAcc ) ); |
|
602 HTI_LOG_FORMAT( "Found SMTP: %d", smtpAcc.iSmtpAccountId ); |
|
603 TMsvId relatedAcc = smtpAcc.iRelatedService; |
|
604 |
|
605 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
606 |
|
607 // Delete the SMTP account |
|
608 accounts->DeleteSmtpAccountL( smtpAcc ); |
|
609 |
|
610 // Search for related POP & IMAP acconts and delete if found |
|
611 TInt result = KErrNone; |
|
612 TPopAccount popAcc; |
|
613 TRAP( result, accounts->GetPopAccountL( relatedAcc, popAcc ) ); |
|
614 if ( result == KErrNone ) |
|
615 { |
|
616 HTI_LOG_FORMAT( "Found related POP: %d", popAcc.iPopAccountId ); |
|
617 accounts->DeletePopAccountL( popAcc ); |
|
618 } |
|
619 |
|
620 TImapAccount imapAcc; |
|
621 TRAP( result, accounts->GetImapAccountL( relatedAcc, imapAcc ) ); |
|
622 if ( result == KErrNone ) |
|
623 { |
|
624 HTI_LOG_FORMAT( "Found related IMAP: %d", imapAcc.iImapAccountId ); |
|
625 accounts->DeleteImapAccountL( imapAcc ); |
|
626 } |
|
627 |
|
628 CleanupStack::PopAndDestroy( 1 ); // accounts |
590 HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::HandleDeleteMailboxL" ); |
629 HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::HandleDeleteMailboxL" ); |
591 } |
630 } |
592 |
631 |
593 |
632 |
594 // ---------------------------------------------------------------------------- |
633 // ---------------------------------------------------------------------------- |