void BPSEventListener::event(bps_event_t *event) {
    if (event != NULL) {
        if (bps_event_get_domain(event) == virtualkeyboard_get_domain()) {
            uint16_t code = bps_event_get_code(event);
            if (code == VIRTUALKEYBOARD_EVENT_VISIBLE) {
                int pixelsHeight = 0;
                virtualkeyboard_get_height(&pixelsHeight);
                if (pixelsHeight > _mPixelsHeightToConsiderKeyboardVisible) {
                    _isKeyboardVisible = true;
                    emit keyboardVisibilityUpdated();
                }
            } else if (code == VIRTUALKEYBOARD_EVENT_HIDDEN && _isKeyboardVisible) {
                _isKeyboardVisible = false;
                emit keyboardVisibilityUpdated();
            } else if (code == VIRTUALKEYBOARD_EVENT_INFO) {
                int pixelsHeight = 0;
                virtualkeyboard_get_height(&pixelsHeight);
                _isKeyboardVisible = pixelsHeight > _mPixelsHeightToConsiderKeyboardVisible;
                emit keyboardVisibilityUpdated();
            }
        } else if (bps_event_get_domain(event) == netstatus_get_domain()) {
            if (NETSTATUS_INFO == bps_event_get_code(event)) {
                netstatus_info_t *info = netstatus_event_get_info(event);
                if (info) {
                    bool networkReachable = netstatus_info_get_availability(info);
                    ms_message("[BB10] Network status event: network reachable: %i", networkReachable);

                    LinphoneManager *manager = LinphoneManager::getInstance();
                    linphone_core_set_network_reachable(manager->getLc(), networkReachable);
                }
            }
        }
    }
}
BPSEventListener::BPSEventListener()
    : _isKeyboardVisible(false)
{
    subscribe(virtualkeyboard_get_domain());
    subscribe(netstatus_get_domain());

    bps_initialize();
    virtualkeyboard_request_events(0);
    netstatus_request_events(0);
}
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;
}
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);
}
Beispiel #5
0
bool QBBEngine::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
    Q_UNUSED(eventType);
    Q_UNUSED(result);

    bps_event_t * const event = static_cast<bps_event_t *>(message);

    Q_ASSERT(event);

    if (bps_event_get_domain(event) == netstatus_get_domain()) {
        qBearerDebug() << Q_FUNC_INFO << "got update request.";
        doRequestUpdate();
    }

    return false;
}
void StatusEventHandler::event(bps_event_t *event) {
    bool status = false;
    const char* language = "";
    const char* country = "";
    const char* locale = "";
    const char* interface = "";
    const char* type = "none";
    double latitude = 0;
    double longitude= 0;

    if (bps_event_get_domain(event) == geolocation_get_domain()) {
           if(event == NULL || bps_event_get_code(event) != GEOLOCATION_INFO) {
               qDebug() << "NO INFORMATION PROVIDED";
               return;
           }
               latitude = geolocation_event_get_latitude(event);
               longitude = geolocation_event_get_longitude(event);
               double accuracy = geolocation_event_get_accuracy(event);

               double altitude = geolocation_event_get_altitude(event);
               bool altitude_valid =
                          geolocation_event_is_altitude_valid(event);

               double altitude_accuracy =
                           geolocation_event_get_altitude_accuracy(event);
               bool altitude_accuracy_valid =
                           geolocation_event_is_altitude_accuracy_valid(event);

               double heading = geolocation_event_get_heading(event);
               bool heading_valid =
                           geolocation_event_is_heading_valid(event);

               double speed = geolocation_event_get_speed(event);
               bool speed_valid = geolocation_event_is_speed_valid(event);

               double num_satellites =
                           geolocation_event_get_num_satellites_used(event);
               bool num_satellites_valid =
                           geolocation_event_is_num_satellites_valid(event);

               emit geolocationUpdated(latitude,longitude);
       }
    if (bps_event_get_domain(event) == netstatus_get_domain()) {
        if (NETSTATUS_INFO == bps_event_get_code(event)) {
            netstatus_info_t *info = netstatus_event_get_info(event);
            if (info)
            {
                status = netstatus_info_get_availability(info);
                interface = netstatus_info_get_default_interface(info);

                netstatus_interface_details_t *details;

                int success = netstatus_get_interface_details(interface, &details);
                if (success == BPS_SUCCESS) {
                    switch (netstatus_interface_get_type(details)) {

                    case NETSTATUS_INTERFACE_TYPE_UNKNOWN:
                        type = "Unknown";
                        break;

                    case NETSTATUS_INTERFACE_TYPE_WIRED:
                        type = "Wired";
                        break;

                    case NETSTATUS_INTERFACE_TYPE_WIFI:
                        type = "Wi-Fi";
                        break;

                    case NETSTATUS_INTERFACE_TYPE_BLUETOOTH_DUN:
                        type = "Bluetooth";
                        break;

                    case NETSTATUS_INTERFACE_TYPE_USB:
                        type = "USB";
                        break;

                    case NETSTATUS_INTERFACE_TYPE_VPN:
                        type = "VPN";
                        break;

                    case NETSTATUS_INTERFACE_TYPE_BB:
                        type = "BB";
                        break;

                    case NETSTATUS_INTERFACE_TYPE_CELLULAR:
                        type = "Cellular";
                        break;

                    case NETSTATUS_INTERFACE_TYPE_P2P:
                        type = "P2P";
                        break;
                    }
                }

                netstatus_free_interface_details(&details);
                emit networkStatusUpdated(status, type);
            }
        }
    } else if (bps_event_get_domain(event) == locale_get_domain()) {
        if (LOCALE_INFO == bps_event_get_code(event)) {
            language = locale_event_get_language(event);
            country = locale_event_get_country(event);
            locale = locale_event_get_locale(event);
            emit localeUpdated(language, country, locale);
        }
    }
}
Beispiel #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;
}
void ConnectionInfo::event(bps_event_t *event) {
	bool status = false;
	const char* interface = "";
	Type type = Unknown;
	netstatus_interface_details_t* details = NULL;

	// Verify that the event coming in is a network status event.
	if (bps_event_get_domain(event) == netstatus_get_domain()) {
		// Using the BPS event code of the network status event,
		// verify that the event is a network information event.
		if (NETSTATUS_INFO == bps_event_get_code(event)) {
			// Retrieve the network status information, and verify
			// that the procedure is successful.
			if (BPS_SUCCESS == netstatus_get_info(&info)) {
				status = netstatus_info_get_availability(info);
				interface = netstatus_info_get_default_interface(info);
				int success = netstatus_get_interface_details(interface,
						&details);

				if (success == BPS_SUCCESS) {
					switch (netstatus_interface_get_type(details)) {
					case NETSTATUS_INTERFACE_TYPE_WIRED:
						type = Wired;
						break;

					case NETSTATUS_INTERFACE_TYPE_WIFI:
						type = Wifi;
						break;

					case NETSTATUS_INTERFACE_TYPE_BLUETOOTH_DUN:
						type = Bluetooth;
						break;

					case NETSTATUS_INTERFACE_TYPE_USB:
					case NETSTATUS_INTERFACE_TYPE_BB:
						type = Usb;
						break;

					case NETSTATUS_INTERFACE_TYPE_VPN:
						type = VPN;
						break;

					case NETSTATUS_INTERFACE_TYPE_CELLULAR:
						type = Cellular;
						break;

					case NETSTATUS_INTERFACE_TYPE_P2P:
					case NETSTATUS_INTERFACE_TYPE_UNKNOWN:
						type = Unknown;
						break;
					}
					netstatus_free_info(&info);
				}
			}

			// Emit the signal to trigger networkStatusUpdated slot.
			this->setConnected(status);
			this->setInterfaceType(type);
		}
	}
}