TInt E32Main()
	{
	test.Title();

	// Turn off evil lazy dll unloading
	RLoader l;
	test(l.Connect()==KErrNone);
	test(l.CancelLazyDllUnload()==KErrNone);
	l.Close();

	test.Start(_L("Preload t_oedll1.dll"));
	RLibrary library;
	test(library.Load(_L("t_oedll1.dll")) == KErrNone);

	test.Next(_L("Run T_OEEXPORT.EXE..."));
	RProcess p;
	TInt r=p.Create(_L("T_OEEXPORT.EXE"), _L("2"));
	test(r==KErrNone);
	TRequestStatus s;
	p.Logon(s);
	p.Resume();
	User::WaitForRequest(s);
	TExitCategoryName aExitCategory = p.ExitCategory();
	test.Printf(_L("Second test exits with: %d,%d,%S\n"),p.ExitType(),p.ExitReason(),&aExitCategory);
	test(p.ExitType()==EExitKill);
	test(p.ExitReason()==0);
	p.Close();

	library.Close();

	test.End();
	return KErrNone;
	}
    void init()
    {
        _LIT(KLibName_3_1, "qts60plugin_3_1" QT_LIBINFIX_UNICODE L".dll");
        _LIT(KLibName_3_2, "qts60plugin_3_2" QT_LIBINFIX_UNICODE L".dll");
        _LIT(KLibName_5_0, "qts60plugin_5_0" QT_LIBINFIX_UNICODE L".dll");

        TPtrC libName;
        TInt uidValue;
        switch (QSysInfo::s60Version()) {
        case QSysInfo::SV_S60_3_1:
            libName.Set(KLibName_3_1);
            uidValue = 0x2001E620;
            break;
        case QSysInfo::SV_S60_3_2:
            libName.Set(KLibName_3_2);
            uidValue = 0x2001E621;
            break;
        case QSysInfo::SV_S60_5_0: // Fall through to default
        default:
            // Default to 5.0 version, as any unknown platform is likely to be newer than that
            libName.Set(KLibName_5_0);
            uidValue = 0x2001E622;
            break;
        }

        TUidType libUid(KDynamicLibraryUid, KSharedLibraryUid, TUid::Uid(uidValue));
        lib.Load(libName, libUid);

        // Duplicate lib handle to enable process wide access to it. Since Duplicate overwrites
        // existing handle without closing it, store original for subsequent closing.
        RLibrary origHandleCloser = lib;
        lib.Duplicate(RThread(), EOwnerProcess);
        origHandleCloser.Close();
    }
/**
 * Executable Entry Point
 * Top level always creates TRAP harness.
 * Calls MainL() inside the TRAP harness
 */
GLDEF_C TInt E32Main()
	{
	__UHEAP_MARK;
	CTrapCleanup* cleanup = CTrapCleanup::New();
	if(cleanup == NULL)
		{
		return KErrNoMemory;
		}

  // Fix PDEF124952, set the priority EPriorityAbsoluteHigh. In this case, the timeout will 
  // take effect even if the server executes with almost 100% CPU usage.
  RThread().SetPriority(EPriorityAbsoluteHigh);
  // End PDEF124952
  
	// Check to see if the plugin wrapper around the GetSystemDrive is loadable
	// If yes, then instantiate the wrapper object and obtain the default system drive
	// Else, use the hardcoded default drive as c:
	TDriveName defaultSysDrive(KTEFLegacySysDrive);	
	
	RLibrary pluginLibrary;
	CWrapperUtilsPlugin* plugin = TEFUtils::WrapperPluginNew(pluginLibrary);
	
	if (plugin!=NULL)
		{
		TDriveUnit driveUnit(plugin->GetSystemDrive());
		defaultSysDrive.Copy(driveUnit.Name());
		delete plugin;
		pluginLibrary.Close();
		}
	
	TBool enableSysStart = ETrue;
	CTestExecuteIniData* iniData = NULL;
	TRAPD(err, iniData = CTestExecuteIniData::NewL(defaultSysDrive));
	if (err == KErrNone)
		{
		// Extract all the key values within the object
		iniData->ExtractValuesFromIni();
		iniData->GetKeyValueFromIni(KTEFSystemStarter, enableSysStart);
		}

	err = KErrNone;
	#if !(defined TEF_LITE)
	if (enableSysStart)
		{
		TRAP(err, StartSystemL());
		__ASSERT_ALWAYS(!err, User::Panic(KTestExecuteName,err));
		}
	#endif
	if (iniData != NULL)
		{
		delete iniData;
		}	
	
	err = KErrNone;
	TRAP(err,MainL(defaultSysDrive));
	__ASSERT_ALWAYS(!err, User::Panic(KTestExecuteName,err));
	delete cleanup;
	__UHEAP_MARKEND;
	return KErrNone;
    }
