mpxplugins/serviceplugins/collectionplugins/mpxsqlitepodcastdbplugin/src/mpxpodcastdbhandler.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 53 3de6c4cf6b67
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) 2006 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:  This class is used by db plugin to add episodes into DB or
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
*                remove episodes from DB
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 <PCRes.rsg>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
#include <bautils.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
#include <MetaDataUtility.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
#ifdef RD_MULTIPLE_DRIVE
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
#include <driveinfo.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
#include <pathinfo.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
#endif //RD_MULTIPLE_DRIVE
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
#include <mpxmediageneraldefs.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
#include <mpxmediacontainerdefs.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
#include <mpxmediamusicdefs.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
#include <mpxmediaaudiodefs.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
#include <mpxmedia.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
#include <mpxmediaarray.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
#include <mpxcollectionpath.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
#include <mpxlog.h>
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
#include "mpxdbcommondef.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
#include "mpxresource.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
#include "mpxdbcommonutil.h"
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
#include "mpxdbutil.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
#include "mpxpodcastcollectiondbdef.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
#include "mpxpodcastdbmanager.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
#include "mpxdbcategory.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
#include "mpxdbauxiliary.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
#include "mpxpodcastdbhandler.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
#include "mpxpodcastdbpluginqueries.h"
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
// CONSTANTS
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
#if defined (__MTP_PROTOCOL_SUPPORT)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
#include <centralrepository.h>
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
const TUid KMPXMtpSettings = {0x101FFC53};    // MTP CenRep Key UID
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
const TUint32 KMPXMtpSaveDeletedRecordFlag = 0x00000001;      // MTP CenRep Key for Delete contents
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
#endif
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
const TInt KSqlDbCorrupted = -321;
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
// ============================ MEMBER FUNCTIONS ==============================
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
// Two-phased constructor.
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
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
CMPXPodcastDbHandler* CMPXPodcastDbHandler::NewL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
    RFs& aFs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
    CMPXResource& aResource)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
    MPX_FUNC("CMPXPodcastDbHandler::NewL");
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
    CMPXPodcastDbHandler* self = CMPXPodcastDbHandler::NewLC(aFs, aResource);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
    CleanupStack::Pop(self);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
    return self;
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
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
// Two-phased constructor.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
// ----------------------------------------------------------------------------
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
CMPXPodcastDbHandler* CMPXPodcastDbHandler::NewLC(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
    RFs& aFs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
    CMPXResource& aResource)
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
    MPX_FUNC("CMPXPodcastDbHandler::NewLC");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
    CMPXPodcastDbHandler* self = new (ELeave) CMPXPodcastDbHandler(aFs, aResource);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
    CleanupStack::PushL( self );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
    self->ConstructL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
    return self;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
    }
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
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
// Destructor
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
CMPXPodcastDbHandler::~CMPXPodcastDbHandler()
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
    MPX_FUNC("CMPXPodcastDbHandler::~CMPXPodcastDbHandler");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
    delete iDbPodcast;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
    delete iDbArtist;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
    delete iDbAlbum;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
    delete iDbGenre;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
    delete iDbComposer;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
    delete iDbAuxiliary;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
    delete iDbManager;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
    delete iPodcastPublishDateCat;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
    iPodcastPublishDateIds.Close();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
    iDbDrives.Close();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
