Skip to content
Snippets Groups Projects
Commit 08545aec authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#17013: Move in SipCall logic to prevent action occuring in wrong state

parent 6c25a1e0
No related branches found
No related tags found
No related merge requests found
......@@ -129,26 +129,14 @@ public class CallActivity extends Activity implements OnClickListener
mCall.notifyServiceAnswer(service);
break;
case R.id.buttonhangup:
if((mCall.getCallStateInt() == SipCall.CALL_STATE_NONE) ||
(mCall.getCallStateInt() == SipCall.CALL_STATE_CURRENT) ||
(mCall.getCallStateInt() == SipCall.CALL_STATE_HOLD)) {
mCall.notifyServiceHangup(service);
if(mCall.notifyServiceHangup(service))
finish();
}
else if(mCall.getCallStateInt() == SipCall.CALL_STATE_RINGING) {
mCall.notifyServiceRefuse(service);
finish();
}
break;
case R.id.buttonhold:
if(mCall.getCallStateInt() == SipCall.CALL_STATE_CURRENT) {
mCall.notifyServiceHold(service);
}
mCall.notifyServiceHold(service);
break;
case R.id.buttonunhold:
if(mCall.getCallStateInt() == SipCall.CALL_STATE_HOLD) {
mCall.notifyServiceUnhold(service);
}
mCall.notifyServiceUnhold(service);
break;
default:
Log.e(TAG, "Invalid button clicked");
......
......@@ -299,12 +299,12 @@ public class SipCall
}
public void notifyServiceAnswer(ISipService service)
public boolean notifyServiceAnswer(ISipService service)
{
int callState = getCallStateInt();
if((callState != CALL_STATE_RINGING) &&
(callState != CALL_STATE_NONE)) {
return;
return false;
}
try {
......@@ -312,6 +312,8 @@ public class SipCall
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
return true;
}
/**
......@@ -331,40 +333,67 @@ public class SipCall
/**
* Perform hangup action and send request to the service
*/
public void notifyServiceHangup(ISipService service)
public boolean notifyServiceHangup(ISipService service)
{
try {
service.hangUp(mCallInfo.mCallID);
if((getCallStateInt() == SipCall.CALL_STATE_NONE) ||
(getCallStateInt() == SipCall.CALL_STATE_CURRENT) ||
(getCallStateInt() == SipCall.CALL_STATE_HOLD)) {
service.hangUp(mCallInfo.mCallID);
return true;
}
else if(getCallStateInt() == SipCall.CALL_STATE_RINGING) {
service.refuse(mCallInfo.mCallID);
return true;
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
return false;
}
public void notifyServiceRefuse(ISipService service)
public boolean notifyServiceRefuse(ISipService service)
{
try {
service.refuse(mCallInfo.mCallID);
if(getCallStateInt() == SipCall.CALL_STATE_RINGING) {
service.refuse(mCallInfo.mCallID);
return true;
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
return false;
}
public void notifyServiceHold(ISipService service)
public boolean notifyServiceHold(ISipService service)
{
try {
service.hold(mCallInfo.mCallID);
if(getCallStateInt() == SipCall.CALL_STATE_CURRENT) {
service.hold(mCallInfo.mCallID);
return true;
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
return false;
}
public void notifyServiceUnhold(ISipService service)
public boolean notifyServiceUnhold(ISipService service)
{
try {
service.unhold(mCallInfo.mCallID);
if(getCallStateInt() == SipCall.CALL_STATE_HOLD) {
service.unhold(mCallInfo.mCallID);
return true;
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
return false;
}
public void addToConference()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment