|
@@ -15,7 +15,7 @@
|
|
#include "manager/LanguageManager.h"
|
|
#include "manager/LanguageManager.h"
|
|
|
|
|
|
|
|
|
|
-std::string _isOutgoing;
|
|
|
|
|
|
+std::string _callActivityType = "wait";
|
|
std::string _toIdStr;
|
|
std::string _toIdStr;
|
|
|
|
|
|
//voip::WAVPlayer wavPlayer; // 播放音频
|
|
//voip::WAVPlayer wavPlayer; // 播放音频
|
|
@@ -27,6 +27,7 @@ static base::MediaPlayer mediaPlayer;
|
|
static bool _isSleepTimerRegistered = false;
|
|
static bool _isSleepTimerRegistered = false;
|
|
|
|
|
|
#define CALLING_TIME 60 // 用于控制呼叫时间,定时器
|
|
#define CALLING_TIME 60 // 用于控制呼叫时间,定时器
|
|
|
|
+#define GAIN_CALL_TIME 61
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -66,6 +67,11 @@ void callActivityFinish(CallFinishType type){
|
|
mTextViewNamePtr->setTextTr("CallFailed");
|
|
mTextViewNamePtr->setTextTr("CallFailed");
|
|
mActivityPtr->registerUserTimer(goBack, 5000);
|
|
mActivityPtr->registerUserTimer(goBack, 5000);
|
|
break;
|
|
break;
|
|
|
|
+ case END:
|
|
|
|
+ LOGD("end");
|
|
|
|
+ mediaPlayer.Stop();
|
|
|
|
+ EASYUICONTEXT->goBack();
|
|
|
|
+ break;
|
|
case NOT_FOUND:
|
|
case NOT_FOUND:
|
|
{
|
|
{
|
|
mTextViewNamePtr->setTextTr("NotFound");
|
|
mTextViewNamePtr->setTextTr("NotFound");
|
|
@@ -100,49 +106,58 @@ void callActivityFinish(CallFinishType type){
|
|
case ACCEPT:
|
|
case ACCEPT:
|
|
mActivityPtr->unregisterUserTimer(CALLING_TIME);
|
|
mActivityPtr->unregisterUserTimer(CALLING_TIME);
|
|
break;
|
|
break;
|
|
|
|
+ case GAIN_OK:
|
|
|
|
+ mActivityPtr->unregisterUserTimer(GAIN_CALL_TIME);
|
|
|
|
+ break;
|
|
|
|
+ case GAIN_FAIL:
|
|
|
|
+ mediaPlayer.Stop();
|
|
|
|
+ mTextViewNamePtr->setTextTr("CallAndwered");
|
|
|
|
+ mActivityPtr->registerUserTimer(goBack, 5000);
|
|
|
|
+ break;
|
|
case A1CLICK:
|
|
case A1CLICK:
|
|
LOGD("a1 click");
|
|
LOGD("a1 click");
|
|
|
|
|
|
if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "TCP"){
|
|
if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "TCP"){
|
|
TcpModel storeModel = CallingStatus::instance()->getTcpModel();
|
|
TcpModel storeModel = CallingStatus::instance()->getTcpModel();
|
|
- //只回传iId
|
|
|
|
- storeModel.data = storeModel.json["id"].asString();
|
|
|
|
-
|
|
|
|
- voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
|
- LOGD("info state = %d",info.state);
|
|
|
|
- if (info.state == voip::STATE_CALL_CALLING
|
|
|
|
- || info.state == voip::STATE_CALL_CALLING
|
|
|
|
- || info.state == voip::STATE_CALL_CONFIRMED){
|
|
|
|
- sendVoiceTcp(VoiceAction::HANDOFF, storeModel, storeModel.from_id);
|
|
|
|
- GetTelephone()->Hangup(info.id, voip::SIP_STATUS_CODE_DECLINE);
|
|
|
|
- GetTelephone()->Hangup();
|
|
|
|
-
|
|
|
|
- setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
|
- EASYUICONTEXT->goBack();
|
|
|
|
- }
|
|
|
|
- else if (_isOutgoing == "false"){ //state = 5
|
|
|
|
- mButtonAnswerPtr->setVisible(false);
|
|
|
|
- TcpModel model = CallingStatus::instance()->getTcpModel();
|
|
|
|
- model.data = model.json["id"].asString();
|
|
|
|
- sendVoiceTcp(VoiceAction::ACCEPT, model, model.from_id);
|
|
|
|
-
|
|
|
|
- mActivityPtr->unregisterUserTimer(CALLING_TIME);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- else if (_isOutgoing == "true") {
|
|
|
|
- sendVoiceTcp(VoiceAction::CANCEL, storeModel, storeModel.from_id);
|
|
|
|
-
|
|
|
|
- setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
|
- EASYUICONTEXT->goBack();
|
|
|
|
- }
|
|
|
|
- else if (_isOutgoing == "handleHCall") {
|
|
|
|
- sendVoiceCancel(storeModel.to_id, 0);
|
|
|
|
-
|
|
|
|
- setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
|
- EASYUICONTEXT->goBack();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ if (!storeModel.json.isNull() && storeModel.json > 0 && storeModel.json.isMember("id")) {
|
|
|
|
+ //只回传iId
|
|
|
|
+ storeModel.data = storeModel.json["id"].asString();
|
|
|
|
+
|
|
|
|
+ voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
|
+ LOGD("info state = %d",info.state);
|
|
|
|
+ if (info.state == voip::STATE_CALL_CALLING
|
|
|
|
+ || info.state == voip::STATE_CALL_CALLING
|
|
|
|
+ || info.state == voip::STATE_CALL_CONFIRMED){
|
|
|
|
+ sendVoiceTcp(VoiceAction::HANDOFF, storeModel, storeModel.from_id);
|
|
|
|
+ GetTelephone()->Hangup(info.id, voip::SIP_STATUS_CODE_DECLINE);
|
|
|
|
+ GetTelephone()->Hangup();
|
|
|
|
+
|
|
|
|
+ setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
|
+ EASYUICONTEXT->goBack();
|
|
|
|
+ }
|
|
|
|
+ else if (_callActivityType == "toCall"){ //state = 5
|
|
|
|
+ mediaPlayer.Stop();
|
|
|
|
+ mButtonAnswerPtr->setVisible(false);
|
|
|
|
+ TcpModel model = CallingStatus::instance()->getTcpModel();
|
|
|
|
+ model.data = model.json["id"].asString();
|
|
|
|
+ sendVoiceTcp(VoiceAction::ACCEPT, model, model.from_id);
|
|
|
|
+
|
|
|
|
+ mActivityPtr->unregisterUserTimer(CALLING_TIME);
|
|
|
|
+ }
|
|
|
|
+ else if (_callActivityType == "fromCall") {
|
|
|
|
+ sendVoiceCancel(storeModel.from_id);
|
|
|
|
+ }
|
|
|
|
+ else if (_callActivityType == "handleHCall") {
|
|
|
|
+ sendVoiceCancel(storeModel.to_id, 0);
|
|
|
|
+
|
|
|
|
+ setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
|
+ EASYUICONTEXT->goBack();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ sendVoiceCancel(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
case KEY6_CLICK:
|
|
case KEY6_CLICK:
|
|
LOGD("KEY6 click");
|
|
LOGD("KEY6 click");
|
|
@@ -166,7 +181,7 @@ void callActivityFinish(CallFinishType type){
|
|
|
|
|
|
lightControl("DOORLED", "000F");
|
|
lightControl("DOORLED", "000F");
|
|
}
|
|
}
|
|
- else if (_isOutgoing == "false"){ //state = 5
|
|
|
|
|
|
+ else if (_callActivityType == "toCall"){ //state = 5
|
|
mButtonAnswerPtr->setVisible(false);
|
|
mButtonAnswerPtr->setVisible(false);
|
|
TcpModel model = CallingStatus::instance()->getTcpModel();
|
|
TcpModel model = CallingStatus::instance()->getTcpModel();
|
|
model.data = model.json["id"].asString();
|
|
model.data = model.json["id"].asString();
|
|
@@ -299,42 +314,36 @@ static void onUI_intent(const Intent *intentPtr) {
|
|
_isSleepTimerRegistered = getSleepTimerRegistered();
|
|
_isSleepTimerRegistered = getSleepTimerRegistered();
|
|
setSleepTimerRegistered(false);
|
|
setSleepTimerRegistered(false);
|
|
|
|
|
|
-// wavPlayer.Play(CONFIGMANAGER->getResFilePath("ring.wav"));
|
|
|
|
-// mediaPlayer.Play(CONFIGMANAGER->getResFilePath("ring.wav"));
|
|
|
|
mediaPlayer.Play(CONFIGMANAGER->getResFilePath("ring.wav"), "", 1000,
|
|
mediaPlayer.Play(CONFIGMANAGER->getResFilePath("ring.wav"), "", 1000,
|
|
base::MediaPlayer::PlayMode::Loop);
|
|
base::MediaPlayer::PlayMode::Loop);
|
|
- // 键值解析
|
|
|
|
- _isOutgoing = intentPtr->getExtra(isOutgoing);
|
|
|
|
|
|
|
|
if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
|
|
if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (_isOutgoing == "true"){
|
|
|
|
|
|
+ _callActivityType = intentPtr->getExtra(callActivityType);
|
|
|
|
+
|
|
|
|
+ if (_callActivityType == "fromCall") {
|
|
int toId = 0;
|
|
int toId = 0;
|
|
_toIdStr = intentPtr->getExtra(toIdStr);
|
|
_toIdStr = intentPtr->getExtra(toIdStr);
|
|
if (_toIdStr != "") {
|
|
if (_toIdStr != "") {
|
|
toId = atoi(_toIdStr.c_str());
|
|
toId = atoi(_toIdStr.c_str());
|
|
}
|
|
}
|
|
|
|
+// else {
|
|
|
|
+// std::string _callRoleType = intentPtr->getExtra(callRoleType);
|
|
|
|
+// if (_callRoleType == "") {
|
|
|
|
+// _callRoleType = "NURSE";
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// Json::Value json;
|
|
|
|
+// json["roleType"] = _callRoleType;
|
|
|
|
+// tid = sendVoiceCall(json);
|
|
|
|
+// }
|
|
|
|
|
|
// 呼叫的时候需要把tid放进去
|
|
// 呼叫的时候需要把tid放进去
|
|
tid = sendVoiceCall(toId);
|
|
tid = sendVoiceCall(toId);
|
|
- mButtonAnswerPtr->setVisible(false);
|
|
|
|
-
|
|
|
|
- std::string _callName = intentPtr->getExtra(callName);
|
|
|
|
- if (_callName != "") {
|
|
|
|
- mTextViewNamePtr->setText(LANGUAGEMANAGER->getValue("Call") + _callName);
|
|
|
|
- } else {
|
|
|
|
- mTextViewNamePtr->setTextTr("CallOutTitle");
|
|
|
|
- }
|
|
|
|
|
|
+ setCallTid(tid);
|
|
|
|
|
|
- mActivityPtr->registerUserTimer(CALLING_TIME, 60000); // 如果对方没接听,则发送一个CANCEL回去
|
|
|
|
- }
|
|
|
|
- else if (_isOutgoing == "handleHCall") {
|
|
|
|
- string handleCallIdStr = intentPtr->getExtra(handleCallId);
|
|
|
|
- int _handleCallId = std::stoi(handleCallIdStr);
|
|
|
|
- // 呼叫的时候需要把tid放进去
|
|
|
|
- tid = sendVoiceHCall(_handleCallId);
|
|
|
|
mButtonAnswerPtr->setVisible(false);
|
|
mButtonAnswerPtr->setVisible(false);
|
|
|
|
|
|
std::string _callName = intentPtr->getExtra(callName);
|
|
std::string _callName = intentPtr->getExtra(callName);
|
|
@@ -346,7 +355,7 @@ static void onUI_intent(const Intent *intentPtr) {
|
|
|
|
|
|
mActivityPtr->registerUserTimer(CALLING_TIME, 60000); // 如果对方没接听,则发送一个CANCEL回去
|
|
mActivityPtr->registerUserTimer(CALLING_TIME, 60000); // 如果对方没接听,则发送一个CANCEL回去
|
|
}
|
|
}
|
|
- else {
|
|
|
|
|
|
+ else if (_callActivityType == "toCall") {
|
|
TcpModel storeModel = CallingStatus::instance()->getTcpModel();
|
|
TcpModel storeModel = CallingStatus::instance()->getTcpModel();
|
|
TcpModel backTcp = storeModel;
|
|
TcpModel backTcp = storeModel;
|
|
backTcp.data = storeModel.json["id"].asString();
|
|
backTcp.data = storeModel.json["id"].asString();
|
|
@@ -366,8 +375,37 @@ static void onUI_intent(const Intent *intentPtr) {
|
|
sendVoiceTcp(VoiceAction::ACCEPT, storeModel, storeModel.from_id);
|
|
sendVoiceTcp(VoiceAction::ACCEPT, storeModel, storeModel.from_id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ else if (_callActivityType == "handleHCall") {
|
|
|
|
+ string handleCallIdStr = intentPtr->getExtra(handleCallId);
|
|
|
|
+ int _handleCallId = std::stoi(handleCallIdStr);
|
|
|
|
+ // 呼叫的时候需要把tid放进去
|
|
|
|
+ tid = sendVoiceHCall(_handleCallId);
|
|
|
|
+ setCallTid(tid);
|
|
|
|
+
|
|
|
|
+ mButtonAnswerPtr->setVisible(false);
|
|
|
|
+
|
|
|
|
+ std::string _callName = intentPtr->getExtra(callName);
|
|
|
|
+ if (_callName != "") {
|
|
|
|
+ mTextViewNamePtr->setText(LANGUAGEMANAGER->getValue("Call") + _callName);
|
|
|
|
+ } else {
|
|
|
|
+ mTextViewNamePtr->setTextTr("CallOutTitle");
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ mActivityPtr->registerUserTimer(CALLING_TIME, 60000); // 如果对方没接听,则发送一个CANCEL回去
|
|
|
|
+ }
|
|
|
|
+ else if (_callActivityType == "gainCall") {
|
|
|
|
+ mButtonAnswerPtr->setVisible(false);
|
|
|
|
+
|
|
|
|
+ std::string _callName = intentPtr->getExtra(callName);
|
|
|
|
+ if (_callName != "") {
|
|
|
|
+ mTextViewNamePtr->setText(LANGUAGEMANAGER->getValue("Call") + _callName);
|
|
|
|
+ } else {
|
|
|
|
+ mTextViewNamePtr->setTextTr("CallOutTitle");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mActivityPtr->registerUserTimer(GAIN_CALL_TIME, 60000);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -389,13 +427,13 @@ static void onUI_hide() {
|
|
* 当界面完全退出时触发
|
|
* 当界面完全退出时触发
|
|
*/
|
|
*/
|
|
static void onUI_quit() {
|
|
static void onUI_quit() {
|
|
- if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "TCP"){
|
|
|
|
- EASYUICONTEXT->showNaviBar();
|
|
|
|
- EASYUICONTEXT->showStatusBar();
|
|
|
|
|
|
+ EASYUICONTEXT->showNaviBar();
|
|
|
|
+ EASYUICONTEXT->showStatusBar();
|
|
|
|
|
|
- CallingStatus::instance()->setBusy(false);
|
|
|
|
- CallingStatus::instance()->clearTcpModel();
|
|
|
|
|
|
+ CallingStatus::instance()->setBusy(false);
|
|
|
|
+ CallingStatus::instance()->clearTcpModel();
|
|
|
|
|
|
|
|
+ if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "TCP"){
|
|
voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
if (info.state == voip::STATE_CALL_CALLING
|
|
if (info.state == voip::STATE_CALL_CALLING
|
|
|| info.state == voip::STATE_CALL_CALLING
|
|
|| info.state == voip::STATE_CALL_CALLING
|
|
@@ -405,7 +443,7 @@ static void onUI_quit() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+ _callActivityType = "wait";
|
|
mediaPlayer.Stop();
|
|
mediaPlayer.Stop();
|
|
mActivityPtr->unregisterUserTimer(goBack);
|
|
mActivityPtr->unregisterUserTimer(goBack);
|
|
}
|
|
}
|
|
@@ -482,6 +520,11 @@ static bool onUI_Timer(int id){
|
|
|
|
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+ case GAIN_CALL_TIME: {
|
|
|
|
+ setSleepTimerRegistered(_isSleepTimerRegistered);
|
|
|
|
+ EASYUICONTEXT->goBack();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -540,14 +583,14 @@ static bool onButtonClick_ButtonHangup(ZKButton *pButton) {
|
|
sendVoiceTcp(VoiceAction::HANDOFF, storeModel, storeModel.from_id);
|
|
sendVoiceTcp(VoiceAction::HANDOFF, storeModel, storeModel.from_id);
|
|
GetTelephone()->Hangup(info.id, voip::SIP_STATUS_CODE_DECLINE);
|
|
GetTelephone()->Hangup(info.id, voip::SIP_STATUS_CODE_DECLINE);
|
|
GetTelephone()->Hangup();
|
|
GetTelephone()->Hangup();
|
|
- }
|
|
|
|
- else if (_isOutgoing == "true") {
|
|
|
|
|
|
+ }
|
|
|
|
+ else if (_callActivityType == "fromCall" || _callActivityType == "gainCall") {
|
|
string storeModelStr = getTcpModelString(storeModel);
|
|
string storeModelStr = getTcpModelString(storeModel);
|
|
sendVoiceTcp(VoiceAction::CANCEL, storeModel, storeModel.from_id);
|
|
sendVoiceTcp(VoiceAction::CANCEL, storeModel, storeModel.from_id);
|
|
|
|
|
|
lightControl("DOORLED", "000F");
|
|
lightControl("DOORLED", "000F");
|
|
}
|
|
}
|
|
- else if (_isOutgoing == "handleHCall") {
|
|
|
|
|
|
+ else if (_callActivityType == "handleHCall") {
|
|
LOGD("storeModel.from_id ============> %d", storeModel.from_id);
|
|
LOGD("storeModel.from_id ============> %d", storeModel.from_id);
|
|
sendVoiceCancel(storeModel.to_id, 0);
|
|
sendVoiceCancel(storeModel.to_id, 0);
|
|
|
|
|