Fix for N_SE-47477
[apps/osp/Call.git] / src / CallActiveCallForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        PhnActiveCallForm.cpp
19  * @brief       Active Call Form class
20  */
21 #include <FApp.h>
22 #include <FUi.h>
23 #include <FMedia.h>
24 #include <FSystem.h>
25 #include <FShell.h>
26 #include "CallActiveCallForm.h"
27 #include "CallButtonsPanel.h"
28 #include "CallInfo.h"
29 #include "CallAppUtility.h"
30 #include "CallDtmfKeypadPanel.h"
31 #include "CallPresentationModel.h"
32 #include "CallSceneRegister.h"
33 #include "CallTypes.h"
34 #include "CallApp.h"
35
36 using namespace Tizen::App;
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Collection;
39 using namespace Tizen::Base::Utility;
40 using namespace Tizen::Graphics;
41 using namespace Tizen::Media;
42 using namespace Tizen::Social;
43 using namespace Tizen::System;
44 using namespace Tizen::Ui;
45 using namespace Tizen::Ui::Controls;
46 using namespace Tizen::Ui::Scenes;
47 using namespace Tizen::Shell;
48
49 //constants
50 const int IDI_MAX_SECONDS = 60;
51 const int IDI_MAX_MINS = 60;
52 const int W_HOLD_BITMAP = 78;
53 const int H_HOLD_BITMAP = 78;
54 //for Options menu list
55 const int IDI_POPUP_TEXT_SIZE = 33;
56 const unsigned int COLOR_POPUP_TEXT = Color32<255, 255, 255, 255>::Value;
57 const int IDI_MOREOPTIONS_LIST_ITEMS = 1;
58 const int W_OPTION_ANCHOR = 72;
59 const int H_OPTION_ANCHOR = 22;
60 const int W_MGR_CONFCALL_BITMAP = 64;
61 const int H_MGR_CONFCALL_BITMAP = 64;
62 const int X_POPUP_ANCHOR = 632;
63 const int Y_POPUP_ANCHOR = 140;
64 const int W_POPUP_ANCHOR = 72;
65 const int H_POPUP_ANCHOR = 22;
66 const int IDI_OPTIONMENU_ITEM_SPACING = 16;
67 const Point IDI_OPTIONMENU_POS(238, 162);
68 const Dimension IDI_OPTIONMENU_DIMEN(466, 99);
69 const int X_PHOTO_LBL = 166;
70 const int Y_PHOTO_LBL = 232;
71 const int W_PHOTO_LBL = 388;
72 const int H_PHOTO_LBL = 388;
73 const int W_PHOTO_LABEL = 720;
74 const int H_PHOTO_LABEL = 720;
75 const int W_RIGHT_MORE_ICON_MARGIN = 24;
76 const int W_MORE_LABEL = 466;
77 const int H_MORE_LABEL = 162;
78 const int W_MORE_ICON = 70;
79
80 static const wchar_t* IDC_CONF_CALL_MORE_BUTTON = L"IDC_CONF_CALL_MORE_BUTTON";
81 static const wchar_t* IDC_HOLD_BUTTON = L"IDC_HOLD_BUTTON";
82 static const wchar_t* IDC_SWAP_BUTTON = L"IDC_SWAP_BUTTON";
83 static const wchar_t* IDC_HOLD_LABEL = L"IDC_HOLD_LABEL";
84 static const wchar_t* IDC_TEXTBOX = L"IDC_NUM_EDITFIELD";
85 static const wchar_t* IDC_CALLER1_LABEL = L"IDC_CALLER1_LABEL";
86 static const wchar_t* IDC_BACKGROUND_LABEL = L"IDC_BACKGROUND_LABEL";
87 static const wchar_t* IDC_CALLER1_TIME_LABEL = L"IDC_CALLER1_TIME_LABEL";
88 static const wchar_t* IDC_NUMBER1_LABEL = L"IDC_NUMBER1_LABEL";
89 static const wchar_t* IDC_VOICE_CALL_ICON_LABEL = L"IDC_VOICE_CALL_ICON_LABEL";
90 static const wchar_t* IDC_CALLER2_LABEL = L"IDC_CALLER2_LABEL";
91 static const wchar_t* IDC_NUMBER2_LABEL = L"IDC_NUMBER2_LABEL";
92 static const wchar_t* IDC_CALLER2_TIME_LABEL = L"IDC_CALLER2_TIME_LABEL";
93 static const wchar_t* IDC_SWAP_LABEL = L"IDC_SWAP_LABEL";
94 static const wchar_t* IDC_BACKGROUND_LABEL2 = L"IDC_BACKGROUND_LABEL2";
95 static const wchar_t* IDC_PARTICIPANTS_LABEL = L"IDC_PARTICIPANTS_LABEL";
96 static const wchar_t* IDC_CALLER1_BIGPHOTO_LABEL = L"IDC_CALLER1_BIGPHOTO_LABEL";
97 static const wchar_t* IDC_CALLER2_PHOTO_LABEL = L"IDC_CALLER2_PHOTO_LABEL";
98 static const wchar_t* IDC_CALLER1_PHOTO_LABEL = L"IDC_CALLER1_PHOTO_LABEL";
99 static const wchar_t* IDC_KEY_BG_LABEL = L"IDC_KEY_BG_LABEL";
100
101 ActiveCallForm::ActiveCallForm(FormType formType)
102         : BaseForm(formType)
103 {
104         __pActiveCallTimer = null;
105         __pCallButtonsPanel = null;
106         __pDTMFKeypad = null;
107         __pMoreOptionsList = null;
108         __pMoreOptionsListAnchor = null;
109         __pSmallPhotoLabel = null;
110         __pActiveCallInfo = null;
111         __pHeldCallInfo = null;
112         __isSwapInProgress = false;
113         __pAddressbook = null;
114 }
115
116 ActiveCallForm::~ActiveCallForm(void)
117 {
118         if (__pActiveCallTimer != null)
119         {
120                 __pActiveCallTimer->Cancel();
121                 delete __pActiveCallTimer;
122         }
123         if (__pMoreOptionsList != null)
124         {
125                 __pMoreOptionsList = null;
126         }
127         if (__pMoreOptionsListAnchor != null)
128         {
129                 __pMoreOptionsListAnchor = null;
130         }
131         if (__pSmallPhotoLabel != null)
132         {
133                 __pSmallPhotoLabel = null;
134         }
135         if (__pActiveCallInfo != null)
136         {
137                 delete __pActiveCallInfo;
138         }
139         if (__pHeldCallInfo != null)
140         {
141                 delete __pHeldCallInfo;
142         }
143         if(__pDTMFKeypad != null)
144         {
145                 __pDTMFKeypad = null;
146         }
147 }
148
149 void
150 ActiveCallForm::Initialize(void)
151 {
152         switch (__formType)
153         {
154         case FORMTYPE_OUTGOINGCALL:
155                 Construct(IDL_OUTCALL_FORM);
156                 break;
157
158         case FORMTYPE_EMERGENCYOUTGOINGCALL:
159                 Construct(IDL_OUT_EMERGENCYCALL_FORM);
160                 break;
161
162         case FORMTYPE_ACTIVECALL:
163                 Construct(IDL_CALL_FORM);
164                 break;
165
166         case FORMTYPE_EMERGENCYACTIVECALL:
167                 Construct(IDL_EMERGENCY_CALL_FORM);
168                 break;
169
170         case FORMTYPE_MULTIPLECALLS:
171                 Construct(IDL_MULTIPLE_CALL_FORM);
172                 break;
173
174         case FORMTYPE_ACTIVECONFCALL:
175                 Construct(IDL_CONFCALL_FORM);
176                 break;
177
178         default:
179                 break;
180         }
181 }
182
183 result
184 ActiveCallForm::OnInitializing(void)
185 {
186         result r = E_SUCCESS;
187
188         //Hold Button - Shown on single active/conf call scene
189         InitializeHoldButton();
190         //Swap button for multiple call screen
191         InitializeSwapButton();
192         //Initialize manage conf. call list form
193         InitializeManageConfCallButton();
194
195         __pCallPresentor = CallPresentationModel::GetInstance();
196         return r;
197 }
198
199 void
200 ActiveCallForm::ShowDTMFKeypad(void)
201 {
202         if(__pDTMFKeypad == null)
203         {
204                 //update rect according to client screen area
205                 Rectangle rect(0, 0, 0, 0);
206                 if (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
207                 {
208                         rect.width = GetClientAreaBounds().width;
209                         rect.height = GetClientAreaBounds().height - __pCallButtonsPanel->GetHeight();
210                 }
211                 else if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
212                 {
213                         rect.height = GetClientAreaBounds().height;
214                         rect.width = GetClientAreaBounds().width - __pCallButtonsPanel->GetWidth();
215                 }
216
217                 AppLog("DTMF Keypad rect(%d,%d,%d,%d)",rect.x,rect.y,rect.width,rect.height);
218                 __pDTMFKeypad = new (std::nothrow) DtmfKeyPadPanel();
219                 __pDTMFKeypad->Initialize(this, rect);
220                 AddControl(__pDTMFKeypad);
221
222                 //set layout relation w.r.t call buttons panel
223                 RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(GetLandscapeLayoutN());
224                 if (pRelativeLayout != null)
225                 {
226                         pRelativeLayout->SetRelation(*__pDTMFKeypad, this, RECT_EDGE_RELATION_LEFT_TO_LEFT);
227                         pRelativeLayout->SetRelation(*__pDTMFKeypad, __pCallButtonsPanel, RECT_EDGE_RELATION_RIGHT_TO_LEFT);
228                 }
229         }
230         __pDTMFKeypad->SetShowState(true);
231         if(__DtmfString.IsEmpty() == false)
232         {
233                 EditField* pTextBox = static_cast<EditField*>(__pDTMFKeypad->GetControl(IDC_TEXTBOX));
234                 pTextBox->SetText(__DtmfString);
235         }
236         __pDTMFKeypad->Draw(true);
237         __pDTMFKeypad->Show();
238 }
239
240 void
241 ActiveCallForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
242 {
243         AppLog("ENTER");
244
245         if (__pCallButtonsPanel != null)
246         {
247                 //update position of call buttons panel
248                 Label* pKeysBgLbl = static_cast<Label*>(GetControl(IDC_KEY_BG_LABEL, true));
249                 __pCallButtonsPanel->SetBounds(pKeysBgLbl->GetBounds());
250
251                 //bring button on top
252                 __pCallButtonsPanel->SetButtonPosition();
253
254                 RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(GetPortraitLayoutN());
255                 if (pRelativeLayout != null)
256                 {
257                         pRelativeLayout->SetRelation(*__pCallButtonsPanel, *pKeysBgLbl, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM);
258                 }
259
260                 pRelativeLayout = dynamic_cast<RelativeLayout*>(GetLandscapeLayoutN());
261                 if (pRelativeLayout != null)
262                 {
263                         pRelativeLayout->SetRelation(*__pCallButtonsPanel, *pKeysBgLbl, RECT_EDGE_RELATION_LEFT_TO_LEFT);
264                         pRelativeLayout->SetRelation(*__pCallButtonsPanel, *pKeysBgLbl, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
265                 }
266
267                 //change orientation of DTMF Keypad, if it is visible.
268                 if (__pDTMFKeypad != null)
269                 {
270                         if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
271                         {
272                                 //in landscape mode, caller info is visible.
273                                 SetShowStateOnKeypad(true);
274                                 SetHoldButtonShowState(false);
275                         }
276                         else if (orientationStatus == ORIENTATION_STATUS_PORTRAIT || orientationStatus == ORIENTATION_STATUS_PORTRAIT_REVERSE)
277                         {
278                                 //in Portrait mode it is hidden beneath DTMF Keypad.
279                                 SetShowStateOnKeypad(false);
280                                 DestroyMoreOptionsMenuList();
281                         }
282                         if(__pDTMFKeypad->GetShowState() == true)
283                         {
284                                 String dtmfText = static_cast<EditField*>(__pDTMFKeypad->GetControl(IDC_TEXTBOX))->GetText();
285                                 HideDTMFKeypad();
286                                 ShowDTMFKeypad();
287                         }
288                 }
289         }
290         //More option is displayed recreate it
291         if(__pMoreOptionsListAnchor != null)
292         {
293                 CreateMoreOptionsMenuList();
294                 CreateMoreOptionsMenuList();
295         }
296 }
297
298 void
299 ActiveCallForm::HideDTMFKeypad(void)
300 {
301         if(__pDTMFKeypad != null)
302         {
303                 __DtmfString = static_cast<EditField*>(__pDTMFKeypad->GetControl(IDC_TEXTBOX))->GetText();
304
305                 RemoveControl(__pDTMFKeypad);
306                 __pDTMFKeypad = null;
307         }
308 }
309
310 result
311 ActiveCallForm::InitializeCallButtonsPanel(void)
312 {
313         result r = E_SUCCESS;
314         //Set background bitmap for call keypad
315         Label* pKeysBgLbl = static_cast<Label*>(GetControl(IDC_KEY_BG_LABEL, true));
316         Bitmap* pBgBitmap = AppUtility::GetBitmapFromResourcesN(IDB_BACKGROUND_BITMAP, pKeysBgLbl->GetWidth(), pKeysBgLbl->GetHeight());
317         if (pBgBitmap != null)
318         {
319                 pKeysBgLbl->SetBackgroundBitmap(*pBgBitmap);
320         }
321
322         if (__pCallButtonsPanel == null)
323         {
324                 __pCallButtonsPanel = new (std::nothrow) CallButtonsPanel();
325                 __pCallButtonsPanel->ConstructPanel(this, __formType);
326                 __pCallButtonsPanel->SetBounds(pKeysBgLbl->GetBounds());
327                 r = AddControl(__pCallButtonsPanel);
328         }
329
330         RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(GetPortraitLayoutN());
331         if (pRelativeLayout != null)
332         {
333                 pRelativeLayout->SetRelation(*__pCallButtonsPanel, *pKeysBgLbl, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM);
334         }
335         pRelativeLayout = dynamic_cast<RelativeLayout*>(GetLandscapeLayoutN());
336         if (pRelativeLayout != null)
337         {
338                 pRelativeLayout->SetRelation(*__pCallButtonsPanel, *pKeysBgLbl, RECT_EDGE_RELATION_LEFT_TO_LEFT);
339                 pRelativeLayout->SetRelation(*__pCallButtonsPanel, *pKeysBgLbl, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
340                 pRelativeLayout->SetRelation(*__pCallButtonsPanel, *pKeysBgLbl, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM);
341                 pRelativeLayout->SetRelation(*__pCallButtonsPanel, *pKeysBgLbl, RECT_EDGE_RELATION_TOP_TO_TOP);
342         }
343
344         return r;
345 }
346
347 void
348 ActiveCallForm::InitializeSwapButton(void)
349 {
350         Button* pSwapBtn = static_cast<Button*>(GetControl(IDC_SWAP_BUTTON));
351         if (pSwapBtn)
352         {
353                 Bitmap* pSwapBmp = AppUtility::GetBitmapFromResourcesN(IDB_SWAP_ICON_NORMAL,
354                                                                                                                            W_HOLD_BITMAP, H_HOLD_BITMAP);
355                 if (pSwapBmp)
356                 {
357                         pSwapBtn->SetNormalBitmap(Point(0, 0), *pSwapBmp);
358                 }
359                 delete pSwapBmp;
360                 pSwapBmp = null;
361
362                 pSwapBmp = AppUtility::GetBitmapFromResourcesN(IDB_SWAP_ICON_PRESS,
363                                                                                                            W_HOLD_BITMAP, H_HOLD_BITMAP);
364                 if (pSwapBmp)
365                 {
366                         pSwapBtn->SetPressedBitmap(Point(0, 0), *pSwapBmp);
367                 }
368                 delete pSwapBmp;
369                 pSwapBmp = null;
370                 pSwapBtn->SetActionId(IDA_SWAP_CALLS);
371                 pSwapBtn->AddActionEventListener(*this);
372         }
373 }
374
375 void
376 ActiveCallForm::InitializeManageConfCallButton(void)
377 {
378         Button* pMoreBtn = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
379         if (pMoreBtn != null)
380         {
381                 pMoreBtn->SetActionId(IDA_MORE_OPTIONS_MENU);
382                 pMoreBtn->AddActionEventListener(*this);
383                 if (__formType == FORMTYPE_MULTIPLECALLS)
384                 {
385                         //Correct state will be set in OnSceneActivated based on the call
386                         pMoreBtn->SetShowState(false);
387                 }
388                 else if (__formType == FORMTYPE_ACTIVECONFCALL)
389                 {
390                         pMoreBtn->SetShowState(true);
391                 }
392         }
393 }
394
395 void
396 ActiveCallForm::InitializeHoldButton(void)
397 {
398         Button* pHoldBtn = static_cast<Button*>(GetControl(IDC_HOLD_BUTTON));
399         if (pHoldBtn != null)
400         {
401                 //set status of Hold Button
402                 SetHoldButtonStatus(true);
403                 pHoldBtn->AddActionEventListener(*this);
404         }
405 }
406
407 void
408 ActiveCallForm::SetHoldButtonStatus(bool toHoldCall)
409 {
410         //background bitmap & button name
411         String btnName("");
412         Bitmap* normalImg = null;
413         Bitmap* pressImg = null;
414         if (toHoldCall)
415         {
416                 btnName.Append(AppUtility::GetResourceString(IDS_HOLD_BTN_NAME));
417                 normalImg = AppUtility::GetBitmapFromResourcesN(IDB_HOLD_NORMAL_BUTTON_ICON,
418                                                                                                                 W_HOLD_BITMAP, H_HOLD_BITMAP);
419                 pressImg = AppUtility::GetBitmapFromResourcesN(IDB_HOLD_PRESS_BUTTON_ICON,
420                                                                                                            W_HOLD_BITMAP, H_HOLD_BITMAP);
421         }
422         else
423         {
424                 btnName.Append(AppUtility::GetResourceString(IDS_UNHOLD_BTN_NAME));
425                 normalImg = AppUtility::GetBitmapFromResourcesN(IDB_UNHOLD_NORMAL_BUTTON_ICON,
426                                                                                                                 W_HOLD_BITMAP, H_HOLD_BITMAP);
427                 pressImg = AppUtility::GetBitmapFromResourcesN(IDB_UNHOLD_PRESS_BUTTON_ICON,
428                                                                                                            W_HOLD_BITMAP, H_HOLD_BITMAP);
429         }
430
431         //Action id
432         CommandIds cmdId = IDA_HOLD_CALL;
433         switch (__formType)
434         {
435         case FORMTYPE_ACTIVECALL:
436         {
437                 cmdId = toHoldCall ? IDA_HOLD_CALL : IDA_UNHOLD_CALL;
438         }
439         break;
440
441         case FORMTYPE_ACTIVECONFCALL:
442         {
443                 cmdId = toHoldCall ? IDA_HOLD_CONF_CALL : IDA_UNHOLD_CONF_CALL;
444         }
445         break;
446
447         default:
448                 break;
449         }
450
451         //set background bitmap, button name & action id
452         Button* pHoldBtn = static_cast<Button*>(GetControl(IDC_HOLD_BUTTON));
453         Label* pHoldLbl = static_cast<Label*>(GetControl(IDC_HOLD_LABEL));
454         if (pHoldBtn)
455         {
456                 pHoldBtn->SetActionId(cmdId);
457                 pHoldBtn->SetNormalBitmap(Point(0, 0),*normalImg);
458                 pHoldBtn->SetPressedBitmap(Point(0, 0),*pressImg);
459                 pHoldBtn->Invalidate(true);
460         }
461         if (pHoldLbl)
462         {
463                 pHoldLbl->SetText(btnName);
464                 pHoldLbl->Invalidate(true);
465         }
466
467         //free the resources
468         delete normalImg;
469         normalImg = null;
470         delete pressImg;
471         pressImg = null;
472 }
473
474 void
475 ActiveCallForm::CreateMoreOptionsMenuList(void)
476 {
477         //create option list anchor
478         if (__pMoreOptionsListAnchor == null)
479         {
480                 Bitmap* pBgPopupArwBmp = AppUtility::GetBitmapFromResourcesN(IDB_POPUP_ARROW_ICON, W_OPTION_ANCHOR,
481                                                                                                                                          H_OPTION_ANCHOR);
482                 __pMoreOptionsListAnchor = new (std::nothrow) Label();
483                 __pMoreOptionsListAnchor->Construct(Rectangle(GetWidth()-W_RIGHT_MORE_ICON_MARGIN - W_MORE_ICON, Y_POPUP_ANCHOR, W_POPUP_ANCHOR, H_POPUP_ANCHOR), L"");
484                 __pMoreOptionsListAnchor->SetBackgroundBitmap(*pBgPopupArwBmp);
485
486                 delete pBgPopupArwBmp;
487                 pBgPopupArwBmp = null;
488
489                 // Adds a Label to the Form
490                 AddControl(__pMoreOptionsListAnchor);
491         }
492
493         //create options menu list
494         if (__pMoreOptionsList == null)
495         {
496                 __pMoreOptionsList = new (std::nothrow) ListView();
497                 __pMoreOptionsList->Construct(Rectangle(Point(GetWidth()-W_RIGHT_MORE_ICON_MARGIN - W_MORE_LABEL,H_MORE_LABEL), IDI_OPTIONMENU_DIMEN), false, SCROLL_STYLE_FADE_OUT);
498                 __pMoreOptionsList->SetItemProvider(*this);
499                 __pMoreOptionsList->AddListViewItemEventListener(*this);
500                 //Add option list to the form
501                 AddControl(__pMoreOptionsList);
502         }
503         else
504         {
505                 //Hide option menu list
506                 DestroyMoreOptionsMenuList();
507         }
508 }
509
510 void
511 ActiveCallForm::DestroyMoreOptionsMenuList(void)
512 {
513         if (__pMoreOptionsListAnchor != null)
514         {
515                 //removes and delete the child control
516                 RemoveControl(__pMoreOptionsListAnchor);
517                 __pMoreOptionsListAnchor = null;
518         }
519
520         if (__pMoreOptionsList != null)
521         {
522                 //removes and delete the child control
523                 RemoveControl(__pMoreOptionsList);
524                 __pMoreOptionsList = null;
525         }
526 }
527
528 result
529 ActiveCallForm::OnTerminating(void)
530 {
531         result r = E_SUCCESS;
532         if (__pCallPresentor != null)
533         {
534                 __pCallPresentor = null;
535         }
536         return r;
537 }
538
539 void
540 ActiveCallForm::OnActionPerformed(const Control& source, int actionId)
541 {
542
543         String dtmfString;
544         switch (actionId)
545         {
546         case IDA_END_CALL:
547         {
548                 //End the currently active / dialing call
549                 if (__pActiveCallInfo->IsConferenceCall() == false)
550                 {
551                         String activeContactNo;
552                         activeContactNo.Append(__pActiveCallInfo->GetContactNumber());
553                         //Check if it is call is in dialing state, then
554                         if (__formType == FORMTYPE_EMERGENCYOUTGOINGCALL || __formType == FORMTYPE_OUTGOINGCALL)
555                         {
556                                 __pCallPresentor->EndDialingCall(activeContactNo);
557                         }
558                         else
559                         {
560                                 //end active calls
561                                 __pCallPresentor->EndActiveCall(*__pActiveCallInfo->GetCallHandle());
562                         }
563                 }
564                 else
565                 {
566                         __pCallPresentor->EndConferenceCall();
567                 }
568         }
569         break;
570
571         case IDA_END_CONF_CALL:
572         {
573                 AppAssert(__formType == FORMTYPE_ACTIVECONFCALL);
574                 __pCallPresentor->EndConferenceCall();
575         }
576         break;
577
578         case IDA_OPEN_NUMKEYPAD:
579         {
580                 if (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
581                 {
582                         //hide only in portrait mode.
583                         SetShowStateOnKeypad(false);
584                         DestroyMoreOptionsMenuList();
585                 }
586                 //Hide the hold button as it goes behind DTMF keypad
587                 SetHoldButtonShowState(false);
588                 ShowDTMFKeypad();
589                 __pCallButtonsPanel->SetKeypadButtonState(IDA_CLOSE_NUMKEYPAD);
590         }
591         break;
592
593         case IDA_CLOSE_NUMKEYPAD:
594         {
595                 SetShowStateOnKeypad(true);
596                 HideDTMFKeypad();
597                 __pCallButtonsPanel->SetKeypadButtonState(IDA_OPEN_NUMKEYPAD);
598         }
599         break;
600
601         case IDA_ADD_CALL:
602         {
603                 //switch to Dialer Form to make an call
604                 if(__pCallPresentor->GetCurrentCallCount() == 1)
605                 {
606                 __pCallPresentor->LaunchDialAppControl();
607                 }
608         }
609         break;
610
611         case IDA_HOLD_CALL:
612         {
613                 bool success = true;
614                 if (__pActiveCallInfo->IsConferenceCall() == false)
615                 {
616                         if(__pActiveCallInfo->GetCallHandle() != null)
617                         {
618                                 success = __pCallPresentor->HoldCall(*__pActiveCallInfo->GetCallHandle());
619                         }
620                 }
621                 else
622                 {
623                         success = __pCallPresentor->HoldConferenceCall();
624                 }
625                 //reset hold status and "OnHold" text
626                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, success);
627                 if(__pActiveCallTimer != null)
628                 {
629                         __pActiveCallTimer->Cancel();
630                 }
631                 SetHoldButtonStatus(!success);
632         }
633         break;
634
635         case IDA_UNHOLD_CALL:
636         {
637                 bool success = false;
638                 if (__pActiveCallInfo->IsConferenceCall() == false)
639                 {
640                         if(__pActiveCallInfo->GetCallHandle() != null)
641                         {
642                                 success = __pCallPresentor->UnHoldCall(*__pActiveCallInfo->GetCallHandle());
643                         }
644                 }
645                 else
646                 {
647                         success = __pCallPresentor->ActivateConferenceCall();
648                 }
649                 //reset hold status and show call timer
650                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, !success, __activeCallStartTime);
651                 SetHoldButtonStatus(success);
652         }
653         break;
654
655         case IDA_HOLD_CONF_CALL:
656         {
657                 AppAssert(__formType == FORMTYPE_ACTIVECONFCALL);
658                 bool success = __pCallPresentor->HoldConferenceCall();
659                 //reset hold status and "OnHold" text
660                 SetHoldButtonStatus(!success);
661                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, success);
662                 if(__pActiveCallTimer != null)
663                 {
664                         __pActiveCallTimer->Cancel();
665                 }
666         }
667         break;
668
669         case IDA_UNHOLD_CONF_CALL:
670         {
671                 AppAssert(__formType == FORMTYPE_ACTIVECONFCALL);
672                 bool success = __pCallPresentor->ActivateConferenceCall();
673                 //reset hold status and show call timer
674                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, !success, __activeCallStartTime);
675                 SetHoldButtonStatus(success);
676         }
677         break;
678
679         case IDA_OPEN_CONTACTS:
680         {
681                 //Open Contacts APP
682                 //Launch call application
683                 AppManager* pAppManager = AppManager::GetInstance();
684                 pAppManager->LaunchApplication(PROVIDER_ID_CONTACTS);
685         }
686                 break;
687
688         case IDA_MUTE:
689         {
690                 bool success = __pCallPresentor->SetMuteStatus(true);
691                 if (success)
692                 {
693                         __pCallButtonsPanel->SetMuteButtonState(IDA_UNMUTE);
694                 }
695         }
696         break;
697
698         case IDA_UNMUTE:
699         {
700                 bool success = __pCallPresentor->SetMuteStatus(false);
701                 if (success)
702                 {
703                         __pCallButtonsPanel->SetMuteButtonState(IDA_MUTE);
704                 }
705         }
706         break;
707
708         case IDA_SPEAKER:
709         {
710                 bool success = __pCallPresentor->SetSpeakerStatus(true);
711                 if (success)
712                 {
713                         __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER_OFF);
714                 }
715         }
716         break;
717
718         case IDA_SPEAKER_OFF:
719         {
720                 bool success = __pCallPresentor->SetSpeakerStatus(false);
721                 if (success)
722                 {
723                         __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER);
724                 }
725         }
726         break;
727
728         case IDA_JOIN_CALL:
729         {
730                 AppAssert(__formType == FORMTYPE_MULTIPLECALLS);
731                 __pCallPresentor->JoinCall();
732         }
733         break;
734
735         case IDA_SWAP_CALLS:
736         {
737                 if(IsSwapInProgress() == false)
738                 {
739                         AppAssert(__formType == FORMTYPE_MULTIPLECALLS);
740                         __pCallPresentor->SwapCalls();
741                         SetSwapInProgress(true);
742                 }
743         }
744         break;
745
746         case IDA_MORE_OPTIONS_MENU:
747         {
748                 //Show 'more' options menu
749                 CreateMoreOptionsMenuList();
750         }
751         break;
752
753         case NUM_KEY0:
754         {
755                 dtmfString.Append(L"0");
756                 SetTextToDTMFTextField(dtmfString);
757                 __pCallPresentor->SendDTMFSignal(dtmfString);
758         }
759         break;
760
761         case NUM_KEY1:
762         {
763                 dtmfString.Append(L"1");
764                 SetTextToDTMFTextField(dtmfString);
765                 __pCallPresentor->SendDTMFSignal(dtmfString);
766         }
767         break;
768
769         case NUM_KEY2:
770         {
771                 dtmfString.Append(L"2");
772                 SetTextToDTMFTextField(dtmfString);
773                 __pCallPresentor->SendDTMFSignal(dtmfString);
774         }
775         break;
776
777         case NUM_KEY3:
778         {
779                 dtmfString.Append(L"3");
780                 SetTextToDTMFTextField(dtmfString);
781                 __pCallPresentor->SendDTMFSignal(dtmfString);
782         }
783         break;
784
785         case NUM_KEY4:
786         {
787                 dtmfString.Append(L"4");
788                 SetTextToDTMFTextField(dtmfString);
789                 __pCallPresentor->SendDTMFSignal(dtmfString);
790         }
791         break;
792
793         case NUM_KEY5:
794         {
795                 dtmfString.Append(L"5");
796                 SetTextToDTMFTextField(dtmfString);
797                 __pCallPresentor->SendDTMFSignal(dtmfString);
798         }
799         break;
800
801         case NUM_KEY6:
802         {
803                 dtmfString.Append(L"6");
804                 SetTextToDTMFTextField(dtmfString);
805                 __pCallPresentor->SendDTMFSignal(dtmfString);
806         }
807         break;
808
809         case NUM_KEY7:
810         {
811                 dtmfString.Append(L"7");
812                 SetTextToDTMFTextField(dtmfString);
813                 __pCallPresentor->SendDTMFSignal(dtmfString);
814         }
815         break;
816
817         case NUM_KEY8:
818         {
819                 dtmfString.Append(L"8");
820                 SetTextToDTMFTextField(dtmfString);
821                 __pCallPresentor->SendDTMFSignal(dtmfString);
822         }
823         break;
824
825         case NUM_KEY9:
826         {
827                 dtmfString.Append(L"9");
828                 SetTextToDTMFTextField(dtmfString);
829                 __pCallPresentor->SendDTMFSignal(dtmfString);
830         }
831         break;
832
833         case PAUSE_KEY:
834         {
835                 dtmfString.Append(L"*");
836                 SetTextToDTMFTextField(dtmfString);
837                 __pCallPresentor->SendDTMFSignal(dtmfString);
838         }
839         break;
840
841         case HASH_KEY:
842         {
843                 dtmfString.Append(L"#");
844                 SetTextToDTMFTextField(dtmfString);
845                 __pCallPresentor->SendDTMFSignal(dtmfString);
846         }
847         break;
848
849         default:
850                 break;
851         }
852 }
853
854 bool
855 ActiveCallForm::IsSwapInProgress(void)
856 {
857         return __isSwapInProgress;
858 }
859
860 void
861 ActiveCallForm::SetSwapInProgress(bool progress)
862 {
863         __isSwapInProgress = progress;
864 }
865
866 void
867 ActiveCallForm::SetTextToDTMFTextField(const String& dtmfStr)
868 {
869         if(__pDTMFKeypad != null)
870         {
871                 EditField* pTextBox = static_cast<EditField*>(__pDTMFKeypad->GetControl(IDC_TEXTBOX));
872
873                 int startpos=-1,endpos=-1;
874                 pTextBox->GetBlockRange(startpos,endpos);
875                 if(startpos != -1)
876                 {
877                         pTextBox->Remove();
878                         pTextBox->ReleaseBlock();
879                 }
880
881                 pTextBox->InsertTextAtCursorPosition(dtmfStr);
882                 //pTextBox->AppendText(dtmfStr);
883                 pTextBox->SetFocus();
884                 pTextBox->Invalidate(true);
885         }
886 }
887
888 void
889 ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
890 {
891         AppLog("ENTER");
892         //set itself as listener
893         __pCallPresentor->SetTelEventListener(this);
894         AddOrientationEventListener(*this);
895
896         CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
897         pPhoneApp->AddAppStateChangeListener(*this);
898
899         //Initialize keypad and buttons
900         InitializeCallButtonsPanel();
901
902         AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
903         __pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);
904         if(__pAddressbook != null)
905         {
906                 __pAddressbook->SetAddressbookChangeEventListener(this);
907         }
908
909
910         if (__pActiveCallInfo != null)
911         {
912                 delete __pActiveCallInfo;
913                 __pActiveCallInfo = null;
914         }
915         if (__pHeldCallInfo != null)
916         {
917                 delete __pHeldCallInfo;
918                 __pHeldCallInfo = null;
919         }
920         DestroyMoreOptionsMenuList();
921
922         switch (__formType)
923         {
924         case FORMTYPE_OUTGOINGCALL:
925         {
926                 String contactNo;
927                 contactNo.Append(*(static_cast<String*>(pArgs->GetAt(0))));
928                 __pActiveCallInfo = new (std::nothrow) AppCallInfo();
929                 __pActiveCallInfo->SetContactNumber(contactNo);
930                 Contact* pContact = __pCallPresentor->GetContactN(contactNo);
931                 if (pContact != null)
932                 {
933                         __pActiveCallInfo->SetContactInfo(*pContact);
934                         delete pContact;
935                 }
936                 ShowPersonDetails(contactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
937                 //make an normal outgoing call
938                 __pCallPresentor->DialCall(contactNo, false);
939         }
940         break;
941
942         case FORMTYPE_EMERGENCYOUTGOINGCALL:
943         {
944                 String* pContactNo = static_cast<String*>(pArgs->GetAt(0));
945                 __pActiveCallInfo = new (std::nothrow) AppCallInfo();
946                 long long phNumber = 0;
947                 LongLong::Parse(*pContactNo, phNumber);
948                 __pActiveCallInfo->SetContactNumber(*pContactNo);
949                 //make an emergency call
950                 __pCallPresentor->DialCall(*pContactNo, true);
951         }
952         break;
953
954         case FORMTYPE_ACTIVECALL:
955         {
956                 //get contact number
957                 AppCallInfo* pCall = static_cast<AppCallInfo*>(pArgs->GetAt(0));
958
959                 __pActiveCallInfo = new (std::nothrow) AppCallInfo();
960                 *__pActiveCallInfo =  *pCall;
961                 String activeContactNo;
962                 if(pCall->GetContactNumber().IsEmpty() == false)
963                 {
964                         activeContactNo.Append(pCall->GetContactNumber());
965                 }
966                 else
967                 {
968                         activeContactNo.Append(AppUtility::GetResourceString(IDS_NUMBER_UNKNOWN));
969                 }
970                 ShowPersonDetails(activeContactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
971                 //show call active time using Timer
972                 //__activeCallStartTime = pCall->GetCallConnectTime();
973                 __activeCallStartTime = pCall->GetDurationTime();
974                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, pCall->IsOnHold(), __activeCallStartTime);
975         }
976         break;
977
978         case FORMTYPE_EMERGENCYACTIVECALL:
979         {
980                 //get contact number
981                 AppCallInfo* pCall = static_cast<AppCallInfo*>(pArgs->GetAt(0));
982
983                 __pActiveCallInfo = new (std::nothrow) AppCallInfo();
984                 *__pActiveCallInfo =  *pCall;
985
986                 //show call active time using Timer
987                 //__activeCallStartTime = pCall->GetCallConnectTime();
988                 __activeCallStartTime = pCall->GetDurationTime();
989                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, pCall->IsOnHold(), __activeCallStartTime);
990         }
991         break;
992
993         case FORMTYPE_MULTIPLECALLS:
994         {
995                 IListT<AppCallInfo>* pCallsList = __pCallPresentor->GetCallListN();
996                 //update calls state
997                 UpdateMultipleCallScreen(*pCallsList);
998                 delete pCallsList;
999                 pCallsList = null;
1000         }
1001         break;
1002
1003         case FORMTYPE_ACTIVECONFCALL:
1004         {
1005                 //get Conf call
1006                 AppCallInfo* pConfInfo = static_cast<AppCallInfo*>(pArgs->GetAt(0));
1007                 __pActiveCallInfo = new (std::nothrow) AppCallInfo();
1008                 *__pActiveCallInfo =  *pConfInfo;
1009
1010                 int participantsCount = __pActiveCallInfo->GetCallerListCount();
1011
1012                 // show participant count on name Label
1013                 Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_PARTICIPANTS_LABEL));
1014                 if (pPeopleCountLbl)
1015                 {
1016                         String count;
1017                         count.Append(participantsCount);
1018                         count.Append(" ");
1019                         count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1020                         pPeopleCountLbl->SetText(count);
1021                 }
1022
1023                 if(participantsCount >= IDI_MAX_CONF_CALL_PARTICIPANTS)
1024                 {
1025                         __pCallButtonsPanel->EnableAddCallButton(false);
1026                 }
1027                 else
1028                 {
1029                         __pCallButtonsPanel->EnableAddCallButton(true);
1030                 }
1031
1032
1033                 //bring button on top
1034                 __pCallButtonsPanel->SetButtonPosition();
1035
1036
1037                 //show call active time using Timer
1038                 //__activeCallStartTime = __pActiveCallInfo->GetCallConnectTime();
1039                 __activeCallStartTime = __pActiveCallInfo->GetDurationTime();
1040                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, __pActiveCallInfo->IsOnHold(),__activeCallStartTime);
1041         }
1042         break;
1043
1044         default:
1045                 break;
1046         }
1047
1048         if(__formType == FORMTYPE_ACTIVECALL || __formType == FORMTYPE_EMERGENCYACTIVECALL ||
1049                         __formType == FORMTYPE_MULTIPLECALLS || __formType == FORMTYPE_ACTIVECONFCALL)
1050         {
1051                 //Unlock the phone if its locked
1052                 if(LockManager::GetInstance()->IsLocked())
1053                 {
1054                         AppLogDebug("Phone Locked");
1055                         LockManager::GetInstance()->Unlock();
1056                 }
1057         }
1058
1059         //Hide DTMFKeypad, if visible and show caller info
1060         HideDTMFKeypad();
1061         SetShowStateOnKeypad(true);
1062         __pCallButtonsPanel->SetKeypadButtonState(IDA_OPEN_NUMKEYPAD);
1063
1064         //Set the correct speaker status
1065         if(__pCallPresentor->IsSpeakerOn() == true)
1066         {
1067                 __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER_OFF);
1068         }
1069         else
1070         {
1071                 __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER);
1072         }
1073
1074         //Set the correct Mute status
1075         if (__pCallPresentor->IsCallMuted() == true)
1076         {
1077                 __pCallButtonsPanel->SetMuteButtonState(IDA_UNMUTE);
1078         }
1079         else
1080         {
1081                 __pCallButtonsPanel->SetMuteButtonState(IDA_MUTE);
1082         }
1083
1084         if (pArgs)
1085         {
1086                 pArgs->RemoveAll();
1087                 delete pArgs;
1088                 pArgs = null;
1089         }
1090
1091         //update position of call buttons panel
1092         Label* pKeysBgLbl = static_cast<Label*>(GetControl(IDC_KEY_BG_LABEL, true));
1093         __pCallButtonsPanel->SetBounds(pKeysBgLbl->GetBounds());
1094
1095         CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
1096         pCallApp->SetTopMostWindow(false);
1097 }
1098
1099 void
1100 ActiveCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1101 {
1102         RemoveOrientationEventListener(*this);
1103         if (__pActiveCallTimer != null)
1104         {
1105                 __pActiveCallTimer->Cancel();
1106                 delete __pActiveCallTimer;
1107                 __pActiveCallTimer = null;
1108         }
1109         if (__pSmallPhotoLabel != null)
1110         {
1111                 __pSmallPhotoLabel->SetShowState(false);
1112         }
1113         //Hide "Manage conf. Call" Context menu
1114         if (__pMoreOptionsListAnchor != null)
1115         {
1116                 __pMoreOptionsListAnchor->SetShowState(false);
1117         }
1118         if (__pMoreOptionsList != null)
1119         {
1120                 __pMoreOptionsList->SetShowState(false);
1121         }
1122         __DtmfString.Clear();
1123         CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
1124         pCallApp->RemoveAppStateChangeListener(*this);
1125         if(__pAddressbook != null)
1126         {
1127                 __pAddressbook->SetAddressbookChangeEventListener(null);
1128         }
1129 }
1130
1131 void
1132 ActiveCallForm::HandleConfCallChanged(void)
1133 {
1134         AppLog("ENTER");
1135         AppAssert((__formType == FORMTYPE_ACTIVECONFCALL) || (__formType == FORMTYPE_MULTIPLECALLS));
1136         //fetch changed conference call info
1137         AppCallInfo* pConfCallInfo = __pCallPresentor->GetConferenceCallInfoN();
1138         if (pConfCallInfo == null)
1139         {
1140                 AppLog("EXIT");
1141                 return;
1142         }
1143
1144         //fetch participant count in conf call
1145         int participantsCount = pConfCallInfo->GetCallerListCount();
1146         //update status of join and Add call
1147         bool isEnableAddCall = false;
1148         bool isEnableJoinCall = false;
1149         if(participantsCount < IDI_MAX_CONF_CALL_PARTICIPANTS)
1150         {
1151                 //available only at Active conf. call or active call screen
1152                 isEnableAddCall = true;
1153                 //join button is available only at multiple call screen
1154                 isEnableJoinCall = true;
1155         }
1156
1157         Label* pPeopleCountLbl = null;
1158         if (__pActiveCallInfo != null && __pActiveCallInfo->IsConferenceCall() == true)
1159         {
1160                 //Active call is conference call
1161                 delete __pActiveCallInfo;
1162                 __pActiveCallInfo = new (std::nothrow) AppCallInfo();
1163                 *__pActiveCallInfo = *pConfCallInfo;
1164
1165                 if (__formType == FORMTYPE_MULTIPLECALLS)
1166                 {
1167                         pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1168                 }
1169                 else if (__formType == FORMTYPE_ACTIVECONFCALL)
1170                 {
1171                         pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_PARTICIPANTS_LABEL));
1172                         AppLog("Active conf call...(%d)", pPeopleCountLbl);
1173                 }
1174         }
1175         else if(__pHeldCallInfo != null && __pHeldCallInfo->IsConferenceCall() == true)
1176         {
1177                 //Held call is conference call - this is definitely multiple call screen.
1178                 delete __pHeldCallInfo;
1179                 __pHeldCallInfo = new (std::nothrow) AppCallInfo();
1180                 *__pHeldCallInfo = *pConfCallInfo;
1181                 pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER2_LABEL));
1182         }
1183
1184         // update participant count on name Label
1185         if (pPeopleCountLbl != null)
1186         {
1187                 String count;
1188                 count.Append(participantsCount);
1189                 count.Append(" ");
1190                 count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1191                 pPeopleCountLbl->SetText(count);
1192                 pPeopleCountLbl->Invalidate(true);
1193         }
1194         //change AddCall Button status
1195         __pCallButtonsPanel->EnableAddCallButton(isEnableAddCall);
1196         //change JoinCall Button status
1197         __pCallButtonsPanel->EnableJoinCallButton(__pCallPresentor->IsEnableJoinCallButton());
1198         AppLog("EXIT");
1199 }
1200
1201 void
1202 ActiveCallForm::OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList)
1203 {
1204         AppLog("Enter");
1205         switch (__formType)
1206         {
1207
1208         case FORMTYPE_OUTGOINGCALL:
1209         case FORMTYPE_ACTIVECALL:
1210         {
1211                 String pContactNumber;
1212                 pContactNumber.Append(__pActiveCallInfo->GetContactNumber());
1213                 Contact* pContact = __pCallPresentor->GetContactN(__pActiveCallInfo->GetContactNumber());
1214                 if(pContact == null)
1215                 {
1216                         __pActiveCallInfo->ResetContactNumber(null);
1217                         __pActiveCallInfo->ResetContactInfo(null);
1218
1219                 }
1220                 else
1221                 {
1222                         __pActiveCallInfo->SetContactNumber(pContactNumber);
1223                         __pActiveCallInfo->SetContactInfo(*pContact);
1224                 }
1225                 if(pContact != null)
1226                 {
1227                         delete pContact;
1228                         pContact = null;
1229                 }
1230                 ShowPersonDetails(pContactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
1231         }
1232         break;
1233
1234         case FORMTYPE_EMERGENCYACTIVECALL:
1235         {
1236         }
1237         break;
1238
1239         case FORMTYPE_MULTIPLECALLS:
1240         {
1241
1242                 IListT<AppCallInfo>* pCallsList = __pCallPresentor->GetCallListN();
1243                 if(pCallsList != null)
1244                 {
1245                         int listCount = pCallsList->GetCount();
1246                         for(int index = 0; index < listCount; index++)
1247                         {
1248                                 AppCallInfo callInfo;
1249                                 Contact* pContact;
1250                                 pCallsList->GetAt(index, callInfo);
1251                                 if(__pActiveCallInfo == null)
1252                                 {
1253                                         __pActiveCallInfo = new (std::nothrow) AppCallInfo();
1254                                 }
1255                                 *__pActiveCallInfo =  callInfo;
1256                                 String contactNumber;
1257                                 contactNumber.Append(__pActiveCallInfo->GetContactNumber());
1258                                 pContact = __pCallPresentor->GetContactN(__pActiveCallInfo->GetContactNumber());
1259                                 if(pContact == null)
1260                                 {
1261                                         __pActiveCallInfo->ResetContactNumber(null);
1262                                         __pActiveCallInfo->ResetContactInfo(null);
1263
1264                                 }
1265                                 else
1266                                 {
1267                                         __pActiveCallInfo->SetContactNumber(contactNumber);
1268                                         __pActiveCallInfo->SetContactInfo(*pContact);
1269                                 }
1270                                 if(pContact != null)
1271                                 {
1272                                         delete pContact;
1273                                         pContact = null;
1274                                 }
1275                                 if(callInfo.IsConferenceCall() == true)
1276                                 {
1277                                         continue;
1278                                 }
1279                                 if(callInfo.IsOnHold() == false)
1280                                 {
1281                                         ShowPersonDetails(contactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
1282                                 }
1283                                 else
1284                                 {
1285                                         ShowPersonDetails(contactNumber, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pActiveCallInfo);
1286                                 }
1287
1288                         }
1289
1290                         delete pCallsList;
1291                         pCallsList = null;
1292                 }
1293         }
1294         break;
1295         default:
1296                 break;
1297         }
1298         AppLog("Exit");
1299 }
1300
1301 void
1302 ActiveCallForm::OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList)
1303 {
1304         //No implementation
1305 }
1306
1307
1308 void
1309 ActiveCallForm::UpdateMultipleCallScreen(Tizen::Base::Collection::IListT<AppCallInfo>& activeCallsList)
1310 {
1311         AppLog("ENTER");
1312         if(__pActiveCallInfo != null)
1313         {
1314                 delete __pActiveCallInfo;
1315                 __pActiveCallInfo = null;
1316         }
1317         if(__pHeldCallInfo != null)
1318         {
1319                 delete __pHeldCallInfo;
1320                 __pHeldCallInfo = null;
1321         }
1322
1323         Button* pMoreBtn = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1324         if (pMoreBtn != null)
1325         {
1326                 pMoreBtn->SetShowState(false);
1327         }
1328
1329         //show caller's info.
1330         for (int index = 0; index < activeCallsList.GetCount(); index++)
1331         {
1332                 //Fetch call info
1333                 AppCallInfo callInfo;
1334                 activeCallsList.GetAt(index, callInfo);
1335
1336                 String contactNo;
1337                 if(callInfo.GetContactNumber().IsEmpty() == false)
1338                 {
1339                         contactNo.Append(callInfo.GetContactNumber());
1340                 }
1341                 else
1342                 {
1343                         contactNo.Append(AppUtility::GetResourceString(IDS_NUMBER_UNKNOWN));
1344                 }
1345
1346                 if (callInfo.IsOnHold() == false)
1347                 {
1348                         __pActiveCallInfo = new (std::nothrow) AppCallInfo();
1349                         *__pActiveCallInfo =  callInfo;
1350
1351                         if (__pActiveCallInfo->IsConferenceCall() == false)
1352                         {
1353                                 Label* pVoiceIconLbl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1354                                 if (pVoiceIconLbl)
1355                                 {
1356                                         pVoiceIconLbl->SetShowState(true);
1357                                 }
1358                                 if (pMoreBtn != null)
1359                                 {
1360                                         pMoreBtn->SetShowState(false);
1361                                 }
1362                                 ShowPersonDetails(contactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
1363                                 if(__pMoreOptionsListAnchor != null && __pMoreOptionsListAnchor->GetShowState() == true)
1364                                 {
1365                                         CreateMoreOptionsMenuList();
1366                                 }
1367                         }
1368                         else
1369                         {
1370                                 // show participant count on name Label
1371                                 Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1372                                 if (pPeopleCountLbl)
1373                                 {
1374                                         String count;
1375                                         count.Append(__pActiveCallInfo->GetCallerListCount());
1376                                         count.Append(" ");
1377                                         count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1378                                         pPeopleCountLbl->SetText(count);
1379                                 }
1380                                 String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING");
1381                                 Label* pNameLbl = static_cast<Label*>(GetControl(IDC_CALLER1_LABEL));
1382                                 if (pNameLbl)
1383                                 {
1384                                         pNameLbl->SetText(nameStr);
1385                                 }
1386                                 Label* pVoiceIconLbl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1387                                 if (pVoiceIconLbl)
1388                                 {
1389                                         pVoiceIconLbl->SetShowState(false);
1390                                 }
1391                                 if (pMoreBtn != null)
1392                                 {
1393                                         pMoreBtn->SetShowState(true);
1394                                 }
1395                                 Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
1396                                 if (pPhotoBitmap != null)
1397                                 {
1398                                         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_CALLER1_PHOTO_LABEL));
1399                                         if (pPhotoLbl)
1400                                         {
1401                                                 pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap);
1402                                                 pPhotoLbl->Invalidate(true);
1403                                         }
1404                                         delete pPhotoBitmap;
1405                                 }
1406                         }
1407                         //show call active time using Timer
1408                         //__activeCallStartTime = __pActiveCallInfo->GetCallConnectTime();
1409                         __activeCallStartTime = __pActiveCallInfo->GetDurationTime();
1410                         ShowTimerInfo(IDC_CALLER1_TIME_LABEL,false,__activeCallStartTime);
1411                 }
1412                 else
1413                 {
1414                         __pHeldCallInfo = new (std::nothrow) AppCallInfo();
1415                         *__pHeldCallInfo = callInfo;
1416
1417                         if (__pHeldCallInfo->IsConferenceCall() == false)
1418                         {
1419                                 ShowPersonDetails(contactNo, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pHeldCallInfo);
1420                         }
1421                         else
1422                         {
1423                                 // show participant count on name Label
1424                                 Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER2_LABEL));
1425                                 if (pPeopleCountLbl)
1426                                 {
1427                                         String count;
1428                                         count.Append(__pHeldCallInfo->GetCallerListCount());
1429                                         count.Append(" ");
1430                                         count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1431                                         pPeopleCountLbl->SetText(count);
1432                                 }
1433                                 String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING");
1434                                 Label* pNameLbl = static_cast<Label*>(GetControl(IDC_CALLER2_LABEL));
1435                                 if (pNameLbl)
1436                                 {
1437                                         pNameLbl->SetText(nameStr);
1438                                 }
1439                                 Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
1440                                 if (pPhotoBitmap != null)
1441                                 {
1442                                         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_CALLER2_PHOTO_LABEL));
1443                                         if (pPhotoLbl)
1444                                         {
1445                                                 pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap);
1446                                                 pPhotoLbl->Invalidate(true);
1447                                         }
1448                                         delete pPhotoBitmap;
1449                                 }
1450                         }
1451                         //show "On Hold"
1452                         ShowTimerInfo(IDC_CALLER2_TIME_LABEL, true);
1453                 }
1454         }
1455
1456         //update JoinCall button status
1457         __pCallButtonsPanel->EnableJoinCallButton(__pCallPresentor->IsEnableJoinCallButton());
1458         Invalidate(true);
1459         AppLog("EXIT");
1460 }
1461
1462 void
1463 ActiveCallForm::ShowPersonDetails(const String& phoneNumber, const String& contactLblName, const String& nameLblName, bool isSecondCaller, AppCallInfo* pCallInfo)
1464 {
1465         result r = E_FAILURE;
1466
1467         //call individual methods to show contact number, caller name & photo
1468         ShowPhoneNumber(phoneNumber, contactLblName);
1469
1470         //fetch contact details based on phone number
1471         String* pDisplayName = pCallInfo->FetchLatestCallerNameN(phoneNumber);
1472         ShowCallerName(*pDisplayName, nameLblName);
1473
1474         Bitmap* pPhotoBitmap = pCallInfo->FetchLatestCallerPhotoN(phoneNumber);
1475         ShowCallerPhoto(pPhotoBitmap, isSecondCaller);
1476
1477         //free resources
1478         if (pDisplayName)
1479         {
1480                 delete pDisplayName;
1481                 pDisplayName = null;
1482         }
1483         if (pPhotoBitmap)
1484         {
1485                 delete pPhotoBitmap;
1486                 pPhotoBitmap = null;
1487         }
1488 }
1489
1490 void
1491 ActiveCallForm::ShowPhoneNumber(const String& phoneNumber, const String& contactLblName)
1492 {
1493         String formattedNumber = phoneNumber;
1494
1495         Label* pContactLbl = static_cast<Label*>(GetControl(contactLblName));
1496         if (pContactLbl)
1497         {
1498                 pContactLbl->SetText(formattedNumber);
1499                 pContactLbl->Invalidate(true);
1500         }
1501 }
1502
1503 void
1504 ActiveCallForm::ShowCallerName(const String& callerName, const String& nameLblName)
1505 {
1506         // show display name on name Label
1507         Label* pNameLbl = static_cast<Label*>(GetControl(nameLblName));
1508         if (pNameLbl)
1509         {
1510                 //passing an empty string to SetText fails in label,
1511                 //if previously valid text has been set
1512                 if (callerName.IsEmpty() == true && pNameLbl->GetText().IsEmpty() == false)
1513                 {
1514                         String stringToBeSet(L" ");
1515                         pNameLbl->SetText(stringToBeSet);
1516                 }
1517                 else
1518                 {
1519                         pNameLbl->SetText(callerName);
1520                 }
1521                 pNameLbl->Invalidate(true);
1522         }
1523 }
1524
1525 void
1526 ActiveCallForm::ShowCallerPhoto(Bitmap* pPhotoId, bool isSecondCaller)
1527 {
1528         //to check if default image is to be shown
1529         bool showDefaultPhoto = false;
1530         bool showSmallPhoto = false;
1531         String photoLabel("");
1532
1533         switch (__formType)
1534         {
1535         case FORMTYPE_OUTGOINGCALL:
1536         case FORMTYPE_ACTIVECALL:
1537         {
1538                 if (pPhotoId == null)
1539                 {
1540                         //show default caller image
1541                         showDefaultPhoto = true;
1542                 }
1543                 else
1544                 {
1545                         //Check the size of photo
1546                         // Now checking the condition with && but actually it should be ||
1547                         //But for now keeping it as && because _pContact->GetThubNail() returns image width as
1548                         // height 270 and width = 480 . So all images set thru gallery is show as small image
1549                         if(pPhotoId->GetHeight() <= H_SMALL_PHOTO
1550                                         && pPhotoId->GetWidth() <= W_SMALL_PHOTO)
1551                         {
1552                                 showSmallPhoto = true;
1553                         }
1554
1555                 }
1556                 photoLabel.Append(IDC_CALLER1_BIGPHOTO_LABEL);
1557         }
1558         break;
1559
1560         case FORMTYPE_MULTIPLECALLS:
1561         {
1562                 if (isSecondCaller)
1563                 {
1564                         photoLabel.Append(IDC_CALLER2_PHOTO_LABEL);
1565                 }
1566                 else
1567                 {
1568                         photoLabel.Append(IDC_CALLER1_PHOTO_LABEL);
1569                 }
1570
1571                 if (pPhotoId == null)
1572                 {
1573                         showDefaultPhoto = true;
1574                 }
1575                 else
1576                 {
1577                         if (pPhotoId->GetHeight() <= H_SMALL_PHOTO
1578                                 && pPhotoId->GetWidth() <= W_SMALL_PHOTO)
1579                         {
1580                                 //pPhotoId->Scale(Dimension(W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO));
1581                                 showSmallPhoto = true;
1582                         }
1583                 }
1584         }
1585         break;
1586
1587         default:
1588                 break;
1589         }
1590
1591         //Remove small photo label
1592         if (__pSmallPhotoLabel != null)
1593         {
1594                 RemoveControl(__pSmallPhotoLabel);
1595                 __pSmallPhotoLabel = null;
1596         }
1597
1598         //show photo - for Big Photo Id, Animated Call Image
1599         if (!showDefaultPhoto)
1600         {
1601                 if(showSmallPhoto == true)
1602                 {
1603                         ShowThumbnailImage(pPhotoId,photoLabel);
1604                 }
1605                 else
1606                 {
1607                         Label* pPhotoLbl = static_cast<Label*>(GetControl(photoLabel));
1608                         if (pPhotoLbl)
1609                         {
1610                                 Canvas* pCanvas = new (std::nothrow) Canvas;
1611                                 Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1612                                 pCanvas->Construct(canvasRect);
1613                                 //draw the contact bitmap
1614                                 pCanvas->DrawBitmap(canvasRect,*pPhotoId);
1615                                 Bitmap* pNewPhotoId = new Bitmap();
1616                                 pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1617                                 delete pCanvas;
1618
1619                                 pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1620                                 pPhotoLbl->Invalidate(true);
1621                                 delete pNewPhotoId;
1622                         }
1623                 }
1624         }
1625         else
1626         {
1627                 Bitmap* pDefaultPhoto = null;
1628                 switch (__formType)
1629                 {
1630                 case FORMTYPE_OUTGOINGCALL:
1631                 case FORMTYPE_ACTIVECALL:
1632                         pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_ACTIVE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO);
1633                         break;
1634
1635                 case FORMTYPE_MULTIPLECALLS:
1636                         pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_MULTIPLE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
1637                         break;
1638
1639                 case FORMTYPE_ACTIVECONFCALL:
1640                         pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BIG_BG_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO);
1641                         break;
1642
1643                 default:
1644                         break;
1645                 }
1646                 if (pDefaultPhoto != null)
1647                 {
1648                         Label* pPhotoLbl = static_cast<Label*>(GetControl(photoLabel));
1649                         if (pPhotoLbl)
1650                         {
1651                                 pPhotoLbl->SetBackgroundBitmap(*pDefaultPhoto);
1652                                 pPhotoLbl->Invalidate(true);
1653                         }
1654                         delete pDefaultPhoto;
1655                 }
1656         }
1657 }
1658
1659 void
1660 ActiveCallForm::ShowThumbnailImage(const Bitmap* pPhotoId,String& photoLabel)
1661 {
1662         Label* pPhotoLbl = static_cast<Label*>(GetControl(photoLabel));
1663
1664         if (pPhotoLbl != null && pPhotoId != null)
1665         {
1666                 Canvas* pCanvas = new (std::nothrow) Canvas;
1667                 Bitmap* pBackground = AppUtility::GetBitmapFromResourcesN(IDB_CALL_THUMBNAIL_BACKGROUND,W_CALL_THUMBNAIL,H_CALL_THUMBNAIL);
1668                 Bitmap* pShadow = AppUtility::GetBitmapFromResourcesN(IDB_CALL_THUMBNAIL_SHADOW,W_CALL_THUMBNAIL_SHADOW,H_CALL_THUMBNAIL_SHADOW);
1669                 Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1670                 pCanvas->Construct(canvasRect);
1671                 //draw the back ground
1672                 pCanvas->DrawBitmap(canvasRect,*pBackground);
1673                 //draw shadow (to be enabled after correct shadow image is provided )
1674                 //pCanvas->DrawBitmap(Rectangle((pPhotoLbl->GetBounds().width/2)-(W_CALL_THUMBNAIL_SHADOW/2),
1675                         //      (pPhotoLbl->GetBounds().height/2)-(H_CALL_THUMBNAIL_SHADOW/2),W_CALL_THUMBNAIL_SHADOW,H_CALL_THUMBNAIL_SHADOW),*pShadow);
1676                 //draw the contact bitmap
1677                 pCanvas->DrawBitmap(Rectangle((pPhotoLbl->GetBounds().width/2)-(W_SMALL_PHOTO/2),
1678                                 (pPhotoLbl->GetBounds().height/2)-(H_SMALL_PHOTO/2),W_SMALL_PHOTO,H_SMALL_PHOTO),*pPhotoId);
1679                 Bitmap* pNewPhotoId = new Bitmap();
1680                 pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1681                 delete pCanvas;
1682
1683                 pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1684                 pPhotoLbl->Invalidate(true);
1685                 delete pNewPhotoId;
1686                 delete pBackground;
1687                 delete pShadow;
1688         }
1689
1690 }
1691
1692 void
1693 ActiveCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
1694 {
1695         if (__pSmallPhotoLabel != null)
1696         {
1697                 RemoveControl(__pSmallPhotoLabel);
1698                 __pSmallPhotoLabel = null;
1699         }
1700         //Draw Small Photo and show on small photo label
1701         __pSmallPhotoLabel  = new (std::nothrow) Label();//static_cast<Label*>(GetControl(IDC_SMALL_PHOTO_LABEL));
1702         __pSmallPhotoLabel->Construct(Rectangle(X_PHOTO_LBL, Y_PHOTO_LBL, W_PHOTO_LBL, H_PHOTO_LBL), L"");
1703         __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0));
1704         __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId);
1705         // Add a Label to the Form
1706         AddControl(__pSmallPhotoLabel);
1707         __pSmallPhotoLabel->Invalidate(true);
1708 }
1709
1710 void
1711 ActiveCallForm::ShowTimerInfo(const String& timerLblName, bool isOnHold, long long startTime)
1712 {
1713         Label* pTimerLbl = static_cast<Label*>(GetControl(timerLblName));
1714
1715         if (__pActiveCallTimer == null)
1716         {
1717                 __pActiveCallTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
1718                 __pActiveCallTimer->Construct(*this);
1719         }
1720
1721         if (pTimerLbl != null)
1722         {
1723                 if (isOnHold == true)
1724                 {
1725                         pTimerLbl->SetText(AppUtility::GetResourceString(IDS_TIMER_ON_HOLD));
1726                         //update Hold button status
1727                         SetHoldButtonStatus(false);
1728                 }
1729                 else
1730                 {
1731                         //update Hold button status
1732                         SetHoldButtonStatus(true);
1733                         //current system time
1734                         long long currTime = 0;
1735                         //SystemTime::GetTicks(currTime);
1736                         CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
1737                         currTime = pPhoneApp->GetCallAppTicks();
1738                         //Set call duration
1739                         TimeSpan diffSpan(abs(startTime - currTime));
1740
1741                         String activeCallTime(L"");
1742
1743                         long long hr = diffSpan.GetHours();
1744                         if (hr <= 9)
1745                         {
1746                                 activeCallTime.Append("0");
1747                         }
1748                         activeCallTime.Append(hr);
1749                         activeCallTime.Append(L":");
1750
1751                         long long min = diffSpan.GetMinutes();
1752                         if (min <= 9)
1753                         {
1754                                 activeCallTime.Append("0");
1755                         }
1756                         activeCallTime.Append(min);
1757                         activeCallTime.Append(L":");
1758
1759                         long long sec = diffSpan.GetSeconds();
1760                         if (sec <= 9)
1761                         {
1762                                 activeCallTime.Append("0");
1763                         }
1764                         activeCallTime.Append(sec);
1765
1766                         pTimerLbl->SetText(activeCallTime);
1767                         __pActiveCallTimer->StartAsRepeatable(TimeSpan::NUM_OF_TICKS_IN_SECOND);
1768                 }
1769                 pTimerLbl->Invalidate(true);
1770         }
1771 }
1772
1773 void
1774 ActiveCallForm::SetHoldButtonShowState(bool showState)
1775 {
1776         Label* pLblControl = static_cast<Label*>(GetControl(IDC_HOLD_LABEL));
1777         if(pLblControl != null)
1778         {
1779                 pLblControl->SetShowState(showState);
1780         }
1781         Button* pButtonControl = static_cast<Button*>(GetControl(IDC_HOLD_BUTTON));
1782         if(pButtonControl != null)
1783         {
1784                 pButtonControl->SetShowState(showState);
1785         }
1786 }
1787
1788 void
1789 ActiveCallForm::SetShowStateOnKeypad(bool showState)
1790 {
1791         Label* pLblControl = static_cast<Label*>(GetControl(IDC_CALLER1_LABEL));
1792         pLblControl->SetShowState(showState);
1793         pLblControl = static_cast<Label*>(GetControl(IDC_BACKGROUND_LABEL));
1794         pLblControl->SetShowState(showState);
1795         pLblControl = static_cast<Label*>(GetControl(IDC_CALLER1_TIME_LABEL));
1796         pLblControl->SetShowState(showState);
1797         if (__pSmallPhotoLabel != null)
1798         {
1799                 __pSmallPhotoLabel->SetShowState(showState);
1800         }
1801
1802         switch (__formType)
1803         {
1804         case FORMTYPE_ACTIVECALL:
1805         {
1806                 pLblControl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1807                 pLblControl->SetShowState(showState);
1808                 pLblControl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1809                 pLblControl->SetShowState(showState);
1810                 SetHoldButtonShowState(showState);
1811         }
1812         break;
1813
1814         case FORMTYPE_MULTIPLECALLS:
1815         {
1816                 pLblControl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1817                 pLblControl->SetShowState(showState);
1818                 pLblControl = static_cast<Label*>(GetControl(IDC_CALLER2_LABEL));
1819                 pLblControl->SetShowState(showState);
1820                 pLblControl = static_cast<Label*>(GetControl(IDC_NUMBER2_LABEL));
1821                 pLblControl->SetShowState(showState);
1822                 pLblControl = static_cast<Label*>(GetControl(IDC_CALLER2_TIME_LABEL));
1823                 pLblControl->SetShowState(showState);
1824                 pLblControl = static_cast<Label*>(GetControl(IDC_SWAP_LABEL));
1825                 pLblControl->SetShowState(showState);
1826                 pLblControl = static_cast<Label*>(GetControl(IDC_BACKGROUND_LABEL2));
1827                 pLblControl->SetShowState(showState);
1828                 if (__pActiveCallInfo != null && __pActiveCallInfo->IsConferenceCall() == false)
1829                 {
1830                         pLblControl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1831                         pLblControl->SetShowState(showState);
1832                 }
1833                 else
1834                 {
1835                         Button* pButtonControl = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1836                         pButtonControl->SetShowState(showState);
1837                 }
1838                 Button* pButtonControl = static_cast<Button*>(GetControl(IDC_SWAP_BUTTON));
1839                 pButtonControl->SetShowState(showState);
1840         }
1841         break;
1842
1843         case FORMTYPE_ACTIVECONFCALL:
1844         {
1845                 pLblControl = static_cast<Label*>(GetControl(IDC_PARTICIPANTS_LABEL));
1846                 pLblControl->SetShowState(showState);
1847                 SetHoldButtonShowState(showState);
1848                 Button* pButtonControl = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1849                 pButtonControl->SetShowState(showState);
1850         }
1851         break;
1852
1853         default:
1854                 break;
1855         }
1856 }
1857
1858 void
1859 ActiveCallForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
1860 {
1861         //Call default implementation of "Object.Equals()"
1862         //returns true, if they are pointing to same address.
1863         if (__pActiveCallTimer->Equals(timer))
1864         {
1865                 Label* pTimerLbl = static_cast<Label*>(GetControl(IDC_CALLER1_TIME_LABEL));
1866                 if (pTimerLbl)
1867                 {
1868                         String activeCallTime = pTimerLbl->GetText();
1869                         // Create a StringTokenizer instance
1870                         StringTokenizer strTokens(activeCallTime, L":");
1871
1872                         int count = strTokens.GetTokenCount(); // count == 3
1873                         String token;
1874                         int sec = 0;
1875                         int min = 0;
1876                         int hr = 0;
1877                         for (int index = 0; index < count; index++)
1878                         {
1879                                 switch (index)
1880                                 {
1881                                 case 0:
1882                                         strTokens.GetNextToken(token);
1883                                         Integer::Parse(token, hr);
1884                                         break;
1885
1886                                 case 1:
1887                                         strTokens.GetNextToken(token);
1888                                         Integer::Parse(token, min);
1889                                         break;
1890
1891                                 case 2:
1892                                         strTokens.GetNextToken(token);
1893                                         Integer::Parse(token, sec);
1894                                         break;
1895                                 }
1896                         }
1897                         //update all values
1898                         sec = sec + 1;
1899                         if (sec == IDI_MAX_SECONDS)
1900                         {
1901                                 sec = 0;
1902                                 min = min + 1;
1903                         }
1904                         if (min == IDI_MAX_MINS)
1905                         {
1906                                 min = 0;
1907                                 hr = hr + 1;
1908                         }
1909
1910                         //replace string
1911                         activeCallTime.Clear();
1912                         if (hr <= 9)
1913                         {
1914                                 activeCallTime.Append("0");
1915                         }
1916                         activeCallTime.Append(hr);
1917                         activeCallTime.Append(":");
1918                         if (min <= 9)
1919                         {
1920                                 activeCallTime.Append("0");
1921                         }
1922                         activeCallTime.Append(min);
1923                         activeCallTime.Append(":");
1924                         if (sec <= 9)
1925                         {
1926                                 activeCallTime.Append("0");
1927                         }
1928                         activeCallTime.Append(sec);
1929                         //update timer label
1930                         pTimerLbl->SetText(activeCallTime);
1931                         pTimerLbl->Invalidate(true);
1932                 }
1933         }
1934 }
1935
1936 ///////////////////////////////////////////////////////////
1937 ///////////     Options Menu List Functionality   /////////
1938 ///////////////////////////////////////////////////////////
1939 void
1940 ActiveCallForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)
1941 {
1942 }
1943
1944 void
1945 ActiveCallForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
1946 {
1947         //Goto conference call list form
1948         SceneManager* pSceneManager = SceneManager::GetInstance();
1949         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALLLIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
1950                          SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_KEEP), null);
1951 }
1952
1953 void
1954 ActiveCallForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
1955 {
1956 }
1957
1958 void
1959 ActiveCallForm::OnListViewItemLongPressed(ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
1960 {
1961 }
1962
1963 int
1964 ActiveCallForm::GetItemCount(void)
1965 {
1966         return IDI_MOREOPTIONS_LIST_ITEMS;
1967 }
1968
1969 ListItemBase*
1970 ActiveCallForm::CreateItem(int index, int itemWidth)
1971 {
1972         //create 1st Menu option
1973         CustomItem* pItem = new (std::nothrow) CustomItem();
1974         pItem->Construct(IDI_OPTIONMENU_DIMEN, LIST_ANNEX_STYLE_NORMAL);
1975
1976         //Set background 9-patch bitmap to option menu
1977         Bitmap* pBgBmp = AppUtility::GetBitmapFromResourcesN(IDB_POPUP_BG_ICON);
1978         if (pBgBmp != null && pBgBmp->IsNinePatchedBitmap())
1979         {
1980                 Canvas bgCanvas;
1981                 bgCanvas.Construct(Rectangle(IDI_OPTIONMENU_POS, IDI_OPTIONMENU_DIMEN));
1982                 bgCanvas.DrawNinePatchedBitmap(bgCanvas.GetBounds(), *pBgBmp);
1983         }
1984         else
1985         {
1986                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color(40, 45, 48));
1987         }
1988         delete pBgBmp;
1989         pBgBmp = null;
1990
1991         //Set bitmap to option menu
1992         Bitmap* pNormalConfCallBmp = AppUtility::GetBitmapFromResourcesN(IDB_MORE_MANAGE_CONFERENCE_ICON ,
1993                                                                                                                                          W_MGR_CONFCALL_BITMAP, H_MGR_CONFCALL_BITMAP);
1994         pItem->AddElement(Rectangle(16, 17, W_MGR_CONFCALL_BITMAP, H_MGR_CONFCALL_BITMAP), 1, *pNormalConfCallBmp, null, null);
1995         // Deallocate bitmaps
1996         delete pNormalConfCallBmp;
1997         pNormalConfCallBmp = null;
1998
1999         //Set text to menu option
2000         String confCallName = AppUtility::GetResourceString(IDS_MGR_CONF_CALL_LIST_STR);
2001
2002         TextElement* pTextElement = new (std::nothrow) TextElement();
2003         pTextElement->Construct(confCallName);
2004         pTextElement->SetTextColor(COLOR_POPUP_TEXT);
2005         //create font
2006         Font font;
2007         font.Construct(FONT_STYLE_PLAIN, IDI_POPUP_TEXT_SIZE);
2008         pTextElement->SetFont(font);
2009         //construct Enriched text
2010         EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText();
2011         FloatDimension textDimension;
2012         font.GetTextExtent(confCallName, confCallName.GetLength(), textDimension);
2013         textDimension.height = textDimension.height + font.GetDescender();
2014         pEnrichedText->Construct(textDimension);
2015         //add text element to enriched text
2016         pEnrichedText->Add(*pTextElement);
2017
2018         //Add Enriched text to pItem
2019         FloatPoint textPos(((2 * IDI_OPTIONMENU_ITEM_SPACING) + W_MGR_CONFCALL_BITMAP), ((IDI_OPTIONMENU_DIMEN.height - textDimension.height) / 2));
2020         pItem->AddElement(FloatRectangle(textPos, textDimension), 2, *pEnrichedText);
2021         // Cleans up
2022         pEnrichedText->RemoveAll(true);
2023         delete pEnrichedText;
2024         return pItem;
2025 }
2026
2027 bool
2028 ActiveCallForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
2029 {
2030         delete pItem;
2031         return true;
2032 }
2033
2034 void
2035 ActiveCallForm::OnForeground(void)
2036 {
2037         AppLogDebug("Enter");
2038         __pCallPresentor->OnAppForeground();
2039 }