[maemo-commits] [maemo-commits] r10656 - projects/haf/trunk/libosso/src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Mar 20 16:57:31 EET 2007
- Previous message: [maemo-commits] r10655 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r10657 - projects/haf/trunk/libosso/src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kihamala Date: 2007-03-20 16:57:30 +0200 (Tue, 20 Mar 2007) New Revision: 10656 Added: projects/haf/trunk/libosso/src/osso-display.c projects/haf/trunk/libosso/src/osso-display.h Modified: projects/haf/trunk/libosso/src/Makefile.am projects/haf/trunk/libosso/src/Makefile.in Log: added osso_hw_display* implementation Modified: projects/haf/trunk/libosso/src/Makefile.am =================================================================== --- projects/haf/trunk/libosso/src/Makefile.am 2007-03-20 14:48:24 UTC (rev 10655) +++ projects/haf/trunk/libosso/src/Makefile.am 2007-03-20 14:57:30 UTC (rev 10656) @@ -38,6 +38,8 @@ osso-time.h \ osso-locale.c \ osso-locale.h \ + osso-display.c \ + osso-display.h \ osso-application-init.c \ osso-mem.h \ osso-mem.c \ Modified: projects/haf/trunk/libosso/src/Makefile.in =================================================================== --- projects/haf/trunk/libosso/src/Makefile.in 2007-03-20 14:48:24 UTC (rev 10655) +++ projects/haf/trunk/libosso/src/Makefile.in 2007-03-20 14:57:30 UTC (rev 10656) @@ -58,7 +58,8 @@ osso-application-top.lo osso-application-autosave.lo \ osso-hw.lo osso-mime.lo osso-system-note.lo osso-rpc.lo \ osso-statusbar.lo osso-cp-plugin.lo osso-log.lo osso-time.lo \ - osso-locale.lo osso-application-init.lo osso-mem.lo + osso-locale.lo osso-display.lo osso-application-init.lo \ + osso-mem.lo libosso_la_OBJECTS = $(am_libosso_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -67,6 +68,7 @@ @AMDEP_TRUE@ ./$(DEPDIR)/osso-application-init.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/osso-application-top.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/osso-cp-plugin.Plo \ + at AMDEP_TRUE@ ./$(DEPDIR)/osso-display.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/osso-hw.Plo ./$(DEPDIR)/osso-init.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/osso-locale.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/osso-log.Plo ./$(DEPDIR)/osso-mem.Plo \ @@ -244,6 +246,8 @@ osso-time.h \ osso-locale.c \ osso-locale.h \ + osso-display.c \ + osso-display.h \ osso-application-init.c \ osso-mem.h \ osso-mem.c \ @@ -322,6 +326,7 @@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/osso-application-init.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/osso-application-top.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/osso-cp-plugin.Plo at am__quote@ + at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/osso-display.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/osso-hw.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/osso-init.Plo at am__quote@ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/osso-locale.Plo at am__quote@ Added: projects/haf/trunk/libosso/src/osso-display.c =================================================================== --- projects/haf/trunk/libosso/src/osso-display.c 2007-03-20 14:48:24 UTC (rev 10655) +++ projects/haf/trunk/libosso/src/osso-display.c 2007-03-20 14:57:30 UTC (rev 10656) @@ -0,0 +1,123 @@ +/** + * @file osso-display.c + * This file implements functions for catching the MCE display state. + * + * This file is part of libosso + * + * Copyright (C) 2007 Nokia Corporation. All rights reserved. + * + * Contact: Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <osso-display.h> +#include <mce/dbus-names.h> +#include <mce/mode-names.h> + +#define MATCH_RULE \ + "type='signal',interface='" MCE_SIGNAL_IF "',"\ + "member='" MCE_DISPLAY_SIG "'" + +static void _display_state_handler(osso_context_t *osso, + DBusMessage *msg, + _osso_callback_data_t *ot, + muali_bus_type dbus_type); + + +/************************************************************************/ +osso_return_t osso_hw_set_display_event_cb(osso_context_t *osso, + osso_display_event_cb_f *cb, + gpointer data) +{ + _osso_callback_data_t *ot; + DBusError error; + + if (osso == NULL || cb == NULL) { + ULOG_ERR_F("invalid arguments"); + return OSSO_INVALID; + } + if (osso->sys_conn == NULL) { + ULOG_ERR_F("no D-Bus system bus connection"); + return OSSO_INVALID; + } + + ot = calloc(1, sizeof(_osso_callback_data_t)); + if (ot == NULL) { + ULOG_ERR_F("calloc failed"); + return OSSO_ERROR; + } + + dbus_error_init(&error); + dbus_bus_add_match(osso->sys_conn, MATCH_RULE, &error); + if (dbus_error_is_set(&error)) { + ULOG_ERR_F("dbus_bus_add_match() failed: %s", error.message); + dbus_error_free(&error); + return OSSO_ERROR; + } + + ot->user_cb = cb; + ot->user_data = data; + ot->data = MCE_DISPLAY_SIG; + + _msg_handler_set_cb_f_free_data(osso, + NULL, + MCE_SIGNAL_PATH, + MCE_SIGNAL_IF, + _display_state_handler, ot, FALSE); + return OSSO_OK; +} + +/************************************************************************/ +static void _display_state_handler(osso_context_t *osso, + DBusMessage *msg, + _osso_callback_data_t *ot, + muali_bus_type dbus_type) +{ + if (dbus_message_is_signal(msg, MCE_SIGNAL_IF, + (char*)ot->data)) { + osso_display_event_cb_f *handler = ot->user_cb; + char *tmp = NULL; + osso_display_state_t new_state; + DBusMessageIter iter; + + if (!dbus_message_iter_init(msg, &iter)) { + ULOG_ERR_F("Message has no arguments"); + return; + } + if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING) { + dbus_message_iter_get_basic(&iter, &tmp); + } else { + ULOG_ERR_F("Signal has no argument"); + return; + } + + if (strncmp(tmp, MCE_DISPLAY_ON_STRING, + strlen(MCE_DISPLAY_ON_STRING)) == 0) { + new_state = OSSO_DISPLAY_ON; + } else if (strncmp(tmp, MCE_DISPLAY_DIM_STRING, + strlen(MCE_DISPLAY_DIM_STRING)) == 0) { + new_state = OSSO_DISPLAY_DIMMED; + } else if (strncmp(tmp, MCE_DISPLAY_OFF_STRING, + strlen(MCE_DISPLAY_OFF_STRING)) == 0) { + new_state = OSSO_DISPLAY_OFF; + } else { + ULOG_ERR_F("Unknown argument: %s", tmp); + return; + } + + (*handler)(new_state, ot->user_data); + } +} Added: projects/haf/trunk/libosso/src/osso-display.h =================================================================== --- projects/haf/trunk/libosso/src/osso-display.h 2007-03-20 14:48:24 UTC (rev 10655) +++ projects/haf/trunk/libosso/src/osso-display.h 2007-03-20 14:57:30 UTC (rev 10656) @@ -0,0 +1,32 @@ +/** + * @file osso-display.h + * + * This file is part of libosso + * + * Copyright (C) 2007 Nokia Corporation. All rights reserved. + * + * Contact: Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef OSSO_DISPLAY_H +#define OSSO_DISPLAY_H + +#include "libosso.h" +#include "osso-internal.h" +#include "osso-log.h" + +#endif
- Previous message: [maemo-commits] r10655 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r10657 - projects/haf/trunk/libosso/src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]