Tutorial: Making Phone Calls
|
Service | Supported Call Types |
---|---|
modem | Voice, Data, Fax, Video, IP |
voip | VoIP |
In this case, the modem service supports the desired Voice call type. By convention, call types start with an upper case letter, and service names start with a lower case letter.
If more than one service were to support a call type, then QPhoneCallManager::services() will return the first that it finds. The caller can explicitly request a particular service in the call to QPhoneCallManager::create():
QPhoneCallManager mgr; QPhoneCall call = mgr.create( "Voice", "modem" );
Once the service has been located, QPhoneCallManager::create() calls QPhoneCallManagerPrivate::create() in qphonecallmanager.cpp. This method constructs a QPhoneCallPrivate instance, wraps it with a QPhoneCall reference, and returns it to the caller.
The constructor for QPhoneCallPrivate in qphonecall.cpp attaches to two Qt Extended IPC channels:
QPE/Communications/QPhoneCallProvider/Request QPE/Communications/QPhoneCallProvider/Response
The first Qt Extended IPC channel is used to send requests to the telephony service to perform call operations. The second Qt Extended IPC channel is used to receive state information about the call back from the telephony service.
The next step is to dial the call:
void Caller::dial() { QPhoneCall call = mgr->create("Voice"); QDialOptions dialOptions; dialOptions.setNumber(numberToDial->text()); call.dial(dialOptions); call.connectStateChanged(this, SLOT(stateChanged(QPhoneCall))); }
After initializing the local state of QPhoneCallPrivate, QPhoneCall::dial() sends the Qt Extended IPC message dial(QString,QString,QString,QDialOptions) to the Request channel.
In the telephony service, the Qt Extended IPC message is received by QPhoneCallProvider::dial() in qphonecallprovider.cpp. It filters the message to check that it is intended for that service (all call providers listen on the same channel), and then calls QPhoneCallProvider::create() to create a QPhoneCallImpl object to represent the server-side instance of the phone call.
The QPhoneCallProvider::create() method is implemented differently for each telephony service. For AT-based modems, it is overridden by QModemCallProvider::create() in qmodemcallprovider.cpp, which then creates a QModemCall object.
Once the server-side instance has been created, QPhoneCallProvider::dial() calls QPhoneCallImpl::dial(), which in our case is overridden by QModemCall::dial() in qmodemcall.cpp. QModemCall::dial() issues the ATD command to the modem and the dial starts.
As the call progresses, the QModemCall class will advertise state changes by calling the QPhoneCallImpl::setState() method. This will cause the QPhoneCallProvider::stateChanged() slot to be invoked, which in turn calls QPhoneCallProvider::sendState().
The QPhoneCallProvider::sendState() method in qphonecallprovider.cpp sends a Qt Extended IPC message on the Response channel, which will return back to the client application in the QPhoneCallPrivate::callStateChanged() method in qphonecall.cpp. This will cause the stateChanged() signal to be emitted on QPhoneCall, notifying the client application.
See also QPhoneCall, QPhoneCallManager, QDialOptions, QPhoneCallProvider, QModemService, QModemCallProvider, and QModemCall.
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt qtextended4.4 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com