apply FSL license
[apps/core/preloaded/call-setting.git] / src / cst-barring-ime.c
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.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
7   *
8   * http://www.tizenopensource.org/license
9   *
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.
15
16   */
17
18 #include <Elementary.h>
19
20 #include "cst-common.h"
21 #include "cst-common-string.h"
22
23 #include "cst-widget.h"
24 #include "cst-barring-ime.h"
25
26 static Elm_Entry_Filter_Limit_Size limit_filter_data;
27 static Elm_Genlist_Item_Class *itc_ime = NULL;
28
29 int _cst_get_cb_input_password(char *buffer, void *data)
30 {
31         ENTER(_cst_get_cb_input_password);
32         CstUgData_t *ugd = (CstUgData_t *)data;
33         retv_if(!ugd, -1);
34         const char *entry_input;
35         Evas_Object *error;
36         Ecore_IMF_Context *imf_ctx;
37
38         entry_input = elm_entry_entry_get(ugd->dg_entry);
39         retv_if(!entry_input, -1);
40         if (strlen(entry_input) == 0) {
41                 imf_ctx = elm_entry_imf_context_get(ugd->dg_entry);
42                 if (imf_ctx) {
43                         ecore_imf_context_input_panel_hide(imf_ctx);
44                 }
45                 error = _cst_create_error_popup(ugd->nf, CST_ERROR_ENTER_NUMBER);
46                 retv_if(!error, -1);
47                 ugd->popup = error;
48                 evas_object_show(error);
49                 return -1;
50         }
51
52         DBG("IME input string = %s length=%d", entry_input, strlen(entry_input));
53
54         snprintf(buffer, CST_MAX_PHONE_NUMBER_LEN, "%s", entry_input);
55         return strlen(entry_input);
56 }
57
58 static Evas_Object *__cst_gl_icon_get_cb_ime(void *data, Evas_Object *obj, const char *part)
59 {
60         retv_if(data == NULL, NULL);
61         CstUgData_t *ugd = (CstUgData_t *)data;
62
63         if (!strcmp(part, "elm.icon")) {
64                 return _cst_create_ime_editfield(ugd, obj, CST_IME_CALL_BAR, NULL);
65         }
66
67         return NULL;
68 }
69
70 static Evas_Object *__cst_create_cb_ime_genlist(CstUgData_t *ugd)
71 {
72         ENTER(__cst_create_cb_ime_genlist);
73         Elm_Object_Item *item = NULL;
74         Evas_Object *genlist;
75
76         genlist = elm_genlist_add(ugd->nf);
77
78         if (!itc_ime)
79                 itc_ime = elm_genlist_item_class_new();
80
81         itc_ime->item_style = "1icon";
82         itc_ime->func.text_get = NULL;
83         itc_ime->func.content_get = __cst_gl_icon_get_cb_ime;
84         itc_ime->func.state_get = NULL;
85         itc_ime->func.del = NULL;
86
87         item = elm_genlist_item_append(genlist, itc_ime,
88                 (void *)ugd, NULL, ELM_GENLIST_ITEM_NONE,
89                 NULL, NULL);
90         return genlist;
91 }
92
93 Evas_Object *_cst_create_cb_ime(Evas_Object *parent, char *edit_string, void *data)
94 {
95         ENTER(_cst_create_cb_ime);
96         retv_if(NULL == data, NULL);
97         CstUgData_t *ugd = (CstUgData_t *)data;
98
99         Evas_Object *genlist = __cst_create_cb_ime_genlist(ugd);
100         return genlist;
101 }