* 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.
+ * limitations under the License.
*/
int device_get_brightness(int display_index, int *brightness);
/**
- * @brief Sets the display brightness value.
+ * @brief Sets the display brightness value.
*
* @param[in] display_index The index of the display, it be greater than or equal to 0 and less than \n
* the number of displays returned by device_get_display_numbers().\n
* The index zero is always assigned to the main display.
* @param[in] brightness The new brightness value to set \n
* The maximum value can be represented by device_get_max_brightness()
- *
+ *
* @return 0 on success, otherwise a negative error value.
* @retval #DEVICE_ERROR_NONE Successful
* @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
int device_set_brightness(int display_index, int brightness);
/**
- * @brief Gets the maximum brightness value that can be set.
+ * @brief Gets the maximum brightness value that can be set.
*
* @param[in] display_index The index of the display, it be greater than or equal to 0 and less than \n
* the number of displays returned by device_get_display_numbers().\n
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+
+#ifndef __TIZEN_SYSTEM_LED_INTERNAL_H__
+#define __TIZEN_SYSTEM_LED_INTERNAL_H__
+
+
+#include "device-error.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @brief Gets the total number of LEDs in the device.
+ * @since_tizen @if MOBILE 5.0 @elseif WEARABLE 5.0 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/led
+ * @remarks This API is related to the following feature: %http://tizen.org/feature/led
+ * @param[out] Number of LEDs
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ */
+int device_multi_led_get_number(int *num_of_leds);
+
+/**
+ * @brief Plays multiple LEDs at the same time.
+ * @since_tizen @if MOBILE 5.0 @elseif WEARABLE 5.0 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/led
+ * @remarks This API is related to the following feature: %http://tizen.org/feature/led
+ * @remarks The array size must be the same as the number of LEDs, which is obtained by device_multi_led_get_number().
+ * @param[in] led[] Indicate LEDs to be controlled
+ * @param[in] color[] The Color values \n
+ * The first byte means opaque, and the other 3 bytes mean RGB values
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ */
+int device_multi_led_play_custom(bool led[], unsigned int color[]);
+
+/**
+ * @brief Stops multiple LEDs at the same time.
+ * @since_tizen @if MOBILE 5.0 @elseif WEARABLE 5.0 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/led
+ * @remarks This API is related to the following feature: %http://tizen.org/feature/led
+ * @remarks The array size must be the same as the number of LEDs, which is obtained by device_multi_led_get_number().
+ * @param[in] led[] Indicate LEDs to be controlled
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ */
+int device_multi_led_stop_custom(bool led[]);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // __TIZEN_SYSTEM_LED_INTERNAL_H__
free(profileName);
return profile;
-}
\ No newline at end of file
+}
return result;
}
+int dbus_method_sync_var(const char *dest, const char *path,
+ const char *interface, const char *method, GVariant *var)
+{
+ GDBusProxy *proxy;
+ GError *err = NULL;
+ GVariant *output;
+ int result;
+
+#if !GLIB_CHECK_VERSION(2, 35, 0)
+ g_type_init();
+#endif
+
+ pthread_mutex_lock(&dmutex);
+ proxy = get_proxy_from_proxy_pool(dest, path, interface, &err);
+ if (!proxy) {
+//LCOV_EXCL_START System Error
+ pthread_mutex_unlock(&dmutex);
+ _E("fail to get proxy from proxy pool : %s-%s (%d-%s)",
+ interface, method, err->code, err->message);
+ result = g_dbus_error_to_errno(err->code);
+ g_clear_error(&err);
+ return result;
+//LCOV_EXCL_STOP
+ }
+
+ output = g_dbus_proxy_call_sync(proxy,
+ method, /* method name */
+ var, /* parameters */
+ G_DBUS_CALL_FLAGS_NONE,
+ DBUS_REPLY_TIMEOUT, /* timeout */
+ NULL, /* GCancellable */
+ &err);
+ pthread_mutex_unlock(&dmutex);
+
+ if (!output) {
+//LCOV_EXCL_START System Error
+ if (!err) {
+ _E("g_dbus_proxy_call_sync error : %s-%s",
+ interface, method);
+ return -EPERM;
+ }
+ _E("g_dbus_proxy_call_sync error : %s-%s (%d-%s)",
+ interface, method, err->code, err->message);
+ result = g_dbus_error_to_errno(err->code);
+ g_clear_error(&err);
+ return result;
+//LCOV_EXCL_STOP
+ }
+
+ /* get output value */
+ g_variant_get(output, "(i)", &result);
+
+ g_variant_unref(output);
+
+ return result;
+}
+
int dbus_method_sync_with_reply(const char *dest,
const char *path, const char *interface,
const char *method, const char *sig,
const char *path, const char *interface,
const char *method, const char *sig,
char *param[], GVariant **info);
+int dbus_method_sync_var(const char *dest, const char *path,
+ const char *iface, const char *method, GVariant *var);
/**
* If result is NULL, err is set.
#include <system_info.h>
#include "led.h"
+#include "led-internal.h"
#include "common.h"
#include "dbus.h"
#define METHOD_GET_MAX_BRIGHTNESS "GetMaxBrightness"
#define METHOD_GET_BRIGHTNESS "GetBrightness"
#define METHOD_SET_BRIGHTNESS "SetBrightness"
-#define METHOD_PLAY_CUSTOM "playcustom"
-#define METHOD_STOP_CUSTOM "stopcustom"
+#define METHOD_PLAY_CUSTOM "playcustom"
+#define METHOD_GET_LED_NUMBER "GetNumOfLeds"
+#define METHOD_MULTI_PLAY_CUSTOM "multi_playcustom"
+#define METHOD_MULTI_STOP_CUSTOM "multi_stopcustom"
+#define METHOD_STOP_CUSTOM "stopcustom"
#define FRONT_LED_FEATURE "tizen.org/feature/led"
#define CAMERA_LED_FEATURE "tizen.org/feature/camera.back.flash"
static bool support_front_led;
static bool support_camera_led;
+static int number_of_devices;
static void __CONSTRUCTOR__ init(void)
{
return DEVICE_ERROR_NONE;
}
+
+int device_multi_led_get_number(int *num_of_leds)
+{
+ int ret;
+
+ if (!support_front_led)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
+ if (!num_of_leds)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ ret = dbus_method_sync(DEVICED_BUS_NAME,
+ DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
+ METHOD_GET_LED_NUMBER, NULL, NULL);
+ if (ret < 0)
+ return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
+
+ *num_of_leds = ret;
+ number_of_devices = ret;
+ return DEVICE_ERROR_NONE;
+}
+
+int device_multi_led_play_custom(bool led[], unsigned int color[])
+{
+ GVariantBuilder *builder = NULL;
+ GVariant *var = NULL;
+ int i;
+
+ if (!support_front_led)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
+ if (led == NULL || color == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a(bu)"));
+ for (i = 0; i < number_of_devices; i++)
+ g_variant_builder_add(builder, "(bu)", led[i], color[i]);
+
+ var = g_variant_new("(a(bu))", builder);
+ g_variant_builder_unref(builder);
+
+ return dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_LED,
+ DEVICED_INTERFACE_LED, METHOD_MULTI_PLAY_CUSTOM, var);
+
+}
+
+int device_multi_led_stop_custom(bool led[])
+{
+ GVariantBuilder *builder = NULL;
+ GVariant *var = NULL;
+ int ret, i;
+
+ if (!support_front_led)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("ab"));
+ for (i = 0 ; i < number_of_devices; i++)
+ g_variant_builder_add(builder, "b", led[i]);
+
+ var = g_variant_new("(ab)", builder);
+ g_variant_builder_unref(builder);
+
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
+ DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
+ METHOD_MULTI_STOP_CUSTOM, var);
+ //LCOV_EXCL_START System Error
+ if (ret < 0)
+ return errno_to_device_error(ret);
+ //LCOV_EXCL_STOP
+
+ return DEVICE_ERROR_NONE;
+}