[maemo-commits] [maemo-commits] r8664 - in projects/haf/trunk/libosso: debian src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Dec 7 12:54:56 EET 2006
- Previous message: [maemo-commits] r8663 - projects/haf/trunk/hildon-theme-layout-2/data
- Next message: [maemo-commits] r8665 - in projects/haf/trunk/maemo-af-desktop: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kihamala Date: 2006-12-07 12:54:55 +0200 (Thu, 07 Dec 2006) New Revision: 8664 Modified: projects/haf/trunk/libosso/debian/changelog projects/haf/trunk/libosso/src/muali.h projects/haf/trunk/libosso/src/osso-hw.c Log: muali_set_event_handler split to two functions Modified: projects/haf/trunk/libosso/debian/changelog =================================================================== --- projects/haf/trunk/libosso/debian/changelog 2006-12-07 09:48:42 UTC (rev 8663) +++ projects/haf/trunk/libosso/debian/changelog 2006-12-07 10:54:55 UTC (rev 8664) @@ -10,6 +10,8 @@ optional. Fixes: MB#824 * Added super-cool syslog-logging and stderr-logging configure options. * Added libosso1-doc documentation package (and dependency to doxygen). + * Split muali_set_event_handler to two functions to make API more easy + to use. -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> Thu, 09 Nov 2006 18:46:08 +0200 Modified: projects/haf/trunk/libosso/src/muali.h =================================================================== --- projects/haf/trunk/libosso/src/muali.h 2006-12-07 09:48:42 UTC (rev 8663) +++ projects/haf/trunk/libosso/src/muali.h 2006-12-07 10:54:55 UTC (rev 8664) @@ -144,11 +144,8 @@ * This function registers a handler for event, message, or signal. * * @param context Muali context. - * @param info Structure specifying the type of events to handle, - * or #NULL if the event_type argument is provided. - * Providing this or the event_type argument is mandatory. - * @param event_type Specifies the event to handle. Providing this or - * the info argument is mandatory. + * @param event_type Specifies the event to handle (should be one of the + * MUALI_EVENT_* values). * @param handler The handler function to call when the event happens. * @param user_data Optional user data to pass to the handler when it * is called. @@ -158,13 +155,31 @@ * @return #MUALI_ERROR_SUCCESS on success. */ muali_error_t muali_set_event_handler(muali_context_t *context, - const muali_event_info_t *info, int event_type, muali_handler_t *handler, void *user_data, int *handler_id); /** + * This function registers a handler for event, message, or signal. + * + * @param context Muali context. + * @param info Structure specifying the type of events to handle. + * @param handler The handler function to call when the event happens. + * @param user_data Optional user data to pass to the handler when it + * is called. + * @param handler_id Return location for the handler ID, which is used + * to unregister the handler. + * + * @return #MUALI_ERROR_SUCCESS on success. + */ +muali_error_t muali_set_event_handler_custom(muali_context_t *context, + const muali_event_info_t *info, + muali_handler_t *handler, + void *user_data, + int *handler_id); + +/** * This function unregisters a handler for event, message, or signal. * * @param context Muali context. Modified: projects/haf/trunk/libosso/src/osso-hw.c =================================================================== --- projects/haf/trunk/libosso/src/osso-hw.c 2006-12-07 09:48:42 UTC (rev 8663) +++ projects/haf/trunk/libosso/src/osso-hw.c 2006-12-07 10:54:55 UTC (rev 8664) @@ -854,7 +854,6 @@ } muali_error_t muali_set_event_handler(muali_context_t *context, - const muali_event_info_t *info, int event_type, muali_handler_t *handler, void *user_data, @@ -874,40 +873,13 @@ return MUALI_ERROR_INVALID; } - if (info == NULL && event_type == 0) { - ULOG_ERR_F("info or event_type must be provided"); + if (event_type == MUALI_EVENT_NONE) { + ULOG_ERR_F("event_type must be provided"); return MUALI_ERROR_INVALID; } new_handler_id = context->next_handler_id++; - if (info != NULL) { - muali_error_t ret; - - event_cb = generic_signal_handler; - - ret = compose_match(info, &match); - ULOG_DEBUG_F("match='%s'", match); - - if (ret == MUALI_ERROR_SUCCESS) { - error = _set_handler(context, - info->service, - info->path, - info->interface, - info->name, - match, - event_cb, - 0, /* event_type ignored */ - handler, - user_data, - new_handler_id); - } else { - error = ret; - } - *handler_id = new_handler_id; - return error; - } - switch (event_type) { case MUALI_EVENT_LOWMEM_BOTH: case MUALI_EVENT_LOWMEM_OFF: @@ -975,6 +947,62 @@ ULOG_ERR_F("unknown event type %d", event_type); error = MUALI_ERROR_INVALID; } - *handler_id = new_handler_id; + + if (handler_id != NULL) { + *handler_id = new_handler_id; + } return error; } + +muali_error_t muali_set_event_handler_custom(muali_context_t *context, + const muali_event_info_t *info, + muali_handler_t *handler, + void *user_data, + int *handler_id) +{ + muali_error_t error = MUALI_ERROR_SUCCESS; + _osso_handler_f *event_cb = NULL; + char *match = NULL; + int new_handler_id; + muali_error_t ret; + + ULOG_DEBUG_F("entered"); + + if (context == NULL || handler == NULL) { + ULOG_ERR_F("invalid arguments"); + return MUALI_ERROR_INVALID; + } + + if (info == NULL) { + ULOG_ERR_F("info structure must be provided"); + return MUALI_ERROR_INVALID; + } + + new_handler_id = context->next_handler_id++; + + event_cb = generic_signal_handler; + + ret = compose_match(info, &match); + ULOG_DEBUG_F("match='%s'", match); + + if (ret == MUALI_ERROR_SUCCESS) { + error = _set_handler(context, + info->service, + info->path, + info->interface, + info->name, + match, + event_cb, + 0, /* event_type ignored */ + handler, + user_data, + new_handler_id); + } else { + error = ret; + } + + if (handler_id != NULL) { + *handler_id = new_handler_id; + } + return error; +}
- Previous message: [maemo-commits] r8663 - projects/haf/trunk/hildon-theme-layout-2/data
- Next message: [maemo-commits] r8665 - in projects/haf/trunk/maemo-af-desktop: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]