mmappcomponents/harvester/metadataextractor/src/mpxmetadataextractor.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 13 Oct 2010 15:06:09 +0300
branchRCL_3
changeset 67 16db3449d7ba
parent 59 666f9a5a90a9
permissions -rw-r--r--
Revision: 201039 Kit: 201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:  Extracts metadata from a file
67
16db3449d7ba Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 59
diff changeset
    15
*  Version     : %version: da1mmcf#38.1.4.2.6.1.14 % << Don't touch! Updated by Synergy at check-out.
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
*/
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <e32base.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <badesca.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <apgcli.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <MetaDataUtility.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <MetaDataFieldContainer.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#ifdef RD_MPX_TNM_INTEGRATION
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <hash.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <f32file.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <sysutil.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include <thumbnailmanager.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#endif //RD_MPX_TNM_INTEGRATION
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include <mpxlog.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include <mpxmedia.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
#include <mpxcollectionpath.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#include <mpxcollectiontype.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include <mpxdrmmediautility.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include <mpxmediamusicdefs.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
#include <mpxmediageneraldefs.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
#include <mpxmediaaudiodefs.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
#include <mpxmediadrmdefs.h>
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
#include <mpxmediamtpdefs.h>
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
    44
#include <mpxmetadataextractorobserver.h>
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
#include "mpxmetadataextractor.h"
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
#include "mpxfileinfoutility.h"
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    48
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    49
_LIT( KWmaMimeType, "audio/x-ms-wma" );
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    50
_LIT( KWmaCafMimeType, "x-caf-audio/x-ms-wma" );
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    51
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
#ifdef RD_MPX_TNM_INTEGRATION
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
_LIT( KImageFileType, "image/jpeg" );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
const TInt KMPXTimeoutTimer = 3000000; // 3 seconds
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
    55
const TInt KMPXMaxThumbnailRequest = 2; 
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
#endif //RD_MPX_TNM_INTEGRATION
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
17
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
    58
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
    59
_LIT( KNonEmbeddedArtExt, ".alb" );
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
    60
#endif
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
//Helper functions
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
static void FindAndReplaceForbiddenChars(TDes& aString, TInt aLen)
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
    MPX_ASSERT(aLen == aString.Length());
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
    for (TInt i = 0; i < aLen; ++i)
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
        {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
        if (aString[i] == TText('\t'))
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
            {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
            aString[i] = TText(' ');
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
            }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
        }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
// Constructor
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
//
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
CMPXMetadataExtractor::CMPXMetadataExtractor(
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
                                  RFs& aFs,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
                                  RApaLsSession& aAppArc,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
                                  RPointerArray<CMPXCollectionType>& aTypes  )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
                                  : iFs( aFs ),
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
                                    iAppArc( aAppArc ),
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
                                    iSupportedTypes( aTypes ),
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
    86
                                    iCancelled( EFalse ),
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
    87
                                    iObs( NULL ),
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
    88
                                    iMedia( NULL ),
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
    89
                                    iMetadataOnly( EFalse ),
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
    90
                                    iFileOpenError( KErrNone )
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
// 2nd Phase Constructor
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
//
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
void CMPXMetadataExtractor::ConstructL()
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
    iMetadataUtility = CMetaDataUtility::NewL();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
    iDrmMediaUtility = CMPXDrmMediaUtility::NewL();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
    iFileInfoUtil    = CMPXFileInfoUtility::NewL();
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   105
    iTaskTimer = CPeriodic::NewL( CActive::EPriorityIdle );
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
#ifdef RD_MPX_TNM_INTEGRATION
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    // Create Thumbnail Manager instance. This object is the observer.
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
    iTNManager = CThumbnailManager::NewL( *this );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
    iTNManager->SetFlagsL( CThumbnailManager::EDefaultFlags );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    iTNManager->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQuality);
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
    // create wait loop
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
    iTNSyncWait = new (ELeave) CActiveSchedulerWait;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
    iTimer = CPeriodic::NewL( CActive::EPriorityIdle );
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   115
    iArrayTNRequestId.Reset();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   116
    iArrayTasks.Reset();
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
#endif //RD_MPX_TNM_INTEGRATION
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
// Two-Phased Constructor
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
//
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
EXPORT_C CMPXMetadataExtractor* CMPXMetadataExtractor::NewL(
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
                                  RFs& aFs,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
                                  RApaLsSession& aAppArc,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
                                  RPointerArray<CMPXCollectionType>& aTypes  )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
    CMPXMetadataExtractor* self = new( ELeave ) CMPXMetadataExtractor( aFs,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
                                                                       aAppArc,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
                                                                       aTypes );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
    CleanupStack::PushL( self );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    self->ConstructL();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
    CleanupStack::Pop( self );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
    return self;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
// Destructor
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
//
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
CMPXMetadataExtractor::~CMPXMetadataExtractor()
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
    delete iMetadataUtility;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
    delete iFileInfoUtil;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
    delete iDrmMediaUtility;
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   148
    delete iTaskTimer;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   149
    iFile.Close();
