Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Interapplication Communication with Qualcomm Brew : Page 5

Learn the ins and outs of interapplication communication on Brew.

Since Brew 1.x, applications have been able to share data via the file system by putting files in the shared directory. Later versions of Brew improve upon this convention by providing access control lists (ACLs), permitting modules to share access to their private directories. While this has been an acceptable means to share large quantities of data between applications, it can have stiff performance penalties, as applications must read and write the data being shared to the flash file system.

In Brew 3.x, Qualcomm introduced the IFIFO interface, which as its name suggests, is a first-in-first-out queue for interapplication communication. Applications using IFIFO specify the location of the fifo as they open it using a file path preceded by the string fifo:/, i.e., fifo:/shared/rayapp or fifo:/~0x123456/rayapp. The first example denotes a fifo in the shared file system that can be accesed by any application; the latter a fifo in a specific module's directory that can only be accessed by applications that have the appropriate entry in their ACL.

Once a FIFO is opened, it can can be read from or written to depending on the access mode they specify when opening the fifo. For example, to open the fifo located at /shared/rayapp for reading and writing, I would refer to the fifo as fifo:/shared/rayapp?mode=rw, like this:

result = ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_FIFO, (void **)&pMe->pififo ); if ( result == SUCCESS ) { result = IFIFO_Open( pMe-<pififo, "fifo:/shared/rayapp?mode=rw" ); // handle result errors here. }

Once open, the using the fifo is just like using any other Brew socket. You must see if you can write to the fifo by calling IFIFO_Writable with a callback, and in your callback, invoke IFIFO_Write. Similarly, to read data, set a callback using IFIFO_Readable and read the data using IFIFO_Read, looking for ISOURCE_WAIT, ISOURCE_ERROR, and ISOURCE_END values, indicating that all of the data has been read, an error has occured, or the writer has closed the fifo, respectively.

You can also set and query the fifo's buffer size (within reason) using