--- a/application/data/PodcastClient_english.rls Sat May 15 11:13:19 2010 +0100
+++ b/application/data/PodcastClient_english.rls Fri May 28 17:43:08 2010 +0100
@@ -142,6 +142,8 @@
rls_string STRING_r_view_remove_all_downloads_cmd "Clear download queue"
rls_string STRING_r_clear_query "Clear download queue?"
rls_string STRING_r_view_remove_download_short_cmd "Remove"
+rls_string STRING_r_view_move_up_short_cmd "Move up"
+rls_string STRING_r_view_move_down_short_cmd "Move down"
rls_string STRING_r_view_remove_download_cmd "Remove download"
rls_string STRING_r_error_notfound "Error: Not found on server"
--- a/application/data/PodcastQueueView.ra Sat May 15 11:13:19 2010 +0100
+++ b/application/data/PodcastQueueView.ra Fri May 28 17:43:08 2010 +0100
@@ -142,6 +142,16 @@
{
txt = STRING_r_view_remove_download_short_cmd;
command = EPodcastRemoveDownload;
+ },
+ STYLUS_POPUP_MENU_ITEM
+ {
+ txt = STRING_r_view_move_up_short_cmd;
+ command = EPodcastMoveDownloadUp;
+ },
+ STYLUS_POPUP_MENU_ITEM
+ {
+ txt = STRING_r_view_move_down_short_cmd;
+ command = EPodcastMoveDownloadDown;
}
};
}
--- a/application/inc/Podcast.hrh Sat May 15 11:13:19 2010 +0100
+++ b/application/inc/Podcast.hrh Fri May 28 17:43:08 2010 +0100
@@ -44,6 +44,8 @@
EPodcastDownloadShow,
EPodcastDeleteShow,
EPodcastRemoveDownload,
+ EPodcastMoveDownloadUp,
+ EPodcastMoveDownloadDown,
EPodcastRemoveAllDownloads,
EPodcastSuspendDownloads,
EPodcastResumeDownloads,
--- a/application/inc/PodcastQueueView.h Sat May 15 11:13:19 2010 +0100
+++ b/application/inc/PodcastQueueView.h Fri May 28 17:43:08 2010 +0100
@@ -78,6 +78,8 @@
void HandleCommandL(TInt aCommand);
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+
+ virtual void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation);
};
#endif
--- a/application/inc/PodcastShowsView.h Sat May 15 11:13:19 2010 +0100
+++ b/application/inc/PodcastShowsView.h Fri May 28 17:43:08 2010 +0100
@@ -96,7 +96,7 @@
void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
void FormatShowInfoListBoxItemL(CShowInfo& aShowInfo, TInt aSizeDownloaded = 0);
- void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation);
+ virtual void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation);
void GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex);
void CreateIconsL();
--- a/application/src/PodcastListView.cpp Sat May 15 11:13:19 2010 +0100
+++ b/application/src/PodcastListView.cpp Fri May 28 17:43:08 2010 +0100
@@ -385,13 +385,14 @@
void CPodcastListView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
{
DP("CPodcastListView::HandleLongTapEventL BEGIN");
+ iListContainer->SetLongTapDetectedL(ETrue);
+
const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1
TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems(
iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight;
if(iStylusPopupMenu && aPenEventLocation.iY < lbHeight)
{
- iListContainer->SetLongTapDetectedL(ETrue);
iStylusPopupMenu->ShowMenu();
iStylusPopupMenu->SetPosition(aPenEventLocation);
}
--- a/application/src/PodcastQueueView.cpp Sat May 15 11:13:19 2010 +0100
+++ b/application/src/PodcastQueueView.cpp Fri May 28 17:43:08 2010 +0100
@@ -67,6 +67,13 @@
iPodcastModel.FeedEngine().AddObserver(this);
iPodcastModel.ShowEngine().AddObserver(this);
+ iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , TPoint(0,0));
+ TResourceReader reader;
+ iCoeEnv->CreateResourceReaderLC(reader,R_QUEUEVIEW_POPUP_MENU);
+ iStylusPopupMenu->ConstructFromResourceL(reader);
+
+ CleanupStack::PopAndDestroy();
+
SetEmptyTextL(R_PODCAST_EMPTY_QUEUE);
}
@@ -246,6 +253,26 @@
}
}
break;
+ case EPodcastMoveDownloadUp:
+ {
+ TInt index = iListContainer->Listbox()->CurrentItemIndex();
+ if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
+ {
+ TRAP_IGNORE(iPodcastModel.ShowEngine().MoveDownloadUpL(iPodcastModel.ActiveShowList()[index]->Uid()));
+ }
+ UpdateListboxItemsL();
+ }
+ break;
+ case EPodcastMoveDownloadDown:
+ {
+ TInt index = iListContainer->Listbox()->CurrentItemIndex();
+ if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
+ {
+ TRAP_IGNORE(iPodcastModel.ShowEngine().MoveDownloadDownL(iPodcastModel.ActiveShowList()[index]->Uid()));
+ }
+ UpdateListboxItemsL();
+ }
+ break;
case EPodcastSuspendDownloads:
{
iPodcastModel.ShowEngine().SuspendDownloads();
@@ -267,27 +294,56 @@
}
void CPodcastQueueView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
-{
+ {
if(aResourceId == R_PODCAST_SHOWSVIEW_MENU)
{
aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, ETrue);
}
-}
+ }
void CPodcastQueueView::UpdateToolbar(TBool aVisible)
-{
+ {
CAknToolbar* toolbar = Toolbar();
- if (toolbar) {
+ if (toolbar)
+ {
RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
TInt itemCnt = fItems.Count();
- if (iListContainer->IsVisible()) {
+ if (iListContainer->IsVisible())
+ {
toolbar->SetToolbarVisibility(aVisible);
- }
+ }
+
toolbar->HideItem(EPodcastRemoveAllDownloads, EFalse, ETrue);
toolbar->SetItemDimmed(EPodcastRemoveAllDownloads, itemCnt == 0, ETrue);
toolbar->HideItem(EPodcastSuspendDownloads,iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);
toolbar->HideItem(EPodcastResumeDownloads,!iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);
toolbar->SetItemDimmed(EPodcastRemoveDownload, itemCnt == 0, ETrue);
+ }
}
+
+void CPodcastQueueView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
+{
+ DP("CPodcastQueueView::HandleLongTapEventL BEGIN");
+ iListContainer->SetLongTapDetectedL(ETrue);
+
+ const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1
+ TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems(
+ iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight;
+
+ if(iStylusPopupMenu && aPenEventLocation.iY < lbHeight)
+ {
+ TBool dimDown = (iListContainer->Listbox()->CurrentItemIndex() >= iPodcastModel.ActiveShowList().Count() - 1 ?
+ ETrue : EFalse);
+ TBool dimUp = (iListContainer->Listbox()->CurrentItemIndex() <= 0 ?
+ ETrue : EFalse);
+
+ iStylusPopupMenu->SetItemDimmed(EPodcastMoveDownloadDown, dimDown);
+ iStylusPopupMenu->SetItemDimmed(EPodcastMoveDownloadUp, dimUp);
+
+ iStylusPopupMenu->ShowMenu();
+ iStylusPopupMenu->SetPosition(aPenEventLocation);
+ }
+
+ DP("CPodcastQueueView::HandleLongTapEventL END");
}
--- a/engine/inc/ShowEngine.h Sat May 15 11:13:19 2010 +0100
+++ b/engine/inc/ShowEngine.h Fri May 28 17:43:08 2010 +0100
@@ -29,6 +29,12 @@
#include "MetaDataReader.h"
#include <sqlite3.h>
+struct TDownload
+ {
+ TUint iIndex;
+ TUint iUid;
+ };
+
class CShowEngine : public CBase, public MHttpClientObserver, public MMetaDataReaderObserver
{
public:
@@ -72,6 +78,9 @@
IMPORT_C void CheckForDeletedShows(TUint aFeedUid);
IMPORT_C CMetaDataReader& MetaDataReader();
+
+ IMPORT_C void MoveDownloadUpL(TUint aUid);
+ IMPORT_C void MoveDownloadDownL(TUint aUid);
private:
// from HttpClientObserver, dont have to be public
@@ -122,6 +131,7 @@
TUint DBGetDownloadsCountL();
void DBAddDownloadL(TUint aUid);
CShowInfo* DBGetNextDownloadL();
+ void DBSwapDownloadsL(TDownload aFirstDL, TDownload aSecondDL);
private:
CHttpClient* iShowClient;
--- a/engine/src/ShowEngine.cpp Sat May 15 11:13:19 2010 +0100
+++ b/engine/src/ShowEngine.cpp Fri May 28 17:43:08 2010 +0100
@@ -1025,6 +1025,52 @@
}
}
+void CShowEngine::DBSwapDownloadsL(TDownload aFirstDL, TDownload aSecondDL)
+ {
+ DP("CShowEngine::DBSwapDownloadsL");
+ _LIT(KSqlStatement, "update downloads set uid=%d where dl_index=%d");
+
+ iSqlBuffer.Format(KSqlStatement, aFirstDL.iUid, aSecondDL.iIndex);
+ sqlite3_stmt *st;
+ int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
+ &st, (const void**) NULL);
+
+ if (rc == SQLITE_OK)
+ {
+ Cleanup_sqlite3_finalize_PushL(st);
+ rc = sqlite3_step(st);
+ if (rc != SQLITE_DONE)
+ {
+ User::Leave(KErrUnknown);
+ }
+ CleanupStack::PopAndDestroy(); // st
+ }
+ else
+ {
+ User::Leave(KErrCorrupt);
+ }
+
+ iSqlBuffer.Format(KSqlStatement, aSecondDL.iUid, aFirstDL.iIndex);
+
+ rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
+ &st, (const void**) NULL);
+
+ if (rc == SQLITE_OK)
+ {
+ Cleanup_sqlite3_finalize_PushL(st);
+ rc = sqlite3_step(st);
+ if (rc != SQLITE_DONE)
+ {
+ User::Leave(KErrUnknown);
+ }
+ CleanupStack::PopAndDestroy(); // st
+ }
+ else
+ {
+ User::Leave(KErrCorrupt);
+ }
+ }
+
EXPORT_C CShowInfo* CShowEngine::GetNextShowByTrackL(CShowInfo* aShowInfo)
{
CShowInfo* nextShow = NULL;
@@ -1387,3 +1433,129 @@
}
}
+EXPORT_C void CShowEngine::MoveDownloadUpL(TUint aUid)
+ {
+ DP("CShowEngine::MoveDownLoadUpL");
+ _LIT(KSqlStatement, "select * from downloads");
+ iSqlBuffer.Format(KSqlStatement);
+
+ sqlite3_stmt *st;
+
+ int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
+ &st, (const void**) NULL);
+
+ if (rc == SQLITE_OK)
+ {
+ RArray<TDownload> downloads;
+ CleanupClosePushL(downloads);
+
+ rc = sqlite3_step(st);
+ Cleanup_sqlite3_finalize_PushL(st);
+
+ TInt selectedIdx = -1;
+ while (rc == SQLITE_ROW && selectedIdx == -1)
+ {
+ TDownload download;
+
+ download.iIndex = sqlite3_column_int(st, 0);
+ download.iUid = sqlite3_column_int(st, 1);
+
+ downloads.Append(download);
+
+ if (download.iUid == aUid)
+ {
+ selectedIdx = downloads.Count()-1;
+ }
+
+ rc = sqlite3_step(st);
+ }
+ CleanupStack::PopAndDestroy();//st, downloads
+
+ // If the selected download was found in the database
+ if (selectedIdx != -1)
+ {
+ // Swap the specified download with the one above it
+ TDownload selectedDownload = downloads[selectedIdx];
+ TDownload previousDownload = downloads[selectedIdx - 1];
+
+ // SQL - Update index (with index of selected download) where uid is of previous download
+ // and update index (with index of previous download) where uid if of selected download
+ DBSwapDownloadsL(selectedDownload, previousDownload);
+ }
+ else
+ {
+ User::Leave(KErrNotFound);
+ }
+
+ CleanupStack::PopAndDestroy(); // downloads
+ }
+ else
+ {
+ User::Leave(KErrCorrupt);
+ }
+ }
+
+EXPORT_C void CShowEngine::MoveDownloadDownL(TUint aUid)
+ {
+ DP("CShowEngine::MoveDownLoadDownL");
+
+ // An upside-down list will result in the download moving down
+ _LIT(KSqlStatement, "select * from downloads order by dl_index desc");
+ iSqlBuffer.Format(KSqlStatement);
+
+ sqlite3_stmt *st;
+
+ int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
+ &st, (const void**) NULL);
+
+ if (rc == SQLITE_OK)
+ {
+ RArray<TDownload> downloads;
+ CleanupClosePushL(downloads);
+
+ rc = sqlite3_step(st);
+ Cleanup_sqlite3_finalize_PushL(st);
+
+ TInt selectedIdx = -1;
+ while (rc == SQLITE_ROW && selectedIdx == -1)
+ {
+ TDownload download;
+
+ download.iIndex = sqlite3_column_int(st, 0);
+ download.iUid = sqlite3_column_int(st, 1);
+
+ downloads.Append(download);
+
+ if (download.iUid == aUid)
+ {
+ selectedIdx = downloads.Count()-1;
+ }
+
+ rc = sqlite3_step(st);
+ }
+ CleanupStack::PopAndDestroy();//st, downloads
+
+ // If the selected download was found in the database
+ if (selectedIdx != -1)
+ {
+ // Swap the specified download with the one above it
+ TDownload selectedDownload = downloads[selectedIdx];
+ TDownload previousDownload = downloads[selectedIdx - 1];
+
+ // SQL - Update index (with index of selected download) where uid is of previous download
+ // and update index (with index of previous download) where uid if of selected download
+ DBSwapDownloadsL(selectedDownload, previousDownload);
+ }
+ else
+ {
+ User::Leave(KErrNotFound);
+ }
+
+ CleanupStack::PopAndDestroy(); // downloads
+ }
+ else
+ {
+ User::Leave(KErrCorrupt);
+ }
+ }
+