Exemple #4
0
/**
@SYMTestCaseID          SYSLIB-FATCHARSETCONV-CT-1847-0002
@SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class as part of INC090073
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for correct character conversion on certain chinese characters for CP936
@SYMTestExpectedResults Test must not fail
*/
void CT_CP949::TestINC090073L()
	{
    INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847-0002 "));
 	_LIT16(unicode, "\x715C\x7A37\x61A9\x80B1\x86A3\x6B46\x6615");
	_LIT8(CP932Code, "\xE9\xF2\xF2\xC3\xCC\xA8\xCE\xDD\xCD\xF7\xFD\xE4\xFD\xDA");

	RLibrary lib;

	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
	// load the dll
	TInt returnValue = lib.Load(KName,serverUid);
	test(returnValue==0);

	// get a pointer to the specified ordinal function and call it
	TLibraryFunction function1 = lib.Lookup(1);


	//cast the function pointer f to a function of type void with two arguments
	typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);
	TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1);

	TBuf8<15> foreign1;

	foreign1.Zero();
	const TDesC16& unicode1(unicode);
	TRAPD(err,(*aConvertFromUnicodeL)(foreign1, unicode1)); 	//testing conversion from Unicode
	test(err==0);
	TInt error = foreign1.Compare(CP932Code);
	test(error==0);
	foreign1.Zero();

	lib.Close();
	}
enum TVerdict CTestIdna08::doTestStepL()
	{

	INFO_PRINTF1(_L(" Testing the Loading of the new Library "));
	INFO_PRINTF1(_L("****************************************"));
	
	SetTestStepResult(EFail); // By default start the test case with failure.	
	
	RLibrary testLibrary;
	TInt err = testLibrary.Load(_L("punycodeconverter.dll"));
	
	if(err == KErrNone)
		{
		INFO_PRINTF1(_L(" Loading the punycodeconverter library is successful"));
		SetTestStepResult(EPass);
		}
	else 
		{	
		INFO_PRINTF1(_L(" Loading the punycodeconverter library is NOT successful"));
		User::LeaveIfError(KErrNone);  // just to suppress the LeaveScan warning
		}
	
	INFO_PRINTF1(_L("Negative Testing of SetOpt		 "));
	INFO_PRINTF1(_L("****************************************"));		

	RSocketServ pSocketServ;
	User::LeaveIfError(pSocketServ.Connect());
	RConnection myConnection;
	myConnection.Open(pSocketServ, KAfInet);

	TRequestStatus myStatus=KErrNone;
	myConnection.Start(myStatus);
	User::WaitForRequest(myStatus);

	RHostResolver hr;
	hr.Open(pSocketServ,KAfInet,KProtocolInetUdp);
	
	TBool enableIdn = ETrue;//enabling the option of IDN support
	TPckgC<TBool> pckgEnable(enableIdn);
	TInt setOptErr = hr.SetOpt(KSoInetConfigInterface , KSolInetDns , pckgEnable);
	if(setOptErr != KErrNone)
		{
		INFO_PRINTF1(_L(" Negative Testing of the Setopt successful "));
		SetTestStepResult(EPass);
		}
	
	setOptErr = hr.SetOpt(KSoDnsEnableIdn , KSolInetDns , pckgEnable);
	User::LeaveIfError(setOptErr);

	enableIdn = EFalse;
	TPckgC<TBool> pckgDisable(enableIdn);
	setOptErr = hr.SetOpt(KSoDnsEnableIdn , KSolInetDns , pckgDisable);
	User::LeaveIfError(setOptErr);
	
	hr.Close();
	myConnection.Close();
	pSocketServ.Close();
	return TestStepResult();

	}
TInt ChildThread(TAny* aArg)
	{
	TInt testType = (TInt)aArg;
	RThread mainThread;
	TInt r = mainThread.Open(MainThreadId);
	if (r != KErrNone)
		return r;
	// Open handle on dynamic DLL in this thread
	RLibrary library;
	test_KErrNone(library.Load(KDynamicDll));
	RThread().Rendezvous(KErrNone);
	TRequestStatus status;
	mainThread.Logon(status);
	User::WaitForRequest(status);
	if (mainThread.ExitType() != EExitKill)
		return KErrGeneral;
	if (mainThread.ExitReason() != KErrNone)
		return mainThread.ExitReason();
	mainThread.Close();
	if (testType != ETestRecursive)
		{
		RMsgQueue<TMessage> messageQueue;
		r = messageQueue.OpenGlobal(KMessageQueueName);
		if (r != KErrNone)
			return r;
		r = messageQueue.Send(EMessagePreDestruct);
		if (r != KErrNone)
			return r;
		}
	return testType;
	}
