Using the SIMIdentity query type, which returns the IMSI number of the SIM the method is as follows:
create PhoneLine object to handle the request:
PhoneLine *line = new PhoneLine();create the PhoneLineQCop object to transmit requests from the application to the phone server.
return responses to queries via the queryResult signal
A slot is created and the signal is connected:
connect( line, SIGNAL(queryResult(PhoneLine::QueryType, const QString&)),
this, SLOT(simIdResult(PhoneLine::QueryType, const QString&)) );
...
void AppClass::simIdResult( PhoneLine::QueryType type, const QString& value )
{
// Process the result "value".
...
}Once the signal has been connected, the application issues the query as follows:
line->query( PhoneLine::SIMIdentity );PhoneLine::query calls the private phone handler method query.
For this example the query method is PhoneLineQCop::query which sends a Qtopia IPC message to the phone server on the QPE/Phone channel.
The phone server listening on the QPE/Phone channel, receives the message in PhoneServerQCop::phoneMessage and dispatches it to its PhoneLine object.
Note: The PhoneLine for the phone server contains a private PhoneLineAt object rather than the PhoneLineQCop object used by applications.
The phone server calls PhoneLineAt::query which determines the AT command to execute to perform the request. In this case, the command is AT+CIMI.
After the command is executed, the PhoneLineAt::queryDone method decodes the response and emits the queryResult signal.
The queryResult signal is intercepted by the phone server PhoneServerQCop::queryResult in phoneserver.cpp) and turned into a Qtopia IPC message on the QPE/Phone channel.
The Qtopia IPC message is received in the application by PhoneLineQCop::stateListen which emits the queryResult signal to the application's AppClass::simIdResult slot.
This completes the example. Other commands and notifications within the phone library follow a similar pattern.
No comments :
Post a Comment