void WidgetCheckInstallationFromFolder::execute()
{
    QString filePath = m_WidgetInfo[ EPropertyFilePath ].toString();
    
    if ( !( QFileInfo(filePath).isFile() ) ) 
    {
        RProcess me;
        TUidType uidType(me.Type());
        TUint32 uid3 = uidType[2].iUid;

        if (uid3 != BackupRestoreUid && uid3 != MediaManagerUid) 
        {
            emit aborted( EErrorPermissionDenied );
            return;
        }
    }

    emit completed();
    return; 
}
Exemplo n.º 2
0
void CSetClientUid::PerformAction(TRequestStatus& aStatus)
	{
	switch (iState)
		{
		case EMain:
			{
			RProcess thisProcess;
			thisProcess.Open(thisProcess.Id());
			CleanupClosePushL(thisProcess);
			TUidType type = thisProcess.Type();
			TUidType newType(type[0], type[1], iUid);
			thisProcess.SetType(newType);
			CleanupStack::PopAndDestroy(); // thisProcess
			
			iState = EFinished;
			TRequestStatus* status = &aStatus;
			User::RequestComplete(status, KErrNone);
			break;
			}

		case EFinished:
			{
			TRequestStatus* status = &aStatus;
			User::RequestComplete(status, aStatus.Int());
			if (aStatus == iExpectedResult)
				{
				iResult = ETrue;
				}
			else
				{
				iResult = EFalse;
				}
			
			iActionState = EPostrequisite;
			}
			break;
		}
	}
Exemplo n.º 3
0
TVerdict CFindRunningExe::doTestStepL()
	{
	TInt uidValue;
	_LIT(KUidKey, "uid");
	if (!GetHexFromConfig(ConfigSection(), KUidKey, uidValue))
		{
		ERR_PRINTF1(_L("Cannot read UID from config section."));
		SetTestStepResult(EFail);
		return EFail;
		}

	TUid exeUid;
	exeUid.iUid = uidValue;

	SetTestStepResult(EFail);
	TInt loop=0;
	for(;(loop < 20)&&(TestStepResult() == EFail);loop++)
		{
		TFindProcess findProcess;
		TFullName fullName;
		while((findProcess.Next(fullName) == KErrNone) && (TestStepResult() == EFail))
			{
			RProcess process;
			TInt ret=KErrNone;
			TInt count=0;
			do
			{
			count++;
 			ret=process.Open(findProcess);
			if (ret!=KErrNone)
				{
				User::After(200000);
				}
			}while (ret!=KErrNone && count<=10);
			if (ret!=KErrNone)
				{
				User::Leave(ret);
				}
			TUidType uid = process.Type();
			TExitType exitType = process.ExitType();
			process.Close();
			if(uid[2] == exeUid)
				{
					if (exitType == EExitPending)
						SetTestStepResult(EPass);
				}
			}
			User::After(1000000);
		}

	if (TestStepResult() == EPass)
		{
		INFO_PRINTF2(_L("Process with UID 0x%x running."), exeUid.iUid);
		}
	else
		{
		ERR_PRINTF2(_L("No process with UID 0x%x running."), exeUid.iUid);		
		}

	return TestStepResult();
	}
