StatusEventHandler::StatusEventHandler() { subscribe(netstatus_get_domain()); subscribe(locale_get_domain()); subscribe(geolocation_get_domain()); bps_initialize(); netstatus_request_events(0); locale_request_events(0); geolocation_request_events(0); geolocation_set_period(1); }
QT_BEGIN_NAMESPACE QQnxVirtualKeyboardBps::QQnxVirtualKeyboardBps(QObject *parent) : QQnxAbstractVirtualKeyboard(parent) { if (locale_request_events(0) != BPS_SUCCESS) qWarning("QQNX: Failed to register for locale events"); if (virtualkeyboard_request_events(0) != BPS_SUCCESS) qWarning("QQNX: Failed to register for virtual keyboard events"); int height = 0; if (virtualkeyboard_get_height(&height) != BPS_SUCCESS) qWarning("QQNX: Failed to get virtual keyboard height"); setHeight(height); }
/** * A sample application that demonstrates the BlackBerry Native APIs for * managing locale. The sample queries for the current locale and then listens * for locale update events. */ int main(int argc, char *argv[]) { /* * Before we can listen for events from the BlackBerry Tablet OS platform * services, we need to initialize the BPS infrastructure */ bps_initialize(); if (setup_screen() != EXIT_SUCCESS) { printf("Unable to set up the screen. Exiting."); return 0; } /* * Once the BPS infrastructure has been initialized we can register for * events from the various BlackBerry Tablet OS platform services. The * Navigator service manages and delivers application life cycle and * visibility events. * For this sample, we request Navigator events so that we can track when * the system is terminating the application (NAVIGATOR_EXIT event) as well * as Locale events so we can be notified when the locale is updated */ navigator_request_events(0); locale_request_events(0); dialog_request_events(0); /* * Create and display the dialog. */ create_dialog(); /* * Retrieve and display the current Locale using the locale_get(...) API */ char* country = NULL; char* language = NULL; locale_get(&language, &country); display_locale(language, country); bps_free((char*)language); bps_free((char*)country); /* * Process Locale and Navigator events until we receive a NAVIGATOR_EXIT event. */ int exit_application = 0; while (!exit_application) { /* * Using a negative timeout (-1) in the call to bps_get_event(...) * ensures that we don't busy wait by blocking until an event is * available. */ bps_event_t *event = NULL; bps_get_event(&event, -1); if (event) { if (bps_event_get_domain(event) == locale_get_domain()) { /* * If it is a LOCALE_INFO event then display the updated locale * information */ if (LOCALE_INFO == bps_event_get_code(event)) { /* * The locale_event_get_language and locale_event_get_country * calls return pointers to data within the event. When * the event is destroyed below via the call to * bps_event_destroy(event), the returned pointers would * reference deallocated memory. * * To avoid potentially having pointers to dereferenced * memory, we'll use local variables to store the pointers * into the event data. This way, the pointers will go * out of scope and thus cannot be used after the event * is freed. */ const char* language = locale_event_get_language(event); const char* country = locale_event_get_country(event); display_locale(language, country); } } /* * If it is a NAVIGATOR_EXIT event then set the exit_application * flag so the application will stop processing events, clean up * and exit */ if (bps_event_get_domain(event) == navigator_get_domain()) { if (NAVIGATOR_EXIT == bps_event_get_code(event)) { exit_application = 1; } } } } /* * Destroy the dialog, if it exists and cleanup screen resources. */ destroy_dialog(); cleanup_screen(); /* * Clean up the BPS infrastructure and exit */ bps_shutdown(); return 0; }