// C++ default constructor can NOT contain any code, that might leave
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
// ----------------------------------------------------------------------------
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
CMPXPodcastDbHandler::CMPXPodcastDbHandler(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
    RFs& aFs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
    CMPXResource& aResource) :
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
    iFs(aFs),
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
    iResource(aResource)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
    MPX_FUNC("CMPXPodcastDbHandler::CMPXPodcastDbHandler");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
    }
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
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
// Symbian 2nd phase constructor can leave.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
void CMPXPodcastDbHandler::ConstructL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
    MPX_FUNC("CMPXPodcastDbHandler::ConstructL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   134
    iPodcastPublishDateCat = iResource.ReadMenuArrayL(R_MPX_QTN_NMP_PUBLISH_DATE_ARRAY,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   135
        iPodcastPublishDateIds);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
    
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   137
    //create db manager
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
    iDbManager = CMPXPodcastDbManager::NewL(iFs);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   139
    CDesCArrayFlat* podcastFolders =
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   140
#ifdef RD_MULTIPLE_DRIVE
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   141
		GetPodcastFoldersL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   142
#else
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   143
    	iResource.ReadDesCArrayL(R_MC_DEFAULT_MUSIC_FOLDERS);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   144
#endif
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   145
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   146
    // create the podcast folders and initialize iDbDrives
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   147
    CleanupStack::PushL(podcastFolders);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   148
    ProcessPodcastFoldersL(*podcastFolders);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   149
    CleanupStack::PopAndDestroy(podcastFolders);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   150
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   151
    // create the db infrastructure
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   152
    iDbPodcast = CMPXDbPodcast::NewL(*iDbManager, iResource, *this);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   153
    iDbArtist = CMPXDbCategory::NewL(*iDbManager, EMPXArtist);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   154
    iDbAlbum = CMPXDbCategory::NewL(*iDbManager, EMPXAlbum);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   155
    iDbGenre = CMPXDbCategory::NewL(*iDbManager, EMPXGenre);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   156
    iDbComposer = CMPXDbCategory::NewL(*iDbManager, EMPXComposer);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   157
    iDbAuxiliary = CMPXDbAuxiliary::NewL(*iDbManager);
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
    // make sure all databases are created and valid
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   160
    MPX_TRAPD(err, iDbManager->InitDatabasesL(iDbDrives));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   161
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   162
    // If KErrCorrupt is returned, a database file was found to be corrupted
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   163
    // and was replaced with a new one.  The db plugin can ignore this error and continue
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   164
    // because a new db file was successfully created in a subsequent retry.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   165
    if ((err != KErrNone) && (err != KErrCorrupt) && (err != KErrDiskFull))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   166
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   167
        // leave to signal the caller that there was an error why creating and opening
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   168
        // one or more of the databases
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   169
        User::Leave(err);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   170
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   171
    else if (err == KErrDiskFull)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   172
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   173
        iOutOfDisk = ETrue;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   174
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   175
    else
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   176
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   177
        // do nothing
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   178
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   179
    // Verify the volume ID Matches
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   180
    MPX_TRAP(err,VerifyVolumeIdL());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   181
    if ((err != KErrNone) && (err != KErrDiskFull))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   182
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   183
        // leave to signal the caller that there was an error why creating and opening
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   184
        // one or more of the databases
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   185
        User::Leave(err);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   186
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   187
    else if (err == KErrDiskFull)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   188
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   189
        iOutOfDisk = ETrue;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   190
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   191
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   192
    // iDbManager->PrintDatabaseL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   193
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   194
    MPX_DEBUG2("CMPXDbHandler::ConstructL DbCount[%d]", iDbManager->DatabaseCount());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   195
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   196
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   197
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   198
// Add episode into collection
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
TUint32 CMPXPodcastDbHandler::AddEpisodeL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   202
    const CMPXMedia& aMedia)
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
    MPX_FUNC("CMPXPodcastDbHandler::AddEpisodeL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   205
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   206
    BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   207
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   208
    TUint32 episodeId(0);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   209
    MPX_TRAPD(err, episodeId = DoAddEpisodeL(aMedia));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   210
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   211
    if (iOutOfDisk && (err == KErrNotFound))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   212
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   213
        err = KErrDiskFull;
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
    EndTransactionL(err);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   216
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   217
    return episodeId;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   218
    }
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
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   221
// Update a episode in the collection
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   222
// ----------------------------------------------------------------------------
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
CMPXDbActiveTask::TChangeVisibility CMPXPodcastDbHandler::UpdateEpisodeL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   225
    const CMPXMedia& aMedia,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   226
    CMPXMessageArray& aItemChangedMessages)
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
    MPX_FUNC("CMPXPodcastDbHandler::UpdateEpisodeL");
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
    BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   231
    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   232
    MPX_TRAPD(err, visibleChange = DoUpdateEpisodeL(aMedia, aItemChangedMessages));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   233
    EndTransactionL(err);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   234
    return visibleChange;
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
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
// Remove the entire podcast collection database
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   239
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   240
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   241
void CMPXPodcastDbHandler::RemoveEntireCollectionL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   242
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   243
    MPX_FUNC("CMPXPodcastDbHandler::RemoveEntireCollectionL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   244
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   245
    BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   246
    MPX_TRAPD(err, iDbManager->RecreateAllDatabasesL());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   247
    EndTransactionL(err);
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
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   250
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   251
// Delete a episode from collection
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   252
// The function notifies collection model to perform deletion
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   253
// ----------------------------------------------------------------------------
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
void CMPXPodcastDbHandler::RemoveEpisodeL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   256
    TUint32 aEpisodeId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   257
    CDesCArray& aUriArray,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   258
    CMPXMessageArray& aItemChangedMessages,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   259
    TBool aDeleteRecord)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   260
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   261
    MPX_FUNC("CMPXPodcastDbHandler::RemoveEpisodeL");
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
    BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   264
    MPX_TRAPD(err, DoRemoveEpisodeL(aEpisodeId, aUriArray, aItemChangedMessages, aDeleteRecord));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   265
    EndTransactionL(err);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   266
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   267
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
// Removes a category of episodes from the podcast collection, and its
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   270
// corresponding category in the lookup table
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   271
// ----------------------------------------------------------------------------
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
void CMPXPodcastDbHandler::RemoveEpisodesMatchingCategoryL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   274
    TMPXGeneralCategory aCategory,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   275
    TUint32 aCategoryId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   276
    CDesCArray& aUriArray,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   277
    CMPXMessageArray& aItemChangedMessages)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   278
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   279
    MPX_FUNC("CMPXPodcastDbHandler::RemoveEpisodesMatchingCategoryL");
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
    BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   282
    MPX_TRAPD(err, DoRemoveEpisodesMatchingCategoryL(aCategory, aCategoryId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   283
        aUriArray, aItemChangedMessages));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   284
    EndTransactionL(err);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   285
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   286
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   287
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   288
// Delete episode(s) from collection belonging to specified publish date category
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   289
// The function notifies collection model to perform deletion
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   290
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   291
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   292
void CMPXPodcastDbHandler::RemoveEpisodesMatchingPublishDateCategoryL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   293
    TUint32 aCategoryId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   294
    CDesCArray& aUriArray,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   295
    CMPXMessageArray& aItemChangedMessages)
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
    MPX_FUNC("CMPXPodcastDbHandler::RemoveEpisodesMatchingPublishDateCategoryL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   298
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   299
    BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   300
    MPX_TRAPD(err, DoRemoveEpisodesMatchingPublishDateCategoryL(aCategoryId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   301
        aUriArray, aItemChangedMessages));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   302
    EndTransactionL(err);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   303
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   304
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   305
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   306
// Cleanup records marked as deleted. This is designated for MTP to clean up
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   307
// records marked as deleted at the end of its session.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   308
// ----------------------------------------------------------------------------
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
void CMPXPodcastDbHandler::CleanupDeletedRecordsL()
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
    MPX_FUNC("CMPXPodcastDbHandler::CleanupDeletedRecordsL");
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
    BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   315
    MPX_TRAPD(err, DoCleanupDeletedRecordsL());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   316
    EndTransactionL(err);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   317
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   318
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   319
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   320
//  Read all episodes and cache them into an array ordered by episode name
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   321
// ----------------------------------------------------------------------------
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
void CMPXPodcastDbHandler::GetAllEpisodesL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   324
    const TArray<TMPXAttribute>& aAttrs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   325
    CMPXMediaArray& aMediaArray)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   326
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   327
    MPX_FUNC("CMPXPodcastDbHandler::GetAllEpisodesL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   328
    iDbPodcast->GetAllEpisodesL(aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   329
    }
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
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   332
// Retrieve the episode(s) with the specified title
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
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   335
void CMPXPodcastDbHandler::GetEpisodesMatchingTitleL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   336
    TUint aTitleId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   337
    const TArray<TMPXAttribute>& aAttrs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   338
    CMPXMediaArray& aMediaArray)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   339
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   340
    MPX_FUNC("CMPXPodcastDbHandler::GetEpisodesMatchingTitleL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   341
    iDbPodcast->GetEpisodesForCategoryL(EMPXAlbum, aTitleId, aAttrs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   342
                                        aMediaArray, ETrue);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   343
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   344
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
// Retrieve the episode(s) belonging to the specified playlist
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   347
// ----------------------------------------------------------------------------
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
void CMPXPodcastDbHandler::GetEpisodesMatchingPlaylistL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   350
    TUint aPlaylistId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   351
    const TArray<TMPXAttribute>& aAttrs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   352
    CMPXMediaArray& aMediaArray,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   353
    TInt& aIndexOfCurrentlyPlayingItem)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   354
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   355
    MPX_FUNC("CMPXPodcastDbHandler::GetEpisodesMatchingPlaylistL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   356
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   357
    switch (aPlaylistId)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   358
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   359
        case KRecentlyAddedPlaylistUID:
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
            iDbPodcast->GetRecentlyAddedPlaylistEpisodesL(aAttrs, aMediaArray,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   362
                aIndexOfCurrentlyPlayingItem);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   363
            break;
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
        case KNotPlayedPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   366
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   367
            iDbPodcast->GetNotYetPlayedPlaylistEpisodesL(aAttrs, aMediaArray,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   368
                aIndexOfCurrentlyPlayingItem);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   369
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   370
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   371
        default:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   372
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   373
            User::Leave(KErrNotSupported);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   374
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   375
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   376
    }
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
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   379
// Retrieve the episode with the specified ID
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
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   382
void CMPXPodcastDbHandler::GetEpisodeL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   383
    TUint32 aEpisodeId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   384
    const TArray<TMPXAttribute>& aAttrs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   385
    CMPXMediaArray& aMediaArray)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   386
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   387
    MPX_FUNC("CMPXPodcastDbHandler::GetEpisodeL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   388
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   389
    CMPXMedia* media = CMPXMedia::NewL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   390
    CleanupStack::PushL(media);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   391
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   392
    GetEpisodeL(aEpisodeId, aAttrs, *media);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   393
    aMediaArray.AppendL(*media);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   394
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   395
    CleanupStack::PopAndDestroy(media);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   396
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   397
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   398
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   399
// Retrieve the episode with the specified ID
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   400
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   401
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   402
void CMPXPodcastDbHandler::GetEpisodeL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   403
    TUint32 aEpisodeId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   404
    const TArray<TMPXAttribute>& aAttrs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   405
    CMPXMedia& aMedia)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   406
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   407
    MPX_FUNC("CMPXPodcastDbHandler::GetEpisodeL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   408
    iDbPodcast->GetEpisodeL(aEpisodeId, aAttrs, aMedia);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   409
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   410
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   411
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   412
// Retrieve the episode with the specified URI
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   413
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   414
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   415
TUint32 CMPXPodcastDbHandler::GetEpisodeIdMatchingUriL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   416
    const TDesC& aUri)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   417
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   418
    MPX_FUNC("CMPXPodcastDbHandler::GetEpisodeIdMatchingUriL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   419
    return MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXCollection, aUri, EFalse);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   420
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   421
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   422
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   423
// Return all podcast title names
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   424
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   425
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   426
void CMPXPodcastDbHandler::GetAllPodcastTitlesL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   427
    const TArray<TMPXAttribute>& aAttrs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   428
    CMPXMediaArray& aMediaArray)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   429
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   430
    MPX_FUNC("CMPXPodcastDbHandler::GetAllPodcastTitlesL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   431
    iDbAlbum->GetAllCategoryItemsL(aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   432
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   433
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   434
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   435
// Retrieve episodes matching the specified publish playlist id
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   436
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   437
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   438
TInt CMPXPodcastDbHandler::GetEpisodesMatchingPublishPlaylistL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   439
    TUint aPlaylistId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   440
    const TArray<TMPXAttribute>& aAttrs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   441
    TBool aPendingCategoryDeletionFlag,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   442
    CMPXMediaArray& aMediaArray)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   443
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   444
    MPX_FUNC("CMPXPodcastDbHandler::GetEpisodesMatchingPublishPlaylistL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   445
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   446
    TInt numEpisodes(0);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   447
    TMPXItemId podcastPublishDateCatId = 0;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   448
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   449
    // the deletion helper is retrieving all the media within this category
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   450
    // to delete it so need to record category id within last item so
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   451
    // that the HandleChangeL callback can cause OpenL to be called after the
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   452
    // last item within the category is deleted
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   453
    if (aPendingCategoryDeletionFlag)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   454
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   455
        TInt categoryID(EMPXOther);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   456
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   457
        // pass in the category Id so that the helper method can add
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   458
        // the category Id to the last item in this category to aid
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   459
        // in deletion of a category
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   460
        podcastPublishDateCatId = (aPlaylistId - KPublishTodayPlaylistUID) | (categoryID << 28);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   461
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   462
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   463
    switch (aPlaylistId)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   464
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   465
        case KPublishAllPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   466
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   467
            TInt itemCount(iPodcastPublishDateCat->Count());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   468
            for (TInt i = 0; i < itemCount; ++i)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   469
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   470
                TMPXItemId itemId = iPodcastPublishDateIds[i];
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   471
                TInt count(0);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   472
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   473
                switch (iPodcastPublishDateIds[i] + KPublishTodayPlaylistUID)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   474
                    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   475
                    case KPublishTodayPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   476
                        count = iDbPodcast->GetTodayEpisodesCountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   477
                        break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   478
                    case KPublishYesterdayPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   479
                        count = iDbPodcast->GetYesterdayEpisodesCountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   480
                        break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   481
                    case KPublishThisWeekPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   482
                        count = iDbPodcast->GetThisWeekEpisodesCountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   483
                        break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   484
                    case KPublishLastWeekPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   485
                        count = iDbPodcast->GetLastWeekEpisodesCountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   486
                        break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   487
                    case KPublish2WeeksAgoPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   488
                        count = iDbPodcast->Get2WeeksAgoEpisodesCountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   489
                        break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   490
                    case KPublish3WeeksAgoPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   491
                        count = iDbPodcast->Get3WeeksAgoEpisodesCountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   492
                        break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   493
                    case KPublishLastMonthPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   494
                        count = iDbPodcast->GetLastMonthEpisodesCountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   495
                        break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   496
                    case KPublishEarlierPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   497
                        count = iDbPodcast->GetEarlierEpisodesCountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   498
                        break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   499
                    case KPublishUnknownPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   500
                        count = iDbPodcast->GetUnknownEpisodesCountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   501
                        break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   502
                    default:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   503
                        User::Leave(KErrNotFound);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   504
                        break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   505
                    };
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   506
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   507
                if (count > 0)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   508
                    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   509
                    numEpisodes += count;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   510
                    MPXDbUtil::AppendMediaL(aMediaArray, iPodcastPublishDateCat->MdcaPoint(i),
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   511
                        EMPXGroup, EMPXPlaylist, EMPXPodcastGroup, EMPXPubDate, itemId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   512
                    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   513
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   514
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   515
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   516
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   517
        case KPublishTodayPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   518
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::GetEpisodesMatchingPublishPlaylistL: Published Today"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   519
            iDbPodcast->GetTodayEpisodesL(podcastPublishDateCatId, aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   520
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   521
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   522
        case KPublishYesterdayPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   523
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::GetEpisodesMatchingPublishPlaylistL: Published Yesterday"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   524
            iDbPodcast->GetYesterdayEpisodesL(podcastPublishDateCatId, aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   525
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   526
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   527
        case KPublishThisWeekPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   528
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::GetEpisodesMatchingPublishPlaylistL: Published This Week"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   529
            iDbPodcast->GetThisWeekEpisodesL(podcastPublishDateCatId, aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   530
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   531
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   532
        case KPublishLastWeekPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   533
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::GetEpisodesMatchingPublishPlaylistL: Published Last Week"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   534
            iDbPodcast->GetLastWeekEpisodesL(podcastPublishDateCatId, aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   535
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   536
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   537
        case KPublish2WeeksAgoPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   538
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::GetEpisodesMatchingPublishPlaylistL: Published 2 Weeks Ago"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   539
            iDbPodcast->Get2WeeksAgoEpisodesL(podcastPublishDateCatId, aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   540
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   541
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   542
        case KPublish3WeeksAgoPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   543
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::GetEpisodesMatchingPublishPlaylistL: Published 3 Weeks Ago"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   544
            iDbPodcast->Get3WeeksAgoEpisodesL(podcastPublishDateCatId, aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   545
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   546
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   547
        case KPublishLastMonthPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   548
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::GetEpisodesMatchingPublishPlaylistL: Published Last Month"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   549
            iDbPodcast->GetLastMonthEpisodesL(podcastPublishDateCatId, aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   550
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   551
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   552
        case KPublishEarlierPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   553
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::GetEpisodesMatchingPublishPlaylistL: Published Earlier"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   554
            iDbPodcast->GetEarlierEpisodesL(podcastPublishDateCatId, aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   555
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   556
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   557
        case KPublishUnknownPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   558
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::GetEpisodesMatchingPublishPlaylistL: Published Unknown"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   559
            iDbPodcast->GetUnknownEpisodesL(podcastPublishDateCatId, aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   560
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   561
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   562
        default:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   563
            MPX_DEBUG2 (_L("CMPXPodcastDbHandler::GetEpisodesMatchingPublishPlaylistL: Invalid publish ID [%d]"), aPlaylistId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   564
            User::Leave(KErrNotFound);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   565
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   566
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   567
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   568
    if (aPlaylistId != KPublishAllPlaylistUID)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   569
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   570
        numEpisodes = aMediaArray.Count();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   571
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   572
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   573
    return numEpisodes;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   574
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   575
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   576
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   577
// Get the name of the row matching the given ID
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   578
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   579
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   580
HBufC* CMPXPodcastDbHandler::GetTitleNameMatchingIdL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   581
    const TUint32 aId)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   582
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   583
    MPX_FUNC("CMPXPodcastDbHandler::GetTitleNameMatchingIdL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   584
    return iDbAlbum->GetNameL(aId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   585
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   586
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   587
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   588
// Get the URI of the row matching the given ID
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   589
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   590
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   591
HBufC* CMPXPodcastDbHandler::GetUriMatchingIdL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   592
    const TUint32 aId)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   593
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   594
    MPX_FUNC("CMPXPodcastDbHandler::GetUriMatchingIdL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   595
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   596
    return iDbPodcast->GetUriL(aId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   597
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   598
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   599
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   600
// Find episode(s) that satisfy the specified criteria
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   601
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   602
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   603
CMPXMedia* CMPXPodcastDbHandler::FindAllLC(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   604
    const CMPXMedia& aCriteria,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   605
    const TArray<TMPXAttribute>& aAttrs)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   606
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   607
    MPX_FUNC("CMPXPodcastDbHandler::FindAllLC");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   608
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   609
    // leave if the given media doesn't contain the following attributes
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   610
    if (!aCriteria.IsSupported(KMPXMediaGeneralType) ||
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   611
        !aCriteria.IsSupported(KMPXMediaGeneralCategory))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   612
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   613
        User::Leave(KErrArgument);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   614
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   615
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   616
    RArray<TInt> supportedIds;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   617
    CleanupClosePushL(supportedIds);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   618
    supportedIds.AppendL(KMPXMediaIdContainer);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   619
    MPXDbCommonUtil::FillInSupportedUIDsL(aAttrs, supportedIds);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   620
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   621
    CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   622
    CleanupStack::PopAndDestroy(&supportedIds);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   623
    CleanupStack::PushL(entries);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   624
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   625
    CMPXMediaArray* array = CMPXMediaArray::NewL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   626
    CleanupStack::PushL(array);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   627
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   628
    FindAllL(aCriteria, aAttrs, *array);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   629
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   630
    entries->SetTObjectValueL(KMPXMediaGeneralType, EMPXGroup);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   631
    entries->SetTObjectValueL(KMPXMediaGeneralCategory,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   632
         aCriteria.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   633
    entries->SetCObjectValueL(KMPXMediaArrayContents, array);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   634
    entries->SetTObjectValueL(KMPXMediaArrayCount, array->Count());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   635
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   636
    CleanupStack::PopAndDestroy(array);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   637
    return entries;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   638
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   639
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   640
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   641
// Find the number of items in the database
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   642
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   643
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   644
TInt CMPXPodcastDbHandler::NumberOfItemsL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   645
    TMPXPodcastCategory aCategory)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   646
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   647
    MPX_FUNC("CMPXPodcastDbHandler::NumberOfItemsL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   648
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   649
    TInt numOfItems(0);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   650
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   651
    switch(aCategory)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   652
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   653
        case EMPXAll:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   654
        case EMPXEpisode:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   655
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   656
            numOfItems = iDbPodcast->CountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   657
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   658
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   659
        case EMPXRecentlyAdded:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   660
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   661
            numOfItems = iDbPodcast->GetRecentlyAddedEpisodesCountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   662
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   663
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   664
        case EMPXNotYetPlayed:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   665
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   666
            numOfItems = iDbPodcast->GetNotYetPlayedEpisodesCountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   667
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   668
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   669
        case EMPXTitle:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   670
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   671
            numOfItems = iDbPodcast->GetNotYetPlayedEpisodesCountL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   672
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   673
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   674
        default:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   675
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   676
            User::Leave(KErrNotSupported);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   677
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   678
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   679
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   680
    return numOfItems;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   681
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   682
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   683
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   684
// Has the database been created?
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   685
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   686
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   687
TBool CMPXPodcastDbHandler::DatabaseCreated()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   688
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   689
    MPX_FUNC("CMPXPodcastDbHandler::DatabaseCreated");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   690
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   691
    TBool AuxilaryDbIsRefreshed(EFalse);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   692
    TRAP_IGNORE(AuxilaryDbIsRefreshed = iDbAuxiliary->IsRefreshedL());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   693
    // If none of the databases were available, ie out of disk
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   694
    // we return EFalse
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   695
    return iDbManager->IsInitialized() && AuxilaryDbIsRefreshed;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   696
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   697
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   698
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   699
//  CMPXPodcastDbHandler::GetAllEpisodesDurationL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   700
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   701
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   702
TInt CMPXPodcastDbHandler::GetAllEpisodesDurationL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   703
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   704
    MPX_FUNC("CMPXPodcastDbHandler::GetAllEpisodesDurationL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   705
    return iDbPodcast->AllEpisodesDurationL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   706
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   707
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   708
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   709
//  CMPXPodcastDbHandler::GetTitleDurationL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   710
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   711
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   712
TInt CMPXPodcastDbHandler::GetTitleDurationL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   713
    TUint32 aTitleId)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   714
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   715
    MPX_FUNC("CMPXPodcastDbHandler::GetTitleDurationL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   716
    return iDbPodcast->TitleDurationL(aTitleId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   717
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   718
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   719
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   720
//  CMPXPodcastDbHandler::GetNotPlayedDurationL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   721
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   722
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   723
TInt CMPXPodcastDbHandler::GetNotPlayedDurationL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   724
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   725
    MPX_FUNC("CMPXPodcastDbHandler::GetNotPlayedDurationL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   726
    return iDbPodcast->NotPlayedDurationL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   727
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   728
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   729
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   730
//  CMPXPodcastDbHandler::GetRecentlyAddedDurationL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   731
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   732
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   733
TInt CMPXPodcastDbHandler::GetRecentlyAddedDurationL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   734
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   735
    MPX_FUNC("CMPXPodcastDbHandler::GetRecentlyAddedDurationL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   736
    return iDbPodcast->RecentlyAddedDurationL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   737
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   738
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   739
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   740
// Set the last refreshed time into the collection
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   741
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   742
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   743
void CMPXPodcastDbHandler::SetLastRefreshedTimeL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   744
    TTime aTime)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   745
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   746
    MPX_FUNC("CMPXPodcastDbHandler::SetLastRefreshedTimeL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   747
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   748
    BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   749
    MPX_TRAPD(err, iDbAuxiliary->SetLastRefreshedTimeL(aTime));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   750
    EndTransactionL(err);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   751
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   752
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   753
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   754
// Get the last refreshed time into the collection
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   755
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   756
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   757
TTime CMPXPodcastDbHandler::GetLastRefreshedTimeL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   758
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   759
    MPX_FUNC("CMPXPodcastDbHandler::GetLastRefreshedTimeL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   760
    return iDbAuxiliary->LastRefreshedTimeL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   761
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   762
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   763
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   764
// Set the db corrupted state for all drives
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   765
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   766
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   767
void CMPXPodcastDbHandler::SetDBCorruptedL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   768
    TBool aCorrupted)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   769
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   770
    MPX_FUNC("CMPXPodcastDbHandler::SetDBCorruptedL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   771
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   772
    BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   773
    MPX_TRAPD(err, iDbAuxiliary->SetDBCorruptedL(aCorrupted));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   774
    EndTransactionL(err);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   775
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   776
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   777
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   778
// Gets the db corrupted state for all drives
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   779
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   780
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   781
TBool CMPXPodcastDbHandler::IsDBCorruptedL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   782
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   783
    MPX_FUNC("CMPXPodcastDbHandler::IsDBCorruptedL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   784
    return iDbAuxiliary->DBCorruptedL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   785
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   786
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   787
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   788
// Opens a database
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   789
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   790
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   791
void CMPXPodcastDbHandler::OpenDatabaseL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   792
    TInt aDrive)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   793
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   794
    MPX_FUNC("CMPXPodcastDbHandler::OpenDatabaseL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   795
    iDbManager->OpenDatabaseL(aDrive);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   796
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   797
    // Verify the volume ID after a remount event
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   798
    VerifyVolumeIdL( aDrive );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   799
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   800
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   801
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   802
// Close a database
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   803
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   804
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   805
void CMPXPodcastDbHandler::CloseDatabaseL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   806
    TInt aDrive)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   807
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   808
    MPX_FUNC("CMPXPodcastDbHandler::CloseDatabaseL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   809
    iDbManager->CloseDatabaseL(aDrive);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   810
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   811
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   812
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   813
// Re-create all databases
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   814
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   815
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   816
void CMPXPodcastDbHandler::ReCreateDatabasesL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   817
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   818
    MPX_FUNC("CMPXPodcastDbHandler::ReCreateDatabasesL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   819
    iDbManager->RecreateAllDatabasesL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   820
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   821
66
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 53
diff changeset
   822
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 53
diff changeset
   823
// ----------------------------------------------------------------------------
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 53
diff changeset
   824
// Re-create a specified database file
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 53
diff changeset
   825
// ----------------------------------------------------------------------------
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 53
diff changeset
   826
//
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 53
diff changeset
   827
void CMPXPodcastDbHandler::RecreateDatabaseFileL( TInt aDrive )
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 53
diff changeset
   828
    {
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 53
diff changeset
   829
    MPX_FUNC("CMPXPodcastDbHandler::RecreateDatabaseFileL");
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 53
diff changeset
   830
    MPX_DEBUG2( "CMPXPodcastDbHandler::RecreateDatabaseFileL drive: %i", aDrive );
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 53
diff changeset
   831
    iDbManager->RecreateDatabaseFileL( aDrive );  
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 53
diff changeset
   832
    }
1f1dad4af8f8 Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 53
diff changeset
   833
53
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   834
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   835
// Set handler refresh status
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   836
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   837
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   838
void CMPXPodcastDbHandler::RefreshStartL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   839
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   840
    MPX_FUNC("CMPXPodcastDbHandler::RefreshStartL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   841
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   842
    iOutOfDisk = EFalse;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   843
    // Re-open databases
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   844
    // This is needed for the case where we were OOD before, but user
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   845
    // has cleared some space but now try to refresh
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   846
    MPX_TRAPD(err, iDbManager->InitDatabasesL(iDbDrives));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   847
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   848
    if(err == KErrDiskFull)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   849
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   850
        iOutOfDisk = ETrue;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   851
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   852
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   853
    if(!iOutOfDisk)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   854
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   855
        MPX_TRAP(err,CheckDiskSpaceOnDrivesL());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   856
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   857
        if(err == KErrDiskFull)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   858
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   859
            iOutOfDisk = ETrue;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   860
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   861
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   862
    BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   863
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   864
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   865
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   866
// Re-set handler refresh status
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   867
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   868
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   869
void CMPXPodcastDbHandler::RefreshEndL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   870
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   871
    MPX_FUNC("CMPXPodcastDbHandler::RefreshEndL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   872
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   873
    EndTransactionL(KErrNone);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   874
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   875
    if (!iOutOfDisk)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   876
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   877
        // Write last refreshed time as current time
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   878
        // This also sets corrupt = 0
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   879
        TTime curTime;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   880
        curTime.HomeTime();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   881
        SetLastRefreshedTimeL(curTime);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   882
//        iDbManager->PrintDatabaseL();    // PREQ2536 the files sqlrowsetutil.h and sqlrowsetutil.cpp has been removed
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   883
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   884
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   885
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   886
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   887
// CMPXPodcastDbHandler::SetIsPlayingL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   888
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   889
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   890
void CMPXPodcastDbHandler::SetIsPlayingL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   891
    const CMPXMedia& aMedia,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   892
    TBool aIsPlaying)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   893
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   894
    MPX_FUNC("CMPXPodcastDbHandler::SetIsPlayingL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   895
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   896
    TUint32 episodeId(0);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   897
    if (aMedia.IsSupported(KMPXMediaGeneralId))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   898
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   899
        episodeId = aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   900
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   901
    else if (aMedia.IsSupported(KMPXMediaGeneralUri))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   902
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   903
        const TDesC& location(aMedia.ValueText(KMPXMediaGeneralUri));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   904
        episodeId = MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXCollection, location, EFalse);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   905
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   906
    else
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   907
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   908
        User::Leave(KErrArgument);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   909
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   910
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   911
    BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   912
    MPX_TRAPD(err, iDbPodcast->SetIsPlayingL(episodeId, aIsPlaying));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   913
    EndTransactionL(err);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   914
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   915
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   916
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   917
// Get all records count for podcasts
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   918
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   919
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   920
TUint CMPXPodcastDbHandler::GetTotalCountL(TInt aDrive)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   921
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   922
    MPX_FUNC("CMPXPodcastDbHandler::GetTotalCountL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   923
    TUint total(0);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   924
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   925
    total = iDbPodcast->GetDrivePodcastCountL(aDrive);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   926
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   927
    return total;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   928
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   929
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   930
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   931
// Get all records count for podcasts
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   932
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   933
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   934
void CMPXPodcastDbHandler::GetPodcastUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   935
                                               CDesCArray& aUriArr, TInt& aLastID)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   936
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   937
    MPX_FUNC("CMPXPodcastDbHandler::GetTotalUriArrayL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   938
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   939
    iDbPodcast->GetPodcastUriArrayL(aDrive,aFromID,aRecords,aUriArr,aLastID);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   940
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   941
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   942
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   943
// CMPXPodcastDbHandler::DoCleanupDeletedRecordsL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   944
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   945
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   946
void CMPXPodcastDbHandler::DoCleanupDeletedRecordsL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   947
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   948
    MPX_FUNC("CMPXPodcastDbHandler::DoCleanupDeletedRecordsL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   949
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   950
    // delete all marked records from the Music table
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   951
    iDbPodcast->CleanupL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   952
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   953
    // reset the count in the Auxiliary table
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   954
    iDbAuxiliary->SetSaveDeletedRecordCountL(KDbManagerAllDrives,0);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   955
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   956
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   957
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   958
// FindAllL helper
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   959
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   960
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   961
void CMPXPodcastDbHandler::FindAllL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   962
    const CMPXMedia& aCriteria,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   963
    const TArray<TMPXAttribute>& aAttrs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   964
    CMPXMediaArray& aMediaArray)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   965
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   966
    MPX_FUNC("CMPXPodcastDbHandler::FindAllL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   967
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   968
    RArray<TMPXAttribute> attributes;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   969
    CleanupClosePushL (attributes);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   970
    MPXUser::MergeAttributeL(aAttrs, attributes);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   971
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   972
    // TODO: b10liu: update all users to properly use podcast category?
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   973
    // Some users of FindAll still call without specifying a podcast category group(ie.. delete helper)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   974
    // so need to check and use media category instead if not available.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   975
    if (!aCriteria.IsSupported(KMPXMediaPodcastCategoryGroup))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   976
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   977
        if (!aCriteria.IsSupported(KMPXMediaGeneralCategory))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   978
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   979
            User::Leave(KErrArgument);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   980
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   981
        TMPXGeneralCategory category = aCriteria.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   982
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   983
        switch (category)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   984
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   985
            case EMPXAlbum:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   986
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   987
                if (!aCriteria.IsSupported(KMPXMediaGeneralId))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   988
                    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   989
                    User::Leave(KErrArgument);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   990
                    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   991
                // return all episodes within this title
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   992
                TMPXItemId episodeTitleId = aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   993
                GetEpisodesMatchingTitleL(episodeTitleId, aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   994
                break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   995
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   996
            case EMPXPodcast:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   997
            case EMPXSong:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   998
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   999
                FindEpisodesL(aCriteria, attributes.Array(), aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1000
                break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1001
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1002
            case EMPXGenre:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1003
            case EMPXPlaylist:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1004
            case EMPXArtist:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1005
            case EMPXComposer:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1006
            default:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1007
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1008
                DbCategoryL(category)->FindAllL(aCriteria, attributes.Array(), aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1009
                break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1010
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1011
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1012
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1013
    else
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1014
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1015
        TMPXPodcastCategory category =
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1016
             aCriteria.ValueTObjectL<TMPXPodcastCategory>(KMPXMediaPodcastCategoryGroup);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1017
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1018
        switch (category)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1019
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1020
            case EMPXTitle:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1021
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1022
                if (!aCriteria.IsSupported(KMPXMediaGeneralId))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1023
                    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1024
                    User::Leave(KErrArgument);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1025
                    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1026
                // return all episodes within this title
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1027
                TMPXItemId episodeTitleId = aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1028
                GetEpisodesMatchingTitleL(episodeTitleId, aAttrs, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1029
                break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1030
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1031
            case EMPXPubDate:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1032
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1033
                if (!aCriteria.IsSupported(KMPXMediaGeneralId))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1034
                    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1035
                    User::Leave(KErrArgument);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1036
                    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1037
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1038
                TMPXItemId categoryId = aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1039
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1040
                // zero out the high 4 bits which indicate the general category
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1041
                categoryId.iId2 &= 0x00FFFFFF;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1042
                GetEpisodesMatchingPublishPlaylistL(categoryId.iId2 + KPublishTodayPlaylistUID, // offset by KPublishTodayPlaylistUID
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1043
                    aAttrs, EFalse, aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1044
                break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1045
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1046
            case EMPXRecentlyAdded:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1047
            case EMPXNotYetPlayed:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1048
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1049
                break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1050
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1051
            case EMPXAll:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1052
            case EMPXEpisode:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1053
            case EMPXNew:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1054
            case EMPXPartlyPlayed:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1055
            case EMPXCompletelyPlayed:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1056
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1057
                FindEpisodesL(aCriteria, attributes.Array(), aMediaArray);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1058
                break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1059
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1060
            default:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1061
                User::Leave(KErrNotSupported);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1062
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1063
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1064
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1065
    CleanupStack::PopAndDestroy(&attributes);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1066
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1067
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1068
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1069
// Get episode(s) from the music table that match the given criteria
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1070
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1071
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1072
void CMPXPodcastDbHandler::FindEpisodesL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1073
    const CMPXMedia& aCriteria,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1074
    const TArray<TMPXAttribute>& aAttrs,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1075
    CMPXMediaArray& aMediaArray)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1076
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1077
    MPX_FUNC("CMPXPodcastDbHandler::FindEpisodesL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1078
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1079
    TMPXGeneralType type(EMPXNoType);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1080
    if (!aCriteria.IsSupported(KMPXMediaGeneralType))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1081
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1082
        User::Leave(KErrArgument);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1083
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1084
    type = aCriteria.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1085
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1086
    TMPXPodcastType podcastType(EMPXPodcastNoType);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1087
    if (aCriteria.IsSupported(KMPXMediaPodcastType))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1088
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1089
        podcastType = aCriteria.ValueTObjectL<TMPXPodcastType>(KMPXMediaPodcastType);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1090
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1091
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1092
    TUint32 id(0);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1093
    if (aCriteria.IsSupported(KMPXMediaGeneralId))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1094
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1095
        id = aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1096
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1097
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1098
    TUint32 containerId(0);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1099
    if (aCriteria.IsSupported(KMPXMediaGeneralContainerId))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1100
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1101
        containerId = aCriteria.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralContainerId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1102
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1103
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1104
    MPX_TRAPD(err, iDbPodcast->FindEpisodesL(id, containerId, type, podcastType,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1105
        aCriteria, aAttrs, aMediaArray));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1106
    if (err == KErrNotSupported)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1107
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1108
        User::Leave(KErrNotFound);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1109
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1110
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1111
    User::LeaveIfError(err);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1112
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1113
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1114
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1115
// Add episode to collection
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1116
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1117
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1118
TUint32 CMPXPodcastDbHandler::DoAddEpisodeL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1119
    const CMPXMedia& aMedia)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1120
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1121
    MPX_FUNC("CMPXPodcastDbHandler::DoAddEpisodeL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1122
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1123
    if (!aMedia.IsSupported(KMPXMediaGeneralUri))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1124
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1125
        User::Leave(KErrArgument);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1126
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1127
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1128
    TDriveUnit drive(aMedia.ValueText(KMPXMediaGeneralUri));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1129
    return iDbPodcast->AddEpisodeL(aMedia, drive);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1130
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1131
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1132
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1133
// Update a episode in the collection
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1134
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1135
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1136
CMPXDbActiveTask::TChangeVisibility CMPXPodcastDbHandler::DoUpdateEpisodeL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1137
    const CMPXMedia& aMedia,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1138
    CMPXMessageArray& aItemChangedMessages)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1139
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1140
    MPX_FUNC("CMPXPodcastDbHandler::DoUpdateEpisodeL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1141
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1142
    CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1143
    TUint32 curId(0);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1144
    TUint32 newId(0);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1145
    TInt curDrive(KErrNotFound);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1146
    TInt newDrive(KErrNotFound);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1147
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1148
    // find the episode by Id and update it
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1149
    if( aMedia.IsSupported(KMPXMediaGeneralId))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1150
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1151
        curId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1152
        curDrive = iDbPodcast->GetDriveL(curId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1153
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1154
    // find the episode by URI and update it
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1155
    if(aMedia.IsSupported(KMPXMediaGeneralUri))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1156
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1157
        const TDesC& uri = aMedia.ValueText(KMPXMediaGeneralUri);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1158
        if (uri.Length() == 0)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1159
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1160
            User::Leave( KErrArgument );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1161
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1162
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1163
        newDrive = TDriveUnit(uri);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1164
        newId = MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXCollection, uri, EFalse);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1165
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1166
    if (!curId && !newId)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1167
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1168
        User::Leave(KErrNotSupported);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1169
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1170
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1171
    TInt driveId = (curDrive != KErrNotFound) ? curDrive : newDrive;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1172
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1173
    if (driveId != KErrNotFound)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1174
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1175
        TUint32 episodeId = curId ? curId : newId;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1176
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1177
        // Update the Podcast table
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1178
        visibleChange = iDbPodcast->UpdateEpisodeL(episodeId, aMedia, aItemChangedMessages);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1179
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1180
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1181
    return visibleChange;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1182
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1183
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1184
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1185
// CMPXPodcastDbHandler::DoRemoveEpisodeL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1186
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1187
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1188
void CMPXPodcastDbHandler::DoRemoveEpisodeL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1189
    TUint32 aEpisodeId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1190
    CDesCArray& aUriArray,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1191
    CMPXMessageArray& aItemChangedMessages,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1192
    TBool aDeleteRecord)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1193
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1194
    MPX_FUNC("CMPXPodcastDbHandler::DoRemoveEpisodeL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1195
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1196
    TBool deleteRecord(ETrue);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1197
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1198
#if defined (__MTP_PROTOCOL_SUPPORT)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1199
    // Mark the song record as deleted if the following is true; otherwise, delete the
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1200
    // song record.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1201
    //
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1202
    // A client other than MTP has initiated this song deletion (aDeleteRecord is EFalse)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1203
    // and MTP has turned on its cenrep key to save deleted records and current number of
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1204
    // saved deleted records has not exceeded its maximum, KMCMaxSavedDeletedRecords.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1205
    //
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1206
    // Songs are marked as deleted in order to support auto-sync. MTP will delete these
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1207
    // marked records at the end of each session via CleanupDeletedMediasL.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1208
    //
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1209
    // For performance consideration, if the number of saved records exceeds its maximum,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1210
    // song record will be deleted.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1211
    if (!aDeleteRecord && SaveDeletedSongs())
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1212
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1213
        TUint32 savedDeletedRecordCount(iDbAuxiliary->SaveDeletedRecordCountL());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1214
        MPX_DEBUG2("Current number of saved deleted record count is %d", savedDeletedRecordCount);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1215
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1216
        if (savedDeletedRecordCount < KMCMaxSavedDeletedRecords)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1217
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1218
            deleteRecord = EFalse;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1219
            TInt drive = iDbPodcast->GetDriveL(aEpisodeId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1220
            TUint32 savedDeletedDriveRecordCount(iDbAuxiliary->SaveDeletedRecordCountL(drive));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1221
            iDbAuxiliary->SetSaveDeletedRecordCountL(drive,++savedDeletedDriveRecordCount);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1222
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1223
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1224
#endif
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1225
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1226
    // delete the episode 
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1227
	// IsAdd is passed EFalse to ensure the episode count will be decremented
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1228
    iDbPodcast->DeleteEpisodeL(aEpisodeId, aUriArray, aItemChangedMessages, EFalse, deleteRecord);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1229
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1230
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1231
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1232
// CMPXPodcastDbHandler::DoRemoveEpisodesMatchingCategoryL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1233
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1234
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1235
void CMPXPodcastDbHandler::DoRemoveEpisodesMatchingCategoryL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1236
    TMPXGeneralCategory aCategory,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1237
    TUint32 aCategoryId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1238
    CDesCArray& aUriArray,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1239
    CMPXMessageArray& aItemChangedMessages)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1240
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1241
    MPX_FUNC("CMPXPodcastDbHandler::DoRemoveEpisodesMatchingCategoryL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1242
    iDbPodcast->DeleteCategoryL(aCategory, aCategoryId, aUriArray,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1243
        aItemChangedMessages);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1244
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1245
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1246
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1247
// CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1248
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1249
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1250
void CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1251
    TUint32 aCategoryId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1252
    CDesCArray& aUriArray,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1253
    CMPXMessageArray& aItemChangedMessages)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1254
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1255
    MPX_FUNC("CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1256
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1257
    switch (aCategoryId + KPublishTodayPlaylistUID)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1258
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1259
        case KPublishTodayPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1260
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL: Published Today"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1261
            iDbPodcast->DeleteTodayEpisodesL(aUriArray, aItemChangedMessages);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1262
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1263
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1264
        case KPublishYesterdayPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1265
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL: Published Yesterday"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1266
            iDbPodcast->DeleteYesterdayEpisodesL(aUriArray, aItemChangedMessages);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1267
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1268
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1269
        case KPublishThisWeekPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1270
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL: Published This Week"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1271
            iDbPodcast->DeleteThisWeekEpisodesL(aUriArray, aItemChangedMessages);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1272
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1273
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1274
        case KPublishLastWeekPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1275
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL: Published Last Week"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1276
            iDbPodcast->DeleteLastWeekEpisodesL(aUriArray, aItemChangedMessages);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1277
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1278
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1279
        case KPublish2WeeksAgoPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1280
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL: Published 2 Weeks Ago"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1281
            iDbPodcast->Delete2WeeksAgoEpisodesL(aUriArray, aItemChangedMessages);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1282
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1283
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1284
        case KPublish3WeeksAgoPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1285
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL: Published 3 Weeks Ago"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1286
            iDbPodcast->Delete3WeeksAgoEpisodesL(aUriArray, aItemChangedMessages);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1287
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1288
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1289
        case KPublishLastMonthPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1290
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL: Published Last Month"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1291
            iDbPodcast->DeleteLastMonthEpisodesL(aUriArray, aItemChangedMessages);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1292
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1293
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1294
        case KPublishEarlierPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1295
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL: Published Earlier"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1296
            iDbPodcast->DeleteEarlierEpisodesL(aUriArray, aItemChangedMessages);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1297
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1298
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1299
        case KPublishUnknownPlaylistUID:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1300
            MPX_DEBUG1 (_L("CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL: Published Unknown"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1301
            iDbPodcast->DeleteUnknownEpisodesL(aUriArray, aItemChangedMessages);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1302
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1303
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1304
        default:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1305
            MPX_DEBUG2 (_L("CMPXPodcastDbHandler::DoRemoveEpisodesMatchingPublishDateCategoryL: Invalid publish date ID [%d]"), aCategoryId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1306
            // TODO: Leave with error?
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1307
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1308
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1309
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1310
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1311
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1312
// CMPXPodcastDbHandler::ProcessPodcastFoldersL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1313
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1314
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1315
void CMPXPodcastDbHandler::ProcessPodcastFoldersL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1316
    const CDesCArray& aFolders)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1317
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1318
    MPX_FUNC("CMPXPodcastDbHandler::ProcessPodcastFoldersL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1319
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1320
    TInt count(aFolders.MdcaCount());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1321
    for (TInt i = 0; i < count; ++i)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1322
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1323
        TPtrC16 folder = aFolders.MdcaPoint(i);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1324
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1325
        // check if disk is inserted and act accordingly
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1326
        TDriveUnit driveUnit(folder);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1327
        if (!iFs.IsValidDrive(driveUnit))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1328
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1329
            User::Leave(KErrArgument);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1330
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1331
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1332
        // append the drive to the drive list
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1333
        iDbDrives.AppendL(driveUnit);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1334
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1335
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1336
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1337
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1338
// CMPXPodcastDbHandler::DbCategoryL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1339
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1340
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1341
CMPXDbCategory* CMPXPodcastDbHandler::DbCategoryL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1342
    TMPXGeneralCategory aCategory) const
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1343
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1344
    MPX_FUNC("CMPXPodcastDbHandler::DbCategoryL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1345
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1346
    CMPXDbCategory* dbCategory(NULL);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1347
    switch (aCategory)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1348
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1349
        case EMPXArtist:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1350
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1351
            dbCategory = iDbArtist;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1352
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1353
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1354
        case EMPXAlbum:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1355
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1356
            dbCategory = iDbAlbum;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1357
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1358
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1359
        case EMPXGenre:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1360
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1361
            dbCategory = iDbGenre;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1362
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1363
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1364
        case EMPXComposer:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1365
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1366
            dbCategory = iDbComposer;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1367
            break;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1368
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1369
        default:
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1370
            User::Leave(KErrNotSupported);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1371
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1372
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1373
    return dbCategory;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1374
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1375
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1376
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1377
// Starts a transaction on all databases
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1378
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1379
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1380
void CMPXPodcastDbHandler::BeginTransactionL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1381
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1382
    MPX_FUNC("CMPXPodcastDbHandler::BeginTransactionL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1383
    iDbManager->BeginL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1384
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1385
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1386
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1387
// Ends a transaction on all databases
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1388
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1389
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1390
void CMPXPodcastDbHandler::EndTransactionL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1391
    TInt aError)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1392
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1393
    MPX_FUNC("CMPXPodcastDbHandler::EndTransactionL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1394
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1395
    if (aError)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1396
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1397
        iDbManager->RollbackL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1398
        
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1399
        // KSqlDbCorrupted indicates DB corrupted, need to recreate.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1400
        if ( aError != KSqlDbCorrupted )
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1401
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1402
            User::Leave(aError);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1403
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1404
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1405
    else
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1406
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1407
        iDbManager->CommitL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1408
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1409
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1410
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1411
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1412
// Checks if the database is currently in a transaction
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1413
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1414
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1415
TBool CMPXPodcastDbHandler::InTransaction()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1416
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1417
    MPX_FUNC("CMPXPodcastDbHandler::InTransaction");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1418
    return iDbManager->InTransaction();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1419
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1420
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1421
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1422
// Verifies that the volume ID of the database matches the drive
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1423
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1424
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1425
void CMPXPodcastDbHandler::VerifyVolumeIdL( TInt aDrive )
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1426
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1427
    MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL <--");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1428
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1429
    if( iDbManager->IsOpen(aDrive) )
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1430
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1431
        TVolumeInfo volInfo;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1432
        iFs.Volume(volInfo, aDrive );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1433
        TUint curId(volInfo.iUniqueID);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1434
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1435
        TInt volId = iDbAuxiliary->IdL( aDrive );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1436
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1437
        // New database, no volume id set, mask out top bit because this is an uint
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1438
        //
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1439
        MPX_DEBUG3("CMPXPodcastDbHandler::VerifyVolumeIdL drive:%i db:%i", curId, volId);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1440
        if( volId == 0 && (curId&0x7FFFFFFF) )
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1441
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1442
            MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- New ID");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1443
            BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1444
            TRAPD( err, iDbAuxiliary->SetIdL( aDrive, curId&0x7FFFFFFF ) );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1445
            EndTransactionL( err );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1446
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1447
            // KSqlDbCorrupted indicates DB corrupted, need to recreate.
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1448
            if ( err == KSqlDbCorrupted )
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1449
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1450
                MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- Corrupted DB");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1451
                iDbManager->RecreateDatabaseL( aDrive );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1452
                BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1453
                TRAPD( err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1454
                EndTransactionL( err );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1455
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1456
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1457
        // Unmatched volume id, mark db as corrupt
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1458
        //
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1459
        else if ( (curId&0x7FFFFFFF) != (volId&0x7FFFFFFFF) )
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1460
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1461
            MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -- ID match FAILED");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1462
            iDbManager->RecreateDatabaseL( aDrive );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1463
            BeginTransactionL();
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1464
            TRAPD( err, iDbAuxiliary->SetDBCorruptedL( ETrue ) );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1465
            EndTransactionL( err );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1466
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1467
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1468
    MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -->");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1469
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1470
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1471
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1472
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1473
// Verifies that the volume ID of the database matches the drive
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1474
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1475
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1476
void CMPXPodcastDbHandler::VerifyVolumeIdL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1477
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1478
    MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL <--");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1479
    TInt count( iDbDrives.Count() );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1480
    for( TInt i=0; i<count; ++i )
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1481
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1482
        VerifyVolumeIdL(iDbDrives[i]);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1483
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1484
    MPX_DEBUG1("CMPXPodcastDbHandler::VerifyVolumeIdL -->");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1485
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1486
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1487
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1488
// Checks if there is a drive that has a low disk space
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1489
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1490
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1491
void CMPXPodcastDbHandler::CheckDiskSpaceOnDrivesL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1492
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1493
    MPX_DEBUG1("CMPXPodcastDbHandler::CheckDiskSpaceOnDrivesL <--");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1494
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1495
    TInt count( iDbDrives.Count() );
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1496
    for( TInt index=0; index<count; ++index )
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1497
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1498
        iDbManager->CheckDiskSpaceL(iDbDrives[index]);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1499
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1500
    MPX_DEBUG1("CMPXPodcastDbHandler::CheckDiskSpaceOnDrivesL -->");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1501
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1502
#if defined (__MTP_PROTOCOL_SUPPORT)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1503
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1504
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1505
// CMPXPodcastDbHandler::SaveDeletedSongs
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1506
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1507
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1508
TBool CMPXPodcastDbHandler::SaveDeletedSongs()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1509
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1510
    MPX_FUNC("CMPXPodcastDbHandler::SaveDeletedSongs");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1511
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1512
    TBool saveDeletedSongs(ETrue);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1513
    CRepository* cenrep(NULL);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1514
    MPX_TRAPD(error, cenrep = CRepository::NewL(KMPXMtpSettings));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1515
    if (!error)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1516
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1517
        cenrep->Get(KMPXMtpSaveDeletedRecordFlag, saveDeletedSongs);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1518
        delete cenrep;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1519
        MPX_DEBUG2("MTP indicated to save deleted songs? %d", saveDeletedSongs);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1520
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1521
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1522
    return saveDeletedSongs;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1523
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1524
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1525
#endif
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1526
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1527
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1528
// CMPXPodcastDbHandler::AddCategoryItemL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1529
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1530
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1531
TUint32 CMPXPodcastDbHandler::AddCategoryItemL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1532
    TMPXGeneralCategory aCategory,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1533
    const TDesC& aName,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1534
    TInt aDriveId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1535
    CMPXMessageArray* aItemChangedMessages)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1536
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1537
    MPX_FUNC("CMPXPodcastDbHandler::AddCategoryItemL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1538
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1539
    TBool newRecord(EFalse);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1540
    TUint32 id(DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1541
        (aCategory != EMPXGenre)));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1542
    if (newRecord && aItemChangedMessages)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1543
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1544
        MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1545
            EMPXItemInserted, aCategory, KDBPluginUid);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1546
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1547
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1548
    return id;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1549
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1550
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1551
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1552
// CMPXPodcastDbHandler::DeleteEpisodeForCategoryL
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1553
// ----------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1554
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1555
void CMPXPodcastDbHandler::DeleteEpisodeForCategoryL(
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1556
    TMPXGeneralCategory aCategory,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1557
    TUint32 aCategoryId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1558
    TInt aDriveId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1559
    CMPXMessageArray* aItemChangedMessages)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1560
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1561
    MPX_FUNC("CMPXPodcastDbHandler::DeleteEpisodeForCategoryL");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1562
    DbCategoryL(aCategory)->DecrementEpisodesForCategoryL(aCategoryId, aDriveId,
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1563
        aItemChangedMessages);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1564
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1565
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1566
#ifdef RD_MULTIPLE_DRIVE
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1567
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1568
// ----------------------------------------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1569
// Retrieve all visible podcast folder locations
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1570
// ----------------------------------------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1571
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1572
CDesCArrayFlat* CMPXPodcastDbHandler::GetPodcastFoldersL()
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1573
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1574
    MPX_FUNC("CMPXPodcastDbHandler::GetPodcastFoldersL()");
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1575
    TDriveList driveList;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1576
    TInt driveCount(0);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1577
    User::LeaveIfError(DriveInfo::GetUserVisibleDrives(iFs, driveList, driveCount));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1578
    MPX_DEBUG2 ("CMPXDbHandler::GetPodcastFoldersL() - driveCount = %d", driveCount);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1579
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1580
    CDesCArrayFlat* folders = new (ELeave) CDesCArrayFlat(1); // granularity
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1581
    CleanupStack::PushL(folders);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1582
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1583
    for (TInt i = EDriveA; i <= EDriveZ; i++)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1584
        {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1585
        if ((driveList[i]) && (!IsRemoteDrive(static_cast<TDriveNumber>(i))))
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1586
            {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1587
            if (i == EDriveC)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1588
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1589
                // Append the default phone memory path to the list
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1590
                // of music folders
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1591
                TPtrC rootPath(PathInfo::PhoneMemoryRootPath());
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1592
                folders->AppendL(rootPath);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1593
                MPX_DEBUG2("CMPXDbHandler::GetPodcastFoldersL() - adding...%S", &rootPath);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1594
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1595
            else
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1596
                {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1597
                // Get drive letter
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1598
                TChar driveChar;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1599
                User::LeaveIfError(iFs.DriveToChar(i, driveChar));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1600
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1601
                // Append visible drive to list of music folders
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1602
                TBuf<2> drive;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1603
                drive.Append(driveChar);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1604
                drive.Append(_L(":"));
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1605
                folders->AppendL(drive);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1606
                MPX_DEBUG2 ("CMPXDbHandler::GetPodcastFoldersL() - adding...%S", &drive);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1607
                }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1608
            }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1609
        }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1610
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1611
    CleanupStack::Pop(folders);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1612
    return folders;
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1613
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1614
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1615
#endif // RD_MULTIPLE_DRIVE
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1616
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1617
// ---------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1618
// CMPXPodcastDbHandler::IsRemoteDrive
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1619
// ---------------------------------------------------------------------------
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1620
//
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1621
TBool CMPXPodcastDbHandler::IsRemoteDrive(TDriveNumber aDrive)
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1622
    {
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1623
    return iDbManager->IsRemoteDrive(aDrive);
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1624
    }
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1625
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1626
// End of File
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1627
3de6c4cf6b67 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1628