2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
\r
4 * Licensed under the Apache License, Version 2.0 (the License);
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an AS IS BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
19 #include <privacy_manager.h>
\r
20 #include <privacy_info.h>
\r
21 #include <privacy_manager_client_types.h>
\r
22 #include <privacy_info_client.h>
\r
23 #include <privacy_manager_client.h>
\r
24 #include <privacy_manager_types_private.h>
\r
27 static int _privacy_manager_convert_error(int error)
\r
29 return PRIVACY_MANAGER_ERROR_NONE;
\r
32 typedef struct _foreach_privacy_package_context_
\r
34 privacy_manager_privacy_packages_cb callback;
\r
36 } foreach_privacy_package_context_s;
\r
38 typedef struct _foreach_privacy_info_context_
\r
40 privacy_manager_privacy_info_cb callback;
\r
42 } foreach_privacy_info_context_s;
\r
44 //static int _create_privacy_info(const char* package_id, bool enabled, privacy_info_h *privacy_info)
\r
46 // privacy_info_h temp = (privacy_info_h) calloc(1, sizeof(privacy_info_h));
\r
47 // if (temp == NULL)
\r
48 // return PRIV_MGR_ERROR_OUT_OF_MEMORY;
\r
50 // int size = strlen(package_id);
\r
51 // temp->privacy_info_client->privacy_id = (char*) calloc(1, size + 1);
\r
52 // if (temp->privacy_info_client->privacy_id == NULL)
\r
55 // return PRIV_MGR_ERROR_OUT_OF_MEMORY;
\r
57 // memcpy(temp->privacy_info_client->privacy_id, package_id, size + 1);
\r
59 // temp->privacy_info_client->is_enabled = enabled;
\r
61 // *privacy_info = temp;
\r
63 // return PRIV_MGR_ERROR_SUCCESS;
\r
66 bool __privacy_manager_client_privacy_packages_cb(const char *package_id, void* user_data)
\r
68 foreach_privacy_package_context_s* context = (foreach_privacy_package_context_s*) user_data;
\r
69 return context->callback(package_id, context->user_data);
\r
72 bool __privacy_manager_client_privacy_info_cb (privacy_info_client_s* privacy_info_client, void* user_data)
\r
74 foreach_privacy_info_context_s* context = (foreach_privacy_info_context_s*) user_data;
\r
76 struct privacy_info_s* privacy_info = NULL;
\r
80 privacy_info = (struct privacy_info_s*) calloc(1, sizeof(struct privacy_info_s));
\r
82 privacy_info->privacy_info_client = privacy_info_client;
\r
84 ret = context->callback(privacy_info, context->user_data);
\r
91 int privacy_manager_foreach_privacy_packages(privacy_manager_privacy_packages_cb callback, void *user_data)
\r
95 foreach_privacy_package_context_s* context = NULL;
\r
97 context = (foreach_privacy_package_context_s*) calloc(1, sizeof(foreach_privacy_package_context_s));
\r
98 if (context == NULL)
\r
99 return PRIV_MGR_ERROR_OUT_OF_MEMORY;
\r
101 context->callback = callback;
\r
102 context->user_data = user_data;
\r
104 retval = privacy_manager_client_foreach_privacy_packages(__privacy_manager_client_privacy_packages_cb, context);
\r
107 return _privacy_manager_convert_error(retval);
\r
110 int privacy_manager_foreach_privacy_info(const char *package_id, privacy_manager_privacy_info_cb callback, void* user_data)
\r
114 foreach_privacy_info_context_s* context = NULL;
\r
116 context = (foreach_privacy_info_context_s*) calloc(1, sizeof(foreach_privacy_info_context_s));
\r
117 if (context == NULL)
\r
118 return PRIV_MGR_ERROR_OUT_OF_MEMORY;
\r
120 context->callback = callback;
\r
121 context->user_data = user_data;
\r
123 retval = privacy_manager_client_foreach_get_privacy_info(package_id, __privacy_manager_client_privacy_info_cb, context);
\r
125 return _privacy_manager_convert_error(retval);
\r
127 int privacy_manager_set_package_privacy(const char *package_id, const char *privacy_id, bool enable)
\r
129 int retval = privacy_manager_client_set_package_privacy(package_id, privacy_id, enable);
\r
131 return _privacy_manager_convert_error(retval);
\r