2 * Copyright 2012 Samsung Electronics Co., Ltd
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
8 * http://www.tizenopensource.org/license
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.
17 #include <Elementary.h>
18 #include <Ecore_Evas.h>
20 #include "minicontrol-internal.h"
21 #include "minicontrol-type.h"
22 #include "minicontrol-viewer.h"
23 #include "minicontrol-log.h"
25 #define MINICTRL_PLUG_DATA_KEY "__minictrl_plug_name"
27 static void _minictrl_plug_server_del(Ecore_Evas *ee)
29 char *svr_name = NULL;
31 svr_name = ecore_evas_data_get(ee, MINICTRL_PLUG_DATA_KEY);
33 ERR("fail to get svr_name");
37 INFO("server - %s is deleted", svr_name);
39 /* send message to remve plug */
40 _minictrl_provider_message_send(MINICTRL_DBUS_SIG_STOP,
42 MINICONTROL_PRIORITY_LOW);
45 static void _minictrl_plug_del(void *data, Evas *e,
46 Evas_Object *obj, void *event_info)
48 Ecore_Evas *ee = NULL;
49 char *svr_name = NULL;
51 ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
55 svr_name = ecore_evas_data_get(ee, MINICTRL_PLUG_DATA_KEY);
59 ecore_evas_data_set(ee, MINICTRL_PLUG_DATA_KEY, NULL);
63 Evas_Object *minicontrol_viewer_image_object_get(const Evas_Object *obj)
65 return elm_plug_image_object_get(obj);
68 EXPORT_API Evas_Object *minicontrol_viewer_add(Evas_Object *parent,
71 Evas_Object *plug = NULL;
72 Evas_Object *plug_img = NULL;
73 Ecore_Evas *ee = NULL;
75 plug = elm_plug_add(parent);
77 ERR("fail to create plug");
81 if (!elm_plug_connect(plug, svr_name, 0, EINA_FALSE)) {
82 ERR("Cannot connect plug[%s]", svr_name);
83 evas_object_del(plug);
87 plug_img = elm_plug_image_object_get(plug);
89 ee = ecore_evas_object_ecore_evas_get(plug_img);
90 ecore_evas_data_set(ee, MINICTRL_PLUG_DATA_KEY, strdup(svr_name));
91 ecore_evas_callback_delete_request_set(ee, _minictrl_plug_server_del);
93 evas_object_event_callback_add(plug, EVAS_CALLBACK_DEL,
94 _minictrl_plug_del, plug);