|
| 1 | +/* |
| 2 | + * If not stated otherwise in this file or this component's LICENSE file the |
| 3 | + * following copyright and licenses apply: |
| 4 | + * |
| 5 | + * Copyright 2025 RDK Management |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +#pragma once |
| 21 | + |
| 22 | +#include "Module.h" |
| 23 | + |
| 24 | +// @stubgen:include <com/IIteratorType.h> |
| 25 | + |
| 26 | +namespace WPEFramework { |
| 27 | +namespace Exchange { |
| 28 | + |
| 29 | + /* @json @text:keep */ |
| 30 | + struct EXTERNAL ISharedStorage : virtual public Core::IUnknown { |
| 31 | + enum { ID = ID_SHARED_STORAGE }; |
| 32 | + |
| 33 | + ~ISharedStorage() override = default; |
| 34 | + |
| 35 | + enum ScopeType : uint8_t { |
| 36 | + DEVICE /* @text device */, |
| 37 | + ACCOUNT /* @text account */ |
| 38 | + }; |
| 39 | + struct EXTERNAL Success { |
| 40 | + bool success; |
| 41 | + }; |
| 42 | + |
| 43 | + // @event |
| 44 | + struct EXTERNAL INotification : virtual public Core::IUnknown { |
| 45 | + enum { ID = ID_SHARED_STORAGE_NOTIFICATION }; |
| 46 | + |
| 47 | + ~INotification() override = default; |
| 48 | + |
| 49 | + // @brief Values stored are changed using setValue |
| 50 | + // @text onValueChanged |
| 51 | + // @param scope: must be device or account |
| 52 | + // @param key: key |
| 53 | + // @param value: value |
| 54 | + virtual void OnValueChanged(const ScopeType scope, const string& ns /* @text:namespace */, const string& key, const string& value) {}; |
| 55 | + }; |
| 56 | + |
| 57 | + virtual Core::hresult Register(Exchange::ISharedStorage::INotification* notification) = 0; |
| 58 | + virtual Core::hresult Unregister(Exchange::ISharedStorage::INotification* notification) = 0; |
| 59 | + |
| 60 | + // @brief Sets the value of a key in the the specified namespace |
| 61 | + // @text setValue |
| 62 | + // @param scope: must be device or account |
| 63 | + // @param ns: name space |
| 64 | + // @param key: key |
| 65 | + // @param value: value |
| 66 | + // @param ttl: time to live (optional) |
| 67 | + // @param success: success |
| 68 | + virtual Core::hresult SetValue(const ScopeType scope, const string& ns /* @text:namespace */, const string& key, const string& value, const uint32_t ttl, Success& success /* @out */) = 0; |
| 69 | + // @brief Returns the value of a key from the specified namespace. |
| 70 | + // @text getValue |
| 71 | + // @param scope: must be device or account |
| 72 | + // @param ns: name space |
| 73 | + // @param key: key |
| 74 | + // @param value: value out |
| 75 | + // @param ttl: time to live (optional) |
| 76 | + // @param success: success |
| 77 | + virtual Core::hresult GetValue(const ScopeType scope, const string& ns /* @text:namespace */, const string& key, string& value /* @out */, uint32_t& ttl /* @out */, bool& success /* @out */) = 0; |
| 78 | + // @brief Deletes a key from the specified namespace |
| 79 | + // @text deleteKey |
| 80 | + // @param scope: must be device or account |
| 81 | + // @param ns: name space |
| 82 | + // @param key: key |
| 83 | + // @param success: success |
| 84 | + virtual Core::hresult DeleteKey(const ScopeType scope, const string& ns /* @text:namespace */, const string& key, Success& success /* @out */) = 0; |
| 85 | + // @brief Deletes the specified namespace |
| 86 | + // @text deleteNamespace |
| 87 | + // @param scope: must be device or account |
| 88 | + // @param ns: name space |
| 89 | + // @param success: success |
| 90 | + virtual Core::hresult DeleteNamespace(const ScopeType scope, const string& ns /* @text:namespace */, Success& success /* @out */) = 0; |
| 91 | + }; |
| 92 | + |
| 93 | + /* @json @text:keep */ |
| 94 | + struct EXTERNAL ISharedStorageInspector : virtual public Core::IUnknown { |
| 95 | + enum { ID = ID_SHARED_STORAGE_INSPECTOR }; |
| 96 | + |
| 97 | + ~ISharedStorageInspector() override = default; |
| 98 | + |
| 99 | + struct NamespaceSize { |
| 100 | + string ns; |
| 101 | + uint32_t size; |
| 102 | + }; |
| 103 | + |
| 104 | + using ScopeType = ISharedStorage::ScopeType; |
| 105 | + using IStringIterator = RPC::IIteratorType<string, RPC::ID_STRINGITERATOR>; |
| 106 | + using INamespaceSizeIterator = RPC::IIteratorType<NamespaceSize, ID_SHARED_STORAGE_INSPECTOR_NAMESPACE_SIZE_ITERATOR>; |
| 107 | + |
| 108 | + // @brief Returns the keys that are stored in the specified namespace |
| 109 | + // @text getKeys |
| 110 | + // @param scope: must be device or account |
| 111 | + // @param ns: name space |
| 112 | + // @param keys: keys list |
| 113 | + // @param success: success |
| 114 | + virtual Core::hresult GetKeys(const ScopeType scope, const string& ns /* @text:namespace */, IStringIterator*& keys /* @out */, bool& success /* @out */) = 0; |
| 115 | + // @brief Returns the namespaces |
| 116 | + // @text getNamespaces |
| 117 | + // @param scope: must be device or account |
| 118 | + // @param namespaces: namespaces list |
| 119 | + // @param success: success |
| 120 | + virtual Core::hresult GetNamespaces(const ScopeType scope, IStringIterator*& namespaces /* @out */, bool& success /* @out */) = 0; |
| 121 | + // @brief Returns the size occupied by each namespace |
| 122 | + // @text getStorageSizes |
| 123 | + // @param scope: must be device or account |
| 124 | + // @param storageList: list of namespaces and their sizes |
| 125 | + // @param success: success |
| 126 | + virtual Core::hresult GetStorageSizes(const ScopeType scope, INamespaceSizeIterator*& storageList /* @out */, bool& success /* @out */) = 0; |
| 127 | + }; |
| 128 | + |
| 129 | + /* @json @text:keep */ |
| 130 | + struct EXTERNAL ISharedStorageLimit : virtual public Core::IUnknown { |
| 131 | + enum { ID = ID_SHARED_STORAGE_LIMIT }; |
| 132 | + |
| 133 | + ~ISharedStorageLimit() override = default; |
| 134 | + |
| 135 | + using ScopeType = ISharedStorage::ScopeType; |
| 136 | + struct StorageLimit { |
| 137 | + uint32_t storageLimit; |
| 138 | + }; |
| 139 | + |
| 140 | + // @brief Sets the storage limit for a given namespace |
| 141 | + // @text setNamespaceStorageLimit |
| 142 | + // @param scope: must be device or account |
| 143 | + // @param ns: name space |
| 144 | + // @param storageLimit: size |
| 145 | + // @param success: success |
| 146 | + virtual Core::hresult SetNamespaceStorageLimit(const ScopeType scope, const string& ns /* @text:namespace */, const uint32_t storageLimit, bool& success /* @out */) = 0; |
| 147 | + // @brief Returns the storage limit for a given namespace |
| 148 | + // @text getNamespaceStorageLimit |
| 149 | + // @param scope: must be device or account |
| 150 | + // @param ns: name space |
| 151 | + // @param storageLimit: Size in bytes |
| 152 | + virtual Core::hresult GetNamespaceStorageLimit(const ScopeType scope, const string& ns /* @text:namespace */, StorageLimit& storageLimit /* @out */) = 0; |
| 153 | + }; |
| 154 | + |
| 155 | + /* @json @text:keep */ |
| 156 | + struct EXTERNAL ISharedStorageCache : virtual public Core::IUnknown { |
| 157 | + enum { ID = ID_SHARED_STORAGE_CACHE }; |
| 158 | + |
| 159 | + // @brief Flushes the device cache |
| 160 | + // @text flushCache |
| 161 | + virtual Core::hresult FlushCache() = 0; |
| 162 | + }; |
| 163 | + |
| 164 | +} // namespace Exchange |
| 165 | +} // namespace WPEFramework |
0 commit comments