Toolbars now hide when connection query appears
authorteknolog
Thu, 25 Feb 2010 20:02:27 +0000
changeset 13 f58e3c482bd9
parent 12 47c8595ffc70
child 14 4e75731546eb
Toolbars now hide when connection query appears
application/inc/PodcastAppui.h
application/inc/PodcastFeedView.h
application/inc/PodcastListView.h
application/inc/PodcastQueueView.h
application/inc/PodcastSearchView.h
application/inc/PodcastShowsView.h
application/src/PodcastAppui.cpp
application/src/PodcastFeedView.cpp
application/src/PodcastListView.cpp
application/src/PodcastQueueView.cpp
application/src/PodcastSearchView.cpp
application/src/PodcastShowsView.cpp
engine/inc/ConnectionEngine.h
engine/inc/HttpClient.h
engine/src/ConnectionEngine.cpp
--- a/application/inc/PodcastAppui.h	Thu Feb 25 18:56:36 2010 +0000
+++ b/application/inc/PodcastAppui.h	Thu Feb 25 20:02:27 2010 +0000
@@ -24,6 +24,8 @@
 #include <akntabgrp.h>
 #include <aknnavide.h> 
 
+#include "ConnectionEngine.h"
+
 class CPodcastMainView;
 class CPodcastFeedView;
 class CPodcastShowsView;
@@ -97,7 +99,8 @@
     MTimeoutObserver& iObserver;
 };
 
-class CPodcastAppUi : public CAknViewAppUi, public MAknTabObserver, MTimeoutObserver
+class CPodcastAppUi : public CAknViewAppUi, public MAknTabObserver, 
+	public MTimeoutObserver, public MConnectionObserver
     {
     public: 
     	CPodcastAppUi(CPodcastModel* aPodcastModel);
@@ -120,6 +123,14 @@
     protected:
     	void HandleTimeout(const CTimeout& aId, TInt aError);
 
+    protected:
+    	// from MConnectionObserver
+    	
+    	void ConnectionSelectionStart();
+    	void ConnectionSelectionEnd();    	
+    	void ConnectCompleteL(TInt /*aErrorCode*/) {}
+    	void Disconnected() {};
+    	
     private:
     	CPodcastMainView *iMainView;
 		CPodcastFeedView* iFeedView;
--- a/application/inc/PodcastFeedView.h	Thu Feb 25 18:56:36 2010 +0000
+++ b/application/inc/PodcastFeedView.h	Thu Feb 25 20:02:27 2010 +0000
@@ -40,6 +40,7 @@
         ~CPodcastFeedView();
         void UpdateItemL(TInt aIndex);
 		void CheckResumeDownload();
+		void UpdateToolbar(TBool aVisible=ETrue);
 
 	protected:
 	    void ConstructL();
@@ -90,7 +91,6 @@
 		void UpdateFeedInfoDataL(CFeedInfo* aFeedInfo, TInt aIndex, TBool aIsUpdating = EFalse);
 		void UpdateFeedInfoStatusL(TUint aFeedUid, TBool aIsUpdating = EFalse);
 
-		void UpdateToolbar();
 		// from MProgressDialogCallback
 		void DialogDismissedL(TInt aButtonId); 
 
--- a/application/inc/PodcastListView.h	Thu Feb 25 18:56:36 2010 +0000
+++ b/application/inc/PodcastListView.h	Thu Feb 25 20:02:27 2010 +0000
@@ -62,6 +62,7 @@
 		CEikFormattedCellListBox* Listbox();
 		void ScrollToVisible();
     	void Draw(const TRect& aRect) const;
+    	
 		CEikFormattedCellListBox * iListbox;		
 
 	protected:
@@ -81,6 +82,8 @@
     {
     public: 
         ~CPodcastListView();
+		virtual void UpdateToolbar(TBool aVisible=ETrue) = 0;
+
 	protected:
 	    void ConstructL();
 		CPodcastListView();	
@@ -145,7 +148,6 @@
 		// from MPointerListener
 		void PointerEventL(const TPointerEvent& aPointerEvent);
 
-		virtual void UpdateToolbar() = 0;
 	protected:
 		 CPodcastListContainer* iListContainer;
 		 /** Previous activated view */
--- a/application/inc/PodcastQueueView.h	Thu Feb 25 18:56:36 2010 +0000
+++ b/application/inc/PodcastQueueView.h	Thu Feb 25 20:02:27 2010 +0000
@@ -37,6 +37,7 @@
 	static CPodcastQueueView* NewL(CPodcastModel& aPodcastModel);
 	static CPodcastQueueView* NewLC(CPodcastModel& aPodcastModel);
 	~CPodcastQueueView();
+	void UpdateToolbar(TBool aVisible=ETrue);
 protected:
 	void ConstructL();
 	CPodcastQueueView(CPodcastModel& aPodcastModel);
@@ -96,8 +97,6 @@
 
 private:
 	void GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex);
-	void UpdateToolbar();
-
 	
 private:
 	
--- a/application/inc/PodcastSearchView.h	Thu Feb 25 18:56:36 2010 +0000
+++ b/application/inc/PodcastSearchView.h	Thu Feb 25 20:02:27 2010 +0000
@@ -32,6 +32,7 @@
         static CPodcastSearchView* NewL(CPodcastModel& aPodcastModel);
         static CPodcastSearchView* NewLC(CPodcastModel& aPodcastModel);
         ~CPodcastSearchView();
+		void UpdateToolbar(TBool aVisible=ETrue);
 
 	protected:
 	    void ConstructL();
@@ -77,9 +78,7 @@
 		 * @param aCommand ID of the command to respond to. 
 		 */
 		void HandleCommandL(TInt aCommand);
-		
-		void UpdateToolbar();
-		
+				
 	private:
 		CPodcastModel& iPodcastModel;		
 		TBool iSearchRunning;
--- a/application/inc/PodcastShowsView.h	Thu Feb 25 18:56:36 2010 +0000
+++ b/application/inc/PodcastShowsView.h	Thu Feb 25 20:02:27 2010 +0000
@@ -40,6 +40,8 @@
 	static CPodcastShowsView* NewL(CPodcastModel& aPodcastModel);
 	static CPodcastShowsView* NewLC(CPodcastModel& aPodcastModel);
 	~CPodcastShowsView();
+	void UpdateToolbar(TBool aVisible=ETrue);
+
 protected:
 	void ConstructL();
 	CPodcastShowsView(CPodcastModel& aPodcastModel);
@@ -101,7 +103,6 @@
 
 private:
 	void GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex);