/**
Performs unit test. 

@param aSeverity The current logging severity level.
@param aSuitDLL The test suite DLL which contains the unit test.
@param aIniFile The ini file name.
*/
LOCAL_C void doUnitTestL(TInt aSeverity, const TFileName& aSuitDLL,const TFileName& aIniFile)
{	
	// check the dll can be found before trying to load
    RLibrary lib;
	TInt err = lib.Load(aSuitDLL, KTxtDLLpath);
    if (err == KErrNone)
        {
        lib.Close();
        }
	    
	if ( err==KErrNotFound ) 
	{	
		// this is not going to load !
 		//pLogSystem->Log(_L("Test suite %S could not be found"), &aSuitDLL );
		//return;
	}

	// create a new suitedll object to store info on loaded DLL
	CSuiteDll * newRef = CSuiteDll::NewL( aSuitDLL );

	// set severity level and logging system
	newRef->iTestSuite->SetSeverity(aSeverity);
	newRef->iTestSuite->SetLogSystem(pLogSystem);

	// do unit test
	newRef->iTestSuite->DoTestUnit(const_cast<TFileName&>(aIniFile));

	delete newRef;
}
TDriveNumber CFileServPlugin::GetSystemDrive()
	{
	TDriveNumber defaultSysDrive(EDriveC);
	RFs fileServer;
	TVersionName version(fileServer.Version().Name());
	if (fileServer.Version().iMajor >= 2 &&
		fileServer.Version().iBuild >= 1100)
		{
		_LIT(KFileSrvDll, "efsrv.dll");

		RLibrary pluginLibrary;
		TInt pluginErr = pluginLibrary.Load(KFileSrvDll);

		if (pluginErr == KErrNone)
			{
			typedef TDriveNumber(*fun1)();
			fun1 sysdrive;

	#ifdef __EABI__
			sysdrive = (fun1)pluginLibrary.Lookup(336);
	#else
			sysdrive = (fun1)pluginLibrary.Lookup(304);
	#endif
			defaultSysDrive = sysdrive();
			}
		pluginLibrary.Close();
		}
	
	return defaultSysDrive;
	}
// ----------------------------------------------------------------------------
// CSamplerPluginLoader::LoadRlibraryL
// ----------------------------------------------------------------------------
//
void CSamplerPluginLoader::LoadRlibraryL(CArrayPtrFlat<CSamplerPluginInterface>* aPluginArray)
    {
    LOGSTRING("CSamplerPluginLoader rlibrary loading");
                // Load dll
    iPluginArray = aPluginArray;
    RLibrary aLib;
    TInt ret = aLib.Load(_L("PIProfilerGenerals.dll"),_L("c:\\sys\\bin"));

    LOGSTRING2("RLibrary load returns %d", ret);
    User::LeaveIfError(ret);
    const TInt KNewLOrdinal = 2;
    TLibraryFunction NewL =aLib.Lookup(KNewLOrdinal);

    if(!NewL)
        {
        RDebug::Printf("library.lookup returns null");    
        }
    else
        {
        LOGSTRING2("library.lookup returns 0x%x", NewL);
        //CGeneralsPlugin* mydll=(CGeneralsPlugin*)NewL();
        CSamplerPluginInterface* mydll=(CSamplerPluginInterface*)NewL();
        //Generals plugin loaded, samplers enabled.
        CleanupStack::PushL( mydll );
        //InsertPluginInOrderL( mydll, aPluginArray);
        CleanupStack::Pop(mydll);
        // call engine to finalize the startup
        //TRAPD(result, iObserver->HandleSamplerControllerReadyL(););
        NotifyProgress();

        //Begin CActive asynchronous loop.
        CompleteOwnRequest();
        }
    LOGSTRING("RLibrary and plugins loaded");
    }
TInt LoopThread(TAny*)
	{
	// Open handle on dynamic DLL in this thread
	RLibrary library;
	test_KErrNone(library.Load(KDynamicDll));
	for (;;)
		;
	}
static TInt StartServer()
//
// Start the server process or thread
//
	{
	const TUidType serverUid(KNullUid,KNullUid,KServerUid3);

#ifdef __CDLSERVER_NO_PROCESSES__
	//
	// In EKA1 WINS the server is a DLL, the exported entrypoint returns a TInt
	// which represents the real entry-point for the server thread
	//
	RLibrary lib;
	TInt r=lib.Load(KCdlServerDllImg,serverUid);
	if (r!=KErrNone)
		return r;
	TLibraryFunction ordinal1=lib.Lookup(1);
	TThreadFunction serverFunc=reinterpret_cast<TThreadFunction>(ordinal1());
	//
	// To deal with the unique thread (+semaphore!) naming in EPOC, and that we may
	// be trying to restart a server that has just exited we attempt to create a
	// unique thread name for the server.
	// This uses Math::Random() to generate a 32-bit random number for the name
	//
	TName name(KCdlServerName);
	name.AppendNum(Math::Random(),EHex);
	RThread server;
	r=server.Create(name,serverFunc,
					KCdlServerStackSize,
					NULL,&lib,NULL,
					KCdlServerInitHeapSize,KCdlServerMaxHeapSize,EOwnerProcess);
	lib.Close();	// if successful, server thread has handle to library now
#else
	//
	// EPOC and EKA2 is easy, we just create a new server process. Simultaneous launching
	// of two such processes should be detected when the second one attempts to
	// create the server object, failing with KErrAlreadyExists.
	//
	RProcess server;
	TInt r=server.Create(KCdlServerExeImg,KNullDesC,serverUid);
#endif
	if (r!=KErrNone)
		return r;
	TRequestStatus stat;
	server.Rendezvous(stat);
	if (stat!=KRequestPending)
		server.Kill(0);		// abort startup
	else
		server.Resume();	// logon OK - start the server
	User::WaitForRequest(stat);		// wait for start or death
	// we can't use the 'exit reason' if the server panicked as this
	// is the panic 'reason' and may be '0' which cannot be distinguished
	// from KErrNone
	r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
	server.Close();
	return r;
	}
