mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbartist.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 13 Oct 2010 14:28:40 +0300
branchRCL_3
changeset 66 1f1dad4af8f8
parent 56 2cbbefa9af78
permissions -rw-r--r--
Revision: 201039 Kit: 201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
/*
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
* All rights reserved.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
*
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
* Initial Contributors:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
*
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
* Contributors:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
*
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
* Description:  Responsible for interation with the Artist table
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
*
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
*
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
*/
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
// INCLUDE FILES
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
#include <sqldb.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
#include <mpxlog.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
#include "mpxdbcommonutil.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
#include "mpxdbcommondef.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
#include "mpxmediamusicdefs.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
#include "mpxdbmanager.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
#include "mpxcollectiondbdef.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
#include "mpxdbpluginqueries.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
#include "mpxdbutil.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
#include "mpxdbartist.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
// CONSTANTS
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
// ============================ MEMBER FUNCTIONS ==============================
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
// Two-phased constructor.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
CMPXDbArtist* CMPXDbArtist::NewL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
    CMPXDbManager& aDbManager,
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
    45
    TMPXGeneralCategory aCategory,
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
    46
    MMPXDbArtistObserver& aObserver)
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
    MPX_FUNC("CMPXDbArtist::NewL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
    50
    CMPXDbArtist* self = CMPXDbArtist::NewLC(aDbManager, aCategory, aObserver);
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
    CleanupStack::Pop(self);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
    return self;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
// Two-phased constructor.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
CMPXDbArtist* CMPXDbArtist::NewLC(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
    CMPXDbManager& aDbManager,
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
    61
    TMPXGeneralCategory aCategory,
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
    62
    MMPXDbArtistObserver& aObserver)
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
    MPX_FUNC("CMPXDbArtist::NewLC");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
    66
    CMPXDbArtist* self = new (ELeave) CMPXDbArtist(aDbManager, aCategory, aObserver);
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
    CleanupStack::PushL(self);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
    self->ConstructL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
    return self;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
// Destructor
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
CMPXDbArtist::~CMPXDbArtist()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
    MPX_FUNC("CMPXDbArtist::~CMPXDbArtist");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
// Constructor
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
CMPXDbArtist::CMPXDbArtist(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
    CMPXDbManager& aDbManager,
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
    87
    TMPXGeneralCategory aCategory,
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
    88
    MMPXDbArtistObserver& aObserver) :
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
    89
    CMPXDbCategory(aDbManager, aCategory),
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
    90
    iObserver(aObserver)
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
    MPX_FUNC("CMPXDbArtist::CMPXDbArtist");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
// Second phase constructor.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
void CMPXDbArtist::ConstructL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
    MPX_FUNC("CMPXDbArtist::ConstructL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
    BaseConstructL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
// CMPXDbArtist::AddItemL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
TUint32 CMPXDbArtist::AddItemL(
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   111
    const TDesC& aName,
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   112
    const TDesC& aArt,
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
    TInt aDriveId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
    TBool& aNewRecord,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
    TBool aCaseSensitive)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   117
    MPX_FUNC("CMPXDbArtist::AddItemL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
    // try to find the item first
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
    TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), iCategory,
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   121
        aName, aCaseSensitive));
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   122
    aNewRecord = !CategoryItemExistsL(aDriveId, rowId);
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   124
    if (aNewRecord)
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
        // insert new
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   127
        HBufC* query = PreProcessStringLC(KQueryArtistInsert);
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   128
        HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(aName);
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   129
        HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(aArt);
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   131
        iDbManager.ExecuteQueryL(aDriveId, *query, rowId, name, 1, art);
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
        CleanupStack::PopAndDestroy(art);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   134
        CleanupStack::PopAndDestroy(name);
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   135
        CleanupStack::PopAndDestroy(query);
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
        }
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   137
    else
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
        {
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   139
        // retrieve the existing record
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   140
        HBufC* query = NULL;
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   141
        query = PreProcessStringLC(KQueryCategoryItem);
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   142
        RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, rowId));
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   143
        CleanupStack::PopAndDestroy(query);
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   144
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   145
        CleanupClosePushL(recordset);
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   146
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   147
        if (recordset.Next() != KSqlAtRow)
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   148
            {
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   149
            User::Leave(KErrNotFound);
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   150
        }
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   151
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   152
        // Album Art
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   153
        TPtrC art(KNullDesC);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   154
        art.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EArtistArt));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   155
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   156
        // the current one is Unknown and the new one is Not Unknown
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   157
        if ( art == KNullDesC && aArt != KNullDesC )
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   158
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   159
            HBufC* artReplaceSingleQuote = 
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   160
                MPXDbCommonUtil::ProcessSingleQuotesLC( aArt );
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   161
            _LIT( KFormatArt, "Art=\'%S\'" );
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   162
            HBufC* setStr = HBufC::NewLC(256);
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   163
            setStr->Des().Format( KFormatArt, artReplaceSingleQuote );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   164
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   165
            iDbManager.ExecuteQueryL(aDriveId, KQueryArtistUpdate, setStr, rowId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   166
            CleanupStack::PopAndDestroy(setStr);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   167
            CleanupStack::PopAndDestroy(artReplaceSingleQuote);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   168
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   169
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   170
        CleanupStack::PopAndDestroy(&recordset);
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   171
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   172
        // increment the number of songs for the category
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   173
        query = PreProcessStringLC(KQueryCategoryIncrementSongCount);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   174
        iDbManager.ExecuteQueryL(aDriveId, *query, rowId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   175
        CleanupStack::PopAndDestroy(query);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   176
        }
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   177
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   178
    return rowId;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   179
    }
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   180
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   181
// ----------------------------------------------------------------------------
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   182
// CMPXDbArtist::IsUnknownArtistL
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   183
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   184
//
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   185
TBool CMPXDbArtist::IsUnknownArtistL(TUint32 aId)
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   186
    {
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   187
	MPX_FUNC("CMPXDbArtist::IsUnknownArtistL");
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   188
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   189
    HBufC* name = GetNameL(aId);
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   190
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   191
	TInt ret = EFalse;
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   192
	if (*name == KNullDesC)
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   193
		{
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   194
		ret = ETrue;
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   195
		}
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   196
	delete name;
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   197
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   198
	return ret;
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   199
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   200
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   201
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   202
// CMPXDbArtist::UpdateMediaL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   203
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   204
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   205
void CMPXDbArtist::UpdateMediaL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   206
    RSqlStatement& aRecord,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   207
    const TArray<TMPXAttribute>& aAttrs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   208
    CMPXMedia& aMedia)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   209
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   210
    MPX_FUNC("CMPXDbArtist::UpdateMediaL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   211
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   212
    TInt count(aAttrs.Count());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   213
    for (TInt i = 0; i < count; ++i)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   214
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   215
        TInt contentId(aAttrs[i].ContentId());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   216
        TUint attributeId(aAttrs[i].AttributeId());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   217
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   218
        if (contentId == KMPXMediaIdGeneral)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   219
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   220
            if (attributeId & EMPXMediaGeneralId)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   221
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   222
                MPX_DEBUG1("	EMPXMediaGeneralId");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   223
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   224
                aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   225
                    aRecord.ColumnInt64(EArtistUniqueId));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   226
				MPX_DEBUG2("	Id[%d]", aRecord.ColumnInt64(EArtistUniqueId));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   227
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   228
            if (attributeId & EMPXMediaGeneralTitle)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   229
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   230
                MPX_DEBUG1("	EMPXMediaGeneralTitle");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   231
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   232
                TPtrC artist( MPXDbCommonUtil::GetColumnTextL(aRecord, EArtistName) );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   233
                aMedia.SetTextValueL(KMPXMediaGeneralTitle,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   234
                    MPXDbCommonUtil::GetColumnTextL(aRecord, EArtistName));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   235
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   236
				MPX_DEBUG2("	Artist[%S]", &artist);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   237
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   238
            if (attributeId & EMPXMediaGeneralCount)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   239
                {
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   240
//				TInt albumCount = GetAlbumsCountL(aRecord.ColumnInt64(EArtistUniqueId));
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   241
//              aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount,albumCount);
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   242
//              MPX_DEBUG1("	EMPXMediaGeneralCount");
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   243
//				MPX_DEBUG2("	AlbumCount[%d]", albumCount);
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   244
                // get songs count from all drives
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   245
                TInt songCount = GetSongsCountL( KDbManagerAllDrives,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   246
                                    aRecord.ColumnInt64( EArtistUniqueId ) );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   247
				aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount); // mod by anjokela
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   248
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   249
                MPX_DEBUG1("	EMPXMediaGeneralCount");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   250
				MPX_DEBUG2("	SongCount[%d]", songCount);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   251
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   252
            } // end if contentId == KMPXMediaIdGeneral
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   253
        else if ( contentId == KMPXMediaIdMusic )
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   254
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   255
            if (attributeId & EMPXMediaMusicAlbumArtFileName)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   256
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   257
                MPX_DEBUG1("    EMPXMediaMusicAlbumArtFileName");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   258
                TPtrC art(KNullDesC);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   259
                art.Set(MPXDbCommonUtil::GetColumnTextL(aRecord, EArtistArt));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   260
                aMedia.SetTextValueL(KMPXMediaMusicAlbumArtFileName, art);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   261
                MPX_DEBUG2("    Art[%S]", &art);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   262
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   263
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   264
		} // end for
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   265
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   266
    aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   267
    aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, iCategory);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   268
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   269
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   270
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   271
// CMPXDbArtist::GenerateArtistFieldsValuesL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   272
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   273
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   274
void CMPXDbArtist::GenerateArtistFieldsValuesL(const CMPXMedia& aMedia, CDesCArray& aFields, CDesCArray& aValues)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   275
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   276
    if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   277
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   278
        const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   279
        MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArt, albumArtFilename);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   280
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   281
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   282
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   283
// ----------------------------------------------------------------------------
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   284
// CMPXDbArtist::GetAlbumsCountL
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   285
// ----------------------------------------------------------------------------
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   286
//
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   287
TInt CMPXDbArtist::GetAlbumsCountL(TUint32 aId)
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   288
    {
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   289
    MPX_FUNC("CMPXDbArtist::GetAlbumsCountL");
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   290
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   291
	return iObserver.HandleGetAlbumsCountForArtistL(aId);
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   292
    }
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   293
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   294
// ----------------------------------------------------------------------------
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   295
// CMPXDbArtist::GetAllCategoryItemsL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   296
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   297
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   298
void CMPXDbArtist::GetAllCategoryItemsL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   299
    const TArray<TMPXAttribute>& aAttrs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   300
    CMPXMediaArray& aMediaArray)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   301
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   302
    MPX_FUNC("CMPXDbArtist::GetAllCategoryItemsL");
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   303
    HBufC* query = PreProcessStringLC(KQueryArtistAll);
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   304
    RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query));
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   305
    CleanupStack::PopAndDestroy(query);
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   306
    CleanupClosePushL(recordset);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   307
    ProcessRecordsetL(aAttrs, recordset, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   308
    CleanupStack::PopAndDestroy(&recordset);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   309
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   310
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   311
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   312
// CMPXDbArtist::UpdateItemL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   313
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   314
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   315
void CMPXDbArtist::UpdateItemL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   316
    TUint32 aId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   317
    const CMPXMedia& aMedia,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   318
    TInt aDriveId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   319
    CMPXMessageArray* aItemChangedMessages)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   320
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   321
    MPX_FUNC("CMPXDbAlbum::UpdateItemL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   322
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   323
    CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EArtistFieldCount);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   324
    CleanupStack::PushL(fields);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   325
    CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EArtistFieldCount);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   326
    CleanupStack::PushL(values);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   327
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   328
    // process the media parameter and construct the fields and values array
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   329
    GenerateArtistFieldsValuesL(aMedia, *fields, *values);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   330
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   331
    // construct the SET string
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   332
    HBufC* setStr = MPXDbCommonUtil::StringFromArraysLC(*fields, *values, KMCEqualSign, KMCCommaSign);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   333
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   334
    if (setStr->Length())
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   335
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   336
        // execute the query
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   337
        iDbManager.ExecuteQueryL(aDriveId, KQueryArtistUpdate, setStr, aId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   338
        MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   339
        		EMPXArtist, KDBPluginUid, ETrue, 0 );          
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   340
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   341
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   342
    CleanupStack::PopAndDestroy(setStr);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   343
    CleanupStack::PopAndDestroy(values);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   344
    CleanupStack::PopAndDestroy(fields);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   345
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   346
// ----------------------------------------------------------------------------
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   347
// CMPXDbAlbum::CreateTableL
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   348
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   349
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   350
void CMPXDbArtist::CreateTableL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   351
    RSqlDatabase& aDatabase,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   352
    TBool /* aCorruptTable */)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   353
    {
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   354
    MPX_FUNC("CMPXDbCategory::CreateTableL");
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   355
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   356
    // create the table
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   357
    HBufC* query = PreProcessStringLC(KArtistCreateTable);
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   358
    User::LeaveIfError(aDatabase.Exec(*query));
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   359
    CleanupStack::PopAndDestroy(query);
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   360
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   361
    // do not create an index on the Name field
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   362
    // as it only slows down the insert/update queries overall
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   363
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   364
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   365
// ----------------------------------------------------------------------------
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   366
// CMPXDbAlbum::CheckTableL
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   367
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   368
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   369
TBool CMPXDbArtist::CheckTableL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   370
    RSqlDatabase& aDatabase)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   371
    {
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   372
    MPX_FUNC("CMPXDbCategory::CheckTableL");
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   373
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   374
    HBufC* query = PreProcessStringLC(KArtistCheckTable);
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   375
    TBool check(DoCheckTable(aDatabase, *query));
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 56
diff changeset
   376
    CleanupStack::PopAndDestroy(query);
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   377
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   378
    return check;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   379
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   380
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   381
// End of File