void CApaDRMRecognizer::DoRecognizeL( const TDesC& aName, const TDesC8& aBuffer ) { if ( aBuffer.Size() < 3) { return; } #ifdef RECOGNIZE_KEY_CHAIN // Recognize device key chain if ( aName.Length() > 3 && aName.Right(4).CompareF(_L(".dkc")) == 0) { iConfidence = ECertain; iDataType = TDataType( _L8("application/x-device-key-chain") ); return; } #endif #ifdef DRM_OMA2_ENABLED // Recognize ROAP Trigger if ( RecognizeRoapTrigger( aBuffer ) ) { return; } // Recognize DCFv2 if ( RecognizeODF( aBuffer ) ) { return; } #endif // Recognize DCFv1 TUint8 version = aBuffer[0]; TUint8 contentTypeLen = aBuffer[1]; TUint8 contentURILen = aBuffer[2]; if ( contentTypeLen < KMinContentTypeLen || contentURILen == 0 ) { return; } if ( version != KDCFVersionSupported ) { return; } // Too little data received if ( aBuffer.Size() < ( contentTypeLen + KDCFHeaderLength ) ) { return; } TPtrC8 mimeType = aBuffer.Mid( KDCFHeaderLength, contentTypeLen ); if ( mimeType.Locate( '/' ) != KErrNotFound ) { iConfidence = ECertain; iDataType=TDataType( mimeType ); } return; }
/** @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery9 @SYMPREQ 538 @SYMTestCaseDesc Test the functionality of AppForDataTypeAndService in the cases where (a) the datatype is not defined in the registration file (b) the data type is defined in the registration file @SYMTestPriority @SYMTestStatus Implemented @SYMTestActions (a)Call InsertDataMapping to make a mapping between the datatype and app. The parameters used are: the datatype object, the priority assigned and the app uid Call AppForDataTypeAndService with the three parameters: the data type, the service uid and an unitialised uid for the returning value. Call DeleteDataMapping with the datatype object as parameter to delete this mapping (b) Call AppForDataTypeAndService with the three parameters: the data type, the service uid and an unitialised uid for the returning value. on z: drive.\n API Calls:\n RApaLsSession::AppForDataTypeAndService(const TDataType& aDataType, TUid aServiceUid, TUid& aAppUid) const @SYMTestExpectedResults (a) Returns the app uid of the app that has this datatype and service requested. It can be checked that the app uid corresponds to the app to which the mapping has been inserted. (b) Returns the uid of the app that has this datatype and service uid defined in its registration file. */ void CT_ServicesTestStep::TestServiceDiscovery9() { INFO_PRINTF1(_L("TestServiceDiscovery9 about to start...")); const TUid KUidService1234 = {0x01020304}; const TUid KUidServerApp = {0x10004c56}; TInt ret(0); // Start AppForDataTypeAndService test cases // make sure our data mapping is removed before executing the following test cases _LIT8(KLitMimeTypeServerApp,"serverapp/data"); _LIT8(KLitMimeTypeServerAppData,"text/plain"); ret = iApaLsSession.InsertDataMapping(TDataType(KLitMimeTypeServerApp), 1, KUidServerApp, KUidService1234); // need to remove magic number TEST(ret==KErrNone); // Waits till the data type mappings are restored from the data store ini file iApaLsSession.WaitForTypeStoreUpdate(); TUid appUid; ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerApp), KUidService1234,appUid); TEST(ret==KErrNone); // KUidServerApp2 handles KLitMimeTypeJpeg with a higher priority than KUidServerApp, // but doesn't implement service KUidService1234, so KUidServerApp should be returned TEST(appUid == KUidServerApp); ret = iApaLsSession.DeleteDataMapping(TDataType(KLitMimeTypeServerApp),KUidService1234); TEST(ret==KErrNone); // Waits till the data type mappings are restored from the data store ini file iApaLsSession.WaitForTypeStoreUpdate(); ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerAppData), KUidService1234,appUid); TEST(ret==KErrNone); TEST(appUid == KUidServerApp); }
void CTorrentRecognizer::DoRecognizeL(const TDesC &aName, const TDesC8 &/*aBuffer*/) { iConfidence = ECertain; TParse parse; parse.Set(aName, NULL, NULL); TPtrC ext = parse.Ext(); if (ext.CompareF(KTorrentExtension) == 0) { iConfidence = ECertain; iDataType = TDataType(KTorrentType); } else { iConfidence = ENotRecognized; iDataType = TDataType(); } /*TFileName name=aName; name.LowerCase(); if (name.Right(KTorrentExtension().Length()) == KTorrentExtension) { iDataType = TDataType(KTorrentType); return; }*/ }
/** @SYMTestCaseID APPFWK-APPARC-0049 @SYMDEF DEF082982 @SYMTestCaseDesc This test verify that apparc can dynamically install an Ecom recognizer plugin. @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions To avoid using a precompiled recognizer for this test, following workaround is used: 1. The test plugin are copied into z: by the build tools when building apparc tef tests. 2. The plugin will not be installed during startup because CreateRecognizerL will leave 3. During the test a dummy plugin.rsc will be copied into c:\resource\plugins to trig Ecom 4. Apparc will be notified and make sure all recognizers listed by Ecom are properly installed 5. Ecom will not be able install the copied dummy file as it has no matching dll on the same drive, but 6. The recognizer will detect existence of the dummy file and chose not to leave from CreateRecognizerL Due to platsec we can't build plugin.dll to an alternative location and we can't copy files from epoc32\release\winscw\udeb in runtime. Both plugin.rsc and plugin.dll must be on the same drive to be accepted by Ecom. @SYMTestExpectedResults Test should complete without any leave, panic or error. */ void CT_ApsScanStep::TestDynInstallRecognizerL(RApaLsSession& aApparcServer) { INFO_PRINTF1(_L("Step 1 of 4: Verifies that recognizer isn't installed.")); // TESTL will leave and abort this teststep if DoRecognizeL returns ETrue TESTL(EFalse == DoRecognizeL(aApparcServer, TDataType(KDataTypeNew))); INFO_PRINTF1(_L("Step 2 of 4: Installs recognizer plugin file ")); CopyRecognizerFileL(); INFO_PRINTF2(_L("Step 3 of 4: Waits %d seconds for new recognizer to be installed."), KDelay/1000000); User::After(KDelay); INFO_PRINTF1(_L("Step 4 of 4: Verifies that the new recognizer was installed successfully")); TEST(DoRecognizeL(aApparcServer, TDataType(KDataTypeNew))); }
/** @SYMTestCaseID T-RApaLsSessionTestStep-TestStartApp4L @SYMPREQ @SYMTestCaseDesc @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions \n API Calls:\n \n @SYMTestExpectedResults */ void CT_StartAppTestStep::TestStartApp4L() { INFO_PRINTF1(_L("Test RApaLsSession::StartDocument....known data type")); TThreadId startAppThreadID; TInt ret=iApaLsSession.StartDocument(iStartAppTestsFilename, TDataType(KLitMimeType_TRApaLsSessionStartAppTest),startAppThreadID); TEST(ret==KErrNone); //we need to close the started thread, if appropiate if (ret==KErrNone) { RThread thread; User::LeaveIfError(thread.Open(startAppThreadID)); CleanupClosePushL(thread); RProcess process; User::LeaveIfError(thread.Process(process)); CleanupClosePushL(process); process.Kill(0); CleanupStack::PopAndDestroy(&process); CleanupStack::PopAndDestroy(&thread); } INFO_PRINTF1(KCompleted); }
/** @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery19 @SYMPREQ 538 @SYMTestPriority High @SYMTestCaseDesc Test the functionality of AppForDataTypeAndService in the cases where (a) the datatype requested is undefined for a particular service uid (b) the service uid is not defined for any app @SYMTestStatus Implemented @SYMTestActions Call AppForDataTypeAndService with the three parameters: the data type, the service uid and an unitialised uid for the returning value. on z: drive.\n API Calls:\n RApaLsSession::AppForDataTypeAndService(const TDataType& aDataType, TUid aServiceUid, TUid& aAppUid) const @SYMTestExpectedResults In both cases, the app uid value is set to null */ void CT_ServicesTestStep::TestServiceDiscovery19() { INFO_PRINTF1(_L("TestServiceDiscovery19 about to start...")); _LIT8(KLitMimeTypeServerAppData,"text/rubbish"); _LIT8(KLitMimeTypeServerApp,"serverapp/data"); TUid appUid=KNullUid; TInt ret(0); const TUid KUidService = {0x01020304}; const TUid KUidServiceUnused = {0x01020300}; ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerAppData), KUidService,appUid); TEST(ret==KErrNone); TEST(appUid == KNullUid); ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerApp), KUidServiceUnused,appUid); TEST(ret==KErrNone); TEST(appUid == KNullUid); }
void CT_StartAppTestStep::TestDeleteDataTypeL() { INFO_PRINTF1(_L("Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion")); TRequestStatus status; //Register for notification when data type mappings are restored from the data store ini file iApaLsSession.NotifyOnDataMappingChange(status); TInt err=iApaLsSession.DeleteDataMapping(TDataType(KLitPlainText)); INFO_PRINTF2(_L("returned, %d"), err); TSecurityInfo info; info.Set(RProcess()); info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone) : TEST(err==KErrPermissionDenied); if (err==KErrNone) { // Waits till the data type mappings are restored from the data store ini file User::WaitForRequest(status); TEST(status.Int()==KErrNone); } else { iApaLsSession.CancelNotifyOnDataMappingChange(); TEST(status.Int()==KErrCancel); } INFO_PRINTF1(_L("Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion....Done")); }
void CTestMimeRecognizer::DoRecognizeL(const TDesC& /*aName*/, const TDesC8& /*aBuffer*/) { // If an error stops CTestMimeRecognizer being removed as part of test cleanup, // returning ENotRecognized will avoid the possibility of impacting other test code. iDataType=TDataType(); iConfidence=ENotRecognized; }
TDataType CTNonNativeRec::SupportedDataTypeL(TInt aIndex) const { if (aIndex == EMimeTypeNnt1) return TDataType(KLit8_DataType_Gif); else if (aIndex == EMimeTypeNnt2) return TDataType(KLit8_DataType_Html); else if (aIndex == EMimeTypeNnt3) return TDataType(KLit8_DataType_Vcard); else if (aIndex == EMimeTypeNnt4) return TDataType(KLit8_DataType_plainText); else return TDataType(KNullDesC8); }
TDataType CApaDRMRecognizer::SupportedDataTypeL( TInt aIndex ) const #else TDataType CApaDRMRecognizer::SupportedDataTypeL( TInt /*aIndex*/ ) const #endif { __ASSERT_DEBUG( aIndex >= 0 && aIndex < iCountDataTypes, User::Invariant() ); return TDataType( _L8("application/vdn.omd.drm.content") ); // this should never be run }
void CFileExecuter::OpenFileBySystemDefaultL(TFileName aFileName) { #ifndef __SERIES60_3X__ { //如果是Jar、Sis或Sisx文件则调用内容打开 TInt nType=ParseExPathNum(aFileName); if (nType==2) { OpenAppFile(aFileName); return; } } #endif TDataType empty=TDataType(); #ifdef __SERIES60_3X__ { iDocHandler->SetExitObserver(this); TRAPD(error,iDocHandler->OpenFileEmbeddedL(aFileName,empty)); } #else { iDocHandler->OpenFileL(aFileName,empty ); //If the standalone handler is already running then update the //document file TUid handlerUid; TInt err = KErrNone; #ifdef __SERIES60_3X__ err = iDocHandler->HandlerAppUid(handlerUid); #else RApaLsSession apaLs; User::LeaveIfError( apaLs.Connect() ); err = apaLs.AppForDocument(aFileName, handlerUid, empty); apaLs.Close(); #endif if( !err ) { RefreshDocumentFileL(handlerUid, aFileName); } else if( err == KNotInitialized ) { //Handler not initialized } else { //Some other error } } #endif }
void CPodcastModel::LaunchFileEmbeddedL(const TDesC& aFilename) { //Set the exit observer so HandleServerAppExit will be called iDocHandler->SetExitObserver(this); TDataType emptyDataType = TDataType(); //Open a file embedded iDocHandler->OpenFileEmbeddedL(aFilename, emptyDataType); }
/** @SYMTestCaseID T_RApaLsSessionTestStep_TestStartApp5L @SYMPREQ @SYMTestCaseDesc @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions \n API Calls:\n \n @SYMTestExpectedResults */ void CT_StartAppTestStep::TestStartApp5L() { INFO_PRINTF1(_L("Test RApaLsSession::StartDocument....unknown data type")); TThreadId startAppThreadID; TInt ret=iApaLsSession.StartDocument(iStartAppTestsFilename, TDataType(_L8("text/plain/no thanks")),startAppThreadID); TEST(ret==KErrNotFound); INFO_PRINTF1(KCompleted); }
TDataType CTorrentRecognizer::SupportedDataTypeL(TInt aIndex) const { switch (aIndex) { case 0: default: return TDataType(KTorrentType); } }
void CConfigRecognizer::DoRecognizeL(const TDesC & /*aName*/, const TDesC8 &aBuffer) { if ( aBuffer.Length() < KIdLength ) { return; } if ( aBuffer.Left(KIdLength).Compare(KSettingsId) ) { return; } iConfidence = ECertain; iDataType = TDataType(KMIMEType); }
/** @SYMTestCaseID T_RApaLsSessionTestStep_TestAppForDataTypeL @SYMPREQ @SYMTestCaseDesc . @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions \n API Calls:\n @SYMTestExpectedResults */ void CT_StartAppTestStep::TestAppForDataTypeL() { INFO_PRINTF1(_L("Test RApaLsSession::AppForDataType....Check an app binding")); _LIT8(KLitPlainText,"text/plain"); TUid testUid={KTestAppUidValue}; TInt ret=iApaLsSession.AppForDataType(TDataType(KLitPlainText),iStartAppTestsUid); TEST(ret==KErrNone); TEST(iStartAppTestsUid==testUid); INFO_PRINTF1(KCompleted); }
TBool CApaDRMRecognizer::RecognizeRoapTrigger( const TDesC8& aBuffer ) { if ( aBuffer.FindF( KRoapTriggerElement() ) != KErrNotFound || aBuffer.FindF( KRoapTriggerElement2() ) != KErrNotFound ) { iConfidence = ECertain; iDataType=TDataType( KRoapTriggerType() ); return ETrue; } return EFalse; }
/** @SYMTestCaseID APPFWK-APPARC-0010 @SYMPREQ PREQ967 @SYMREQ REQ3889 @SYMTestCaseDesc Tests DeleteDataMapping() which removes the linking of a datatype to the UID of an associated application @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions Call RApaLsSession::DeleteDataMapping() with datatype and service UID API Calls:\n RApaLsSession::DeleteDataMapping(const TDataType& aDataType, TUid aServiceUid) @SYMTestExpectedResults DeleteDataMapping() causes Main Panic KERN-EXEC 0 */ void CSysStartApparcTestCase::TestDeleteDataTypeL() { RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion")); _LIT8(KLitPlainText,"text/plain"); TSecurityInfo info; info.Set(RProcess()); //Main Panic KERN-EXEC 0 iApaLsSession.DeleteDataMapping(TDataType(KLitPlainText)); }
/** @SYMTestCaseID APPFWK-APPARC-0009 @SYMPREQ PREQ967 @SYMREQ REQ3889 @SYMTestCaseDesc Tests AppForDataType() which returns the UID of an application which can handle the specified datatype @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions Call RApaLsSession::InsertDataMapping() with datatype and application UID (and priority) API Calls:\n RApaLsSession::InsertDataMapping(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid) @SYMTestExpectedResults AppForDataType() causes Main Panic KERN-EXEC 0 */ void CSysStartApparcTestCase::TestAppForDataTypeL() { RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::AppForDataType....Check an app binding")); _LIT8(KLitPlainText,"text/plain"); TUid retUid = KNullUid; //Main Panic KERN-EXEC 0 iApaLsSession.AppForDataType(TDataType(KLitPlainText), retUid); }
void CTestUpgradeRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& /*aBuffer*/) { // If an error stops CTestUpgradeRecognizer being removed as part of test cleanup, // returning ENotRecognized will avoid the possibility of impacting other test code. _LIT(KExtension , ".upr"); TParse parse; parse.Set(aName,NULL,NULL); TPtrC ext=parse.Ext(); // extract the extension from the filename if (ext.CompareF(KExtension)==0) { iDataType = TDataType(KMimeUprType); iConfidence = ECertain; } else { iDataType=TDataType(); iConfidence=ENotRecognized; } }
// --------------------------------------------------------------------------- // CThumbnailAudioProvider::GetThumbnailL() // Provides the thumbnail image // --------------------------------------------------------------------------- // void CThumbnailAudioProvider::GetThumbnailL( RFs& aFs, RFile64& aFile, const TDataType& aMimeType , const CThumbnailManager::TThumbnailFlags aFlags, const TDisplayMode /*aDisplayMode*/, const CThumbnailManager::TThumbnailQualityPreference /*aQualityPreference*/ ) { TN_DEBUG1( "CThumbnailAudioProvider::GetThumbnailL() - rfile " ); OstTrace0( TRACE_NORMAL, CTHUMBNAILAUDIOPROVIDER_GETTHUMBNAILL, "CThumbnailAudioProvider::GetThumbnailL - rfile" ); CMetaDataUtility* metaDataUtil = CMetaDataUtility::NewL(); CleanupStack::PushL( metaDataUtil ); RArray<TMetaDataFieldId> wantedFields; CleanupClosePushL(wantedFields); wantedFields.AppendL(EMetaDataJpeg); metaDataUtil->OpenFileL(aFile, wantedFields, aMimeType.Des8()); const CMetaDataFieldContainer& metaCont = metaDataUtil->MetaDataFieldsL(); TPtrC8 ptr = metaCont.Field8( EMetaDataJpeg ); HBufC8* data = ptr.AllocL(); CleanupStack::PopAndDestroy(&wantedFields); CleanupStack::PopAndDestroy(metaDataUtil); CleanupStack::PushL( data ); if(data->Length() == 0) { User::Leave( KErrNotFound ); } if ( !iImageDecoderv3 ) { iImageDecoderv3 = new( ELeave )CThumbnailImageDecoderv3( aFs ); } iMimeType = TDataType(KJpegMime); iFlags = aFlags; //set default mode displaymode from global constants iDisplayMode = KStoreDisplayMode; TRAPD( err, iImageDecoderv3->CreateL( data, *iObserver, iFlags, iMimeType, iTargetSize ) ); if (err == KErrNone) { CleanupStack::Pop( data ); } else { // this is because data buffer is already released in CreateDecoderL // and we must prevent automatic PopAndDestroy CleanupStack::Pop( data ); User::Leave(err); } iOriginalSize = iImageDecoderv3->OriginalSize(); iImageDecoderv3->DecodeL( iDisplayMode ); }
/** @SYMTestCaseID APPFWK-APPARC-0005 @SYMPREQ PREQ967 @SYMREQ REQ3889 @SYMTestCaseDesc Attempt to launch an application by means of an unknown MIME type @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions Call RApaLsSession::StartDocument() with filename and unknown MIME type. API Calls:\n RApaLsSession::StartDocument(const TDesC& aFileName, const TDataType& aDataType, TThreadId& aThreadId, TLaunchType aLaunchType) @SYMTestExpectedResults StartDocument() causes Main Panic KERN-EXEC 0 */ void CSysStartApparcTestCase::TestStartApp5L() { RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::StartDocument....unknown data type")); // Set filename location TPtrC apparcTestFilename(KLitTRApaLsSessionStartAppTest); // KErrNotFound as a return value TThreadId startAppThreadID; //Main Panic KERN-EXEC 0 iApaLsSession.StartDocument(apparcTestFilename, TDataType(_L8("text/plain/no thanks")), startAppThreadID); }
// --------------------------------------------------------- // RecognizerEx::DoRecognizeL() // Recognizes the file by name and/or head buffer // --------------------------------------------------------- // void CApaRecognizerEx::DoRecognizeL(const TDesC& aName, const TDesC8& /*aBuffer*/) { // To keep code simple, we only check file name extension if (aName.Length()>KRecRtFileExtensionsMightBeValid) { if (aName.Right(KRecRtFileExtensionsMightBeValid).CompareF(KExtension1)==0) { iConfidence=ECertain; // is certainly something totally new iDataType=TDataType(KDataType); return; } } }
TBool CApaDRMRecognizer::RecognizeODF( const TDesC8& aBuffer ) { if ( aBuffer.Size() < 24 ) return EFalse; TPtrC8 ftypPrefix = aBuffer.Mid( 4, KFTypPrefix().Length() ); if ( KFTypPrefix().CompareF( ftypPrefix ) == KErrNone ) { TPtrC8 odfPrefix = aBuffer.Mid( 8, KODFPrefix().Length() ); if ( KODFPrefix().CompareF( odfPrefix ) == KErrNone ) { TBuf8<4> buffer; TUint32 size; TPtr8 ptr(NULL, 0); TUint32 offset(20); // ODRM box header buffer.Zero(); buffer.Copy( aBuffer.Mid( offset, 4 )); size = ReadUint32FromBlock( buffer, 0 ); offset += KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags; if (size == 1) { offset += KLengthBoxSize64; } if ( aBuffer.Size() < offset+4 ) return EFalse; // Discrete headers box header buffer.Zero(); buffer.Copy( aBuffer.Mid( offset, 4 )); size = ReadUint32FromBlock( buffer, 0 ); offset += KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags; if ( size == 1 ) { offset += KLengthBoxSize64; } if ( aBuffer.Size() < offset+1 ) return EFalse; // Content type buffer.Zero(); buffer.Copy( aBuffer.Mid( offset, 1 )); if ( aBuffer.Size() < offset + 1 + buffer[0] ) return EFalse; TPtrC8 mimeType = aBuffer.Mid( offset+1, buffer[0] ); iConfidence = ECertain; iDataType=TDataType( mimeType ); return ETrue; } } return EFalse; }
/** @SYMTestCaseID APPFWK-APPARC-0008 @SYMPREQ PREQ967 @SYMREQ REQ3889 @SYMTestCaseDesc Tests InsertDataMapping() which links a datatype to the UID of an associated application for launching assigns adds a low priority. Tests InsertDataMappingIfHigher() which remaps the datatype to the specified UID if the specified priority is higher. The "added" parameter indicates if the mapping was successful. @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions Call RApaLsSession::InsertDataMapping() with datatype, application UID and low priority API Calls:\n RApaLsSession::InsertDataMapping(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid) @SYMTestExpectedResults InsertDataMapping() causes Main Panic KERN-EXEC 0 */ void CSysStartApparcTestCase::TestInsertDataTypeL() { RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::InsertDataMapping....Check data type mapping addition")); const TDataTypePriority KPriLow = 1; _LIT8(KLitPlainText,"text/plain"); TSecurityInfo info; info.Set(RProcess()); //Main Panic KERN-EXEC 0 iApaLsSession.InsertDataMapping(TDataType(KLitPlainText), KPriLow, KUidTestApp); }
/** @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery23 @SYMPREQ 538 @SYMTestPriority High @SYMTestStatus Implemented @SYMTestCaseDesc Test the functionality ofAppForDocumentAndService given an existing file name and undefined service uid @SYMTestActions Call AppForDocumentAndService with two parameters: a filename, a service uid, an app uid and the datatype requested on z: drive.\n API Calls:\n RApaLsSession::AppForDocumentAndService(const TDesC& aFileName, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType) const @SYMTestExpectedResults Returns KErrNone.The value returned for appuid is null.The datatype is set to the one that can desribe the datatype in the document */ void CT_ServicesTestStep::TestServiceDiscovery23() { // AppForDocumentAndService test cases INFO_PRINTF1(_L("TestServiceDiscovery23 about to start...")); TInt ret(0); TUid appUid=KNullUid; const TUid KUidService = {0x01120304}; TDataType dataType; _LIT8(KLitMimeTypeServerData,"text/plain"); ret = iApaLsSession.AppForDocumentAndService(_L("z:\\system\\data\\one_byte.txt"), KUidService, appUid, dataType); TEST(ret==KErrNone); TEST(appUid==KNullUid); TEST(dataType==TDataType(KLitMimeTypeServerData)); }
/** @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery6 @SYMPREQ 538 @SYMTestCaseDesc Test for the functionality AppForDataTypeAndService in the case where two apps provides have the same datatype definition in their registration file. One app offers the requested service but has its priority assigned to normal while the other app does not offer the requested service and has its priority assigned to high @SYMTestPriority @SYMTestStatus Implemented @SYMTestActions Call AppForDataTypeAndService with three parameters: the datatype, the service uid and an unitialised app uid on z: drive.\n API Calls:\n RApaLsSession::AppForDataTypeAndService(const TDataType& aDataType, TUid aServiceUid, TUid& aAppUid) const @SYMTestExpectedResults Sets the app uid to that of the app with lower priority since the one with higher priority does not offer this service */ void CT_ServicesTestStep::TestServiceDiscovery6() { INFO_PRINTF1(_L("TestServiceDiscovery6 about to start...")); const TUid KUidServerAppHigh = {0x10004c57}; const TUid KUidService = {0x02030405}; const TUid KUidServerAppNormal = {0x10004c56}; _LIT8(KLitMimeTypeServerAppData,"text/priority"); TUid appUid; TInt ret(0); ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerAppData), KUidService,appUid); TEST(ret==KErrNone); TEST(appUid != KUidServerAppHigh); TEST(appUid == KUidServerAppNormal); }
/** * @SYMTestCaseID T_ServicesTestStep_TestPrioritySystemL * * @SYMPREQ * * @SYMTestCaseDesc Checks that the system priority for data handlers requires * WriteDeviceData capability * * @SYMTestPriority High * * @SYMTestStatus Implemented * * @SYMTestActions \n * API Calls:\n * * @SYMTestExpectedResults * */ void CT_ServicesTestStep::TestPrioritySystemL() { INFO_PRINTF1(_L("TestPrioritySystemL about to start...")); // App 0x10207f7b has system priority and WriteDeviceData so it should // be returned and not 0x10207f7f which has only high priority const TUid KUidService1 = {0x10207f7d}; TUid appUid=KNullUid; const TUid TUidExpected1 = {0x10207f7b}; _LIT8(KLitMimeTypeServerData,"text/custom1"); TInt ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerData), KUidService1,appUid); TEST(ret==KErrNone); TEST(appUid == TUidExpected1); // App 0x10207f7e has system priority but not WriteDeviceData so it should // be 0x10207f7f that is returned that has high priority const TUid KUidService2 = {0x10207f7e}; const TUid TUidExpected2 = {0x10207f7f}; ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerData), KUidService2,appUid); TEST(ret==KErrNone); TEST(appUid == TUidExpected2); // System priority handler take precedence over user mappings const TUid KUidServerApp = {0x10004c56}; ret = iApaLsSession.InsertDataMapping(TDataType(KLitMimeTypeServerData), 1, KUidServerApp, KUidService1); TEST(ret==KErrNone); // Waits till the data type mappings are restored from the data store ini file iApaLsSession.WaitForTypeStoreUpdate(); ret = iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerData), KUidService1,appUid); TEST(ret==KErrNone); TEST(appUid == TUidExpected1); ret = iApaLsSession.DeleteDataMapping(TDataType(KLitMimeTypeServerData),KUidService1); TEST(ret==KErrNone); // Waits till the data type mappings are restored from the data store ini file iApaLsSession.WaitForTypeStoreUpdate(); }
/* Attempts to recognize the data type, given the filename and data buffer. */ void CExampleNewRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer) { _LIT8(KExampleData, "example"); _LIT(KDotExample, ".Example"); TParse parse; parse.Set(aName,NULL,NULL); TPtrC ext=parse.Ext(); // extract the extension from the filename if (ext.CompareF(KDotExample)==0 && aBuffer.FindF(KExampleData)!=KErrNotFound) { iConfidence=ECertain; iDataType=TDataType(KExampleTextMimeType); } }
/** * @SYMTestCaseID T_ServicesTestStep_TestOpenService1 * * @SYMPREQ * * @SYMTestCaseDesc This test checks that the Open service and legacy datatypes * functions return the same results. See defect INC053978 as well. * * @SYMTestPriority High * * @SYMTestStatus Implemented * * @SYMTestActions \n * API Calls:\n * * @SYMTestExpectedResults * */ void CT_ServicesTestStep::TestOpenService1L() { INFO_PRINTF1(_L("TestOpenService1L about to start...")); // First try using the legacy method _LIT8(KLitDummyopen1,"text/dummyopen1"); TUid expectedAppUid1={0x10208200}; TUid uid1; TInt error1 = iApaLsSession.AppForDataType(TDataType(KLitDummyopen1), uid1); TEST(error1==KErrNone); TEST(uid1==expectedAppUid1); // Then try with legacy API but new Open service in reg file _LIT8(KLitDummyopen2,"text/dummyopen2"); TUid expectedAppUid2={0x10208201}; TUid uid2; TInt error2 = iApaLsSession.AppForDataType(TDataType(KLitDummyopen2), uid2); TEST(error2==KErrNone); TEST(uid2==expectedAppUid2); // Try with new API and old registration file format TUid uid3; TInt error3 = iApaLsSession.AppForDataTypeAndService(TDataType(KLitDummyopen1), KOpenServiceUid, uid3); TEST(error3==KErrNone); TEST(uid3==expectedAppUid1); // Try with new API and new registration file format TUid uid4; TInt error4 = iApaLsSession.AppForDataTypeAndService(TDataType(KLitDummyopen2), KOpenServiceUid, uid4); TEST(error4==KErrNone); TEST(uid4==expectedAppUid2); INFO_PRINTF1(KCompleted); }