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);
43 _minictrl_provider_proc_send(MINICONTROL_DBUS_PROC_INCLUDE);
46 static void _minictrl_plug_del(void *data, Evas *e,
47 Evas_Object *obj, void *event_info)
49 Ecore_Evas *ee = NULL;
50 char *svr_name = NULL;
52 ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
56 svr_name = ecore_evas_data_get(ee, MINICTRL_PLUG_DATA_KEY);
60 ecore_evas_data_set(ee, MINICTRL_PLUG_DATA_KEY, NULL);
64 Evas_Object *minicontrol_viewer_image_object_get(const Evas_Object *obj)
66 return elm_plug_image_object_get(obj);
69 EXPORT_API Evas_Object *minicontrol_viewer_add(Evas_Object *parent,
72 Evas_Object *plug = NULL;
73 Evas_Object *plug_img = NULL;
74 Ecore_Evas *ee = NULL;
76 plug = elm_plug_add(parent);
78 ERR("fail to create plug");
82 if (!elm_plug_connect(plug, svr_name, 0, EINA_TRUE)) {
83 ERR("Cannot connect plug[%s]", svr_name);
84 evas_object_del(plug);
88 plug_img = elm_plug_image_object_get(plug);
90 ee = ecore_evas_object_ecore_evas_get(plug_img);
91 ecore_evas_data_set(ee, MINICTRL_PLUG_DATA_KEY, strdup(svr_name));
92 ecore_evas_callback_delete_request_set(ee, _minictrl_plug_server_del);
94 evas_object_event_callback_add(plug, EVAS_CALLBACK_DEL,
95 _minictrl_plug_del, plug);
100 EXPORT_API minicontrol_error_e minicontrol_viewer_request(const char *appid, minicontrol_request_e request, int value)
102 int ret = MINICONTROL_ERROR_NONE;
105 ERR("appid is NULL, invaild parameter");
106 return MINICONTROL_ERROR_INVALID_PARAMETER;
108 if (request != MINICONTROL_REQ_ROTATE_PROVIDER
109 && request != MINICONTROL_REQ_PROVIDER_PAUSE
110 && request != MINICONTROL_REQ_PROVIDER_RESUME) {
111 return MINICONTROL_ERROR_INVALID_PARAMETER;
114 ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_REQUEST,
115 appid, request, value, MINICONTROL_PRIORITY_MIDDLE);