30
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   150
    if ( iMedia != NULL )
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   151
        {
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   152
        delete iMedia;
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   153
        }
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
#ifdef RD_MPX_TNM_INTEGRATION
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
    delete iTNManager;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
    if (iTNSyncWait && iTNSyncWait->IsStarted() )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
        {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
        iTNSyncWait->AsyncStop();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
        }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    delete iTNSyncWait;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    delete iTimer;
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   162
    iArrayTNRequestId.Close();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   163
    iArrayTasks.Close();
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
#endif //RD_MPX_TNM_INTEGRATION
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
// ---------------------------------------------------------------------------
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   168
// Constructs a media properties object : synchronous function
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
//
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
EXPORT_C void CMPXMetadataExtractor::CreateMediaL( const TDesC& aFile,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
                                                   CMPXMedia*& aNewProperty,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
                                                   TBool aMetadataOnly )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
    {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   175
    MPX_FUNC("CMPXMetadataExtractor::CreateMediaL()");
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   176
    // check if we are still processing a request.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   177
    if ( iArrayTasks.Count() )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   178
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   179
        MPX_DEBUG1("CMPXMetadataExtractor::CreateMediaL Request ongoing. Abort!" );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   180
        User::Leave( KErrAbort );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   181
        }
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   183
    iCancelled = EFalse;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   184
    iFileOpenError = KErrNone;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   185
    iObs = NULL;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   186
    aNewProperty = NULL;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   187
    iFileName = aFile;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   188
    iMetadataOnly = aMetadataOnly;
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   189
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   190
    // populate the task array
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   191
    AddTasksL();
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   192
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   193
    // execute all tasks in the array
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   194
    while ( iArrayTasks.Count() )
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
        {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   196
        // execute task at index 0
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   197
        MPX_TRAPD( error, ExecuteTaskL() );
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   198
        if ( error || iCancelled )
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
            {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   200
            // cleanup
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   201
            if ( iMedia != NULL )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   202
                {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   203
                delete iMedia;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   204
                iMedia = NULL;
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
                }
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   206
            iArrayTasks.Reset();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   207
            if ( error )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   208
                {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   209
                CleanUp();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   210
                User::LeaveIfError( error );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   211
                }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   212
            break;
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
            }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   214
        
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   215
        iArrayTasks.Remove( 0 );
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
        }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   217
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   218
    aNewProperty = iMedia;
