2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include "autofill_private.h"
23 #include <autofill_common.h>
28 #define LOG_TAG "AUTOFILL"
30 EXPORT_API int autofill_fill_response_create(autofill_fill_response_h *h)
33 return AUTOFILL_ERROR_INVALID_PARAMETER;
35 autofill_fill_response_h ri = (autofill_fill_response_h)calloc(1, sizeof(struct autofill_fill_response_s));
37 return AUTOFILL_ERROR_OUT_OF_MEMORY;
39 *h = (autofill_fill_response_h)ri;
41 return AUTOFILL_ERROR_NONE;
44 EXPORT_API int autofill_fill_response_destroy(autofill_fill_response_h h)
47 return AUTOFILL_ERROR_INVALID_PARAMETER;
54 // Release memory autofill fill response item list
55 autofill_fill_response_group_h it_h;
56 EINA_LIST_FREE(h->autofill_fill_response_group_list, it_h)
57 autofill_fill_response_group_destroy(it_h);
61 return AUTOFILL_ERROR_NONE;
64 EXPORT_API int autofill_fill_response_set_app_id(autofill_fill_response_h h, const char *app_id)
67 return AUTOFILL_ERROR_INVALID_PARAMETER;
73 h->app_id = strdup(app_id);
75 return AUTOFILL_ERROR_NONE;
78 EXPORT_API int autofill_fill_response_get_app_id(autofill_fill_response_h h, char **app_id)
81 return AUTOFILL_ERROR_INVALID_PARAMETER;
84 return AUTOFILL_ERROR_OPERATION_FAILED;
86 *app_id = strdup(h->app_id);
88 return AUTOFILL_ERROR_NONE;
91 EXPORT_API int autofill_fill_response_set_view_id(autofill_fill_response_h h, const char *view_id)
94 return AUTOFILL_ERROR_INVALID_PARAMETER;
100 h->view_id = strdup(view_id);
102 return AUTOFILL_ERROR_NONE;
105 EXPORT_API int autofill_fill_response_get_view_id(autofill_fill_response_h h, char **view_id)
108 return AUTOFILL_ERROR_INVALID_PARAMETER;
111 return AUTOFILL_ERROR_OPERATION_FAILED;
113 *view_id = strdup(h->view_id);
115 return AUTOFILL_ERROR_NONE;
118 EXPORT_API int autofill_fill_response_add_group(autofill_fill_response_h h, autofill_fill_response_group_h it)
121 return AUTOFILL_ERROR_INVALID_PARAMETER;
123 autofill_fill_response_group_h clone;
124 autofill_fill_response_group_clone(it, &clone);
126 LOGW("Out of memory");
127 return AUTOFILL_ERROR_OUT_OF_MEMORY;
130 h->autofill_fill_response_group_list = eina_list_append(h->autofill_fill_response_group_list, clone);
132 return AUTOFILL_ERROR_NONE;
135 EXPORT_API int autofill_fill_response_foreach_groups(autofill_fill_response_h h,
136 bool (*callback)(autofill_fill_response_group_h item, void *user_data), void *user_data)
138 if (!h || !callback) {
139 return AUTOFILL_ERROR_INVALID_PARAMETER;
143 autofill_fill_response_group_h it;
144 EINA_LIST_FOREACH(h->autofill_fill_response_group_list, l, it)
146 bool ret = callback(it, user_data);
151 return AUTOFILL_ERROR_NONE;
154 EXPORT_API int autofill_fill_response_get_group_count(autofill_fill_response_h h, int *count)
157 return AUTOFILL_ERROR_INVALID_PARAMETER;
159 *count = eina_list_count(h->autofill_fill_response_group_list);
161 return AUTOFILL_ERROR_NONE;