void CSettings::SetFPSBuffer(bool FPSBuffer)
{
    SetSetting(Set_FPSBuffer, FPSBuffer ? 1 : 0);
}
示例#2
0
void AppSettings::SetModsDir(wxFileName value)
{
	SetSetting(_("ModsDir"), value);
}
void CSettings::SetTinyBuffer(bool TinyBuffer)
{
    SetSetting(Set_TinyBuffer, TinyBuffer ? 1 : 0);
}
//------------------------------------------------------------------------
//! Updates the value of a color setting
//!
//! @param strName The setting name
//! @param color The new setting value
//------------------------------------------------------------------------
void CViewConfigSection::SetColorSetting(const CString& strName, COLORREF color)
{
	SetSetting(strName, ConvertColorSetting(color));
}
示例#5
0
void AppSettings::SetInstDir(wxFileName value)
{
	SetSetting(_("InstanceDir"), value);
}
示例#6
0
//------------------------------------------------------------------------
//! Updates the value of a float setting
//!
//! @param strName The setting name
//! @param nValue The new setting value
//! @param nDecimals The number of decimals to persist
//------------------------------------------------------------------------
void CViewConfigSection::SetFloatSetting(const CString& strName, double nValue, int nDecimals)
{
	SetSetting(strName, ConvertFloatSetting(nValue, nDecimals));
}
示例#7
0
// set "Use Laptop Panel"
status_t
SetUseLaptopPanel(BScreen *screen, bool use)
{
	return SetSetting(screen, ms_use_laptop_panel, use);
}
/**
 * Flow interface thread :-
 * 1. Registers a message callback for any message received.
 * 2. Handles all the commands coming from controller thread.
 */
void FlowInterfaceThread(FlowThread thread, void *taskParameters)
{
	Controller *me = taskParameters;

	FlowInterfaceCmd *cmd = NULL;

	_receiveMsgQueue = &me->receiveMsgQueue;
	RegisterCallbackForReceivedMsg(MessageReceivedCallBack);

	for (;;)
	{
		cmd = FlowQueue_DequeueWaitFor(me->sendMsgQueue,QUEUE_WAITING_TIME);
		if (cmd != NULL)
		{
			switch (cmd->cmdType)
			{
				case FlowInterfaceCmd_SendMessageToUser:
				{
					SendMessage(me->userId, cmd->details,SendMessage_ToUser);
					FreeCmd(cmd);
					break;
				}
				case FlowInterfaceCmd_SendMessageToActuator:
				{
					if (me->actuatorConfig.actuatorId)
					{
						SendMessage(me->actuatorConfig.actuatorId, cmd->details,SendMessage_ToDevice);
						ControllerLog(ControllerLogLevel_Debug, DEBUG_PREFIX "Sending relay command to actuator" );
					}
					else
					{
						ControllerLog(ControllerLogLevel_Debug, DEBUG_PREFIX "Actuator id is NOT known to us" );
					}
					FreeCmd(cmd);
					break;
				}
				case FlowInterfaceCmd_SendMessageToSensor:
				{
					if (me->sensorConfig.sensorId)
					{
						SendMessage(me->sensorConfig.sensorId, cmd->details,SendMessage_ToDevice);
						ControllerLog(ControllerLogLevel_Debug, DEBUG_PREFIX "Sending update settings to sensor" );
					}
					else
					{
						ControllerLog(ControllerLogLevel_Debug, DEBUG_PREFIX "Sensor id is NOT known to us" );
					}
					FreeCmd(cmd);
					break;
				}
				case FlowInterfaceCmd_GetSetting:
				{
					char *data = NULL;

					if (GetSetting(CONTROLLER_CONFIG_NAME, &data))
					{
						if (!PostControllerEventSetting(&me->receiveMsgQueue, data))
						{
							Flow_MemFree((void **)&data);
							ControllerLog(ControllerLogLevel_Error, ERROR_PREFIX "Posting settings event to controller thread failed");
						}
					}
					else
					{
						if (!PostControllerEventSetting(&me->receiveMsgQueue, NULL))
						{
							ControllerLog(ControllerLogLevel_Error, ERROR_PREFIX "Posting settings event to controller thread failed");
						}
					}
					FreeCmd(cmd);
					break;
				}
				case FlowInterfaceCmd_SetSetting:
				{
					if (!SetSetting(CONTROLLER_CONFIG_NAME, cmd->details))
					{
						ControllerLog(ControllerLogLevel_Error, ERROR_PREFIX "Error in saving settings" );
					}
					FreeCmd(cmd);
					break;
				}
				default:
				{
					ControllerLog(ControllerLogLevel_Debug, DEBUG_PREFIX "Received unknown command" );
					FreeCmd(cmd);
					break;
				}
			}
		}
	}
}
示例#9
0
    //-----------------------------------------------------------------------------
    //  ParseCommand
    //  Parses the command when ENTER is pressed
    //-----------------------------------------------------------------------------
    void CConsole::ParseCommand( const char* szCmd )
    {
        static const uint szBoolTrueHash = StringHash32CaseInsensitive( "true" );
        static const uint szBoolFalseHash = StringHash32CaseInsensitive( "false" );


        char szVariable[256] = { 0 };
        char szValue[256] = { 0 };

        uint nIndex = 0;
        while( szCmd[nIndex] != ' ' && szCmd[nIndex] != 0 )
        {
            szVariable[nIndex] = szCmd[nIndex];

            nIndex++;
        }
        
        // There is no value, just add it and return
        if( szCmd[nIndex] == 0 )
        {
            szVariable[nIndex] = 0;
            AddLine( szVariable );
            Memset( m_szCurrCommand, 0, sizeof( m_szCurrCommand ) );
            m_nCurrPos = 0;
            return;
        }

        while( szCmd[nIndex] == ' ' )
        {
            nIndex++;
        }

        uint nValueIndex = 0;
        
        while( szCmd[nIndex] != 0 )
        {
            szValue[nValueIndex++] = szCmd[nIndex];
            nIndex++;
        }

        uint nVariableHash = StringHash32CaseInsensitive( szValue );

        bool bValue = true;
        int nValue = 0;
        eCommandType nType = eCommandInteger;
        if( nVariableHash == szBoolTrueHash )
        {
            nType = eCommandBoolean;
            bValue = true;
        }
        else if( nVariableHash == szBoolFalseHash ) 
        {
            nType = eCommandBoolean;
            bValue = false;
        }
        else
        {
            nIndex = 0;
            while( szValue[nIndex] != 0 )
            {
                if( szValue[nIndex] < '0' || szValue[nIndex] > '9' )
                {
                    nType = eCommandNull;
                    break;
                }
                nIndex++;
            }

            if( nType != eCommandNull )
            {
                // TODO: convert to integer
                nValue = szValue[nIndex-1] - '0';
            }
        }

        switch( nType )
        {
        case eCommandInteger:
            SetSetting( szVariable, nValue );
            break;
        default:
            break;
        }

        AddLine( szCmd );
        m_nCurrPos = 0;

        Memset( m_szCurrCommand, 0, sizeof( m_szCurrCommand ) );
    }