30
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   219
    iMedia = NULL;  // ownership transferred.
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   220
    CleanUp();
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
// Sets all of the default media properties
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
//
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
void CMPXMetadataExtractor::SetDefaultL( CMPXMedia& aMediaProp )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
    {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   229
    MPX_FUNC("CMPXMetadataExtractor::SetDefaultL()");
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
    // Comment
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
    aMediaProp.SetTextValueL( KMPXMediaGeneralComment,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
                              KNullDesC );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
    // Artist
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
    aMediaProp.SetTextValueL( KMPXMediaMusicArtist,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
                              KNullDesC );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
    // Album
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
    aMediaProp.SetTextValueL( KMPXMediaMusicAlbum,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
                              KNullDesC );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   239
    // Year
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   240
    aMediaProp.SetTObjectValueL<TInt64>( KMPXMediaMusicYear,
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   241
                                         (TInt64) 0 );
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
    // Track
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
    aMediaProp.SetTextValueL( KMPXMediaMusicAlbumTrack,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
                              KNullDesC );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
    // Genre
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
    aMediaProp.SetTextValueL( KMPXMediaMusicGenre,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
                              KNullDesC );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
    // Composer
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
    aMediaProp.SetTextValueL( KMPXMediaMusicComposer,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
                              KNullDesC );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
    // Album artFilename
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
    aMediaProp.SetTextValueL( KMPXMediaMusicAlbumArtFileName,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
                              KNullDesC );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
    // URL
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
    aMediaProp.SetTextValueL( KMPXMediaMusicURL,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
                              KNullDesC );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
// Sets media object attributes from metadata utilities
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
//
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   263
void CMPXMetadataExtractor::SetMediaPropertiesL()
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
    {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   265
    MPX_FUNC("CMPXMetadataExtractor::SetMediaPropertiesL()");
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   267
    const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   268
    HBufC8* mimeType8 = HBufC8::NewLC( mimeType.Length() );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   269
    mimeType8->Des().Append( mimeType );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   270
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   271
    // Continue to extract metadata even if fail.
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   272
    MPX_TRAPD( metadataerror, iMetadataUtility->OpenFileL( iFile, *mimeType8 ) );
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   273
    CleanupStack::PopAndDestroy( mimeType8 );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   274
    
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   275
    // Get MetadataUtility Container
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   276
    const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL();
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   277
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   278
    // Get DRM data
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   279
    // Need the protected flag from metadataUtility Container
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   280
    MPX_TRAPD( drmerror, SetDrmMediaPropertiesL( metaCont ) );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   281
    MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, result=%d getting drm data", 
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   282
            drmerror );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   283
        
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   284
    // Get metadata fields
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
    TInt count( metaCont.Count() );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
    for( TInt i=0; i<count; ++i )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
        {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
        TMetaDataFieldId fieldType;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
        HBufC* value = NULL;
9
bee149131e4b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   291
        metaCont.FieldIdAt( i, fieldType );  // get the field type
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   292
        
9
bee149131e4b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   293
        // get the value, except for album art
bee149131e4b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   294
        if ( fieldType != EMetaDataJpeg )
bee149131e4b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   295
           {
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   296
            MPX_TRAPD( err, value = metaCont.At( i, fieldType ).AllocL() );
9
bee149131e4b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   297
           if ( KErrNone != err )
bee149131e4b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   298
               {
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   299
               MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL - error = %i", err);           
9
bee149131e4b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   300
               continue;
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   301
               }     
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   302
           CleanupStack::PushL( value );
9
bee149131e4b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   303
           }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   304
        
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
        switch( fieldType )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
            {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
            case EMetaDataSongTitle:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
                {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
                TPtr valptr = value->Des();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
                valptr.Trim();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
                TInt vallen = value->Length();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
                if (vallen>0)
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
                    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
                    FindAndReplaceForbiddenChars(valptr, vallen);
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   315
                    iMedia->SetTextValueL(KMPXMediaGeneralTitle, *value);
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
                    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
            case EMetaDataArtist:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
                {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
                TPtr valptr = value->Des();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
                valptr.Trim();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
                TInt vallen = value->Length();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
                if (vallen>0)
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
                    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
                    FindAndReplaceForbiddenChars(valptr, vallen);
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   327
                    iMedia->SetTextValueL(KMPXMediaMusicArtist, *value);
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
                    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
            case EMetaDataAlbum:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
                {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
                TPtr valptr = value->Des();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
                valptr.Trim();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
                TInt vallen = value->Length();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
                if (vallen>0)
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
                    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
                    FindAndReplaceForbiddenChars(valptr, vallen);
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   339
                    iMedia->SetTextValueL(KMPXMediaMusicAlbum, *value );
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
                    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
            case EMetaDataYear:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
                {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
                // Perform the date time conversion
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
                TLex lexer( *value );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
                TInt year( 0 );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
                lexer.Val( year );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
                // Convert from TInt -> TDateTime -> TTime -> TInt64
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
                TDateTime dt;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
                dt.SetYear( year );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
                TTime time( dt );
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   354
                iMedia->SetTObjectValueL<TInt64>( KMPXMediaMusicYear,
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
                                                 time.Int64() );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
            case EMetaDataComment:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
                {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   360
                iMedia->SetTextValueL( KMPXMediaGeneralComment,
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
                                      *value );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
            case EMetaDataAlbumTrack:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
                {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   366
                iMedia->SetTextValueL( KMPXMediaMusicAlbumTrack,
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
                                      *value );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
            case EMetaDataGenre:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
                {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
                TPtr valptr = value->Des();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
                valptr.Trim();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
                TInt vallen = value->Length();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
                if (vallen>0)
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
                    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
                    FindAndReplaceForbiddenChars(valptr, vallen);
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   378
                    iMedia->SetTextValueL(KMPXMediaMusicGenre, *value);
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
                    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
            case EMetaDataComposer:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
                {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
                TPtr valptr = value->Des();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
                valptr.Trim();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
                TInt vallen = value->Length();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
                if (vallen>0)
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
                    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
                    FindAndReplaceForbiddenChars(valptr, vallen);
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   390
                    iMedia->SetTextValueL(KMPXMediaMusicComposer, *value);
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
                    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
            case EMetaDataUrl:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
            case EMetaDataUserUrl:  // fall through
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
                {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   397
                iMedia->SetTextValueL( KMPXMediaMusicURL,
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
                                      *value );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
            case EMetaDataJpeg:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
                {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   403
                // Album art handled in AddMediaAlbumArtL()
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
            case EMetaDataCopyright:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
                {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   408
                iMedia->SetTextValueL( KMPXMediaGeneralCopyright,
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
                                      *value );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
                }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   412
            case EMetaDataDuration:     
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   413
                {                  
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   414
                const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   415
                MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);   
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   416
                
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   417
                // Verify if WMA, get the duration
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   418
                if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   419
                    {
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   420
                    MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");                         
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   421
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   422
                    // Perform the duration conversion
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   423
                    TLex lexer( *value );
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   424
                    TInt32 duration ( 0 );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   425
                    lexer.Val( duration );   // [second]      
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   426
                    duration *= 1000;        // [msec]
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   427
                
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   428
                    iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration,
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   429
                                                duration );      
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   430
                
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   431
                    MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", duration);  
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   432
                    }
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   433
                break;
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   434
                }
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
            case EMetaDataOriginalArtist:  // fall through
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
            case EMetaDataVendor:          // fall through
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
            case EMetaDataRating:          // fall through
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
            case EMetaDataUniqueFileIdentifier:  // fall through
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
            case EMetaDataDate:            // fall through
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
                {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
                // not used
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
            default:
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
                {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
                //ASSERT(0);
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
                break;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
            }
9
bee149131e4b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   450
        if (fieldType != EMetaDataJpeg)
bee149131e4b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   451
            {
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   452
            CleanupStack::PopAndDestroy( value );       
9
bee149131e4b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   453
            }
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
        }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
// Sets extra media properties not returned by metadata utilities
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
//
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   461
void CMPXMetadataExtractor::SetExtMediaPropertiesL()
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
    {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   463
    MPX_FUNC("CMPXMetadataExtractor::SetExtMediaPropertiesL()");
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   465
    //
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   466
    // File Size --- The following needs MMF support
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
    //
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
    TInt size( 0 );
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   469
    if( iFileOpenError == KErrNone )
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
        {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   471
        const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   472
        MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, mimeType = %S", &mimeType);   
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   473
        iFile.Size( size );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   474
        iMedia->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, size );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   475
        
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   476
        // Verify if WMA, skip getting info from MMF
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   477
        if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   478
            {
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   479
            // No need to get MMF support
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   480
            MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, skip MMF ");   
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   481
            }
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   482
        else
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   483
            {
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   484
            MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, get MMF controller");   
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   485
            // Duration, bitrate, samplerate, etc
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   486
            //
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   487
            if( !iMetadataOnly )
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
            {
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   489
                MPX_TRAPD(err2, iFileInfoUtil->OpenFileL(
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   490
                          iFile, 
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   491
                          iMedia->ValueText(KMPXMediaGeneralMimeType)));
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   492
                MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, file info util error %i", err2);
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   493
                if( KErrNone == err2 )
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   494
                    {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   495
                    iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   496
                                                   iFileInfoUtil->BitRate() );
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   497
                    iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioSamplerate,
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   498
                                                   iFileInfoUtil->SampleRate() );
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   499
                    TInt64 duration = (TInt64) iFileInfoUtil->Duration().Int64() / 1000; // ms
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   500
                    iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration,
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   501
                                                    duration );
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   502
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   503
                    MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL -- duration %i", duration);
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   504
                    }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   505
                
19
51035f0751c2 Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   506
                iFileInfoUtil->Reset();
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
                }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
            }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
        }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
// Check to see if this file is a supported container
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
//
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
TInt CMPXMetadataExtractor::SupportedContainerTypeL( const TDesC& aFile,
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
                                                     TInt aIndex )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
    {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   519
    MPX_FUNC("CMPXMetadataExtractor::SupportedContainerTypeL()");
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
    TInt index(KErrNotFound);
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
    TDataType dataType;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
    TUid dummyUid(KNullUid);
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
    iAppArc.AppForDocument(aFile, dummyUid, dataType);
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
    TInt index2(KErrNotFound);
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
    const CDesCArray& mimeTypes = iSupportedTypes[aIndex]->Mimetypes();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
    if (!mimeTypes.FindIsq(dataType.Des(), index2))
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
        { // found
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
        index = index2;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
        }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
    return ( index == KErrNotFound ? KErrNotSupported : index );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
// CMPXMetadataExtractor::ThumbnailPreviewReady
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
// Callback but not used here
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
// ---------------------------------------------------------------------------
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   541
void CMPXMetadataExtractor::ThumbnailPreviewReady( 
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
        MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
    MPX_FUNC("CMPXMetadataExtractor::ThumbnailPreviewReady()");
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
    }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   546
        
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
// ---------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
// CMPXMetadataExtractor::ThumbnailReady
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
// Callback but not used here
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
// ---------------------------------------------------------------------------
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   552
void CMPXMetadataExtractor::ThumbnailReady( TInt /*aError*/, 
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   553
        MThumbnailData& /*aThumbnail*/, TThumbnailRequestId aId )
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
    MPX_FUNC("CMPXMetadataExtractor::ThumbnailReady()");
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   556
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   557
    // Remove thumbnail id from array.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   558
    TInt index = iArrayTNRequestId.Find( aId );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   559
    if ( index >= 0 )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   560
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   561
        iArrayTNRequestId.Remove( index );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   562
        }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   563
    MPX_DEBUG2("CMPXMetadataExtractor::ThumbnailReady(): Outstanding Thumbnail Request = %d",
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   564
            iArrayTNRequestId.Count());
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   565
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   566
    if ( iArrayTNRequestId.Count() < KMPXMaxThumbnailRequest )
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
        {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
        StopWaitLoop();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
        }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
// ----------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
// Callback for timer.
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
// ----------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
TInt CMPXMetadataExtractor::TimeoutTimerCallback(TAny* aPtr)
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
    MPX_FUNC("CMPXMetadataExtractor::TimeoutTimerCallback()");
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
    CMPXMetadataExtractor* ptr =
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
        static_cast<CMPXMetadataExtractor*>(aPtr);
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   581
        
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   582
    // Timer expired before thumbnail callback occurred. Stop wait loop to unblock. 
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
    ptr->StopWaitLoop();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
    return KErrNone;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
// ----------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
// Stop the wait loop.
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
// ----------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
void CMPXMetadataExtractor::StopWaitLoop()
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   591
    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   592
    MPX_FUNC("CMPXMetadataExtractor::StopWaitLoop()");
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
    // Cancel timer
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
    CancelTimeoutTimer();
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   595
    
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
    // Stop wait loop to unblock.
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
    if ( iTNSyncWait->IsStarted() )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
        {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
        MPX_DEBUG1("CMPXMetadataExtractor::StopWaitLoop(): Stopping the wait loop.");
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   600
        iTNSyncWait->AsyncStop();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
        }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   602
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   603
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   604
// ----------------------------------------------------------------------------
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   605
// Cancel timer. 
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
// ----------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   607
void CMPXMetadataExtractor::CancelTimeoutTimer()
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   608
    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
    MPX_FUNC("CMPXMetadataExtractor::CancelTimeoutTimer()");
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   610
    
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
    // Cancel timer.
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   612
    if ( iTimer && iTimer->IsActive() )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
        {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
        MPX_DEBUG1("CMPXMetadataExtractor::CancelTimeoutTimer(): Timer active, cancelling");
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
        iTimer->Cancel();
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
        }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
// ----------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
// Extract album art from a file and add to thumbnail manager.
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
// ----------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
EXPORT_C TInt CMPXMetadataExtractor::ExtractAlbumArtL( CMPXMedia* aMedia )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   623
    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
    MPX_FUNC("CMPXMetadataExtractor::ExtractAlbumArtL()");
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   625
    TInt err = KErrNone;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   626
    iCancelled = EFalse;
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   627
    
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
    if ( !aMedia->IsSupported(KMPXMediaGeneralUri) )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
        {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
        return KErrArgument;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
        }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   632
    
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
    // Get full file name.
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
    const TDesC& path = aMedia->ValueText(KMPXMediaGeneralUri);
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
    MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL Filename:%S ", &path );
17
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   636
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   637
    TParsePtrC parse( path );
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   638
    TPtrC ext( parse.Ext() );
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   639
    if (ext.CompareF(KNonEmbeddedArtExt)== 0)
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   640
        {
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   641
#ifdef RD_MPX_TNM_INTEGRATION
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   642
17
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   643
        //check if can send TN request, If thumbnail creation is ongoing, wait til it is done
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   644
        CheckBeforeSendRequest();
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   645
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   646
        CThumbnailObjectSource* source( NULL );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   647
        if (aMedia->IsSupported(KMPXMediaMTPSampleData))
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   648
            {
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   649
            TBuf<20> mimeType(KImageFileType);
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   650
            TInt sampleData = aMedia->ValueTObjectL<TInt>(KMPXMediaMTPSampleData);
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   651
            HBufC8* value8 = ((HBufC8*)sampleData)->Des().AllocLC();   // make a local copy of sampleData
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   652
            source = CThumbnailObjectSource::NewLC(
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   653
                value8, mimeType, path );    // give up ownership of value8
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   654
            
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   655
            MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from buffer");
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   656
            TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   657
            iArrayTNRequestId.Append( tnId );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   658
            CleanupStack::PopAndDestroy( source );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   659
            CleanupStack::Pop( value8 );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   660
            }
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   661
        else
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   662
            {
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   663
            source = CThumbnailObjectSource::NewLC(
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   664
                path, KImageFileType  );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   665
            
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   666
            MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from path");
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   667
            TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   668
            iArrayTNRequestId.Append( tnId );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   669
            CleanupStack::PopAndDestroy( source );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   670
            }
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   671
#endif // RD_MPX_TNM_INTEGRATION
17
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   672
        }
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   673
    else
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   674
        {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   675
#endif // ABSTRACTAUDIOALBUM_INCLUDED
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
    // create wanted fields array
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
    RArray<TMetaDataFieldId> wantedFields;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
    CleanupClosePushL( wantedFields );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
    wantedFields.Append(EMetaDataJpeg);
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   680
    
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
    // Open file
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   682
    if ( aMedia->IsSupported(KMPXMediaGeneralMimeType) )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
        {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
        const TDesC& mimeType = aMedia->ValueText( KMPXMediaGeneralMimeType );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
        MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL MimeType:%S ", &mimeType );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   686
        HBufC8* mimeType8 = HBufC8::NewLC( mimeType.Length() );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
        mimeType8->Des().Append( mimeType );
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   688
        MPX_TRAP( err, iMetadataUtility->OpenFileL( path, wantedFields, *mimeType8 ) );
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
        CleanupStack::PopAndDestroy( mimeType8 );
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   690
        }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
    else
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
        {
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   693
        MPX_TRAP( err, iMetadataUtility->OpenFileL( path, wantedFields ) );
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
        }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   695
    CleanupStack::PopAndDestroy( &wantedFields );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   696
    
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   697
    if ( !err )
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   698
        {
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   699
        //check if can send TN request, If thumbnail creation is ongoing, wait til it is done
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   700
        CheckBeforeSendRequest();
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   701
        MPX_TRAP( err, AddMediaAlbumArtL( *aMedia, path ));
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
        }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
    // Reset the utility
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   705
    iMetadataUtility->ResetL();
17
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   706
#ifdef ABSTRACTAUDIOALBUM_INCLUDED
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   707
      }
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   708
#endif // ABSTRACTAUDIOALBUM_INCLUDED
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   709
    return err;
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   710
    }
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   712
// ----------------------------------------------------------------------------
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   713
// Add album art to media object.
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   714
// ----------------------------------------------------------------------------
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   715
void CMPXMetadataExtractor::AddMediaAlbumArtL( CMPXMedia& aMedia, 
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   716
                                               const TDesC& aFile )
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   717
    {
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   718
    MPX_FUNC("CMPXMetadataExtractor::AddMediaAlbumArtL()");
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   719
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   720
    // get metadata container.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   721
    const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   722
    TPtrC8 data8 = metaCont.Field8( EMetaDataJpeg );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   723
   
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   724
    if ( data8.Length() )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   725
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   726
        MPX_DEBUG1("CMPXMetadataExtractor::GetMediaAlbumArtL(): Album art exist.");
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   727
#ifdef RD_MPX_TNM_INTEGRATION
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   728
        HBufC8* value8 = NULL; 
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   729
        MPX_TRAPD( err, value8 = data8.AllocL() );
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   730
        if ( KErrNone != err )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   731
            {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   732
            MPX_DEBUG2("CMPXMetadataExtractor::GetMediaAlbumArtL - error jpeg = %i", err);
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   733
            return;
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   734
            }              
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   735
        CleanupStack::PushL( value8 );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   736
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   737
        TBuf<256> mimeType;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   738
        mimeType.Copy( KImageFileType );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   739
        CThumbnailObjectSource* source = CThumbnailObjectSource::NewL(
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   740
                value8, mimeType, aFile );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   741
        TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   742
        iArrayTNRequestId.Append( tnId ); // add thumbnail id to array
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   743
        CleanupStack::Pop( value8 );
42
4aca42fa4eb1 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   744
        delete source;
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   745
        
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   746
        aMedia.SetTextValueL( KMPXMediaMusicOriginalAlbumArtFileName, aFile );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   747
#endif // RD_MPX_TNM_INTEGRATION          
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   748
        aMedia.SetTextValueL( KMPXMediaMusicAlbumArtFileName, aFile );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   749
        }
0
a2952bb97e68 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   750
    }
17
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   751
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   752
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   753
// Check if can send request to TNM or not.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   754
// ----------------------------------------------------------------------------
17
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   755
void CMPXMetadataExtractor::CheckBeforeSendRequest()
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   756
     {
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   757
     MPX_FUNC("CMPXMetadataExtractor::CheckBeforeSendRequest()");
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   758
#ifdef RD_MPX_TNM_INTEGRATION
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   759
    MPX_DEBUG2("CMPXMetadataExtractor::CheckBeforeSendRequest(): Outstanding Thumbnail Request = %d",
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   760
            iArrayTNRequestId.Count());
17
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   761
	// If thumbnail creation is ongoing, wait til it is done
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   762
    if ( iArrayTNRequestId.Count() >= KMPXMaxThumbnailRequest )
17
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   763
        {
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   764
        MPX_DEBUG1("CMPXMetadataExtractor::CheckBeforeSendRequest(): Thumbnail creation ongoing!");
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   765
        // Cancel timer.
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   766
        CancelTimeoutTimer();
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   767
        // Start timer in case there is no callback from ThumbNail Manager.
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   768
        iTimer->Start(
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   769
            KMPXTimeoutTimer,
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   770
            KMPXTimeoutTimer,
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   771
            TCallBack(TimeoutTimerCallback, this ));
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   772
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   773
        // Start wait loop until we get a callback from ThumbNail Manager.
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   774
        if ( !iTNSyncWait->IsStarted() )
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   775
            {
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   776
            iTNSyncWait->Start();
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   777
            }
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   778
        }
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   779
#endif // RD_MPX_TNM_INTEGRATION
780c925249c1 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
   780
     }
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   781
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   782
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   783
// Cancel request. This will empty the task array and stop the wait loop. This
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   784
//                 will cause the CreateMediaL() to finish more quickly.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   785
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   786
EXPORT_C void CMPXMetadataExtractor::CancelRequest()
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   787
    {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   788
    MPX_FUNC("CMPXMetadataExtractor::CancelRequest()");
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   789
    iCancelled = ETrue;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   790
    // Cancel all tasks
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   791
    iArrayTasks.Reset();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   792
    // Cancel all thumbnail request
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   793
    CancelAllThumbnailRequests();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   794
    StopWaitLoop();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   795
    }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   796
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   797
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   798
// Cancel all outstanding thumbnail requests.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   799
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   800
void CMPXMetadataExtractor::CancelAllThumbnailRequests()
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   801
    {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   802
    MPX_FUNC("CMPXMetadataExtractor::CancelAllThumbnailRequests()");
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   803
#ifdef RD_MPX_TNM_INTEGRATION
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   804
    // TODO: remove comments when TNM make CancelRequest asynchronous.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   805
    /*TInt count = iArrayTNRequestId.Count();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   806
    for ( TInt i=0; i<count; i++ )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   807
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   808
        iTNManager->CancelRequest( iArrayTNRequestId[i] );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   809
        }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   810
    */
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   811
    iArrayTNRequestId.Reset();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   812
#endif // RD_MPX_TNM_INTEGRATION
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   813
    }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   814
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   815
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   816
// Create media and set default data and mimetype.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   817
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   818
void CMPXMetadataExtractor::DoCreateMediaL()
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   819
    {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   820
    MPX_FUNC("CMPXMetadataExtractor::DoCreateMediaL()");
30
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   821
    MPX_ASSERT( iMedia == NULL );
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   822
    RArray<TInt> contentIDs;
30
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   823
    CleanupClosePushL( contentIDs );
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   824
    contentIDs.AppendL( KMPXMediaIdGeneral );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   825
    contentIDs.AppendL( KMPXMediaIdAudio );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   826
    contentIDs.AppendL( KMPXMediaIdMusic );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   827
    contentIDs.AppendL( KMPXMediaIdDrm );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   828
    contentIDs.AppendL( KMPXMediaIdMTP );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   829
    iMedia = CMPXMedia::NewL( contentIDs.Array() );
30
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   830
    CleanupStack::PopAndDestroy( &contentIDs );
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   831
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   832
    // CMPXMedia default types
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   833
    iMedia->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType,
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   834
                                              EMPXItem );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   835
    iMedia->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory,
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   836
                                                  EMPXSong );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   837
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   838
    TParsePtrC parse( iFileName );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   839
    // Title, default is file name
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   840
    iMedia->SetTextValueL( KMPXMediaGeneralTitle,
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   841
                          parse.Name() );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   842
    // Default album track
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   843
    iMedia->SetTextValueL( KMPXMediaMusicAlbumTrack,
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   844
                          KNullDesC );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   845
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   846
    // Set the Mime Type and collection UID
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   847
    //
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   848
    if( !iMetadataOnly )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   849
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   850
        TInt index(KErrNotFound);
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   851
        TInt count( iSupportedTypes.Count() );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   852
        for (TInt i=0; i <count; ++i)
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   853
            {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   854
            TInt index2(KErrNotFound);
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   855
            const CDesCArray& exts = iSupportedTypes[i]->Extensions();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   856
            const TDesC& ext = parse.Ext();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   857
            if (!exts.FindIsq(ext, index2))
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   858
                { // found
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   859
                index = i;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   860
                break;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   861
                }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   862
            }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   863
        if( KErrNotFound != index )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   864
            {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   865
            MPX_DEBUG1("CMPXMetadataExtractor::DoCreateMediaL apparc <---" );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   866
            TInt mimeIndex = SupportedContainerTypeL( iFileName, index );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   867
            User::LeaveIfError( mimeIndex );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   868
            MPX_DEBUG1("CMPXMetadataExtractor::DoCreateMediaL apparc --->" );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   869
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   870
            iMedia->SetTextValueL( KMPXMediaGeneralMimeType,
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   871
                                  iSupportedTypes[index]->Mimetypes()[mimeIndex] );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   872
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   873
            iMedia->SetTObjectValueL( KMPXMediaGeneralCollectionId,
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   874
                                     iSupportedTypes[index]->Uid() );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   875
            }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   876
        else
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   877
            {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   878
            User::Leave(KErrNotSupported);
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   879
            }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   880
        }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   881
    else // other case use apparc to fetch and set mimetype
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   882
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   883
        TDataType dataType;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   884
        TUid dummyUid(KNullUid);
67
16db3449d7ba Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 59
diff changeset
   885
        iAppArc.AppForDocument(iFileName, dummyUid, dataType);
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   886
        iMedia->SetTextValueL( KMPXMediaGeneralMimeType,dataType.Des() );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   887
        }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   888
        
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   889
    // Initially set default tags.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   890
    SetDefaultL( *iMedia );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   891
    }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   892
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   893
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   894
// Execute task at index 0.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   895
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   896
void CMPXMetadataExtractor::ExecuteTaskL()
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   897
    {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   898
    MPX_FUNC("CMPXMetadataExtractor::ExecuteTasksL()");
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   899
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   900
    if ( iArrayTasks.Count() )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   901
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   902
        switch ( iArrayTasks[0] )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   903
            {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   904
            case ETaskCreateMedia:
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   905
                DoCreateMediaL();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   906
                break;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   907
            case ETaskAddMetadata:
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   908
                SetMediaPropertiesL();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   909
                break;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   910
            case ETaskAddExtMetadata:
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   911
                SetExtMediaPropertiesL();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   912
                break;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   913
            case ETaskAddAlbumArt:
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   914
                AddMediaAlbumArtL( *iMedia, iFileName );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   915
                break;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   916
            case ETaskCheckBeforeSend:
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   917
                CheckBeforeSendRequest();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   918
                break;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   919
            default:
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   920
                MPX_ASSERT(0); // Should never get here
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   921
            }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   922
        }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   923
    }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   924
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   925
// ---------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   926
// Constructs a media properties object : asynchronous funcion
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   927
// ---------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   928
//
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   929
EXPORT_C void CMPXMetadataExtractor::CreateMediaAsyncL( const TDesC& aFile,
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   930
                                                        MMPXMetadataExtractorObserver* aObs,
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   931
                                                        TBool aMetadataOnly )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   932
    {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   933
    MPX_FUNC("CMPXMetadataExtractor::CreateMediaAsyncL()");
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   934
    // check if we are still processing a request.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   935
    if ( iArrayTasks.Count() )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   936
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   937
        MPX_DEBUG1("CMPXMetadataExtractor::CreateMediaAsyncL Request ongoing. Abort!" );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   938
        User::Leave( KErrAbort );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   939
        }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   940
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   941
    iCancelled = EFalse;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   942
    iFileOpenError = KErrNone;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   943
    iFileName = aFile;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   944
    iObs = aObs;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   945
    iMetadataOnly = aMetadataOnly;
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   946
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   947
    // populate the task array
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   948
    AddTasksL();
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   949
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   950
    // Start task timer to execute task
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   951
    if ( iArrayTasks.Count() )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   952
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   953
        if ( iTaskTimer->IsActive() )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   954
            {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   955
            iTaskTimer->Cancel();
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   956
            }   
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   957
        iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this ));
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   958
        }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   959
    }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   960
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   961
// ---------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   962
// Opens the file
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   963
// ---------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   964
//
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   965
TInt CMPXMetadataExtractor::OpenFile()
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   966
    {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   967
    MPX_FUNC("CMPXMetadataExtractor::OpenFile()");
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   968
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   969
    // Open the file
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   970
    iFile.Close();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   971
    TInt error = iFile.Open( iFs, iFileName, EFileRead | EFileShareReadersOrWriters );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   972
    MPX_DEBUG2("CMPXMetadataExtractor::OpenFile open error = %d", error );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   973
    return error;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   974
    }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   975
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   976
// ---------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   977
// Populat task array
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   978
// ---------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   979
//
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   980
void CMPXMetadataExtractor::AddTasksL()
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   981
    {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   982
    MPX_FUNC("CMPXMetadataExtractor::AddTasks()");
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   983
    iFileOpenError = OpenFile();
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
   984
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   985
    // Do not change the order of the task below.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   986
    iArrayTasks.Reset();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   987
    if ( iFileOpenError == KErrNone )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   988
        {
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   989
        // to avoid resources contention (i.e. accessing sql, file system, etc)
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   990
        // Ordering the tasks - so no multiple tasks run at the same time
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   991
        // put the longest running task at the last (i.e. thumbnailing)
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   992
        iArrayTasks.AppendL(ETaskCreateMedia);
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   993
        iArrayTasks.AppendL(ETaskAddExtMetadata);   // Get the MMF first
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   994
        iArrayTasks.AppendL(ETaskAddMetadata);      // Get metadata & maybe drm data
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   995
        iArrayTasks.AppendL(ETaskCheckBeforeSend);
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   996
        iArrayTasks.AppendL(ETaskAddAlbumArt);      // Get album art / thumbnail last
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   997
        }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   998
    else
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   999
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1000
        iArrayTasks.AppendL(ETaskCreateMedia);
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1001
        iArrayTasks.AppendL(ETaskAddExtMetadata);
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1002
        }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1003
    }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1004
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1005
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1006
// Callback for timer.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1007
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1008
TInt CMPXMetadataExtractor::TaskTimerCallback(TAny* aPtr)
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1009
    {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1010
    MPX_FUNC("CMPXMetadataExtractor::TaskTimerCallback()");
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1011
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1012
    CMPXMetadataExtractor* ptr =
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1013
        static_cast<CMPXMetadataExtractor*>(aPtr);
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1014
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1015
    ptr->HandleTaskTimerExpired();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1016
    return KErrNone;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1017
    }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1018
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1019
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1020
// Handle task timer expired
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1021
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1022
void CMPXMetadataExtractor::HandleTaskTimerExpired()
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1023
    {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1024
    MPX_FUNC("CMPXMetadataExtractor::HandleTaskTimerExpired()");
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
  1025
    
30
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
  1026
    if ( iTaskTimer && iTaskTimer->IsActive() )
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
  1027
        {
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
  1028
        iTaskTimer->Cancel();
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
  1029
        }
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1030
    // execute task at index 0
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1031
    MPX_TRAPD( error, ExecuteTaskL() );
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1032
    if ( error || iCancelled )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1033
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1034
        // cleanup
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1035
        if ( iMedia != NULL )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1036
            {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1037
            delete iMedia;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1038
            iMedia = NULL;
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1039
            }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1040
        iArrayTasks.Reset();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1041
        }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
  1042
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1043
    // Remove task at index 0.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1044
    if ( iArrayTasks.Count() )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1045
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1046
        iArrayTasks.Remove( 0 );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1047
        }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
  1048
    
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1049
    // check if we have any more task to run
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1050
    if ( iArrayTasks.Count() )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1051
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1052
        // start task timer
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1053
        iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this ));
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1054
        }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1055
    else
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1056
        {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1057
        // done
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1058
        if ( iObs && !iCancelled )
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1059
            {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1060
            iObs->HandleCreateMediaComplete( iMedia, error );
30
6f9f6e99a23e Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
  1061
            iMedia = NULL;  // ownership transferred.
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1062
            }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
  1063
        
23
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1064
        CleanUp();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1065
        }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1066
    }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1067
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1068
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1069
// Callback for timer.
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1070
// ----------------------------------------------------------------------------
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1071
void CMPXMetadataExtractor::CleanUp()
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1072
    {
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1073
    MPX_FUNC("CMPXMetadataExtractor::CleanUp()");
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1074
    // Reset the utility
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1075
    TRAP_IGNORE( iMetadataUtility->ResetL() );
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1076
    iFile.Close();
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1077
    }
