1 /**************************************************************************
3 eom (external output manager)
5 Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
8 SooChan Lim <sc1.lim@samsung.com>
9 Boram Park <boram1288.park@samsung.com>
10 Changyeon Lee <cyeon.lee@samsung.com>
12 Permission is hereby granted, free of charge, to any person obtaining a
13 copy of this software and associated documentation files (the
14 "Software"), to deal in the Software without restriction, including
15 without limitation the rights to use, copy, modify, merge, publish,
16 distribute, sub license, and/or sell copies of the Software, and to
17 permit persons to whom the Software is furnished to do so, subject to
18 the following conditions:
20 The above copyright notice and this permission notice (including the
21 next paragraph) shall be included in all copies or substantial portions
24 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
27 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
28 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 **************************************************************************/
39 #include "eom-connect.h"
40 #include "eom-private.h"
43 eom_output_set_mode(eom_output_id output_id, eom_output_mode_e mode)
46 GValueArray *msg_array;
47 GValueArray *ret_array;
48 GValue v = G_VALUE_INIT;
50 RETV_IF_FAIL(mode < EOM_OUTPUT_MODE_MAX, EOM_ERROR_INVALID_PARAMETER);
54 INFO("mode: %d\n", mode);
56 msg_array = g_value_array_new(0);
58 g_value_init(&v, G_TYPE_INT);
59 g_value_set_int(&v, output_id);
60 msg_array = g_value_array_append(msg_array, &v);
61 g_value_set_int(&v, mode);
62 msg_array = g_value_array_append(msg_array, &v);
64 ret_array = eom_dbus_client_send_message("SetMode", msg_array);
65 g_value_array_free(msg_array);
68 return EOM_ERROR_MESSAGE_SENDING_FAILURE;
71 ret = g_value_get_int(g_value_array_get_nth(ret_array, 0));
73 g_value_array_free(ret_array);
75 INFO("SetMode: %s", (ret) ? "success" : "failed");
79 return (ret) ? EOM_ERROR_NONE : EOM_ERROR_MESSAGE_OPERATION_FAILURE;
83 _eom_dbus_convert_gvalue_to_message_temp(GArray *array, DBusMessage *msg)
96 dbus_message_iter_init_append(msg, &iter);
98 INFO("[EOM_CLIENT:%s] len(%d)", client_info.name, array->len);
100 for (i = 0; i < array->len; i++) {
101 v = &g_array_index(array, GValue, i);
104 INFO("[EOM_CLIENT:%s] type(%d)", client_info.name, (int)type);
109 int integer = g_value_get_int(v);
111 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &integer)) {
112 ERR("[EOM_CLIENT:%s] failed: int append", client_info.name);
119 unsigned int uinteger = g_value_get_uint(v);
121 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &uinteger)) {
122 ERR("[EOM_CLIENT:%s] failed: uint append", client_info.name);
129 char *string = (char *)g_value_get_string(v);
131 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, (void *)&string)) {
132 ERR("[EOM_CLIENT:%s] failed: uint append", client_info.name);
139 GVariant *variant = g_value_get_variant(v);
140 int data_size = g_variant_get_size(variant);
141 void *data = (void *)g_variant_get_data(variant);
144 RETV_IF_FAIL(data != NULL, 0);
145 RETV_IF_FAIL(data_size > 0, 0);
147 dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "y", &sub);
148 if (!dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, (void *)&data, data_size)) {
149 ERR("[EOM_CLIENT:%s] failed: uint append", client_info.name);
152 dbus_message_iter_close_container(&iter, &sub);
164 _eom_dbus_convert_message_to_gvalue_temp(DBusMessage *msg)
167 DBusMessageIter iter;
169 if (!dbus_message_iter_init(msg, &iter))
172 array = g_array_new(FALSE, FALSE, sizeof(GValue));
175 int type = dbus_message_iter_get_arg_type(&iter);
176 GValue v = G_VALUE_INIT;
178 INFO("[EOM_CLIENT:%s] type(%c(%d))", client_info.name, (char)type, type);
181 case DBUS_TYPE_INT32:
184 dbus_message_iter_get_basic(&iter, &integer);
185 g_value_init(&v, G_TYPE_INT);
186 g_value_set_int(&v, integer);
187 array = g_array_append_val(array, v);
191 case DBUS_TYPE_UINT32:
193 unsigned int uinteger = 0;
194 dbus_message_iter_get_basic(&iter, &uinteger);
195 g_value_init(&v, G_TYPE_UINT);
196 g_value_set_uint(&v, uinteger);
197 array = g_array_append_val(array, v);
201 case DBUS_TYPE_STRING:
204 dbus_message_iter_get_basic(&iter, &string);
205 g_value_init(&v, G_TYPE_STRING);
206 g_value_set_string(&v, string);
207 array = g_array_append_val(array, v);
213 g_array_free(array, FALSE);
216 } while (dbus_message_iter_has_next(&iter) && dbus_message_iter_next(&iter));