etebaseadapter.cpp 3.13 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * SPDX-FileCopyrightText: 2020 Shashwat Jolly <shashwat.jolly@gmail.com>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "etebaseadapter.h"

#include "etesync_debug.h"

QString QStringFromCharPtr(const CharPtr &str)
{
    if (str.get() == nullptr) {
        return QString();
    }
    const QString ret = QString::fromUtf8(str.get());
    return ret;
}

20
EtebaseClientPtr etebase_client_new(const QString &client_name, const QString &server_url)
21
{
22
    return EtebaseClientPtr(etebase_client_new(charArrFromQString(client_name), charArrFromQString(server_url)));
23 24
}

25
EtebaseAccountPtr etebase_account_login(const EtebaseClient *client, const QString &username, const QString &password)
26
{
27
    return EtebaseAccountPtr(etebase_account_login(client, charArrFromQString(username), charArrFromQString(password)));
28 29
}

30
void etebase_fetch_options_set_stoken(EtebaseFetchOptions *fetch_options, const QString &stoken)
31
{
32
    etebase_fetch_options_set_stoken(fetch_options, charArrFromQString(stoken));
33 34
}

35
EtebaseCollectionMetadataPtr etebase_collection_metadata_new(const QString &type, const QString &name)
36
{
37
    return EtebaseCollectionMetadataPtr(etebase_collection_metadata_new(charArrFromQString(type), charArrFromQString(name)));
38 39
}

40
void etebase_collection_metadata_set_color(EtebaseCollectionMetadata *meta_data, const QString &color)
41
{
42
    etebase_collection_metadata_set_color(meta_data, charArrFromQString(color));
43 44
}

45
void etebase_collection_metadata_set_name(EtebaseCollectionMetadata *meta_data, const QString &name)
46
{
47
    etebase_collection_metadata_set_name(meta_data, charArrFromQString(name));
48 49
}

50
EtebaseFileSystemCachePtr etebase_fs_cache_new(const QString &path, const QString &username)
51
{
52
    return EtebaseFileSystemCachePtr(etebase_fs_cache_new(charArrFromQString(path), charArrFromQString(username)));
53 54
}

55
int32_t etebase_fs_cache_item_set(const EtebaseFileSystemCache *file_cache, const EtebaseItemManager *item_mgr, const QString &col_uid, const EtebaseItem *item)
56
{
57
    return etebase_fs_cache_item_set(file_cache, item_mgr, charArrFromQString(col_uid), item);
58
}
59

60
EtebaseCollectionPtr etebase_fs_cache_collection_get(const EtebaseFileSystemCache *fs_cache, const EtebaseCollectionManager *col_mgr, const QString &col_uid)
61
{
62
    return EtebaseCollectionPtr(etebase_fs_cache_collection_get(fs_cache, col_mgr, charArrFromQString(col_uid)));
63
}
64

65
EtebaseItemPtr etebase_fs_cache_item_get(const EtebaseFileSystemCache *fs_cache, const EtebaseItemManager *item_mgr, const QString &col_uid, const QString &item_uid)
66
{
67
    return EtebaseItemPtr(etebase_fs_cache_item_get(fs_cache, item_mgr, charArrFromQString(col_uid), charArrFromQString(item_uid)));
68 69
}

70
int32_t etebase_fs_cache_collection_unset(const EtebaseFileSystemCache *fs_cache, const EtebaseCollectionManager *col_mgr, const QString &col_uid)
71
{
72
    return etebase_fs_cache_collection_unset(fs_cache, col_mgr, charArrFromQString(col_uid));
73 74
}

75
int32_t etebase_fs_cache_item_unset(const EtebaseFileSystemCache *fs_cache, const EtebaseItemManager *item_mgr, const QString &col_uid, const QString &item_uid)
76
{
77
    return etebase_fs_cache_item_unset(fs_cache, item_mgr, charArrFromQString(col_uid), charArrFromQString(item_uid));
78
}