Dominik Gusenbauer Qt Mobility


Published on

Dominik Gusenbauer, Qt Mobility, 6.3.2010, Hagenberg

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Dominik Gusenbauer Qt Mobility

  1. 1. Qt is © 2009 Nokia Corporation and/or its subsidiaries. Nokia, Qt, Qt Development Frameworks and their respective  logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide. 
  2. 2. Qt Mobility is not about supplying ready made  solutions but delivering the means to create great  software using your own skill and creativity. f k ll d Inspire your creativity for using the new Qt Mobility APIs  Inspire your creativity for using the new Qt Mobility APIs in your own projects and developments. Dominik Gusenbauer, 2010 2
  3. 3. Q g Qt Background The Qt Mobility Project Overview of new Mobility APIs Introducing description Some code snippets Example application ( E l li i (h //bi l / RI7V) Open Discussion/Development Open Discussion/Development Dominik Gusenbauer, 2010 3
  4. 4. Q y p Qt traditionally based in the desktop world Cross‐platform application and UI framework Linux Mac OS‐X Windows Previous ports to embedded platforms Simple port of desktop APIs No specific APIs for mobile platforms N ifi API f bil l tf Dominik Gusenbauer, 2010 4
  5. 5. y ( ) Takeover of Trolltech by Nokia (2008) Availability of additional features through mobile domain Location Sensors etc. Need for specific APIs to support mobile device functionality on  particular platforms (Symbian, Maemo, Windows Mobile/CE) particular platforms (Symbian Maemo Windows Mobile/CE) Solution: Qt Mobility S l ti Qt M bilit Dominik Gusenbauer, 2010 5
  6. 6. y g y g The Mobility APIs generally intend to be an enabling  technology. New Qt APIs add support for mobile device functionality pp y Enlarge developer offering irrespective of actual platform Functional back‐ends implementation on all platforms where  it makes sense Simplify cross‐platform transfer of applications even between  desktop and mobile world Dominik Gusenbauer, 2010 6
  7. 7. p pp Scope of application Application Use Cases 80 % of Application Use Cases Native Platform  New Qt Developer Offering APIs Native Platform Symbian Maemo Win. Mobile/CE Others Source: A. Luddy – The Mobility Project, 2009 Dominik Gusenbauer, 2010 7
  8. 8. p Roadmap Q1 2009 Q2 2009 Q3 2009 Q4 2009 Q1 2010 … Q1 2009           Q2 2009            Q3 2009            Q4 2009            Q1 2010        … Qt Mobile Extensions  Qt Mobile Extensions  Qt Mobile Extensions  Qt Mobility APIs Qt Mobility APIs  (Techn. Preview 1) (Techn. Preview 2) (Techn. Preview 3) (Technology Preview) (Beta Release) Qt 4.5 Garden Qt 4.5 Garden Qt 4.5.2 Tower Qt 4.6 Qt 4.6 API Completeness Early preview of  Enhancement of  Major  Major changes to  Added preview for  Calendar mobile APIs (pre‐ the TP 1 package enhancements of  Mobile Extensions Sensors API and  Location and  alpha stage) previous packages Installer package  Camera API  Landmarks Added Alarms and  of pre‐built libs Enhanced example  Sensors AP Manager AP‐Manager Qt Mobility Project  Qt Mobility Project Calendar API Calendar API applications Audio announced Added email  Bearer Management Full Release of  Camera support within  Contacts Mobility Project Contacts Messaging API Location Landmarks Installer package  Messaging Location of pre‐built libs Multimedia Media d Publish and Subscribe bl h d b b Messaging Service Framework Profile System Information Sensors Versit System Information Telephony p y Vibra Source:‐roadmap Dominik Gusenbauer, 2010 8
  9. 9. p y Platform Compatibility S60 rd Edition S60 th Edition Functional back‐end  mbian 10.1 API Maturity mbian 9.2 implementation available. CE/Mobile 1, FP2)  ndows  ndows  c OS‐X emo 5 emo 6 XP/Vista Functional back‐end 0 3 0 5 ux el Leve Mae Mae (FP1 Mac Sym Sym Linu Win Win implementation available  but not complete. Service  BETA Work on functional back‐ Framework API end implementation. No  Messaging API g g BETA platform specific code  inside Qt API. Bearer  BETA No functional back‐end Management API implementation. Publish and BETA Subscribe API Contacts API BETA Location API BETA Multimedia API BETA System  BETA Information API Sensor API TP Camera API Camera API TP Versit API TP Source:‐1.0‐beta/index.html#platform‐compatability 9
  10. 10. We want to create a… mobile application which is cross‐platform Scenario/Idea: Fall Detection Agent / g Automatically detects when a person falls down Notification of predefined contact person(s) – first aid,  emergency, … Dominik Gusenbauer, 2010 10
  11. 11. p Purpose Provides access to various hardware sensors on a device Supports both low‐level, real‐time sensors (accelerometer  etc.) and high level sensors (device orientation etc.) etc.) and high‐level sensors (device orientation etc.) Each sensor provides certain update policies (polling, timed  updates, on value changed etc.) updates on value changed etc ) Plugin based approach – utilizes dedicated  backend library implementations for  backend library implementations for concrete hardware sensor access Note: The Sensor API is still in a technology preview state N t Th S API i till i t h l i t t and under development or subject to change respectively. Dominik Gusenbauer, 2010 11
  12. 12. Basic architecture overview Holds the actual  Base class for concrete  sensor readings. hardware sensors. Interface – provides callback  QSensorReading facility for async. notifications.  1           * QSensor QS QSensorFilter QS Filt Supported hardware sensors: S t dh d ‐ Accelerometer ‐ Ambient Light Sensor QSensorManager ‐ Compass ‐ Magnetometer ‐ Orientation Sensor << creates, instantiates >> ‐ Proximity Sensor ‐ Rotation Sensor QSensorBackend ‐ Tap Sensor Symbian Sensor Maemo Sensor … QSensorBackend instance is created by a  (backend) (backend) (backend) factory class for concrete sensor on demand factory class for concrete sensor on demand. Dominik Gusenbauer, 2010 12
  13. 13. int main(int argc, char** argv) { QCoreApplication app(argc, argv); // Try to instantiate sensor class AccelerometerFilter QAccelerometer sensor; : public QAccelerometerFilter sensor.connect(); { if (!sensor isAvailable()) { (!sensor.isAvailable()) public: qWarning(“Sensor not available.”); bool filter(QAccelerometerReading* r) { return 1; QString format(“%0.2f %0.2f %0.2f”); } qDebug() << “Acceleration: “ << QString().sprintf(format, // U Use async. callback facility llb k f ilit r >x(), r->x() // instead of signals and slots r->y(), // (faster) r->z()); AccelerometerFilter filter; sensor.setSignalEnabled(false); // Do not store the reading in the sensor.addFilter(&filter); // sensor // Set update interval as fast as return false; // the sensor can go } sensor.setUpdateInterval(100); } // Start sensor Process actual sensor  sensor.start(); reading. return app.exec(); } Reading actual device  Reading actual device acceleration from sensor. Dominik Gusenbauer, 2010 13
  14. 14. Features we need … Acceleration sensor readings  Current location Contacts for notification Messaging for notification Dominik Gusenbauer, 2010 14
  15. 15. p Purpose Receive, access and distribute location data using arbitrary and  independent data sources independent data sources Stream location information Stream location information Abstracts underlying location technology (GPS, Cell Network, WiFi etc.) (GPS Cell‐Network WiFi etc ) Provides notifications when entering or  leaving specified location range leaving specified location range Simplifies implementation of custom  position data sources position data sources Dominik Gusenbauer, 2010 15
  16. 16. Basic architecture overview Actual position data: Longitude,  Latitude, Altitude, Bearing etc. Actual satellite information:  number of satellites, signal  b f t llit i l strengths, satellite elevation etc. QGeoPositionInfo Enables the detection of proximity  Enables the detection of proximity QGeoCoordinate QGeoSatelliteInfo changes for a specified set of  coordinates. QGeoPositionInfoSource QGeoSatelliteInfoSource QGeoAreaMonitor Basic Location API Symbian Location  Maemo Location API … Serial NMEA Source Acquisition API Qt software emulation Dominik Gusenbauer, 2010 16
  17. 17. Requesting actual location  class LocationInfo : public QObject { information from data source. information from data source Q_OBJECT public: LocationInfo(QObject* parent) : QObject(parent) { QGeoPositionInfoSource QGeoPositionInfoSource* src = QGeoPositionInfoSource::createDefaultSource(); if (src) { connect(src, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(updatePosition(QGeoPositionInfo)); connect(src, SIGNAL( d t Ti t( SIGNAL(updateTimeout()), thi t()) this, SLOT( d t Ti SLOT(updateTimeout())); t())) src->requestUpdate(5000); // Start request for actual position } } private slots: void updatePosition(const QGeoPositionInfo& info) { qDebug() << “Current position: ” << info; } void updateTimeout() { // Current location could not be retrieved within the specified timeout // of 5 seconds. qWarning(“Failed to retrieve current position.”); } } Dominik Gusenbauer, 2010 17
  18. 18. Features we need … Acceleration sensor readings  Current location Contacts for notification Messaging for notification Dominik Gusenbauer, 2010 18
  19. 19. p Purpose Management of contact data in a platform independent and  datastore‐agnostic way datastore‐agnostic way Introduces a generic abstraction level  Introduces a generic abstraction level for personal information data Use of contact data stores (local and remote) Use of contact data stores (local and remote) Supports asynchronous operations on data  stores (enabling remote contact stores) stores (enabling remote contact stores) Modify and introspect available contact data Add application specific data to contacts (attributes etc.) Dominik Gusenbauer, 2010 19
  20. 20. Basic architecture overview Contact name, address, phone  number etc. Provides specification for a detail  in any particular contact. Defines  semantics of the representation  QContactDetail and use of data details. QContact Detail Definition QAbstractContactRequest QMap<Qstring, QContactDetailDefinition> QMap<Qstring, QContactDetailDefinition> create, read, update, delete  query and update asynchronous operations QContactManager QContactManagerEngine (plugin) QC t tM E i plugin) l i Symbian Contact  Meamo Contact  Default Store Other Contact Store Store Store Source: A. Luddy – The Mobility Project, 2009 Dominik Gusenbauer, 2010 20
  21. 21. // Construct contact manager for default contact backend g QContactManager* cm = new QContactManager(); // Create example contact QContact example; // Add contact name QContactName name; name.setFirst(“John”); name.setLast(“Doe”); ( ) example.saveDetail(&name); // Add contact email address QContactEmailAddress email; email.setContexts(QContactDetail::ContextHome); email.setEmailAddress(“”); example.saveDetail(&email); // Finally, save the contact details cm->saveContact(&example); Create an example contact and  populate it with data. Dominik Gusenbauer, 2010 21
  22. 22. // Get the contact definition we want to modify ( y (cm is a // previously created QContactManager object) QMap<QString, QContactDetailDefinition> def = cm->detailDefinitions(); Q QContactDetailDefinition modified = def.value(QContactNote::DefinitionName); // Define new field ‘Interests’ Q QContactDetailDefinitionField field; field.setDataType(QVariant::String); QMap<QString, QContactDetailDefinitionField> fields = modified.fields(); // Insert new field to the list of contact’s fields and update // the contact’s field definitions fields.insert(“Interests”, field); modified.setFields(fields); // Save the updated field definitions back to the manager cm->saveDetailDefinition(modified); Add custom field  Interests to a note Add custom field “Interests” to a note  associated with a contact. Dominik Gusenbauer, 2010 22
  23. 23. // Create new contact detail filter QContactDetailFilter filter; filter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName, QContactPhoneNumber::FieldNumber); // Specify the requested value and filter matching criteria QString incomingNbr(“+436641234567”); filter.setValue(incomingNbr); filter.setMatchFlags(QContactFilter::MatchExactly); g (Q y) // Fetch matching contacts list for specified filter (cm is a // previously created QContactManager object) QList<QContactLocalId> matches = cm->contacts(filter); for (int i = 0; i < matches.size(); ++i) qDebug() << cm->contact(; Search for a contact based on an  f incoming phone call id. Dominik Gusenbauer, 2010 23
  24. 24. Features we need … Acceleration sensor readings  Current location Contacts for notification Messaging for notification Dominik Gusenbauer, 2010 24
  25. 25. p Purpose Provide a common interface for handling Email, SMS and MMS  messages Send and retrieve messages (with or without attachments) Send and retrieve messages (with or without attachments) Notification of new messages Work with stored or remote messages k h d Launches preferred messaging client for  displaying or composing of messages Access and manage message accounts defined on device Dominik Gusenbauer, 2010 25
  26. 26. Basic architecture overview Each message has an associated  message account and where  QMessageServiceAction QM S i A ti i t d l i t d appropriated  also an associated  Single Message store for the  message folder. platform but multiple message  send, query, retrieve accounts (for each message type). QMessage Has A QM F ld QMessageFolder QM A t QMessageAccount QMessageStore (messages, folders, accounts) Platform message services Source: A. Luddy – The Mobility Project, 2009 Dominik Gusenbauer, 2010 26
  27. 27. Send an email message with a photo  // Setup new email message attachment using the messaging API. QMessage msg; msg.setType(QMessage::Email); // Set recipient for our email message QString recipient(“”); msg.setTo(QMessageAddress(QMessageAddress::Email, recipient)); // Define message subject, body and append attachment msg.setSubject(“Messaging API example”); msg.setBody(“Hello,nnthis is an example message.”); QStringList attachments; attachments << “images/example.png”; msg.appendAttachments(attachments); // Send message using a new service handle QMessageService* svc = new QMessageService(); if (svc->send(msg)) qDebug(“Successfully sent message.”); else qWarning(“Failed to send message.”); Dominik Gusenbauer, 2010 27
  28. 28. Features we need … Acceleration sensor readings  Current location Contacts for notification Messaging for notification Dominik Gusenbauer, 2010 28
  29. 29. g Bearer Management Controls the application’s connectivity state and enables  seamless management and selection of connections Multimedia Provides an easy way to play, record and manage a collection of  P id l d d ll i f media content of various formats System Information Offers a simple interface to access system related information  and capabilities of a device Dominik Gusenbauer, 2010 29
  30. 30. ( gy p Camera API (technology preview) ) Provides interfaces for utilizing the system’s camera devices. Versit (technology preview) Enables parsing and encoding of Versit® documents such as  vCards as well as importing and exporting contact data from  C d ll i i d i d f and to Versit® documents Calendar (coming soon) Dominik Gusenbauer, 2010 30
  31. 31. Publish and Subscribe Serves primarily as a means of easy inter‐process  communication with additional notification capability communication with additional notification capability Enables context sensitive access to various unified sources of  hierarchical data hierarchical data Uses key‐value (key: QString, value:  QValueSpacePublisher publisher(“/Location”); QV l S P bli h bli h (“/L ti ”) QVariant) tuples to store data. QVariant) tuples to store data publisher.setValue(“City”, “Vienna”); publisher.setValue(“ZIP”, 1010); publisher.setValue(“Street”, “Opernring”); publisher.setValue(“Number”, 2) bli h tV l (“N b ” 2); publisher.sync(); // Usually not required This defines four keys: ‐ /Location/City ‐ /Location/ZIP ‐ /Location/Street ‐ /Location/Number Dominik Gusenbauer, 2010 31
  32. 32. Service Framework QObject Provides a unified way of finding,  implementing and accessing implementing and accessing  Qt S i F k Qt Service Framework services across multiple platforms service interface Service: an independent component  Service: an independent component Service Provider that allows a client to perform a well  dll defined operation p Qt Mobility API Symbian  Maemo Windows … (backend) ( ) ( ) (backend) (backend) ( ) ( ) (backend) Note: Both Publish and Subscribe API as well  Note: Both Publish and Subscribe API as well as Service Framework API are more focused  on the development of a system rather than  Symbian Maemo Windows … an application. Source: Qt Mobility Whitepaper, 2010 Dominik Gusenbauer, 2010 32
  33. 33. p pp Development of application scenario  (Fall Detection Agent) Questions ? For latest Information on Qt Mobility visit h //l b ki / /P j /Q M bili Dominik Gusenbauer, 2010 33
  34. 34. Alex Luddy. The Mobility Project. Technical Session at Qt Developer Days 2009,  Munich. F.H.P. Fitzek, Tommi Mikonen and Tony Torp. Qt for Symbian. John Wiley & Sons,  2010. Forum Nokia Online. Qt Mobility Project: forum/showthread.php?t=193452. Qt Labs Online. Qt Mobility Project: QtMobility. Qt Mobility Project Online. New Qt APIs Beta: Q M bili P j O li N Q API B h // ki /d l / new‐qt‐apis. y j , Qt Mobility Project 1.0.0 API Documentation. Nokia, 2009. Qt Mobility Whitepaper 2010:‐mobility‐ whitepaper‐1.0.0. Nokia, 2010 Qt Online Documentation: Nokia, 2010. 34