4740b34b83ce Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1078
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1079
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1080
// ---------------------------------------------------------------------------
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1081
// Sets DRRM media properties not returned by metadata utilities
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1082
// ---------------------------------------------------------------------------
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1083
//
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1084
void CMPXMetadataExtractor::SetDrmMediaPropertiesL(const CMetaDataFieldContainer& aMetaCont)
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1085
    {
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1086
    MPX_FUNC("CMPXMetadataExtractor::SetDrmMediaPropertiesL()");
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1087
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1088
    TBool prot(EFalse);
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1089
    // DB Flags to set
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1090
    TUint dbFlags(KMPXMediaGeneralFlagsSetOrUnsetBit);
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1091
    // Validate the objects to be used
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1092
    MPX_ASSERT(iMedia);
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1093
    MPX_ASSERT(iDrmMediaUtility);
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
  1094
    
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1095
    // File Path
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1096
    TParsePtrC parse( iFileName );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1097
    iMedia->SetTextValueL( KMPXMediaGeneralUri, iFileName );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1098
    iMedia->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1099
    MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL - Filename=%S", &iFileName);
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1100
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1101
    // get the protected flag from MetadataUtility Container
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
  1102
    TPtrC ptr = aMetaCont.Field( EMetaDataProtected );  
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1103
    MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL -- status=%S", &ptr);
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1104
    _LIT( KNonProtected, "0" );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1105
    if ( ptr.Compare( KNonProtected ) == 0 )
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1106
        {
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1107
        // this is non-protected file
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1108
        // prot = EFalse
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1109
        MPX_DEBUG1("CMPXMetadataExtractor::SetDrmMediaPropertiesL - non protected");
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1110
        iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1111
        iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1112
        }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
  1113
    else  
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1114
        {  // DRM file
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1115
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1116
        // DRM Rights
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1117
        //
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1118
        CMPXMedia* drm = NULL;
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1119
        MPX_TRAPD( drmError, iDrmMediaUtility->InitL( iFileName );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1120
        drm = CMPXMedia::NewL( *iDrmMediaUtility->GetMediaL( KMPXMediaDrmProtected.iAttributeId |
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1121
                                                                KMPXMediaDrmRightsStatus.iAttributeId ) );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1122
             );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1123
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1124
        TBool prot(EFalse);
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1125
        if( drm )
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1126
            {
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1127
            CleanupStack::PushL( drm );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1128
            MPX_DEBUG1("CMPXMetadataExtractor::SetDrmMediaPropertiesL -- is a drm file");
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1129
            if( drm->IsSupported( KMPXMediaDrmProtected ) )
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1130
                {
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1131
                prot = drm->ValueTObjectL<TBool>( KMPXMediaDrmProtected );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1132
                MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL protected %i", prot);
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1133
                }
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1134
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1135
            TMPXMediaDrmRightsStatus status(EMPXDrmRightsFull);
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1136
            if( drm->IsSupported( KMPXMediaDrmRightsStatus ) )
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1137
                {
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1138
                status = drm->ValueTObjectL<TMPXMediaDrmRightsStatus>(KMPXMediaDrmRightsStatus);
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1139
                iMedia->SetTObjectValueL<TInt>(KMPXMediaDrmRightsStatus, status );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1140
                MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL -- status %i", status);
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1141
                }
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1142
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1143
            // Set DB flags
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1144
            dbFlags |= KMPXMediaGeneralFlagsIsDrmProtected;
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1145
            if( status != EMPXDrmRightsFull && status != EMPXDrmRightsRestricted && status != EMPXDrmRightsPreview )
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1146
                {
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1147
                dbFlags |= KMPXMediaGeneralFlagsIsDrmLicenceInvalid;
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1148
                }
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1149
            CleanupStack::PopAndDestroy( drm );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1150
            }
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1151
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1152
        // Trapped PV DRM error. If -46, we know the file has no rights
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1153
        //
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1154
        if( drmError == KErrPermissionDenied )
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1155
            {
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1156
            dbFlags |= KMPXMediaGeneralFlagsIsDrmLicenceInvalid;
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1157
            }
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1158
        else
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1159
            {
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1160
            User::LeaveIfError( drmError );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1161
            }
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1162
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1163
        iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot );
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1164
        iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
  1165
    
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1166
        iDrmMediaUtility->Close();
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
  1167
    
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1168
        }  // DRM file
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1169
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
  1170
    
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1171
    // verify the file open status
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1172
    if( iFileOpenError == KErrNotFound || iFileOpenError == KErrPathNotFound )
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1173
        {
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1174
        dbFlags |= KMPXMediaGeneralFlagsIsInvalid;
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1175
        }
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
  1176
    
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1177
    // Finally set the db flag
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1178
    //
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1179
    iMedia->SetTObjectValueL( KMPXMediaGeneralFlags, dbFlags );
56
63223d4fd956 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 55
diff changeset
  1180
   
28
f56ec6ce2732 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1181
    }