void QMDEGalleryQueryResultSet::HandleQueryNewResults( CMdEQuery &aQuery, TInt firstNewItemIndex, TInt newItemCount ) { if (m_launchUpdateQuery) { if (aQuery.ResultMode() == EQueryResultModeItem) { int max = aQuery.Count(); for ( TInt i = firstNewItemIndex; i < max; i++ ) { CMdEObject *item = static_cast<CMdEObject *>(aQuery.TakeOwnershipOfResult( i )); m_updatedItemArray.Append( item ); m_updatedObjectIDs.Append( item->Id() ); } } } else { if (aQuery.ResultMode() == EQueryResultModeItem) { int max = aQuery.Count(); for ( TInt i = firstNewItemIndex; i < max; i++ ) { CMdEObject *item = static_cast<CMdEObject *>(aQuery.TakeOwnershipOfResult( i )); m_itemArray.Append( item ); m_currentObjectIDs.Append( item->Id() ); } } //Signals that items have been inserted into a result set at emit itemsInserted(firstNewItemIndex, newItemCount); emit progressChanged(aQuery.Count(), KMdEQueryDefaultMaxCount); } }
// --------------------------------------------------------------------------- // CHarvesterMessagePluginAO::RemoveObjectL // --------------------------------------------------------------------------- // void CMessageMonitorPlugin::RemoveObjectL( const TDesC& aUri ) { WRITELOG( "CMessageMonitorPlugin::RemoveObjectL enter" ); CMdEObject* mdeObject = iMdeSession->GetObjectL( aUri ); // check if in mde if ( mdeObject ) { TItemId objectId = mdeObject->Id(); delete mdeObject; mdeObject = NULL; TTime time( 0 ); CMdENamespaceDef& nsDef = iMdeSession->GetDefaultNamespaceDefL(); CMdEEventDef& eventDef = nsDef.GetEventDefL( MdeConstants::Events::KDeleted ); iMdeSession->RemoveObjectL( aUri, &nsDef ); WRITELOG1( "aUri: %S", &aUri ); time.UniversalTime(); CMdEEvent* event = iMdeSession->NewEventL( eventDef, objectId, time,NULL,NULL ); iMdeSession->AddEventL( *event ); delete event; event = NULL; } WRITELOG( "CMessageMonitorPlugin::RemoveObjectL return" ); }
void MsgAudioSelectionEngine::HandleQueryCompletedL(CMdEQuery& aQuery, TInt aError) { iNameList.clear(); iUriList.clear(); if (aError == KErrCancel) { emit queryError(aError); return; } else { QMap<QString,QString> nameUriList; CMdEObjectQuery* query = static_cast<CMdEObjectQuery*> (&aQuery); TInt count = query->Count(); for (TInt i = 0; i < count; ++i) { CMdEObject* object = (CMdEObject*) query->TakeOwnershipOfResult(i); CleanupStack::PushL(object); CMdEPropertyDef& propDef = MsgAudioSelectionEngine::PropertyDefL( iSession, MsgAudioSelectionEngine::EAttrFileName); CMdEProperty* property = 0; TInt err = object->Property(propDef, property, 0); if (err != KErrNotFound && property) { QString songName(XQConversions::s60DescToQString( property->TextValueL())); QString uriValue(XQConversions::s60DescToQString( object->Uri())); //insert into the map nameUriList.insertMulti(uriValue, songName); } CleanupStack::PopAndDestroy(object); } //now get all the song names and sort them iNameList = nameUriList.values(); iNameList.sort(); // go through the song list and get the associated uri // insert into the uri list int nameListTotal = iNameList.count(); for(int nameListCount = 0; nameListCount<nameListTotal; nameListCount++) { QString key = nameUriList.key(iNameList.at(nameListCount)); iUriList.append(key); nameUriList.remove(key); } // emit the list to the model emit queryComplete(iNameList, iUriList); } }
// ----------------------------------------------------------------------------- // CContextEnginePluginTest::MultipleSnapshots // ----------------------------------------------------------------------------- // TInt CContextEnginePluginTest::MultipleSnapshotsL( CStifItemParser& aItem ) { _LIT( KMsg1, "Enter MultipleSnapshots" ); iLog->Log( KMsg1 ); RDebug::Print( KMsg1 ); iSnapshotTarget = 3; TInt count = iIds.Count(); CMdEObject* mdeObject; iObjectArray.Reset(); // choose if plugin tested, otherwise engine TPtrC testPlugin; TBool plugin = EFalse; User::LeaveIfError( aItem.GetNextString( testPlugin )); _LIT( pluginString, "plugin" ); if( testPlugin == pluginString ) { plugin = ETrue; } // multiple objects for ( TInt i = 0; i < count; ++i ) { iHD = NULL; mdeObject = NULL; mdeObject = iMdEClient->GetObjectL( iIds[i] ); HBufC* uriBuf = mdeObject->Uri().AllocLC(); iHD = CHarvesterData::NewL( uriBuf ); iHD->SetMdeObject( mdeObject ); CleanupStack::Pop( uriBuf ); iObjectArray.Append( iHD ); } // snapshots if( plugin ) { iPlugin->ContextSnapshot( *this, iObjectArray ); } else { iContextEngine->ContextSnapshot( *this, iObjectArray ); } _LIT( KMsg2, "Exit MultipleSnapshots" ); iLog->Log( KMsg2 ); RDebug::Print( KMsg2 ); return KErrNone; }
// ----------------------------------------------------------------------------- // CContextEnginePluginTest::CreateObjects // ----------------------------------------------------------------------------- // TInt CContextEnginePluginTest::CreateObjectsL( CStifItemParser& aItem ) { CMdENamespaceDef& defaultNamespace = iMdEClient->GetDefaultNamespaceDefL(); CMdEObjectDef& imageDef = defaultNamespace.GetObjectDefL( MdeConstants::Image::KImageObject ); // Mandatory parameters for any object. CMdEPropertyDef& creationDef = imageDef.GetPropertyDefL( MdeConstants::Object::KCreationDateProperty ); CMdEPropertyDef& modifiedDef = imageDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ); CMdEPropertyDef& sizeDef = imageDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty ); CMdEPropertyDef& itemTypeDef = imageDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty ); CMdEPropertyDef& descriptionPropertyDef = imageDef.GetPropertyDefL( MdeConstants::MediaObject::KDescriptionProperty ); CMdEPropertyDef& widthDef = imageDef.GetPropertyDefL( MdeConstants::MediaObject::KWidthProperty ); CMdEPropertyDef& heightDef = imageDef.GetPropertyDefL( MdeConstants::MediaObject::KHeightProperty ); CMdEPropertyDef& makeDef = imageDef.GetPropertyDefL( MdeConstants::Image::KMakeProperty ); CMdEPropertyDef& modelDef = imageDef.GetPropertyDefL( MdeConstants::Image::KModelProperty ); CMdEObject* object = NULL; TItemId objectId(0); TTime currTime; TPtrC inputFile; TInt count(0); TBuf <100> msg; iIds.Reset(); User::LeaveIfError( aItem.GetNextInt( count )); for ( TInt i = 0; i < count; ++i ) { User::LeaveIfError( aItem.GetNextString( inputFile )); // create object iMdEClient->RemoveObjectL(inputFile); object = iMdEClient->NewObjectLC(imageDef, inputFile); currTime.HomeTime(); object->AddTimePropertyL(creationDef, currTime); object->AddTimePropertyL(modifiedDef, currTime); object->AddUint32PropertyL( sizeDef, 0 ); object->AddTextPropertyL( itemTypeDef, MdeConstants::Image::KImageObject ); objectId = iMdEClient->AddObjectL(*object); iIds.Append(objectId); CleanupStack::PopAndDestroy(object); object = NULL; // open object for modification TRAPD( openError, object = iMdEClient->OpenObjectL(objectId) ); if ( !object || openError != KErrNone ) { _LIT( KOpenErr, " ModifyObjects - Open error : %d" ); msg.Format(KOpenErr, openError); iLog->Log( msg ); RDebug::Print(msg); User::LeaveIfError(openError); } CleanupStack::PushL( object ); // add properties CMdEProperty* property = NULL; // Description _LIT( KDesc, "Description" ); object->Property( descriptionPropertyDef, property ); if ( property ) { property->SetTextValueL( KDesc ); } else { object->AddTextPropertyL( descriptionPropertyDef, KDesc ); } property = NULL; // Width object->Property( widthDef, property ); if ( property ) { property->SetUint16ValueL( 100 ); } else { object->AddUint16PropertyL( widthDef, 100 ); } property = NULL; // Height object->Property( heightDef, property ); if ( property ) { property->SetUint16ValueL( 100 ); } else { object->AddUint16PropertyL( heightDef, 100 ); } property = NULL; // Maker object->Property( makeDef, property ); _LIT( KOnkia, "Maker" ); if ( property ) { property->SetTextValueL( KOnkia ); } else { object->AddTextPropertyL( makeDef, KOnkia ); } property = NULL; // Model object->Property( modelDef, property ); _LIT( KModel, "Model" ); if ( property ) { property->SetTextValueL( KModel ); } else { object->AddTextPropertyL( modelDef, KModel ); } // Commit object TRAPD( commitError, iMdEClient->CommitObjectL(*object) ); if ( commitError != KErrNone ) { _LIT( KCommErr, " CreateObjects - Commit error : %d" ); msg.Format(KCommErr, commitError); iLog->Log( msg ); RDebug::Print(msg); User::LeaveIfError(commitError); } CleanupStack::PopAndDestroy(object); object = NULL; } _LIT( KMsg, "Exit EndCreateObjects" ); iLog->Log( KMsg ); RDebug::Print( KMsg ); return KErrNone; }