void CryptoSpiUtil::LoadPluginDllLC(RLibrary& aLib, TFileName& aFileName)
	{
	User::LeaveIfError(aLib.Load(aFileName));
	CleanupClosePushL(aLib);
	RLibrary plugin=aLib;
	CleanupClosePushL(plugin);
	User::LeaveIfError(aLib.Duplicate(RThread(), EOwnerProcess));
	CleanupStack::PopAndDestroy(&plugin);		
	}
REmbed::REmbed(const bool verbose, const bool interactive) : verbose(verbose), interactive(interactive)
{
    loaded = false;

    // need to load the library
    RLibrary rlib;
    if (!rlib.load()) {

        // disable for future
        appsettings->setValue(GC_EMBED_R, false);
        rlib.errors.append("\nR has now been disabled in options.");

        QMessageBox msg(QMessageBox::Information,
                    "Failed to load R library",
                    rlib.errors.join("\n"));
        msg.exec();
        return;
    }

    // we need to tell embedded R where to work
    QString envR_HOME(getenv("R_HOME"));
    QString configR_HOME = appsettings->value(NULL,GC_R_HOME,"").toString();
    if (envR_HOME == "") {
        if (configR_HOME == "") {
            qDebug()<<"R HOME not set, R disabled";
            return;
        } else {
            setenv("R_HOME", configR_HOME.toLatin1().constData(), true);
        }
    }
    // fire up R
    const char *R_argv[] = {name, "--gui=none", "--no-save",
                            "--no-readline", "--silent", "--vanilla", "--slave"};
    int R_argc = sizeof(R_argv) / sizeof(R_argv[0]);
    Rf_initEmbeddedR(R_argc, (char**)R_argv);
    R_ReplDLLinit();                    // this is to populate the repl console buffers

    structRstart Rst;
    R_DefParams(&Rst);
#ifdef WIN32
    Rst.rhome = getenv("R_HOME");
    Rst.home = getRUser();
    Rst.CharacterMode = LinkDLL;
    Rst.ReadConsole = &RTool::R_ReadConsoleWin;
    Rst.WriteConsole = &RTool::R_WriteConsole;
    Rst.WriteConsoleEx = &RTool::R_WriteConsoleEx;
    Rst.CallBack = &RTool::R_ProcessEvents;
    Rst.ShowMessage = &RTool::R_ShowMessage;
    Rst.YesNoCancel = &RTool::R_YesNoCancel;
    Rst.Busy = &RTool::R_Busy;
#endif
    Rst.R_Interactive = (Rboolean) interactive;       // sets interactive() to eval to false
    R_SetParams(&Rst);

    loaded = true;
}
Exemple #14
0
/**
@SYMTestCaseID          SYSLIB-FATCHARSETCONV-CT-1777
@SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for conversions from/to Unicode, using a function pointer
@SYMTestExpectedResults Test must not fail
*/
void CT_CP949::TestL()
	{
    INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1777 "));
	RLibrary lib;

	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
	// load the dll
	TInt returnValue = lib.Load(KName,serverUid);
	test(returnValue==0);

	// get a pointer to the specified ordinal function and call it
	TLibraryFunction function1 = lib.Lookup(1);
	TLibraryFunction function2 = lib.Lookup(2);
	TLibraryFunction function3 = lib.Lookup(3);

	//cast the function pointer f to a function of type void with two arguments
	typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);
	TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1);

	typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&);
	TConvertToUnicodeL aConvertToUnicodeL = reinterpret_cast <TConvertToUnicodeL> (function2);

	typedef TBool (*TIsLegalShortNameCharacter)(TUint);
	TIsLegalShortNameCharacter aIsLegalShortNameCharacter = reinterpret_cast <TIsLegalShortNameCharacter> (function3);


	TBuf8<20> foreign1;
	TBuf16<15> unicode2;

	const TDesC16& unicode1(Uni_1);
	TRAPD(err,(*aConvertFromUnicodeL)(foreign1, unicode1)); 	//testing conversion from Unicode
	test(err==0);
	TInt error = foreign1.Compare(CP949_1);
	test(error==0);
	foreign1.Zero();

	const TDesC8& foreign2(CP949_2);
	(*aConvertToUnicodeL)(unicode2,foreign2); 	//testing conversion to Unicode
	error = unicode2.Compare(Uni_2);
	test(error==0);
	unicode2.Zero();


	//testing for legal short name character
	TInt result = (*aIsLegalShortNameCharacter)(0x005F); //testing for existent character
	test(result==1);
	result = (*aIsLegalShortNameCharacter)(0x003F); //testing for illegal character
	test(result==0);
	result = (*aIsLegalShortNameCharacter)(0x2999); //testing for non-existent character
	test(result==0);
	result = (*aIsLegalShortNameCharacter)(0xAC02); //testing for double byte character
	test(result==1);

	lib.Close();
	}
