New Qt APIs for Mobile Development Mobility I Alex Blasche
What is Qt Mobility about? Mobile Gap Compatibility Availability QML support Beyond Mobile
Mobility API Overview Consumer engagement Data Driven Infrastructure Future Feedback Contacts Bearer Management Bluetooth Location Document Gallery Publish & Subscribe NFC Multimedia Messaging Sensors Organizer Service Framework
Qt Mobility Presentations MOBILITY I Service Framework MOBILITY II Positioning Data APIs Maps Contacts Navigation QML Sensors
Service Framework Metadata store Qt Plugins Qt Service Framework Plug-in system on steroids Simplifies cross process communications Higher degree of choice for developers Enabler for 3rdparty customisation IPC
Service Framework Interface name com.nokia.qt.echointerface Version 1.0 Service name EchoService Custom properties class EchoServiceClass : public QObject { Q_OBJECT public: EchoServiceClass(QObject* parent = 0); Q_SIGNALS: void broadcast(const QString& msg); public slots: void sendmessage(const QString& msg); public: Q_INVOKABLE QString lastmessage() const; void printdebug() const; };
Service Framework (Client) //load the service QServiceManager manager; QServiceInterfaceDescriptor desc = manager.findinterfaces( EchoService ).at(0); QObject* echo = manager.loadinterface(desc); //listen to broadcasts QObject::connect(echo, SIGNAL(broadcast(QString)), this, SLOT(received(QString))); //send a message QString message = Hello World ; QMetaObject::invokeMethod(echo, sendmessage,q_arg(qstring, message)); QMetaObject::invokeMethod(echo, lastmessage, Q_RETURN_ARG(QString, message));
Qt Application Service Framework Architecture Service Framework QObject Plug-in based Services Qt Plugin Framework <<invoke>> <<discover>> Registration/ Lookup Out-of-process Services Metadata Store Cross Platform IPC DBUS RMessage Dynamic MetaObjects Sockets
Service Framework (IPC) Service Process Client Process Service Framework Service Object Slots, Signals, invokable functions, Properties Proxy Object QMetaObject Serialized MetaObject QMetaObject Copy Message Abstraction Message protocol Message Abstraction DBus Symbian IPC Sockets
ServiceFramework register = new QRemoteServiceRegister(); QRemoteServiceRegister::Entry entry= register->createentry<echoservice>( "EchoService", "com.nokia.qt.example.sfwecho", "1.1"); entry.setinstantiationtype( QRemoteServiceRegister::GlobalInstance); register->publishentries("sfwecho_service");
Service Framework
Service Framework Plug-ins Service object type castable Private instances Common (A)Synchronous calls No stubs Automated service start IPC Global/private instances Custom type limitation Single level QObject Security checks
Data-Driven APIs Delete Create Update Retrieve Contacts Documents Gallery Landmarks Messaging Organizer
Data-Driven API s Addressbook entries Contacts Albums Documents Folders Images Playlists Doc Gallery Points of interest Landmarks SMS MMS Email IM Events Notes Journals Todos Messaging Organizer
Data-Driven APIs Common Elements Metadata management Asynchronous requests Event Notifications Global data storage Grouping/Categorisation API naming & principles
Contacts (the example) Device Relationship ActionFactory 1..* <<creates>> Manager 1..* Contact Action 1..* Detail <<targets>> Data Store ActionTarget
Contacts (querying) Manager Abstract Request <<uses>> Start/Cancel Progress notifications Errors Request Type specific results Fetch Save Types are API specific
Mobility & QML Declarative way implementing UI Requires Qt 4.7+ Almost all API s have a QML API/wrapper C++ API designed to be easily integratable
QML orientation example orientation.qml import Qt 4.7 import QtMobility.sensors 1.1 OrientationSensor { active: true onreadingchanged: { if (reading.orientation == OrientationReading::TopUp) display.text = TopUp ; else display.text = Unknown ; } } int main(int argc, char** argv) { QApplication app(argc, argv); QDeclarativeView v; v.setsource( qrc:/orientation.qml ); v.show(); return app.exec(); }
Mobility & QML integration orientation.qml main.cpp qmlviewer <<imports>> declarative_sensors plug-in <<links>> <<links>> QtSensors Library QtDeclarative Library
Mobility I QUESTIONS?