+static gint
+flashlight_applet_dbus_request_handler (const gchar *interface,
+ const gchar *method,
+ GArray *arguments,
+ gpointer data,
+ osso_rpc_t *retval)
+{
+ FlashlightPlugin *plugin = data;
+ FlashlightPluginPrivate *priv = FLASHLIGHT_STATUS_PLUGIN_GET_PRIVATE (plugin);
+ gboolean is_open = FALSE;
+
+ g_return_val_if_fail (interface, OSSO_ERROR);
+ g_return_val_if_fail (method, OSSO_ERROR);
+
+ g_return_val_if_fail (priv, OSSO_ERROR);
+ g_return_val_if_fail (priv->hal, OSSO_ERROR);
+ g_return_val_if_fail (priv->button, OSSO_ERROR);
+
+ if (strcmp (interface, FLASHLIGHT_APPLET_IFACE))
+ return OSSO_ERROR;
+
+ is_open = !libhal_device_get_property_bool (priv->hal, CAM_COVER_UDI, CAM_COVER_STATE, NULL);
+
+ if (!strcmp (method, FLASHLIGHT_APPLET_METHOD_ENABLE)) {
+ /* check if cover is open */
+ if (is_open) {
+ /* try to enable flashlight, only if it's disabled */
+ if (!strcmp (hildon_button_get_value (HILDON_BUTTON (priv->button)), MSG_FLASHLIGHT_OFF)) {
+ flashlight_status_plugin_enable (plugin, TRUE);
+ }
+ } else {
+ flashlight_status_plugin_show_notification (plugin, _CAMERAUI ("camera_ia_open_lens_cover"));
+ }
+ } else if (!strcmp (method, FLASHLIGHT_APPLET_METHOD_DISABLE)) {
+ if (is_open) {
+ /* try to disable flashlight, only if it's enabled */
+ if (!strcmp (hildon_button_get_value (HILDON_BUTTON (priv->button)), MSG_FLASHLIGHT_ON)) {
+ flashlight_status_plugin_enable (plugin, FALSE);
+ }
+ }
+ } else {
+ return OSSO_ERROR;
+ }
+
+ return OSSO_OK;
+}
+