--- a/mpxmusicplayer/commonui/bwinscw/mpxcommonuiU.DEF Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxmusicplayer/commonui/bwinscw/mpxcommonuiU.DEF Tue Sep 14 21:14:08 2010 +0300
@@ -57,4 +57,5 @@
?SetNeedSave@MPXTlsHelper@@SAXH@Z @ 56 NONAME ; void MPXTlsHelper::SetNeedSave(int)
??1CMPXLbxExtendedFeatures@@UAE@XZ @ 57 NONAME ; CMPXLbxExtendedFeatures::~CMPXLbxExtendedFeatures(void)
?SpeedNaviUpdating@CMPXLbxExtendedFeatures@@QAEXH@Z @ 58 NONAME ; void CMPXLbxExtendedFeatures::SpeedNaviUpdating(int)
+ ?IsHostCalendarL@CMPXCommonUiHelper@@QAEHXZ @ 59 NONAME ; int CMPXCommonUiHelper::IsHostCalendarL(void)
--- a/mpxmusicplayer/commonui/eabi/mpxcommonuiU.DEF Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxmusicplayer/commonui/eabi/mpxcommonuiU.DEF Tue Sep 14 21:14:08 2010 +0300
@@ -67,4 +67,5 @@
_ZTI16CMPXAlbumArtUtil @ 66 NONAME
_ZTV13CMPXImageUtil @ 67 NONAME
_ZTV16CMPXAlbumArtUtil @ 68 NONAME
+ _ZN18CMPXCommonUiHelper15IsHostCalendarLEv @ 69 NONAME
--- a/mpxmusicplayer/commonui/inc/mpxcommonui.hrh Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxmusicplayer/commonui/inc/mpxcommonui.hrh Tue Sep 14 21:14:08 2010 +0300
@@ -36,6 +36,7 @@
#define KMPXBrowserUid2 0x1020724D
#define KPodcastingAppUid 0x1028190B
#define KMPXCommonMailUid 0x2001E277
+#define KMPXCalendarUid 0x10005901
#endif // MPXCOMMONUI_HRH
--- a/mpxmusicplayer/commonui/src/mpxalbumartutil.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxmusicplayer/commonui/src/mpxalbumartutil.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -253,6 +253,11 @@
iObserver->ExtractAlbumArtCompleted( NULL, KErrNotFound );
}
}
+ else if ( aError == KErrUnderflow || aError == KErrTimedOut || aError == KErrCompletion)
+ {
+ // Abort imaging decoding
+ iObserver->ExtractAlbumArtCompleted( NULL, KErrNotFound );
+ }
else if (iArtUtil && iFilename)
{
TRAPD( err,
@@ -265,7 +270,11 @@
iObserver->ExtractAlbumArtCompleted( NULL, KErrNotFound );
}
}
-
+ else
+ {
+ iObserver->ExtractAlbumArtCompleted( NULL, KErrNotFound );
+ }
+
iReqId = 0;
}
--- a/mpxmusicplayer/commonui/src/mpxcommonuihelper.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxmusicplayer/commonui/src/mpxcommonuihelper.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -239,6 +239,21 @@
}
return ret;
}
+
+// ---------------------------------------------------------------------------
+// Check if the host application is calendar
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CMPXCommonUiHelper::IsHostCalendarL()
+{
+ TBool ret( EFalse );
+ TInt hostUid = MPXTlsHelper::HostUid().iUid;
+ if ( hostUid == KMPXCalendarUid)
+ {
+ ret = ETrue;
+ }
+ return ret;
+}
// ---------------------------------------------------------------------------
// Check if the host application is browser
--- a/mpxplugins/serviceplugins/collectionplugins/inc/mpxdbmanager.h Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/inc/mpxdbmanager.h Tue Sep 14 21:14:08 2010 +0300
@@ -316,6 +316,15 @@
IMPORT_C void EnsureRamSpaceL() ;
/**
+ * overloaded function for calls where string is allready formatted
+ *
+ * @param aQuery data base query string
+ * @return RSqlStatement
+ */
+ IMPORT_C RSqlStatement ExecuteSelectQueryL( const TDesC& aQuery );
+
+
+ /**
* Move DBs from RAMDisk to disks
*/
//IMPORT_C void BackupDBsL();
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbcommon/bwinscw/mpxsqlitedbcommonu.def Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbcommon/bwinscw/mpxsqlitedbcommonu.def Tue Sep 14 21:14:08 2010 +0300
@@ -126,4 +126,5 @@
?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@@Z @ 125 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &)
?ExecuteSumQueryL@CMPXDbTable@@IAEHABVTDesC16@@KK@Z @ 126 NONAME ; int CMPXDbTable::ExecuteSumQueryL(class TDesC16 const &, unsigned long, unsigned long)
?AddItemAlbumChangedMessageL@MPXDbCommonUtil@@SAXAAVCMPXMediaArray@@VTMPXItemId@@W4TMPXChangeEventType@@W4TMPXGeneralCategory@@IH1@Z @ 127 NONAME ; void MPXDbCommonUtil::AddItemAlbumChangedMessageL(class CMPXMediaArray &, class TMPXItemId, enum TMPXChangeEventType, enum TMPXGeneralCategory, unsigned int, int, class TMPXItemId)
+ ?ExecuteSelectQueryL@CMPXDbManager@@QAE?AVRSqlStatement@@ABVTDesC16@@@Z @ 128 NONAME ; class RSqlStatement CMPXDbManager::ExecuteSelectQueryL(class TDesC16 const &)
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbcommon/eabi/mpxsqlitedbcommonu.def Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbcommon/eabi/mpxsqlitedbcommonu.def Tue Sep 14 21:14:08 2010 +0300
@@ -139,4 +139,5 @@
_ZTV12CMPXResource @ 138 NONAME
_ZTV13CMPXDbManager @ 139 NONAME
_ZN15MPXDbCommonUtil27AddItemAlbumChangedMessageLER14CMPXMediaArray10TMPXItemId19TMPXChangeEventType19TMPXGeneralCategoryjiS2_ @ 140 NONAME
+ _ZN13CMPXDbManager19ExecuteSelectQueryLERK7TDesC16 @ 141 NONAME
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbcommon/src/mpxdbcommonutil.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbcommon/src/mpxdbcommonutil.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -329,7 +329,8 @@
extractPos = KMCPathStartPos; // c:\..., include first '\' of the path
}
- TBuf<KMaxFileName+KMCIntegerLen> fileName;
+ HBufC* fileNameBuf = HBufC::NewLC(aName.Length()+KMCIntegerLen);
+ TPtr fileName(fileNameBuf->Des());
if( extractPos )
{
// append volume's unique Id to path to maintain uniqueness
@@ -357,7 +358,7 @@
TInt narrowFileLen(0);
TPtrC8 narrowFileName;
#if defined(_UNICODE)
- narrowFileLen = fileName.Length() * 2;
+ narrowFileLen = fileNameBuf->Des().Length() * 2;
narrowFileName.Set((TUint8*)fileName.Ptr(), narrowFileLen);
#else
narrowFileLen = fileName.Length();
@@ -375,6 +376,9 @@
TUint32 uniqueId(0);
uniqueId = aTableId << 28;
uniqueId |= (ptr[3]&0x0F)<<24 | (ptr[2]<<16) | (ptr[1]<<8) | ptr[0];
+
+ CleanupStack::PopAndDestroy(fileNameBuf);
+
return uniqueId;
}
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbcommon/src/mpxdbmanager.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbcommon/src/mpxdbmanager.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -2856,6 +2856,18 @@
#endif //__RAMDISK_PERF_ENABLE
}
+// ---------------------------------------------------------------------------
+// CMPXDbManager::ExecuteSelectQueryL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C RSqlStatement CMPXDbManager::ExecuteSelectQueryL( const TDesC& aQuery )
+ {
+ MPX_FUNC("CMPXDatabase::ExecuteSelectQueryL( const TDesC& aQuery )");
+ HBufC* tmp( aQuery.AllocLC() );
+ RSqlStatement statement( ExecuteSelectQueryOnAllDrivesL( tmp->Des() ) );
+ CleanupStack::PopAndDestroy(tmp);
+ return statement;
+ }
// ---------------------------------------------------------------------------
// CMPXDbManager::EnsureDiskSpaceL
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondbdef.h Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxcollectiondbdef.h Tue Sep 14 21:14:08 2010 +0300
@@ -28,12 +28,13 @@
// Db filename
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
-_LIT(KMCDbFile, "mpxv3_1.db");
-_LIT(KMCDbFileEMMC, "mpxv3_1i.db");
+_LIT(KMCDbFile, "mpxv3_2.db");
+_LIT(KMCDbFileEMMC, "mpxv3_2i.db");
#else
-_LIT(KMCDbFile, "mpxv3_1n.db");
-_LIT(KMCDbFileEMMC, "mpxv3_1in.db");
+_LIT(KMCDbFile, "mpxv3_2n.db");
+_LIT(KMCDbFileEMMC, "mpxv3_2in.db");
#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
// Collection Db resource file
_LIT(KMPXCollectionDbResourceFile, "mpxcollectiondbhgres.rsc");
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbalbum.h Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbalbum.h Tue Sep 14 21:14:08 2010 +0300
@@ -29,8 +29,6 @@
class MMPXDbAlbumObserver
{
public:
- virtual TInt HandleIsUnknownArtistL(TUint32 aId) = 0;
- virtual HBufC* HandleArtistForAlbumL( const TUint32 aId ) = 0;
/**
* HandleAlbumartForAlbumL.
* @param aId, The album ID.
@@ -38,6 +36,24 @@
* @returns alternative albumart retrieved in the specified Album.
*/
virtual HBufC* HandleAlbumartForAlbumL( const TUint32 aId, TPtrC aArt ) = 0;
+
+ /**
+ * Called when album artist is removed from an album
+ * @param aCategoryId category item ID
+ * @param aDrive drive the category item is on
+ * @param aItemChangedMessages changed mesages array to be updated or NULL
+ */
+ virtual void DeleteAlbumForArtistL(TUint32 aCategoryId,
+ TInt aDrive, CMPXMessageArray* aItemChangedMessages) = 0;
+
+ /**
+ * Called when album artist is added to an album
+ * @param aName name string
+ * @param aArt Album art path
+ * @param aDriveId drive to add the category to
+ * @return the ID of the category item (new or existing)
+ */
+ virtual TUint32 AddAlbumArtistL(const TDesC& aName, const TDesC& aArt, TInt aDriveId) = 0;
};
/**
* Responsible for managing all music databases
@@ -58,7 +74,7 @@
*/
static CMPXDbAlbum* NewL(CMPXDbManager& aDbManager,
TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
-
+
/**
* Two-phased constructor.
* @param aDbManager database manager to use for database interactions
@@ -67,18 +83,18 @@
*/
static CMPXDbAlbum* NewLC(CMPXDbManager& aDbManager,
TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
-
+
/**
* Destructor
*/
virtual ~CMPXDbAlbum();
public:
-
/**
- * Add a category item. If the record already exists, its counter will
+ * Add an album item. If the record already exists, its counter will
* be incremented.
- * @param aName: This is the name to be entered into the row
+ * @param aCategory category type
+ * @param aMedia: The media object
* @param aDriveId: The Drive Id the name (category) belongs
* @param aNewRecord: indicates to the caller if a new record is created.
* ETrue if a new row is created in the table; otherwise EFalse.
@@ -86,9 +102,9 @@
* into consideration when generating the unique row id
* @return The unique id of the row added.
*/
- TUint32 AddItemL(const TDesC& aName, const TDesC& aArtistName, const TDesC& aArt, TInt aDriveId, TBool& aNewRecord,
+ virtual TUint32 AddItemL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia, TInt aDriveId, TBool& aNewRecord,
TBool aCaseSensitive = ETrue);
-
+
/**
* Decrement the number of songs for the item. If the count gets to 0, remove
* the item.
@@ -102,43 +118,52 @@
* category was deleted
* @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
* EFalse otherwise
- * @param aArtist: The ID of the artist
* @param aArt: The albumart uri
*/
- void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
- CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, const TUint32 aArtist, const TDesC& aArt );
+ void DecrementSongsForAlbumL(TUint32 aId, TInt aDriveId,
+ CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, const TDesC& aArt );
/**
- * Gets the details for all category items.
- * @param aAttrs attributes to be returned
- * @param aMediaArray returns the requested attributes for all items
- */
+ * Gets the details for all category items.
+ * @param aAttrs attributes to be returned
+ * @param aMediaArray returns the requested attributes for all items
+ */
void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
CMPXMediaArray& aMediaArray);
- /**
- * Update a category item.
- * @param aId: The ID of the category to update
- * @param aMedia: The media data
- * @param aDriveId: The Drive Id the name (category) belongs
- * @param aItemChangedMessages: if valid on return contains a updated message if the
- * category was updated
- */
+ /**
+ * Update a category item.
+ * @param aId: The ID of the category to update
+ * @param aMedia: The media data
+ * @param aDriveId: The Drive Id the name (category) belongs
+ * @param aItemChangedMessages: if valid on return contains a updated message if the
+ * category was updated
+ */
void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
- public:
+ public:
/**
- * Get albums count for a specified artist
- * @param aId: The ID of the artist
- */
- TInt GetAlbumsCountForArtistL(TUint32 aArtistId);
-
+ * Get songs count for a specified album and a specified artist
+ * @param aArtistId: The ID of the artist
+ * @param aAlbumId: The ID of the album
+ */
+ TInt GetSongsCountInAlbumMatchingArtistL(TUint32 aArtistId, TUint32 aAlbumId);
+ /**
+ * Check if the specified album ID is an unknown album.
+ * An “Unknown album” is one where the album name and album artist are unknown.
+ * @param aId: The ID of the album
+ * @return ETrue if it's an unknown album
+ */
+ TBool IsUnknownAlbumL(const TUint32 aId);
+
/**
- * Get songs count for a specified album and a specified artist
- * @param aArtistId: The ID of the artist
- * @param aAlbumId: The ID of the album
- */
- TInt GetSongsCountInAlbumMatchingArtistL(TUint32 aArtistId, TUint32 aAlbumId);
+ * Generate Unique ID for Album
+ * @param aMedia media object
+ * @param aCaseSensitive indicates whether case sensitivity should be taken
+ * into consideration when generating the unique row id
+ * @return the ID of album
+ */
+ TUint32 GenerateUniqueIdL(const CMPXMedia& aMedia);
private:
/**
@@ -159,16 +184,7 @@
*/
void GenerateAlbumFieldsValuesL(const CMPXMedia& aMedia,
CDesCArray& aFields, CDesCArray& aValues);
-
-
- TBool IsUnknownArtistL(TUint32 aId);
-
- /**
- * Get the ArtistName of song which belongs to the specified Album.
- * @param aId The ID of the album
- * @returns alternative artistname retrieved in the specified Album.
- */
- HBufC* ArtistForAlbumL(const TUint32 aId);
+
/**
* Get the Albumart of song which belongs to the specified Album.
* @param aId The ID of the album
@@ -186,7 +202,31 @@
*/
void ProcessAlbumRecordSetL(const TArray<TMPXAttribute>& aAttrs,
RSqlStatement& aRecordset, CMPXMediaArray& aMediaArray);
+
+ /**
+ * Retrieve AlbumArtist name from media object
+ * @param aMedia media object
+ * @param aName returned name
+ * @return ETrue if name is available
+ */
+ TBool RetrieveAlbumArtistL(const CMPXMedia& aMedia, TPtrC& aName);
+ /**
+ * Retrieve Artist name from media object
+ * @param aMedia media object
+ * @param aName returned name
+ */
+ void RetrieveArtist(const CMPXMedia& aMedia, TPtrC& aName);
+
+ /**
+ * Check if Art needs to be updated
+ * @param aDeletedSongArt deleted song's art
+ * @param aCurrentAlbumArt Album's current art
+ * @return ETrue if aDeletedSongArt is not non-embedded album art and
+ * aDeleteSongArt and aCurrentAlbumArt are the same and known
+ */
+ TBool NeedToUpdateArt(const TDesC& aDeletedSongArt, const TDesC& aCurrentAlbumArt);
+
private: // from MMPXTable
/**
@@ -207,7 +247,7 @@
* @param aCategory identifies the category
*/
CMPXDbAlbum(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory, MMPXDbAlbumObserver& aObserver);
-
+
/**
* Second phase constructor.
*/
@@ -221,16 +261,20 @@
enum TAlbumColumns
{
EAlbumUniqueId = KMPXTableDefaultIndex,
- EAlbumArtistName,
EAlbumName,
EAlbumSongCount,
+ EAlbumArtist,
+ EAlbumArtistName,
EAlbumArt,
EAlbumFieldCount
};
private: // Data
MMPXDbAlbumObserver& iObserver;
+ RPointerArray<CMPXMedia> iUnknownArtists;
+ RPointerArray<CMPXMedia> iUnknownAlbums;
};
+
#endif // MPXDBALBUM_H
// End of File
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbartist.h Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbartist.h Tue Sep 14 21:14:08 2010 +0300
@@ -24,11 +24,6 @@
#include "mpxdbcategory.h"
// CLASS DECLARATION
-class MMPXDbArtistObserver
- {
- public:
- virtual TInt HandleGetAlbumsCountForArtistL(TUint32 aId) = 0;
- };
/**
* Responsible for managing all music databases
@@ -47,7 +42,7 @@
* @return New CMPXDbArtist instance.
*/
static CMPXDbArtist* NewL(CMPXDbManager& aDbManager,
- TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
+ TMPXGeneralCategory aCategory);
/**
* Two-phased constructor.
@@ -56,8 +51,8 @@
* @return New CMPXDbArtist instance on the cleanup stack.
*/
static CMPXDbArtist* NewLC(CMPXDbManager& aDbManager,
- TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
-
+ TMPXGeneralCategory aCategory);
+
/**
* Destructor
*/
@@ -65,17 +60,16 @@
public:
/**
- * Add a category item. If the record already exists, its counter will
+ * Add a artist item. If the record already exists, its counter will
* be incremented.
- * @param aName: This is the name to be entered into the row
+ * @param aCategory category type
+ * @param aMedia: This is the media object
* @param aDriveId: The Drive Id the name (category) belongs
* @param aNewRecord: indicates to the caller if a new record is created.
* ETrue if a new row is created in the table; otherwise EFalse.
- * @param aCaseSensitive indicates whether case sensitivity should be taken
- * into consideration when generating the unique row id
* @return The unique id of the row added.
*/
- TUint32 AddItemL(const TDesC& aName, const TDesC& aArt, TInt aDriveId, TBool& aNewRecord,
+ virtual TUint32 AddItemL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia, TInt aDriveId, TBool& aNewRecord,
TBool aCaseSensitive = ETrue);
/**
@@ -94,14 +88,54 @@
* @param aItemChangedMessages: if valid on return contains a updated message if the
* category was updated
*/
- void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
+ virtual void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
+
+ /**
+ * Decrement the number of songs for the item. If the song and album count gets to 0,
+ * remove the item.
+ * @param aId: The ID of the category to delete.
+ * @param aDriveId: The drive Id the name (category) belongs to. Songs on different
+ * drives may belong to the same album or artist; consequently, one
+ * row for each artist/album id and drive ID pair will exist in the
+ * lookup table with a count existing for each row that tracks the
+ * number number of songs on that drive with that album/artist.
+ * @param aItemChangedMessages if valid on return contains a deleted message if the
+ * category was deleted
+ * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
+ * EFalse otherwise
+ */
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+ virtual void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
+ CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, TBool aMtpInUse = EFalse);
+#else
+ virtual void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
+ CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
+#endif //ABSTRACTAUDIOALBUM_INCLUDED
- /*
- * Checks if the specified artist item is unknown
- * @param aId identifies the artist item
- * @return ETrue if it is unknown, EFalse otherwise
+ /**
+ * Add a AlbumArtist. If the record already exists, its counter will
+ * be incremented.
+ * @param aName: This is the name to be entered into the row
+ * @param aArt: Album art
+ * @param aDriveId: The Drive Id the name (category) belongs
+ * @return The unique id of the row added.
*/
- TBool IsUnknownArtistL(TUint32 aId);
+ TUint32 AddAlbumArtistL(const TDesC& aName, const TDesC& aArt, TInt aDriveId);
+
+ /**
+ * Decrement the number of albums for the item. If the song and album count gets to 0,
+ * remove the item.
+ * @param aId: The ID of the category to delete.
+ * @param aDriveId: The drive Id the name (category) belongs to. Songs on different
+ * drives may belong to the same album or artist; consequently, one
+ * row for each artist/album id and drive ID pair will exist in the
+ * lookup table with a count existing for each row that tracks the
+ * number number of songs on that drive with that album/artist.
+ * @param aItemChangedMessages if valid on return contains a deleted message if the
+ * category was deleted
+ */
+ void DecrementAlbumsForArtistL(TUint32 aId, TInt aDriveId,
+ CMPXMessageArray* aItemChangedMessages);
private:
@@ -123,14 +157,16 @@
*/
void GenerateArtistFieldsValuesL(const CMPXMedia& aMedia,
CDesCArray& aFields, CDesCArray& aValues);
-
+
/**
- * Gets the Album counts for a Artist item
+ * Gets the Songs count and Albums count for a Artist item
+ * @param aDrivceId The Drive Id the name (category) belongs
* @param aId identifies the Artist item
- * @return value of the Album counts
+ * @param aSongsCount songs count
+ * @param aAlbumsCount albums count
*/
- TInt GetAlbumsCountL(TUint32 aId);
-
+ void GetSongsAndAlbumsCountL(TInt aDriveId, TUint32 aId, TInt& aSongsCount, TInt& aAlbumsCount);
+
private: // from MMPXTable
/**
@@ -150,7 +186,7 @@
* @param aDbManager database manager to use for database interactions
* @param aCategory identifies the category
*/
- CMPXDbArtist(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
+ CMPXDbArtist(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory);
/**
* Second phase constructor.
@@ -167,13 +203,12 @@
EArtistUniqueId = KMPXTableDefaultIndex,
EArtistName,
EArtistSongCount,
+ EArtistAlbumCount,
EArtistArt,
EArtistFieldCount
};
-
- private: // Data
- MMPXDbArtistObserver& iObserver;
};
+
#endif // MPXDBARTIST_H
// End of File
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbcategory.h Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbcategory.h Tue Sep 14 21:14:08 2010 +0300
@@ -53,7 +53,8 @@
/**
* Add a category item. If the record already exists, its counter will
* be incremented.
- * @param aName: This is the name to be entered into the row
+ * @param aCategory category type
+ * @param aMedia: This is the media object to be entered into the row
* @param aDriveId: The Drive Id the name (category) belongs
* @param aNewRecord: indicates to the caller if a new record is created.
* ETrue if a new row is created in the table; otherwise EFalse.
@@ -61,14 +62,9 @@
* into consideration when generating the unique row id
* @return The unique id of the row added.
*/
-#ifdef ABSTRACTAUDIOALBUM_INCLUDED
- virtual TUint32 AddItemL(const TDesC& aName, TInt aDriveId, TBool& aNewRecord,
+ virtual TUint32 AddItemL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia, TInt aDriveId, TBool& aNewRecord,
TBool aCaseSensitive = ETrue);
-#else
- TUint32 AddItemL(const TDesC& aName, TInt aDriveId, TBool& aNewRecord,
- TBool aCaseSensitive = ETrue);
-#endif // ABSTRACTAUDIOALBUM_INCLUDED
-
+
/**
* Get the name field for a given ID.
* @param aId identifies the category item
@@ -90,7 +86,7 @@
*/
void FindAllL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
CMPXMediaArray& aMediaArray);
-
+
/**
* Decrement the number of songs for the item. If the count gets to 0, remove
* the item.
@@ -109,7 +105,7 @@
virtual void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, TBool aMtpInUse = EFalse);
#else
- void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
+ virtual void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
#endif // ABSTRACTAUDIOALBUM_INCLUDED
/**
@@ -183,8 +179,8 @@
* @param aDriveId: The Drive Id the name (category) belongs
* @param aItemChangedMessages: if valid on return contains a updated message if the
* category was updated
- */
- void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
+ */
+ virtual void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
protected:
@@ -222,6 +218,15 @@
void ProcessRecordsetL(const TArray<TMPXAttribute>& aAttrs,
RSqlStatement& aRecordset, CMPXMediaArray& aMediaArray);
+ private:
+ /**
+ * Retrieve name from media object based on category
+ * @param aCategory the category to retrieve name
+ * @param aMedia media object
+ * @return name
+ */
+ TPtrC ItemNameL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia);
+
private: // from MMPXTable
/**
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbhandler.h Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbhandler.h Tue Sep 14 21:14:08 2010 +0300
@@ -65,7 +65,6 @@
class CMPXDbHandler :
public CBase,
public MMPXDbMusicObserver,
- public MMPXDbArtistObserver,
public MMPXDbAlbumObserver,
public MMPXDbPlaylistObserver
{
@@ -1009,39 +1008,30 @@
private: // From MMPXDbMusicObserver
-#ifdef ABSTRACTAUDIOALBUM_INCLUDED
/**
* @see MMPXDbMusicObserver
*/
- virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory,
- const TDesC& aName,
- TInt aDriveId,
- CMPXMessageArray* aItemChangedMessages, TBool& aItemExist,
- const TDesC& aUri,
- const TDesC& aAlbumArtist=KNullDesC);
-#else
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+ virtual TUint32 AddAbstractAlbumItemL(const TDesC& aName,
+ TInt aDriveId, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist,
+ const TDesC& aUri, const TDesC& aAlbumArtist=KNullDesC);
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+ virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia,
+ TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
+
+ virtual void UpdateCategoryItemL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
+ const CMPXMedia& aMedia, TInt aDrive, CMPXMessageArray* aItemChangedMessages);
+
+ virtual TUint32 GenerateUniqueIdForAlbumL(const CMPXMedia& aMedia);
+
+ virtual TBool IsUnknownAlbumL(const TUint32 aId);
/**
* @see MMPXDbMusicObserver
*/
- virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory,
- const TDesC& aName, TInt aDriveId,
- CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
-#endif // ABSTRACTAUDIOALBUM_INCLUDED
-
- virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
- const TDesC& aArtistName, const TDesC& aArt,
- TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist);
-
- virtual void UpdateCategoryItemL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
- const CMPXMedia& aMedia, TInt aDrive, CMPXMessageArray* aItemChangedMessages);
-
- /**
- * @see MMPXDbMusicObserver
- */
- virtual void DeleteSongForCategoryL(TMPXGeneralCategory aCategory,
- TUint32 aCategoryId, TInt aDriveId, CMPXMessageArray* aItemChangedMessages,
- TBool& aItemExist);
+ virtual void DeleteSongForCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
+ TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, const TDesC& aArt = KNullDesC);
/**
* @see MMPXDbMusicObserver
@@ -1058,41 +1048,35 @@
*/
virtual HBufC* HandleGetAlbumNameFromIdL(TUint32 aId);
#endif // ABSTRACTAUDIOALBUM_INCLUDED
- private: // From MMPXDbArtistObserver
- /**
- * @see MMPXDbArtistObser
- */
- virtual TInt HandleGetAlbumsCountForArtistL(TUint32 aArtistId);
+
+ private: // From MMPXDbAlbumObserver
+ /**
+ * Get the Albumart of song which belongs to the specified Album.
+ * @param aId, The Album ID.
+ * @param aArt, the AlbumArt uri.
+ * @returns alternative albumart retrieved in the specified Album.
+ */
+ virtual HBufC* HandleAlbumartForAlbumL(const TUint32 aAlbumId, TPtrC aArt);
+
+ /**
+ * @see MMPXDbAlbumObserver
+ */
+ virtual void DeleteAlbumForArtistL(TUint32 aCategoryId,
+ TInt aDrive, CMPXMessageArray* aItemChangedMessages);
- private: // From MMPXDbAlbumObserver
- /**
- * @see MMPXDbAlbumObserver
- */
- virtual TBool HandleIsUnknownArtistL(TUint32 aArtistId);
- /**
- * Get the Artistname of song which belongs to the specified Album.
- * @param aId, The Album ID.
- * @returns alternative artistname retrieved in the specified Album.
- */
- virtual HBufC* HandleArtistForAlbumL(const TUint32 aAlbumId);
-
- /**
- * Get the Albumart of song which belongs to the specified Album.
- * @param aId, The Album ID.
- * @param aArt, the AlbumArt uri.
- * @returns alternative albumart retrieved in the specified Album.
- */
- virtual HBufC* HandleAlbumartForAlbumL(const TUint32 aAlbumId, TPtrC aArt);
+ /**
+ * @see MMPXDbAlbumObserver
+ */
+ virtual TUint32 AddAlbumArtistL(const TDesC& aName, const TDesC& aArt, TInt aDriveId);
private: // From MMPXDbPlaylistObserver
- /**
- * @see MMPXDbPlaylistObserver
- */
+ /**
+ * @see MMPXDbPlaylistObserver
+ */
virtual TInt HandlePlaylistDurationL(TUint32 aPlaylistId);
virtual void HandlePlaylistInfoL(TUint32 aPlaylistId, TInt& aCount, TInt& aDuration);
private:
-
/**
* C++ constructor.
* @param file session
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbmusic.h Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbmusic.h Tue Sep 14 21:14:08 2010 +0300
@@ -51,37 +51,33 @@
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
/**
* Called when a new category item has to be added to a category table.
- * @param aCategory category type
- * @param aName name string
+ * @param aName Abstract Album art name
* @param aDrive drive to add the category to
* @param aItemChangedMessages changed mesages array to be updated or NULL
* @param aItemExist Out parameter, ETrue if the item already exist before the add,
* EFalse otherwise
+ * @param aUri Abstract Album art Uri
* @param aAlbumArtist AlbumArtist string
- * @param aGenre Genre string
* @return the ID of the category item (new or existing)
*/
- virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
- TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, const TDesC& aAlbumArtist=KNullDesC,
- const TDesC& aGenre=KNullDesC) = 0;
-#else
+ virtual TUint32 AddAbstractAlbumItemL(const TDesC& aName,
+ TInt aDriveId, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist,
+ const TDesC& aUri, const TDesC& aAlbumArtist=KNullDesC) = 0;
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
/**
* Called when a new category item has to be added to a category table.
* @param aCategory category type
- * @param aName name string
+ * @param aMedia media object
* @param aDrive drive to add the category to
* @param aItemChangedMessages changed mesages array to be updated or NULL
* @param aItemExist Out parameter, ETrue if the item already exist before the add,
* EFalse otherwise
* @return the ID of the category item (new or existing)
*/
- virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
+ virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia,
TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist) = 0;
-#endif // ABSTRACTAUDIOALBUM_INCLUDED
- // for Album and Artist table
- virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName,
- const TDesC& aArtistName, const TDesC& aArt,
- TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist) = 0;
+
/**
* Called when the ID of a category item changed for a Music record, for example when
* the artist name changed for a song. The implementation is supposed to update the
@@ -92,9 +88,13 @@
* @param aItemChangedMessages changed mesages array to be updated or NULL
* @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
* EFalse otherwise
+ * @param aArt Art of the music record.
+ * Art needs to be given so that the cateogry can switch over to different art
+ * if necessary
+ *
*/
virtual void DeleteSongForCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
- TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist) = 0;
+ TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, const TDesC& aArt = KNullDesC) = 0;
/**
* Called when the play count attribute of a song is changed. Should add an item changed
@@ -121,6 +121,7 @@
*/
virtual void UpdateCategoryItemL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
const CMPXMedia& aMedia, TInt aDrive, CMPXMessageArray* aItemChangedMessages) = 0;
+
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
/**
* Get title from the Id
@@ -128,7 +129,23 @@
* @return name matching the ID
*/
virtual HBufC* HandleGetAlbumNameFromIdL( TUint32 aId ) = 0;
-#endif // ABSTRACTAUDIOALBUM_INCLUDED
+#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+ /**
+ * Generate Unique ID for Album
+ * @param aMedia media object
+ * @param aCaseSensitive indicates whether case sensitivity should be taken
+ * into consideration when generating the unique row id
+ * @return the ID of album
+ */
+ virtual TUint32 GenerateUniqueIdForAlbumL(const CMPXMedia& aMedia) = 0;
+
+ /**
+ * Check if the specified album ID is Unknown album
+ * @param aId: The ID of the album
+ * @return ETrue if it's Unknown album
+ */
+ virtual TBool IsUnknownAlbumL(const TUint32 aId) = 0;
};
/**
@@ -149,7 +166,7 @@
*/
static CMPXDbMusic* NewL(CMPXDbManager& aDbManager, CMPXResource& aResource,
MMPXDbMusicObserver& aObserver);
-
+
/**
* Two-phased constructor.
* @param aDbManager database manager to use for database interactions
@@ -158,7 +175,7 @@
*/
static CMPXDbMusic* NewLC(CMPXDbManager& aDbManager, CMPXResource& aResource,
MMPXDbMusicObserver& aObserver);
-
+
/**
* Destructor
*/
@@ -501,11 +518,13 @@
* @param aAttrs the attributes to include for the artist(s) matching the
* selection criteria
* @param aMediaArray returns the songs
- */
+ * @param aSortByTrackOrder if TRUE sorts tracks according to their track numbers,
+ * if FALSE using track titles or filename
+ */
void FindSongsL(TUint32 aGeneralId, TUint32 aContainerId, TMPXGeneralType aType,
const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs,
- CMPXMediaArray& aMediaArray);
-
+ CMPXMediaArray& aMediaArray, TBool aSortByTrackOrder = EFalse);
+
/**
* Returns the track count for a given drive
* @param aDrive drive
@@ -523,12 +542,6 @@
*/
void GetMusicUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
CDesCArray& aUriArr, TInt& aLastID);
-
- /**
- * Get the ID of Artist which belongs to the specified Album
- * @param aId, the ID of Album
- */
- TUint32 ArtistForAlbumL(const TUint32 aId);
/**
* Get the Albumart of song which belongs to the specified Album
@@ -672,13 +685,12 @@
HBufC* ConstructUriL(RSqlStatement& aMusicTable);
/**
- * Checks if the specified category field (artist/album/genre/composer)
+ * Checks if the specified category field (artist/genre/composer/abstractalbum)
* will change and notifies the observer if so.
* @param aCategory identifies the category
* @param aMedia contains the new record attributes
* @param aAttribute corresponding attribute in the media parameter
- * @param aColumnIndex column index in the recordset
- * @param aMusicTable current record in the music table or NULL if this is an insert
+ * @param aOldId the current category item ID
* @param aDriveId drive ID the update is for
* @param aItemChangedMessages item changed messages to append to
* @param aItemId returns the category item ID
@@ -689,6 +701,22 @@
CMPXMessageArray* aItemChangedMessages, TUint32& aItemId, const TDesC& aArt = KNullDesC);
/**
+ * Checks if album will change and notifies the observer if so.
+ * @param aMedia contains the new record attributes
+ * @param aAttribute corresponding attribute in the media parameter
+ * @param aOldId the current category item ID
+ * @param aDriveId drive ID the update is for
+ * @param aItemChangedMessages item changed messages to append to
+ * @param aItemId returns the album item ID
+ * @param aArt old art of the music record
+ * @param aCaseSensitive indicates whether case sensitivity should be taken
+ * @return ETrue if the field was modified
+ */
+ TBool UpdateCategoryFieldForAlbumL(const CMPXMedia& aMedia,
+ const TMPXAttribute& aAttribute, TUint32 aOldId, TInt aDriveId,
+ CMPXMessageArray* aItemChangedMessages, TUint32& aItemId, const TDesC& aArt = KNullDesC);
+
+ /**
* Checks if extra attributes are required. The "standard attribute set includes:
* EMPXMediaGeneralId, EMPXMediaGeneralType, EMPXMediaGeneralCategory,
* EMPXMediaGeneralTitle, EMPXMediaGeneralUri, and EMPXMediaGeneralFlags
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbpluginqueries.h Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbpluginqueries.h Tue Sep 14 21:14:08 2010 +0300
@@ -209,11 +209,11 @@
_LIT(KQueryMusicGetMusicUrisFrom, "SELECT UniqueId,Location FROM :dbname.Music WHERE Deleted=0 AND UniqueId > %u ORDER BY UniqueId ASC LIMIT %u");
_LIT(KQueryMusicCount, "SELECT count(*) FROM :dbname.Music WHERE Deleted=0");
-_LIT(KQueryMusicAlbum, "SELECT DISTINCT Album FROM :dbname.Music WHERE Deleted=0 AND Artist=%u ORDER BY Album");
+_LIT(KQueryMusicAlbum, "SELECT DISTINCT Album FROM :dbname.Music WHERE Deleted=0 AND Artist=%u ORDER BY Album"); // deprecated, not maintained
_LIT(KQueryMusicVolume, "SELECT VolumeId FROM :dbname.Music WHERE Deleted=0 AND UniqueId=%u");
_LIT(KQueryMusicVolumeAll, "SELECT VolumeId FROM :dbname.Music WHERE UniqueId=%u");
_LIT(KQueryMusicInfo, "SELECT * FROM :dbname.Music WHERE Deleted=0 AND UniqueId=%u");
-_LIT(KQueryOtherSongsInArtistAlbum, "SELECT count(*) FROM :dbname.Music WHERE Deleted=0 AND UniqueId<>%u AND Artist=%u AND Album=%u");
+_LIT(KQueryOtherSongsInArtistAlbum, "SELECT count(*) FROM :dbname.Music WHERE Deleted=0 AND UniqueId<>%u AND Artist=%u AND Album=%u"); // deprecated, not maintained
_LIT(KQueryMusicDurationAll, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0");
_LIT(KQueryMusicDurationArtist, "SELECT sum(Duration) FROM :dbname.Music WHERE Deleted=0 AND Artist=%u");
@@ -230,15 +230,15 @@
_LIT(KQueryMusicGetDurationRecentlyAdded, "SELECT Duration FROM :dbname.Music WHERE Deleted=0 AND (julianday(TimeAdded) > julianday('now','-7 days'))");
// Select songs information from music, playlistsongs and playlistsonginfo via playlistid order by playlistsongs's ordinal
-_LIT(KQueryMusicGetAllSongsbyPl,"select mu.UniqueId,mu.DbFlag,mu.VolumeId,mu.Title,mu.Artist,mu.Art,0,mu.Location,pl.UniqueId as PlUId, pl.ordinal from :dbname.music as mu,:pldbname.playlistsongs as pl where mu.Deleted=0 AND mu.uniqueid = pl.songid and pl.playlistid =%u ORDER BY 10");
+_LIT(KQueryMusicGetAllSongsbyPl,"select mu.UniqueId,mu.DbFlag,mu.VolumeId,mu.Title,mu.Artist,mu.Art,0,mu.Location,pl.UniqueId as PlUId, pl.ordinal from :dbname.music as mu,:pldbname.playlistsongs as pl where mu.Deleted=0 AND mu.uniqueid = pl.songid and pl.playlistid =%u ORDER BY 10"); // deprecated, not maintained
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
_LIT(KQueryMusicGetAllSongsInfobyPl,"SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name,pl.UniqueId as PlUId,pl.ordinal FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer,:pldbname.playlistsongs as pl WHERE Music.Deleted=0 AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId AND Music.UniqueId=pl .songid and pl .PlaylistId=%u ORDER BY 40");
#else
_LIT(KQueryMusicGetAllSongsInfobyPl,"SELECT Music.*,Artist.Name,Album.Name,Genre.Name,Composer.Name,pl.UniqueId as PlUId,pl.ordinal FROM :dbname.Music,:dbname.Artist,:dbname.Album,:dbname.Genre,:dbname.Composer,:pldbname.playlistsongs as pl WHERE Music.Deleted=0 AND Music.Album=Album.UniqueId AND Music.Artist=Artist.UniqueId AND Music.Genre=Genre.UniqueId AND Music.Composer=Composer.UniqueId AND Music.UniqueId=pl .songid and pl .PlaylistId=%u ORDER BY 37");
#endif
-_LIT(KQuerySongsInArtistAlbum, "SELECT count(*) FROM :dbname.Music WHERE Deleted=0 AND Artist=%u AND Album=%u");
-_LIT(KQueryMusicGetArtistForAlbum, "SELECT Artist FROM :dbname.Music,:dbname.Artist WHERE Music.Deleted=0 AND Music.Artist=Artist.UniqueId AND Music.Album=%u");
+_LIT(KQuerySongsInArtistAlbum, "SELECT count(*) FROM :dbname.Music WHERE Deleted=0 AND Artist=%u AND Album=%u"); /// not maintaned and known to be broken due to "album artist (compilation support)"
_LIT(KQueryMusicGetAlbumartForAlbum, "SELECT Art FROM :dbname.Music WHERE Music.Deleted=0 AND Music.Album=%u");
+
// == Category table queries ==================================================
//
_LIT(KCategoryTablePlaceholder, "##table##");
@@ -279,9 +279,9 @@
_LIT(KAuxiliaryDropTable,"DROP TABLE Auxiliary");
_LIT(KAuxiliaryCheckTable, "SELECT Id,Version,TimeRefreshed,TimeSynced,Corrupt,SaveDeletedRecordCount FROM AUXILIARY");
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
-_LIT(KQueryAuxiliaryInsert, "INSERT INTO Auxiliary(Id,Version,Corrupt) VALUES(0,'6.7.0',%u)");
+_LIT(KQueryAuxiliaryInsert, "INSERT INTO Auxiliary(Id,Version,Corrupt) VALUES(0,'6.8.0',%u)");
#else
-_LIT(KQueryAuxiliaryInsert, "INSERT INTO Auxiliary(Id,Version,Corrupt) VALUES(0,'6.7.1',%u)");
+_LIT(KQueryAuxiliaryInsert, "INSERT INTO Auxiliary(Id,Version,Corrupt) VALUES(0,'6.8.1',%u)");
#endif // ABSTRACTAUDIOALBUM_INCLUDED
_LIT(KQueryAuxiliarySetTime, "UPDATE :dbname.Auxiliary SET TimeRefreshed='%S', Corrupt=0");
_LIT(KQueryAuxiliaryGetTime, "SELECT TimeRefreshed FROM :dbname.Auxiliary");
@@ -436,17 +436,17 @@
//
_LIT(KAlbumCreateTable,"CREATE TABLE Album("
L"UniqueId INTEGER PRIMARY KEY,"
- L"ArtistName TEXT COLLATE NOCASE,"
L"Name TEXT COLLATE NOCASE,"
L"SongCount INTEGER,"
- L"Art TEXT)");
+ L"Artist INTEGER,"
+ L"ArtistName TEXT COLLATE NOCASE,"
+ L"Art TEXT)");
-_LIT(KAlbumCheckTable,"SELECT UniqueId,ArtistName,Name,SongCount,Art FROM Album");
+_LIT(KAlbumCheckTable,"SELECT UniqueId,Name,SongCount,Artist,ArtistName,Art FROM Album");
-_LIT(KQueryAlbumInsert, "INSERT INTO :dbname.Album(UniqueId,ArtistName,Name,SongCount,Art) VALUES(%u,'%S','%S',%u,'%S')");
+_LIT(KQueryAlbumInsert, "INSERT INTO :dbname.Album(UniqueId,Name,SongCount,Artist,ArtistName,Art) VALUES(%u,'%S',%u,%u,'%S','%S')");
_LIT(KQueryAlbumUpdate, "UPDATE :dbname.Album SET %S WHERE UniqueId=%u");
-_LIT(KQueryAlbumItem, "SELECT Album.*,Artist.Name FROM :dbname.Album,:dbname.Artist WHERE Album.Artist=Artist.UniqueId AND UniqueId=%u");
_LIT(KQueryAlbumAll, "SELECT Album.* FROM :dbname.Album ORDER BY ArtistName, Name");
_LIT(KCriterionArtistName, "ArtistName='%S'");
_LIT(KCriterionArt, "Art='%S'");
@@ -457,16 +457,22 @@
L"UniqueId INTEGER PRIMARY KEY,"
L"Name TEXT COLLATE NOCASE,"
L"SongCount INTEGER,"
+ L"AlbumCount INTEGER,"
L"Art TEXT)");
-_LIT(KArtistCheckTable,"SELECT UniqueId,Name,SongCount,Art FROM Artist");
+_LIT(KArtistCheckTable,"SELECT UniqueId,Name,SongCount,AlbumCount,Art FROM Artist");
-_LIT(KQueryArtistInsert, "INSERT INTO :dbname.Artist(UniqueId,Name,SongCount,Art) VALUES(%u,'%S',%u,'%S')");
+_LIT(KQueryArtistInsert, "INSERT INTO :dbname.Artist(UniqueId,Name,SongCount,AlbumCount,Art) VALUES(%u,'%S',%u,%u,'%S')");
_LIT(KQueryArtistUpdate, "UPDATE :dbname.Artist SET %S WHERE UniqueId=%u");
-_LIT(KQueryArtistAll, "SELECT Artist.* FROM :dbname.Artist ORDER BY 2");
+_LIT(KQueryArtistAll, "SELECT Artist.* FROM :dbname.Artist WHERE SongCount > 0 ORDER BY 2");
_LIT(KQueryArtistName, "SELECT Artist.Name FROM :dbname.Artist WHERE UniqueId=%u");
+_LIT(KQueryArtistIncrementAlbumCount, "UPDATE :dbname.Artist SET AlbumCount=AlbumCount+1 WHERE UniqueId=%u");
+_LIT(KQueryArtistDecrementAlbumCount, "UPDATE :dbname.Artist SET AlbumCount=AlbumCount-1 WHERE UniqueId=%u");
+_LIT(KQueryArtistGetSongCountAndAlbumCount, "SELECT SongCount,AlbumCount FROM :dbname.Artist WHERE UniqueId=%u");
+_LIT(KQueryArtistItems, "SELECT * FROM :dbname.Artist WHERE %S AND SongCount > 0 ORDER BY Name ASC");
+
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
// == AbstractAlbum table queries ==========================================
//
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbabstractalbum.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbabstractalbum.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -510,7 +510,7 @@
void CMPXDbAbstractAlbum::GetAllItemsWithNoSongL(RArray<TUint32>& aItemsIds)
{
MPX_FUNC("CMPXDbAbstractAlbum::GetAllItemsWithNoSongL");
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAbstractAlbumsWithNoSong));
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAbstractAlbumsWithNoSong()));
CleanupClosePushL(recordset);
TInt err(KErrNone);
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbalbum.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbalbum.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -37,6 +37,11 @@
_LIT( KAbstractAlbumExt, ".alb" );
#endif // ABSTRACTAUDIOALBUM_INCLUDED
+_LIT( KAlbumAlbumArtistSeperator, "\t1");
+_LIT( KAlbumArtistSeperator, "\t2");
+
+const TInt KUnknownAlbumsGranularity = 250;
+
// ============================ MEMBER FUNCTIONS ==============================
// ----------------------------------------------------------------------------
@@ -79,6 +84,9 @@
CMPXDbAlbum::~CMPXDbAlbum()
{
MPX_FUNC("CMPXDbAlbum::~CMPXDbAlbum");
+
+ iUnknownArtists.ResetAndDestroy();
+ iUnknownAlbums.ResetAndDestroy();
}
// ----------------------------------------------------------------------------
@@ -90,7 +98,9 @@
TMPXGeneralCategory aCategory,
MMPXDbAlbumObserver& aObserver) :
CMPXDbCategory(aDbManager, aCategory),
- iObserver(aObserver)
+ iObserver(aObserver),
+ iUnknownArtists(KUnknownAlbumsGranularity),
+ iUnknownAlbums(KUnknownAlbumsGranularity)
{
MPX_FUNC("CMPXDbAlbum::CMPXDbAlbum");
}
@@ -111,79 +121,81 @@
// ----------------------------------------------------------------------------
//
TUint32 CMPXDbAlbum::AddItemL(
- const TDesC& aName,
- const TDesC& aArtistName,
- const TDesC& aArt,
+ TMPXGeneralCategory /*aCategory*/,
+ const CMPXMedia& aMedia,
TInt aDriveId,
TBool& aNewRecord,
TBool aCaseSensitive)
{
MPX_FUNC("CMPXDbAlbum::AddItemL");
+ TPtrC album(KNullDesC);
+ TPtrC albumArtist(KNullDesC);
+ TPtrC artist(KNullDesC);
+ TPtrC albumArt(KNullDesC);
+
// try to find the item first
- TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory,
- aName, aCaseSensitive));
- aNewRecord = !CategoryItemExistsL(aDriveId, rowId);
-
- if (aNewRecord)
- {
- // insert new
- HBufC* query = PreProcessStringLC(KQueryAlbumInsert);
- HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
- HBufC* artistname = MPXDbCommonUtil::ProcessSingleQuotesLC(aArtistName);
- HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(aArt);
-
- iDbManager.ExecuteQueryL(aDriveId, *query, rowId, artistname, name, 1, art);
-
- CleanupStack::PopAndDestroy(art);
- CleanupStack::PopAndDestroy(artistname);
- CleanupStack::PopAndDestroy(name);
- CleanupStack::PopAndDestroy(query);
- }
- else
+ TUint32 rowId(GenerateUniqueIdL(aMedia));
+
+ // retrieve the existing record
+ HBufC* query = PreProcessStringLC(KQueryCategoryItem);
+ RSqlStatement recordset(
+ iDbManager.ExecuteSelectQueryL(aDriveId, *query, rowId));
+ CleanupStack::PopAndDestroy(query);
+ CleanupClosePushL(recordset);
+
+ TInt result = recordset.Next();
+ if (result == KSqlAtEnd)
{
- // retrieve the existing record
- HBufC* query = NULL;
- query = PreProcessStringLC(KQueryCategoryItem);
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, rowId));
- CleanupStack::PopAndDestroy(query);
-
- CleanupClosePushL(recordset);
-
- if (recordset.Next() != KSqlAtRow)
+ aNewRecord = result;
+
+ // check Album attribute
+ if (aMedia.IsSupported(KMPXMediaMusicAlbum))
{
- User::Leave(KErrNotFound);
- }
-
- // Artist
- TPtrC artistname(KNullDesC);
- artistname.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArtistName));
-
-
- // the current one is Unknown and the new one is Not Unknown.
- if ( artistname == KNullDesC && aArtistName!= KNullDesC )
+ album.Set(aMedia.ValueText(KMPXMediaMusicAlbum).Left(KMCMaxTextLen));
+ }
+
+ // check AlbumArt attirbute
+ if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
{
- HBufC* artistnameReplaceSingleQuote =
- MPXDbCommonUtil::ProcessSingleQuotesLC( aArtistName );
- TPtrC criteria(KCriterionArtistName);
- HBufC* setStr = HBufC::NewLC(criteria.Length() + artistnameReplaceSingleQuote->Length());
- setStr->Des().Format( KCriterionArtistName, artistnameReplaceSingleQuote );
-
- iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, rowId);
- CleanupStack::PopAndDestroy(setStr);
- CleanupStack::PopAndDestroy(artistnameReplaceSingleQuote);
-
+ albumArt.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen));
}
- // Album Art
+ // insert new
+ HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(album);
+ TUint32 artistId(0);
+ HBufC* artistName = NULL;
+ if (RetrieveAlbumArtistL(aMedia, albumArtist))
+ {
+ artistId = iObserver.AddAlbumArtistL(albumArtist, albumArt, aDriveId);
+ artistName = MPXDbCommonUtil::ProcessSingleQuotesLC(albumArtist);
+ }
+ else
+ {
+ RetrieveArtist(aMedia, artist);
+ artistId = iObserver.AddAlbumArtistL(artist, albumArt, aDriveId);
+ artistName = MPXDbCommonUtil::ProcessSingleQuotesLC(artist);
+ }
+
+ HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(albumArt);
+
+ iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumInsert, rowId, name, 1, artistId, artistName,art);
+
+ CleanupStack::PopAndDestroy(art);
+ CleanupStack::PopAndDestroy(artistName);
+ CleanupStack::PopAndDestroy(name);
+ }
+ else if (result == KSqlAtRow)
+ {
+ // retrieve Art from Album table
TPtrC art(KNullDesC);
art.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArt));
// the current one is Unknown and the new one is Not Unknown
- if ( art == KNullDesC && aArt != KNullDesC )
+ if ( art == KNullDesC && albumArt != KNullDesC )
{
HBufC* artReplaceSingleQuote =
- MPXDbCommonUtil::ProcessSingleQuotesLC( aArt );
+ MPXDbCommonUtil::ProcessSingleQuotesLC( albumArt );
TPtrC criteria(KCriterionArt);
HBufC* setStr = HBufC::NewLC(criteria.Length() + artReplaceSingleQuote->Length());
@@ -194,35 +206,57 @@
CleanupStack::PopAndDestroy(artReplaceSingleQuote);
}
- CleanupStack::PopAndDestroy(&recordset);
-
// increment the number of songs for the category
query = PreProcessStringLC(KQueryCategoryIncrementSongCount);
iDbManager.ExecuteQueryL(aDriveId, *query, rowId);
CleanupStack::PopAndDestroy(query);
+ } // existing record
+ else
+ {
+ MPX_DEBUG2("SQL error %d", result);
+ User::Leave(result);
}
+ CleanupStack::PopAndDestroy(&recordset);
+
return rowId;
}
// ----------------------------------------------------------------------------
-// CMPXDbAlbum::DecrementSongsForCategoryL
+// CMPXDbAlbum::DecrementSongsForAlbumL
// ----------------------------------------------------------------------------
//
-void CMPXDbAlbum::DecrementSongsForCategoryL(
+void CMPXDbAlbum::DecrementSongsForAlbumL(
const TUint32 aId,
TInt aDriveId,
CMPXMessageArray* aItemChangedMessages,
TBool& aItemExist,
- const TUint32 aArtist,
- const TDesC& aArt)
+ const TDesC& aArt)
{
- MPX_FUNC("CMPXDbAlbum::DecrementSongsForCategoryL");
+ MPX_FUNC("CMPXDbAlbum::DecrementSongsForAlbumL");
+
+ // retrieve the existing record
+ HBufC* query = PreProcessStringLC(KQueryCategoryItem);
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, aId));
+ CleanupStack::PopAndDestroy(query);
+
+ CleanupClosePushL(recordset);
+
+ if (recordset.Next() != KSqlAtRow)
+ {
+ User::Leave(KErrNotFound);
+ }
// if just one song uses this category. Use <= just in case
- if (GetSongsCountL(aDriveId, aId) <= 1)
+ if (recordset.ColumnInt64(EAlbumSongCount) <= 1)
{
aItemExist = EFalse;
+
+ // Decrement albums count on artist
+ TUint32 albumArtistId = recordset.ColumnInt64(EAlbumArtist);
+ iObserver.DeleteAlbumForArtistL(albumArtistId, aDriveId, aItemChangedMessages);
+ CleanupStack::PopAndDestroy(&recordset);
+
// delete the category
DeleteCategoryL(aId, aDriveId);
@@ -237,63 +271,10 @@
{
aItemExist = ETrue;
- // retrieve the existing record
- HBufC* query = PreProcessStringLC(KQueryCategoryItem);
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, aId));
- CleanupStack::PopAndDestroy(query);
-
- CleanupClosePushL(recordset);
-
- if (recordset.Next() != KSqlAtRow)
- {
- User::Leave(KErrNotFound);
- }
-
TBool itemModified = EFalse;
- TPtrC artistname(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArtistName));
- TUint32 artistId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXArtist,
- artistname, ETrue);
-
- // the current artist is equal to deleted song's artist
- if ( artistId == aArtist )
- {
- HBufC* newArtistname = ArtistForAlbumL(aId);
-
- CleanupStack::PushL(newArtistname);
- if (newArtistname && newArtistname->CompareF(artistname)!=0)
- {
- HBufC* artistnameReplaceSingleQuote = MPXDbCommonUtil::ProcessSingleQuotesLC( *newArtistname );
- TPtrC criteria(KCriterionArtistName);
- HBufC* setStr = HBufC::NewLC(criteria.Length() + artistnameReplaceSingleQuote->Length());
- setStr->Des().Format( KCriterionArtistName, artistnameReplaceSingleQuote );
-
- iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId);
- CleanupStack::PopAndDestroy(setStr);
- CleanupStack::PopAndDestroy(artistnameReplaceSingleQuote);
- itemModified = ETrue;
- }
- CleanupStack::PopAndDestroy(newArtistname);
- }
-
-#ifdef ABSTRACTAUDIOALBUM_INCLUDED
- TBool nonEmbeddedArt = EFalse;
- if (aArt.Length()>0)
- {
- TParsePtrC parse(aArt);
- TPtrC ext(parse.Ext());
- //set flag to false, so .alb will not overwrite art field in album, artist table
- // when song with embedded art
- if (ext.CompareF(KAbstractAlbumExt)== 0)
- {
- nonEmbeddedArt = ETrue;
- }
- }
- if (!nonEmbeddedArt)
- {
-#endif // ABSTRACTAUDIOALBUM_INCLUDED
- TPtrC art(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArt));
- // the current art is equal to deleted song's art
- if(aArt.Length()>0 && art.Length()>0 && aArt.CompareF(art) ==0 )
+
+ TPtrC art(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArt));
+ if (NeedToUpdateArt(aArt, art))
{
MPX_DEBUG2("AlbumArt of the Song to be deleted is [%S]", &aArt);
@@ -304,7 +285,7 @@
//update Album table only if alternative albumart found
if (newArt)
{
- MPX_DEBUG1("CMPXDbAlbum::DecrementSongsForCategoryL, get newArt");
+ MPX_DEBUG1("CMPXDbAlbum::DecrementSongsForAlbumL, get newArt");
HBufC* artReplaceSingleQuote = MPXDbCommonUtil::ProcessSingleQuotesLC( *newArt );
TPtrC criteria(KCriterionArt);
HBufC* setStr = HBufC::NewLC(criteria.Length() + artReplaceSingleQuote->Length());
@@ -315,17 +296,15 @@
CleanupStack::PopAndDestroy(artReplaceSingleQuote);
itemModified = ETrue;
}
- CleanupStack::PopAndDestroy(newArt);
- }
-#ifdef ABSTRACTAUDIOALBUM_INCLUDED
- }
-#endif // ABSTRACTAUDIOALBUM_INCLUDED
+ CleanupStack::PopAndDestroy(newArt);
+ }
+
if (aItemChangedMessages && itemModified)
- {
- // add the item changed message
- MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified,
- EMPXAlbum, KDBPluginUid, ETrue, 0 );
- }
+ {
+ // add the item changed message
+ MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified,
+ EMPXAlbum, KDBPluginUid, ETrue, 0 );
+ }
CleanupStack::PopAndDestroy(&recordset);
// decrement the number of songs for the category
@@ -345,12 +324,16 @@
{
MPX_FUNC("CMPXDbAlbum::GetAllCategoryItemsL");
- HBufC* query = PreProcessStringLC(KQueryAlbumAll);
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
- CleanupStack::PopAndDestroy(query);
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAlbumAll()));
CleanupClosePushL(recordset);
- ProcessAlbumRecordSetL(aAttrs, recordset, aMediaArray);
+ TRAPD(err, ProcessAlbumRecordSetL(aAttrs, recordset, aMediaArray));
+ if (err != KErrNone)
+ {
+ iUnknownArtists.ResetAndDestroy();
+ iUnknownAlbums.ResetAndDestroy();
+ User::LeaveIfError(err);
+ }
CleanupStack::PopAndDestroy(&recordset);
}
@@ -391,39 +374,6 @@
}
// ----------------------------------------------------------------------------
-// CMPXDbAlbum::GetAlbumsCountForArtistL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbAlbum::GetAlbumsCountForArtistL(TUint32 aArtistId)
- {
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryCategorySubcategoryItems, aArtistId));
-
- TInt prevId(0);
- TInt count(0);
- TInt err(KErrNone);
-
- while ((err = recordset.Next()) == KSqlAtRow)
- {
- TUint32 rowId(recordset.ColumnInt64(EAlbumUniqueId));
- if (prevId == rowId)
- {
- continue;
- }
-
- count++;
- prevId = rowId;
- }
-
- if (err != KSqlAtEnd)
- {
- User::Leave(err);
- }
-
- return count;
-
- }
-
-// ----------------------------------------------------------------------------
// CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL
// ----------------------------------------------------------------------------
//
@@ -485,14 +435,7 @@
{
MPX_DEBUG1(" EMPXMediaMusicArtist");
- TPtrC artistName(KNullDesC);
-
- // if album is unknown, ignore arist name
- if (MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) != KNullDesC)
- {
- artistName.Set(MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumArtistName));
- }
-
+ TPtrC artistName(MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumArtistName));
aMedia.SetTextValueL(KMPXMediaMusicArtist, artistName);
MPX_DEBUG2(" Artist[%S]", &artistName);
}
@@ -518,14 +461,7 @@
{
MPX_DEBUG1(" EMPXMediaMusicAlbumArtFileName");
- TPtrC art(KNullDesC);
-
- // if album is unknown, ignore album art name
- if (MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) != KNullDesC)
- {
- art.Set(MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumArt));
- }
-
+ TPtrC art(MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumArt));
aMedia.SetTextValueL(KMPXMediaMusicAlbumArtFileName, art);
MPX_DEBUG2(" Art[%S]", &art);
}
@@ -546,34 +482,10 @@
{
const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen);
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArt, albumArtFilename);
- }
-
- if (aMedia.IsSupported(KMPXMediaMusicArtist))
- {
- const TDesC& artistName = aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen);
- MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCAlbumArtistName, artistName);
- }
+ }
}
// ----------------------------------------------------------------------------
-// CMPXDbAlbum::IsUnknownArtistL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbAlbum::IsUnknownArtistL(TUint32 aId)
- {
- return iObserver.HandleIsUnknownArtistL(aId);
- }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::ArtistForAlbumL
-// ----------------------------------------------------------------------------
-//
-HBufC* CMPXDbAlbum::ArtistForAlbumL(const TUint32 aId)
- {
- return iObserver.HandleArtistForAlbumL(aId);
- }
-
-// ----------------------------------------------------------------------------
// CMPXDbAlbum::AlbumartForAlbumL
// ----------------------------------------------------------------------------
//
@@ -583,49 +495,29 @@
}
// ----------------------------------------------------------------------------
-// CMPXDbAlbum::CreateTableL
-// ----------------------------------------------------------------------------
-//
-void CMPXDbAlbum::CreateTableL(
- RSqlDatabase& aDatabase,
- TBool /* aCorruptTable */)
- {
- MPX_FUNC("CMPXDbCategory::CreateTableL");
-
- // create the table
- HBufC* query = PreProcessStringLC(KAlbumCreateTable);
- User::LeaveIfError(aDatabase.Exec(*query));
- CleanupStack::PopAndDestroy(query);
-
- // do not create an index on the Name field
- // as it only slows down the insert/update queries overall
- }
-
-// ----------------------------------------------------------------------------
-// CMPXDbAlbum::CheckTableL
-// ----------------------------------------------------------------------------
-//
-TBool CMPXDbAlbum::CheckTableL(
- RSqlDatabase& aDatabase)
- {
- MPX_FUNC("CMPXDbCategory::CheckTableL");
-
- HBufC* query = PreProcessStringLC(KAlbumCheckTable);
- TBool check(DoCheckTable(aDatabase, *query));
- CleanupStack::PopAndDestroy(query);
-
- return check;
- }
-
-// ----------------------------------------------------------------------------
// CMPXDbAlbum::ProcessAlbumRecordSetL
-// Unknown album is stored in the database as NULL (name field).
-// The first available unknown album is saved for later and will be appended to the array
-// as the last item and rest available unknown album will be ignored.
+// Unknown album or Unknown artist are stored in the database as NULL (Name field and ArtistName field).
+// The available unknown album is saved for later and will be appended to the array
+// as the last item among items which have the same artist.
+// The available unknown artists are saved for later and will be appended to the array
+// as the last items after all known artists are appended.
+// The unknown album and unknown artist is saved for later and will be appended to the array
+// as the last item.
//
// NOTE: putting unknown album to the end of the array only takes place when title
// field is requested. normal sorting algorithm occurs if title isn't
// requested.
+//
+// Example:
+// Album X of artist A
+// Album Y of artist A
+// Unknown album of artist A
+// Album X of artist B
+// Album Z of artist B
+// Unknown album of artist B
+// Album X of unknown artist
+// Album Y of unknown artist
+// Unknown album of unknown artist
// ----------------------------------------------------------------------------
//
void CMPXDbAlbum::ProcessAlbumRecordSetL(
@@ -634,12 +526,27 @@
CMPXMediaArray& aMediaArray)
{
// populate the array
- TBool unknownRecord(EFalse);
- TBool firstUnknownRecord(EFalse);
+ TBool firstRecord(ETrue);
+ CMPXMedia* unknownAlbumUnknownArtistMedia(NULL);
CMPXMedia* unknownMedia(NULL);
- TInt prevId(0);
+ TUint32 prevId(0);
+ TUint32 artistId(0);
+ TUint32 prevArtistId(0);
+ TInt count(0);
TInt err(KErrNone);
-
+
+ // Reset array for unknown artists
+ if (iUnknownArtists.Count() > 0)
+ {
+ iUnknownArtists.ResetAndDestroy();
+ }
+
+ // Reset array for unknown albums
+ if (iUnknownAlbums.Count() > 0)
+ {
+ iUnknownAlbums.ResetAndDestroy();
+ }
+
TInt pPath(0);
if (aMediaArray.Count())
{
@@ -650,6 +557,7 @@
MPX_ASSERT(pPath);
}
}
+
RArray<TMPXItemId> ids;
CleanupClosePushL(ids);
@@ -666,36 +574,58 @@
CleanupStack::PushL(media);
UpdateMediaL(aRecordset, aAttrs, *media);
+
+ artistId = aRecordset.ColumnInt64(EAlbumArtist);
- if (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName).Length() == 0)
+ // Append Known artist and Unknown albums
+ count = iUnknownAlbums.Count();
+ if (prevArtistId != artistId && count > 0)
{
- if (!unknownMedia)
+ unknownMedia = NULL;
+
+ for (TInt i = 0; i < count; i++)
{
- unknownMedia = media;
- firstUnknownRecord = ETrue;
+ unknownMedia = iUnknownAlbums[i];
+ if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath)
+ {
+ ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
+ }
+ aMediaArray.AppendL(*unknownMedia);
}
- unknownRecord = ETrue;
+
+ iUnknownAlbums.ResetAndDestroy();
}
- if (!unknownRecord)
+ // for Unknown artist and Unknown album
+ if (firstRecord && (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName).Length() == 0) &&
+ (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumArtistName).Length() == 0))
+ {
+ unknownAlbumUnknownArtistMedia = media;
+ }
+ // for Unknown artists and Known albums
+ else if (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumArtistName).Length() == 0)
+ {
+ iUnknownArtists.Append(media);
+ CleanupStack::Pop(media);
+ }
+ // for Known artist and Unknown album
+ else if (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName).Length() == 0)
+ {
+ iUnknownAlbums.Append(media);
+ CleanupStack::Pop(media);
+ prevArtistId = artistId;
+ }
+ else
{
if (media->IsSupported(KMPXMediaGeneralId) && pPath)
{
ids.AppendL(media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
}
aMediaArray.AppendL(*media);
+ CleanupStack::PopAndDestroy(media);
}
- if (!firstUnknownRecord)
- {
- CleanupStack::PopAndDestroy(media);
- }
- else
- {
- firstUnknownRecord = EFalse;
- }
-
- unknownRecord = EFalse;
+ firstRecord = EFalse;
} // end while
if (err != KSqlAtEnd)
@@ -703,16 +633,55 @@
User::LeaveIfError(err);
}
- if (unknownMedia)
+ // Append Known artist and Unknown albums
+ count = iUnknownAlbums.Count();
+ if ( count > 0)
{
- if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath)
+ unknownMedia = NULL;
+
+ for (TInt i = 0; i < count; i++)
{
- ids.AppendL(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
+ unknownMedia = iUnknownAlbums[i];
+ if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath)
+ {
+ ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
+ }
+ aMediaArray.AppendL(*unknownMedia);
}
- aMediaArray.AppendL(*unknownMedia);
- CleanupStack::PopAndDestroy(unknownMedia);
+
+ iUnknownAlbums.ResetAndDestroy();
}
+ // Append Unknown artists to MediaArray
+ count = iUnknownArtists.Count();
+ if ( count > 0)
+ {
+ CMPXMedia* unknownMedia = NULL;
+
+ for (TInt i = 0; i < count; i++)
+ {
+ unknownMedia = iUnknownArtists[i];
+ if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath)
+ {
+ ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
+ }
+ aMediaArray.AppendL(*unknownMedia);
+ }
+
+ iUnknownArtists.ResetAndDestroy();
+ }
+
+ // the last item in the list
+ if (unknownAlbumUnknownArtistMedia)
+ {
+ if (unknownAlbumUnknownArtistMedia->IsSupported(KMPXMediaGeneralId) && pPath)
+ {
+ ids.AppendL(unknownAlbumUnknownArtistMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
+ }
+ aMediaArray.AppendL(*unknownAlbumUnknownArtistMedia);
+ CleanupStack::PopAndDestroy(unknownAlbumUnknownArtistMedia);
+ }
+
// Append ids to the returned path
if (pPath)
{
@@ -721,4 +690,194 @@
CleanupStack::PopAndDestroy(&ids);
}
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::GenerateUniqueIdL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbAlbum::GenerateUniqueIdL(const CMPXMedia& aMedia)
+ {
+ TPtrC album(KNullDesC);
+ TPtrC albumArtist(KNullDesC);
+ TPtrC artist(KNullDesC);
+
+ // check Album attirbute
+ if (aMedia.IsSupported(KMPXMediaMusicAlbum))
+ {
+ album.Set(aMedia.ValueText(KMPXMediaMusicAlbum).Left(KMCMaxTextLen));
+ }
+
+ HBufC* buf(NULL);
+ if (RetrieveAlbumArtistL(aMedia, albumArtist))
+ {
+ buf = HBufC::NewLC(album.Length() + albumArtist.Length() + KAlbumAlbumArtistSeperator().Length());
+
+ buf->Des().Append(album);
+ buf->Des().Append(KAlbumAlbumArtistSeperator);
+ buf->Des().Append(albumArtist);
+ }
+ else
+ {
+ RetrieveArtist(aMedia, artist);
+
+ buf = HBufC::NewLC(album.Length() + artist.Length() + KAlbumArtistSeperator().Length());
+
+ buf->Des().Append(album);
+ buf->Des().Append(KAlbumArtistSeperator);
+ buf->Des().Append(artist);
+ }
+
+ // try to find the item first
+ TUint32 id(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXAlbum,
+ *buf, ETrue));
+ CleanupStack::PopAndDestroy(buf);
+
+ return id;
+ }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::IsUnknownAlbumL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbAlbum::IsUnknownAlbumL(const TUint32 aId)
+ {
+ HBufC* query = PreProcessStringLC(KQueryCategoryItem);
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, aId));
+ CleanupStack::PopAndDestroy(query);
+ CleanupClosePushL(recordset);
+
+ if (recordset.Next() != KSqlAtRow)
+ {
+ User::Leave(KErrNotFound);
+ }
+
+ TPtrC album(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumName));
+ TPtrC artistName(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArtistName));
+
+ TBool ret = EFalse;
+ if (album.Length() == 0 || artistName.Length() == 0)
+ {
+ ret = ETrue;
+ }
+ else
+ {
+ ret = EFalse;
+ }
+
+ CleanupStack::PopAndDestroy(&recordset);
+
+ return ret;
+ }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::RetrieveAlbumArtistL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbAlbum::RetrieveAlbumArtistL(const CMPXMedia& aMedia, TPtrC& aName)
+ {
+ // check AlbumArtist attribute
+ if (aMedia.IsSupported(KMPXMediaMusicAlbumArtist))
+ {
+ aName.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen));
+ }
+ else
+ {
+ aName.Set(KNullDesC);
+ }
+
+ if (aName.Length() > 0 )
+ {
+ return ETrue;
+ }
+ else
+ {
+ return EFalse;
+ }
+ }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::RetrieveArtist
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAlbum::RetrieveArtist(const CMPXMedia& aMedia, TPtrC& aName)
+ {
+ // check Artist attribute
+ if (aMedia.IsSupported(KMPXMediaMusicArtist))
+ {
+ aName.Set(aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen));
+ }
+ else
+ {
+ aName.Set(KNullDesC);
+ }
+ }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::NeedToUpdateArt
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbAlbum::NeedToUpdateArt(const TDesC& aDeletedSongArt, const TDesC& aCurrentAlbumArt)
+ {
+ if (aDeletedSongArt.Length() == 0)
+ {
+ // Deleted song's art has default album art
+ return EFalse;
+ }
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+ else
+ if (aDeletedSongArt.Length() > 0)
+ {
+ TParsePtrC parse(aDeletedSongArt);
+ TPtrC ext(parse.Ext());
+ //set flag to false, so .alb will not overwrite art field in album, artist table
+ // when song with embedded art
+ if (ext.CompareF(KAbstractAlbumExt) == 0)
+ {
+ // Deleted song's art is Non-embedded album art
+ return EFalse;
+ }
+ }
+ else
+#endif
+ if (aDeletedSongArt.Length() > 0 && aCurrentAlbumArt.Length() > 0 && aDeletedSongArt.CompareF(aCurrentAlbumArt) == 0)
+ {
+ // Deleted song's art is Embedded album art and it is the same as Album's current art
+ return ETrue;
+ }
+ else
+ {
+ return EFalse;
+ }
+ }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::CreateTableL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbAlbum::CreateTableL(
+ RSqlDatabase& aDatabase,
+ TBool /* aCorruptTable */)
+ {
+ MPX_FUNC("CMPXDbCategory::CreateTableL");
+
+ // create the table
+ User::LeaveIfError(aDatabase.Exec(KAlbumCreateTable));
+
+ // do not create an index on the Name field
+ // as it only slows down the insert/update queries overall
+ }
+
+// ----------------------------------------------------------------------------
+// CMPXDbAlbum::CheckTableL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbAlbum::CheckTableL(
+ RSqlDatabase& aDatabase)
+ {
+ MPX_FUNC("CMPXDbCategory::CheckTableL");
+
+ TBool check(DoCheckTable(aDatabase, KAlbumCheckTable));
+
+ return check;
+ }
+
// End of File
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbartist.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbartist.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -42,12 +42,11 @@
//
CMPXDbArtist* CMPXDbArtist::NewL(
CMPXDbManager& aDbManager,
- TMPXGeneralCategory aCategory,
- MMPXDbArtistObserver& aObserver)
+ TMPXGeneralCategory aCategory)
{
MPX_FUNC("CMPXDbArtist::NewL");
- CMPXDbArtist* self = CMPXDbArtist::NewLC(aDbManager, aCategory, aObserver);
+ CMPXDbArtist* self = CMPXDbArtist::NewLC(aDbManager, aCategory);
CleanupStack::Pop(self);
return self;
}
@@ -58,12 +57,11 @@
//
CMPXDbArtist* CMPXDbArtist::NewLC(
CMPXDbManager& aDbManager,
- TMPXGeneralCategory aCategory,
- MMPXDbArtistObserver& aObserver)
+ TMPXGeneralCategory aCategory)
{
MPX_FUNC("CMPXDbArtist::NewLC");
- CMPXDbArtist* self = new (ELeave) CMPXDbArtist(aDbManager, aCategory, aObserver);
+ CMPXDbArtist* self = new (ELeave) CMPXDbArtist(aDbManager, aCategory);
CleanupStack::PushL(self);
self->ConstructL();
return self;
@@ -84,10 +82,8 @@
//
CMPXDbArtist::CMPXDbArtist(
CMPXDbManager& aDbManager,
- TMPXGeneralCategory aCategory,
- MMPXDbArtistObserver& aObserver) :
- CMPXDbCategory(aDbManager, aCategory),
- iObserver(aObserver)
+ TMPXGeneralCategory aCategory) :
+ CMPXDbCategory(aDbManager, aCategory)
{
MPX_FUNC("CMPXDbArtist::CMPXDbArtist");
}
@@ -108,58 +104,63 @@
// ----------------------------------------------------------------------------
//
TUint32 CMPXDbArtist::AddItemL(
- const TDesC& aName,
- const TDesC& aArt,
+ TMPXGeneralCategory /*aCategory*/,
+ const CMPXMedia& aMedia,
TInt aDriveId,
TBool& aNewRecord,
TBool aCaseSensitive)
{
MPX_FUNC("CMPXDbArtist::AddItemL");
+ TPtrC artist(KNullDesC);
+ TPtrC albumArt(KNullDesC);
+
+ if (aMedia.IsSupported(KMPXMediaMusicArtist))
+ {
+ artist.Set(aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen));
+ }
+
+ if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
+ {
+ albumArt.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen));
+ }
+
// try to find the item first
TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory,
- aName, aCaseSensitive));
- aNewRecord = !CategoryItemExistsL(aDriveId, rowId);
+ artist, aCaseSensitive));
- if (aNewRecord)
+ HBufC* query = PreProcessStringLC(KQueryCategoryItem);
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDriveId, *query, rowId));
+ CleanupStack::PopAndDestroy(query);
+ CleanupClosePushL(recordset);
+
+ TInt result(recordset.Next());
+ if (result == KSqlAtEnd)
{
+ aNewRecord = result;
+
// insert new
- HBufC* query = PreProcessStringLC(KQueryArtistInsert);
- HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
- HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(aArt);
+ HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(artist);
+ HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(albumArt);
- iDbManager.ExecuteQueryL(aDriveId, *query, rowId, name, 1, art);
+ iDbManager.ExecuteQueryL(aDriveId, KQueryArtistInsert, rowId, name, 1, 0, art);
CleanupStack::PopAndDestroy(art);
CleanupStack::PopAndDestroy(name);
- CleanupStack::PopAndDestroy(query);
}
- else
+ else if (result == KSqlAtRow)
{
- // retrieve the existing record
- HBufC* query = NULL;
- query = PreProcessStringLC(KQueryCategoryItem);
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, rowId));
- CleanupStack::PopAndDestroy(query);
-
- CleanupClosePushL(recordset);
-
- if (recordset.Next() != KSqlAtRow)
- {
- User::Leave(KErrNotFound);
- }
-
- // Album Art
+ // retrieve Art from Artist table
TPtrC art(KNullDesC);
art.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EArtistArt));
// the current one is Unknown and the new one is Not Unknown
- if ( art == KNullDesC && aArt != KNullDesC )
+ if ( art == KNullDesC && albumArt != KNullDesC )
{
HBufC* artReplaceSingleQuote =
- MPXDbCommonUtil::ProcessSingleQuotesLC( aArt );
+ MPXDbCommonUtil::ProcessSingleQuotesLC( albumArt );
_LIT( KFormatArt, "Art=\'%S\'" );
- HBufC* setStr = HBufC::NewLC(256);
+ HBufC* setStr = HBufC::NewLC(KMaxFileName);
setStr->Des().Format( KFormatArt, artReplaceSingleQuote );
iDbManager.ExecuteQueryL(aDriveId, KQueryArtistUpdate, setStr, rowId);
@@ -167,35 +168,68 @@
CleanupStack::PopAndDestroy(artReplaceSingleQuote);
}
- CleanupStack::PopAndDestroy(&recordset);
-
// increment the number of songs for the category
query = PreProcessStringLC(KQueryCategoryIncrementSongCount);
iDbManager.ExecuteQueryL(aDriveId, *query, rowId);
CleanupStack::PopAndDestroy(query);
}
-
+ else
+ {
+ MPX_DEBUG2("SQL error %d", result);
+ User::Leave(result);
+ }
+
+ CleanupStack::PopAndDestroy(&recordset);
+
return rowId;
}
-
+
// ----------------------------------------------------------------------------
-// CMPXDbArtist::IsUnknownArtistL
+// CMPXDbArtist::DecrementSongsForCategoryL
// ----------------------------------------------------------------------------
//
-TBool CMPXDbArtist::IsUnknownArtistL(TUint32 aId)
+void CMPXDbArtist::DecrementSongsForCategoryL(
+ const TUint32 aId,
+ TInt aDriveId,
+ CMPXMessageArray* aItemChangedMessages,
+ TBool& aItemExist
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+ ,
+ TBool /*aMTPInUse*/
+#endif //ABSTRACTAUDIOALBUM_INCLUDED
+ )
{
- MPX_FUNC("CMPXDbArtist::IsUnknownArtistL");
-
- HBufC* name = GetNameL(aId);
+ MPX_FUNC("CMPXDbArtist::DecrementSongsForCategoryL");
+
+ TInt songsCount(0);
+ TInt albumsCount(0);
+
+ GetSongsAndAlbumsCountL(aDriveId, aId, songsCount, albumsCount);
+
+ MPX_DEBUG4("id %d, songsCount %d, albumsCount %d", aId, songsCount, albumsCount);
+
+ // if just one song uses this category. Use <= just in case
+ if (songsCount <= 1 && albumsCount == 0)
+ {
+ aItemExist = EFalse;
+ // delete the category
+ DeleteCategoryL(aId, aDriveId);
- TInt ret = EFalse;
- if (*name == KNullDesC)
- {
- ret = ETrue;
- }
- delete name;
-
- return ret;
+ if (aItemChangedMessages)
+ {
+ // add the item changed message
+ MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aId, EMPXItemDeleted,
+ iCategory, KDBPluginUid);
+ }
+ }
+ else if (songsCount > 0)
+ {
+ aItemExist = ETrue;
+ // decrement the number of songs for the category
+ HBufC* query = PreProcessStringLC(KQueryCategoryDecrementSongCount);
+ iDbManager.ExecuteQueryL(aDriveId, *query, aId);
+ CleanupStack::PopAndDestroy(query);
+ }
}
// ----------------------------------------------------------------------------
@@ -237,10 +271,6 @@
}
if (attributeId & EMPXMediaGeneralCount)
{
-// TInt albumCount = GetAlbumsCountL(aRecord.ColumnInt64(EArtistUniqueId));
-// aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount,albumCount);
-// MPX_DEBUG1(" EMPXMediaGeneralCount");
-// MPX_DEBUG2(" AlbumCount[%d]", albumCount);
// get songs count from all drives
TInt songCount = GetSongsCountL( KDbManagerAllDrives,
aRecord.ColumnInt64( EArtistUniqueId ) );
@@ -281,17 +311,6 @@
}
// ----------------------------------------------------------------------------
-// CMPXDbArtist::GetAlbumsCountL
-// ----------------------------------------------------------------------------
-//
-TInt CMPXDbArtist::GetAlbumsCountL(TUint32 aId)
- {
- MPX_FUNC("CMPXDbArtist::GetAlbumsCountL");
-
- return iObserver.HandleGetAlbumsCountForArtistL(aId);
- }
-
-// ----------------------------------------------------------------------------
// CMPXDbArtist::GetAllCategoryItemsL
// ----------------------------------------------------------------------------
//
@@ -300,9 +319,7 @@
CMPXMediaArray& aMediaArray)
{
MPX_FUNC("CMPXDbArtist::GetAllCategoryItemsL");
- HBufC* query = PreProcessStringLC(KQueryArtistAll);
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
- CleanupStack::PopAndDestroy(query);
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryArtistAll()));
CleanupClosePushL(recordset);
ProcessRecordsetL(aAttrs, recordset, aMediaArray);
CleanupStack::PopAndDestroy(&recordset);
@@ -343,37 +360,169 @@
CleanupStack::PopAndDestroy(values);
CleanupStack::PopAndDestroy(fields);
}
+
// ----------------------------------------------------------------------------
-// CMPXDbAlbum::CreateTableL
+// CMPXDbArtist::AddAlbumArtistL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbArtist::AddAlbumArtistL(
+ const TDesC& aName,
+ const TDesC& aArt,
+ TInt aDriveId)
+ {
+ MPX_FUNC("CMPXDbArtist::AddAlbumArtistL");
+
+ // try to find the item first
+ TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory,
+ aName, ETrue));
+ HBufC* query = PreProcessStringLC(KQueryCategoryItem);
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(aDriveId, *query, rowId));
+ CleanupStack::PopAndDestroy(query);
+ CleanupClosePushL(recordset);
+
+ TInt result(recordset.Next());
+ if (result == KSqlAtEnd)
+ {
+ // insert new
+ HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
+ HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(aArt);
+
+ iDbManager.ExecuteQueryL(aDriveId, KQueryArtistInsert, rowId, name, 0, 1, art);
+
+ CleanupStack::PopAndDestroy(art);
+ CleanupStack::PopAndDestroy(name);
+ }
+ else if (result == KSqlAtRow)
+ {
+ // retrieve Art from Artist table
+ TPtrC art(KNullDesC);
+ art.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EArtistArt));
+
+ // the current one is Unknown and the new one is Not Unknown
+ if ( art == KNullDesC && aArt != KNullDesC )
+ {
+ HBufC* artReplaceSingleQuote =
+ MPXDbCommonUtil::ProcessSingleQuotesLC( aArt );
+ _LIT( KFormatArt, "Art=\'%S\'" );
+ HBufC* setStr = HBufC::NewLC(KMaxFileName);
+ setStr->Des().Format( KFormatArt, artReplaceSingleQuote );
+
+ iDbManager.ExecuteQueryL(aDriveId, KQueryArtistUpdate, setStr, rowId);
+ CleanupStack::PopAndDestroy(setStr);
+ CleanupStack::PopAndDestroy(artReplaceSingleQuote);
+ }
+
+ // increment the number of songs for the category
+ iDbManager.ExecuteQueryL(aDriveId, KQueryArtistIncrementAlbumCount, rowId);
+ }
+ else
+ {
+ MPX_DEBUG2("SQL error %d", result);
+ User::Leave(result);
+ }
+
+ CleanupStack::PopAndDestroy(&recordset);
+
+ return rowId;
+ }
+
+// ----------------------------------------------------------------------------
+// CMPXDbArtist::DecrementAlbumsForArtistL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbArtist::DecrementAlbumsForArtistL(
+ const TUint32 aId,
+ TInt aDriveId,
+ CMPXMessageArray* aItemChangedMessages
+ )
+ {
+ MPX_FUNC("CMPXDbArtist::DecrementAlbumsForCategoryL");
+
+ TInt songsCount(0);
+ TInt albumsCount(0);
+
+ GetSongsAndAlbumsCountL(aDriveId, aId, songsCount, albumsCount);
+
+ MPX_DEBUG4("id %d, songsCount %d, albumsCount %d", aId, songsCount, albumsCount);
+
+ // if just one album uses this category. Use <= just in case
+ if (songsCount == 0 && albumsCount <= 1)
+ {
+ // delete the category
+ DeleteCategoryL(aId, aDriveId);
+
+ if (aItemChangedMessages)
+ {
+ // add the item changed message
+ MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aId, EMPXItemDeleted,
+ iCategory, KDBPluginUid);
+ }
+ }
+ else if (albumsCount > 0)
+ {
+ // decrement the number of albums for the category
+ iDbManager.ExecuteQueryL(aDriveId, KQueryArtistDecrementAlbumCount, aId);
+ }
+ }
+
+// ----------------------------------------------------------------------------
+// CMPXDbArtist::GetSongsAndAlbumsCountL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbArtist::GetSongsAndAlbumsCountL(
+ TInt aDriveId,
+ TUint32 aId,
+ TInt& aSongCount,
+ TInt& aAlbumCount)
+ {
+ MPX_FUNC("CMPXDbArtist::GetSongsAndAlbumsCountL");
+
+ RSqlStatement recordset(
+ iDbManager.ExecuteSelectQueryL(aDriveId, KQueryArtistGetSongCountAndAlbumCount, aId));
+ CleanupClosePushL(recordset);
+
+ TInt err(KErrNone);
+ while ((err = recordset.Next()) == KSqlAtRow)
+ {
+ aSongCount += recordset.ColumnInt(KMPXTableDefaultIndex);
+ aAlbumCount += recordset.ColumnInt(KMPXTableDefaultIndex+1);
+ }
+
+ if (err != KSqlAtEnd)
+ {
+ User::Leave(err);
+ }
+
+ CleanupStack::PopAndDestroy(&recordset);
+ }
+
+// ----------------------------------------------------------------------------
+// CMPXDbArtist::CreateTableL
// ----------------------------------------------------------------------------
//
void CMPXDbArtist::CreateTableL(
RSqlDatabase& aDatabase,
TBool /* aCorruptTable */)
{
- MPX_FUNC("CMPXDbCategory::CreateTableL");
+ MPX_FUNC("CMPXDbArtist::CreateTableL");
// create the table
- HBufC* query = PreProcessStringLC(KArtistCreateTable);
- User::LeaveIfError(aDatabase.Exec(*query));
- CleanupStack::PopAndDestroy(query);
+ User::LeaveIfError(aDatabase.Exec(KArtistCreateTable));
// do not create an index on the Name field
// as it only slows down the insert/update queries overall
}
// ----------------------------------------------------------------------------
-// CMPXDbAlbum::CheckTableL
+// CMPXDbArtist::CheckTableL
// ----------------------------------------------------------------------------
//
TBool CMPXDbArtist::CheckTableL(
RSqlDatabase& aDatabase)
{
- MPX_FUNC("CMPXDbCategory::CheckTableL");
+ MPX_FUNC("CMPXDbArtist::CheckTableL");
- HBufC* query = PreProcessStringLC(KArtistCheckTable);
- TBool check(DoCheckTable(aDatabase, *query));
- CleanupStack::PopAndDestroy(query);
+ TBool check(DoCheckTable(aDatabase, KArtistCheckTable));
return check;
}
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbauxiliary.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbauxiliary.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -111,7 +111,7 @@
{
MPX_FUNC("CMPXDbAuxiliary::LastRefreshedTimeL");
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime));
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime()));
CleanupClosePushL(recordset);
if (recordset.Next() != KSqlAtRow)
@@ -195,7 +195,7 @@
TBool refreshed(ETrue);
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime));
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime()));
CleanupClosePushL(recordset);
TInt count(0);
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbcategory.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbcategory.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -30,6 +30,7 @@
#include "mpxdbpluginqueries.h"
#include "mpxdbutil.h"
#include "mpxdbcategory.h"
+#include "mpxmediamusicdefs.h"
// CONSTANTS
@@ -79,23 +80,26 @@
// ----------------------------------------------------------------------------
//
TUint32 CMPXDbCategory::AddItemL(
- const TDesC& aName,
+ TMPXGeneralCategory aCategory,
+ const CMPXMedia& aMedia,
TInt aDriveId,
TBool& aNewRecord,
TBool aCaseSensitive)
{
MPX_FUNC("CMPXDbCategory::AddItemL");
+ TPtrC itemName(ItemNameL(aCategory, aMedia));
+
// try to find the item first
TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory,
- aName, aCaseSensitive));
+ itemName, aCaseSensitive));
aNewRecord = !CategoryItemExistsL(aDriveId, rowId);
if (aNewRecord)
{
// insert new
HBufC* query = PreProcessStringLC(KQueryCategoryInsert);
- HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
+ HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(itemName);
iDbManager.ExecuteQueryL(aDriveId, *query, rowId, name, 1);
@@ -112,7 +116,7 @@
return rowId;
}
-
+
// ----------------------------------------------------------------------------
// CMPXDbCategory::GetNameL
// ----------------------------------------------------------------------------
@@ -240,20 +244,37 @@
}
// construct criteria string
- HBufC* criteriaStr = MPXDbCommonUtil::StringFromArrayLC(*criteriaArray, KMCAndKeyword);
+ HBufC* criteriaStr = NULL;
+ if (criteriaArray->Count() > 0)
+ {
+ criteriaStr = MPXDbCommonUtil::StringFromArrayLC(*criteriaArray, KMCAndKeyword);
+ }
+ else
+ {
+ _LIT(KCriteriaTrue, "1");
+ criteriaStr = KCriteriaTrue().AllocLC();
+ }
+
+ RSqlStatement recordset;
+ if (iCategory == EMPXArtist)
+ {
+ recordset = iDbManager.ExecuteSelectQueryL(KQueryArtistItems, criteriaStr);
+ CleanupStack::PopAndDestroy(2, criteriaArray); //criteriaStr, criteriaArray
+ }
+ else
+ {
+ HBufC* query = PreProcessStringLC(KQueryCategoryItems);
+ recordset = iDbManager.ExecuteSelectQueryL(*query, criteriaStr);
+ CleanupStack::PopAndDestroy(3, criteriaArray); //query, criteriaStr, criteriaArray
+ }
- // either get all items or items filtered based on criteria
- HBufC* query = PreProcessStringLC(criteriaStr->Length() ?
- KQueryCategoryItems() : KQueryCategoryAll());
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, criteriaStr));
- CleanupStack::PopAndDestroy(3, criteriaArray); // query, criteriaStr, criteriaArray
CleanupClosePushL(recordset);
// process the results
ProcessRecordsetL(aAttrs, recordset, aMediaArray);
CleanupStack::PopAndDestroy(&recordset);
}
-
+
// ----------------------------------------------------------------------------
// CMPXDbCategory::DecrementSongsForCategoryL
// ----------------------------------------------------------------------------
@@ -486,7 +507,9 @@
TInt /*aDriveId*/,
CMPXMessageArray* /*aItemChangedMessages*/)
{
- // nothing
+ MPX_FUNC("CMPXDbCategory::UpdateItemL");
+
+ // do nothing
}
// ----------------------------------------------------------------------------
@@ -574,7 +597,7 @@
// ----------------------------------------------------------------------------
// CMPXDbCategory::ProcessRecordsetL
-// Unknown item is stored in the database as NULL (name field). This ensures the
+// Unknown item is stored in the database as empty string (name field). This ensures the
// unknown item to be the 1st found record if it exists. This will save time in
// searching for the unknown record among the results and avoid performing
// descriptor comparison. If the 1st record is the unknown item, it won't be
@@ -666,6 +689,46 @@
}
// ----------------------------------------------------------------------------
+// CMPXDbCategory::ItemNameL
+// ----------------------------------------------------------------------------
+//
+TPtrC CMPXDbCategory::ItemNameL(
+ TMPXGeneralCategory aCategory,
+ const CMPXMedia& aMedia)
+ {
+ MPX_FUNC("CMPXDbCategory::ItemNameL");
+
+ TMPXAttribute attribute;
+ switch(aCategory)
+ {
+ case EMPXGenre:
+ {
+ attribute = KMPXMediaMusicGenre;
+ break;
+ }
+ case EMPXComposer:
+ {
+ attribute = KMPXMediaMusicComposer;
+ break;
+ }
+ default:
+ {
+ User::Leave(KErrArgument);
+ break;
+ }
+ }
+
+ if (aMedia.IsSupported(attribute))
+ {
+ return aMedia.ValueText(attribute).Left(KMCMaxTextLen);
+ }
+ else
+ {
+ return KNullDesC();
+ }
+ }
+
+// ----------------------------------------------------------------------------
// CMPXDbCategory::CreateTableL
// ----------------------------------------------------------------------------
//
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbhandler.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbhandler.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -174,7 +174,7 @@
//
iDbMusic = CMPXDbMusic::NewL(*iDbManager, iResource, *this);
iDbPlaylist = CMPXDbPlaylist::NewL(*iDbManager, *this);
- iDbArtist = CMPXDbArtist::NewL(*iDbManager, EMPXArtist, *this);
+ iDbArtist = CMPXDbArtist::NewL(*iDbManager, EMPXArtist);
iDbAlbum = CMPXDbAlbum::NewL(*iDbManager, EMPXAlbum, *this);
iDbGenre = CMPXDbGenre::NewL(*iDbManager, EMPXGenre);
iDbComposer = CMPXDbComposer::NewL(*iDbManager, EMPXComposer);
@@ -987,18 +987,18 @@
{
MPX_DEBUG1(" EMPXMediaGeneralCount");
- attributes.Append(TMPXAttribute(KMPXMediaIdGeneral, attributeId & ~EMPXMediaGeneralCount));
+ attributes.AppendL(TMPXAttribute(KMPXMediaIdGeneral, attributeId & ~EMPXMediaGeneralCount));
tryGetSongCount = ETrue;
break;
}
- attributes.Append(aAttrs[i]);
+ attributes.AppendL(aAttrs[i]);
}
for (TInt j = i+1; j < attrCount; j++)
{
- attributes.Append(aAttrs[j]);
+ attributes.AppendL(aAttrs[j]);
}
iDbAlbum->GetSubCategoryItemsL(EMPXArtist, aArtistId, attributes.Array(), aMediaArray);
CleanupStack::PopAndDestroy(&attributes);
@@ -2148,7 +2148,7 @@
// Update the category records
TBool categoryExist( EFalse );
iDbArtist->DecrementSongsForCategoryL(artistID, drive, &aItemChangedMessages, categoryExist);
- iDbAlbum->DecrementSongsForCategoryL(albumID, drive, &aItemChangedMessages, categoryExist, artistID, *art);
+ iDbAlbum->DecrementSongsForAlbumL(albumID, drive, &aItemChangedMessages, categoryExist, *art);
iDbGenre->DecrementSongsForCategoryL(genreID, drive, &aItemChangedMessages, categoryExist);
iDbComposer->DecrementSongsForCategoryL(composerID, drive, &aItemChangedMessages, categoryExist);
CleanupStack::PopAndDestroy(art);
@@ -2551,7 +2551,16 @@
//////////////////////////////////////////////////////////////////////
else
{
- iDbMusic->FindSongsL(id, containerId, type, aCriteria, aAttrs, aMediaArray);
+ TBool sortByTrackOrder = EFalse;
+
+ // construct the sort order depending on category. Albums are always sorted by track,
+ // then name, except for unknown album. Songs are sorted by name for unknown album.
+ // NULL track number is stored as KMaxTInt so that they will be sorted to the end
+ if ((type == EMPXGroup) && (MPX_ITEM_CATEGORY(id) == EMPXAlbum) && !iDbAlbum->IsUnknownAlbumL(id))
+ {
+ sortByTrackOrder = ETrue;
+ }
+ iDbMusic->FindSongsL(id, containerId, type, aCriteria, aAttrs, aMediaArray, sortByTrackOrder);
}
}
@@ -3037,103 +3046,63 @@
#endif // RD_MULTIPLE_DRIVE
// ----------------------------------------------------------------------------
+// CMPXDbHandler::AddAbstractAlbumItemL
+// ----------------------------------------------------------------------------
+//
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+TUint32 CMPXDbHandler::AddAbstractAlbumItemL(
+ const TDesC& aName,
+ TInt aDriveId,
+ CMPXMessageArray* aItemChangedMessages,
+ TBool& aItemExist,
+ const TDesC& aUri,
+ const TDesC& aAlbumArtist
+ )
+ {
+ MPX_FUNC("CMPXDbHandler::AddAbstractAlbumItemL()");
+
+ MPX_PERF_START(CMPXDbHandler_AddAbstractAlbumItemL);
+
+ TBool newRecord(EFalse);
+ TUint32 id(0);
+
+ //AbstractAlbum is not case sensitive
+ id = iDbAbstractAlbum->AddItemL(aUri, aName, aAlbumArtist, aDriveId, newRecord, EFalse);
+ MPX_PERF_END(CMPXDbHandler_AddAbstractAlbumItemL);
+
+ return id;
+ }
+#endif
+
+// ----------------------------------------------------------------------------
// CMPXDbHandler::AddCategoryItemL
// ----------------------------------------------------------------------------
//
TUint32 CMPXDbHandler::AddCategoryItemL(
TMPXGeneralCategory aCategory,
- const TDesC& aName,
+ const CMPXMedia& aMedia,
TInt aDriveId,
CMPXMessageArray* aItemChangedMessages,
- TBool& aItemExist
-#ifdef ABSTRACTAUDIOALBUM_INCLUDED
- ,const TDesC& aUri
- ,const TDesC& aAlbumArtist
-#endif // ABSTRACTAUDIOALBUM_INCLUDED
- )
+ TBool& aItemExist)
{
MPX_FUNC("CMPXDbHandler::AddCategoryItemL()");
-
+
MPX_PERF_START(CMPXDbHandler_AddCategoryItemL);
+ ASSERT(aCategory != EMPXAbstractAlbum);
+
TBool newRecord(EFalse);
-#ifdef ABSTRACTAUDIOALBUM_INCLUDED
- TUint32 id(0);
- //for AbstractAlbum, SetAbstractAlbum, associate songs with abstractalbum.
- //only called with newRecord as EFalse
- //increment songCount if id exist in AbstractAlbum table, otherwise do nothing.
-
- //only Genre, AbstractAlbum are not case sensitive
- TBool caseSensitive = ETrue;
- if ((aCategory == EMPXGenre) || (aCategory == EMPXAbstractAlbum))
- caseSensitive = EFalse;
-
- if (aCategory == EMPXAbstractAlbum)
- {
- id = iDbAbstractAlbum->AddItemL(aUri, aName, aAlbumArtist, aDriveId, newRecord, caseSensitive);
- }
- else
- {
- id = DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord, caseSensitive);
-#else
- TUint32 id(DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord, (aCategory != EMPXGenre)));
-#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+ TUint32 id = DbCategoryL(aCategory)->AddItemL(aCategory, aMedia, aDriveId, newRecord, aCategory != EMPXGenre);
if (newRecord && aItemChangedMessages)
{
MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemInserted,
aCategory, KDBPluginUid);
}
- // when the added item's category is Genre or Composer,
- // and it is NOT a new record,
+ // when the added item's category is Genre, Composer or Artist, and it is NOT a new record,
// we should send the item number changed message
- else if ( ( aCategory == EMPXGenre || aCategory == EMPXComposer ) &&
- !newRecord && aItemChangedMessages )
- {
- MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemModified,
- aCategory, KDBPluginUid);
- }
- aItemExist = !newRecord;
-#ifdef ABSTRACTAUDIOALBUM_INCLUDED
- }
-#endif // ABSTRACTAUDIOALBUM_INCLUDED
- MPX_PERF_END(CMPXDbHandler_AddCategoryItemL);
- return id;
- }
-
-TUint32 CMPXDbHandler::AddCategoryItemL(
- TMPXGeneralCategory aCategory,
- const TDesC& aName,
- const TDesC& aArtistName,
- const TDesC& aArt,
- TInt aDriveId,
- CMPXMessageArray* aItemChangedMessages,
- TBool& aItemExist)
- {
- MPX_FUNC("CMPXDbHandler::AddCategoryItemL()");
-
- MPX_PERF_START(CMPXDbHandler_AddCategoryItemL);
-
- TBool newRecord(EFalse);
-
- TUint32 id = 0;
- if(aCategory == EMPXAlbum)
- {
- id = iDbAlbum->AddItemL(aName, aArtistName, aArt, aDriveId, newRecord, (aCategory != EMPXGenre));
- }
- else
- {
- id = iDbArtist->AddItemL(aName, aArt, aDriveId, newRecord, (aCategory != EMPXGenre));
- }
-
- if (newRecord && aItemChangedMessages)
- {
- MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemInserted,
- aCategory, KDBPluginUid);
- }
- // when the added item's category is Artist, and it is NOT a new record,
- // we should send the item number changed message
- else if ( aCategory == EMPXArtist &&
+ else if ( ( aCategory == EMPXGenre || aCategory == EMPXComposer || aCategory == EMPXArtist) &&
!newRecord && aItemChangedMessages )
{
MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemModified,
@@ -3142,31 +3111,23 @@
aItemExist = !newRecord;
MPX_PERF_END(CMPXDbHandler_AddCategoryItemL);
- return id;
+ return id;
}
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::UpdateCategoryItemL
+// ----------------------------------------------------------------------------
+//
void CMPXDbHandler::UpdateCategoryItemL(
- TMPXGeneralCategory aCategory,
- TUint32 aCategoryId,
- const CMPXMedia& aMedia,
- TInt aDrive,
- CMPXMessageArray* aItemChangedMessages)
+ TMPXGeneralCategory aCategory,
+ TUint32 aCategoryId,
+ const CMPXMedia& aMedia,
+ TInt aDrive,
+ CMPXMessageArray* aItemChangedMessages)
{
- switch(aCategory)
- {
- case EMPXAlbum:
- iDbAlbum->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
- break;
-
- case EMPXArtist:
- iDbArtist->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
- break;
-
- default:
- DbCategoryL(aCategory)->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
- break;
- }
+ DbCategoryL(aCategory)->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
}
+
// ----------------------------------------------------------------------------
// CMPXDbHandler::DeleteSongForCategoryL
// ----------------------------------------------------------------------------
@@ -3176,11 +3137,21 @@
TUint32 aCategoryId,
TInt aDriveId,
CMPXMessageArray* aItemChangedMessages,
- TBool& aItemExist)
+ TBool& aItemExist,
+ const TDesC& aArt
+ )
{
MPX_FUNC("CMPXDbHandler::DeleteSongForCategoryL");
- DbCategoryL(aCategory)->DecrementSongsForCategoryL(aCategoryId, aDriveId,
- aItemChangedMessages, aItemExist);
+ switch(aCategory)
+ {
+ case EMPXAlbum:
+ iDbAlbum->DecrementSongsForAlbumL(aCategoryId, aDriveId, aItemChangedMessages, aItemExist, aArt);
+ break;
+ default:
+ DbCategoryL(aCategory)->DecrementSongsForCategoryL(aCategoryId, aDriveId,
+ aItemChangedMessages, aItemExist);
+ break;
+ }
}
// ----------------------------------------------------------------------------
@@ -3221,7 +3192,6 @@
SetTObjectValueL<TMPXItemId>(KMPXMessageMediaDeprecatedId, plId);
}
-
// ---------------------------------------------------------------------------
// CMPXDbHandler::IsRemoteDrive
// ---------------------------------------------------------------------------
@@ -3267,28 +3237,6 @@
CleanupStack::PopAndDestroy(&attributes);
}
-TInt CMPXDbHandler::HandleGetAlbumsCountForArtistL(TUint32 aArtistId)
- {
- return iDbAlbum->GetAlbumsCountForArtistL(aArtistId);
- }
-
-TBool CMPXDbHandler::HandleIsUnknownArtistL(TUint32 aArtistId)
- {
- return iDbArtist->IsUnknownArtistL(aArtistId);
- }
-
-// ---------------------------------------------------------------------------
-// CMPXDbHandler::HandleArtistForAlbumL
-// ---------------------------------------------------------------------------
-//
-HBufC* CMPXDbHandler::HandleArtistForAlbumL(const TUint32 aAlbumId)
- {
-
- TUint32 artistId = iDbMusic->ArtistForAlbumL(aAlbumId);
- HBufC* artistname = GetNameMatchingIdL(artistId);
- return artistname;
- }
-
// ---------------------------------------------------------------------------
// CMPXDbHandler::HandleAlbumartForAlbumL
// ---------------------------------------------------------------------------
@@ -3297,6 +3245,7 @@
{
return iDbMusic->AlbumartForAlbumL(aAlbumId, aArt);
}
+
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
// ----------------------------------------------------------------------------------------------------------
// CMPXDbHandler::HandleGetAlbumNameForSongL
@@ -3307,4 +3256,43 @@
return iDbAbstractAlbum->GetUriL(aId);
}
#endif // ABSTRACTAUDIOALBUM_INCLUDED
+
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::DeleteAlbumForArtistL
+// ----------------------------------------------------------------------------
+//
+void CMPXDbHandler::DeleteAlbumForArtistL(TUint32 aCategoryId,
+ TInt aDrive, CMPXMessageArray* aItemChangedMessages)
+ {
+ MPX_FUNC("CMPXDbHandler::DeleteAlbumForArtistL");
+ iDbArtist->DecrementAlbumsForArtistL(aCategoryId, aDrive, aItemChangedMessages);
+ }
+
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::AddAlbumArtistL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::AddAlbumArtistL(const TDesC& aName, const TDesC& aArt, TInt aDriveId)
+ {
+ MPX_FUNC("CMPXDbHandler::AddAlbumArtistL");
+ return iDbArtist->AddAlbumArtistL(aName, aArt, aDriveId);
+ }
+
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::GenerateUniqueIdForAlbumL
+// ----------------------------------------------------------------------------
+//
+TUint32 CMPXDbHandler::GenerateUniqueIdForAlbumL(const CMPXMedia& aMedia)
+ {
+ return iDbAlbum->GenerateUniqueIdL(aMedia);
+ }
+
+// ----------------------------------------------------------------------------
+// CMPXDbHandler::IsUnknownAlbumL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbHandler::IsUnknownAlbumL(const TUint32 aId)
+ {
+ return iDbAlbum->IsUnknownAlbumL(aId);
+ }
// End of file
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbmusic.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbmusic.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -42,12 +42,6 @@
// CONSTANTS
-// This is what KNullDesC album computes to for the hash
-// to-do: generate this Id through
-// MPXDbUtil::GenerateUniqueIdL(EMPXAlbum, KNullDesC, EFalse)
-// instead of hard-coding the number so if GenerateUniqueIdL
-// is modified, this constant doesn't need to be redefined
-const TInt KUnknownAlbumID = 1770790356;
// UniqueID column in Uris requests
const TInt KColUniqueID = 0;
// URI column in Uris requests
@@ -254,22 +248,25 @@
User::Leave(KErrNotFound);
}
+#ifdef ABSTRACTAUDIOALBUM_INCLUDED
+ iArtNeedUpdated = ETrue; // reset flag
+#endif
TDriveUnit driveUnit(MPXDbCommonUtil::GetDriveIdMatchVolIdL(iDbManager.Fs(),
recordset.ColumnInt64(EMusicVolumeId)));
visible = DoUpdateSongL(aSongId, aMedia, driveUnit, aItemChangedMessages,
recordset);
-
+
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
if(iArtNeedUpdated)
{
#endif // ABSTRACTAUDIOALBUM_INCLUDED
// Update Album table
- if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) || aMedia.IsSupported(KMPXMediaMusicArtist))
+ if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
{
TUint32 albumId = recordset.ColumnInt64(EMusicAlbum);
iObserver.UpdateCategoryItemL(EMPXAlbum, albumId, aMedia, driveUnit, aItemChangedMessages);
}
-
+
// Update Artist table
if ( aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) )
{
@@ -278,7 +275,6 @@
}
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
}
- iArtNeedUpdated = ETrue; //reset flag
#endif // ABSTRACTAUDIOALBUM_INCLUDED
CleanupStack::PopAndDestroy(&recordset);
}
@@ -712,7 +708,7 @@
// Run query and add result media objects to the cache array.
MPX_FUNC("CMPXDbMusic::ExecuteQueryAllSongsL");
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetAllSongsMinimum));
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetAllSongsMinimum()));
CleanupClosePushL(recordset);
TInt err(KErrNone);
@@ -813,7 +809,7 @@
MPX_FUNC("CMPXDbMusic::GetSongsForAlbumL");
TPtrC query;
- if (aAlbumId == KUnknownAlbumID)
+ if (iObserver.IsUnknownAlbumL(aAlbumId))
{
query.Set(ExtraFieldsRequired(aAttrs) ? KQueryMusicGetSongsForUnknownAlbum() :
KQueryMusicGetSongsForUnknownAlbumNoCategories());
@@ -994,7 +990,9 @@
TMPXGeneralType aType,
const CMPXMedia& aCriteria,
const TArray<TMPXAttribute>& aAttrs,
- CMPXMediaArray& aMediaArray)
+ CMPXMediaArray& aMediaArray,
+ TBool aSortByTrackOrder
+ )
{
MPX_FUNC("CMPXDbMusic::FindSongsL");
@@ -1002,12 +1000,8 @@
HBufC* criteriaStr = GenerateMusicMatchingCriteriaLC(aGeneralId, aContainerId, aType,
aCriteria);
- // construct the sort order depending on category. Albums are always sorted by track,
- // then name, except for unknown album. Songs are sorted by name for unknown album.
- // NULL track number is stored as KMaxTInt so that they will be sorted to the end
- TPtrC sortOrder;
- if ((aType == EMPXGroup) && (MPX_ITEM_CATEGORY(aGeneralId) == EMPXAlbum) &&
- (aGeneralId != MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXAlbum, KNullDesC, EFalse)))
+ TPtrC sortOrder;
+ if (aSortByTrackOrder)
{
sortOrder.Set(KQueryMusicFindAllSortOrderTrack);
}
@@ -1015,7 +1009,7 @@
{
sortOrder.Set(KQueryMusicFindAllSortOrderTitle);
}
-
+
// construct the query
HBufC* query = HBufC::NewLC(KQueryMusicFindAll().Length() + criteriaStr->Length() +
sortOrder.Length());
@@ -1100,32 +1094,13 @@
}
// ----------------------------------------------------------------------------
-// CMPXDbMusic::ArtistForAlbumL
-// ----------------------------------------------------------------------------
-//
-TUint32 CMPXDbMusic::ArtistForAlbumL(const TUint32 aId)
- {
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetArtistForAlbum, aId));
-
- CleanupClosePushL(recordset);
- if (recordset.Next() != KSqlAtRow)
- {
- User::Leave(KErrNotFound);
- }
-
- TUint32 artistId = recordset.ColumnInt64(KMPXTableDefaultIndex);
- CleanupStack::PopAndDestroy(&recordset);
-
- return artistId;
- }
-
-// ----------------------------------------------------------------------------
// CMPXDbMusic::AlbumartForAlbumL
// ----------------------------------------------------------------------------
//
HBufC* CMPXDbMusic::AlbumartForAlbumL(const TUint32 aAlbumId, TPtrC aArt)
{
- MPX_FUNC("CMPXDbMusic::AlbumartForAlbumL");
+ MPX_FUNC("CMPXDbMusic::AlbumartForAlbumL");
+
RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetAlbumartForAlbum, aAlbumId));
HBufC* albumart(NULL);
@@ -2134,14 +2109,13 @@
// update the artist field
TUint32 id(0);
- TUint32 artistIdForAlbum(artistId);
if (UpdateCategoryFieldL(EMPXArtist, aMedia, KMPXMediaMusicArtist, artistId,
aDrive, aItemChangedMessages, id, art))
{
MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArtist, id);
metaDataModified = (aMusicTable != NULL);
visibleChange = CMPXDbActiveTask::EAllVisible;
- artistIdForAlbum = id;
+ iArtNeedUpdated = EFalse;
}
// update the album field
@@ -2167,6 +2141,7 @@
MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, albumId,
EMPXItemInserted, EMPXAlbum, KDBPluginUid);
}
+ iArtNeedUpdated = EFalse;
}
// update the genre field
@@ -2468,8 +2443,17 @@
TUint32 aOldId,
TInt aDriveId,
CMPXMessageArray* aItemChangedMessages,
- TUint32& aItemId, const TDesC& aArt)
+ TUint32& aItemId,
+ const TDesC& aArt)
{
+ MPX_FUNC("CMPXDbMusic::UpdateCategoryFieldL");
+
+ if (aCategory == EMPXAlbum)
+ {
+ return UpdateCategoryFieldForAlbumL(aMedia, aAttribute, aOldId,
+ aDriveId, aItemChangedMessages, aItemId, aArt);
+ }
+
TBool updated(EFalse);
TBool itemNotRemoved( EFalse );
TBool itemAdded( EFalse );
@@ -2496,7 +2480,6 @@
aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory,
name, caseSensitive);
-
#else
// only genre is not case sensitive
aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory,
@@ -2511,8 +2494,8 @@
{
if (aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) == EMPXSong )
{
- iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId,
- aItemChangedMessages, itemAdded, name, KNullDesC);
+ iObserver.AddAbstractAlbumItemL(KNullDesC, aDriveId,
+ aItemChangedMessages, itemAdded, name, KNullDesC);
}
else
{
@@ -2523,50 +2506,40 @@
albumartist.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen));
//get AlbumArt AbstractAlbum
MPX_DEBUG2(" albumartist[%S]", &albumartist);
- }
+ }
if (aMedia.IsSupported(KMPXMediaGeneralTitle) )
- {
- abstractAlbumName.Set(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen));
- MPX_DEBUG2(" abstractAlbumName[%S]", &abstractAlbumName);
- }
- // ignore the return value
-
- iObserver.AddCategoryItemL(aCategory, abstractAlbumName, aDriveId,
- aItemChangedMessages, itemAdded, name, albumartist);
+ {
+ abstractAlbumName.Set(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen));
+ MPX_DEBUG2(" abstractAlbumName[%S]", &abstractAlbumName);
+ }
+
+ // ignore the return value
+ iObserver.AddAbstractAlbumItemL(abstractAlbumName, aDriveId,
+ aItemChangedMessages, itemAdded, name, albumartist);
}
}
else
#endif // ABSTRACTAUDIOALBUM_INCLUDED
- if (aCategory == EMPXArtist || aCategory == EMPXAlbum)
+ if (aCategory == EMPXArtist)
{
- TPtrC art(KNullDesC);
- TPtrC artistname(KNullDesC);
-
- if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
- {
- art.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen));
- }
- if (aCategory == EMPXAlbum)
+ //for the update case, need to maintain art field for Artist/Album table.
+ if (aOldId && (aOldId != aItemId))
{
- if (aMedia.IsSupported(KMPXMediaMusicArtist))
- {
- artistname.Set(aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen));
- }
+ CMPXMedia* media = CMPXMedia::NewL(aMedia);
+ CleanupStack::PushL(media);
+ media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, aArt);
+ iObserver.AddCategoryItemL(aCategory, *media, aDriveId, aItemChangedMessages, itemAdded);
+ CleanupStack::PopAndDestroy(media);
+ }
+ else
+ {
+ iObserver.AddCategoryItemL(aCategory, aMedia, aDriveId, aItemChangedMessages, itemAdded);
}
- //for the update case, need to maitain art field for Artist/Album table.
- if (aOldId && (aOldId != aItemId))
- {
- iObserver.AddCategoryItemL(aCategory, name, artistname, aArt, aDriveId, aItemChangedMessages, itemAdded);
- }
- else
- {
- iObserver.AddCategoryItemL(aCategory, name, artistname, art, aDriveId, aItemChangedMessages, itemAdded);
- }
}
else
{
// ignore the return value
- iObserver.AddCategoryItemL(aCategory, name, aDriveId,
+ iObserver.AddCategoryItemL(aCategory, aMedia, aDriveId,
aItemChangedMessages, itemAdded);
}
updated = ETrue;
@@ -2594,37 +2567,18 @@
TPtrC abstractAlbumName(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen));
MPX_DEBUG2(" Music abstractAlbumName[%S]", &abstractAlbumName);
// ignore the return value
- iObserver.AddCategoryItemL(aCategory, abstractAlbumName, aDriveId,
- aItemChangedMessages, itemAdded, KNullDesC, albumartist);
+ iObserver.AddAbstractAlbumItemL(abstractAlbumName, aDriveId,
+ aItemChangedMessages, itemAdded, KNullDesC, albumartist);
}
else
#endif // ABSTRACTAUDIOALBUM_INCLUDED
- if (aCategory == EMPXArtist || aCategory == EMPXAlbum)
- {
- TPtrC art(KNullDesC);
- TPtrC artistname(KNullDesC);
- if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
- {
- art.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen));
- }
- if (aCategory == EMPXAlbum)
- {
- if (aMedia.IsSupported(KMPXMediaMusicArtist))
- {
- artistname.Set(aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen));
- }
- }
- iObserver.AddCategoryItemL(aCategory, KNullDesC, artistname, art, aDriveId,
- aItemChangedMessages, itemAdded);
- }
- else
{
// ignore the return value
- iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId,
- aItemChangedMessages, itemAdded);
- }
- updated = ETrue;
- }
+ iObserver.AddCategoryItemL(aCategory, aMedia, aDriveId,
+ aItemChangedMessages, itemAdded);
+ }
+ updated = ETrue;
+ }
}
if (aOldId && (aOldId != aItemId))
@@ -2690,7 +2644,6 @@
return updated;
}
-
// ----------------------------------------------------------------------------
// CMPXDbMusic::ExtraFieldsRequired
// ----------------------------------------------------------------------------
@@ -2771,4 +2724,120 @@
;
}
+// ----------------------------------------------------------------------------
+// CMPXDbMusic::UpdateCategoryFieldForAlbumL
+// ----------------------------------------------------------------------------
+//
+TBool CMPXDbMusic::UpdateCategoryFieldForAlbumL(
+ const CMPXMedia& aMedia,
+ const TMPXAttribute& aAttribute,
+ TUint32 aOldId,
+ TInt aDriveId,
+ CMPXMessageArray* aItemChangedMessages,
+ TUint32& aItemId,
+ const TDesC& aArt)
+ {
+ MPX_FUNC("CMPXDbMusic::UpdateCategoryFieldForAlbumL");
+
+ TBool updated(EFalse);
+ TBool itemNotRemoved( EFalse );
+ TBool itemAdded( EFalse );
+
+ // update category table and add category Id to the music table
+ if (!aOldId || aMedia.IsSupported(aAttribute))
+ {
+ TInt changeMsgCount( 0 );
+ if( aItemChangedMessages )
+ {
+ changeMsgCount = aItemChangedMessages->Count();
+ }
+
+ // construct the new ID for the category record
+ aItemId = iObserver.GenerateUniqueIdForAlbumL(aMedia);
+
+ if (!aOldId || (aOldId != aItemId))
+ {
+ // only add if the ID changed,
+ // otherwise the song was updated but the artist name was not
+
+ //for the update case, need to maitain art field for Artist/Album table.
+ if (aOldId && (aOldId != aItemId))
+ {
+ CMPXMedia* media = CMPXMedia::NewL(aMedia);
+ CleanupStack::PushL(media);
+ media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, aArt);
+
+ iObserver.AddCategoryItemL(EMPXAlbum, *media, aDriveId, aItemChangedMessages, itemAdded);
+ CleanupStack::PopAndDestroy(media);
+ }
+ else // !aOldId
+ {
+ iObserver.AddCategoryItemL(EMPXAlbum, aMedia, aDriveId, aItemChangedMessages, itemAdded);
+ }
+ updated = ETrue;
+ }
+
+ if (aOldId && (aOldId != aItemId))
+ {
+ iObserver.DeleteSongForCategoryL(EMPXAlbum, aOldId, aDriveId,
+ aItemChangedMessages, itemNotRemoved, aArt);
+ updated = ETrue;
+ }
+
+ // Special case where the item(s) has been renamed.
+ // In this case, a new category is created +1 change msg
+ // a old category is removed +1 change msg
+ // We merge these 2 change messages into one using the deprecated ID
+ //
+ if( aItemChangedMessages )
+ {
+ TInt newChangeMsgCount( aItemChangedMessages->Count() );
+ if( newChangeMsgCount - changeMsgCount > 0 )
+ {
+ TInt oldId = KErrNotFound;
+ TInt newId = KErrNotFound;
+ for( TInt i=0; i<newChangeMsgCount; ++i )
+ {
+ CMPXMessage& msg = *(*aItemChangedMessages)[i];
+
+ TMPXItemId id = msg.ValueTObjectL<TMPXItemId>(KMPXMessageMediaGeneralId);
+ TMPXChangeEventType changeType = msg.ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType);
+
+ // Look for the added and deleted category IDs
+ //
+ if( id == aOldId && changeType == EMPXItemDeleted )
+ {
+ oldId = i;
+ }
+ else if( id == aItemId && changeType == EMPXItemInserted )
+ {
+ newId = i;
+ }
+ }// for
+
+ if( oldId != KErrNotFound &&
+ newId != KErrNotFound )
+ {
+ aItemChangedMessages->Remove(oldId); // category removed
+ aItemChangedMessages->Remove(newId); // category added
+ MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aItemId, EMPXItemModified,
+ EMPXAlbum, KDBPluginUid, aOldId );
+ }
+ else if ( oldId !=KErrNotFound && itemAdded ) // old item removed, new item already exist
+ {
+ MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aItemId, EMPXItemModified,
+ EMPXAlbum, KDBPluginUid, aOldId );
+ }
+ else if ( newId !=KErrNotFound && itemNotRemoved ) // new item added, old item still exist
+ {
+ MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aOldId, EMPXItemModified,
+ EMPXAlbum, KDBPluginUid, aItemId );
+ }
+ }
+ }// aItemChangedMessages
+ }// if (!aOldId || aMedia.IsSupported(aAttribute))
+
+ return updated;
+ }
+
// End of File
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbplugin/src/mpxdbauxiliary.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbplugin/src/mpxdbauxiliary.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -111,7 +111,7 @@
{
MPX_FUNC("CMPXDbAuxiliary::LastRefreshedTimeL");
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime));
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime()));
CleanupClosePushL(recordset);
if (recordset.Next() != KSqlAtRow)
@@ -195,7 +195,7 @@
TBool refreshed(ETrue);
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime));
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime()));
CleanupClosePushL(recordset);
TInt count(0);
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitepodcastdbplugin/src/mpxdbauxiliary.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitepodcastdbplugin/src/mpxdbauxiliary.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -112,7 +112,7 @@
{
MPX_FUNC("CMPXDbAuxiliary::LastRefreshedTimeL");
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime));
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime()));
CleanupClosePushL(recordset);
if (recordset.Next() != KSqlAtRow)
@@ -195,7 +195,7 @@
TBool refreshed(ETrue);
- RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime));
+ RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAuxiliaryGetTime()));
CleanupClosePushL(recordset);
TInt count(0);
--- a/mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgcontainer.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgcontainer.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -801,8 +801,15 @@
SetRect( clientRect );
iBgContext->SetRect(((CAknAppUi*)iCoeEnv->AppUi())->ApplicationRect());
- // call HandleLbxItemAdditionL
- HandleLbxItemAdditionL();
+ if ( iCurrentViewType == EMPXViewMediawall )
+ {
+ PrepareTboneViewL();
+ }
+ else
+ {
+ // call HandleLbxItemAdditionL
+ HandleLbxItemAdditionL();
+ }
}
);
if(iMediaWall)
@@ -1304,11 +1311,6 @@
{
RestoreSelectedAlbumItemL(mediaArray);
PrepareMediaWallWithListL( mediaArray, count );
- // We need to adjust the CBA for this view.
- if( iCbaHandler )
- {
- iCbaHandler->UpdateCba();
- }
break;
}
case EMPXViewList:
@@ -1726,7 +1728,10 @@
((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->MakeVisible(EFalse);
iThumbnailManager->SetSizeL( EAudioGridThumbnailSize );
-
+ if( iCbaHandler )
+ {
+ iCbaHandler->UpdateCba();
+ }
TRect clientRect = ((CAknView*)iView)->ClientRect();
TAknLayoutRect mediawallLayout;
@@ -4729,7 +4734,7 @@
SetupTransitionType(KMPXInterviewTransition);
BeginFullScreenAnimation();
}
- else if( !iLayoutSwitch && iMediaWall )
+ else if( !iLayoutSwitch && iMediaWall && ( iCurrentViewType == EMPXViewMediawall ) )
{
// Close mediawall "flip animation"
iMediaWall->StartOpeningAnimationL( EFalse );
@@ -4765,6 +4770,7 @@
listSize++;
indexAddition = 1;
}
+ currentList->Reset(); //clears any selection along with list reset
// Add space for shuffle item if list contains more than one item.
currentList->ResizeL( listSize );
--- a/mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgimp.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgimp.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -308,6 +308,7 @@
delete iCurrentCba;
delete iIncrementalOpenUtil;
delete iCachedSelectionIndex;
+ delete iCurrentSelectedIndex;
FeatureManager::UnInitializeLib();
delete iOperatorMusicStoreName ;
if ( iOperatorMusicStoreURI )
@@ -6979,7 +6980,20 @@
CEikMenuPane* aMenuPane )
{
MPX_FUNC( "CMPXCollectionViewHgImp::DynInitMenuPaneL" );
-
+
+ if ( iContainer->IsTBoneView() )
+ {
+ //makesure mediawall is not flicking before handling long tap
+ TInt currentIndex( iContainer->CurrentLbxItemIndex() );
+ MPX_DEBUG2( "CMPXCollectionViewHgImp::DynInitMenuPaneL currentIndex = %d", currentIndex );
+ if (currentIndex == KErrNotFound)
+ {
+ MPX_DEBUG1( "DynInitMenuPaneL NOT handling stylus popup menu when flicking");
+ DimAllOptions(aResourceId, aMenuPane);
+ return;
+ }
+ }
+
CMPXCollectionViewListBoxArray* array =
static_cast<CMPXCollectionViewListBoxArray*>(
iContainer->ListBoxArray() );
@@ -8532,6 +8546,7 @@
aMenuPane->SetItemDimmed( EMPXCmdFindInMusicShop, ETrue );
aMenuPane->SetItemDimmed( EMPXCmdSongDetails, ETrue );
aMenuPane->SetItemDimmed( EMPXCmdPlaylistDetails, ETrue );
+ aMenuPane->SetItemDimmed( EMPXCmdUseAsCascade, ETrue );
break;
}
case R_AVKON_MENUPANE_MARKABLE_LIST:
--- a/mpxplugins/viewplugins/views/embeddedplaybackview/src/mpxembeddedplaybackviewimp.cpp Wed Sep 01 12:32:02 2010 +0100
+++ b/mpxplugins/viewplugins/views/embeddedplaybackview/src/mpxembeddedplaybackviewimp.cpp Tue Sep 14 21:14:08 2010 +0300
@@ -549,7 +549,7 @@
fileParse.Path().Left(
KMPXMusicplayerPrivateFolder().Length())));
- if ( iCommonUiHelper->IsHostMessagingL()
+ if ( (iCommonUiHelper->IsHostMessagingL() || iCommonUiHelper->IsHostCalendarL() )
&& mediapath.CompareF(savedpath) && isPrivate )
{
HandleSaveL( (TMPXNpvSaveMode)aCommand );
--- a/musicplayer_plat/mpx_music_player_app_api/inc/mpxcommonuihelper.h Wed Sep 01 12:32:02 2010 +0100
+++ b/musicplayer_plat/mpx_music_player_app_api/inc/mpxcommonuihelper.h Tue Sep 14 21:14:08 2010 +0300
@@ -91,6 +91,13 @@
* @return ETrue if host is messaging, EFalse otherwise
*/
IMPORT_C TBool IsHostMessagingL();
+
+ /**
+ * Check if the host application is calendar
+ * @since Symbian^3
+ * @return ETrue if host is calendar, EFalse otherwise
+ */
+ IMPORT_C TBool IsHostCalendarL();
/**
* Check if the host application is browser