mtpdataproviders/mtpimagedp/src/mtpimagedputilits.cpp
changeset 0 d0791faffa3f
child 2 4843bb5893b6
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19 */
       
    20 
       
    21 #include <f32file.h>
       
    22 #include <centralrepository.h>
       
    23 
       
    24 #include <mtp/mmtpdataproviderframework.h>
       
    25 #include <mtp/cmtpobjectmetadata.h>
       
    26 #include <mtp/mmtpstoragemgr.h>
       
    27 #include <mtp/mmtpobjectmgr.h>
       
    28 
       
    29 #include "mtpimagedpconst.h"
       
    30 #include "mtpimagedputilits.h"
       
    31 #include "cmtpimagedp.h"
       
    32 
       
    33 TMTPResponseCode MTPImageDpUtilits::VerifyObjectHandleL(MMTPDataProviderFramework& aFramework, const TMTPTypeUint32& aHandle, CMTPObjectMetaData& aMetaData)
       
    34 	{
       
    35 	if (!aFramework.ObjectMgr().ObjectL(aHandle, aMetaData))
       
    36 		{
       
    37 		 return EMTPRespCodeInvalidObjectHandle;
       
    38 		}
       
    39 	return EMTPRespCodeOK;
       
    40 	}
       
    41 
       
    42 TInt32 MTPImageDpUtilits::FindStorage(MMTPDataProviderFramework& aFramework, const TDesC& aPath)
       
    43     {
       
    44     TParsePtrC parse(aPath);
       
    45 
       
    46     TPtrC drive(parse.Drive());
       
    47     TInt driveNumber;  
       
    48     aFramework.Fs().CharToDrive(drive[0], driveNumber);
       
    49     
       
    50     return aFramework.StorageMgr().FrameworkStorageId(static_cast<TDriveNumber>(driveNumber));
       
    51     }
       
    52 
       
    53 TUint32 MTPImageDpUtilits::FindParentHandleL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider, const TDesC& aFullPath)
       
    54     {
       
    55     TUint32 parentHandle = KMTPHandleNoParent;
       
    56     TParsePtrC parse(aFullPath);
       
    57     
       
    58     if(!parse.IsRoot())
       
    59         {   
       
    60         if (!aDataProvider.GetCacheParentHandle(parse.DriveAndPath(), parentHandle))
       
    61             {
       
    62             parentHandle = aFramework.ObjectMgr().HandleL(parse.DriveAndPath());
       
    63             if (parentHandle == KMTPHandleNone)
       
    64                 {
       
    65                 parentHandle = KMTPHandleNoParent;
       
    66                 }        
       
    67             else
       
    68                 {
       
    69                 aDataProvider.SetCacheParentHandle(parse.DriveAndPath(), parentHandle);
       
    70                 }
       
    71             }
       
    72         }
       
    73     
       
    74     return parentHandle;    
       
    75     }
       
    76 
       
    77 void MTPImageDpUtilits::UpdateNewPicturesValue(CMTPImageDataProvider& aDataProvider, TInt aNewPics, TBool aSetRProperty)
       
    78     {    
       
    79     TInt preNewPic = 0;
       
    80     aDataProvider.Repository().Get(ENewImagesCount, preNewPic);
       
    81     
       
    82     TInt newPics = aNewPics + preNewPic;
       
    83     aDataProvider.Repository().Set(ENewImagesCount, newPics);
       
    84     
       
    85     TInt curValue = 0;
       
    86     RProperty::Get(TUid::Uid(KMTPServerUID), KMTPNewPicKey, curValue);
       
    87     
       
    88     if (aSetRProperty && curValue != newPics)
       
    89         {
       
    90         RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, newPics);
       
    91         }
       
    92     }