Symbian OS App Development - Play the transfer

xiaoxiao2021-03-05  24

First, in the file and directory articles, we introduce the system RAM mainly used for active programs and system kernels, and can be accessed as disk space C: disc. In fact, the data in the communication record is that there is a RAM that is provided by a wide variety of functions that operate these data is provided by the CONTACTS model. First, in the file and directory articles, we introduce the system RAM mainly used for active programs and system kernels, and can be accessed as disk space C: disc. In fact, the data in the communication record is that there is a RAM that is provided by a wide variety of functions that operate these data is provided by the CONTACTS model. Next, let's simplify the structure of the communication model, which is based on a communication database, and a database contains some communication records. Each communication record has some domains, such as name, address, and phone number, and more. A mobile phone may have several communication databases, but there will always be a default database. In the environment I work (S60 SDK 2.1) ../symbian/7.0s/series60_v21_c/epoc32/wins/c/system/data/contacts.cdb is the default database of the simulator. We know that there will often encounter issues related to the OBEX protocol in mobile application development. In fact, in the communication record development, it also follows this protocol, and the data in the communication record is a carrier called VCARD. VCARD is a type of electronic business card to get support for many electronic devices such as PDA and mobile phones. The purpose of VCARD is to deliver convenient communication data delivery between these devices. You can encode the VCARD into the coded text defined by the MIME specification (RFC 1521). This encoding ensures that the various VCARDs are fully compatible with the delivery coding of the 7-bit character set (such as encoding used in the SMS message). A vcard is formatted as follows: Begin: vcard version: 2.1 N: Wilkinson; Steve Fn: Steve Wilkinson Org: EMCC Software Ltd. Tel; Work; Voice: 01617779700 ADR; Work; Encoding = quoted-printable: ;; 108 manchester . Rd = 0D = 0ACarrington; Manchester; UK; M31 4BD; United Kingdom LABEL; WORK; ENCODING = QUOTED-PRINTABLE:. 108 Manchester Rd = 0D = 0ACarrington = 0D = 0AManchester, UK M31 4BD = 0D = 0AUnited K = ingdom EMAIL , PREF; Internet: steve.wilkinson@emccsoft.com REV: 20030909T164330Z end: Many of the VCARD communication models are related to VCARD processing to ensure that Symbian application development partners can easily prepare electronic business cards and address book exchange Aspects of industrial standards. Let's brief introduction to several classes before specific practice: CContactDatabase class is used to create a new database or open an existing database. It also provides the function of accessing the communication records. You can also read communication records can also be read. If you want to edit or delete the item, you must open it, although an app can only open a specific communication record at some point in time. When the modification of the communication record is completed, it is saved to the database. Of course, this class also provides a lot of other features, such as sort, lookup, and more. This class is a class that is important in communication.

The communication model provides the MContACTDBOBSERVER class, and an application can inherit from this class, which is used to receive a revised prompt generated by a particular communication database. Those applications that use this viewer (OBServer) receive event hints, which can be added to the database, modify, or delete an existing communication record, and other useful tips within a certain range. All communication records are inherited from abstract class CContactItem, and access to their access is managed by the CContactDatabase class. You can get the unique ID of each communication record with the ccontactItem :: ID () function (which returns a TContactItemID). The CContactItem class also includes functions that operate on the domain inside the communication record. You can add and insert a new domain or you can delete an existing domain in your project. Some fields inside a communication record are represented by the CContactItemfield class. For convenience, all domains located inside a particular item are stored inside a structure, which is called a ccontactItemfieldset. Each communication recorder stores actual domain data and a specific storage type for this data. This can be a text string, a data / time value, a store, or a proxy, which is represented by the TSTORAGETYPE class. A proxy domain is basically a link to another communication. For example, Series 60 Platform is implemented: contacting other communication records to the communication recorder. Note: The communication recorded domain indicated here is not supported here. All digital information, such as phone numbers and fax numbers, are saved as text. Next, our practice will use the above class, so the above class needs to be careful, more details can also find the associated SDK's Help file. Open, close the database ccontactDatabase :: OpenL () function has two overload functions. If the function does not give a parameter, open the default database. Another situation is that the application designer can also pass a path and file name about the database, which is set to open another database.

