Fix for 45866
[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
972                 //show call active time using Timer
973                 __activeCallStartTime = pCall->GetCallConnectTime();
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                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, pCall->IsOnHold(), __activeCallStartTime);
989         }
990         break;
991
992         case FORMTYPE_MULTIPLECALLS:
993         {
994                 IListT<AppCallInfo>* pCallsList = __pCallPresentor->GetCallListN();
995                 //update calls state
996                 UpdateMultipleCallScreen(*pCallsList);
997                 delete pCallsList;
998                 pCallsList = null;
999         }
1000         break;
1001
1002         case FORMTYPE_ACTIVECONFCALL:
1003         {
1004                 //get Conf call
1005                 AppCallInfo* pConfInfo = static_cast<AppCallInfo*>(pArgs->GetAt(0));
1006                 __pActiveCallInfo = new (std::nothrow) AppCallInfo();
1007                 *__pActiveCallInfo =  *pConfInfo;
1008
1009                 int participantsCount = __pActiveCallInfo->GetCallerListCount();
1010
1011                 // show participant count on name Label
1012                 Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_PARTICIPANTS_LABEL));
1013                 if (pPeopleCountLbl)
1014                 {
1015                         String count;
1016                         count.Append(participantsCount);
1017                         count.Append(" ");
1018                         count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1019                         pPeopleCountLbl->SetText(count);
1020                 }
1021
1022                 if(participantsCount >= IDI_MAX_CONF_CALL_PARTICIPANTS)
1023                 {
1024                         __pCallButtonsPanel->EnableAddCallButton(false);
1025                 }
1026                 else
1027                 {
1028                         __pCallButtonsPanel->EnableAddCallButton(true);
1029                 }
1030
1031
1032                 //bring button on top
1033                 __pCallButtonsPanel->SetButtonPosition();
1034
1035
1036                 //show call active time using Timer
1037                 __activeCallStartTime = __pActiveCallInfo->GetCallConnectTime();
1038                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, __pActiveCallInfo->IsOnHold(),__activeCallStartTime);
1039         }
1040         break;
1041
1042         default:
1043                 break;
1044         }
1045
1046         if(__formType == FORMTYPE_ACTIVECALL || __formType == FORMTYPE_EMERGENCYACTIVECALL ||
1047                         __formType == FORMTYPE_MULTIPLECALLS || __formType == FORMTYPE_ACTIVECONFCALL)
1048         {
1049                 //Unlock the phone if its locked
1050                 if(LockManager::GetInstance()->IsLocked())
1051                 {
1052                         AppLogDebug("Phone Locked");
1053                         LockManager::GetInstance()->Unlock();
1054                 }
1055         }
1056
1057         //Hide DTMFKeypad, if visible and show caller info
1058         HideDTMFKeypad();
1059         SetShowStateOnKeypad(true);
1060         __pCallButtonsPanel->SetKeypadButtonState(IDA_OPEN_NUMKEYPAD);
1061
1062         //Set the correct speaker status
1063         if(__pCallPresentor->IsSpeakerOn() == true)
1064         {
1065                 __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER_OFF);
1066         }
1067         else
1068         {
1069                 __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER);
1070         }
1071
1072         //Set the correct Mute status
1073         if (__pCallPresentor->IsCallMuted() == true)
1074         {
1075                 __pCallButtonsPanel->SetMuteButtonState(IDA_UNMUTE);
1076         }
1077         else
1078         {
1079                 __pCallButtonsPanel->SetMuteButtonState(IDA_MUTE);
1080         }
1081
1082         if (pArgs)
1083         {
1084                 pArgs->RemoveAll();
1085                 delete pArgs;
1086                 pArgs = null;
1087         }
1088
1089         //update position of call buttons panel
1090         Label* pKeysBgLbl = static_cast<Label*>(GetControl(IDC_KEY_BG_LABEL, true));
1091         __pCallButtonsPanel->SetBounds(pKeysBgLbl->GetBounds());
1092
1093         CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
1094         pCallApp->SetTopMostWindow(false);
1095 }
1096
1097 void
1098 ActiveCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1099 {
1100         RemoveOrientationEventListener(*this);
1101         if (__pActiveCallTimer != null)
1102         {
1103                 __pActiveCallTimer->Cancel();
1104                 delete __pActiveCallTimer;
1105                 __pActiveCallTimer = null;
1106         }
1107         if (__pSmallPhotoLabel != null)
1108         {
1109                 __pSmallPhotoLabel->SetShowState(false);
1110         }
1111         //Hide "Manage conf. Call" Context menu
1112         if (__pMoreOptionsListAnchor != null)
1113         {
1114                 __pMoreOptionsListAnchor->SetShowState(false);
1115         }
1116         if (__pMoreOptionsList != null)
1117         {
1118                 __pMoreOptionsList->SetShowState(false);
1119         }
1120         __DtmfString.Clear();
1121         CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
1122         pCallApp->RemoveAppStateChangeListener(*this);
1123         if(__pAddressbook != null)
1124         {
1125                 __pAddressbook->SetAddressbookChangeEventListener(null);
1126         }
1127 }
1128
1129 void
1130 ActiveCallForm::HandleConfCallChanged(void)
1131 {
1132         AppLog("ENTER");
1133         AppAssert((__formType == FORMTYPE_ACTIVECONFCALL) || (__formType == FORMTYPE_MULTIPLECALLS));
1134         //fetch changed conference call info
1135         AppCallInfo* pConfCallInfo = __pCallPresentor->GetConferenceCallInfoN();
1136         if (pConfCallInfo == null)
1137         {
1138                 AppLog("EXIT");
1139                 return;
1140         }
1141
1142         //fetch participant count in conf call
1143         int participantsCount = pConfCallInfo->GetCallerListCount();
1144         //update status of join and Add call
1145         bool isEnableAddCall = false;
1146         bool isEnableJoinCall = false;
1147         if(participantsCount < IDI_MAX_CONF_CALL_PARTICIPANTS)
1148         {
1149                 //available only at Active conf. call or active call screen
1150                 isEnableAddCall = true;
1151                 //join button is available only at multiple call screen
1152                 isEnableJoinCall = true;
1153         }
1154
1155         Label* pPeopleCountLbl = null;
1156         if (__pActiveCallInfo != null && __pActiveCallInfo->IsConferenceCall() == true)
1157         {
1158                 //Active call is conference call
1159                 delete __pActiveCallInfo;
1160                 __pActiveCallInfo = new (std::nothrow) AppCallInfo();
1161                 *__pActiveCallInfo = *pConfCallInfo;
1162
1163                 if (__formType == FORMTYPE_MULTIPLECALLS)
1164                 {
1165                         pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1166                 }
1167                 else if (__formType == FORMTYPE_ACTIVECONFCALL)
1168                 {
1169                         pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_PARTICIPANTS_LABEL));
1170                         AppLog("Active conf call...(%d)", pPeopleCountLbl);
1171                 }
1172         }
1173         else if(__pHeldCallInfo != null && __pHeldCallInfo->IsConferenceCall() == true)
1174         {
1175                 //Held call is conference call - this is definitely multiple call screen.
1176                 delete __pHeldCallInfo;
1177                 __pHeldCallInfo = new (std::nothrow) AppCallInfo();
1178                 *__pHeldCallInfo = *pConfCallInfo;
1179                 pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER2_LABEL));
1180         }
1181
1182         // update participant count on name Label
1183         if (pPeopleCountLbl != null)
1184         {
1185                 String count;
1186                 count.Append(participantsCount);
1187                 count.Append(" ");
1188                 count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1189                 pPeopleCountLbl->SetText(count);
1190                 pPeopleCountLbl->Invalidate(true);
1191         }
1192         //change AddCall Button status
1193         __pCallButtonsPanel->EnableAddCallButton(isEnableAddCall);
1194         //change JoinCall Button status
1195         __pCallButtonsPanel->EnableJoinCallButton(__pCallPresentor->IsEnableJoinCallButton());
1196         AppLog("EXIT");
1197 }
1198
1199 void
1200 ActiveCallForm::OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList)
1201 {
1202         AppLog("Enter");
1203         switch (__formType)
1204         {
1205
1206         case FORMTYPE_OUTGOINGCALL:
1207         case FORMTYPE_ACTIVECALL:
1208         {
1209                 String pContactNumber;
1210                 pContactNumber.Append(__pActiveCallInfo->GetContactNumber());
1211                 Contact* pContact = __pCallPresentor->GetContactN(__pActiveCallInfo->GetContactNumber());
1212                 if(pContact == null)
1213                 {
1214                         __pActiveCallInfo->ResetContactNumber(null);
1215                         __pActiveCallInfo->ResetContactInfo(null);
1216
1217                 }
1218                 else
1219                 {
1220                         __pActiveCallInfo->SetContactNumber(pContactNumber);
1221                         __pActiveCallInfo->SetContactInfo(*pContact);
1222                 }
1223                 if(pContact != null)
1224                 {
1225                         delete pContact;
1226                         pContact = null;
1227                 }
1228                 ShowPersonDetails(pContactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
1229         }
1230         break;
1231
1232         case FORMTYPE_EMERGENCYACTIVECALL:
1233         {
1234         }
1235         break;
1236
1237         case FORMTYPE_MULTIPLECALLS:
1238         {
1239
1240                 IListT<AppCallInfo>* pCallsList = __pCallPresentor->GetCallListN();
1241                 if(pCallsList != null)
1242                 {
1243                         int listCount = pCallsList->GetCount();
1244                         for(int index = 0; index < listCount; index++)
1245                         {
1246                                 AppCallInfo callInfo;
1247                                 Contact* pContact;
1248                                 pCallsList->GetAt(index, callInfo);
1249                                 if(__pActiveCallInfo == null)
1250                                 {
1251                                         __pActiveCallInfo = new (std::nothrow) AppCallInfo();
1252                                 }
1253                                 *__pActiveCallInfo =  callInfo;
1254                                 String contactNumber;
1255                                 contactNumber.Append(__pActiveCallInfo->GetContactNumber());
1256                                 pContact = __pCallPresentor->GetContactN(__pActiveCallInfo->GetContactNumber());
1257                                 if(pContact == null)
1258                                 {
1259                                         __pActiveCallInfo->ResetContactNumber(null);
1260                                         __pActiveCallInfo->ResetContactInfo(null);
1261
1262                                 }
1263                                 else
1264                                 {
1265                                         __pActiveCallInfo->SetContactNumber(contactNumber);
1266                                         __pActiveCallInfo->SetContactInfo(*pContact);
1267                                 }
1268                                 if(pContact != null)
1269                                 {
1270                                         delete pContact;
1271                                         pContact = null;
1272                                 }
1273                                 if(callInfo.IsOnHold() == false)
1274                                 {
1275                                         ShowPersonDetails(contactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
1276                                 }
1277                                 else
1278                                 {
1279                                         ShowPersonDetails(contactNumber, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pActiveCallInfo);
1280                                 }
1281
1282                         }
1283
1284                         delete pCallsList;
1285                         pCallsList = null;
1286                 }
1287         }
1288         break;
1289         default:
1290                 break;
1291         }
1292         AppLog("Exit");
1293 }
1294
1295 void
1296 ActiveCallForm::OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList)
1297 {
1298         //No implementation
1299 }
1300
1301
1302 void
1303 ActiveCallForm::UpdateMultipleCallScreen(Tizen::Base::Collection::IListT<AppCallInfo>& activeCallsList)
1304 {
1305         AppLog("ENTER");
1306         if(__pActiveCallInfo != null)
1307         {
1308                 delete __pActiveCallInfo;
1309                 __pActiveCallInfo = null;
1310         }
1311         if(__pHeldCallInfo != null)
1312         {
1313                 delete __pHeldCallInfo;
1314                 __pHeldCallInfo = null;
1315         }
1316
1317         Button* pMoreBtn = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1318         if (pMoreBtn != null)
1319         {
1320                 pMoreBtn->SetShowState(false);
1321         }
1322
1323         //show caller's info.
1324         for (int index = 0; index < activeCallsList.GetCount(); index++)
1325         {
1326                 //Fetch call info
1327                 AppCallInfo callInfo;
1328                 activeCallsList.GetAt(index, callInfo);
1329
1330                 String contactNo;
1331                 if(callInfo.GetContactNumber().IsEmpty() == false)
1332                 {
1333                         contactNo.Append(callInfo.GetContactNumber());
1334                 }
1335                 else
1336                 {
1337                         contactNo.Append(AppUtility::GetResourceString(IDS_NUMBER_UNKNOWN));
1338                 }
1339
1340                 if (callInfo.IsOnHold() == false)
1341                 {
1342                         __pActiveCallInfo = new (std::nothrow) AppCallInfo();
1343                         *__pActiveCallInfo =  callInfo;
1344
1345                         if (__pActiveCallInfo->IsConferenceCall() == false)
1346                         {
1347                                 Label* pVoiceIconLbl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1348                                 if (pVoiceIconLbl)
1349                                 {
1350                                         pVoiceIconLbl->SetShowState(true);
1351                                 }
1352                                 if (pMoreBtn != null)
1353                                 {
1354                                         pMoreBtn->SetShowState(false);
1355                                 }
1356                                 ShowPersonDetails(contactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
1357                                 if(__pMoreOptionsListAnchor != null && __pMoreOptionsListAnchor->GetShowState() == true)
1358                                 {
1359                                         CreateMoreOptionsMenuList();
1360                                 }
1361                         }
1362                         else
1363                         {
1364                                 // show participant count on name Label
1365                                 Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1366                                 if (pPeopleCountLbl)
1367                                 {
1368                                         String count;
1369                                         count.Append(__pActiveCallInfo->GetCallerListCount());
1370                                         count.Append(" ");
1371                                         count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1372                                         pPeopleCountLbl->SetText(count);
1373                                 }
1374                                 String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING");
1375                                 Label* pNameLbl = static_cast<Label*>(GetControl(IDC_CALLER1_LABEL));
1376                                 if (pNameLbl)
1377                                 {
1378                                         pNameLbl->SetText(nameStr);
1379                                 }
1380                                 Label* pVoiceIconLbl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1381                                 if (pVoiceIconLbl)
1382                                 {
1383                                         pVoiceIconLbl->SetShowState(false);
1384                                 }
1385                                 if (pMoreBtn != null)
1386                                 {
1387                                         pMoreBtn->SetShowState(true);
1388                                 }
1389                                 Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
1390                                 if (pPhotoBitmap != null)
1391                                 {
1392                                         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_CALLER1_PHOTO_LABEL));
1393                                         if (pPhotoLbl)
1394                                         {
1395                                                 pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap);
1396                                                 pPhotoLbl->Invalidate(true);
1397                                         }
1398                                         delete pPhotoBitmap;
1399                                 }
1400                         }
1401                         //show call active time using Timer
1402                         __activeCallStartTime = __pActiveCallInfo->GetCallConnectTime();
1403                         ShowTimerInfo(IDC_CALLER1_TIME_LABEL,false,__activeCallStartTime);
1404                 }
1405                 else
1406                 {
1407                         __pHeldCallInfo = new (std::nothrow) AppCallInfo();
1408                         *__pHeldCallInfo = callInfo;
1409
1410                         if (__pHeldCallInfo->IsConferenceCall() == false)
1411                         {
1412                                 ShowPersonDetails(contactNo, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pHeldCallInfo);
1413                         }
1414                         else
1415                         {
1416                                 // show participant count on name Label
1417                                 Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER2_LABEL));
1418                                 if (pPeopleCountLbl)
1419                                 {
1420                                         String count;
1421                                         count.Append(__pHeldCallInfo->GetCallerListCount());
1422                                         count.Append(" ");
1423                                         count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1424                                         pPeopleCountLbl->SetText(count);
1425                                 }
1426                                 String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING");
1427                                 Label* pNameLbl = static_cast<Label*>(GetControl(IDC_CALLER2_LABEL));
1428                                 if (pNameLbl)
1429                                 {
1430                                         pNameLbl->SetText(nameStr);
1431                                 }
1432                                 Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
1433                                 if (pPhotoBitmap != null)
1434                                 {
1435                                         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_CALLER2_PHOTO_LABEL));
1436                                         if (pPhotoLbl)
1437                                         {
1438                                                 pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap);
1439                                                 pPhotoLbl->Invalidate(true);
1440                                         }
1441                                         delete pPhotoBitmap;
1442                                 }
1443                         }
1444                         //show "On Hold"
1445                         ShowTimerInfo(IDC_CALLER2_TIME_LABEL, true);
1446                 }
1447         }
1448
1449         //update JoinCall button status
1450         __pCallButtonsPanel->EnableJoinCallButton(__pCallPresentor->IsEnableJoinCallButton());
1451         Invalidate(true);
1452         AppLog("EXIT");
1453 }
1454
1455 void
1456 ActiveCallForm::ShowPersonDetails(const String& phoneNumber, const String& contactLblName, const String& nameLblName, bool isSecondCaller, AppCallInfo* pCallInfo)
1457 {
1458         result r = E_FAILURE;
1459
1460         //call individual methods to show contact number, caller name & photo
1461         ShowPhoneNumber(phoneNumber, contactLblName);
1462
1463         //fetch contact details based on phone number
1464         String* pDisplayName = pCallInfo->FetchLatestCallerNameN(phoneNumber);
1465         ShowCallerName(*pDisplayName, nameLblName);
1466
1467         Bitmap* pPhotoBitmap = pCallInfo->FetchLatestCallerPhotoN(phoneNumber);
1468         ShowCallerPhoto(pPhotoBitmap, isSecondCaller);
1469
1470         //free resources
1471         if (pDisplayName)
1472         {
1473                 delete pDisplayName;
1474                 pDisplayName = null;
1475         }
1476         if (pPhotoBitmap)
1477         {
1478                 delete pPhotoBitmap;
1479                 pPhotoBitmap = null;
1480         }
1481 }
1482
1483 void
1484 ActiveCallForm::ShowPhoneNumber(const String& phoneNumber, const String& contactLblName)
1485 {
1486         String formattedNumber = phoneNumber;
1487
1488         Label* pContactLbl = static_cast<Label*>(GetControl(contactLblName));
1489         if (pContactLbl)
1490         {
1491                 pContactLbl->SetText(formattedNumber);
1492                 pContactLbl->Invalidate(true);
1493         }
1494 }
1495
1496 void
1497 ActiveCallForm::ShowCallerName(const String& callerName, const String& nameLblName)
1498 {
1499         // show display name on name Label
1500         Label* pNameLbl = static_cast<Label*>(GetControl(nameLblName));
1501         if (pNameLbl)
1502         {
1503                 //passing an empty string to SetText fails in label,
1504                 //if previously valid text has been set
1505                 if (callerName.IsEmpty() == true && pNameLbl->GetText().IsEmpty() == false)
1506                 {
1507                         String stringToBeSet(L" ");
1508                         pNameLbl->SetText(stringToBeSet);
1509                 }
1510                 else
1511                 {
1512                         pNameLbl->SetText(callerName);
1513                 }
1514                 pNameLbl->Invalidate(true);
1515         }
1516 }
1517
1518 void
1519 ActiveCallForm::ShowCallerPhoto(Bitmap* pPhotoId, bool isSecondCaller)
1520 {
1521         //to check if default image is to be shown
1522         bool showDefaultPhoto = false;
1523         bool showSmallPhoto = false;
1524         String photoLabel("");
1525
1526         switch (__formType)
1527         {
1528         case FORMTYPE_OUTGOINGCALL:
1529         case FORMTYPE_ACTIVECALL:
1530         {
1531                 if (pPhotoId == null)
1532                 {
1533                         //show default caller image
1534                         showDefaultPhoto = true;
1535                 }
1536                 else
1537                 {
1538                         //Check the size of photo
1539                         // Now checking the condition with && but actually it should be ||
1540                         //But for now keeping it as && because _pContact->GetThubNail() returns image width as
1541                         // height 270 and width = 480 . So all images set thru gallery is show as small image
1542                         if(pPhotoId->GetHeight() <= H_SMALL_PHOTO
1543                                         && pPhotoId->GetWidth() <= W_SMALL_PHOTO)
1544                         {
1545                                 showSmallPhoto = true;
1546                         }
1547
1548                 }
1549                 photoLabel.Append(IDC_CALLER1_BIGPHOTO_LABEL);
1550         }
1551         break;
1552
1553         case FORMTYPE_MULTIPLECALLS:
1554         {
1555                 if (isSecondCaller)
1556                 {
1557                         photoLabel.Append(IDC_CALLER2_PHOTO_LABEL);
1558                 }
1559                 else
1560                 {
1561                         photoLabel.Append(IDC_CALLER1_PHOTO_LABEL);
1562                 }
1563
1564                 if (pPhotoId == null)
1565                 {
1566                         showDefaultPhoto = true;
1567                 }
1568                 else
1569                 {
1570                         if (pPhotoId->GetHeight() <= H_SMALL_PHOTO
1571                                 && pPhotoId->GetWidth() <= W_SMALL_PHOTO)
1572                         {
1573                                 //pPhotoId->Scale(Dimension(W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO));
1574                                 showSmallPhoto = true;
1575                         }
1576                 }
1577         }
1578         break;
1579
1580         default:
1581                 break;
1582         }
1583
1584         //Remove small photo label
1585         if (__pSmallPhotoLabel != null)
1586         {
1587                 RemoveControl(__pSmallPhotoLabel);
1588                 __pSmallPhotoLabel = null;
1589         }
1590
1591         //show photo - for Big Photo Id, Animated Call Image
1592         if (!showDefaultPhoto)
1593         {
1594                 if(showSmallPhoto == true)
1595                 {
1596                         ShowThumbnailImage(pPhotoId,photoLabel);
1597                 }
1598                 else
1599                 {
1600                         Label* pPhotoLbl = static_cast<Label*>(GetControl(photoLabel));
1601                         if (pPhotoLbl)
1602                         {
1603                                 Canvas* pCanvas = new (std::nothrow) Canvas;
1604                                 Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1605                                 pCanvas->Construct(canvasRect);
1606                                 //draw the contact bitmap
1607                                 pCanvas->DrawBitmap(canvasRect,*pPhotoId);
1608                                 Bitmap* pNewPhotoId = new Bitmap();
1609                                 pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1610                                 delete pCanvas;
1611
1612                                 pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1613                                 pPhotoLbl->Invalidate(true);
1614                                 delete pNewPhotoId;
1615                         }
1616                 }
1617         }
1618         else
1619         {
1620                 Bitmap* pDefaultPhoto = null;
1621                 switch (__formType)
1622                 {
1623                 case FORMTYPE_OUTGOINGCALL:
1624                 case FORMTYPE_ACTIVECALL:
1625                         pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_ACTIVE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO);
1626                         break;
1627
1628                 case FORMTYPE_MULTIPLECALLS:
1629                         pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_MULTIPLE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
1630                         break;
1631
1632                 case FORMTYPE_ACTIVECONFCALL:
1633                         pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BIG_BG_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO);
1634                         break;
1635
1636                 default:
1637                         break;
1638                 }
1639                 if (pDefaultPhoto != null)
1640                 {
1641                         Label* pPhotoLbl = static_cast<Label*>(GetControl(photoLabel));
1642                         if (pPhotoLbl)
1643                         {
1644                                 pPhotoLbl->SetBackgroundBitmap(*pDefaultPhoto);
1645                                 pPhotoLbl->Invalidate(true);
1646                         }
1647                         delete pDefaultPhoto;
1648                 }
1649         }
1650 }
1651
1652 void
1653 ActiveCallForm::ShowThumbnailImage(const Bitmap* pPhotoId,String& photoLabel)
1654 {
1655         Label* pPhotoLbl = static_cast<Label*>(GetControl(photoLabel));
1656
1657         if (pPhotoLbl != null && pPhotoId != null)
1658         {
1659                 Canvas* pCanvas = new (std::nothrow) Canvas;
1660                 Bitmap* pBackground = AppUtility::GetBitmapFromResourcesN(IDB_CALL_THUMBNAIL_BACKGROUND,W_CALL_THUMBNAIL,H_CALL_THUMBNAIL);
1661                 Bitmap* pShadow = AppUtility::GetBitmapFromResourcesN(IDB_CALL_THUMBNAIL_SHADOW,W_CALL_THUMBNAIL_SHADOW,H_CALL_THUMBNAIL_SHADOW);
1662                 Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1663                 pCanvas->Construct(canvasRect);
1664                 //draw the back ground
1665                 pCanvas->DrawBitmap(canvasRect,*pBackground);
1666                 //draw shadow (to be enabled after correct shadow image is provided )
1667                 //pCanvas->DrawBitmap(Rectangle((pPhotoLbl->GetBounds().width/2)-(W_CALL_THUMBNAIL_SHADOW/2),
1668                         //      (pPhotoLbl->GetBounds().height/2)-(H_CALL_THUMBNAIL_SHADOW/2),W_CALL_THUMBNAIL_SHADOW,H_CALL_THUMBNAIL_SHADOW),*pShadow);
1669                 //draw the contact bitmap
1670                 pCanvas->DrawBitmap(Rectangle((pPhotoLbl->GetBounds().width/2)-(W_SMALL_PHOTO/2),
1671                                 (pPhotoLbl->GetBounds().height/2)-(H_SMALL_PHOTO/2),W_SMALL_PHOTO,H_SMALL_PHOTO),*pPhotoId);
1672                 Bitmap* pNewPhotoId = new Bitmap();
1673                 pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1674                 delete pCanvas;
1675
1676                 pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1677                 pPhotoLbl->Invalidate(true);
1678                 delete pNewPhotoId;
1679                 delete pBackground;
1680                 delete pShadow;
1681         }
1682
1683 }
1684
1685 void
1686 ActiveCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
1687 {
1688         if (__pSmallPhotoLabel != null)
1689         {
1690                 RemoveControl(__pSmallPhotoLabel);
1691                 __pSmallPhotoLabel = null;
1692         }
1693         //Draw Small Photo and show on small photo label
1694         __pSmallPhotoLabel  = new (std::nothrow) Label();//static_cast<Label*>(GetControl(IDC_SMALL_PHOTO_LABEL));
1695         __pSmallPhotoLabel->Construct(Rectangle(X_PHOTO_LBL, Y_PHOTO_LBL, W_PHOTO_LBL, H_PHOTO_LBL), L"");
1696         __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0));
1697         __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId);
1698         // Add a Label to the Form
1699         AddControl(__pSmallPhotoLabel);
1700         __pSmallPhotoLabel->Invalidate(true);
1701 }
1702
1703 void
1704 ActiveCallForm::ShowTimerInfo(const String& timerLblName, bool isOnHold, long long startTime)
1705 {
1706         Label* pTimerLbl = static_cast<Label*>(GetControl(timerLblName));
1707
1708         if (__pActiveCallTimer == null)
1709         {
1710                 __pActiveCallTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
1711                 __pActiveCallTimer->Construct(*this);
1712         }
1713
1714         if (pTimerLbl != null)
1715         {
1716                 if (isOnHold == true)
1717                 {
1718                         pTimerLbl->SetText(AppUtility::GetResourceString(IDS_TIMER_ON_HOLD));
1719                         //update Hold button status
1720                         SetHoldButtonStatus(false);
1721                 }
1722                 else
1723                 {
1724                         //update Hold button status
1725                         SetHoldButtonStatus(true);
1726                         //current system time
1727                         long long currTime = 0;
1728                         SystemTime::GetTicks(currTime);
1729                         //Set call duration
1730                         TimeSpan diffSpan(abs(startTime - currTime));
1731
1732                         String activeCallTime(L"");
1733
1734                         long long hr = diffSpan.GetHours();
1735                         if (hr <= 9)
1736                         {
1737                                 activeCallTime.Append("0");
1738                         }
1739                         activeCallTime.Append(hr);
1740                         activeCallTime.Append(L":");
1741
1742                         long long min = diffSpan.GetMinutes();
1743                         if (min <= 9)
1744                         {
1745                                 activeCallTime.Append("0");
1746                         }
1747                         activeCallTime.Append(min);
1748                         activeCallTime.Append(L":");
1749
1750                         long long sec = diffSpan.GetSeconds();
1751                         if (sec <= 9)
1752                         {
1753                                 activeCallTime.Append("0");
1754                         }
1755                         activeCallTime.Append(sec);
1756
1757                         pTimerLbl->SetText(activeCallTime);
1758                         __pActiveCallTimer->StartAsRepeatable(TimeSpan::NUM_OF_TICKS_IN_SECOND);
1759                 }
1760                 pTimerLbl->Invalidate(true);
1761         }
1762 }
1763
1764 void
1765 ActiveCallForm::SetHoldButtonShowState(bool showState)
1766 {
1767         Label* pLblControl = static_cast<Label*>(GetControl(IDC_HOLD_LABEL));
1768         if(pLblControl != null)
1769         {
1770                 pLblControl->SetShowState(showState);
1771         }
1772         Button* pButtonControl = static_cast<Button*>(GetControl(IDC_HOLD_BUTTON));
1773         if(pButtonControl != null)
1774         {
1775                 pButtonControl->SetShowState(showState);
1776         }
1777 }
1778
1779 void
1780 ActiveCallForm::SetShowStateOnKeypad(bool showState)
1781 {
1782         Label* pLblControl = static_cast<Label*>(GetControl(IDC_CALLER1_LABEL));
1783         pLblControl->SetShowState(showState);
1784         pLblControl = static_cast<Label*>(GetControl(IDC_BACKGROUND_LABEL));
1785         pLblControl->SetShowState(showState);
1786         pLblControl = static_cast<Label*>(GetControl(IDC_CALLER1_TIME_LABEL));
1787         pLblControl->SetShowState(showState);
1788         if (__pSmallPhotoLabel != null)
1789         {
1790                 __pSmallPhotoLabel->SetShowState(showState);
1791         }
1792
1793         switch (__formType)
1794         {
1795         case FORMTYPE_ACTIVECALL:
1796         {
1797                 pLblControl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1798                 pLblControl->SetShowState(showState);
1799                 pLblControl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1800                 pLblControl->SetShowState(showState);
1801                 SetHoldButtonShowState(showState);
1802         }
1803         break;
1804
1805         case FORMTYPE_MULTIPLECALLS:
1806         {
1807                 pLblControl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1808                 pLblControl->SetShowState(showState);
1809                 pLblControl = static_cast<Label*>(GetControl(IDC_CALLER2_LABEL));
1810                 pLblControl->SetShowState(showState);
1811                 pLblControl = static_cast<Label*>(GetControl(IDC_NUMBER2_LABEL));
1812                 pLblControl->SetShowState(showState);
1813                 pLblControl = static_cast<Label*>(GetControl(IDC_CALLER2_TIME_LABEL));
1814                 pLblControl->SetShowState(showState);
1815                 pLblControl = static_cast<Label*>(GetControl(IDC_SWAP_LABEL));
1816                 pLblControl->SetShowState(showState);
1817                 pLblControl = static_cast<Label*>(GetControl(IDC_BACKGROUND_LABEL2));
1818                 pLblControl->SetShowState(showState);
1819                 if (__pActiveCallInfo != null && __pActiveCallInfo->IsConferenceCall() == false)
1820                 {
1821                         pLblControl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1822                         pLblControl->SetShowState(showState);
1823                 }
1824                 else
1825                 {
1826                         Button* pButtonControl = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1827                         pButtonControl->SetShowState(showState);
1828                 }
1829                 Button* pButtonControl = static_cast<Button*>(GetControl(IDC_SWAP_BUTTON));
1830                 pButtonControl->SetShowState(showState);
1831         }
1832         break;
1833
1834         case FORMTYPE_ACTIVECONFCALL:
1835         {
1836                 pLblControl = static_cast<Label*>(GetControl(IDC_PARTICIPANTS_LABEL));
1837                 pLblControl->SetShowState(showState);
1838                 SetHoldButtonShowState(showState);
1839                 Button* pButtonControl = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1840                 pButtonControl->SetShowState(showState);
1841         }
1842         break;
1843
1844         default:
1845                 break;
1846         }
1847 }
1848
1849 void
1850 ActiveCallForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
1851 {
1852         //Call default implementation of "Object.Equals()"
1853         //returns true, if they are pointing to same address.
1854         if (__pActiveCallTimer->Equals(timer))
1855         {
1856                 Label* pTimerLbl = static_cast<Label*>(GetControl(IDC_CALLER1_TIME_LABEL));
1857                 if (pTimerLbl)
1858                 {
1859                         String activeCallTime = pTimerLbl->GetText();
1860                         // Create a StringTokenizer instance
1861                         StringTokenizer strTokens(activeCallTime, L":");
1862
1863                         int count = strTokens.GetTokenCount(); // count == 3
1864                         String token;
1865                         int sec = 0;
1866                         int min = 0;
1867                         int hr = 0;
1868                         for (int index = 0; index < count; index++)
1869                         {
1870                                 switch (index)
1871                                 {
1872                                 case 0:
1873                                         strTokens.GetNextToken(token);
1874                                         Integer::Parse(token, hr);
1875                                         break;
1876
1877                                 case 1:
1878                                         strTokens.GetNextToken(token);
1879                                         Integer::Parse(token, min);
1880                                         break;
1881
1882                                 case 2:
1883                                         strTokens.GetNextToken(token);
1884                                         Integer::Parse(token, sec);
1885                                         break;
1886                                 }
1887                         }
1888                         //update all values
1889                         sec = sec + 1;
1890                         if (sec == IDI_MAX_SECONDS)
1891                         {
1892                                 sec = 0;
1893                                 min = min + 1;
1894                         }
1895                         if (min == IDI_MAX_MINS)
1896                         {
1897                                 min = 0;
1898                                 hr = hr + 1;
1899                         }
1900
1901                         //replace string
1902                         activeCallTime.Clear();
1903                         if (hr <= 9)
1904                         {
1905                                 activeCallTime.Append("0");
1906                         }
1907                         activeCallTime.Append(hr);
1908                         activeCallTime.Append(":");
1909                         if (min <= 9)
1910                         {
1911                                 activeCallTime.Append("0");
1912                         }
1913                         activeCallTime.Append(min);
1914                         activeCallTime.Append(":");
1915                         if (sec <= 9)
1916                         {
1917                                 activeCallTime.Append("0");
1918                         }
1919                         activeCallTime.Append(sec);
1920                         //update timer label
1921                         pTimerLbl->SetText(activeCallTime);
1922                         pTimerLbl->Invalidate(true);
1923                 }
1924         }
1925 }
1926
1927 ///////////////////////////////////////////////////////////
1928 ///////////     Options Menu List Functionality   /////////
1929 ///////////////////////////////////////////////////////////
1930 void
1931 ActiveCallForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)
1932 {
1933 }
1934
1935 void
1936 ActiveCallForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
1937 {
1938         //Goto conference call list form
1939         SceneManager* pSceneManager = SceneManager::GetInstance();
1940         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALLLIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
1941                          SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_KEEP), null);
1942 }
1943
1944 void
1945 ActiveCallForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
1946 {
1947 }
1948
1949 void
1950 ActiveCallForm::OnListViewItemLongPressed(ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
1951 {
1952 }
1953
1954 int
1955 ActiveCallForm::GetItemCount(void)
1956 {
1957         return IDI_MOREOPTIONS_LIST_ITEMS;
1958 }
1959
1960 ListItemBase*
1961 ActiveCallForm::CreateItem(int index, int itemWidth)
1962 {
1963         //create 1st Menu option
1964         CustomItem* pItem = new (std::nothrow) CustomItem();
1965         pItem->Construct(IDI_OPTIONMENU_DIMEN, LIST_ANNEX_STYLE_NORMAL);
1966
1967         //Set background 9-patch bitmap to option menu
1968         Bitmap* pBgBmp = AppUtility::GetBitmapFromResourcesN(IDB_POPUP_BG_ICON);
1969         if (pBgBmp != null && pBgBmp->IsNinePatchedBitmap())
1970         {
1971                 Canvas bgCanvas;
1972                 bgCanvas.Construct(Rectangle(IDI_OPTIONMENU_POS, IDI_OPTIONMENU_DIMEN));
1973                 bgCanvas.DrawNinePatchedBitmap(bgCanvas.GetBounds(), *pBgBmp);
1974         }
1975         else
1976         {
1977                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color(40, 45, 48));
1978         }
1979         delete pBgBmp;
1980         pBgBmp = null;
1981
1982         //Set bitmap to option menu
1983         Bitmap* pNormalConfCallBmp = AppUtility::GetBitmapFromResourcesN(IDB_MORE_MANAGE_CONFERENCE_ICON ,
1984                                                                                                                                          W_MGR_CONFCALL_BITMAP, H_MGR_CONFCALL_BITMAP);
1985         pItem->AddElement(Rectangle(16, 17, W_MGR_CONFCALL_BITMAP, H_MGR_CONFCALL_BITMAP), 1, *pNormalConfCallBmp, null, null);
1986         // Deallocate bitmaps
1987         delete pNormalConfCallBmp;
1988         pNormalConfCallBmp = null;
1989
1990         //Set text to menu option
1991         String confCallName = AppUtility::GetResourceString(IDS_MGR_CONF_CALL_LIST_STR);
1992
1993         TextElement* pTextElement = new (std::nothrow) TextElement();
1994         pTextElement->Construct(confCallName);
1995         pTextElement->SetTextColor(COLOR_POPUP_TEXT);
1996         //create font
1997         Font font;
1998         font.Construct(FONT_STYLE_PLAIN, IDI_POPUP_TEXT_SIZE);
1999         pTextElement->SetFont(font);
2000         //construct Enriched text
2001         EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText();
2002         FloatDimension textDimension;
2003         font.GetTextExtent(confCallName, confCallName.GetLength(), textDimension);
2004         textDimension.height = textDimension.height + font.GetDescender();
2005         pEnrichedText->Construct(textDimension);
2006         //add text element to enriched text
2007         pEnrichedText->Add(*pTextElement);
2008
2009         //Add Enriched text to pItem
2010         FloatPoint textPos(((2 * IDI_OPTIONMENU_ITEM_SPACING) + W_MGR_CONFCALL_BITMAP), ((IDI_OPTIONMENU_DIMEN.height - textDimension.height) / 2));
2011         pItem->AddElement(FloatRectangle(textPos, textDimension), 2, *pEnrichedText);
2012         // Cleans up
2013         pEnrichedText->RemoveAll(true);
2014         delete pEnrichedText;
2015         return pItem;
2016 }
2017
2018 bool
2019 ActiveCallForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
2020 {
2021         delete pItem;
2022         return true;
2023 }
2024
2025 void
2026 ActiveCallForm::OnForeground(void)
2027 {
2028         AppLogDebug("Enter");
2029         __pCallPresentor->OnAppForeground();
2030 }