Tizen release 1.0
[pkgs/p/phone-lock.git] / phone-lock-common / src / phone-lock-gadget.c
1 /*
2  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved 
3  *
4  * This file is part of <phone-lock>
5  * Written by <Seungtaek Chung> <seungtaek.chung@samsung.com>, <Mi-Ju Lee> <miju52.lee@samsung.com>, <Xi Zhichan> <zhichan.xi@samsung.com>
6  *
7  * PROPRIETARY/CONFIDENTIAL
8  *
9  * This software is the confidential and proprietary information of SAMSUNG ELECTRONICS ("Confidential Information").
10  * You shall not disclose such Confidential Information and shall use it only in accordance
11  * with the terms of the license agreement you entered into with SAMSUNG ELECTRONICS.
12  * SAMSUNG make no representations or warranties about the suitability of the software,
13  * either express or implied, including but not limited to the implied warranties of merchantability,
14  * fitness for a particular purpose, or non-infringement.
15  * SAMSUNG shall not be liable for any damages suffered by licensee as a result of using,
16  * modifying or distributing this software or its derivatives.
17  *
18  */
19
20 #include <ui-gadget-module.h>
21 #include <bundle.h>
22
23 #include "phone-lock-gadget.h"
24 #include "phone-lock-util.h"
25
26 static phone_lock_gadget_destroy_cb gdestroy_cb = NULL;
27
28 static void
29 _phone_lock_gadget_layout_cb(struct ui_gadget *ug, enum ug_mode mode,
30                              void *priv)
31 {
32         PHONE_LOCK_DBG("%s\n", __FUNCTION__);
33
34         Evas_Object *base;
35         Evas_Object *win;
36
37         if (!ug)
38                 return;
39
40         base = (Evas_Object *) ug_get_layout(ug);
41         win = (Evas_Object *) ug_get_window();
42
43         if (!base) {
44                 PHONE_LOCK_DBG("Error : base layout is null.\n",
45                                  __FUNCTION__);
46                 return;
47         }
48
49         switch (mode) {
50         case UG_MODE_FULLVIEW:
51                 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
52                                                  EVAS_HINT_EXPAND);
53                 elm_win_resize_object_add(win, base);
54                 evas_object_show(base);
55                 break;
56         default:
57                 break;
58         }
59 }
60
61 static void
62 _phone_lock_gadget_result_cb(struct ui_gadget *ug, bundle * result, void *priv)
63 {
64         PHONE_LOCK_DBG("%s\n", __FUNCTION__);
65 }
66
67 static void _phone_lock_gadget_destroy_cb(struct ui_gadget *ug, void *priv)
68 {
69         PHONE_LOCK_DBG("%s\n", __FUNCTION__);
70
71         if (ug) {
72                 gdestroy_cb(priv);
73
74                 ug_destroy(ug);
75         }
76 }
77
78 void *phone_lock_gadget_show_dialer(Evas_Object * win, struct ui_gadget *parent,
79                                     phone_lock_gadget_destroy_cb destroy_cb,
80                                     void *user_data)
81 {
82         PHONE_LOCK_DBG("%s\n", __FUNCTION__);
83
84         bundle *b;
85         struct ui_gadget *ug;
86
87         struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
88         if (!cbs)
89                 return NULL;
90
91         b = bundle_create();
92         bundle_add(b, "emergency_dialer", "emergency");
93
94         cbs->layout_cb = _phone_lock_gadget_layout_cb;
95         cbs->result_cb = _phone_lock_gadget_result_cb;
96         cbs->destroy_cb = _phone_lock_gadget_destroy_cb;
97         cbs->priv = user_data;
98
99         gdestroy_cb = destroy_cb;
100
101         ug = ug_create(parent, "dialer-efl", UG_MODE_FULLVIEW, b, cbs);
102
103         bundle_free(b);
104         free(cbs);
105
106         evas_object_show(win);
107
108         PHONE_LOCK_DBG("%s : win %p\n", __FUNCTION__, win);
109
110         return (void *)ug;
111 }