/**
   @SYMTestCaseID		APPFWK-APPARC-0036

   @SYMPREQ			    Policing server apis

   @SYMTestCaseDesc 	Testing whether untrusted applications are able to override MIME types mapping

   @SYMTestPriority 	High

   @SYMTestStatus 		Implemented

   @SYMTestActions      To connect to RApaLsSession and try to register trusted and untrusted apps for mime types.
   @SYMTestExpectedResults Test should complete without any panic.

 */
void CT_DataTypeMappingWithSid1::ExecuteL(RApaLsSession& aLs)
{
    TInt ret;
    TBool added=EFalse;
    _LIT8(KLitAudioFake, "audio/fakedata");

    TDataType dataType( KLitAudioFake );

    TUid trustedAppUid = {0x10207f8f};
    TUid untrustedAppUid = {0xA3010010};
    TUid retAppUid( KNullUid );

    ret=aLs.InsertDataMapping(dataType, KDataTypePriorityHigh, trustedAppUid);
    INFO_PRINTF1(_L("Trusted app sets a MimeType mapping: InsertDataMapping with PriorityHigh"));
    INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    ret = aLs.AppForDataType(dataType,retAppUid);
    INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid);
    TEST(retAppUid == trustedAppUid);

    ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh, untrustedAppUid, added);
    INFO_PRINTF1(_L("UnTrusted app sets a MimeType mapping: InsertDataMapping with PriorityTrustedHigh"));
    INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    ret = aLs.AppForDataType(dataType,retAppUid);
    INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), untrustedAppUid, retAppUid);
    TEST(retAppUid == untrustedAppUid);

    ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh, trustedAppUid, added);
    INFO_PRINTF1(_L("Trusted app sets a MimeType mapping: InsertDataMapping with PriorityTrustedHigh"));
    INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    ret = aLs.AppForDataType(dataType,retAppUid);
    INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid);
    TEST(retAppUid == trustedAppUid);

    ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh+1, untrustedAppUid, added);
    INFO_PRINTF1(_L("UnTrusted app sets a MimeType mapping: InsertDataMapping with KDataTypePriorityTrustedHigh+1"));
    INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    ret = aLs.AppForDataType(dataType,retAppUid);
    INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid);
    TEST(retAppUid == trustedAppUid);

    //delete data type mapping
    ret=aLs.DeleteDataMapping(dataType);
    INFO_PRINTF3(_L("Deleting data mapping: Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
}
void CDataQuotaView::OpenWebBrowserL(const TDesC& aUrl,
									 const TBool aForceNative)
	{
	// To suppress compiler warnings
	(void)aUrl;
	(void)aForceNative;

#ifdef __OVI_SIGNED__
	RApaLsSession lsSession;
	User::LeaveIfError(lsSession.Connect());
	CleanupClosePushL(lsSession); 

	const TUid KBrowserUid = {0x10008D39};
	TUid handlerUid = KBrowserUid;

	if (!aForceNative)
		{
		// Find the default browser, on S^1/S^3 it may be a 3rd party browser
		_LIT8(KMimeDataType, "application/x-web-browse");
		TDataType mimeDataType(KMimeDataType);
		// Get the default application UID for "application/x-web-browse"
		lsSession.AppForDataType(mimeDataType, handlerUid);
	
		if (handlerUid.iUid == 0)
			{
			// For S60 3.x
			handlerUid = KBrowserUid;
			}
		}
	
	TApaTaskList taskList(CEikonEnv::Static()->WsSession());
	TApaTask task(taskList.FindApp(handlerUid));
	if(task.Exists())
		{
		task.BringToForeground();
		HBufC8* param8(HBufC8::NewLC(aUrl.Length()));
		param8->Des().Append(aUrl);
		task.SendMessage(TUid::Uid(0), *param8); // UID not used
		CleanupStack::PopAndDestroy(param8);
		}
	else
		{
		TThreadId thread;
		User::LeaveIfError(lsSession.StartDocument(aUrl, handlerUid, thread));
		}
	CleanupStack::PopAndDestroy(&lsSession);

#else // !__OVI_SIGNED__

	if (!iBrowserLauncher)
		{
		iBrowserLauncher = CBrowserLauncher::NewL();
		}
	iBrowserLauncher->LaunchBrowserEmbeddedL(aUrl);
#endif // __OVI_SIGNED__
	}
Esempio n. 3
0
//----------------------------
void OpenWebBrowser(C_application_base &app, const char *url){

#ifdef __SYMBIAN_3RD__
   /*
   RApaLsSession ls;
   if(!ls.Connect()){
      bool is_https = false;
      if(text_utils::CheckStringBegin(url, text_utils::HTTPS_PREFIX))
         is_https = true;
      else
         text_utils::CheckStringBegin(url, text_utils::HTTP_PREFIX);
      Cstr_w par;
      par.Format(L"4 %#%") <<(!is_https ? text_utils::HTTP_PREFIX : text_utils::HTTPS_PREFIX) <<url;

      TDataType mimeDatatype(_L8("application/x-web-browse"));
      TUid handlerUID;
      ls.AppForDataType(mimeDatatype, handlerUID);
      //Fatal("id", handlerUID.iUid);
      if(!handlerUID.iUid)
         handlerUID = TUid::Uid(0x1020724d);
      text_utils::CheckStringBegin(url, text_utils::HTTP_PREFIX) ||
         text_utils::CheckStringBegin(url, text_utils::HTTPS_PREFIX);

      LaunchBrowserL(TPtrC((word*)(const wchar*)par, par.Length()), handlerUID);
      ls.Close();
      return;
   }
   */
   RApaLsSession ls;
   if(!ls.Connect()){
      TUid hid;
      ls.AppForDataType(_L8("application/x-web-browse"), hid);
      ls.Close();
      //Fatal("uid", hid.iUid);
      if(hid.iUid){
         if(StartBrowser(hid.iUid, url))
            return;
      }
   }

                              //try 'Web' browser
   if(StartBrowser(0x1020724d, url))
      return;
#endif
                              //use 'Services'
   StartBrowser(0x10008d39, url);
}