emailuis/emailui/src/FreestyleEmailUiSettingsList.cpp
changeset 2 5253a20d2a1e
parent 1 12c456ceeff2
child 8 e1b6206813b4
equal deleted inserted replaced
1:12c456ceeff2 2:5253a20d2a1e
    27 #include <aknViewAppUi.h>
    27 #include <aknViewAppUi.h>
    28 #include <eikappui.h>
    28 #include <eikappui.h>
    29 #include <aknlistquerydialog.h>
    29 #include <aknlistquerydialog.h>
    30 #include <e32cmn.h>
    30 #include <e32cmn.h>
    31 #include <FreestyleEmailUi.rsg>
    31 #include <FreestyleEmailUi.rsg>
    32 //<cmail>
    32 
    33 #include "CFSMailClient.h"
    33 #include "CFSMailClient.h"
    34 #include "CFSMailBox.h"
    34 #include "CFSMailBox.h"
    35 #include <AknGlobalConfirmationQuery.h> // confirmation
    35 #include <AknGlobalConfirmationQuery.h> // confirmation
    36 #include <freestyleemailui.mbg> // icons
    36 #include <freestyleemailui.mbg> // icons
    37 #include "ESMailSettingsPluginUids.hrh"
    37 #include "ESMailSettingsPluginUids.hrh"
    38 #include "ESMailSettingsPlugin.h"
    38 #include "ESMailSettingsPlugin.h"
    39 //</cmail>
    39 
    40 #include <aknnotewrappers.h> // for note
    40 #include <aknnotewrappers.h> // for note
    41 #include <AknDialog.h> // for settings dialog
    41 #include <AknDialog.h> // for settings dialog
    42 #include <aknsettingitemlist.h> // for settings dialog
    42 #include <aknsettingitemlist.h> // for settings dialog
    43 
    43 
    44 // 9.11.2009: Temporary flagging SYMBIAN_ENABLE_SPLIT_HEADERS
    44 // 9.11.2009: Temporary flagging SYMBIAN_ENABLE_SPLIT_HEADERS
   336         {
   336         {
   337         delete iListBox;
   337         delete iListBox;
   338         iListBox = NULL;
   338         iListBox = NULL;
   339         }
   339         }
   340 
   340 
       
   341     if ( iLongTapDetector )
       
   342     	{
       
   343     	delete iLongTapDetector;
       
   344     	iLongTapDetector = NULL;
       
   345     	}
   341     }
   346     }
   342 
   347 
   343 // ---------------------------------------------------------------------------
   348 // ---------------------------------------------------------------------------
   344 // Construct the control (first phase).
   349 // Construct the control (first phase).
   345 //
   350 //
   389 
   394 
   390     CFsEmailSettingsList* self = new ( ELeave ) CFsEmailSettingsList(aAppUi, aMailClient, aView );
   395     CFsEmailSettingsList* self = new ( ELeave ) CFsEmailSettingsList(aAppUi, aMailClient, aView );
   391     CleanupStack::PushL( self );
   396     CleanupStack::PushL( self );
   392     self->ConstructL( aRect, aParent);
   397     self->ConstructL( aRect, aParent);
   393 
   398 
   394 
       
   395     return self;
   399     return self;
   396     }
   400     }
   397 
   401 
   398 // ---------------------------------------------------------------------------
   402 // ---------------------------------------------------------------------------
   399 // Construct the control (first phase).
   403 // Construct the control (first phase).
   404 // @param aMailClient reference to freestyle mail client
   408 // @param aMailClient reference to freestyle mail client
   405 // ---------------------------------------------------------------------------
   409 // ---------------------------------------------------------------------------
   406 //
   410 //
   407 void CFsEmailSettingsList::ConstructL(
   411 void CFsEmailSettingsList::ConstructL(
   408         const TRect& aRect,
   412         const TRect& aRect,
   409         const CCoeControl* aParent)
   413         const CCoeControl* aParent )
   410     {
   414     {
   411     FUNC_LOG;
   415     FUNC_LOG;
   412 
   416 
   413     if ( aParent == NULL )
   417     if ( aParent == NULL )
   414         {
   418         {
   421 
   425 
   422     iFocusControl = NULL;
   426     iFocusControl = NULL;
   423     InitializeControlsL();
   427     InitializeControlsL();
   424     SetRect( aRect );
   428     SetRect( aRect );
   425     ActivateL();
   429     ActivateL();
   426 
       
   427     }
   430     }
   428 
   431 
   429 // ---------------------------------------------------------------------------
   432 // ---------------------------------------------------------------------------
   430 // Return the number of controls in the container (override)
   433 // Return the number of controls in the container (override)
   431 // @return count
   434 // @return count
   656     iFocusControl = iListBox;
   659     iFocusControl = iListBox;
   657 
   660 
   658     // event listener this class
   661     // event listener this class
   659     iListBox->SetListBoxObserver( this );
   662     iListBox->SetListBoxObserver( this );
   660 
   663 
       
   664     // Construct the long tap detector.
       
   665 	iLongTapDetector = CAknLongTapDetector::NewL( this );
   661     }
   666     }
   662 
   667 
   663 
   668 
   664 // ---------------------------------------------------------------------------
   669 // ---------------------------------------------------------------------------
   665 // Handle global resource changes, such as scalable UI or skin events (override)
   670 // Handle global resource changes, such as scalable UI or skin events (override)
   669     {
   674     {
   670     FUNC_LOG;
   675     FUNC_LOG;
   671 
   676 
   672     CCoeControl::HandleResourceChange( aType );
   677     CCoeControl::HandleResourceChange( aType );
   673     SetRect( iAvkonViewAppUi->View( SettingsViewId )->ClientRect() );
   678     SetRect( iAvkonViewAppUi->View( SettingsViewId )->ClientRect() );
   674 
   679     }
   675     }
   680 
       
   681 
       
   682 // -----------------------------------------------------------------------------
       
   683 // CFsEmailSettingsList::HandlePointerEventL()
       
   684 // From CCoeControl.
       
   685 // -----------------------------------------------------------------------------
       
   686 //
       
   687 void CFsEmailSettingsList::HandlePointerEventL(
       
   688 	const TPointerEvent& aPointerEvent )
       
   689 	{
       
   690     // Pass the event to the long tap detector.
       
   691 	iLongTapDetector->PointerEventL( aPointerEvent );
       
   692 
       
   693 	if ( !iLongTapEventConsumed )
       
   694 		{
       
   695 		// Call HandlePointerEventL() of the base class.
       
   696 		CCoeControl::HandlePointerEventL( aPointerEvent );
       
   697 		}
       
   698 	else
       
   699 		{
       
   700 		iLongTapEventConsumed = EFalse;
       
   701 		}
       
   702 	}
       
   703 
   676 
   704 
   677 // ---------------------------------------------------------------------------
   705 // ---------------------------------------------------------------------------
   678 // Draw container contents.
   706 // Draw container contents.
   679 // ---------------------------------------------------------------------------
   707 // ---------------------------------------------------------------------------
   680 //
   708 //
   721 TBool CFsEmailSettingsList::PIMSyncItemVisible()
   749 TBool CFsEmailSettingsList::PIMSyncItemVisible()
   722     {
   750     {
   723     FUNC_LOG;
   751     FUNC_LOG;
   724     return ( iPIMSyncMailboxIndex == -1 ) ? EFalse : ETrue;
   752     return ( iPIMSyncMailboxIndex == -1 ) ? EFalse : ETrue;
   725     }
   753     }
       
   754 
       
   755 
       
   756 // -----------------------------------------------------------------------------
       
   757 // CFsEmailSettingsList::HandleLongTapEventL()
       
   758 // From MAknLongTapDetectorCallBack.
       
   759 // -----------------------------------------------------------------------------
       
   760 //
       
   761 void CFsEmailSettingsList::HandleLongTapEventL(
       
   762 	const TPoint& aPenEventLocation,
       
   763 	const TPoint& aPenEventScreenLocation )
       
   764 	{
       
   765 	// Get the item index based on the position of the tap event.
       
   766 	TInt itemIndex( 0 );
       
   767 	TBool itemSelected =
       
   768 		iListBox->View()->XYPosToItemIndex( aPenEventLocation,
       
   769 											itemIndex );
       
   770 
       
   771 	if ( itemSelected && itemIndex >= 0 )
       
   772 		{
       
   773 		// Update the item index based on the position of the tap event.
       
   774 		iListBox->SetCurrentItemIndex( itemIndex );
       
   775 
       
   776 		if ( SelectedItemIsMailbox() )
       
   777 			{
       
   778 			iView.DisplayStylusPopUpMenu( aPenEventScreenLocation );
       
   779 			}
       
   780 		
       
   781 		iLongTapEventConsumed = ETrue;
       
   782 		}
       
   783 	}
       
   784 
   726 
   785 
   727 // ---------------------------------------------------------------------------
   786 // ---------------------------------------------------------------------------
   728 // Create a list box item for plain text
   787 // Create a list box item for plain text
   729 // ---------------------------------------------------------------------------
   788 // ---------------------------------------------------------------------------
   730 //
   789 //
  1477     iAppUi.LaunchWizardL();
  1536     iAppUi.LaunchWizardL();
  1478 
  1537 
  1479     }
  1538     }
  1480 
  1539 
  1481 // ---------------------------------------------------------------------------
  1540 // ---------------------------------------------------------------------------
  1482 // RemoveAccount
  1541 // RemoveAccountL()
  1483 // Handle account removal from fs mail client
  1542 // Handle account removal from fs mail client.
  1484 // @return void
  1543 // ---------------------------------------------------------------------------
  1485 // ---------------------------------------------------------------------------
  1544 //
  1486 //
  1545 TBool CFsEmailSettingsList::RemoveAccountL()
  1487 void CFsEmailSettingsList::RemoveAccountL()
  1546     {
  1488     {
  1547     FUNC_LOG;
  1489     FUNC_LOG;
  1548     TBool wasDeleted( EFalse );
  1490 
  1549 
  1491     // Make sure that FSMailServer is running, so that the mailbox is removed
  1550     // Make sure that FSMailServer is running, so that the mailbox is removed
  1492     // also from MCE. Let's do it already here, so that the server has some
  1551     // also from MCE. Let's do it already here, so that the server has some
  1493     // time to launch itself before the actual mailbox deletion happens.
  1552     // time to launch itself before the actual mailbox deletion happens.
  1494     TFsEmailUiUtility::EnsureFsMailServerIsRunning( iEikonEnv->WsSession() );
  1553     TFsEmailUiUtility::EnsureFsMailServerIsRunning( iEikonEnv->WsSession() );
  1495 
  1554 
  1496     // if item index is 0 then we are on global settings item
  1555     // if item index is 0 then we are on global settings item
  1497     // this shouldn't be happening, but just in case
  1556     // this shouldn't be happening, but just in case
  1498     iDeletedIndex = iListBox->CurrentItemIndex();
  1557     iDeletedIndex = iListBox->CurrentItemIndex();
       
  1558 
  1499     if ( iDeletedIndex == 0 )
  1559     if ( iDeletedIndex == 0 )
  1500         {
  1560         {
  1501         return;
  1561         return EFalse;
  1502         }
  1562         }
  1503 
  1563 
  1504     // get mailbox
  1564     // get mailbox
  1505     CFSMailBox* mailBox = GetMailboxByIndexLC(iDeletedIndex-1);
  1565     CFSMailBox* mailBox = GetMailboxByIndexLC(iDeletedIndex-1);
  1506     CAknQueryDialog* queryNote = new ( ELeave ) CAknQueryDialog();
  1566     CAknQueryDialog* queryNote = new ( ELeave ) CAknQueryDialog();
  1529             iWaitDialog->RunLD();
  1589             iWaitDialog->RunLD();
  1530             // Set email indicator off.
  1590             // Set email indicator off.
  1531             TFsEmailUiUtility::ToggleEmailIconL(EFalse);
  1591             TFsEmailUiUtility::ToggleEmailIconL(EFalse);
  1532             // delete mailbox and wait event (RequestResponseL)
  1592             // delete mailbox and wait event (RequestResponseL)
  1533             iDeleteMailboxId = iMailClient.DeleteMailBoxByUidL( mailBox->GetId(), *this );
  1593             iDeleteMailboxId = iMailClient.DeleteMailBoxByUidL( mailBox->GetId(), *this );
       
  1594             wasDeleted = ETrue;
  1534             }
  1595             }
  1535         }
  1596         }
  1536     CleanupStack::PopAndDestroy(); // mailBox
  1597     CleanupStack::PopAndDestroy(); // mailBox
       
  1598     return wasDeleted;
  1537     }
  1599     }
  1538 
  1600 
  1539 
  1601 
  1540 // ---------------------------------------------------------------------------
  1602 // ---------------------------------------------------------------------------
  1541 // RequestResponseL
  1603 // RequestResponseL
  1707         TInt newIdx = Min( count-1, currentIdx + itemsOnPage );
  1769         TInt newIdx = Min( count-1, currentIdx + itemsOnPage );
  1708         ListBox()->SetCurrentItemIndexAndDraw( newIdx );
  1770         ListBox()->SetCurrentItemIndexAndDraw( newIdx );
  1709         }
  1771         }
  1710     }
  1772     }
  1711 
  1773 
       
  1774 
       
  1775 // ---------------------------------------------------------------------------
       
  1776 // CFsEmailSettingsList::SelectedItemIsMailbox()
       
  1777 // Used to check if the currently selected item is a mailbox.
       
  1778 // ---------------------------------------------------------------------------
       
  1779 //
       
  1780 TBool CFsEmailSettingsList::SelectedItemIsMailbox() const
       
  1781 	{
       
  1782     // Check if the current view is the main level and the selected list item
       
  1783 	// is a mailbox.
       
  1784 	const TInt index( iListBox->CurrentItemIndex() );
       
  1785 
       
  1786     if ( iCurrentSubView == EFsEmailSettingsMainListView &&
       
  1787     	 index > 0 && index <= iMailboxCount )
       
  1788     	{
       
  1789     	// Is a mailbox.
       
  1790     	return ETrue;
       
  1791     	}
       
  1792 
       
  1793     // Is something else.
       
  1794     return EFalse;
       
  1795 	}
       
  1796 
       
  1797 
       
  1798 // ---------------------------------------------------------------------------
       
  1799 // CFsEmailSettingsList::ClearFocus()
       
  1800 // Removes the focus.
       
  1801 // ---------------------------------------------------------------------------
       
  1802 //
       
  1803 void CFsEmailSettingsList::ClearFocus()
       
  1804 	{
       
  1805 	// This is not a nice way to clear the focus but unless some one comes
       
  1806 	// with a better solution, this will have to do.
       
  1807 	iListBox->ItemDrawer()->SetFlags( CListItemDrawer::EDisableHighlight );
       
  1808 	iListBox->View()->Draw();
       
  1809 	iListBox->ItemDrawer()->ClearFlags( CListItemDrawer::EDisableHighlight );
       
  1810 	}
       
  1811 
       
  1812 
       
  1813 // End of file.