|
Nokia N97 SDK Example Applications Guide |
1. About this Example
2. Prerequisites
3. Design and Implementation
The Message Queue Library application consists of two modules, which should be built in the following order:
The definition for the whole application can be found in the bld.inf file in the group subdirectory of the applications main directory.
MessageQueueLibrary.mmp file (DLL - library): CAPABILITY ALL -TCB MessageQueueClient.mmp file (EXE - application): CAPABILITY NONE.
This example will create a DLL which exports set of generic APIs for the user using which one can do message queue related operations.
To give an rough idea on how to use these apis, an EXE is provided that creates threads and does send/receive on message queues using those exported apis
int MsgQCreate(ULONG qName, ULONG maxMsgs, ULONG qOptions, int* err) Description: Creates a message queue
int MsgQDelete(ULONG qName, int *err) Description: Function for deleting a message queue
int MsgQSend(ULONG qName, char *msg, ULONG nBytes, ULONG priority, int timeout, int *err) Description: Function for sending a message with internal copy
int MsgQReceive(ULONG qName, char *msg, ULONG maxNBytes, int timeout, int *err) Description: Function for receiving a message with internal copy
int MsgQClean(ULONG qName, int *err) Description: Function that empties the specified queue
int MsgQCheck(ULONG qName, int *err) Description: Function for checking how many messages are in a queue
int MsgQMaxCheck(ULONG qName, int *err) Description: This function checks the maximum number of messages in a
All the above APIs will return the library specific error codes to the user through "err".
Each Message Queue created using these apis will have following things maintained:
Internally, these api use ipc related apis of libc like:
Possible error codes are:
Main thread of Application will create two message queues. It will create two threads, passing them Message Queue name.
Thread one will send message to message queue 1 and waits for messages from message queue 2. Thread one will send message to message queue 2 and waits for messages from message queue 1.
Using OpenCMessageQueueLibrary.dll, if user tries to create a message queue with already existing name, it will just return the existing message queue id.
It has its own icon and can be launched from the UI both in the emulator and in the device.
|
© Nokia 2009 |