Fixed recursive appcontrol issue. Fixed Call reject from event injector during answer...
[apps/osp/Call.git] / src / CallApp.cpp
index 093c423..b9f46b6 100644 (file)
@@ -309,6 +309,11 @@ CallApp::HandleIncomingCallAppControlRequest(RequestId reqId,const IMap* pArgsMa
                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);
@@ -327,7 +332,7 @@ 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.");
@@ -343,7 +348,6 @@ CallApp::HandleIncomingCallAppControlRequest(RequestId reqId,const IMap* pArgsMa
                                AppLog("Terminate Phone Application");
                                Terminate();
                        }
-
                }
                //set success message
                appControlResult = APP_CTRL_RESULT_SUCCEEDED;
@@ -401,13 +405,6 @@ CallApp::HandleDialCallAppControlRequest(RequestId reqId,const IMap* pArgsMap,co
                //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)
                        {
@@ -417,7 +414,6 @@ CallApp::HandleDialCallAppControlRequest(RequestId reqId,const IMap* pArgsMap,co
                                Terminate();
                                return;
                        }
-
                }
                //call type
                pKey = new (std::nothrow) String(PARAM_CALL_TYPE);
@@ -452,6 +448,11 @@ CallApp::HandleDialCallAppControlRequest(RequestId reqId,const IMap* pArgsMap,co
                        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);
@@ -496,13 +497,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;
 
 }
 
@@ -519,20 +530,37 @@ CallApp::SetTopMostWindow(bool bTopMost)
                GetAppFrame()->GetFrame()->SetZOrderGroup(WINDOW_Z_ORDER_GROUP_HIGHEST);
                if(PowerManager::IsScreenOn() == false)
                {
+                       AppLogDebug("TurnScreenOn");
                        res = PowerManager::TurnScreenOn();
+                       AppLogDebug("TurnScreenOn %d",res);
                }
-               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);
        }
        //Unlock the phone if its locked
 /*     if(LockManager::GetInstance()->IsLocked())
        {
+               AppLogDebug("Phone Locked");
                LockManager::GetInstance()->Unlock();
        }*/
 
 }
+void
+CallApp::OnActiveAppChanged(const String& appId)
+{
+       AppLogDebug("Enter %ls",appId.GetPointer());
+       if(GetAppId().Equals(appId) == true)
+       {
+               result res = PowerManager::KeepScreenOnState(true,false);
+               AppLogDebug("KeepScreenOnState %d",res);
+
+
+       }
+
+}