X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FCallApp.cpp;h=31f7f52fe6e29028d11d6b147495b2ab509263ed;hb=6a3ed04a7ca44470fdfeb8f35980f99eab5314b2;hp=3eb01cfb60b819ff14ec5b6d05fccf04ffe665e9;hpb=3a941d2e031e4f37eb5981b5b5ad87cd31b61d30;p=apps%2Fosp%2FCall.git diff --git a/src/CallApp.cpp b/src/CallApp.cpp index 3eb01cf..31f7f52 100644 --- a/src/CallApp.cpp +++ b/src/CallApp.cpp @@ -23,7 +23,6 @@ using namespace Tizen::Ui::Scenes; using namespace Tizen::Base::Utility; using namespace Tizen::Base::Collection; using namespace Tizen::Base::Utility; -using namespace Tizen::Shell; CallApp::CallApp(void):__initialSceneId(L""), __pLaunchArgs(null) @@ -47,6 +46,7 @@ CallApp::OnAppInitializing(AppRegistry& appRegistry) { AppControlProviderManager* pProviderMgr = AppControlProviderManager::GetInstance(); pProviderMgr->SetAppControlProviderEventListener(this); + PowerManager::AddScreenEventListener(*this); return true; } @@ -87,6 +87,7 @@ CallApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) // TODO: // Deallocate resources allocated by this App for termination. // The App's permanent data and context can be saved via appRegistry. + PowerManager::RemoveScreenEventListener(*this); return true; } @@ -140,12 +141,21 @@ CallApp::OnScreenOn(void) void CallApp::OnScreenOff(void) { - // TODO: - // Unless there is a strong reason to do otherwise, release resources (such as 3D, media, and sensors) to allow the device - // to enter the sleep mode to save the battery. - // Invoking a lengthy asynchronous method within this listener method can be risky, because it is not guaranteed to invoke a - // callback before the device enters the sleep mode. - // Similarly, do not perform lengthy operations in this listener method. Any operation must be a quick one. + AppLogDebug("Enter"); + IEnumerator* pEnum = __listenerList.GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + IAppStateChangeListener* pInterface = static_cast(pEnum->GetCurrent()); + if (pInterface == null) + { + delete pEnum; + + return; + } + pInterface->OnScreenOff(); + } + delete pEnum; + } SceneId @@ -176,6 +186,12 @@ void CallApp::OnAppControlRequestReceived(RequestId reqId, const String& operationId, const String* pUriData, const String* pMimeType, const IMap* pExtraData) { + AppLogDebug("Enter "); + if(pUriData != null) + { + AppLogDebug("%ls ",pUriData->GetPointer()); + } + if(pExtraData == null && pUriData != null) { //The request is from web app @@ -185,7 +201,7 @@ CallApp::OnAppControlRequestReceived(RequestId reqId, const String& operationId, else { //process AppControl parameters - ProcessAppControlRequest(reqId, operationId, pExtraData); + ProcessAppControlRequest(reqId, operationId, pExtraData,pUriData); } AppLogDebug("EXIT"); } @@ -225,7 +241,7 @@ CallApp::ProcessWebAppControlRequest(RequestId reqId, const String& operationId, } void -CallApp::ProcessAppControlRequest(RequestId reqId, const String& operationId,const IMap* pArgsMap) +CallApp::ProcessAppControlRequest(RequestId reqId, const String& operationId,const IMap* pArgsMap,const String* pUriData) { AppLogDebug("Enter %ls",operationId.GetPointer()); __pLaunchArgs = null; @@ -251,7 +267,7 @@ CallApp::ProcessAppControlRequest(RequestId reqId, const String& operationId,con } else { - HandleDialCallAppControlRequest(reqId, pArgsMap); + HandleDialCallAppControlRequest(reqId, pArgsMap,pUriData); } } else @@ -298,12 +314,17 @@ CallApp::HandleIncomingCallAppControlRequest(RequestId reqId,const IMap* pArgsMa //Fetch incoming call details CallPresentationModel* pCallPresentor = CallPresentationModel::GetInstance(); - CallInfo* pIncomingCall = pCallPresentor->FetchIncomingCallDetailsN(callHandle, contactNumber); + AppCallInfo* pIncomingCall = pCallPresentor->FetchIncomingCallDetailsN(callHandle, contactNumber); if(pIncomingCall != null) { bool isCallRejected = pCallPresentor->CheckIncomingCallToBeRejected(pIncomingCall); if(isCallRejected == false) { + //Abort any AppControl Request running already to show incoming call screen + if (pCallPresentor->IsAppControlRunning() == true) + { + pCallPresentor->AbortAppControlRequest(); + } //save app launch argument list __pLaunchArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); __pLaunchArgs->Construct(1); @@ -322,14 +343,14 @@ CallApp::HandleIncomingCallAppControlRequest(RequestId reqId,const IMap* pArgsMa else { //Show messageBox showing automatic call rejection - MessageBox callRejectedInoMsgBox; + /*MessageBox callRejectedInoMsgBox; String msg(L"Call From "); msg.Append(contactNumber); msg.Append(L" Rejected."); callRejectedInoMsgBox.Construct(L"Call Rejected", msg, MSGBOX_STYLE_NONE,1000); int modalResult = 0; // Calls ShowAndWait() : Draws and Shows itself and processes events - callRejectedInoMsgBox.ShowAndWait(modalResult); + callRejectedInoMsgBox.ShowAndWait(modalResult);*/ //go back to previous scene if App was already running, else exit application. if(__initialSceneId.IsEmpty() == true) @@ -338,7 +359,6 @@ CallApp::HandleIncomingCallAppControlRequest(RequestId reqId,const IMap* pArgsMa AppLog("Terminate Phone Application"); Terminate(); } - } //set success message appControlResult = APP_CTRL_RESULT_SUCCEEDED; @@ -352,7 +372,7 @@ CallApp::HandleIncomingCallAppControlRequest(RequestId reqId,const IMap* pArgsMa } void -CallApp::HandleDialCallAppControlRequest(RequestId reqId,const IMap* pArgsMap) +CallApp::HandleDialCallAppControlRequest(RequestId reqId,const IMap* pArgsMap,const String* pUriData) { //response message AppCtrlResult appControlResult = APP_CTRL_RESULT_FAILED; @@ -375,18 +395,27 @@ CallApp::HandleDialCallAppControlRequest(RequestId reqId,const IMap* pArgsMap) else { AppLogDebug("PARAM_PHONE_NUMBER not present"); + //Now check if tel uri is present + if(pUriData != null) + { + AppLogDebug("pUriData is present %ls",pUriData->GetPointer()); + phoneNumber.Append(*pUriData); + if(phoneNumber.Contains(PARAM_PHONE_NUMBER)) + { + phoneNumber.Replace(PARAM_PHONE_NUMBER,L""); + if(phoneNumber.Contains(DELIMITER)) + { + phoneNumber.Replace(DELIMITER,L""); + AppLogDebug("%ls",phoneNumber.GetPointer()); + } + } + AppLogDebug("%ls",phoneNumber.GetPointer()); + } } delete pKey; //Check if its a valid number if(CheckNumberIsValid(phoneNumber) == false) { - //Show messageBox showing automatic call rejection - MessageBox InvalidNumberMsgBox; - InvalidNumberMsgBox.Construct(AppUtility::GetResourceString(IDS_INVALID_NUMBER), L"",MSGBOX_STYLE_NONE,1000); - int modalResult = 0; - // Calls ShowAndWait() : Draws and Shows itself and processes events - InvalidNumberMsgBox.ShowAndWait(modalResult); - //go back to previous scene if App was already running, else exit application. if(__initialSceneId.IsEmpty() == true) { @@ -396,7 +425,12 @@ CallApp::HandleDialCallAppControlRequest(RequestId reqId,const IMap* pArgsMap) Terminate(); return; } - + else + { + //invalid phone number.always return, but App will come to foreground + //and show current screen, if any calls is present. + return; + } } //call type pKey = new (std::nothrow) String(PARAM_CALL_TYPE); @@ -431,6 +465,11 @@ CallApp::HandleDialCallAppControlRequest(RequestId reqId,const IMap* pArgsMap) int currentActiveCallCount = pCallPresentor->GetCurrentCallCount(); if(currentActiveCallCount <= 1) { + //Abort any AppControl Request running already to show incoming call screen + if (pCallPresentor->IsAppControlRunning() == true) + { + pCallPresentor->AbortAppControlRequest(); + } //make an outgoing call with given number String* contactTxt = new (std::nothrow) String(phoneNumber); __pLaunchArgs = new (std::nothrow) ArrayList(SingleObjectDeleter); @@ -475,13 +514,23 @@ bool CallApp::CheckNumberIsValid(String phoneNumber) { //Pattern to compare all characters except 0-9 * # P ; , + - String phoneNumberPattern(L"[^0-9*#P,+]"); - RegularExpression checkPhoneNumber; + String phoneNumberPattern(L"[^0-9*#P,p+;]"); + String phoneNumberEndingWithHash(L"#$"); + RegularExpression checkPhoneNumber,checkHash; checkPhoneNumber.Construct(phoneNumberPattern); + checkHash.Construct(phoneNumberEndingWithHash); //If there is any character other than these listed above then display invalid number bool resultMatch = checkPhoneNumber.Match(phoneNumber,false); //return false for patterns other than 0-9 * # P ; , + - return !resultMatch; + bool endsWithHash = checkHash.Match(phoneNumber,false); + //returns false for any numbers that end with Hash + if(resultMatch == true || endsWithHash == true) + { + //return phone number is invalid + return false; + } + + return true; } @@ -489,23 +538,41 @@ void CallApp::SetTopMostWindow(bool bTopMost) { AppLogDebug("bTopMost = %d",bTopMost); - result res = E_FAILURE; //ToDO: Need to see if there is better way to handle //this case + if(bTopMost == true) { GetAppFrame()->GetFrame()->SetZOrderGroup(WINDOW_Z_ORDER_GROUP_HIGHEST); - if(PowerManager::IsScreenOn() == false) - { - res = PowerManager::TurnScreenOn(); - } - res = PowerManager::KeepScreenOnState(true,false); + AppManager::GetInstance()->AddActiveAppEventListener(*this); } else { GetAppFrame()->GetFrame()->SetZOrderGroup(WINDOW_Z_ORDER_GROUP_NORMAL); PowerManager::KeepScreenOnState(false); + AppManager::GetInstance()->RemoveActiveAppEventListener(*this); + } + + +} +void +CallApp::OnActiveAppChanged(const String& appId) +{ + result res = E_FAILURE; + AppLogDebug("Enter %ls",appId.GetPointer()); + if(GetAppId().Equals(appId) == true) + { + if(PowerManager::IsScreenOn() == false) + { + AppLogDebug("TurnScreenOn"); + res = PowerManager::TurnScreenOn(); + AppLogDebug("TurnScreenOn %d",res); + } + result res = PowerManager::KeepScreenOnState(true,false); + AppLogDebug("KeepScreenOnState %d",res); + + } }