101 // Two-Phased Constructor |
103 // Two-Phased Constructor |
102 // --------------------------------------------------------------------------- |
104 // --------------------------------------------------------------------------- |
103 // |
105 // |
104 CMPXCollectionUiHelperImp* CMPXCollectionUiHelperImp::NewLC(const TUid& aModeId) |
106 CMPXCollectionUiHelperImp* CMPXCollectionUiHelperImp::NewLC(const TUid& aModeId) |
105 { |
107 { |
106 CMPXCollectionUiHelperImp* self = new( ELeave ) CMPXCollectionUiHelperImp(); |
108 |
107 CleanupStack::PushL( self ); |
109 CMPXCollectionUiHelperImp* self(NULL); |
108 self->ConstructL(aModeId); |
110 |
109 return self; |
111 if ( aModeId == KMcModeDefault ) |
|
112 { |
|
113 self = reinterpret_cast<CMPXCollectionUiHelperImp*>(Dll::Tls()); |
|
114 if ( !self ) |
|
115 { |
|
116 self = new( ELeave ) CMPXCollectionUiHelperImp(); |
|
117 CleanupStack::PushL( self ); |
|
118 self->ConstructL(aModeId); |
|
119 Dll::SetTls( self ); |
|
120 } |
|
121 else |
|
122 { |
|
123 self->iRefCount++; |
|
124 CleanupStack::PushL( self ); |
|
125 } |
|
126 |
|
127 return self; |
|
128 } |
|
129 else |
|
130 { |
|
131 self = new( ELeave ) CMPXCollectionUiHelperImp(); |
|
132 CleanupStack::PushL( self ); |
|
133 self->ConstructL(aModeId); |
|
134 return self; |
|
135 } |
110 } |
136 } |
111 |
137 |
112 // --------------------------------------------------------------------------- |
138 // --------------------------------------------------------------------------- |
113 // Virtual Destructor |
139 // Virtual Destructor |
114 // --------------------------------------------------------------------------- |
140 // --------------------------------------------------------------------------- |
1014 // Frees this object |
1046 // Frees this object |
1015 // --------------------------------------------------------------------------- |
1047 // --------------------------------------------------------------------------- |
1016 // |
1048 // |
1017 void CMPXCollectionUiHelperImp::Close() |
1049 void CMPXCollectionUiHelperImp::Close() |
1018 { |
1050 { |
1019 delete this; |
1051 |
|
1052 ASSERT( iRefCount > 0 ); |
|
1053 if ( --iRefCount == 0 ) |
|
1054 { |
|
1055 // last client released |
|
1056 CMPXCollectionUiHelperImp* s = reinterpret_cast<CMPXCollectionUiHelperImp*>( Dll::Tls() ); |
|
1057 if ( s ) |
|
1058 { |
|
1059 if ( s == this ) |
|
1060 { |
|
1061 delete this; |
|
1062 Dll::SetTls( NULL ); |
|
1063 } |
|
1064 } |
|
1065 } |
1020 } |
1066 } |
1021 |
1067 |
1022 // --------------------------------------------------------------------------- |
1068 // --------------------------------------------------------------------------- |
1023 // Test if the specified title already exists for the category |
1069 // Test if the specified title already exists for the category |
1024 // --------------------------------------------------------------------------- |
1070 // --------------------------------------------------------------------------- |
1209 // |
1255 // |
1210 void CMPXCollectionUiHelperImp::HandleOpenL(const CMPXCollectionPlaylist& /*aPlaylist*/, TInt /*aError*/) |
1256 void CMPXCollectionUiHelperImp::HandleOpenL(const CMPXCollectionPlaylist& /*aPlaylist*/, TInt /*aError*/) |
1211 { |
1257 { |
1212 // Not used |
1258 // Not used |
1213 ASSERT(0); |
1259 ASSERT(0); |
|
1260 } |
|
1261 |
|
1262 // --------------------------------------------------------------------------- |
|
1263 // From MMPXCollectionObserver |
|
1264 // --------------------------------------------------------------------------- |
|
1265 // |
|
1266 void CMPXCollectionUiHelperImp::HandleCommandComplete(CMPXCommand* aCommandResult, TInt aError) |
|
1267 { |
|
1268 MPX_DEBUG3("CMPXCollectionUiHelperImp::HandleCommandComplete iTask=%d, aError=%d", |
|
1269 iTask, aError); |
|
1270 |
|
1271 if( iTask == ETaskIncAddMedia && iInputMedia ) |
|
1272 { |
|
1273 if ( iChunkNumber == 0 ) |
|
1274 { |
|
1275 // save playlistId in input media & use it for subsequent appending operations |
|
1276 if( aCommandResult ) |
|
1277 { |
|
1278 TMPXItemId playlistId = |
|
1279 aCommandResult->ValueTObjectL<TMPXItemId>(KMPXCommandColAddRtnId); |
|
1280 |
|
1281 iInputMedia->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, playlistId); |
|
1282 } |
|
1283 |
|
1284 iChunkNumber++; // move on to next chunk |
|
1285 |
|
1286 CompleteTask(iTask, aError); |
|
1287 } |
|
1288 else if ( iChunkNumber == iTotalChunkNumber-1 ) // last chunk |
|
1289 { |
|
1290 CompleteTask(ETaskIncFinish, aError); // finish inc task |
|
1291 } |
|
1292 else // intermedia chunks |
|
1293 { |
|
1294 iChunkNumber++; // move on to next chunk |
|
1295 |
|
1296 CompleteTask(iTask, aError); |
|
1297 } |
|
1298 } |
|
1299 else if( iTask == ETaskIncAppendMedia && iInputMedia ) |
|
1300 { |
|
1301 // last chunk |
|
1302 // for the case that there is only one chunk (first & last chunk at the same |
|
1303 // time), Inc Add is not used |
|
1304 if( iChunkNumber == iTotalChunkNumber-1 ) |
|
1305 { |
|
1306 // update input media as well |
|
1307 FillInPlaylistDetailsL(*iInputMedia); |
|
1308 CompleteTask(ETaskIncFinish, aError); |
|
1309 } |
|
1310 else // intermediate chunks, including first chunk |
|
1311 { |
|
1312 iChunkNumber++; |
|
1313 CompleteTask(iTask, aError); |
|
1314 } |
|
1315 } |
1214 } |
1316 } |
1215 |
1317 |
1216 // ---------------------------------------------------------------------------- |
1318 // ---------------------------------------------------------------------------- |
1217 // Handles completion of moving an object, just a proxy |
1319 // Handles completion of moving an object, just a proxy |
1218 // ---------------------------------------------------------------------------- |
1320 // ---------------------------------------------------------------------------- |
1639 // --------------------------------------------------------------------------- |
1741 // --------------------------------------------------------------------------- |
1640 // |
1742 // |
1641 void CMPXCollectionUiHelperImp::DoIncAddMediaL() |
1743 void CMPXCollectionUiHelperImp::DoIncAddMediaL() |
1642 { |
1744 { |
1643 /***** include only aSize/iChunkSize number of songs *****/ |
1745 /***** include only aSize/iChunkSize number of songs *****/ |
1644 |
1746 MPX_DEBUG5("CMPXCollectionUiHelperImp::DoIncAddMediaL (%d, %d, %d, %d)", |
|
1747 iChunkNumber, iChunkSize, iTotalChunkNumber, iRemainder); |
1645 // copy media |
1748 // copy media |
1646 CMPXMedia* media = CMPXMedia::CopyL(*iInputMedia); |
1749 CMPXMedia* media = CMPXMedia::CopyL(*iInputMedia); |
1647 CleanupStack::PushL(media); |
1750 CleanupStack::PushL(media); |
1648 |
1751 |
1649 CMPXMediaArray* tracksArray = iInputMedia->Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
1752 CMPXMediaArray* tracksArray = iInputMedia->Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
1697 iInputMedia->SetTObjectValueL<TUid>( |
1800 iInputMedia->SetTObjectValueL<TUid>( |
1698 KMPXMediaGeneralCollectionId, TUid::Uid( collectionId )); |
1801 KMPXMediaGeneralCollectionId, TUid::Uid( collectionId )); |
1699 |
1802 |
1700 CleanupStack::PopAndDestroy(playlistExtension); |
1803 CleanupStack::PopAndDestroy(playlistExtension); |
1701 |
1804 |
1702 iMediator->AddItemL( media ); // this creates the new playlist |
1805 iMediator->AddItemAsyncL( media ); // this creates the new playlist |
1703 |
|
1704 // save playlistId in input media & use it for subsequent appending operations |
|
1705 TMPXItemId playlistId = media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
1706 iInputMedia->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, playlistId); |
|
1707 |
|
1708 iChunkNumber++; // move on to next chunk |
|
1709 |
|
1710 CompleteTask(iTask, KErrNone); |
|
1711 } |
1806 } |
1712 else if ( iChunkNumber == iTotalChunkNumber-1 ) // last chunk |
1807 else if ( iChunkNumber == iTotalChunkNumber-1 ) // last chunk |
1713 { |
1808 { |
1714 // get saved collection id from input media & set it in current media |
1809 // get saved collection id from input media & set it in current media |
1715 TUid id = iInputMedia->ValueTObjectL<TUid>(KMPXMediaGeneralCollectionId); |
1810 TUid id = iInputMedia->ValueTObjectL<TUid>(KMPXMediaGeneralCollectionId); |
1717 |
1812 |
1718 // get playlistId from input media & set it in current media |
1813 // get playlistId from input media & set it in current media |
1719 TMPXItemId playlistId = iInputMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
1814 TMPXItemId playlistId = iInputMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
1720 media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, playlistId); |
1815 media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, playlistId); |
1721 |
1816 |
1722 iMediator->AddItemL( media ); |
1817 iMediator->AddItemAsyncL( media ); |
1723 |
|
1724 CompleteTask(ETaskIncFinish, KErrNone); // finish inc task |
|
1725 } |
1818 } |
1726 else // intermedia chunks |
1819 else // intermedia chunks |
1727 { |
1820 { |
1728 // get saved collection id from input media & set it in current media |
1821 // get saved collection id from input media & set it in current media |
1729 TUid id = iInputMedia->ValueTObjectL<TUid>(KMPXMediaGeneralCollectionId); |
1822 TUid id = iInputMedia->ValueTObjectL<TUid>(KMPXMediaGeneralCollectionId); |
1731 |
1824 |
1732 // get playlistId from original media & set it in current media |
1825 // get playlistId from original media & set it in current media |
1733 TMPXItemId playlistId = iInputMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
1826 TMPXItemId playlistId = iInputMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
1734 media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, playlistId); |
1827 media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, playlistId); |
1735 |
1828 |
1736 iMediator->AddItemL( media ); |
1829 iMediator->AddItemAsyncL( media ); |
1737 |
|
1738 iChunkNumber++; // move on to next chunk |
|
1739 |
|
1740 CompleteTask(iTask, KErrNone); |
|
1741 } |
1830 } |
1742 |
1831 |
1743 CleanupStack::PopAndDestroy(cArray); |
1832 CleanupStack::PopAndDestroy(cArray); |
1744 CleanupStack::PopAndDestroy(media); |
1833 CleanupStack::PopAndDestroy(media); |
1745 } |
1834 } |
1788 |
1877 |
1789 /***** logic to see which chunk this code is in *****/ |
1878 /***** logic to see which chunk this code is in *****/ |
1790 |
1879 |
1791 // update media then append to playlist |
1880 // update media then append to playlist |
1792 FillInPlaylistDetailsL(*media); |
1881 FillInPlaylistDetailsL(*media); |
1793 iMediator->AddItemL( media ); |
1882 iMediator->AddItemAsyncL( media ); |
1794 |
1883 |
1795 // last chunk |
|
1796 // for the case that there is only one chunk (first & last chunk at the same |
|
1797 // time), Inc Add is not used |
|
1798 if( iChunkNumber == iTotalChunkNumber-1 ) |
|
1799 { |
|
1800 // update input media as well |
|
1801 FillInPlaylistDetailsL(*iInputMedia); |
|
1802 CompleteTask(ETaskIncFinish, KErrNone); |
|
1803 } |
|
1804 else // intermediate chunks, including first chunk |
|
1805 { |
|
1806 iChunkNumber++; |
|
1807 CompleteTask(iTask, KErrNone); |
|
1808 } |
|
1809 |
|
1810 CleanupStack::PopAndDestroy(cArray); |
1884 CleanupStack::PopAndDestroy(cArray); |
1811 CleanupStack::PopAndDestroy(media); |
1885 CleanupStack::PopAndDestroy(media); |
1812 } |
1886 } |
1813 |
1887 |
1814 // --------------------------------------------------------------------------- |
1888 // --------------------------------------------------------------------------- |