Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Using RTelServer class

This section describes, by example, some of the less intuitive behaviour of the RTelServer class.


Loading a TSY module

To use a specific modem, client applications must first load a TSY module which supports its functionality. This is achieved by passing the file name of the TSY to the LoadPhoneModule() function, as shown below:

RTelServer server;
Int ret = server.Connect();
_LIT(KTsyName,"HAYES.TSY")
ret=server.LoadPhoneModule(KTsyName);
ret=server.UnloadPhoneModule(KTsyName);
yest(ret==KErrNone);
server.Close();

In the case above the server is first connected, and then the Hayes TSY is loaded. Note that the name of the TSY has been hard coded. This is not recommended practice. Instead the name of the TSY module should be obtained by querying the communications database for the name of the currently selected TSY, or by scanning the \system\libs\ directory of each drive for files with the *.tsy extension. An example of how to scan the file system for a particular file type is provided in the File Server examples.

The code fragment below shows a function which can be used to obtain the name of the currently selected TSY. The project should also #include commdb.h, and link to commdb.lib.

void CExampleCode::GetTsyNameL(TDes& aTsyName)
 {
 CCommsDatabase* db = CCommsDatabase::NewL();
 db->Open();
 TUint32 id;
 db->GetDefaultRecordL(TPtrC(CONNECTED_MODEM), id);
 CCommsDbTableView* table = db->OpenViewMatchingUintLC(TPtrC(CONNECTED_MODEM), TPtrC(COMMDB_ID), id);
 User::LeaveIfError(table->GotoFirstRecord());
 TBuf<KCommsDbSvrMaxFieldLength> tsyName;
 table->ReadTextL(TPtrC(MODEM_TSY_NAME), aTsyName);
 CleanupStack::PopAndDestroy();
 db->Close();
 delete db;
 }