-	void UpdateToolbar();
 	void DisplayShowInfoDialogL();
 	/*
 	 * Called by CImageHandler when an image has been loaded.
--- a/application/src/PodcastAppui.cpp	Thu Feb 25 18:56:36 2010 +0000
+++ b/application/src/PodcastAppui.cpp	Thu Feb 25 20:02:27 2010 +0000
@@ -45,6 +45,8 @@
     DP("CPodcastAppUi::ConstructL() BEGIN");
     BaseConstructL(CAknAppUi::EAknEnableSkin); 
 
+    iPodcastModel->ConnectionEngine().AddObserver(this);
+    
     DP("Constructing FeedView");
 	iFeedView = CPodcastFeedView::NewL(*iPodcastModel);
 	this->AddViewL(iFeedView);
@@ -272,3 +274,22 @@
 	
 	iTabsVisible=aVisible;
 	}
+
+void CPodcastAppUi::ConnectionSelectionStart()
+	{
+	DP("CPodcastAppUi::ConnectionSelectionStart()");
+	iFeedView->UpdateToolbar(EFalse);
+	iShowsView->UpdateToolbar(EFalse);
+	iQueueView->UpdateToolbar(EFalse);
+	iSearchView->UpdateToolbar(EFalse);
+	}
+
+void CPodcastAppUi::ConnectionSelectionEnd()
+	{
+	DP("CPodcastAppUi::ConnectionSelectionEnd()");
+	iFeedView->UpdateToolbar(ETrue);
+	iFeedView->UpdateToolbar(ETrue);
+	iShowsView->UpdateToolbar(ETrue);
+	iQueueView->UpdateToolbar(ETrue);
+	iSearchView->UpdateToolbar(ETrue);
+	}
--- a/application/src/PodcastFeedView.cpp	Thu Feb 25 18:56:36 2010 +0000
+++ b/application/src/PodcastFeedView.cpp	Thu Feb 25 20:02:27 2010 +0000
@@ -197,9 +197,9 @@
 
 	switch(aEventType)
 		{
-	case EEventEnterKeyPressed:
+//	case EEventEnterKeyPressed:
 	case EEventItemDoubleClicked:
-	case EEventItemActioned:
+//	case EEventItemActioned:
 			{
 			const RFeedInfoArray* sortedItems = NULL;
 			TInt index = iListContainer->Listbox()->CurrentItemIndex();
@@ -547,12 +547,13 @@
 	UpdateToolbar();
 	}
 
-void CPodcastFeedView::UpdateToolbar()
+void CPodcastFeedView::UpdateToolbar(TBool aVisible)
 {
 	CAknToolbar* toolbar = Toolbar();
 	
 	if (toolbar)
 		{
+		toolbar->SetToolbarVisibility(aVisible);
 		toolbar->HideItem(EPodcastUpdateAllFeeds, iUpdatingAllRunning, ETrue);
 		toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !iUpdatingAllRunning, ETrue );
 		toolbar->SetItemDimmed(EPodcastAddFeed, iUpdatingAllRunning, ETrue );
--- a/application/src/PodcastListView.cpp	Thu Feb 25 18:56:36 2010 +0000
+++ b/application/src/PodcastListView.cpp	Thu Feb 25 20:02:27 2010 +0000
@@ -371,8 +371,6 @@
 
 void CPodcastListView::DynInitToolbarL (TInt /*aResourceId*/, CAknToolbar * /*aToolbar*/)
 	{
-	DP("CPodcastListView::DynInitToolbarL");
-	UpdateToolbar();
 	}
 
 
