> -----Original Message----- > From: Ricardo Marques > Sent: Wednesday, August 13, 2003 8:29 AM > > For example, the user would go to the menu and press "Send > File", after which a form would appear asking which file the > user would like to send and allowing to indicate it. How can > I do that? That is, how do i know where a file is stored > within the OS, how do I find it and select it to send, and > how do I save a received file in a location chosen by the user
This is a very common functionality and as such, there are helper APIs that will save you a lot of time, Ricardo. You can get a list of all files on the device with SysCreateDataBaseList(). For example: ----- MemHandle haItems = NULL; // Handle to array of SysDBListItemType UInt16 wNumDBsFound = 0; // # of SysDBListItemType items in haItems SysCreateDataBaseList( sysFileTApplication, 0, &wNumDBsFound, &haItems, true ); ----- Once haItems is generated, you can load up a list control with the strings inside the SysDBListItemType.name member (see http://tinyurl.com/jws9 for info on generating a list's contents during runtime): ----- SysDBListItemType* paItems = NULL; if ( haItems ) SysDBListItemType* paItems = (SysDBListItemType*) MemHandleLock( haItems ); if ( paItems ) { for ( UInt16 i = 0; i < wNumDBsFound; i++ ) AddStringToMyList( paItems[i].name ); // Analogous to FillListWithYears() // in the List recipe URL } MemHandleFree( haItems ); haItems = NULL; ----- Once a user has selected one of the items from the listbox to beam, you want to lock down haItems again, advance to the index corresponding to the user's selection, extract its name, creator ID, and dbID, and then use the Exchange Manager to send the file. BE SURE to MemHandleFree( haItems ) at some point after you no longer need it, or else you will leak the memory allocated to store the array. See http://tinyurl.com/jwrd for sample code of how to send a database using the Exchange Manager. The only thing I would add to this recipe is to use one of the prefixes defined in http://tinyurl.com/jwr7 so that your user is prompted whether they'd like to send (Bluetooth) or beam (IR) or SMS the file, depending on the capabilities of the device on which your app would be run. See the bottom of http://tinyurl.com/jwrw for a sample WriteProc() that should work for your ExgDBWrite() call. I hope this gets you going. Be patient with the Exchange Manager, it can be fickle, but once you've beamed a file through thin air, you realize it was worth it. At least, I did. -Jeff Ishaq -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/