示例#10
0
	void SQLStorageBackend::InitializeTables ()
	{
		QSqlQuery query (DB_);

		if (!DB_.tables ().contains ("history"))
		{
			if (!query.exec ("CREATE TABLE history ("
						"date TIMESTAMP PRIMARY KEY, "
						"title TEXT, "
						"url TEXT"
						");"))
			{
				LeechCraft::Util::DBLock::DumpError (query);
				return;
			}

			if (!query.exec ("CREATE INDEX idx_history_title_url "
						"ON history (title, url)"))
				LeechCraft::Util::DBLock::DumpError (query);
		}

		if (!DB_.tables ().contains ("favorites"))
		{
			if (!query.exec ("CREATE TABLE favorites ("
						"title TEXT PRIMARY KEY, "
						"url TEXT, "
						"tags TEXT"
						");"))
			{
				LeechCraft::Util::DBLock::DumpError (query);
				return;
			}
		}

		if (!DB_.tables ().contains ("storage_settings"))
		{
			if (!query.exec ("CREATE TABLE storage_settings ("
						"key TEXT PRIMARY KEY, "
						"value TEXT"
						");"))
			{
				LeechCraft::Util::DBLock::DumpError (query);
				return;
			}

			if (Type_ == SBPostgres)
			{
				if (!query.exec ("CREATE RULE \"replace_storage_settings\" AS "
									"ON INSERT TO \"storage_settings\" "
									"WHERE "
										"EXISTS (SELECT 1 FROM storage_settings "
											"WHERE key = NEW.key) "
									"DO INSTEAD "
										"(UPDATE storage_settings "
											"SET value = NEW.value "
											"WHERE key = NEW.key)"))
				{
					LeechCraft::Util::DBLock::DumpError (query);
					return;
				}
			}

			SetSetting ("historyversion", "1");
			SetSetting ("favoritesversion", "1");
			SetSetting ("storagesettingsversion", "1");
		}

		if (!DB_.tables ().contains ("forms"))
		{
			QString binary = "BLOB";
			if (Type_ == SBPostgres)
				binary = "BYTEA";

			if (!query.exec (QString ("CREATE TABLE forms ("
							"url TEXT, "
							"form_index INTEGER, "
							"name TEXT, "
							"type TEXT, "
							"value %1"
							");").arg (binary)))
			{
				LeechCraft::Util::DBLock::DumpError (query);
				return;
			}
		}

		if (!DB_.tables ().contains ("forms_never"))
		{
			if (!query.exec ("CREATE TABLE forms_never ("
						"url TEXT PRIMARY KEY"
						");"))
			{
				LeechCraft::Util::DBLock::DumpError (query);
				return;
			}
		}
	}