Exemplo n.º 4
0
void CTestStepESockSSA::KillC32Start()
	{
	// Start by looking for the running configurator and kill it if found. The caller
	// needs the appropriate capability to do this

	RDebug::Printf("Finding existing configurator process.");	
	_LIT(KC32StartName, "*");
	TInt result;
	TBool configuratorWasPresent;
	TInt count = 0;
	const TInt KMaxKillRetry = 10;
	do 
		{
		configuratorWasPresent = EFalse;
		TFullName fn;
		TFindProcess fp(KC32StartName);
		while(fp.Next(fn) == KErrNone)
			{
			RProcess proc;
			result = proc.Open(fn);
			if(result == KErrNone)
				{
				TUidType type = proc.Type();
				if(type[2] == TUid::Uid(KUidC32StartProcess) && proc.ExitType() == EExitPending) 
					{
					// Kill the existing configurator process.
					RDebug::Print(_L("Opened existing configurator process \"%S\""), &fn);
					TRequestStatus status;
					proc.Logon(status);
					proc.Kill(KErrNone);
					RDebug::Printf("Killed process.");
					User::WaitForRequest(status);
					TExitType exitType = proc.ExitType();
					
					// Create a timer in case some other entity holds an open handle on the
					// configurator which prevents the kernel from destroying it.  We timeout
					// after one second.
					TAutoClose<RTimer> timer;
					if(timer.iObj.CreateLocal() == KErrNone)
						{
						// Request destruction notification so we know when it is safe to start
						// the process again.
						TRequestStatus destructionStatus;
						proc.NotifyDestruction(destructionStatus);
						proc.Close();
					
						enum{ KProcessDestructionTimeout = 1000000 };
  					
						TRequestStatus timerStatus;
						timer.iObj.After(timerStatus, KProcessDestructionTimeout);
						
						// Wait for the process to be destroyed or for the timeout.
						User::WaitForRequest(destructionStatus, timerStatus);
						if(timerStatus.Int() == KRequestPending)
							{
							timer.iObj.Cancel();
							User::WaitForRequest(timerStatus);
							}
						else
							{
							User::CancelMiscNotifier(destructionStatus);
							User::WaitForRequest(destructionStatus);
			
							RDebug::Printf("Existing configurator process has still not been destroyed after %f.0s", KProcessDestructionTimeout / 1000000.0);
							}
						}
					else
						{
						proc.Close();
						}
						
					RDebug::Printf("Process logon completed with %d, exitType %d", status.Int(), exitType);
					configuratorWasPresent = ETrue;
					}
				else
					{
					proc.Close();	
					}
				}
			}
		} while(configuratorWasPresent && ++count < KMaxKillRetry);

		if (count >= KMaxKillRetry)
			{
			RDebug::Printf("KillC32Start - Cannot kill the configurator process, we will try continue and hope all is well");
			}
		
	// Restart the boot sequence from scratch - the configurator reads this.
	RProperty::Set(KUidSystemCategory, KUidC32StartPropertyKey.iUid, EReset);
	}
static bool processIconL(TInt32 uid, QString& newIconPath, const QString& path, const QString& basePath)
{
    LOG("processIconL path" << path);
    LOG("processIconL basePath " << basePath);
    // this should never happen as there is usually at least
    // the default icon path here
    if (path.isEmpty())
        return false;

    // 3 cases here for widget icon:
    // 1: default icon (i.e. QT_DEFAULT_ICON)
    // 2: an image file
    // 3: svg(z) image file

    // generate icon path
    newIconPath = basePath;
    if (!basePath.endsWith(QDir::separator()))
      newIconPath.append(QDir::separator());

#ifdef QTWRT_USE_USIF
    newIconPath.append('[' + QString::number( uid, 16 ) + "].png");
#else
    newIconPath.append('[' + QString::number( uid, 16 ) + "].mbm");
#endif
    LOG("processIconL newIconPath" << newIconPath << QFile::exists(newIconPath));
    QDir dir = QDir::root();
    dir.mkpath(basePath);

    bool ret = false;

    QString srcPath = path;
    if (path == QT_DEFAULT_ICON) {
        srcPath = newIconPath + ".png";
        if (QFile::exists(srcPath))
            QFile::remove(srcPath);

        if (!QFile::copy(path, srcPath))
            return false;

        // when default icon file is read only, so changing the attribute of copied icon file
        // so that, it can be writable otherwise it may cause problems while deleting/cleanup
        if (!QFile::setPermissions(srcPath, QFile::WriteOwner))
            return false;
    }

    RProcess myUID;
    TUidType uidType(myUID.Type());
    TUint32 processuid = uidType[2].iUid;
    if ((processuid == BACKUP_RESTORE_UID || processuid ==  MEDIA_MANAGER_UID) &&
        QFile::exists(newIconPath)) {
        // skip the convertion since the file is good
        LOG("processIconL skipping conversion");
        ret = true;
    } else {

        // try to convert the image into symbian specific format
        QEventLoop* loop = new QEventLoop();
        IconConverterWrapper* iconConverter = new IconConverterWrapper(loop);

#ifdef QTWRT_USE_USIF
        // if the destination icon already exists, remove it
        if (QFile::exists(newIconPath))
            QFile::remove(newIconPath);

        if (srcPath.endsWith(QLatin1String(".png"), Qt::CaseInsensitive) && 
            QFile::copy(srcPath, newIconPath))
            ret = true;
#else
        if (iconConverter && iconConverter->Init(srcPath, newIconPath)) {
            loop->exec();
            ret = true;
        }
#endif

        if (!ret) {
            // if convert fails, check if the file was .svg
            ret = processOtherFormats( newIconPath, path, *iconConverter, loop );
        }

        delete iconConverter;
        delete loop;
    }
    return ret;
}