--- a/application/src/PodcastQueueView.cpp	Thu Feb 25 18:56:36 2010 +0000
+++ b/application/src/PodcastQueueView.cpp	Thu Feb 25 20:02:27 2010 +0000
@@ -560,19 +560,22 @@
 		}
 }
 
-void CPodcastQueueView::UpdateToolbar()
+void CPodcastQueueView::UpdateToolbar(TBool aVisible)
 {
 	CAknToolbar* toolbar = Toolbar();
 	
-	RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
-	TInt itemCnt = fItems.Count();
+	if (toolbar) {
+		RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
+		TInt itemCnt = fItems.Count();
+		toolbar->SetToolbarVisibility(aVisible);
 	
-	toolbar->HideItem(EPodcastRemoveDownload, EFalse, ETrue);
-	toolbar->HideItem(EPodcastRemoveAllDownloads, EFalse, ETrue);
-	toolbar->SetItemDimmed(EPodcastRemoveDownload, itemCnt == 0, ETrue);
-	toolbar->SetItemDimmed(EPodcastRemoveAllDownloads, itemCnt == 0, ETrue);
-	toolbar->HideItem(EPodcastSuspendDownloads,iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);
-	toolbar->HideItem(EPodcastResumeDownloads,!iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);	
+		toolbar->HideItem(EPodcastRemoveDownload, EFalse, ETrue);
+		toolbar->HideItem(EPodcastRemoveAllDownloads, EFalse, ETrue);
+		toolbar->SetItemDimmed(EPodcastRemoveDownload, itemCnt == 0, ETrue);
+		toolbar->SetItemDimmed(EPodcastRemoveAllDownloads, itemCnt == 0, ETrue);
+		toolbar->HideItem(EPodcastSuspendDownloads,iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);
+		toolbar->HideItem(EPodcastResumeDownloads,!iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);	
+	}
 }
 
 void CPodcastQueueView::DownloadQueueUpdatedL(TInt /*aDownloadingShows*/, TInt /*aQueuedShows*/)
--- a/application/src/PodcastSearchView.cpp	Thu Feb 25 18:56:36 2010 +0000
+++ b/application/src/PodcastSearchView.cpp	Thu Feb 25 20:02:27 2010 +0000
@@ -284,7 +284,7 @@
 	DP("CPodcastSearchView::OpmlParsingComplete END");
 	}
 
