Example #1
0
static void
writeDone (CCSContext * context)
{
    /* export the data to ensure the changes are on disk */
    char        *fileName;
    char        *currentProfile;
    IniPrivData *data;

    data = findPrivFromContext (context);
    if (!data)
        return;

    currentProfile = ccsGetProfile (context);

    if (!currentProfile || !strlen (currentProfile))
        currentProfile = strdup (DEFAULTPROF);
    else
        currentProfile = strdup (currentProfile);

    fileName = getIniFileName (currentProfile);

    free (currentProfile);

    ccsIniSave (data->iniFile, fileName);

    ccsEnableFileWatch (data->iniWatchId);

    free (fileName);
}
Example #2
0
static void
writeDone (CCSBackend *backend, CCSContext * context)
{
    /* export the data to ensure the changes are on disk */
    char        *fileName;
    const char        *currentProfileCCS;
    char	*currentProfile;
    IniPrivData *data;

    data = (IniPrivData *) ccsObjectGetPrivate (backend);
    if (!data)
	return;

    currentProfileCCS = ccsGetProfile (context);

    if (!currentProfileCCS || !strlen (currentProfileCCS))
	currentProfile = strdup (DEFAULTPROF);
    else
	currentProfile = strdup (currentProfileCCS);

    fileName = getIniFileName (currentProfile);

    free (currentProfile);

    ccsIniSave (data->iniFile, fileName);

    ccsEnableFileWatch (data->iniWatchId);

    free (fileName);
}
Bool
ccsWriteConfig (ConfigOption option,
		char         *value)
{
    IniDictionary *iniFile;
    char          *entry = NULL;
    char          *section;
    char          *fileName;
    char          *curVal;
    Bool          changed = TRUE;

    /* don't change config if nothing changed */
    if (ccsReadConfig (option, &curVal))
    {
	changed = (strcmp (value, curVal) != 0);
	free (curVal);
    }

    if (!changed)
	return TRUE;

    iniFile = getConfigFile();
    if (!iniFile)
	return FALSE;

    switch (option)
    {
    case OptionProfile:
	entry = "profile";
	break;
    case OptionBackend:
	entry = "backend";
	break;
    case OptionIntegration:
	entry = "integration";
	break;
    case OptionAutoSort:
	entry = "plugin_list_autosort";
	break;
    default:
	break;
    }

    if (!entry)
    {
	ccsIniClose (iniFile);
	return FALSE;
    }

    section = getSectionName();
    ccsIniSetString (iniFile, section, entry, value);
    free (section);

    fileName = getConfigFileName();
    if (!fileName)
    {
	ccsIniClose (iniFile);
	return FALSE;
    }

    ccsIniSave (iniFile, fileName);
    ccsIniClose (iniFile);
    free (fileName);

    return TRUE;
}