示例#11
0
	void SQLStorageBackendMysql::InitializeTables ()
	{
		QSqlQuery query (DB_);

		if (!DB_.tables ().contains ("history"))
		{
			if (!query.exec ("CREATE TABLE history ("
						"date TIMESTAMP PRIMARY KEY, "
						"title TEXT, "
						"url TEXT"
						");"))
			{
				LeechCraft::Util::DBLock::DumpError (query);
				return;
			}

			if (!query.exec ("CREATE INDEX idx_history_title_url "
						"ON history (title, url)"))
				LeechCraft::Util::DBLock::DumpError (query);
		}

		if (!DB_.tables ().contains ("favorites"))
		{
			if (!query.exec ("CREATE TABLE favorites ("
						"title TEXT PRIMARY KEY, "
						"url TEXT, "
						"tags TEXT"
						");"))
			{
				LeechCraft::Util::DBLock::DumpError (query);
				return;
			}
		}

		if (!DB_.tables ().contains ("storage_settings"))
		{
			if (!query.exec ("CREATE TABLE storage_settings ("
						"key TEXT PRIMARY KEY, "
						"value TEXT"
						");"))
			{
				LeechCraft::Util::DBLock::DumpError (query);
				return;
			}

			SetSetting ("historyversion", "1");
			SetSetting ("favoritesversion", "1");
			SetSetting ("storagesettingsversion", "1");
		}

		if (!DB_.tables ().contains ("forms"))
		{
			QString binary = "BLOB";

			if (!query.exec (QString ("CREATE TABLE forms ("
							"url TEXT, "
							"form_index INTEGER, "
							"name TEXT, "
							"type TEXT, "
							"value %1"
							");").arg (binary)))
			{
				LeechCraft::Util::DBLock::DumpError (query);
				return;
			}
		}

		if (!DB_.tables ().contains ("forms_never"))
		{
			if (!query.exec ("CREATE TABLE forms_never ("
						"url TEXT PRIMARY KEY"
						");"))
			{
				LeechCraft::Util::DBLock::DumpError (query);
				return;
			}
		}
	}
示例#12
0
//-------------------------------------------------------------------------
// SetSetting
//-------------------------------------------------------------------------
bool SettingsFile::SetSetting(const char *section, const char *key, float value)
{
	char buffer[64];
	sprintf(buffer, "%f", value);
	return SetSetting(section, key, buffer);
}
示例#13
0
//-------------------------------------------------------------------------
// SetSetting
//-------------------------------------------------------------------------
bool SettingsFile::SetSetting(const char *section, const char *key, bool value)
{
	return SetSetting(section, key, value ? "true" : "false");
}
示例#14
0
// set TV Standard
status_t
SetTVStandard(BScreen *screen, uint32 standard)
{
	return SetSetting(screen, ms_tv_standard, standard);
}
示例#15
0
//------------------------------------------------------------------------
//! Updates the value of a bool setting
//!
//! @param strName The setting name
//! @param bValue The new setting value
//------------------------------------------------------------------------
void CViewConfigSection::SetBoolSetting(const CString& strName, bool bValue)
{
	SetSetting(strName, ConvertBoolSetting(bValue));
}
示例#16
0
//------------------------------------------------------------------------
//! Updates the value of a font setting
//!
//! @param strName The setting name
//! @param font The new setting value
//------------------------------------------------------------------------
void CViewConfigSection::SetLogFontSetting(const CString& strName, const LOGFONT& font)
{
	SetSetting(strName, ConvertLogFontSetting(font));
}
示例#17
0
//------------------------------------------------------------------------
//! Updates the value of an integer setting
//!
//! @param strName The setting name
//! @param nValue The new setting value
//------------------------------------------------------------------------
void CViewConfigSection::SetIntSetting(const CString& strName, int nValue)
{
	SetSetting(strName, ConvertIntSetting(nValue));
}
示例#18
0
//------------------------------------------------------------------------
//! Updates the value of a rectangle setting
//!
//! @param strName The setting name
//! @param rect The new setting value
//------------------------------------------------------------------------
void CViewConfigSection::SetRectSetting(const CString& strName, const RECT& rect)
{
	SetSetting(strName, ConvertRectSetting(rect));
}
示例#19
0
//------------------------------------------------------------------------
//! Updates the value of an integer-array setting
//!
//! @param strName The setting name
//! @param values The integer array
//! @param strDelimiter The delimiter for combining the values of an array to a string
//------------------------------------------------------------------------
void CViewConfigSection::SetArraySetting(const CString& strName, const CSimpleArray<int>& values, const CString& strDelimiter)
{
	SetSetting(strName, ConvertArraySetting(values, strDelimiter));
}
示例#20
0
// set "Swap Displays"
status_t
SetSwapDisplays(BScreen *screen, bool swap)
{
	return SetSetting(screen, ms_swap, swap);
}