------------------------------------------ // Open the default Contacts Database . CContactDatabase * contactsDb = CContactDatabase :: OpenL (); // open the default database CleanupStack :: PushL (contactsDb);. // Count how many contacts are in the default database and then // delete the CContactDatabase object // Note that all Resources Owned by the Contacts Database Are Freed // Upon Deletion. Tint NumberOfContacts = ContactSDB-> countl (); // All data items Cleanupstack :: PopandDestroy (ContactSDB); // Destruction ---------- --------------------------------- To note that a communication database does not have a close () function Or similar functions. The only difference between the new database ccontactDatabase :: Createl () function and ccontactDatabase :: ReplaceL () If the database already exists, the former will exit with KerraLReadyexists. As mentioned earlier, these functions will create a default database if the parameters are not defined. The ccontactDatabase :: FindContactFile () function gives a descriptor, and if there is no default database, the descriptor returns the location of the default database.

------------------------------------------ // if one is found, replace it with a new empty default database // if no default database is found, create a new one TFileName contactDbFilePath;.. CContactDatabase * newDefaultContactDb; if (CContactDatabase :: FindContactFile (contactDbFilePath)) // if there is a default database {newDefaultContactDb = CContactDatabase :: ReplaceL ();} else {newDefaultContactDb = CContactDatabase :: CreateL ();} CleanupStack :: PushL (newDefaultContactDb); // add their own function code CleanupStack :: PopAndDestroy (newDefaultContactDb); --------- -------------------------------- Traversal communication records can be traversed with a communication database with the TContactiter class. This class provides a complete set of functions for traversing all communication records. All functions are operated with a communication recorder ID (TContactItemID), which is used to access a particular communication record.

------------------------------------------ // Open the default Contacts Database : CContactDatabase * contactsDb = CContactDatabase :: OpenL (); CleanupStack :: PushL (contactsDb); TContactIter iter (* contactsDb); // similar cursor TContactItemId cardId; while (! (cardId = iter.NextL ()) = KNullContactId) / / Loop traversing {ccontactItem * card = contactsdb-> readcontactL (cardid); // Read Cleanupstack :: Pushl (Card); // Add your own function code ContactSDB-> CloseContactL (); Cleanupstack :: popandDestroy (); // card} cleanupstack :: popanddestroy (); //undactsdb ---------------------------------------------------------------------------------------------------------------------- ------------- Export all communication items to files Mainly using the ExportSelectedContactsl function in class ccontactDatabase.

S60 2.1help is defined as follows: ------------------------------------------- void ExportSelectedContactsL (const TUid & aFormat, const CContactIdArray & aSelectedContactIds, RWriteStream & aWriteStream, TInt aOption, TBool aExportPrivateFields = ETrue); void ExportSelectedContactsL (const TUid & aFormat, const CContactIdArray & aSelectedContactIds, RWriteStream & aWriteStream, TInt aOption, const CVersitParser :: TVersitCharSet aCharSet, TBool aExportPrivateFields = ETrue); Supported from 6.0 Description:.. Exports an array of contact items to a write stream - overloaded function The items are converted into vCards before being written to the stream Parameters: const TUid & aFormat: Indicates the format for imported and exported contacts. Must have a value of KVersitEntityUidVCard const CContactIdArray & aSelectedContactIds:. Array of contact IDs to export RWriteStream & aWriteStream:.. The stream to write to TInt aOption: Indicates the options for import and export See the TOptions enum const CVersitParser :: TVersitCharSet aCh.. arSet: The character format If not specified, defaults to CVersitParser :: EUTF8CharSet TBool aExportPrivateFields = ETrue:.... ETrue exports fields marked as private EFalse does not export fields marked as private See CContactItemField :: SetPrivate () Leave codes.:

