Remove trivial unnecessary build dependency
[apps/core/preloaded/lockscreen.git] / src / sim_ctrl.c
1 /*
2  * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
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 #include "log.h"
18 #include "main_view.h"
19 #include "sim.h"
20
21 static Ecore_Event_Handler *handler;
22 static Evas_Object *main_view;
23
24 static void _sim_state_view_update()
25 {
26         const char *sim1, *sim2;
27         char buf[128] = {0,};
28
29         sim1 = lockscreen_sim_get_plmn(LOCKSCREEN_PRIMARY_SIM);
30         sim2 = lockscreen_sim_get_plmn(LOCKSCREEN_SECONDARY_SIM);
31
32         if (sim1 && sim2) {
33                 snprintf(buf, sizeof(buf), "%s / %s", sim1, sim2);
34         } else if (sim1) {
35                 snprintf(buf, sizeof(buf), "%s", sim1);
36         } else if (sim2) {
37                 snprintf(buf, sizeof(buf), "%s", sim2);
38         }
39
40         lockscreen_main_view_sim_status_text_set(main_view, buf);
41 }
42
43 static Eina_Bool _sim_status_changed(void *data, int type, void *event_info)
44 {
45         _sim_state_view_update();
46         return EINA_TRUE;
47 }
48
49 int lockscreen_sim_ctrl_init(Evas_Object *view)
50 {
51         if (lockscreen_sim_init()) {
52                 ERR("lockscreen_sim_init failed");
53                 return 1;
54         }
55
56         handler = ecore_event_handler_add(LOCKSCREEN_EVENT_SIM_STATUS_CHANGED, _sim_status_changed, NULL);
57         main_view = view;
58         _sim_state_view_update();
59         return 0;
60 }
61
62 void lockscreen_sim_ctrl_shutdown()
63 {
64         ecore_event_handler_del(handler);
65         lockscreen_sim_shutdown();
66 }