Ejemplo n.º 1
0
static void
saveYourselfCallback(SmcConn connection,
                     SmPointer client_data,
                     int saveType,
                     Bool shutdown,
                     int interact_Style,
                     Bool fast)
{
   CompOption args[4];

   args[0].type = CompOptionTypeInt;
   args[0].name = "save_type";
   args[0].value.i = saveType;

   args[1].type = CompOptionTypeBool;
   args[1].name = "shutdown";
   args[1].value.b = shutdown;

   args[2].type = CompOptionTypeInt;
   args[2].name = "interact_style";
   args[2].value.i = interact_Style;

   args[3].type = CompOptionTypeBool;
   args[3].name = "fast";
   args[3].value.b = fast;

   (*core.sessionEvent)(&core, CompSessionEventSaveYourself, args, 4);

   setCloneRestartCommands(connection);
   setRestartStyle(connection, SmRestartImmediately);
   setProgramInfo(connection, getpid(), getuid());
   SmcSaveYourselfDone(connection, 1);
}
Ejemplo n.º 2
0
	// for when the tables need to be updated
	void RSSManager::updateDatabaseFormat()
	{
		// create tables if not already there
		int createRC = simpleSQL(db,
			"CREATE TABLE \"FeedItems\" (\n\t`guid`\tTEXT NOT NULL UNIQUE,\n\t`title`\tTEXT NOT NULL,\n\t`description`\tTEXT NOT NULL,\n\t`feedid`\tINTEGER NOT NULL,\n\t`date`\tTEXT NOT NULL,\n\t`actualdate`\tTEXT,\n\t`status`\tINTEGER NOT NULL DEFAULT 0,\n\t`link`\tTEXT,\n\t`contentencoded`\tTEXT,\n\tPRIMARY KEY(guid)\n);");
		simpleSQL(db,
			"CREATE TABLE IF NOT EXISTS \"FeedInfo\" (\n\t`id`\tINTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n\t`name`\tTEXT NOT NULL,\n\t`url`\tTEXT NOT NULL UNIQUE\n)");
		simpleSQL(db, 
			"CREATE TABLE IF NOT EXISTS `ProgramInfo` (\n\t`infoname`\tTEXT NOT NULL UNIQUE,\n\t`value`\tTEXT,\n\tPRIMARY KEY(infoname)\n);");

		// these statements need to be created first
		std::string feedStr = "select value from ProgramInfo where infoname=?1;";
		int rc = sqlite3_prepare_v2(db, feedStr.c_str(), feedStr.length() + 1, &getProgramInfoStmt, NULL);
		feedStr = "insert or replace into ProgramInfo (infoname, value) values (?1, ?2);";
		rc = sqlite3_prepare_v2(db, feedStr.c_str(), feedStr.length() + 1, &setProgramInfoStmt, NULL);

		// when the tables already exist, update the table format
		if (createRC == SQLITE_ERROR)
		{
			// get version of databse
			std::string version = getProgramInfo("version", "0.0");
			if (!version.compare("0.0"))	// version 0, before content encoded, and ProgramInfo
			{
				simpleSQL(db, "alter table FeedItems add column `contentencoded` TEXT;");
			}
		}

		// current version
		setProgramInfo("version", "0.1");
	}
Ejemplo n.º 3
0
static void
saveYourselfCallback (SmcConn   connection,
		      SmPointer client_data,
		      int       saveType,
		      Bool      shutdown,
		      int       interact_Style,
		      Bool      fast)
{
    CompOption::Vector args;

    args.push_back (CompOption ("save_type",      CompOption::TypeInt));
    args.push_back (CompOption ("shutdown",       CompOption::TypeBool));
    args.push_back (CompOption ("interact_style", CompOption::TypeInt));
    args.push_back (CompOption ("fast",           CompOption::TypeBool));

    args[0].value ().set (saveType);
    args[1].value ().set ((bool) shutdown);
    args[2].value ().set (interact_Style);
    args[3].value ().set ((bool) fast);

    screen->sessionEvent (CompSession::EventSaveYourself, args);

    setCloneRestartCommands (connection);
    setRestartStyle (connection, SmRestartImmediately);
    setProgramInfo (connection, getpid (), getuid ());
    SmcSaveYourselfDone (connection, 1);
}