Messaging enabler is a graphic independent library which provides services for sending, receiving and managing unified messages.
Messaging enabler library depends on the following libraries:
l glib-2.0 GLib is the low-level core library that forms the basis for projects such as GTK+ and GNOME. It provides data structure handling for C, portability wrappers, and interfaces for such runtime functionality as an event loop, threads, dynamic loading, and an object system.
l librecord provides basic functions for database manipulation
l dbus Dbus is a simple IPC library based on message
Messaging enabler is designed to handle unified message, which means it tries to provide one set of interface for several types of messages. In design, messaging enabler should cover SMS (Short Message Service), MMS (Multimedia Messaging Service), EMS (Enhanced Messaging Services), EMAIL and Voicemail. But for current functionality implementation, libmsgenabler only can handle sending and receiving of SMS.
libmsgenabler not only provides service for sending and receiving message but also provides mechanism to manage messages with folder hierarchy.
libmsgenabler has the following three features:
libmsgenabler API will not expose to applications any feature specific to the bearer or the protocol actually used to send and receive messages. Take SMS as a example, the upper layer application can invoke relevant API in libmsgenabler send the message without knowing the detailed information of GSM protocol and SMS format.
libmsgenabler provides a generic message object to represent different types of message. Several types of message all can fit into this unified message, and a set of unified APIs provided by libmsgenabler can handle these types of message.
Beyond message sending and receiving, libmsgenabler also provides a generic message repository to store, classify and retrieve different types of message, and folder tree to describe classification and organization of messages.
This section explains what you should know as a programmer about libmsgenabler when developing it. It helps to understand its architecture and implementation.
The following graphic gives out the general architecture of SMS application.

Figure 3.1 Architecture of libmsgenabler
As described in architecture figure, libmsgenabler is in charge of communication with phoneserver to send and receiving message, libmsgenabler invoke librecord to deal with database, in order to manage message repository and folder tree.
There are four core services in libmsgenabler, they are listed in following table:
|
Concept |
introduction |
Implementation |
|
Session service |
enable applications to open a session and do subsequent operation in session.
|
msgsession.c |
|
Message service |
offer applications with interface to operate a generic object representing multiple types of message |
msgmessage.c |
|
folder service |
provide applications with methods to store messages, and to classify and organize messages by folder tree |
msgfolder.c |
|
Event service |
enable application to catch and respond to the unsolicited event |
msgevent.c |
Before the messaging application based on libmsgenabler uses any services related to repository operation and message sending and receiving, it should use msg_session_open() to open a session first and later when it no longer uses any relative messaging service, it should use msg_session_close() to close the session.
Messaging Enabler provide a generic object msg_message_t to represent different types of message.
msg_message_t abstracts common attributes from various attributes of different types of message as format definite field, such as recipients, addresser, subject and so on. The speciality of each type of message concentrates on form and format of message content, while messaging enabler does not care the detailed format of each type of message, it only treats message content in various type of format as a whole, and stores it in body field of msg_message_t structure. Body field of msg_message_t structure is in binary form without any specific format. In the case of SMS, the body of the msg_message_t should be the SMS content in plain text format.
msg_message_t structure is opaque data structure, application (user of enabler) can not read and write obscure fields inside directly, but a set of getter and setter functions are provided to access these fields.
![]() |
Figure 3.2 unified message object
libmsgenabler stores message records in database together with folder information. Folder service in libmsgenabler provides application methods to store, list and manage messages in folder structure.
libmsgenabler provides application methods to query and list the messages in folder, add and delete message to and from folder, and at the same time, application can add and delete the child folder to a specific folder.
there are two key attributes of a folder object, folder type and message type.
Folder type is used to defining the functionality of the folder, the folder type is listed in the following table, Message type is used to define which kind of message the folder can contain, including SMS, MMS, Email and so on.
|
Folder type |
Descripition |
|
MSG_FOLDER_ANY |
No specific folder type |
|
MSG_FOLDER_ROOT |
root folder, system folder |
|
MSG_FOLDER_INBOX |
folder containing incoming message |
|
MSG_FOLDER_OUTBOX |
enable application to catch and respond to the unsolicited event |
|
MSG_FOLDER_SENT |
folder containing sent message |
|
MSG_FOLDER_DRAFT |
folder containing draft message |
|
MSG_FOLDER_TRASH |
folder containing useless message |
|
MSG_FOLDER_USER |
folder defined by user |
libmsgenabler provides event mechanism to report the unsolicited event and allow application to catch and respond to the event.
In order to receive and respond to the event, application needs to register for the specific event with msg_evt_register(). msg_evt_unregister() is used to cancel the registration for the certain event.
Currently, libmsgenabler provides interface to register the follow event type.
|
Event type |
Description |
|
MSG_EVT_MSG_INCOMING |
When incoming message is received, this event will happen and be delivered to the client |
|
MSG_EVT_MSG_SENT_SUCCESS |
When a message is successfully sent out, this event will happen and be delivered to the client. |
|
MSG_EVT_MSG_SENT_FAILED |
folder containing incoming message |
|
MSG_EVT_MSG_REACH_COMFIRMED |
When a message fails to be sent out, this event will happen and be delivered to the client. |
|
MSG_EVT_MSG_REACH_FAILED |
When a sent message fails to reach its destination, this event will happen and be delivered to the client.
|