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::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; }