summaryrefslogtreecommitdiff
path: root/home/src/minictrl_util.c
blob: 35a583c0b66e468ce6de8221a64cab6b58989ef8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
 * Samsung API
 * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/license/
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <Elementary.h>
#include <Evas.h>
#include <stdbool.h>
#include <glib.h>
#include <aul.h>
#include <vconf.h>
#include <minicontrol-viewer.h>
#include <minicontrol-monitor.h>
#include <minicontrol-handler.h>
#include <efl_assist.h>
#include <dlog.h>

#include "conf.h"
#include "layout.h"
#include "log.h"
#include "util.h"
#include "main.h"
#include "page_info.h"
#include "scroller_info.h"
#include "page.h"
#include "scroller.h"
#include "minictrl.h"

HAPI char *minicontrol_appid_get_by_pid(int pid)
{
	int ret = AUL_R_OK;
	char *dup_pkgname = NULL;
	char pkgname[512 + 1] = { 0, };

	ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname));
	if (ret == AUL_R_OK) {
		if (strlen(pkgname) <= 0) {
			return NULL;
		}
	}

	dup_pkgname = strdup(pkgname);
	if (!dup_pkgname) {
		_E("Failed to dup string");
	}

	return dup_pkgname;
}

HAPI void minicontrol_magic_set(Evas_Object *obj) {
	if (obj != NULL) {
		evas_object_data_set(obj, MINICTRL_DATA_KEY_MAGIC, (void *)MINICONTROL_MAGIC);
	}
}

HAPI int minicontrol_magic_get(Evas_Object *obj) {
	if (obj != NULL) {
		return (int)evas_object_data_get(obj, MINICTRL_DATA_KEY_MAGIC);
	}

	return 0x0;
}

HAPI void minicontrol_name_set(Evas_Object *obj, const char *name) {
	char *name_old = NULL;

	name_old = evas_object_data_get(obj, MINICTRL_DATA_KEY_NAME);
	if (name_old != NULL) {
		evas_object_data_del(obj, MINICTRL_DATA_KEY_NAME);
		free(name_old);
	}

	if (obj != NULL && name != NULL) {
		evas_object_data_set(obj, MINICTRL_DATA_KEY_NAME, (void *)strdup(name));
	}
}

HAPI char *minicontrol_name_get(Evas_Object *obj) {
	if (obj != NULL) {
		return (char *)evas_object_data_get(obj, MINICTRL_DATA_KEY_NAME);
	}

	return NULL;
}

HAPI void minicontrol_category_set(Evas_Object *obj, int category) {
	if (obj != NULL) {
		evas_object_data_set(obj, MINICTRL_DATA_KEY_CATEGORY, (void *)category);
	}
}

HAPI int minicontrol_category_get(Evas_Object *obj) {
	if (obj != NULL) {
		return (int)evas_object_data_get(obj, MINICTRL_DATA_KEY_CATEGORY);
	}

	return 0;
}

HAPI void minicontrol_pid_set(Evas_Object *obj, int pid) {
	if (obj != NULL) {
		evas_object_data_set(obj, MINICTRL_DATA_KEY_PID, (void *)pid);
	}
}

HAPI int minicontrol_pid_get(Evas_Object *obj) {
	if (obj != NULL) {
		return (int)evas_object_data_get(obj, MINICTRL_DATA_KEY_PID);
	}

	return 0;
}

HAPI void minicontrol_visibility_set(Evas_Object *obj, int visibility) {
	if (obj != NULL) {
		evas_object_data_set(obj, MINICTRL_DATA_KEY_VISIBILITY, (void *)visibility);
	}
}

HAPI int minicontrol_visibility_get(Evas_Object *obj) {
	if (obj != NULL) {
		return (int)evas_object_data_get(obj, MINICTRL_DATA_KEY_VISIBILITY);
	}

	return 0;
}

HAPI int minicontrol_message_send(Evas_Object *minictrl, char *message)
{
	Ecore_Evas *ee = NULL;
	Evas_Object *plug_img = NULL;
	retv_if(message == NULL, 0);
	retv_if(minictrl == NULL, 0);

	plug_img = elm_plug_image_object_get(minictrl);
	retv_if(plug_img == NULL, 0);
	ee = ecore_evas_object_ecore_evas_get(plug_img);
	retv_if(ee == NULL, 0);
	ecore_evas_msg_parent_send(ee, 0, 0, message, strlen(message) + 1);

	return 1;
}