MeeGo Touch service framework

Source: Internet
Author: User

Nokia claimsMeeGo is more open than Android: MeeGo is a Linux-based platform that can drive a variety of computing devices, including mobile phones, netbooks, tablets, connected TVs, and on-board information and entertainment systems. Is that true? Let's take a look at the MeeGo Touch service framework.

BKJIA recommended topic: MeeGo: ubiquitous mobile operating system

The user process interface is called this service framework as an IPC mechanism that allows application units to use or serve an interface easily. In this document, the provider process interface is called "provider ".

The purpose of this service framework is as follows:

◆ Provides a simple IPC Mechanism

◆ Ensure that there is no runtime binary dependency between service users and providers

◆ Allow users to use an interface without worrying about the specific logic when selecting or connecting to an interface

◆ Allows users to query the list of providers and select

Basic Service Mechanism

Demonstrate what will happen when a server user SU uses an interface IF.


MeeGo touch Architecture

◆ Server user example: an interface is used to request the service er to give the name of the service provider that implements the interface

◆ This server er maintains a ing table between services and interfaces (by viewing the catalog service directory, usually/usr/share/dbus-1/services) the server er also has a set of service selection rules. it selects a service and returns the service name to the SU interface.

◆ The SU interface then creates a proper token to connect to a service with a given name, and then calls an appropriate method

IF a new SP exists, the Service er sends a signal to the appropriate SU interface to notify them, or IF there are no more SP, the SU will also send a notification. When an event occurs, the application will receive a notification and take the corresponding action by connecting to a signal in IF. For example, an image app may want to allow a user to send a photo by EMAIL. It can listen to the signal "no more SP sends to IF, so as to know when to invalidate this operation.

The service framework should not be used for general IPC communication or communication between two small programs, such, the same way as DuiValueSpace can be used to provide the data backend method for numerical change notifications.

Usage

As a service provider (SP)

◆ SP developers need to prepare two items:

Binary files

When a server user application tries to connect to this service, the binary file will be loaded if it is not running ).

Interface

The files required by the developer of the server user application include:

◆ Duiservicefwbaseif. h/cpp files. These files are common duiservicefwbaseif for all interface layers. the hfile is part of the libdui-dev package, duiservicefwbaseif. cpp will be compiled to libdui, so they are all part of the libdui0 package.

◆ The interface must be provided with XML files, header files, libraries, and A. serveice File

Interface-specific header files and interface XML files will be part of the maemo-interfaces-dev package, and the corresponding cpp file needs to be compiled into the interface-specific library file, these libraries are part of the maemo-interfaces package .. The service file will also be part of the maemo-interfaces package.

Binary files

◆ Create an XML file for defining interfaces.

If you want a method to connect to the current application, you can add a chainTask = "true" attribute to this method label. If you want a method to be asynchronous, you can add an asyncTask = "true" attribute to the label of this method. Note that these methods must not contain any 'out' parameter.

For example:

 
 
  1. <!DOCTYPE node PUBLIC"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN""http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> 
  2. <node> 
  3.       <interfacenameinterfacename="com.nokia.TextProcessorInterface"> 
  4.             <methodnamemethodname="reverse" chainTask="true"> 
  5.                  <arg name="message"type="s" direction="in"/> 
  6.                   <arg name=""type="s" direction="out"/> 
  7.             </method> 
  8.             <method name="blinkScreen"asyncTask="true"> 
  9.                  <arg name="message"type="s" direction="in"/> 
  10.             </method> 
  11.       </interface> 
  12. </node> 
  13.  

◆ Run dui-servicefwgen to generate related. h and. cpp files. The command is as follows:

 
 
  1.  
  2. Dui-servicefwgen-acom. nokia. TextProcessorInterfac [font =, SimSun] e [/font]

Modify code

◆ The modification can be divided into three steps:

 
 
  1. // 1. Create a class instance that has implemented interface functions
  2. MyService myService;
  3.  
  4. // 2. Create an adapter to connect to the methods in ingress and myService
  5. // According to QDBusAbstractAdaptor (), it must be created on the stack,
  6. // And the memory is managed by QDBusAbstractAdaptor, so you do not need to save the pointer
  7. New MyServiceIfAdaptor (& myService );
  8.  
  9. // 3. Connect to the session and register the service
  10. QDBusConnection connection = QDBusConnection: sessionBus ();
  11. Boolret = connection. registerService ("com. nokia. TextProcessor ");
  12. // Compile the remaining part of the program
  13. Return app.exe c ();

Interface

There are three steps to define an interface:

◆ Create an XML file defining an interface-the same XML file as described above.

◆ Run dui-servicefwgen to generate the. h and. cpp files. The command is as follows:

 
 
  1.  
  2. dui-servicefwgen -pcom.nokia.TextProcessorInterface  
  3.  
  4.  
  5.  

◆ Service-related libraries need to be generated.

The above files must be included in the maemo-interfaces package, and the library must be included in maemo-interfaces. header files and XML files must also be included in maemo-interfaces-dev.

Descriptions of interfaces and methods can be added between '<doc> ''</doc>'. For example:

 
 
  1.  
  2. <interfacenameinterfacename="com.nokia.someserviceinterface"> 
  3. <doc> 
  4. <argtagargtag="brief">brief documentation for the interface</arg> 
  5. <argtagargtag="details">detailed documentation for theinterface</arg> 
  6. </doc> 
  7. <method name="showPage"> 
  8. <doc> 
  9. <argtagargtag="brief">brief documentation for showPage()method</arg> 
  10. <argtagargtag="details">detailed documentation for showPage()method</arg> 
  11. </doc> 
  12. <arg name="targetPage"type="s" direction="in" /> 
  13. <arg name="previousPage"type="s" direction="in" /> 
  14. <arg name="" type="b"direction="out"/>      
  15. </method> 
  16. ....etc 

As a service user

◆ Install the libdui-dev debian package. It will provide you with service ing to the ghost daemon, header files, and library files.

◆ Install the maemo-interfaces-dev package that contains the header file of the proxy header, library, and package)

◆ Add-ldui and-l <Interface Name> to the LIBS of your project file.

◆ Include this interface header file in your source file, create an interface instance, and call serviceName () to obtain the interface provider.

◆ Use the 'isvalid () 'method to check whether the service is available.

◆ Call the interface method you want to use.

Implement and connect slots to process signals sent by a service er 'serviceavailable () ', 'serviceunavailable ()', and 'servicechanged () '.

Demo and code example

In libdui/demos/servicefw/, an example demonstrates three service providers and one service user. Com. nokia. textprocessor and org. maemo. the textprocessor Service implements the same interface-com. nokia. textProcessorInterface. because there are two services, we can try to remove the service and then observe that the service users are switching from one service to another. There is a script tool/dui-servicefwgen, which is used to generate source files that are used to define interfaces for service users. Run the following demo:

◆ Cd libdui

◆ Qmake & make instal (or execute at least one make iinstall operation in the duiservicemapper directory)

◆ Cd demos/servicefw

◆ Pushd misc; sudo./INSTALL; popd (this operation will INSTALL the ghost service related files to the/usr/share/dbus-1/services Directory)

◆ LD_LIBRARY_PATH = lib bin/user

◆ This step opens a small window that allows you to enter characters. These characters will be sent to a service through the interface, and the service will return the characters after being reversed.

In this demo, you can remove several services from/usr/share/dbus-1/services to simulate the removal of the service and then add ), to verify whether the service user program can perform the correct operation.

Original English:Http://apidocs.meego.com/mtf/servicefw.html

Original article addressHttp://www.meegoq.com/thread-250-1-1.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.