// -----------------------------------------------------------------------------
// MceServerStarter::CreateServerProcess
// -----------------------------------------------------------------------------
//
TInt MceServerStarter::CreateServerProcess (RSemaphore& aSemaphore)
	{
	const TUidType serverUid (KNullUid, KNullUid, KServerUid3);


#if ((defined (__WINS__) || defined(__WINSCW__)) && !defined (EKA2))

	RLibrary lib;
    RETURN_IF_ERROR (lib.Load(KMceServerFilename,serverUid))

    //  Get the WinsMain function
	TLibraryFunction functionWinsMain = lib.Lookup (1);

    //  Call it and cast the result to a thread function
	TThreadFunction serverThreadFunction = 
        reinterpret_cast<TThreadFunction> (functionWinsMain());

	TName threadName (KSipServerName);

	// Append a random number to make it unique
	threadName.AppendNum (Math::Random(), EHex);

	RThread server;
    TInt err = server.Create (threadName,
                              serverThreadFunction, // thread's main function
                              KDefaultStackSize,
                              NULL,
                              &lib,
                              NULL,
                              KServerMinHeapSize,
                              KServerMaxHeapSize,
                              EOwnerProcess );

	lib.Close ();	// if successful, server thread has handle to library now
    RETURN_IF_ERROR (err)

	server.SetPriority (EPriorityMore);

#else // HW build

	RProcess server;
	RETURN_IF_ERROR (server.Create( KMceServerName, KNullDesC, serverUid ) )

#endif


	server.Resume ();
	aSemaphore.Wait();
	TInt exitReason = server.ExitReason();
	server.Close ();

    return exitReason;
	}
EXPORT_C CAsyncHash* CAsyncHash::CopyL()
	{
	MAsyncHash* plugin=((MAsyncHash*)iPlugin)->CopyL();
	CleanupClosePushL(*plugin);
	RLibrary lib;
	lib.SetHandle(iLibHandle);
	RLibrary duplib=lib;
	User::LeaveIfError(duplib.Duplicate(RThread(), EOwnerProcess));
	CleanupClosePushL(duplib);
	CAsyncHash* self=new(ELeave) CAsyncHash(plugin, duplib.Handle());
	CleanupStack::Pop(2, plugin); //duplib, plugin
	return self;	
	}
TVerdict CApStartTestStep::doTestStepPreambleL()
	{
	// Load the CApaStarter implementation
	RLibrary lib;
	User::LeaveIfError(lib.Load(KApStartDLL)); // load the library
	CleanupClosePushL(lib);		
	TLibraryFunction ord1 = lib.Lookup(1); // This is the NewL function
	TFuncNewL funcL = reinterpret_cast<TFuncNewL>(ord1);
	iAppStart = static_cast<CApaStarter*> (funcL());	
	CleanupStack::PopAndDestroy(&lib);
		
	return CTestStep::doTestStepPreambleL();	
	}
