|
|
|
RTelServer classTo 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.
// Use CommDB to find which TSY to load
void CEtelEngine::GetDefaultTSYL(TDes& aTSYName;)
{
CCommsDatabase* db = CCommsDatabase::NewL(EDatabaseTypeUnspecified);
CleanupStack::PushL(db);
// Connect to the Modem table.
CCommsDbTableView* table = db->OpenTableLC(TPtrC(MODEM));
TInt tabErr = table->GotoFirstRecord();
User::LeaveIfError(tabErr);
TUint32 id;
table->ReadUintL(TPtrC(COMMDB_ID), id);
if (id == (TUint32)KDbNullColNo) // this was the template record, so go to the next one
{
User::LeaveIfError(table->GotoNextRecord());
table->ReadUintL(TPtrC(COMMDB_ID),id);
}
table->ReadTextL(TPtrC(MODEM_TSY_NAME), aTSYName);
CleanupStack::PopAndDestroy(2); // table and db