mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/csendobject.cpp
changeset 64 92dbd2a406d9
parent 51 e61a04404bdf
equal deleted inserted replaced
61:3b098142db83 64:92dbd2a406d9
   449     PRINT3( _L("MM MTP <> CSendObject::DoHandleResponsePhaseInfoL iObjectFormat = 0x%x, iWidth = %d, iHeight = %d"),
   449     PRINT3( _L("MM MTP <> CSendObject::DoHandleResponsePhaseInfoL iObjectFormat = 0x%x, iWidth = %d, iHeight = %d"),
   450         iObjectFormat,
   450         iObjectFormat,
   451         iWidth,
   451         iWidth,
   452         iHeight );
   452         iHeight );
   453 
   453 
   454     // TODO: dateModified is reserved for extention usage.
       
   455     delete iDateMod;
   454     delete iDateMod;
   456     iDateMod = NULL;
   455     iDateMod = NULL;
   457     iDateMod = iObjectInfo->StringCharsL( CMTPTypeObjectInfo::EDateModified ).AllocL();
   456     iDateMod = iObjectInfo->StringCharsL( CMTPTypeObjectInfo::EDateModified ).AllocL();
   458 
   457 
   459     // check if storage is full
   458     // check if storage is full
   909                     element.Uint8L( CMTPTypeObjectPropListElement::EValue ) );
   908                     element.Uint8L( CMTPTypeObjectPropListElement::EValue ) );
   910                 break;
   909                 break;
   911 
   910 
   912             case EMTPObjectPropCodeDateAdded:
   911             case EMTPObjectPropCodeDateAdded:
   913             case EMTPObjectPropCodeDateCreated:
   912             case EMTPObjectPropCodeDateCreated:
   914             case EMTPObjectPropCodeDateModified:
       
   915             case EMTPObjectPropCodeObjectFileName:
   913             case EMTPObjectPropCodeObjectFileName:
   916                 // Do nothing for read-only properties
   914                 // Do nothing for read-only properties
   917                 /* spec:
   915                 /* spec:
   918                  * Object properties that are get-only (0x00 GET)
   916                  * Object properties that are get-only (0x00 GET)
   919                  * should accept values during object creation by
   917                  * should accept values during object creation by
   920                  * way of the SendObjectPropList command.
   918                  * way of the SendObjectPropList command.
   921                  */
   919                  */
   922                 break;
   920                 break;
   923 
   921 
       
   922             case EMTPObjectPropCodeDateModified:
   924             case EMTPObjectPropCodeProtectionStatus:
   923             case EMTPObjectPropCodeProtectionStatus:
   925                 // Already done in AddMediaToStore, it's not necessary to set it again.
   924                 // Already done in AddMediaToStore, it's not necessary to set it again.
   926                 // SetProtectionStatus();
       
   927                 break;
   925                 break;
   928 
   926 
   929             case EMTPObjectPropCodeName:
   927             case EMTPObjectPropCodeName:
   930             case EMTPObjectPropCodeAlbumArtist:
   928             case EMTPObjectPropCodeAlbumArtist:
   931                 {
   929                 {
  1224     PRINT( _L( "MM MTP <= CSendObject::ReserveObjectL" ) );
  1222     PRINT( _L( "MM MTP <= CSendObject::ReserveObjectL" ) );
  1225     return err;
  1223     return err;
  1226     }
  1224     }
  1227 
  1225 
  1228 // -----------------------------------------------------------------------------
  1226 // -----------------------------------------------------------------------------
  1229 // CSendObject::SetProtectionStatus
  1227 // CSendObject::SetFileProperties
  1230 // -----------------------------------------------------------------------------
  1228 // -----------------------------------------------------------------------------
  1231 //
  1229 //
  1232 void CSendObject::SetProtectionStatus()
  1230 void CSendObject::SetFileProperties()
  1233     {
  1231     {
  1234     PRINT1( _L( "MM MTP => CSendObject::SetProtectionStatus iProtectionStatus = %d" ), iProtectionStatus );
  1232     PRINT1( _L( "MM MTP => CSendObject::SetFileProperties iProtectionStatus = %d" ), iProtectionStatus );
  1235 
  1233 
  1236     if ( iFileReceived != NULL )
  1234     if ( iFileReceived != NULL )
  1237         {
  1235         {
  1238         if ( iProtectionStatus == EMTPProtectionNoProtection
  1236         if ( iProtectionStatus == EMTPProtectionNoProtection
  1239             || iProtectionStatus == EMTPProtectionReadOnly )
  1237             || iProtectionStatus == EMTPProtectionReadOnly )
  1248                 err = iFileReceived->File().SetAtt( KEntryAttReadOnly, KEntryAttNormal );
  1246                 err = iFileReceived->File().SetAtt( KEntryAttReadOnly, KEntryAttNormal );
  1249                 }
  1247                 }
  1250     
  1248     
  1251             if ( err != KErrNone )
  1249             if ( err != KErrNone )
  1252                 {
  1250                 {
  1253                 PRINT1( _L("MM MTP <> CSendObject::SetProtectionStatus err = %d" ), err );
  1251                 PRINT1( _L( "MM MTP <> CSendObject::SetFileProperties SetAtt err = %d" ), err );
  1254                 }
  1252                 }
  1255             }
  1253             }
  1256         // Close the file after SetProtectionStatus to make sure other process won't open
  1254 
       
  1255         if( iDateMod != NULL )
       
  1256             {
       
  1257             TTime modTime( 0 );
       
  1258             TInt err = MmMtpDpUtility::DesToTTime( *iDateMod, modTime );
       
  1259             if( err == KErrNone )
       
  1260                 {
       
  1261                 err = iFileReceived->File().SetModified( modTime );
       
  1262                 PRINT1( _L( "MM MTP <> CSendObject::SetFileProperties SetModified err = %d" ), err );
       
  1263                 }
       
  1264             }
       
  1265 
       
  1266         // Close the file after SetFileProperties to make sure other process won't open
  1257         // the file successfully right at the time calling RFile::SetAtt.
  1267         // the file successfully right at the time calling RFile::SetAtt.
  1258         if ( iObjectSize > 0 )
  1268         if ( iObjectSize > 0 )
  1259             {
  1269             {
  1260             delete iFileReceived;
  1270             delete iFileReceived;
  1261             iFileReceived = NULL;
  1271             iFileReceived = NULL;
  1262             }
  1272             }
  1263         else
  1273         else
  1264             iFileReceived->File().Close();
  1274             iFileReceived->File().Close();
  1265         }
  1275         }
  1266 
  1276 
  1267     PRINT( _L( "MM MTP <= CSendObject::SetProtectionStatus" ) );
  1277     PRINT( _L( "MM MTP <= CSendObject::SetFileProperties" ) );
  1268     }
  1278     }
  1269 
  1279 
  1270 // -----------------------------------------------------------------------------
  1280 // -----------------------------------------------------------------------------
  1271 // CSendObject::SaveEmptyFileL
  1281 // CSendObject::SaveEmptyFileL
  1272 // -----------------------------------------------------------------------------
  1282 // -----------------------------------------------------------------------------
  1307 //
  1317 //
  1308 void CSendObject::AddMediaToStoreL()
  1318 void CSendObject::AddMediaToStoreL()
  1309     {
  1319     {
  1310     PRINT( _L( "MM MTP => CSendObject::AddMediaToStoreL" ) );
  1320     PRINT( _L( "MM MTP => CSendObject::AddMediaToStoreL" ) );
  1311 
  1321 
  1312     // SetProtectionStatus here make sure no matter the previous operation is SendObjectInfo
  1322     // SetFileProperties here make sure no matter the previous operation is SendObjectInfo
  1313     // or SendObjectPropList
  1323     // or SendObjectPropList
  1314     // Might need to set dateadded and datemodify for further extension.
  1324     // Might need to set dateadded for further extension.
  1315     SetProtectionStatus();
  1325     SetFileProperties();
  1316 
  1326 
  1317     PRINT1( _L( "MM MTP <> CSendObject::AddMediaToStoreL iFullPath = %S" ), &iFullPath );
  1327     PRINT1( _L( "MM MTP <> CSendObject::AddMediaToStoreL iFullPath = %S" ), &iFullPath );
  1318     iDpConfig.GetWrapperL().AddObjectL( *iReceivedObjectInfo );
  1328     iDpConfig.GetWrapperL().AddObjectL( *iReceivedObjectInfo );
  1319 
  1329 
  1320     iDpConfig.GetWrapperL().SetImageObjPropL( *iReceivedObjectInfo, iWidth, iHeight );
  1330     iDpConfig.GetWrapperL().SetImageObjPropL( *iReceivedObjectInfo, iWidth, iHeight );