# HG changeset patch # User Brendan Donegan # Date 1275599884 -3600 # Node ID 2e626f5a52c8dccc8173da75bcae0796ad148982 # Parent 78d1b03a94ffd0ebe5cffe3b849d778b76afb9d7# Parent bef51e67100fcc8df3075d79077f01ce8f50da33 Merge diff -r bef51e67100f -r 2e626f5a52c8 application/data/PodcastClient_english.rls --- a/application/data/PodcastClient_english.rls Thu May 27 17:06:11 2010 +0100 +++ b/application/data/PodcastClient_english.rls Thu Jun 03 22:18:04 2010 +0100 @@ -147,6 +147,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" diff -r bef51e67100f -r 2e626f5a52c8 application/data/PodcastQueueView.ra --- a/application/data/PodcastQueueView.ra Thu May 27 17:06:11 2010 +0100 +++ b/application/data/PodcastQueueView.ra Thu Jun 03 22:18:04 2010 +0100 @@ -142,6 +142,17 @@ { 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; } + */ }; } diff -r bef51e67100f -r 2e626f5a52c8 application/inc/Podcast.hrh --- a/application/inc/Podcast.hrh Thu May 27 17:06:11 2010 +0100 +++ b/application/inc/Podcast.hrh Thu Jun 03 22:18:04 2010 +0100 @@ -44,6 +44,8 @@ EPodcastDownloadShow, EPodcastDeleteShow, EPodcastRemoveDownload, + EPodcastMoveDownloadUp, + EPodcastMoveDownloadDown, EPodcastRemoveAllDownloads, EPodcastSuspendDownloads, EPodcastResumeDownloads, diff -r bef51e67100f -r 2e626f5a52c8 application/inc/PodcastQueueView.h --- a/application/inc/PodcastQueueView.h Thu May 27 17:06:11 2010 +0100 +++ b/application/inc/PodcastQueueView.h Thu Jun 03 22:18:04 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 diff -r bef51e67100f -r 2e626f5a52c8 application/inc/PodcastShowsView.h --- a/application/inc/PodcastShowsView.h Thu May 27 17:06:11 2010 +0100 +++ b/application/inc/PodcastShowsView.h Thu Jun 03 22:18:04 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(); diff -r bef51e67100f -r 2e626f5a52c8 application/src/PodcastListView.cpp --- a/application/src/PodcastListView.cpp Thu May 27 17:06:11 2010 +0100 +++ b/application/src/PodcastListView.cpp Thu Jun 03 22:18:04 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); } diff -r bef51e67100f -r 2e626f5a52c8 application/src/PodcastQueueView.cpp --- a/application/src/PodcastQueueView.cpp Thu May 27 17:06:11 2010 +0100 +++ b/application/src/PodcastQueueView.cpp Thu Jun 03 22:18:04 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,30 @@ } } break; + case EPodcastMoveDownloadUp: + { + //iPodcastModel.ShowEngine().SuspendDownloads(); + TInt index = iListContainer->Listbox()->CurrentItemIndex(); + if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) + { + TRAP_IGNORE(iPodcastModel.ShowEngine().MoveDownloadUpL(iPodcastModel.ActiveShowList()[index]->Uid())); + } + //iPodcastModel.ShowEngine().ResumeDownloadsL(); + UpdateListboxItemsL(); + } + break; + case EPodcastMoveDownloadDown: + { + //iPodcastModel.ShowEngine().SuspendDownloads(); + TInt index = iListContainer->Listbox()->CurrentItemIndex(); + if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) + { + TRAP_IGNORE(iPodcastModel.ShowEngine().MoveDownloadDownL(iPodcastModel.ActiveShowList()[index]->Uid())); + } + //iPodcastModel.ShowEngine().ResumeDownloadsL(); + UpdateListboxItemsL(); + } + break; case EPodcastSuspendDownloads: { iPodcastModel.ShowEngine().SuspendDownloads(); @@ -267,27 +298,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"); } diff -r bef51e67100f -r 2e626f5a52c8 engine/group/bld.inf --- a/engine/group/bld.inf Thu May 27 17:06:11 2010 +0100 +++ b/engine/group/bld.inf Thu Jun 03 22:18:04 2010 +0100 @@ -1,3 +1,4 @@ + /* * Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB * diff -r bef51e67100f -r 2e626f5a52c8 engine/inc/ShowEngine.h --- a/engine/inc/ShowEngine.h Thu May 27 17:06:11 2010 +0100 +++ b/engine/inc/ShowEngine.h Thu Jun 03 22:18:04 2010 +0100 @@ -29,6 +29,12 @@ #include "MetaDataReader.h" #include +struct TDownload + { + TUint iIndex; + TUint iUid; + }; + typedef enum TShowFilter { EAllShows, @@ -81,6 +87,9 @@ IMPORT_C void CheckForDeletedShows(TUint aFeedUid); IMPORT_C CMetaDataReader& MetaDataReader(); IMPORT_C void SetShowFilter(TShowFilter aFilter); + IMPORT_C void MoveDownloadUpL(TUint aUid); + IMPORT_C void MoveDownloadDownL(TUint aUid); + private: // from HttpClientObserver, dont have to be public void Connected(CHttpClient* aClient); @@ -130,6 +139,7 @@ TUint DBGetDownloadsCountL(); void DBAddDownloadL(TUint aUid); CShowInfo* DBGetNextDownloadL(); + void DBSwapDownloadsL(TDownload aFirstDL, TDownload aSecondDL); private: CHttpClient* iShowClient; @@ -137,20 +147,20 @@ CPodcastModel& iPodcastModel; // observers that will receive callbacks - RArray iObservers; + RArray iObservers; // The show we are currently downloading CShowInfo* iShowDownloading; - TUint iDownloadErrors; + TUint iDownloadErrors; - CMetaDataReader* iMetaDataReader; + CMetaDataReader* iMetaDataReader; - RApaLsSession iApaSession; + RApaLsSession iApaSession; TBuf8<512> iRecogBuffer; sqlite3& iDB; - TBuf iSqlBuffer; - TShowFilter iShowFilter; + TBuf iSqlBuffer; + TShowFilter iShowFilter; }; #endif /*SHOWENGINE_H_*/ diff -r bef51e67100f -r 2e626f5a52c8 engine/src/ShowEngine.cpp --- a/engine/src/ShowEngine.cpp Thu May 27 17:06:11 2010 +0100 +++ b/engine/src/ShowEngine.cpp Thu Jun 03 22:18:04 2010 +0100 @@ -1042,6 +1042,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; @@ -1404,7 +1450,129 @@ } } -EXPORT_C void CShowEngine::SetShowFilter(TShowFilter aFilter) +EXPORT_C void CShowEngine::MoveDownloadUpL(TUint aUid) { - iShowFilter = aFilter; + 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 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 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); + } + } +