CHAPTER 6. PHONE INTERFACE
6.5 VIRTUAL ETHERNET
B. Data service flow
Now that network environments of china are very complicated and service providers
are also different, applications that use data communication have to consider
this situation. For the reason, special module is required to mediate the situation
and Indicator is the module, which operates as plug-in of launcher.
a. Check phone status
After checking phone status, application decides whether it will progress next
step or not.
LXT_PHONE_STATE state = MzPhoneNotifier::instance()->state()
|
if(state == LXT_STATE_STANDBY) || (state == LXT_STATE_DATA_SERVICED)
{
go to next step
}
else
{
show_reject_message();
}
|
b. Request network status
Phone status getting ready, application requests network status. And the response
is as following.
It is the code to receive the response of network status.
connect
(
MzPhoneNotifier::instance(),
this,
SIGNAL(changedNetworkState()),
SLOT(slot_MzPhoneNotifier_changedNetworkState(int))
);
|
Through the following code, application requests the information of network
status.
MzActionCollection ac;
MzAction *pAction = new MzAction("", &ac, "actionPPPSystemParamRequest");
MzAction::activate("skywalker", pAction);
delete pAction;
|
Current Network status (1x, 95A) is asked. Network state being changed, the
fact is broadcasted to all if application, which is not oneself, asks the status.
At this time, you should care the slot that receives the network status not
to have the code that progresses next step.
Because the response that other applications request can also be taken except
the response that oneself requests. The following code prevents this.
It is the method of disconnecting slot from signal.
void slot_MzPhoneNotifier_changedNetworkState(int state)
{
disconnect
(
MzPhoneNotifier::instance(),
SIGNAL(changedNetworkState())),
0,
0
);
...
}
|
Through the following code, application decides own profile name according
to the network status.
void slot_MzPhoneNotifier_changedNetworkState(int state)
{
if(state == 0xF1) // 1x
{
profile_name = 1X_WAP_in_CHINIA
// profile_name = 1X_DATA_in_CHINIA
}
else if(state == 0xF2) // 2g
{
profile_name = 95A_WAP_in_CHINIA
// profile_name = 95A_DATA_in_CHINIA
}
}
|
The profile names currently used are the followings.
1x_WAP_in_CHINA
95A_WAP_in_CHINA
95A_DATA_in_CHINA
1x_DATA_in_CHINA
|
c. Get a permit
If application gets response of the network status, it requests its permission
to indicator with its profile name.
MzActionCollection ac;
MzAction *pAction = new MzAction("", &ac, "actionPPPAuthRequest");
pAction->setText("qwapbrower?profile_name");
//pAction->setText("netriver?profile_name");
//pAction->setText("tracemessanger?profile_name");
MzAction::activate("skywalker", pAction);
delete pAction;
|
d. Response of permit
After requesting, application gets response from indicator and the response
is the followings.
* accept – In case that PPP service isn’t used or it is
used by application that uses the same profile
* reject?0 – In case that requested profile can’t be found
* reject?1 – In case that PPP service is about to be run with other
profile
* reject?2 – In case that PPP service is already run with other
profile
* reject?3 – In case that there is an application that forces to
connect to PPP service after receiving reject?2 and quitting the existing
PPP service
|
The following function takes the response.
static MzAction *getClientAction (const char *name)
{
MzAction *actionClient = MzActionClient::instance()->actionCollection()->action(name);
if (!actionClient)
actionClient = new MzAction(MzActionClient::instance()->actionCollection(), name);
return actionClient;
} |
The signal is registered to receive the response.
connect(getClientAction("actionPPPAuthResponse"), SIGNAL(activated(const QString &)), this, SLOT(slot_PPPAuthResponse(const QString &)));
|
It is process according to the response of permission.
void slot_PPPAuthResponse(QString &data)
{
if (data == "reject?0")
{
}
else if(data == "reject?1")
{
}
...
else if(data == "accept")
{
Network processing ();
}
}
|
e. Get a permit by force
In case that PPP service is already started and run, if applications attempt
to use the service with the same profile, they will get “accept”
response, otherwise they will get “reject2?2” response. In case
of the latter, the application will show warning message, which informs that
other application already uses PPP service with other profile and asks that
you want to quit the existing PPP service. If you choose OK, it sends the following
action.
MzActionCollection ac; MzAction *pAction = new MzAction("", &ac, "actionPPPAuthRequest");
// ex) ppptest?1x_WAP_in_CHINA=super
pAction->setText("qwapbrower?profile_name=super");
//pAction->setText("netriver?profile_name");
//pAction->setText("tracemessanger?profile_name");
MzAction::activate("skywalker", pAction);
delete pAction;
|
That is, application adds “=super” to “actionPPPAuthRequest”
parameter of the existing action and sends the action. Then the existing PPP
service is quitted and PPP becomes idle state, which is initial state. At this
time, application attempts to connect through progressing all the steps again.
The difference is that the authority for PPP use is only given to the application
that requires super. If the application that requires super can’t get
response for 3 seconds, it returns to normal mode.
f. Release permit
In order to quit PPP service when any application doesn’t use the service,
applications have to inform indicator when quitted and when not using the service
any more.
MzActionCollection ac; MzAction *pAction = new MzAction("", &ac, "actionPPPOutOfConnectionIndication");
MzAction::activate("skywalker", pAction);
delete pAction;
|
|