class CXmppSettingsApi : public CBase |
This class handles dynamic name-value pair storing. Be warned, all actions are final.
This is how this component works: It has two tables. First one, the column table, contains only single row. This table is actually a header table for the record table. When you set an new attribute, we check that does it already exist in column table. If it does not, it is added as last entry. After that data of the attribute is set to the record table into same column as it is attribute name is in the column table. Row of the settings record is determined by given settingsrecordid.
The column table can hold 0xFFFE (65534) of different user attributes and you can add 0xFF (255) different settingsrecords.
Below is an picture of the tables. Only the ID column is mandatory. All other columns are defined by user.
------------------------------------------------------------ | COLUMNS TABLE | |----------------------------------------------------------- | 1 | 2 | 3 | 4 | 5... | | ------------------------------------------------------------ | ID | SERVER-ADDR | SERVER-PORT | USERNAME | etc...| | ------------------------------------------------------------
------------------------------------------------------------ | RECORDS TABLE | |----------------------------------------------------------- | 1 | 2 | 3 | 4 | 5... | | ------------------------------------------------------------ | 1 | www.gizmo.com | 5223 | Myerdin | etc...| | ------------------------------------------------------------ | 2 | | 5222 | Ballmer | etc...| | ------------------------------------------------------------ | 3 | login.com | | Apple | etc...| | ------------------------------------------------------------ | 4 | aaa.bbb.com | 1234 | user | etc...| | ------------------------------------------------------------
---- Example 1 ---------------------------------------------- Usage example: First Create settings record: TUint32 settingId(0); CXmppSettingsApi* sapi = CXmppSettingsApi::NewLC(); sapi->CreateSettingsRecordL( settingId ); CleanupStack::PopAndDestroy( sapi ); The settingId contains now new id. ---- Example 2 ---------------------------------------------- You can request default settings record (currently returns the first): TUint32 settingId(0); sapi->DefaultSettingsRecordL( settingId ); The settingId contains now the id. ---- Example 3 ---------------------------------------------- When you want to add new parameter to the settings record, do following: _LIT( KOurParam, "USERNAME"); sapi->SetParamL( settingId, KOurParam(), aUsername ); If this is the first time the parameter is added to the settings record, it creates new room for it. ---- Example 4 ---------------------------------------------- When you want to get parameter from the settings record, do following: _LIT( KOurParam, "USERNAME"); RBuf value; value.CreateL( KMaxParamLength ); sapi->SetParamL( settingId, KOurParam(), value ); Value now contains the value recordd in the settings record. If no value has been set for this settins records column, then it cannot be found ->leaves KErrNotFound.
Public Member Functions | |
---|---|
~CXmppSettingsApi () | |
IMPORT_C void | CreateSettingsRecordL ( TUint32 &) |
IMPORT_C void | DefaultSettingsRecordL ( TUint32 &) |
IMPORT_C void | GetParamL ( TUint32 , const TDesC &, TDes &) |
IMPORT_C void | GetParamL ( TUint32 , const TDesC &, TInt &) |
IMPORT_C void | GetRepositoryKeyL ( TUint32 , const TDesC &, TBool , TUint32 &) |
IMPORT_C void | GetSettingsRecordIdArrayL ( RArray < TUint32 > &) |
IMPORT_C CXmppSettingsApi * | NewL () |
IMPORT_C CXmppSettingsApi * | NewLC () |
IMPORT_C void | RemoveParamL ( TUint32 , const TDesC &) |
IMPORT_C void | RemoveSettingsRecordL ( TUint32 ) |
IMPORT_C void | SetParamL ( TUint32 , const TDesC &, const TDesC &) |
IMPORT_C void | SetParamL ( TUint32 , const TDesC &, TInt ) |
Private Member Functions | |
---|---|
CXmppSettingsApi () | |
void | ConstructL () |
void | GetColumnKeyL ( TUint32 , const TDesC &, TBool , TUint32 &) |
Private Attributes | |
---|---|
CXmppSettingsColumn * | iColumns |
CXmppSettingsRecord * | iRecords |
CRepository * | iRepository |
IMPORT_C void | CreateSettingsRecordL | ( | TUint32 & | aSettingsRecordId | ) |
Creates new settings record.
TUint32 & aSettingsRecordId | On return contains the new setting id. |
IMPORT_C void | DefaultSettingsRecordL | ( | TUint32 & | aSettingsRecordId | ) |
Returns default settings record id.
TUint32 & aSettingsRecordId | On return contains the setting id. |
void | GetColumnKeyL | ( | TUint32 | aSettingsRecordId, |
const TDesC & | aAttrName, | |||
TBool | aCreateColumnIfNotExist, | |||
TUint32 & | aTheKey | |||
) | [private] |
This method does checks before setting or getting values.
IMPORT_C void | GetParamL | ( | TUint32 | aSettingsRecordId, |
const TDesC & | aAttrName, | |||
TDes & | aAttrValue | |||
) |
KErrNotFound if setting collection or Param is not found.
IMPORT_C void | GetParamL | ( | TUint32 | aSettingsRecordId, |
const TDesC & | aAttrName, | |||
TInt & | aAttrValue | |||
) |
KErrNotFound if setting collection or Param is not found.
IMPORT_C void | GetRepositoryKeyL | ( | TUint32 | aSettingsRecordId, |
const TDesC & | aAttrName, | |||
TBool | aCreateColumnIfNotExist, | |||
TUint32 & | aTheKey | |||
) |
This method does checks before setting or getting values.
IMPORT_C void | GetSettingsRecordIdArrayL | ( | RArray < TUint32 > & | aArray | ) |
Fills the array with settings ids. If there is none, array is zero length.
IMPORT_C void | RemoveParamL | ( | TUint32 | aSettingsRecordId, |
const TDesC & | aAttrName | |||
) |
KErrNotFound If Settings record or param is not found.
IMPORT_C void | RemoveSettingsRecordL | ( | TUint32 | aSettingsRecordId | ) |
Removes Settings record using given settings record id.
TUint32 aSettingsRecordId | Setting id to be removed. |
IMPORT_C void | SetParamL | ( | TUint32 | aSettingsRecordId, |
const TDesC & | aAttrName, | |||
const TDesC & | aAttrValue | |||
) |
Sets value of the param. If ParamName is not found, it creates new.
IMPORT_C void | SetParamL | ( | TUint32 | aSettingsRecordId, |
const TDesC & | aAttrName, | |||
TInt | aAttrValue | |||
) |
Sets value of the param. If ParamName is not found, it creates new.
CXmppSettingsColumn * | iColumns | [private] |
Class for column table handling. Own.
CXmppSettingsRecord * | iRecords | [private] |
Class for settings records handling. Own.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.