Analysis of Symbian Application Framework

Source: Internet
Author: User
S60 applications depend on a large number of OS components, such as Screen Drawing and application data persistence. You can directly use the OS window server or file server.


Application core framework

The application framework consists of a set of core classes, which are the basis of all application frameworks. These classes encapsulate the interaction between applications and required OS servers.

The first layer: cbase and cactive are two base classes. cactive is also derived from cbase, and cactive is derived from cconenv on the second layer.

Layer 2: contains two basic components: apparc and cone. Apparc stands for the "application architecture". These classes provide basic application structures, mechanisms for submitting system information to applications, and the use of file servers for persistent data. The class name contains the prefix "* APA ". Cone is the abbreviation of the control environment. Classes in this component provide mechanisms for processing user input and creating user interfaces. These classes are mainly used for interaction with window servers, the class is named with the prefix "* Coe ". Many classes in this layer are abstract classes and only define an API interface.

Layer 3: uikon component. This is a general device-independent implementation with rich functions and non-abstract framework classes, and provides a UI library layer shared on all Symbian OS. Some specific UI controls (such as list lists and scroll bars) can be created at this layer. These controls are sometimes called Eikon controls. The classes in the uikon component are named with the prefix "* eik ". Added a common Symbian OS implementation to share with other Symbian OS UI platforms.

Layer 4: consists of avkon classes that provide core s60 UI functions, such as menu support. The classes of the avkon control are named with the prefix "* akn ". Add the unique implementation of s60 to the framework.

Layer 5: For the application layer, design your own application and add custom application implementation.

The classes mentioned above are: View, document, application, and application UI ). How can an s60 UI application use these classes to implement its organic program? This involves the initialization of an application framework.



Application Framework Initialization

Each of the following methods must be created to provide the minimum s60 application:

A. Framework Portal: All s60 UIS implement a global function e32dll () (the non-UI class global portal function is e32main). When the application starts, the framework will first call this function, also known as the DLL entry point, which must exist in the application. Each s60 UI application is a multi-state DLL.

B. Create an application instance: Let the framework call newapplication (). This function is the only function exported by DLL. It is responsible for creating an instance of the application class and returning its pointer, later, the framework uses this pointer to create an application. Here, the "new" method is used to create an application instance on the stack instead of the common "New (eleave)" method in Symbian OS, because trap harness (trap capture) has not yet been created. If the system cannot allocate memory for a new instance, the returned pointer is null. the application framework can check and handle this problem.

C. Return uid: The Framework calls appdlluid () to return the UID of the application. This function must return the UID value specified in the. MMP file. This value can be used to determine whether the application instance is running. If an application is running and another instance of the program is to be started, the running program will be switched to the foreground instead of generating a new one.

D. Create a document instance: the Framework calls the createdocumentl () function of the application class instance through the framework to obtain the pointer to the newly created document class instance. Through the document instance pointer, the framework can call some functions of the document instance. At the same time, the document instance also calls its own newl () and newlc () Double static Constructor (why is it a double constructor, this is related to the exception handling mechanism of Symbian, and it is still not clear why I have designed static functions) to create myself.

E. Whether to mount the file: The Framework calls appdlluid () again to check whether a file is to be loaded from the file system. (It seems that this is related to some permanent storage information. Currently, this function has not been used by the project, and I do not know how to use this function)

F. Create Appui and view instances: the framework generates an Appui instance by calling the createappuil () method of the Document Object and obtains the pointer to it. The default constructor of C ++ is used when the Appui instance is created and the pointer of the instance is returned. Then, the Framework calls the constructl () function of the Appui instance to construct the constructl () function. In this constructl () function, basecontructl () function of the Appui base class is called first to read resources related to the program, the second is to create an instance of the View class to be loaded (through dual construction). If there are more than one view, you need to call the addviewl () function to load the new view instance, finally, if there are multiple views, use the setdefaviewviewl () function to set the default view. For example, if the Appui reads a resource file related to the program and calls the newl function of the appview class to generate its instance, the dual structure is also used.

G. redrawing of view: the framework has the unlimited scheduling right of view through the above creation process, in this case, if there is a general system event framework, you can use the window server to call the view draw () function. These system events generally refer to program startup, application focus, and option menu disappearance. It should be noted that the programming developer cannot directly call draw. It requires that the graphics context of the system be activated before the call. If the programming developer wants to re-paint the screen, you can only call the drawnow () method. In addition, the draw function cannot exit abnormally because the function can be directly called by the framework, and the framework does not know how to handle possible exceptions. Therefore, draw needs to capture and handle possible errors.

H. Processing Command: After completing the preceding steps, you can use the Interactive UI such as menu options to make the framework call the handlecommandl () function and pass the acommand parameter, it specifies the command selected by the user. handlecommandl () Judges different commands based on this to schedule the execution separately. Note that if you want the view instance of the program to respond to the user's buttons, you must use the addtostackl () the function is added to the control stack of the Appui instance.


For the above call method implementation instructions, I personally think it is necessary to list several important event handling methods of Appui:

Handlewseventl () is used to process the events passed by the window server. Its function enables the framework to call the following specific event processing methods;

Handkeyevent () is used to process user key events (this function is called when the control stack is empty, otherwise the framework will call the offerkeyeventl () function );

Handleforegroundeventl () This function is called when an application switches to the foreground or to the background from the foreground. By default, the keyboard focus can be changed;

Handlesystemeventl () is used to process events generated by the window server;

Handleapplicationspecificeventl () is used to process custom events. By default, the color scheme change notification can be processed;

Handlecommandl () is used to process the menu items selected by the user;

Handleswitchoneventl () is used to process specific switching events such as device switching;

Handlemessagereadyl () is used to process message events generated by the window server.

Among the above functions, except for the first handlewseventl () function, other functions are pure virtual functions by default and need to be reloaded for use.

After the above initialization steps for the application framework, a complete framework is created.





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: 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.