Add 3.0 APIs and sync APIs same as 2.4
[platform/core/convergence/service-adaptor.git] / adaptor / storage-adaptor / storage_adaptor.h
1 /*
2  * Storage Adaptor
3  *
4  * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef __STORAGE_ADAPTOR_H__
21 #define __STORAGE_ADAPTOR_H__
22
23 #ifndef API
24 #define API __attribute__ ((visibility("default")))
25 #endif
26
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31
32 #include <stdio.h>
33 #include <glib.h>
34
35 #include "service_adaptor_errors.h"
36 #include "cloud_service.h"
37 //#include "posix_service.h"
38
39 /**
40  * @file storage_adaptor.h
41  */
42
43 /**
44  * @ingroup
45  * @defgroup
46  *
47  * @brief
48  *
49  * @section
50  *  \#include <storage_adaptor.h>
51  *
52  * <BR>
53  * @{
54  */
55
56 #define URI_STORAGE     "storage"
57 #define URI_CLOUD       "storage/cloud"
58 #define URI_POSIX       "storage/posix"
59
60 /**
61  * @brief Describes infromation about Storage Spec
62  */
63 typedef enum _storage_spec_e
64 {
65         STORAGE_SPEC_CLOUD      = (1 << 0),
66         STORAGE_SPEC_POSIX      = (1 << 1),
67 } storage_spec_e;
68
69 /**
70  * @brief Describes infromation about Storage Plugin
71  */
72 typedef struct _storage_plugin_s
73 {
74         char *uri;
75         char *name;
76         char *package;
77
78         cloud_service_h cloud;
79 //      posix_service_h posix;
80
81         GMutex mutex;
82         GCond cond;
83 } storage_plugin_s;
84 typedef struct _storage_plugin_s *storage_plugin_h;
85
86 /**
87  * @brief Describes infromation about Storage Adaptor
88  */
89 typedef struct _storage_adaptor_s
90 {
91         GList *plugins;         // storage_plugin_h
92
93         GMutex mutex;
94         int start;
95 } storage_adaptor_s;
96 typedef struct _storage_adaptor_s *storage_adaptor_h;
97
98 /**
99  * @brief Describes infromation about Storage Adaptor Listener
100  */
101 typedef struct _storage_adaptor_listener_s
102 {
103         void (*create_file_cb)(const char *uri, const char *path, void *user_data);
104 } storage_adaptor_listener_s;
105 typedef struct _storage_adaptor_listener_s *storage_adaptor_listener_h;
106
107 storage_adaptor_h storage_adaptor_create();
108 service_adaptor_error_e storage_adaptor_destroy(storage_adaptor_h storage);
109 service_adaptor_error_e storage_adaptor_start(storage_adaptor_h storage);
110 service_adaptor_error_e storage_adaptor_stop(storage_adaptor_h storage);
111 service_adaptor_error_e storage_adaptor_register_listener(storage_adaptor_h storage, storage_adaptor_listener_h listener);
112 service_adaptor_error_e storage_adaptor_unregister_listener(storage_adaptor_h storage, storage_adaptor_listener_h listener);
113 service_adaptor_error_e storage_adaptor_create_plugin(const char *uri, const char *name, const char *package, storage_plugin_h *plugin);
114 service_adaptor_error_e storage_adaptor_destroy_plugin(storage_plugin_h plugin);
115 service_adaptor_error_e storage_adaptor_register_plugin_service(storage_plugin_h plugin, GHashTable *service);
116 service_adaptor_error_e storage_adaptor_unregister_plugin_service(storage_plugin_h plugin);
117 service_adaptor_error_e storage_adaptor_add_plugin(storage_adaptor_h storage, storage_plugin_h plugin);
118 service_adaptor_error_e storage_adaptor_remove_plugin(storage_adaptor_h storage, storage_plugin_h plugin);
119 storage_plugin_h storage_adaptor_get_plugin(storage_adaptor_h storage, const char *uri);
120 char *storage_adaptor_get_uri(storage_adaptor_h storage, const char *package);
121 service_adaptor_error_e storage_adaptor_ref_plugin(storage_adaptor_h storage, const char *uri);
122 service_adaptor_error_e storage_adaptor_unref_plugin(storage_adaptor_h storage, const char *uri);
123
124 /**
125  * @}
126  */
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif /* __STORAGE_ADAPTOR_H__ */