dlog
vconf
tts
- capi-system-device
)
FOREACH(flag ${pkgs_CFLAGS})
+++ /dev/null
-#ifndef SMART_NOTIFICATION_H_
-#define SMART_NOTIFICATION_H_
-
-/**
- * @brief Type of notification events.
- *
- * @FOCUS_CHAIN_END_NOTIFICATION_EVENT emitted when
- * currnetly focued widget is the last one
- * in focus chain for application current view.
- *
- * @REALIZED_ITEMS_NOTIFICATION_EVENT
- */
-enum _Notification_Type {
- FOCUS_CHAIN_END_NOTIFICATION_EVENT,
- REALIZED_ITEMS_NOTIFICATION_EVENT,
-};
-
-typedef enum _Notification_Type Notification_Type;
-
-/**
- * @brief Initializes notification submodule.
- *
- * @description
- * Notification submodule is resposnisle for providing
- * voice output to end user when on of following events
- * occur:
- *
- * 1. User starts scrolling active application view.
- * 2. User finished scrolling (and all scrolling related
- * animations has stopped) active application view.
- * 3. When user has navigated to the last widget in focus
- * chain.
- * 4. After scrolling lists, some of item becomes visible
- *
- * @nore
- * 1 and 2 are handled internally by smart navigation submodule.
- * about events 3 and 4 submodule has to be informed by the developer
- * by using smart_notification API.
- */
-void smart_notification_init(void);
-
-/**
- * @brief Notifies smart_notification about UI event.
- *
- * @param nt Type of the occured event.
- * @param start_index Item of the first item that becomes visible
- * after scrolling list widget.
- * @param end_index index of the last item that becomes visible
- * after scrolling list widget.
- *
- * @note start_index and end_index are interpreted only
- * when nt parameter is REALIZED_ITEMS_NOTIFICATION_EVENT
- * @note initializes haptic module.
- */
-void smart_notification(Notification_Type nt, int start_index, int end_index);
-
-/**
- * @brief Shutdowns notification subsystem.
- */
-void smart_notification_shutdown(void);
-
-#endif /* end of include guard: SMART_NOTIFICATION_H_ */
BuildRequires: at-spi2-core-devel
BuildRequires: cmake
BuildRequires: pkgconfig(capi-appfw-application)
-BuildRequires: pkgconfig(capi-system-device)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(bundle)
#include "object_cache.h"
#include "flat_navi.h"
#include "app_tracker.h"
-#include "smart_notification.h"
-#include "screen_reader_system.h"
-#include "screen_reader_haptic.h"
#define QUICKPANEL_DOWN TRUE
#define QUICKPANEL_UP FALSE
{
flat_navi_context_line_first(context);
obj = flat_navi_context_first(context);
- smart_notification(FOCUS_CHAIN_END_NOTIFICATION_EVENT, 0, 0);
}
if (obj)
_current_highlight_object_set(obj);
{
flat_navi_context_line_last(context);
obj = flat_navi_context_last(context);
- smart_notification(FOCUS_CHAIN_END_NOTIFICATION_EVENT, 0, 0);
}
if (obj)
_current_highlight_object_set(obj);
window_tracker_register(on_window_activate, NULL);
window_tracker_active_window_request();
app_tracker_init();
- smart_notification_init();
- system_notifications_init();
keyboard_tracker_init();
keyboard_tracker_register(kb_tracker, NULL);
}
object_cache_shutdown();
app_tracker_shutdown();
window_tracker_shutdown();
- smart_notification_shutdown();
- system_notifications_shutdown();
keyboard_tracker_shutdown();
}
+++ /dev/null
-#include <device/haptic.h>
-#include "logger.h"
-#include "smart_notification.h"
-
-static haptic_device_h handle;
-static haptic_effect_h effect_handle;
-
-#define RED "\x1B[31m"
-#define RESET "\033[0m"
-
-/**
- * @brief Initializer for haptic module
- *
- */
-void haptic_module_init(void)
-{
- int num;
-
- if(!device_haptic_get_count(&num))
- {
- DEBUG(RED"Haptic device received!"RESET);
- }
- else
- {
- ERROR("Cannot receive haptic device count");
- return;
- }
-
- if(!device_haptic_open(0, &handle))
- {
- DEBUG(RED"Device connected!"RESET);
- }
- else
- {
- ERROR("Cannot open haptic device");
- }
-}
-
-/**
- * @brief Disconnect haptic handle
- *
- */
-void haptic_module_disconnect(void)
-{
- if(!handle)
- {
- ERROR("Haptic handle lost");
- return;
- }
- if(!device_haptic_close(handle))
- {
- DEBUG("Haptic disconnected");
- }
- else
- {
- ERROR("Haptic close error");
- }
-}
-
-/**
- * @brief Start vibrations
- *
- */
-void haptic_vibrate_start(void)
-{
- if(!handle)
- {
- ERROR("Haptic handle lost");
- return;
- }
- if(!device_haptic_vibrate(handle, 1000, 100, &effect_handle))
- {
- DEBUG(RED"Vibrations started!"RESET);
- }
- else
- {
- ERROR("Cannot start vibration");
- }
-}
-
-/**
- * @brief Stop vibrations
- *
- */
-void haptic_vibrate_stop(void)
-{
- if(!handle)
- {
- ERROR("Haptic handle lost");
- return;
- }
- if(!device_haptic_stop(handle, &effect_handle))
- {
- ERROR("Vibrations stopped!");
- }
- else
- {
- DEBUG(RED"Cannot stop vibration"RESET);
- }
-}
+++ /dev/null
-#include <device/battery.h>
-#include <device/display.h>
-#include <device/callback.h>
-#include "screen_reader.h"
-#include "screen_reader_tts.h"
-#include "smart_notification.h"
-#include "logger.h"
-
-#define CHARGING "Battery charger connected"
-#define NOT_CHARGING "Battery charger disconnected"
-#define SCREEN_ON "Screen is on"
-#define SCREEN_OFF "Screen is off"
-#define BATTERY_LOW "Battery level is low"
-#define BATTERY_FULL "Battery level is full"
-#define BATTERY_CRITICAL "Battery level is critical"
-
-static void device_system_cb(device_callback_e type, void *value, void *user_data);
-
-/**
- * @brief Initializer for smart notifications
- *
- */
-void system_notifications_init(void)
-{
- // BATTERY LOW/FULL
- device_add_callback(DEVICE_CALLBACK_BATTERY_LEVEL, device_system_cb, NULL);
- // BATTERY CHARGING/NOT-CHARGING
- device_add_callback(DEVICE_CALLBACK_BATTERY_CHARGING, device_system_cb, NULL);
- // SCREEN OFF/ON
- device_add_callback(DEVICE_CALLBACK_DISPLAY_STATE, device_system_cb, NULL);
-}
-
-/**
- * @brief Initializer for smart notifications
- *
- */
-void system_notifications_shutdown(void)
-{
- // BATTERY LOW/FULL
- device_remove_callback(DEVICE_CALLBACK_BATTERY_LEVEL, device_system_cb);
- // BATTERY CHARGING/NOT-CHARGING
- device_remove_callback(DEVICE_CALLBACK_BATTERY_CHARGING, device_system_cb);
- // SCREEN OFF/ON
- device_remove_callback(DEVICE_CALLBACK_DISPLAY_STATE, device_system_cb);
-}
-
-/**
- * @brief Device system callback handler
- *
- * @param type Device callback type
- * @param value UNUSED
- * @param user_data UNUSED
- */
-static void device_system_cb(device_callback_e type, void *value, void *user_data)
-{
- if(type == DEVICE_CALLBACK_BATTERY_LEVEL)
- {
- device_battery_level_e status;
- if(device_battery_get_level_status(&status))
- {
- ERROR("Cannot get battery level status");
- return;
- }
-
- if(status == DEVICE_BATTERY_LEVEL_LOW)
- {
- tts_speak(BATTERY_LOW, TRUE);
- }
- else if(status == DEVICE_BATTERY_LEVEL_CRITICAL)
- {
- tts_speak(BATTERY_CRITICAL, TRUE);
- }
- else if(status == DEVICE_BATTERY_LEVEL_FULL)
- {
- tts_speak(BATTERY_FULL, TRUE);
- }
- }
- else if(type == DEVICE_CALLBACK_BATTERY_CHARGING)
- {
- bool charging;
- if(device_battery_is_charging(&charging))
- {
- ERROR("Cannot check if battery is charging");
- return;
- }
-
- if(charging)
- {
- tts_speak(CHARGING, FALSE);
- }
- else
- {
- tts_speak(NOT_CHARGING, FALSE);
- }
- }
- else if(type == DEVICE_CALLBACK_DISPLAY_STATE)
- {
- display_state_e state;
- if(device_display_get_state(&state))
- {
- ERROR("Cannot check if battery is charging");
- return;
- }
-
- if(state == DISPLAY_STATE_NORMAL)
- {
- tts_speak(SCREEN_ON, FALSE);
- }
- else if(state == DISPLAY_STATE_SCREEN_OFF)
- {
- tts_speak(SCREEN_OFF, FALSE);
- }
- }
-}
+++ /dev/null
-#include <atspi/atspi.h>
-#include <stdio.h>
-#include "logger.h"
-#include "screen_reader_tts.h"
-#include "screen_reader_haptic.h"
-#include "smart_notification.h"
-
-#define RED "\x1B[31m"
-#define RESET "\033[0m"
-
-#define ITEMS_NOTIFICATION "Visible items from %d to %d"
-
-static gboolean status = FALSE;
-
-static void _smart_notification_focus_chain_end(void);
-static void _smart_notification_realized_items(int start_idx, int end_idx);
-
-/**
- * @brief Smart Notifications event handler
- *
- * @param nt Notification event type
- * @param start_index int first visible items index smart_notification_realized_items
- * @param end_index int last visible items index used for smart_notification_realized_items
- */
-void smart_notification(Notification_Type nt, int start_index, int end_index)
-{
- if(!status)
- return;
-
- switch(nt)
- {
- case FOCUS_CHAIN_END_NOTIFICATION_EVENT:
- _smart_notification_focus_chain_end();
- break;
- case REALIZED_ITEMS_NOTIFICATION_EVENT:
- _smart_notification_realized_items(start_index, end_index);
- break;
- default:
- DEBUG("Gesture type %d not handled in switch", nt);
- }
-}
-
-/**
- * @brief Used for getting first and last index of visible items
- *
- * @param scrollable_object AtspiAccessible object on which scroll was triggered
- * @param start_index int first visible items index smart_notification_realized_items
- * @param end_index int last visible items index used for smart_notification_realized_items
- */
-void get_realized_items_count(AtspiAccessible *scrollable_object, int *start_idx, int *end_idx)
-{
- int count_child, jdx;
- AtspiAccessible *child_iter;
- AtspiStateType state = ATSPI_STATE_SHOWING;
-
- if(!scrollable_object)
- {
- DEBUG("No scrollable object");
- return;
- }
-
- count_child = atspi_accessible_get_child_count(scrollable_object, NULL);
-
- for(jdx = 0; jdx < count_child; jdx++)
- {
- child_iter = atspi_accessible_get_child_at_index(scrollable_object, jdx, NULL);
-
- AtspiStateSet* state_set = atspi_accessible_get_state_set(child_iter);
-
- gboolean is_visible = atspi_state_set_contains(state_set, state);
- if(is_visible)
- {
- *start_idx = jdx;
- DEBUG("Item with index %d is visible", jdx);
- }
- else
- DEBUG("Item with index %d is NOT visible", jdx);
- }
- *end_idx = *start_idx + 8;
-}
-
-/**
- * @brief Scroll-start/Scroll-end event callback
- *
- * @param event AtspiEvent
- * @param user_data UNUSED
- */
-static void
-_scroll_event_cb(AtspiEvent *event, void *user_data)
-{
- if(!status)
- return;
-
- int start_index, end_index;
- start_index = 0;
- end_index = 0;
-
- DEBUG("Event: %s: %d, obj: %p: role: %s\n", event->type, event->detail1, event->source,
- atspi_accessible_get_role_name(event->source, NULL));
-
- if (!strcmp(event->type, "object:scroll-start"))
- {
- DEBUG("Scrolling started");
- tts_speak("Scrolling started", TRUE);
- }
- else if (!strcmp(event->type, "object:scroll-end"))
- {
- DEBUG("Scrolling finished");
- tts_speak("Scrolling finished", FALSE);
- get_realized_items_count((AtspiAccessible *)event->source, &start_index, &end_index);
- _smart_notification_realized_items(start_index, end_index);
- }
-}
-
-/**
- * @brief Initializer for smart notifications
- *
- *
- */
-void smart_notification_init(void)
-{
- DEBUG("Smart Notification init!");
-
- AtspiEventListener *listener;
-
- listener = atspi_event_listener_new(_scroll_event_cb, NULL, NULL);
- atspi_event_listener_register(listener, "object:scroll-start", NULL);
- atspi_event_listener_register(listener, "object:scroll-end", NULL);
-
- haptic_module_init();
-
- status = TRUE;
-}
-
-/**
- * @brief Smart notifications shutdown
- *
- */
-void smart_notification_shutdown(void)
-{
- status = FALSE;
-}
-
-/**
- * @brief Smart notifications focus chain event handler
- *
- */
-static void _smart_notification_focus_chain_end(void)
-{
- if(!status)
- return;
-
- DEBUG(RED"Smart notification - FOCUS CHAIN END"RESET);
-}
-
-/**
- * @brief Smart notifications realized items event handler
- *
- */
-static void _smart_notification_realized_items(int start_idx, int end_idx)
-{
- if(!status)
- return;
-
- if(start_idx == end_idx)
- return;
-
- DEBUG(RED"Smart notification - Visible items notification"RESET);
-
- char buf[256];
-
- snprintf(buf, sizeof(buf), ITEMS_NOTIFICATION, start_idx, end_idx);
-
- tts_speak(strdup(buf), FALSE);
-}