Exemplo n.º 1
0
static inline QString writeJSONPopupData(int id, const QWebSelectData& listData)
{
    QFile file(QString("/tmp/ComboBoxPopup%1").arg(id));
    if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
        return QString();

    pbnjson::JValue content = createJSONPopupData(listData);
    std::string result;
    jsonToString(content, result);
    const char* data = result.c_str();
    file.write(data, strlen(data));

    return file.flush() ? file.fileName() : QString();
}
Exemplo n.º 2
0
bool Preferences::setStringPreference(const char * keyName, const char * value)
{
	pbnjson::JValue pref = pbnjson::Object();
	pref.put(keyName, value);

	LSError error;
	LSErrorInit(&error);

	std::string	valueStr = jsonToString(pref);
	//g_debug("Preferences::setStringPreference: '%s' = '%s'", keyName, valueStr.c_str());

	bool ret = LSCall(Preferences::instance()->m_lsHandle,
				 "palm://com.palm.systemservice/setPreferences", valueStr.c_str(),
				 NULL, NULL, NULL, &error);
	if (!ret) {
		g_warning("%s: Failed setting '%s' to '%s' (%s)",
				   __FUNCTION__, keyName, value, error.message);
		LSErrorFree(&error);
		return false;
	}
	return true;
}
Exemplo n.º 3
0
bool Preferences::setMuteSoundPref(bool mute)
{
	m_muteOn = mute;

	pbnjson::JValue pref = pbnjson::Object();
	pref.put("muteSound", m_muteOn);

	LSError error;
	LSErrorInit(&error);

	std::string	valueStr = jsonToString(pref);

	bool ret = LSCall(Preferences::instance()->m_lsHandle,
				 "palm://com.palm.systemservice/setPreferences", valueStr.c_str(),
				 NULL, NULL, NULL, &error);
	if (!ret) {
		g_warning("%s: Failed setting 'muteSound' to '%d' (%s)",
				   __FUNCTION__, m_muteOn, error.message);
		LSErrorFree(&error);
		return false;
	}
	return true;
}
Exemplo n.º 4
0
bool Preferences::setRotationLockPref(OrientationEvent::Orientation lockedOrientation)
{
	m_rotationLock = lockedOrientation;

	pbnjson::JValue pref = pbnjson::Object();
	pref.put("rotationLock", (int)m_rotationLock);

	LSError error;
	LSErrorInit(&error);

	std::string	valueStr = jsonToString(pref);

	bool ret = LSCall(Preferences::instance()->m_lsHandle,
				 "palm://com.palm.systemservice/setPreferences", valueStr.c_str(),
				 NULL, NULL, NULL, &error);
	if (!ret) {
		g_warning("%s: Failed setting 'rotationLock' to '%d' (%s)",
				   __FUNCTION__, m_rotationLock, error.message);
		LSErrorFree(&error);
		return false;
	}
	return true;
}
Exemplo n.º 5
0
bool Preferences::saveBluetoothState(bool on)
{
	m_bluetoothOn = on;

	pbnjson::JValue pref = pbnjson::Object();
	pref.put("bluetoothRadio", m_bluetoothOn);

	LSError error;
	LSErrorInit(&error);

	std::string	valueStr = jsonToString(pref);

	bool ret = LSCall(Preferences::instance()->m_lsHandle,
				 "palm://com.palm.systemservice/setPreferences", valueStr.c_str(),
				 NULL, NULL, NULL, &error);
	if (!ret) {
		g_warning("%s: Failed setting 'wifiRadio' to '%d' (%s)",
				   __FUNCTION__, m_bluetoothOn, error.message);
		LSErrorFree(&error);
		return false;
	}
	return true;
}
Exemplo n.º 6
0
int Request::encode(std::string &rawString) {
    return jsonToString(root, rawString);
}