BPSEventListener::BPSEventListener()
    : _isKeyboardVisible(false)
{
    subscribe(virtualkeyboard_get_domain());
    subscribe(netstatus_get_domain());

    bps_initialize();
    virtualkeyboard_request_events(0);
    netstatus_request_events(0);
}
TEST(Connection, CanGetEvents) {
    webworks::ConnectionBPS *connectionBPS = new webworks::ConnectionBPS();
    connectionBPS->InitializeEvents();
    netstatus_request_events(0);

    connectionBPS->SendEndEvent();
    EXPECT_EQ(0, connectionBPS->WaitForEvents());

    delete connectionBPS;
}
ConnectionInfo::ConnectionInfo() :
		m_connected(false), m_interfaceName("Unknown"), m_interfaceType(
				ConnectionInfo::Unknown) {
	subscribe(netstatus_get_domain());

	bps_initialize();

	// Request all network status events.
	netstatus_request_events(0);

	info = NULL;
}
Ejemplo n.º 4
0
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);
}
TEST(Connection, CanStopEvents) {
    webworks::ConnectionBPS *connectionBPS = new webworks::ConnectionBPS();
    connectionBPS->InitializeEvents();

    // Send an end event and see if bps_get_event receives it
    netstatus_request_events(0);
    connectionBPS->SendEndEvent();
    bps_event_t *event = NULL;
    bps_get_event(&event, 1000);
    delete connectionBPS;

    // Use assert so that the next test does not run if this one fails
    ASSERT_TRUE(event != NULL);
}
Ejemplo n.º 6
0
void QBBEngine::initialize()
{
    if (initialized) {
        qWarning() << Q_FUNC_INFO << "called, but instance already initialized.";
        return;
    }

    instanceStorage()->setLocalData(new EngineInstanceHolder(this));

    if (netstatus_request_events(0) != BPS_SUCCESS) {
        qWarning() << Q_FUNC_INFO << "cannot register for network events. Polling enabled.";

        const QMutexLocker locker(&pollingMutex);
        pollingRequired = true;
    } else {
        QAbstractEventDispatcher::instance()->installEventFilter(this);
    }

    doRequestUpdate();
}
Ejemplo n.º 7
0
/**
 * A sample application demonstrates the BlackBerry Native APIs for network status.
 * The sample queries for the current network status and then listens for status
 * 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();

    /*
     * 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 (NAV_EXIT event) as well as
     * Network Status service events so we can be notified when the network
     * status is updated
     */
    navigator_request_events(0);
    netstatus_request_events(0);

    /*
     * Retrieve and display the current network status using the
     * netstatus_get_availability(...) call
     */
    bool is_available;
    netstatus_get_availability(&is_available);
    display_net_status(is_available);

    /*
    * Process Network Status 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 it is a NETSTATUS_INFO event then display the updated status
             */
            if (bps_event_get_domain(event) == netstatus_get_domain()) {
                if (NETSTATUS_INFO == bps_event_get_code(event)) {
                    is_available = netstatus_event_get_availability(event);
                    display_net_status(is_available);
                }
            }
            /*
             * 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;
                }
            }
        }
    }

    /*
     * Clean up the BPS infrastructure and exit
     */
    bps_shutdown();
    return 0;
}