libbb/abstractbpseventhandler_example.cpp

An example showing the usage of the AbstractBpsEventHandler class.
#include <bb/Application>
#include <bb/AbstractBpsEventHandler>
#include <bps/bps.h>
#include <bps/navigator.h>

class NavigatorBpsEventHandler: public AbstractBpsEventHandler {
public:
    NavigatorBpsEventHandler();
    virtual ~NavigatorBpsEventHandler();

    virtual void event(bps_event_t *event);
};

NavigatorBpsEventHandler::NavigatorBpsEventHandler() {
    subscribe(navigator_get_domain());
    bps_initialize();
    navigator_request_events(0);
}

NavigatorBpsEventHandler::~NavigatorBpsEventHandler() {
    bps_shutdown();
}

void NavigatorBpsEventHandler::event( bps_event_t *event ) {
    int domain = bps_event_get_domain(event);
    if (domain == navigator_get_domain()) {
        int code = bps_event_get_code(event);
        switch(code) {
            case NAVIGATOR_WINDOW_STATE:
                // Do something
                break;
        }
    }
}

int main(int argc, char **argv) {
    bb::Application app(argc, argv);
    NavigatorBpsEventHandler handler;

    handler = new NavigatorBpsEventHandler();
    return app.exec();
}

Overview

Last modified: 2014-05-15



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus