Tizen 2.0 Release
[framework/system/oma-dm-agent.git] / src / plugins / dm-private / multiapps / src / plugin_interface.c
1 /*
2  * oma-dm-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #include <stdlib.h>
19 #include <string.h>
20 #include <stdio.h>
21 #include <unistd.h>
22 #include <glib.h>
23 #include <glib/gprintf.h>
24 #include <vconf.h>
25
26 /*sync-agent*/
27 #include <sync_agent.h>
28
29 #ifndef EXPORT_API
30 #define EXPORT_API __attribute__ ((visibility("default")))
31 #endif
32
33 #ifndef OMADM_AGENT_LOG
34 #undef LOG_TAG
35 #define LOG_TAG "PLUGIN_MULTIAPPS"
36 #endif
37
38 #define SERVER_NUM                                                                                                              1
39 /*
40 #define  CSC_VCONF_KEY_SYNCMLDM_NBFIELD                                 "db/SyncML/oma-dm-service/DevManagement/NbDevManagement"
41 #define  CSC_VCONF_KEY_SYNCMLDM_ACCNAME                         "db/SyncML/oma-dm-service/DevManagement/%d/AccName"
42 #define  CSC_VCONF_KEY_SYNCMLDM_SERVID                                  "db/SyncML/oma-dm-service/DevManagement/%d/ServID"
43
44 #define ALTER_SYNCMLDM_NBFIELD                                                                  3
45 #define SERVER_NUM                                                                                                              1
46 #define ALTER_SYNCMLDM_ACCNAME                                                          "gcf"
47 #define ALTER_SYNCMLDM_SERVID                                                                   "RSate"
48 */
49
50 #define ROOT    "./Application"
51
52 static sync_agent_get_devinfo_cb func_get_dev_info = 0;
53
54 //static int _get_Index(const char *name);
55 //static char *_get_MO_Value_STR(const char *vconf_key, int nIndex);
56
57 EXPORT_API char **sync_agent_plugin_get_server_id_list(int *server_id_list_cnt)
58 {
59         _EXTERN_FUNC_ENTER;
60 /*
61         char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
62         if (temp_id_list == NULL) {
63                 _EXTERN_FUNC_EXIT;
64                 return 0;
65         }
66
67         int server_idx = _get_Index(ALTER_SYNCMLDM_ACCNAME);
68         char *server_id = _get_MO_Value_STR(CSC_VCONF_KEY_SYNCMLDM_SERVID, server_idx);
69         if (server_id == NULL) {
70                 server_id = strdup(ALTER_SYNCMLDM_SERVID);
71         }
72         *temp_id_list = server_id;
73         *server_id_list_cnt = 1;
74
75         _DEBUG_INFO("server_id = %s\n", server_id);
76         _DEBUG_INFO("server_id_list_cnt = %d\n", *server_id_list_cnt);
77
78         _EXTERN_FUNC_EXIT;
79         return temp_id_list;
80 */
81         *server_id_list_cnt = 1;
82         char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
83         if (temp_id_list == NULL) {
84                 _EXTERN_FUNC_EXIT;
85                 return NULL;
86         }
87         char *server_id = NULL;
88         server_id = strdup("*");
89         *temp_id_list = server_id;
90
91         _DEBUG_INFO("multiapps  server_id = %s\n", server_id);
92         _DEBUG_INFO("multiapps  server_id_list_cnt = %d\n", *server_id_list_cnt);
93
94         _EXTERN_FUNC_EXIT;
95         return temp_id_list;
96 }
97
98 EXPORT_API int sync_agent_plugin_get_mo_value(const char *mo_pull_path, const char *mo_name, char **mo_value)
99 {
100         _EXTERN_FUNC_ENTER;
101
102         retvm_if((mo_pull_path) == NULL, -1, "mo_pull_path is NULL!!");
103         retvm_if((mo_name) == NULL, -1, "mo_name is NULL!!");
104
105         _DEBUG_INFO("mo_name : %s", mo_name);
106         *mo_value = 0;
107
108         _DEBUG_INFO("mo_value : %s", *mo_value);
109         _EXTERN_FUNC_EXIT;
110         return 0;
111 }
112
113 EXPORT_API void sync_agent_plugin_set_function_get_devinfo(sync_agent_get_devinfo_cb func)
114 {
115         _EXTERN_FUNC_ENTER;
116
117         func_get_dev_info = func;
118
119         _EXTERN_FUNC_EXIT;
120 }
121
122 EXPORT_API int sync_agent_plugin_initialize()
123 {
124         _EXTERN_FUNC_ENTER;
125
126         int result = 1;
127
128         _EXTERN_FUNC_EXIT;
129         return result;
130 }
131
132 /*
133 static int _get_Index(const char *name)
134 {
135         _INNER_FUNC_ENTER;
136
137         retvm_if((name) == NULL, -1, "name is NULL!!");
138
139         int acc_count = 0;
140         if (vconf_get_int(CSC_VCONF_KEY_SYNCMLDM_NBFIELD, &acc_count)) {
141                 _DEBUG_TRACE("vconf_get_int FAIL");
142                 //return -1;
143                 acc_count =ALTER_SYNCMLDM_NBFIELD;
144         }
145
146         _DEBUG_TRACE("nAccCount : %d", acc_count);
147
148         int i = 0;
149         for (; i < acc_count; i++) {
150                 char *compare_name = _get_MO_Value_STR(CSC_VCONF_KEY_SYNCMLDM_ACCNAME, i + 1);
151                 if (compare_name == NULL) {
152                         compare_name = ALTER_SYNCMLDM_ACCNAME;
153                 }
154                 _DEBUG_TRACE("[%d] compare_name : %s [%d], name : %s [%d]", i, compare_name, strlen(compare_name), name, strlen(name));
155                 if (!strcmp(name, compare_name)) {
156                         _DEBUG_TRACE("nIndex : %d", i + 1);
157                         _INNER_FUNC_EXIT;
158                         return i + 1;
159                 }
160         }
161
162         _INNER_FUNC_EXIT;
163         return -1;
164 }
165
166 static char *_get_MO_Value_STR(const char *vconf_key, int nIndex)
167 {
168         _INNER_FUNC_ENTER;
169
170         retvm_if((vconf_key) == NULL, NULL, "vconf_key is NULL!!");
171
172         if (nIndex == -1) {
173                 _INNER_FUNC_EXIT;
174                 return 0;
175         }
176
177         char input_vconf_path[200] = { 0, };
178         char rec_idx[8];
179
180         memset(rec_idx, 0x0, sizeof(rec_idx));
181         snprintf(rec_idx, sizeof(rec_idx), "%d", nIndex);
182         snprintf(input_vconf_path, strlen(vconf_key) + strlen(rec_idx) + 1, vconf_key, nIndex);
183
184         char *value = vconf_get_str(input_vconf_path);
185         if (value == NULL) {
186                 _DEBUG_TRACE("vconf_get_str FAIL");
187         }
188
189         _INNER_FUNC_EXIT;
190         return value;
191 }
192 */