Exemple #18
0
void gf_modules_unload_library(ModuleInstance *inst)
{
	if (!inst->lib_handle || gf_list_count(inst->interfaces)) return;

	RLibrary* pLibrary = (RLibrary *) inst->lib_handle;
	pLibrary->Close();
	delete pLibrary;

	inst->lib_handle = NULL;
	inst->load_func = NULL;
	inst->destroy_func = NULL;
	inst->query_func = NULL;
	//GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Core] Module %s unloaded\n", inst->szName));
}
Exemple #19
0
/*delete all interfaces loaded on object*/
void gf_modules_free_module(ModuleInstance *inst)
{
	void *objinterface;
	while (gf_list_count(inst->interfaces)) {
		objinterface = gf_list_get(inst->interfaces, 0);
		gf_list_rem(inst->interfaces, 0);
		inst->destroy_func(objinterface);
	}
	if (inst->lib_handle) {
		RLibrary* pLibrary = (RLibrary *) inst->lib_handle;
		pLibrary->Close();
	}
	gf_list_del(inst->interfaces);
	gf_free(inst);
}
// -----------------------------------------------------------------------------
// CHtiFramework::WaitNormalState
// Delays HTI startup until device reaches normal state.
// -----------------------------------------------------------------------------
void CHtiFramework::WaitNormalState( TInt aMaxWaitTime, TInt aStartUpDelay )
    {
    HTI_LOG_FUNC_IN("CHtiFramework::WaitNormalState");
    // First make sure that EComServer is running before continuing
    TFullName processName;
    TFindProcess finder( KEComServerMatchPattern );
    while ( finder.Next( processName ) != KErrNone )
        {
        HTI_LOG_TEXT( "HTI waiting for EComServer startup" );
        finder.Find( KEComServerMatchPattern );
        User::After( 1000000 ); // wait 1 second
        }
    HTI_LOG_TEXT( "EComServer process found - HTI startup continuing" );

    if ( aMaxWaitTime > 0 )
        {
        TInt err = KErrNone;
        RFs fs;
        err = fs.Connect();
        if ( err == KErrNone )
            {
            RLibrary library;
            err = library.Load( KHtiStartupWaitDllName );
            HTI_LOG_FORMAT( "StartupWait library load returned %d", err );
            if ( err == KErrNone &&
                 library.Type()[1] == KHtiStartupWaitInterfaceUid )
                {
                HTI_LOG_TEXT( "StartupWait DLL found" );
                TLibraryFunction entry = library.Lookup( 1 );
                if ( entry != NULL )
                    {
                    MHtiStartupWaitInterface* startupWait =
                        ( MHtiStartupWaitInterface* ) entry();
                    err = startupWait->WaitForStartup( aMaxWaitTime );
                    HTI_LOG_FORMAT( "StartupWait returned %d", err );
                    delete startupWait;
                    startupWait = NULL;
                    }
                }
            library.Close();
            }
        }

    HTI_LOG_FORMAT( "HTI Starting after %d seconds", aStartUpDelay );
    User::After( aStartUpDelay * 1000 * 1000 );

    HTI_LOG_FUNC_OUT( "CHtiFramework::WaitNormalState" );
    }
EXPORT_C void CCryptoSpiStateApi::EnumerateCharacteristicsL(RPointerArray<CCharacteristicsAndPluginName>& aCharacteristicsDll, TInt32 aInterface, TBool aExtended)
	{
	if (aInterface==0)
		{
		TInt interfaceCount=sizeof(KInterfacesUids)/sizeof(KInterfacesUids[0]);
		for (TInt i=0;i<interfaceCount;i++)
			{
			CryptoSpiUtil::RetrieveCharacteristicsL(KInterfacesUids[i].iUid, aCharacteristicsDll);
			}
		}
	else
		{
		CryptoSpiUtil::RetrieveCharacteristicsL(aInterface, aCharacteristicsDll);
		}
		
	if (aExtended)
		{
		TInt count=aCharacteristicsDll.Count();
		for (TInt i=0;i<count;i++)
			{
			RLibrary lib;
			CryptoSpiUtil::LoadPluginDllLC(lib, aCharacteristicsDll[i]->iDllName);
			GetExtendedCharacteristicsFuncL getExtendedCharFuncL=(GetExtendedCharacteristicsFuncL)lib.Lookup(EGetExtendedCharacteristicOrdinal);
			if (getExtendedCharFuncL)
				{
				TUid implementationUid={aCharacteristicsDll[i]->iCharacteristic->iImplementationUid};
				getExtendedCharFuncL(implementationUid, aCharacteristicsDll[i]->iExtendedCharacteristic);
				}
			CleanupStack::PopAndDestroy(&lib);
			}
		}
	}
/**
Attempt to load the library with the supplied name

@param aLibrary Library object used to load the DLL
@param aLibraryFilename file name of library to load
@leave KErrNotSupported If UID2 of the DLL is not KStatePolicyDllTypeUidValue
@leave KErrNotFound If the requested policy DLL file is missing.
@leave KErrCorrupt Or any other system wide error code that the fileserver can raise.
*/
void CSsmSwpPolicyResolver::LoadLibraryLC(RLibrary& aLibrary, const TDesC& aLibraryFilename) const
	{
	CleanupClosePushL(aLibrary);
	const TInt fileErr = aLibrary.Load(aLibraryFilename);
	if (fileErr != KErrNone)
		{
		DEBUGPRINT3(_L("Failed to load library file %S, file error-code: %d"), &aLibraryFilename, fileErr);
		User::Leave(fileErr);
		}
	if (aLibrary.Type()[1] != KSsmSwpPolicyDllTypeUid)
		{
		DEBUGPRINT4(_L("Wrong type (uid2) in swp policy library dll %S. Expected %x found %x"),
					&aLibraryFilename, KSsmSwpPolicyDllTypeUid, aLibrary.Type()[1]);
		User::Leave(KErrNotSupported);
		}
	}
