Beispiel #1
0
void KAutostartTest::testRegisteringAndManipulatingANewService()
{
    QFile::remove(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String("/autostart/") + "doesnotexist.desktop");
    {
        // need to clean up the KAutostart object before QFile can remove it
        KAutostart autostart(QStringLiteral("doesnotexist"));
        QCOMPARE(autostart.autostarts(), false);
        autostart.setCommand(QStringLiteral("aseigo"));
        autostart.setCommandToCheck(QStringLiteral("/bin/ls"));
        autostart.setVisibleName(QStringLiteral("doesnotexisttest"));
        autostart.setStartPhase(KAutostart::BaseDesktop);
        autostart.setAllowedEnvironments(QStringList(QStringLiteral("KDE")));
        autostart.addToAllowedEnvironments(QStringLiteral("XFCE"));
        autostart.addToAllowedEnvironments(QStringLiteral("GNOME"));
        autostart.removeFromAllowedEnvironments(QStringLiteral("GNOME"));
        autostart.setExcludedEnvironments(QStringList(QStringLiteral("GNOME")));
        autostart.addToExcludedEnvironments(QStringLiteral("XFCE"));
        autostart.addToExcludedEnvironments(QStringLiteral("KDE"));
        autostart.removeFromExcludedEnvironments(QStringLiteral("KDE"));
    }

    QVERIFY(QFile::exists(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String("/autostart/") + "doesnotexist.desktop"));

    {
        QStringList allowedEnvs;
        allowedEnvs << QStringLiteral("KDE") << QStringLiteral("XFCE");

        QStringList excludedEnvs;
        excludedEnvs << QStringLiteral("GNOME") << QStringLiteral("XFCE");

        KAutostart autostart(QStringLiteral("doesnotexist"));
        QCOMPARE(autostart.command(), QStringLiteral("aseigo"));
        QCOMPARE(autostart.autostarts(), true);
        QCOMPARE(autostart.autostarts(QStringLiteral("KDE")), true);
        QCOMPARE(autostart.autostarts(QStringLiteral("GNOME")), false);
        QCOMPARE(autostart.autostarts(QStringLiteral("XFCE")), true);
        QCOMPARE(autostart.autostarts(QStringLiteral("XFCE"), KAutostart::CheckCommand), true);
        QCOMPARE(autostart.visibleName(), QStringLiteral("doesnotexisttest"));
        QCOMPARE(autostart.commandToCheck(), QStringLiteral("/bin/ls"));
        QCOMPARE(int(autostart.startPhase()), int(KAutostart::BaseDesktop));
        QCOMPARE(autostart.allowedEnvironments(), allowedEnvs);
        QCOMPARE(autostart.excludedEnvironments(), excludedEnvs);

        autostart.setCommandToCheck(QStringLiteral("/bin/whozitwhat"));
    }

    {
        KAutostart autostart(QStringLiteral("doesnotexist"));
        QCOMPARE(autostart.autostarts(QStringLiteral("KDE"), KAutostart::CheckCommand), false);
    }
}
int
handled_update_all_cmd(int sockfd, engine_type* engine, const char *cmd,
	ssize_t n)
{
	const char *scmd = "update all";
	cmd = ods_check_command(cmd,n,scmd);
	if (!cmd) return 0; // not handled
	ods_log_debug("[%s] %s command", module_str, scmd);

	// check that we are using a compatible protobuf version.
	GOOGLE_PROTOBUF_VERIFY_VERSION;
	time_t tstart = time(NULL);

	autostart(engine);

	/* Check all files for errors. The perform_update_*()
	 * functions check as well but this gives us all or nothing.
	 * Plus we get a complete check of the files mentioned in the 
	 * conf which need not be the same as the files in use by the 
	 * running enforcer!*/
	char *kasp = NULL;
	char *zonelist = NULL;
	char **replist = NULL;
	int repcount, i;
	int error = 1;
	if (check_conf(engine->config->cfg_filename, &kasp, 
			&zonelist, &replist, &repcount, 0))
		ods_log_error_and_printf(sockfd, module_str, 
			"Unable to validate '%s' consistency.", 
			engine->config->cfg_filename);
	else if (check_kasp(kasp, replist, repcount, 0))
		ods_log_error_and_printf(sockfd, module_str, 
			"Unable to validate '%s' consistency.", kasp);
	else if (check_zonelist(zonelist, 0))
		ods_log_error_and_printf(sockfd, module_str, 
			"Unable to validate '%s' consistency.", zonelist);
	else error = 0;
	
	free(kasp);
	free(zonelist);
	if (replist) {
		for (i = 0; i < repcount; i++) free(replist[i]);
	}

	if (!error) 
		error |= perform_update_repositorylist(sockfd, engine);
	if (!error) 
		error |= perform_update_kasp(sockfd, engine->config);
	if (!error) 
		error |= perform_update_keyzones(sockfd, engine->config);
	if (!error) {
		perform_update_hsmkeys(sockfd, engine->config, 0 /* automatic */);
		perform_hsmkey_gen(sockfd, engine->config, 0 /* automatic */,
						   engine->config->automatic_keygen_duration);
		flush_all_tasks(sockfd, engine);
	}
	ods_printf(sockfd, "%s completed in %ld seconds.\n",scmd,time(NULL)-tstart);
	return 1;
}
Beispiel #3
0
void KAutostartTest::testStartName()
{
    if (!KAutostart::isServiceRegistered(QStringLiteral("plasma-desktop"))) {
        QSKIP("plasma-desktop.desktop not found, kdebase not installed");
    }
    KAutostart autostart(QStringLiteral("plasma-desktop"));
    QCOMPARE(autostart.visibleName(), QStringLiteral("Plasma Desktop Workspace"));
}
Beispiel #4
0
void KAutostartTest::testStartphase()
{
    QFETCH(QString, service);
    QFETCH(int, startPhase);

    KAutostart autostart(service);
    QCOMPARE(int(autostart.startPhase()), startPhase);
}
Beispiel #5
0
void KAutostartTest::testStartDetection()
{
    QFETCH(QString, service);
    QFETCH(bool, doesAutostart);

    KAutostart autostart(service);
    QCOMPARE(autostart.autostarts(), doesAutostart);
}
Beispiel #6
0
void KAutostartTest::testStartInEnvDetection()
{
    QFETCH(QString, env);
    QFETCH(bool, doesAutostart);

    KAutostart autostart(QStringLiteral("plasma-desktop"));
    // Let's see if plasma.desktop actually exists
    if (QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QLatin1String("autostart/") + "plasma-desktop.desktop").isEmpty()) {
        QSKIP("plasma-desktop.desktop not found, kdebase not installed");
    } else {
        QCOMPARE(autostart.autostarts(env), doesAutostart);
    }
}
SessionManager::SessionManager(QObject *parent)
    : QObject(parent)
    , m_launcher(new ProcessLauncher(this))
    , m_idle(false)
    , m_locked(false)
{
    CompositorLauncher *compositorLauncher = CompositorLauncher::instance();

    // Actions to do when the compositor is ready
    connect(compositorLauncher, &CompositorLauncher::started, this, [this] {
        // Autostart applications as soon as the compositor is ready
        QTimer::singleShot(500, this, SLOT(autostart()));
    });

}
Beispiel #8
0
void MediaNotifier::slotStatResult(KIO::Job *job)
{
    bool allowNotification = m_allowNotificationMap[job];
    m_allowNotificationMap.remove(job);

    if(job->error() != 0)
        return;

    KIO::StatJob *stat_job = static_cast< KIO::StatJob * >(job);

    KIO::UDSEntry entry = stat_job->statResult();
    KURL url = stat_job->url();

    KFileItem medium(entry, url);

    if(autostart(medium))
        return;

    if(allowNotification)
        notify(medium);
}
Beispiel #9
0
int main()
{
	 // initialize COM
	ComInit usingCOM;


	HWND hwnd = 0;


	try {

		 // example for retrieval of special folder paths

		SpecialFolderFSPath programs(CSIDL_PROGRAM_FILES, hwnd);
		SpecialFolderFSPath autostart(CSIDL_STARTUP, hwnd);

		cout << "program files path = " << (LPCTSTR)programs << endl;
		cout << "autostart folder path = " << (LPCTSTR)autostart << endl;

		cout << endl;


		 // example for enumerating shell namespace objects

		cout << "Desktop:\n";
		dump_shell_namespace(GetDesktopFolder());
		cout << endl;

		cout << "C:\\\n";
		dump_shell_namespace(ShellPath("C:\\").get_folder());
		cout << endl;


		 // example for calling a browser dialog for the whole desktop

		FolderBrowser desktop_browser(hwnd,
									  BIF_RETURNONLYFSDIRS|BIF_EDITBOX|BIF_NEWDIALOGSTYLE,
									  TEXT("Please select the path:"));

		if (desktop_browser.IsOK())
			MessageBox(hwnd, desktop_browser, TEXT("Your selected path"), MB_OK);


		 // example for calling a rooted browser dialog

		ShellPath browseRoot("C:\\");
		FolderBrowser rooted_browser(hwnd,
									 BIF_RETURNONLYFSDIRS|BIF_EDITBOX|BIF_VALIDATE,
									 TEXT("Please select the path:"),
									 browseRoot);

		if (rooted_browser.IsOK())
			MessageBox(hwnd, rooted_browser, TEXT("Your selected path"), MB_OK);

	} catch(COMException& e) {

		//HandleException(e, hwnd);
		cerr << e.ErrorMessage() << endl;

	}

	return 0;
}