-void CPodcastSearchView::UpdateToolbar()
+void CPodcastSearchView::UpdateToolbar(TBool aVisible)
 {
 	TBool disableAdd = iItemArray->MdcaCount() == 0 || iSearchRunning;
 	
@@ -292,6 +292,7 @@
 	
 	if (toolbar)
 		{
+		toolbar->SetToolbarVisibility(aVisible);
 		toolbar->SetItemDimmed(EPodcastAddSearchResult, disableAdd, ETrue );
 		toolbar->HideItem(EPodcastSearch, iSearchRunning, ETrue );
 		toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !iSearchRunning, ETrue);
--- a/application/src/PodcastShowsView.cpp	Thu Feb 25 18:56:36 2010 +0000
+++ b/application/src/PodcastShowsView.cpp	Thu Feb 25 20:02:27 2010 +0000
@@ -724,10 +724,16 @@
 		}
 	}
 
-void CPodcastShowsView::UpdateToolbar()
+void CPodcastShowsView::UpdateToolbar(TBool aVisible)
 {
 	CAknToolbar* toolbar = Toolbar();
+
+	if (!toolbar) {
+		return;
+	}
 	
+	toolbar->SetToolbarVisibility(aVisible);
+
 	RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
 	TInt itemCnt = fItems.Count();
 
--- a/engine/inc/ConnectionEngine.h	Thu Feb 25 18:56:36 2010 +0000
+++ b/engine/inc/ConnectionEngine.h	Thu Feb 25 20:02:27 2010 +0000
@@ -33,6 +33,8 @@
 class MConnectionObserver
 	{
 public:
+	virtual void ConnectionSelectionStart() = 0;
+	virtual void ConnectionSelectionEnd() = 0;
 	virtual void ConnectCompleteL(TInt aErrorCode) = 0;
 	virtual void Disconnected() = 0;
 	};
@@ -89,6 +91,9 @@
 	TBool ConnectionSettingL();
 	
 	void ReportConnection(TInt aError);
+	void ReportConnectionSelectionStart();
+	void ReportConnectionSelectionEnd();
+	
 private:
 	RConnection                   iConnection;
 	RSocketServ                   iSocketServer;
--- a/engine/inc/HttpClient.h	Thu Feb 25 18:56:36 2010 +0000
+++ b/engine/inc/HttpClient.h	Thu Feb 25 20:02:27 2010 +0000
@@ -49,6 +49,8 @@
 	void ConnectHttpSessionL();
 	void ConnectCompleteL(TInt aErrorCode);
 	void Disconnected();
+	void ConnectionSelectionStart() {}
+	void ConnectionSelectionEnd() {}
 	void DoGetAfterConnectL();
 private:
 	RHTTPSession iSession;	
--- a/engine/src/ConnectionEngine.cpp	Thu Feb 25 18:56:36 2010 +0000
+++ b/engine/src/ConnectionEngine.cpp	Thu Feb 25 20:02:27 2010 +0000
@@ -134,13 +134,13 @@
 	CMManager::EShowDestinations;
 
 	TBearerFilterArray filter;
-
+	ReportConnectionSelectionStart();
 	selected = settings->RunApplicationSettingsL( iUserSelection,
 			listedItems,
 			filter );
 
 	CleanupStack::PopAndDestroy( settings );
-
+	ReportConnectionSelectionEnd();
 	return selected;
 	}
 
@@ -281,3 +281,25 @@
 		iObserverArray[noObservers]->ConnectCompleteL(aError);
 		}
 	}
+
+
+void CConnectionEngine::ReportConnectionSelectionStart()
+	{
+	TInt noObservers = iObserverArray.Count();
+	while(noObservers)
+		{
+		noObservers--;
+		iObserverArray[noObservers]->ConnectionSelectionStart();
+		}
+	}
+
+
+void CConnectionEngine::ReportConnectionSelectionEnd()
+	{
+	TInt noObservers = iObserverArray.Count();
+	while(noObservers)
+		{
+		noObservers--;
+		iObserverArray[noObservers]->ConnectionSelectionEnd();
+		}
+	}