Add 3.0 APIs and sync APIs same as 2.4
[platform/core/convergence/service-adaptor.git] / adaptor / auth-adaptor / auth_adaptor.h
1 /*
2  * Auth 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 __AUTH_ADAPTOR_H__
21 #define __AUTH_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 #include <glib-object.h>
35 #include <glib-unix.h>
36
37 #include "service_adaptor_errors.h"
38 #include "oauth1_service.h"
39 #include "oauth2_service.h"
40
41 /**
42  * @file auth_adaptor.h
43  */
44
45 /**
46  * @ingroup
47  * @defgroup
48  *
49  * @brief
50  *
51  * @section
52  *  \#include <auth_adaptor.h>
53  *
54  * <BR>
55  * @{
56  */
57
58 #define URI_AUTH        "auth"
59 #define URI_OAUTH1_0    "auth/oauth1.0"
60 #define URI_OAUTH2_0    "auth/oauth2.0"
61
62 /**
63  * @brief Describes infromation about Auth Spec
64  */
65 typedef enum _auth_spec_e
66 {
67         AUTH_SPEC_OAUTH1_0      = (1 << 0),
68         AUTH_SPEC_OAUTH2_0      = (1 << 1),
69 } auth_spec_e;
70
71 /**
72  * @brief Describes infromation about Auth Plugin
73  */
74 typedef struct _auth_plugin_s
75 {
76         char *uri;
77         char *name;
78         char *package;
79
80         oauth1_service_h oauth1;
81         oauth2_service_h oauth2;
82
83         GMutex mutex;
84         GCond cond;
85         int login;
86 } auth_plugin_s;
87 typedef struct _auth_plugin_s *auth_plugin_h;
88
89 /**
90  * @brief Describes infromation about Auth Adaptor
91  */
92 typedef struct _auth_adaptor_s
93 {
94         GList *plugins;         // auth_plugin_h
95
96         GMutex mutex;
97         int start;
98 } auth_adaptor_s;
99 typedef struct _auth_adaptor_s *auth_adaptor_h;
100
101 /**
102  * @brief Describes infromation about Auth Adaptor Listener
103  */
104 typedef struct _auth_adaptor_listener_s
105 {
106         void (*login_cb)(const char *uri, void *user_data);
107 } auth_adaptor_listener_s;
108 typedef struct _auth_adaptor_listener_s *auth_adaptor_listener_h;
109
110 auth_adaptor_h auth_adaptor_create();
111 service_adaptor_error_e auth_adaptor_destroy(auth_adaptor_h auth);
112 service_adaptor_error_e auth_adaptor_start(auth_adaptor_h auth);
113 service_adaptor_error_e auth_adaptor_stop(auth_adaptor_h auth);
114 service_adaptor_error_e auth_adaptor_register_listener(auth_adaptor_h auth, auth_adaptor_listener_h listener);
115 service_adaptor_error_e auth_adaptor_unregister_listener(auth_adaptor_h auth, auth_adaptor_listener_h listener);
116 service_adaptor_error_e auth_adaptor_create_plugin(const char *uri, const char *name, const char *package,  auth_plugin_h *plugin);
117 service_adaptor_error_e auth_adaptor_destroy_plugin(auth_plugin_h plugin);
118 service_adaptor_error_e auth_adaptor_register_plugin_service(auth_plugin_h plugin, GHashTable *service);
119 service_adaptor_error_e auth_adaptor_unregister_plugin_service(auth_plugin_h plugin);
120 service_adaptor_error_e auth_adaptor_add_plugin(auth_adaptor_h auth, auth_plugin_h plugin);
121 service_adaptor_error_e auth_adaptor_remove_plugin(auth_adaptor_h auth, auth_plugin_h plugin);
122 auth_plugin_h auth_adaptor_get_plugin(auth_adaptor_h auth, const char *uri);
123 char *auth_adaptor_get_uri(auth_adaptor_h auth, const char *package);
124 service_adaptor_error_e auth_adaptor_ref_plugin(auth_adaptor_h auth, const char *uri);
125 service_adaptor_error_e auth_adaptor_unref_plugin(auth_adaptor_h auth, const char *uri);
126
127 /**
128  * @}
129  */
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif /* __AUTH_ADAPTOR_H__ */