Example #1
0
Status
pluginDataRemove(const Account &account, const std::string &plugin,
                 const std::string &key)
{
    std::string filename = keyFilename(account, plugin, key);

    if (fileExists(filename))
        ABC_CHECK(fileDelete(filename));

    return Status();
}
Example #2
0
Status
pluginDataRemove(const Account &account, const std::string &plugin,
    const std::string &key)
{
    std::string filename = keyFilename(account, plugin, key);

    if (fileExists(filename))
        ABC_CHECK_OLD(ABC_FileIODeleteFile(filename.c_str(), &error));

    return Status();
}
Example #3
0
Status
pluginDataSet(const Account &account, const std::string &plugin,
    const std::string &key, const std::string &data)
{
    ABC_CHECK(fileEnsureDir(pluginsDirectory(account)));
    ABC_CHECK(fileEnsureDir(pluginDirectory(account, plugin)));

    PluginDataFile json;
    json.keySet(key);
    json.dataSet(data);
    ABC_CHECK(json.save(keyFilename(account, plugin, key), account.login.dataKey()));

    return Status();
}
Example #4
0
Status
pluginDataGet(const Account &account, const std::string &plugin,
              const std::string &key, std::string &data)
{
    PluginDataFile json;
    ABC_CHECK(json.load(keyFilename(account, plugin, key),
                        account.login.dataKey()));
    ABC_CHECK(json.keyOk());
    ABC_CHECK(json.dataOk());

    if (json.key() != key)
        return ABC_ERROR(ABC_CC_JSONError, "Plugin filename does not match contents");

    data = json.data();
    return Status();
}
Example #5
0
Status
pluginDataSet(const Account &account, const std::string &plugin,
              const std::string &key, const std::string &data)
{
    ABC_CHECK(fileEnsureDir(pluginsDirectory(account)));
    ABC_CHECK(fileEnsureDir(pluginDirectory(account, plugin)));

    const auto namePath = pluginDirectory(account, plugin) + "Name.json";
    if (!fileExists(namePath))
    {
        PluginNameJson json;
        ABC_CHECK(json.nameSet(plugin));
        json.save(namePath, account.login.dataKey());
    }

    PluginDataFile json;
    json.keySet(key);
    json.dataSet(data);
    ABC_CHECK(json.save(keyFilename(account, plugin, key),
                        account.login.dataKey()));

    return Status();
}