--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sipplugins/sippsipsettingsui/src/sipsettingscontainer.cpp Tue Feb 02 01:03:15 2010 +0200
@@ -0,0 +1,659 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Container for SIPSettings view
+*
+*/
+
+
+// INCLUDE FILES
+#include <aknlists.h>
+#include <csxhelp/cp.hlp.hrh>
+#include <gsfwviewuids.h>
+#include <gssipsettingspluginrsc.rsg>
+#include <gssipsettingsplugin.mbg>
+#include <AknIconArray.h>
+#include <aknsutils.h> //for loading icons
+#include <akntitle.h>
+#include <eikspane.h>
+#include <aknnavi.h>
+#include <stringloader.h>
+#include "sipsettingscontainer.h"
+#include "sipsettingsmodel.h"
+#include "sipsettingsplugin.h"
+#include "gssippluginlogger.h"
+
+#include "barsread.h"
+
+// LOCAL CONSTANTS AND MACROS
+
+const TInt KNumberOfControls = 1;
+const TInt KControlListBox = 0;
+const TInt KUnknownListBoxIndex = -1;
+const TInt KGranularity = 1;
+
+
+// MODULE DATA STRUCTURES
+
+/**
+ * Listbox item drawer for CSIPSettingsContainer.
+ */
+class CSIPSettingsContainer::CItemDrawer :
+ public CFormattedCellListBoxItemDrawer
+ {
+ public: // interface
+ /**
+ * Constructor.
+ */
+ inline CItemDrawer( MTextListBoxModel* aTextListBoxModel,
+ const CFont* aFont,
+ CFormattedCellListBoxData* aFormattedCellData );
+
+ /**
+ * Sets iMod to aModel.
+ */
+ inline void SetModel( CSIPSettingsModel& aModel );
+
+ private: // From CListItemDrawer returns list item properties
+ TListItemProperties Properties( TInt aItemIndex ) const;
+
+ private: // data members
+ // Ref: array of SIP Settings.
+ CSIPSettingsModel* iMod;
+ };
+
+/**
+ * Listbox for CSIPSettingsContainer
+ */
+class CSIPSettingsContainer::CListBox : public CAknDoubleGraphicStyleListBox
+ {
+ public: // constructor
+ inline CListBox();
+ inline CItemDrawer* ItemDrawer() const;
+ inline void SetIconArray( CArrayPtr<CGulIcon>* aIconArray );
+ inline CArrayPtr<CGulIcon>* IconArray();
+ public: // from CEikFormattedCellListBox
+ void CreateItemDrawerL();
+
+ };
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::CItemDrawer::CItemDrawer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+inline
+CSIPSettingsContainer::CItemDrawer::CItemDrawer
+ ( MTextListBoxModel* aTextListBoxModel,
+ const CFont* aFont,
+ CFormattedCellListBoxData* aFormattedCellData ) :
+ CFormattedCellListBoxItemDrawer(
+ aTextListBoxModel,
+ aFont,
+ aFormattedCellData )
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::CItemDrawer::CItemDrawer" )
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::CItemDrawer::SetModel
+// Sets model for underlining default sip profile.
+// -----------------------------------------------------------------------------
+//
+inline
+void CSIPSettingsContainer::CItemDrawer::SetModel( CSIPSettingsModel& aModel )
+ {
+ iMod = &aModel;
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::CItemDrawer::Properties
+// Gets list box item properties.
+// -----------------------------------------------------------------------------
+//
+TListItemProperties CSIPSettingsContainer::CItemDrawer::Properties(
+ TInt aItemIndex ) const
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::CItemDrawer::Properties" )
+ TListItemProperties result =
+ CFormattedCellListBoxItemDrawer::Properties( aItemIndex );
+
+ if ( iMod && ( aItemIndex == iMod->DefaultProfileIndex() ) )
+ {
+ result.SetUnderlined(ETrue);
+ }
+
+ return result;
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::CListBox::CListBox
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+inline
+CSIPSettingsContainer::CListBox::CListBox()
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::CListBox::CListBox" )
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::CListBox::ItemDrawer
+// Gets the object used by this list box view to draw its items.
+// -----------------------------------------------------------------------------
+//
+inline
+CSIPSettingsContainer::CItemDrawer*
+ CSIPSettingsContainer::CListBox::ItemDrawer( ) const
+ {
+ return static_cast<CSIPSettingsContainer::CItemDrawer*>(
+ CAknDoubleGraphicStyleListBox::ItemDrawer() );
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::CListBox::SetIconArray
+// Sets the icon array used when drawing bitmaps.
+// -----------------------------------------------------------------------------
+//
+inline
+void CSIPSettingsContainer::CListBox::SetIconArray(
+ CArrayPtr<CGulIcon>* aIconArray )
+ {
+ ItemDrawer()->ColumnData()->SetIconArray( aIconArray );
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::CListBox::IconArray
+// Queries the icon array used when drawing bitmaps for the listbox items.
+// -----------------------------------------------------------------------------
+//
+inline
+CArrayPtr<CGulIcon>* CSIPSettingsContainer::CListBox::IconArray()
+ {
+ return ItemDrawer()->ColumnData()->IconArray();
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::CListBox::CreateItemDrawerL
+// Chooses which itemdrawer to use.
+// -----------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::CListBox::CreateItemDrawerL()
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::CListBox::CreateItemDrawerL" )
+ CFormattedCellListBoxData* formattedData = CFormattedCellListBoxData::NewL();
+ CleanupStack::PushL( formattedData );
+ iItemDrawer = new(ELeave) CSIPSettingsContainer::CItemDrawer(
+ Model(),
+ iEikonEnv->NormalFont(),
+ formattedData );
+ CleanupStack::Pop( formattedData );
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::CSIPSettingsContainer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSIPSettingsContainer::CSIPSettingsContainer( CSIPSettingsPlugin* aObserver )
+ : iObs( aObserver )
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::CSIPSettingsContainer" )
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::ConstructL(
+ const TRect& aRect,
+ TInt aActiveIndex,
+ CSIPSettingsModel* aModel )
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::ConstructL Start" )
+ // Change the text on the title pane
+ HBufC* titleBuf = StringLoader::LoadLC( R_QTN_APP_CAPTION_STRING );
+
+ CEikStatusPane* sp = iAvkonAppUi->StatusPane();
+ CAknTitlePane* title = static_cast<CAknTitlePane*>(
+ sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+ title->SetTextL( *titleBuf );
+ CleanupStack::PopAndDestroy( titleBuf );
+
+ // Set navipane to default
+ CAknNavigationControlContainer* naviContainer =
+ static_cast<CAknNavigationControlContainer*>
+ (sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi ) ) );
+ naviContainer->PushDefaultL();
+
+ CreateWindowL();
+ iLongTapDetector = CAknLongTapDetector::NewL( this );
+
+ SetLongPress( EFalse );
+
+ // Initialize list box outlook
+ iListBox = new ( ELeave ) CListBox;
+ iListBox->SetContainerWindowL( *this );
+ iListBox->ConstructL( this, EAknListBoxSelectionList );
+
+ iListBox->View()->ItemDrawer()->SetFlags( CTextListItemDrawer::ESingleClickEnabled );
+
+ CAknIconArray* icons = new (ELeave) CAknIconArray( KGranularity );
+ CleanupStack::PushL( icons );
+
+ // locked icon
+ CGulIcon* iconLocked = AknsUtils::CreateGulIconL(
+ AknsUtils::SkinInstance(),
+ KAknsIIDQgnIndiSettProtectedAdd,
+ KGSDefaultSIPIconFileName,
+ EMbmGssipsettingspluginQgn_prop_sip_locked,
+ EMbmGssipsettingspluginQgn_prop_sip_locked );
+
+ CleanupStack::PushL( iconLocked );
+ icons->AppendL( iconLocked );
+ CleanupStack::Pop( iconLocked );
+
+ // empty icon
+ CGulIcon* iconEmpty = AknsUtils::CreateGulIconL(
+ AknsUtils::SkinInstance(),
+ KAknsIIDQgnIndiSettProtectedAdd,
+ KGSDefaultSIPIconFileName,
+ EMbmGssipsettingspluginEmpty13x13,
+ EMbmGssipsettingspluginEmpty13x13 );
+
+ CleanupStack::PushL( iconEmpty );
+ icons->AppendL( iconEmpty );
+ CleanupStack::Pop( iconEmpty );
+
+ iListBox->SetIconArray( icons );
+ CleanupStack::Pop( icons );
+
+ iListBox->ItemDrawer()->SetModel( *aModel );
+
+ iListBox->CreateScrollBarFrameL( ETrue );
+ iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
+ CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
+
+ // Set empty listbox's text.
+ HBufC* text = iCoeEnv->AllocReadResourceLC( R_GS_SIP_NO_SIP_SETTINGS );
+ iListBox->View()->SetListEmptyTextL( *text );
+ CleanupStack::PopAndDestroy( text );
+
+ // Set the model
+ iListBox->SetListBoxObserver( iObs );
+ iListBox->Model()->SetItemTextArray( aModel );
+ // List box won't delete model, the Controller object will take care of it
+ iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+
+ // Set limits to the view & activate it
+ SetRect( aRect );
+ ActivateL();
+
+ if ( aActiveIndex != KUnknownListBoxIndex &&
+ aModel->NumOfProfiles() > 0 )
+ {
+ iListBox->SetCurrentItemIndex( aActiveIndex );
+ }
+
+ iTimer = CGSSIPTimer::NewL( *this, *(iListBox->View()->ItemDrawer()) );
+
+ iStylusPopupMenu = NULL;
+
+ DrawNow();
+ __GSLOGSTRING("CSIPSettingsContainer::ConstructL End" )
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::~CSIPSettingsContainer()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSIPSettingsContainer::~CSIPSettingsContainer()
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::~CSIPSettingsContainer" )
+ delete iListBox;
+ delete iLongTapDetector;
+ iLongTapDetector = NULL;
+ delete iStylusPopupMenu;
+ iStylusPopupMenu = NULL;
+ delete iTimer;
+ iTimer = NULL;
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::CurrentIndex()
+// Returns the current active index from the list box
+// -----------------------------------------------------------------------------
+//
+TInt CSIPSettingsContainer::CurrentIndex()
+ {
+ return iListBox->CurrentItemIndex();
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::ListItemModifiedL
+// Selects the existing index and redraws the view
+// -----------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::ListItemModifiedL( TInt aIndex )
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::ListItemModifiedL" )
+ iListBox->SetCurrentItemIndex( aIndex );
+ iListBox->HandleItemAdditionL();
+
+ if ( iListBox->CurrentItemIndex() == KUnknownListBoxIndex )
+ {
+ if ( iListBox->Model()->ItemTextArray()->MdcaCount() > 0 )
+ {
+ iListBox->SetCurrentItemIndex(
+ iListBox->Model()->ItemTextArray()->MdcaCount() - 1 );
+ }
+ }
+
+ iListBox->DrawNow();
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::ListItemDeletedL
+// Selects the existing index and redraws the view
+// -----------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::ListItemDeletedL()
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::ListItemDeletedL" )
+ iListBox->HandleItemRemovalL();
+
+ if ( iListBox->CurrentItemIndex() == KUnknownListBoxIndex )
+ {
+ if ( iListBox->Model()->ItemTextArray()->MdcaCount() > 0 )
+ {
+ iListBox->SetCurrentItemIndex(
+ iListBox->Model()->ItemTextArray()->MdcaCount() - 1 );
+ }
+ }
+
+ iListBox->DrawNow();
+ }
+
+// ---------------------------------------------------------------------------
+// CSIPSettingsContainer::CurrentFeatureId()
+//
+// ---------------------------------------------------------------------------
+//
+TInt CSIPSettingsContainer::CurrentFeatureId( )
+ {
+ return CurrentIndex();
+ }
+
+// ---------------------------------------------------------------------------
+// Sets observer for MSK label updations.
+// ---------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::SetMiddleSoftkeyObserver(
+ MGsFWMSKObserver* aObserver )
+ {
+ if ( !iMSKObserver && aObserver )
+ {
+ iMSKObserver = aObserver;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::CountComponentControls()
+// Returns the amount of controls on the view
+// -----------------------------------------------------------------------------
+//
+TInt CSIPSettingsContainer::CountComponentControls() const
+ {
+ return KNumberOfControls;
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::ComponentControl
+// Returns list box
+// -----------------------------------------------------------------------------
+//
+CCoeControl* CSIPSettingsContainer::ComponentControl(
+ TInt aIndex ) const
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::ComponentControl" )
+ CCoeControl* cntrl = NULL;
+
+ if ( aIndex == KControlListBox )
+ {
+ cntrl = iListBox;
+ }
+
+ return cntrl;
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::SizeChanged
+// Sets new size for the list box
+// -----------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::SizeChanged()
+ {
+ iListBox->SetRect( Rect() );
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::OfferKeyEventL()
+// Handles the key events, pushes them to list box
+// -----------------------------------------------------------------------------
+//
+TKeyResponse CSIPSettingsContainer::OfferKeyEventL(
+ const TKeyEvent& aKeyEvent,
+ TEventCode aType )
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::OfferKeyEventL" )
+ if ( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
+ {
+ iListBox->View()->ItemDrawer()->ClearFlags( CTextListItemDrawer::EDisableHighlight );
+
+ iTimer->StartTimer();
+
+ }
+
+ if ( aType == EEventKey && aKeyEvent.iCode == EKeyBackspace )
+ {
+ iObs->HandleCommandL( EGSCmdAppDelete );
+ return EKeyWasConsumed;
+ }
+
+ // Pass the key event to list box
+ return iListBox->OfferKeyEventL( aKeyEvent, aType );
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::FocusChanged()
+// Responds to a change in focus
+// -----------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::FocusChanged( TDrawNow aDrawNow )
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::FocusChanged" )
+ CCoeControl::FocusChanged( aDrawNow );
+ if( iListBox )
+ {
+ iListBox->SetFocus( IsFocused(), aDrawNow );
+ }
+ iTimer -> StopTimer();
+
+ }
+
+// ---------------------------------------------------------------------------
+// CSIPSettingsContainer::HandleResourceChange
+// Resource change handling
+// ---------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::HandleResourceChange( TInt aType )
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::HandleResourceChange" )
+ //Handle layout orientation or skin change
+ if ( aType == KEikDynamicLayoutVariantSwitch )
+ {
+ TRect mainPaneRect;
+ AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
+ mainPaneRect);
+ SetRect( mainPaneRect );
+ }
+ CCoeControl::HandleResourceChange( aType );
+ }
+
+// ---------------------------------------------------------------------------
+// CSIPSettingsContainer::GetHelpContext(TCoeHelpContext& aContext) const
+// Gets Help
+//
+// ---------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::GetHelpContext(
+ TCoeHelpContext& aContext ) const
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::GetHelpContext" )
+ aContext.iMajor = KUidGS;
+ aContext.iContext = KSIP_HLP_MAIN;
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::HandleLongTapEventL()
+// Responds to Long Tap Event
+// -----------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /*aPenEventScreenLocation*/ )
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::HandleLongTapEventL" )
+
+ iPoint = aPenEventLocation;
+
+ delete iStylusPopupMenu;
+ iStylusPopupMenu = NULL;
+
+ iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , PenEventLocation() );
+ TResourceReader reader;
+ iCoeEnv->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU );
+ iStylusPopupMenu->ConstructFromResourceL( reader );
+ CleanupStack::PopAndDestroy();
+
+ iStylusPopupMenu->ShowMenu();
+ iStylusPopupMenu->SetPosition( PenEventLocation() );
+ SetLongPress( ETrue );
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::HandleLongTapEventL()
+// Responds to Long Tap Event
+// -----------------------------------------------------------------------------
+//
+TPoint CSIPSettingsContainer::PenEventLocation()
+ {
+ return iPoint;
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::ProcessCommandL()
+// Handle ProcessCommandL
+// -----------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::ProcessCommandL( TInt aCommand )
+ {
+ __GSLOGSTRING1("CSIPSettingsContainer::ProcessCommandL aCommand: %d", aCommand)
+ switch( aCommand )
+ {
+ case EGSCmdAppEdit:
+ iObs->EditProfileL();
+ break;
+
+ case EGSCmdAppDelete:
+ iObs->DeleteProfileL();
+ break;
+
+ case EGSCmdAppDefault:
+ iObs->ChangeDefaultProfileL();
+ default:
+ break;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::HandlePointerEventL()
+// Responds to a Pointer Event.
+// -----------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::HandlePointerEventL" )
+ iListBox->View()->ItemDrawer()->ClearFlags( CTextListItemDrawer::EDisableHighlight );
+ DrawNow();
+ iPointerEvent = aPointerEvent;
+ CCoeControl::HandlePointerEventL( aPointerEvent );
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::IfPointerEvent()
+// Check if it is Pointer Event.
+// -----------------------------------------------------------------------------
+//
+TBool CSIPSettingsContainer::IfPointerEvent()
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::IfPointerEvent" )
+ return !( iTimer->IsStarted() );
+ }
+
+void CSIPSettingsContainer::SetEmphasis( CCoeControl* /*aMenuControl*/, TBool /*aEmphasis*/ )
+ {
+
+ }
+
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::LongPressStatus()
+// Check if Long Press happen.
+// -----------------------------------------------------------------------------
+//
+TBool CSIPSettingsContainer::LongPressStatus()
+ {
+ return iLongPress;
+ }
+
+// -----------------------------------------------------------------------------
+// CSIPSettingsContainer::SetLongPress()
+// Set Long Press.
+// -----------------------------------------------------------------------------
+//
+void CSIPSettingsContainer::SetLongPress(TBool aLongPress )
+ {
+ __GSLOGSTRING("CSIPSettingsContainer::SetLongPress" )
+ this->iLongPress = aLongPress;
+ }
+
+
+CAknLongTapDetector* CSIPSettingsContainer::LongTapDetector()
+ {
+ return iLongTapDetector;
+ }
+
+
+TPointerEvent CSIPSettingsContainer::PointerEvent()
+ {
+ return iPointerEvent;
+ }
+
+
+// End of File