Kerrnotsupported AFORMAT.IUID IS Not KversitentityUidvcard. KerrNotfound One or More of The Contact Items Does Not Exist in The Database. --------------------------- ---------------- routines are as follows: ------------------------------ ------------- RFS FileESession; user :: leaveiferror (filesession.connect ()); // Connect file server cleanupclosepushl (filess); ccontactDatabase * contactDb = ccontactDatabase :: OpenL (); / / open the default database CleanupStack :: PushL (contactDb); CContactIdArray * exportContact = CContactIdArray :: NewL (); // array of recording data items CleanupStack :: PushL (exportContact); RFile file; file.Replace (fileSession, aFileName, EFileWrite) ; // Create a new file, aFileName file name CleanupClosePushL (file); RFileWriteStream outputStream (file); // declare a file stream CleanupClosePushL (outputStream); exportContact = iContacts; // iContacts is initialized an array of corresponding export properties, needed Class ccntfilter //, such as: // ccntfilter * filter = ccntfilter :: newlc (); // filter-> setContactFilTertypell (efalse); // filter-> setContactFilTerTypeCard (eTrue); // Press VCARD format to export // lastactDb-> FILTERDATABASEL (* filter); // Remove the corresponding item to meet the conditions in this Filter property TUID i D; id.iuid = kversientityuidvcard; contactdb->

ExportSelectedContactsl (id, * exportContact, // Export to file awritestream, ccontactDatabase :: eExCludeuid); Cleanupstack :: PopandDestroy (5); ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------- Delete a Specified Communication Book Now You can use class cpbkcontactengine. This class can be very convenient to complete a variety of operations, which is equivalent to operating mobile phone communication. When a quick engine is used: cpbkcontactengine * ipbkcontactengine = cpbkcontactengine :: newl (); this will establish a engine object of a default communication. Then: ----------------------------------------- Import_c void cpbkcontactengine :: DeleteContactL (TContactItemId aContactId, TBool aImmediateNotify = EFalse) IMPORT_C void CPbkContactEngine :: DeleteContactsL (const CContactIdArray & aContactIds, TBool aImmediateNotify = EFalse) ----------------------- -------------------- The above two functions can complete the deletion operation, just one is a communication record that deletes a specific ID, the other is to delete one satisfaction Conditional communication recorder array.

Simple call implementation: ipbkcontactengine-> deleteContactL (ID); IPBKContactengine-> compressL () after deletion; check the database under the compression of the database, because the compression is time consuming, so do not per delete. Of course, there is a class CPBKContactengine, we can also achieve new and modify the functionality of the communication record. In fact, we can complete the same functionality at the beginning of the article, but relatively complicated relative to this class, What kind of class is only your own hobby.

The following example shows a new and modified operation: New ------------------------------------------------------------------------------------------------------------------------------------------------ --- // 省 省 部分 部分 代 (上) ... cpbkcontactitem * contact = engine-> createemptycontactL (); // Newly built an empty communication record Cleanupstack :: Pushl (contact); _lit (kfname, "king" ); _LIT (KLName, "Chai"); _LIT (KNumber, "13777777777"); // modified first name TPbkContactItemField * field = contact-> FindField (EPbkFieldIdFirstName); field-> textStorage () -> SetTextL (KFName); // modify the last name field = contact-> FindField (EPbkFieldIdLastName); field-> textStorage () -> SetTextL (KLName); // modify the phone number field = contact-> FindField (EPbkFieldIdPhoneNumberMobile); field-> textStorage () - > SetTextL (KNumber); ... // You can add additional value // Modify the result to add to the database, return the ID of this communication record, you can use TContactItemid ID = Engine-> AddNewContactL (* Contact); Cleanupstack :: PopandDestroy (Contact); ----------------------------------------------------------------------------------------------------- Implement modifications and new code similar, different, you need to find the field you want to modify, then modify, finally import database modification -----------------------

-------------------- CPBKContactItem * Contact = Engine-> OpenContactLCX (ACONTACTID); Cleanupstack :: Pushl (Contact); // Find the Field TPBKContactItemfield * field that you want to modify = Contact-> Findfield (EPBKFIELDIDPHONENUMBERMOBIL); Cleanupstack :: Pushl (Field); _LIT (Number, "135000000"); TBUF <11> phonenumber (number); // Setting and confirmation Field-> textStorage () -> setTextL (Phonenumber); Engine-> CommitContactL (* contact); Cleanupstack :: PopandDestroy (2); article Source: http://symbian.org.cn/bbs/viewtopic.php?t=884

转载请注明原文地址:https://www.9cbs.com/read-38061.html

New Post(0)