void CCryptoPluginsLoader::LoadPluginsL()
{
    HBufC *configFileBuf = GetConfigFileNameL();
    CleanupStack::PushL(configFileBuf);
    TPtr configFile(configFileBuf->Des());

    RFs fs;
    User::LeaveIfError(fs.Connect());
    CleanupClosePushL(fs);

    RFile file;
    User::LeaveIfError(file.Open(fs, configFile, KEntryAttNormal));
    CleanupClosePushL(file);

    TFileText ft;
    ft.Set(file);
    TFileName line;

    User::LeaveIfError(ft.Read(line));

    //Load all the plugins
    do
    {
        TFileName filename;
        filename.Append(KPluginDir);
        filename.Append(line);

        //Load...
        RLibrary plugin;
        TInt err=plugin.Load(filename);
        if (err==KErrNone)
        {
            CleanupClosePushL(plugin);
            iPluginDllList.AppendL(plugin);
            CleanupStack::Pop(&plugin);
            iPluginNames.AppendL(line);
        }
    }
    while(ft.Read(line) == KErrNone);


    CleanupStack::PopAndDestroy(&file);
    CleanupStack::PopAndDestroy(&fs);
    CleanupStack::PopAndDestroy(configFileBuf);

    BuildPluginCharacteristicsL();
}
   ~C_simple_sound_player_imp(){
      //delete asw;
      delete plr;
#ifdef USE_OPTIONAL_POSITIONING
      if(lib_loaded)
         lib_mca.Close();
#endif
   }
Exemple #25
0
Bool gf_modules_load_library(ModuleInstance *inst)
{
	const TUid KGPACModuleUid= {0x10000080};
	char s_path[GF_MAX_PATH];
	HBufC *path;
	TInt e;

	if (inst->lib_handle) return 1;

	sprintf(s_path, "%s%c%s", inst->plugman->dir, GF_PATH_SEPARATOR, inst->szName);

	path = HBufC::NewL( User::StringLength( ( TUint8* ) s_path) + 1 );
	path->Des().Copy( TPtrC8(( TText8* ) s_path) );

	RLibrary* pLibrary = new RLibrary();
	e = pLibrary->Load(*path);
	delete path;

	if (e != KErrNone) {
		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[core] Cannot load library %s: %d", s_path, e));
		delete pLibrary;
		goto err_exit;
	}
	/*check UID 2 is GPAC's identifier*/
	if (pLibrary->Type()[1] != KGPACModuleUid) {
		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[core] Invalid library UID %x", (u32) pLibrary->Type()[1].iUid));
		pLibrary->Close();
		delete pLibrary;
		goto err_exit;
	}
	inst->query_func = (QueryInterfaces) pLibrary->Lookup(1);
	inst->load_func = (LoadInterface) pLibrary->Lookup(2);
	inst->destroy_func = (ShutdownInterface) pLibrary->Lookup(3);

	if ((inst->query_func==NULL) || (inst->load_func==NULL) || (inst->destroy_func==NULL) ) {
		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[core] Library %s has invalid interfaces", inst->szName));
		pLibrary->Close();
		delete pLibrary;
		goto err_exit;
	}

	//store library handle
	inst->lib_handle = (void*) pLibrary;
	//GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Core] Module %s loaded\n", inst->szName));
	return 1;

err_exit:
	gf_cfg_set_key(inst->plugman->cfg, "SymbianDLLs", inst->szName, "no");
	return 0;
}
Exemple #26
0
GLDEF_C TInt EtelServerThread(TAny* /*anArg*/)
//
// The ETel Server Thread.
//
	{
	__UHEAP_MARK;
	LOGTEXT(_L8("----------New Log----------\015\012"));
	LOGTEXT(_L8("Entered ETel Server thread"));
	LOGTEXTREL(_L8("Entered ETel Server thread"));

	CTrapCleanup* pT;
	if ((pT=CTrapCleanup::New())==NULL)
		Fault(EEtelFaultCreateTrapCleanup);

	//
	// Start the scheduler and then the server
	//
	CTelScheduler* pScheduler = CTelScheduler::New();
	CTelServer* pServer=CTelServer::New();

	User::SetCritical(User::ENotCritical);
	RSemaphore s;
	TInt semRet=s.OpenGlobal(KETelSemaphoreName);

	if (semRet==KErrNone)
		{
		s.Signal();
		s.Close();
		}
	RLibrary lib;
	lib.Load(KEtelDLLName); // to ensure the access count on the library is always >0
										// while the ETel thread is running
	CTelScheduler::Start();
	LOGTEXT(_L8("ETel:\tScheduler has been stopped\n"));

	delete pT;
	delete pServer;
	delete pScheduler;

	LOGTEXT(_L8("ETel:\tAbout to exit ETel thread function\n"));
	LOGTEXTREL(_L8("ETel:\tAbout to exit ETel thread function\n"));
	__UHEAP_MARKEND;

	return(KErrNone);
	}
