Ejemplo n.º 1
0
void PrefsDb::backupDefaultPrefs() 
{
	std::string prefStr = getPref("wallpaper");
	setPref(PrefsDb::s_sysDefaultWallpaperKey,prefStr);
	prefStr = getPref("ringtone");
	setPref(PrefsDb::s_sysDefaultRingtoneKey,prefStr);
}
Ejemplo n.º 2
0
void XMLPreferences::setPref(const QString& inName, const QString& inSection, 
			     const QVariant& inValue, Persistence pers)
{
  // set the preference in the appropriate section
  if (pers & Runtime)
    setPref(m_runtimeSections, inName, inSection, inValue);
  if (pers & User)
    setPref(m_userSections, inName, inSection, inValue);
  if (pers & Defaults)
    setPref(m_defaultsSections, inName, inSection, inValue);

  m_modified |= pers;
}
Ejemplo n.º 3
0
int PrefsDb::copyKeys(PrefsDb * p_sourceDb,const std::list<std::string>& keys,bool overwriteSameKeys)
{
	if (!p_sourceDb || (p_sourceDb == this))
		return 0;
	if (keys.empty())
		return 0;
	if (p_sourceDb->m_prefsDb == 0)
		return 0;

	g_message("%s: source DB file: [%s] , target DB file: [%s] , overwriteSameKeys = %s",
			__FUNCTION__,p_sourceDb->m_dbFilename.c_str(), m_dbFilename.c_str(),(overwriteSameKeys ? "YES" : "NO"));
	int n=0;
	for (std::list<std::string>::const_iterator it = keys.begin();
			it != keys.end();++it)
	{
		std::string val;
		if (p_sourceDb->getPref(*it,val))
		{
			std::string myVal;
			if (!getPref(*it,myVal) || overwriteSameKeys)
			{
				g_message("%s: copying key,value = ( [%s] , [%s] ) , overwriting [%s] ",
						__FUNCTION__,(*it).c_str(),val.c_str(),myVal.c_str());
				setPref(*it,val);
				++n;
			}
		}
	}
	return n;
}
Ejemplo n.º 4
0
void XMLPreferences::setPrefVariant(const QString& inName, 
				    const QString& inSection,
				    const QVariant& inValue, 
				    Persistence pers)
{
  setPref(inName, inSection, inValue, pers);
}
Ejemplo n.º 5
0
void XMLPreferences::setPrefKey(const QString& inName,
				const QString& inSection,
				int inValue,
				Persistence pers)
{
  setPref(inName, inSection, QVariant(QKeySequence(inValue)), pers);
}
Ejemplo n.º 6
0
void XMLPreferences::setPrefBool(const QString& inName, 
				 const QString& inSection,
				 bool inValue,
				 Persistence pers)
{
  setPref(inName, inSection, QVariant(inValue, 0), pers);
}
Ejemplo n.º 7
0
void PrefsDb::synchronizeCustomerCareInfo() {
	
	char* jsonStr = Utils::readFile(s_custCareNumberFile);
	if (!jsonStr) {
		g_warning("PrefsDb::synchronizeCustomerCareInfo(): Failed to load customer care file: %s", s_custCareNumberFile);
		return;
	}

	json_object* root = 0;
	std::string ccnumber;
	int ret;
	gchar* queryStr;

	root = json_tokener_parse(jsonStr);
	if (!root || is_error(root)) {
		g_warning("PrefsDb::synchronizeCustomerCareInfo(): Failed to parse file contents into json");
		return;
	}
	
	json_object_object_foreach(root, key, val) {

		if (val == NULL)
			continue;		//TODO: really should delete this key if it is in the database
		char * p_cDbv = json_object_to_json_string(val);
		if (p_cDbv == NULL)
			continue;
		
		//check the key to see if it exists in the db already
		std::string cv = getPref(key);
		std::string dbv(p_cDbv);
		
		if (cv.length() == 0) {
			queryStr = g_strdup_printf("INSERT INTO Preferences "
					"VALUES ('%s', '%s')",
					key, json_object_to_json_string(val));
			if (!queryStr) {
				g_warning("PrefsDb::synchronizeCustomerCareInfo(): Failed to allocate query string for key %s",key);
				continue;
			}

			ret = sqlite3_exec(m_prefsDb, queryStr, NULL, NULL, NULL);
			g_free(queryStr);

			if (ret) {
				g_warning("PrefsDb::synchronizeCustomerCareInfo(): Failed to execute query for key %s", key);
				continue;
			}
		}
		else if (cv != dbv) {
			//update
			setPref(key,dbv);
		}
	}
	
	json_object_put(root);
		
}
Ejemplo n.º 8
0
void XMLPreferences::setPrefUInt64(const QString& inName,
				   const QString& inSection,
				   uint64_t inValue,
				   Persistence pers)
{
  QByteArray ba;
  ba.duplicate((const char*)&inValue, sizeof(uint64_t));
  setPref(inName, inSection, ba, pers);
}
Ejemplo n.º 9
0
prefObj& prefObj::operator=(const prefObj& src){


    if(this != &src){
        setPref(src.USER, src.UPASS, src.HOSTIP, src.HOSTPORT, src.HostTable, src.localDBPath);
    }

    return *this;

}