File indexing completed on 2024-11-24 04:43:41

0001 /*
0002  * SPDX-FileCopyrightText: 2020 Shashwat Jolly <shashwat.jolly@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "etebaseadapter.h"
0008 
0009 #include "etesync_debug.h"
0010 
0011 QString QStringFromCharPtr(const CharPtr &str)
0012 {
0013     if (str.get() == nullptr) {
0014         return QString();
0015     }
0016     const QString ret = QString::fromUtf8(str.get());
0017     return ret;
0018 }
0019 
0020 EtebaseClientPtr etebase_client_new(const QString &client_name, const QString &server_url)
0021 {
0022     return EtebaseClientPtr(etebase_client_new(charArrFromQString(client_name), charArrFromQString(server_url)));
0023 }
0024 
0025 EtebaseAccountPtr etebase_account_login(const EtebaseClient *client, const QString &username, const QString &password)
0026 {
0027     return EtebaseAccountPtr(etebase_account_login(client, charArrFromQString(username), charArrFromQString(password)));
0028 }
0029 
0030 void etebase_fetch_options_set_stoken(EtebaseFetchOptions *fetch_options, const QString &stoken)
0031 {
0032     etebase_fetch_options_set_stoken(fetch_options, charArrFromQString(stoken));
0033 }
0034 
0035 void etebase_item_metadata_set_color(EtebaseItemMetadata *meta_data, const QString &color)
0036 {
0037     etebase_item_metadata_set_color(meta_data, charArrFromQString(color));
0038 }
0039 
0040 void etebase_item_metadata_set_name(EtebaseItemMetadata *meta_data, const QString &name)
0041 {
0042     etebase_item_metadata_set_name(meta_data, charArrFromQString(name));
0043 }
0044 
0045 EtebaseCollectionPtr etebase_collection_manager_create(const EtebaseCollectionManager *col_mgr,
0046                                                        const QString &collection_type,
0047                                                        const EtebaseItemMetadata *meta,
0048                                                        const void *content,
0049                                                        uintptr_t content_size)
0050 {
0051     return EtebaseCollectionPtr(etebase_collection_manager_create(col_mgr, charArrFromQString(collection_type), meta, content, content_size));
0052 }
0053 
0054 EtebaseFileSystemCachePtr etebase_fs_cache_new(const QString &path, const QString &username)
0055 {
0056     return EtebaseFileSystemCachePtr(etebase_fs_cache_new(charArrFromQString(path), charArrFromQString(username)));
0057 }
0058 
0059 int32_t etebase_fs_cache_item_set(const EtebaseFileSystemCache *file_cache, const EtebaseItemManager *item_mgr, const QString &col_uid, const EtebaseItem *item)
0060 {
0061     return etebase_fs_cache_item_set(file_cache, item_mgr, charArrFromQString(col_uid), item);
0062 }
0063 
0064 EtebaseCollectionPtr etebase_fs_cache_collection_get(const EtebaseFileSystemCache *fs_cache, const EtebaseCollectionManager *col_mgr, const QString &col_uid)
0065 {
0066     return EtebaseCollectionPtr(etebase_fs_cache_collection_get(fs_cache, col_mgr, charArrFromQString(col_uid)));
0067 }
0068 
0069 EtebaseItemPtr
0070 etebase_fs_cache_item_get(const EtebaseFileSystemCache *fs_cache, const EtebaseItemManager *item_mgr, const QString &col_uid, const QString &item_uid)
0071 {
0072     return EtebaseItemPtr(etebase_fs_cache_item_get(fs_cache, item_mgr, charArrFromQString(col_uid), charArrFromQString(item_uid)));
0073 }
0074 
0075 int32_t etebase_fs_cache_collection_unset(const EtebaseFileSystemCache *fs_cache, const EtebaseCollectionManager *col_mgr, const QString &col_uid)
0076 {
0077     return etebase_fs_cache_collection_unset(fs_cache, col_mgr, charArrFromQString(col_uid));
0078 }
0079 
0080 int32_t etebase_fs_cache_item_unset(const EtebaseFileSystemCache *fs_cache, const EtebaseItemManager *item_mgr, const QString &col_uid, const QString &item_uid)
0081 {
0082     return etebase_fs_cache_item_unset(fs_cache, item_mgr, charArrFromQString(col_uid), charArrFromQString(item_uid));
0083 }