/**
Gets the dll handle to SwpPolicy and initializes the SwpPolicy
*/
void CSsmSwpPolicyServer::CallSetDllHandleAndInitializeL(const RMessage2& aMessage, const TInt aSessionIndex)
	{
	__ASSERT_DEBUG(IN_RANGE(aSessionIndex, iSessionInfoArray.Count()), PanicNow(KSsmSwpPolicyBadIdx, KSsmSwpPolicySrvArrayIndexInvalid));

	RLibrary library;
	// Sets the swp policy library handle.  Library is owned by the CSsmSwpRequestHandler.
	library.SetHandle(aMessage.Int0());

	DEBUGPRINT1(_L("CSsmSwpPolicyServer: SwpPolicy handle is set"));
	iSessionInfoArray[aSessionIndex].iSwpPolicy = reinterpret_cast<MSsmSwpPolicy*>(library.Lookup(1)());

	DEBUGPRINT1(_L("CSsmSwpPolicyServer: Create CSsmSwpPolicyStepCompletion active object"));
	iSessionInfoArray[aSessionIndex].iSsmSwpPolicyStepCompletion = CSsmSwpPolicyStepCompletion::NewL(iSessionInfoArray[aSessionIndex].iSwpPolicy, *this, aSessionIndex);

	// aMessage will be completed in CSsmSwpPolicyStepCompletion's RunL method,
	// when the Initialization of the swp policy is completed.
	iSessionInfoArray[aSessionIndex].iSsmSwpPolicyStepCompletion->StartInitialize(aMessage);
	}
Exemple #28
0
extern "C" TLinAddr GetEka1ExeEntryPoint()
	{
	TLinAddr a = 0;
	RLibrary l;
	TInt r = l.Load(KEka1EntryStubName, KNullDesC, TUidType(KDynamicLibraryUid, KEka1EntryStubUid));
	if (r == KErrNone)
		r = l.Duplicate(RThread(), EOwnerProcess);
	if (r == KErrNone)
		{
		a = (TLinAddr)l.Lookup(1);
		if (!a)
			r = KErrNotSupported;
		}
	if (r != KErrNone)
		RThread().Kill(r);
	Exec::SetReentryPoint(a);
	return a;
	}
void CTestChangeLanguageStep::ChangeLocaleL(TLanguage aLanguage)
	{
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
    _LIT(KLitLocaleDllNameBase, "elocl_lan");
    _LIT(KLitLocaleDllNameExtension, ".loc");
#else 
    _LIT(KLitLocaleDllNameBase, "ELOCL");
    _LIT(KLitLocaleDllNameExtension, ".LOC");
#endif
    RLibrary localeDll;
    TBuf<16> localeDllName(KLitLocaleDllNameBase);
    CleanupClosePushL(localeDll);
    const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6));
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
    _LIT(ThreeDigExt,".%03d");
    localeDllName.AppendFormat(ThreeDigExt, aLanguage);
#else
    _LIT(KTwoDigExt,".%02d");
    localeDllName.AppendFormat(KTwoDigExt, aLanguage);
#endif        
       
    TInt error=localeDll.Load(localeDllName, uidType);
    if (error == KErrNotFound)
        {
        _LIT(KLoadError,"ChangeLanguageStep : localeDll-Load() returned error = %d");
        ERR_PRINTF2(KLoadError,error);
        localeDllName=KLitLocaleDllNameBase;
        localeDllName.Append(KLitLocaleDllNameExtension);
        error=localeDll.Load(localeDllName, uidType);   
        }
    User::LeaveIfError(error);
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
    _LIT(KLoadLocale,"Using API LoadLocaleAspect()");
    INFO_PRINTF1(KLoadLocale);
    TExtendedLocale myExtendedLocale;
    User::LeaveIfError(myExtendedLocale.LoadLocaleAspect(localeDllName));
    User::LeaveIfError(myExtendedLocale.SaveSystemSettings());
#else
	_LIT(KSecure,"Using Secure API ChangeLocale()");
	INFO_PRINTF1(KSecure);
	User::LeaveIfError(UserSvr::ChangeLocale(localeDllName));
#endif
	CleanupStack::PopAndDestroy(); // localeDll
	}
TInt PermanentThread(TAny* aArg)
	{
	TInt testType = (TInt)aArg;
	// Open handle on dynamic DLL in this thread
	RLibrary library;
	TInt r = library.Load(KDynamicDll);
	if (r != KErrNone)
		return r;
	RMsgQueue<TMessage> messageQueue;
	r = messageQueue.OpenGlobal(KMessageQueueName);
	if (r != KErrNone)
		return r;
	r = messageQueue.Send(EMessagePreDestruct);
	if (r != KErrNone)
		return r;
	messageQueue.Close();
	User::SetCritical(User::EProcessPermanent);
	User::Exit(testType);
	return KErrGeneral;
	}