e7c1274d74a7859518240ddac10af4164cc8901d
[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.IsConferenceCall() == true)
1274                                 {
1275                                         continue;
1276                                 }
1277                                 if(callInfo.IsOnHold() == false)
1278                                 {
1279                                         ShowPersonDetails(contactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
1280                                 }
1281                                 else
1282                                 {
1283                                         ShowPersonDetails(contactNumber, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pActiveCallInfo);
1284                                 }
1285
1286                         }
1287
1288                         delete pCallsList;
1289                         pCallsList = null;
1290                 }
1291         }
1292         break;
1293         default:
1294                 break;
1295         }
1296         AppLog("Exit");
1297 }
1298
1299 void
1300 ActiveCallForm::OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList)
1301 {
1302         //No implementation
1303 }
1304
1305
1306 void
1307 ActiveCallForm::UpdateMultipleCallScreen(Tizen::Base::Collection::IListT<AppCallInfo>& activeCallsList)
1308 {
1309         AppLog("ENTER");
1310         if(__pActiveCallInfo != null)
1311         {
1312                 delete __pActiveCallInfo;
1313                 __pActiveCallInfo = null;
1314         }
1315         if(__pHeldCallInfo != null)
1316         {
1317                 delete __pHeldCallInfo;
1318                 __pHeldCallInfo = null;
1319         }
1320
1321         Button* pMoreBtn = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1322         if (pMoreBtn != null)
1323         {
1324                 pMoreBtn->SetShowState(false);
1325         }
1326
1327         //show caller's info.
1328         for (int index = 0; index < activeCallsList.GetCount(); index++)
1329         {
1330                 //Fetch call info
1331                 AppCallInfo callInfo;
1332                 activeCallsList.GetAt(index, callInfo);
1333
1334                 String contactNo;
1335                 if(callInfo.GetContactNumber().IsEmpty() == false)
1336                 {
1337                         contactNo.Append(callInfo.GetContactNumber());
1338                 }
1339                 else
1340                 {
1341                         contactNo.Append(AppUtility::GetResourceString(IDS_NUMBER_UNKNOWN));
1342                 }
1343
1344                 if (callInfo.IsOnHold() == false)
1345                 {
1346                         __pActiveCallInfo = new (std::nothrow) AppCallInfo();
1347                         *__pActiveCallInfo =  callInfo;
1348
1349                         if (__pActiveCallInfo->IsConferenceCall() == false)
1350                         {
1351                                 Label* pVoiceIconLbl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1352                                 if (pVoiceIconLbl)
1353                                 {
1354                                         pVoiceIconLbl->SetShowState(true);
1355                                 }
1356                                 if (pMoreBtn != null)
1357                                 {
1358                                         pMoreBtn->SetShowState(false);
1359                                 }
1360                                 ShowPersonDetails(contactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
1361                                 if(__pMoreOptionsListAnchor != null && __pMoreOptionsListAnchor->GetShowState() == true)
1362                                 {
1363                                         CreateMoreOptionsMenuList();
1364                                 }
1365                         }
1366                         else
1367                         {
1368                                 // show participant count on name Label
1369                                 Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1370                                 if (pPeopleCountLbl)
1371                                 {
1372                                         String count;
1373                                         count.Append(__pActiveCallInfo->GetCallerListCount());
1374                                         count.Append(" ");
1375                                         count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1376                                         pPeopleCountLbl->SetText(count);
1377                                 }
1378                                 String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING");
1379                                 Label* pNameLbl = static_cast<Label*>(GetControl(IDC_CALLER1_LABEL));
1380                                 if (pNameLbl)
1381                                 {
1382                                         pNameLbl->SetText(nameStr);
1383                                 }
1384                                 Label* pVoiceIconLbl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1385                                 if (pVoiceIconLbl)
1386                                 {
1387                                         pVoiceIconLbl->SetShowState(false);
1388                                 }
1389                                 if (pMoreBtn != null)
1390                                 {
1391                                         pMoreBtn->SetShowState(true);
1392                                 }
1393                                 Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
1394                                 if (pPhotoBitmap != null)
1395                                 {
1396                                         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_CALLER1_PHOTO_LABEL));
1397                                         if (pPhotoLbl)
1398                                         {
1399                                                 pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap);
1400                                                 pPhotoLbl->Invalidate(true);
1401                                         }
1402                                         delete pPhotoBitmap;
1403                                 }
1404                         }
1405                         //show call active time using Timer
1406                         __activeCallStartTime = __pActiveCallInfo->GetCallConnectTime();
1407                         ShowTimerInfo(IDC_CALLER1_TIME_LABEL,false,__activeCallStartTime);
1408                 }
1409                 else
1410                 {
1411                         __pHeldCallInfo = new (std::nothrow) AppCallInfo();
1412                         *__pHeldCallInfo = callInfo;
1413
1414                         if (__pHeldCallInfo->IsConferenceCall() == false)
1415                         {
1416                                 ShowPersonDetails(contactNo, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pHeldCallInfo);
1417                         }
1418                         else
1419                         {
1420                                 // show participant count on name Label
1421                                 Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER2_LABEL));
1422                                 if (pPeopleCountLbl)
1423                                 {
1424                                         String count;
1425                                         count.Append(__pHeldCallInfo->GetCallerListCount());
1426                                         count.Append(" ");
1427                                         count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1428                                         pPeopleCountLbl->SetText(count);
1429                                 }
1430                                 String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING");
1431                                 Label* pNameLbl = static_cast<Label*>(GetControl(IDC_CALLER2_LABEL));
1432                                 if (pNameLbl)
1433                                 {
1434                                         pNameLbl->SetText(nameStr);
1435                                 }
1436                                 Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
1437                                 if (pPhotoBitmap != null)
1438                                 {
1439                                         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_CALLER2_PHOTO_LABEL));
1440                                         if (pPhotoLbl)
1441                                         {
1442                                                 pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap);
1443                                                 pPhotoLbl->Invalidate(true);
1444                                         }
1445                                         delete pPhotoBitmap;
1446                                 }
1447                         }
1448                         //show "On Hold"
1449                         ShowTimerInfo(IDC_CALLER2_TIME_LABEL, true);
1450                 }
1451         }
1452
1453         //update JoinCall button status
1454         __pCallButtonsPanel->EnableJoinCallButton(__pCallPresentor->IsEnableJoinCallButton());
1455         Invalidate(true);
1456         AppLog("EXIT");
1457 }
1458
1459 void
1460 ActiveCallForm::ShowPersonDetails(const String& phoneNumber, const String& contactLblName, const String& nameLblName, bool isSecondCaller, AppCallInfo* pCallInfo)
1461 {
1462         result r = E_FAILURE;
1463
1464         //call individual methods to show contact number, caller name & photo
1465         ShowPhoneNumber(phoneNumber, contactLblName);
1466
1467         //fetch contact details based on phone number
1468         String* pDisplayName = pCallInfo->FetchLatestCallerNameN(phoneNumber);
1469         ShowCallerName(*pDisplayName, nameLblName);
1470
1471         Bitmap* pPhotoBitmap = pCallInfo->FetchLatestCallerPhotoN(phoneNumber);
1472         ShowCallerPhoto(pPhotoBitmap, isSecondCaller);
1473
1474         //free resources
1475         if (pDisplayName)
1476         {
1477                 delete pDisplayName;
1478                 pDisplayName = null;
1479         }
1480         if (pPhotoBitmap)
1481         {
1482                 delete pPhotoBitmap;
1483                 pPhotoBitmap = null;
1484         }
1485 }
1486
1487 void
1488 ActiveCallForm::ShowPhoneNumber(const String& phoneNumber, const String& contactLblName)
1489 {
1490         String formattedNumber = phoneNumber;
1491
1492         Label* pContactLbl = static_cast<Label*>(GetControl(contactLblName));
1493         if (pContactLbl)
1494         {
1495                 pContactLbl->SetText(formattedNumber);
1496                 pContactLbl->Invalidate(true);
1497         }
1498 }
1499
1500 void
1501 ActiveCallForm::ShowCallerName(const String& callerName, const String& nameLblName)
1502 {
1503         // show display name on name Label
1504         Label* pNameLbl = static_cast<Label*>(GetControl(nameLblName));
1505         if (pNameLbl)
1506         {
1507                 //passing an empty string to SetText fails in label,
1508                 //if previously valid text has been set
1509                 if (callerName.IsEmpty() == true && pNameLbl->GetText().IsEmpty() == false)
1510                 {
1511                         String stringToBeSet(L" ");
1512                         pNameLbl->SetText(stringToBeSet);
1513                 }
1514                 else
1515                 {
1516                         pNameLbl->SetText(callerName);
1517                 }
1518                 pNameLbl->Invalidate(true);
1519         }
1520 }
1521
1522 void
1523 ActiveCallForm::ShowCallerPhoto(Bitmap* pPhotoId, bool isSecondCaller)
1524 {
1525         //to check if default image is to be shown
1526         bool showDefaultPhoto = false;
1527         bool showSmallPhoto = false;
1528         String photoLabel("");
1529
1530         switch (__formType)
1531         {
1532         case FORMTYPE_OUTGOINGCALL:
1533         case FORMTYPE_ACTIVECALL:
1534         {
1535                 if (pPhotoId == null)
1536                 {
1537                         //show default caller image
1538                         showDefaultPhoto = true;
1539                 }
1540                 else
1541                 {
1542                         //Check the size of photo
1543                         // Now checking the condition with && but actually it should be ||
1544                         //But for now keeping it as && because _pContact->GetThubNail() returns image width as
1545                         // height 270 and width = 480 . So all images set thru gallery is show as small image
1546                         if(pPhotoId->GetHeight() <= H_SMALL_PHOTO
1547                                         && pPhotoId->GetWidth() <= W_SMALL_PHOTO)
1548                         {
1549                                 showSmallPhoto = true;
1550                         }
1551
1552                 }
1553                 photoLabel.Append(IDC_CALLER1_BIGPHOTO_LABEL);
1554         }
1555         break;
1556
1557         case FORMTYPE_MULTIPLECALLS:
1558         {
1559                 if (isSecondCaller)
1560                 {
1561                         photoLabel.Append(IDC_CALLER2_PHOTO_LABEL);
1562                 }
1563                 else
1564                 {
1565                         photoLabel.Append(IDC_CALLER1_PHOTO_LABEL);
1566                 }
1567
1568                 if (pPhotoId == null)
1569                 {
1570                         showDefaultPhoto = true;
1571                 }
1572                 else
1573                 {
1574                         if (pPhotoId->GetHeight() <= H_SMALL_PHOTO
1575                                 && pPhotoId->GetWidth() <= W_SMALL_PHOTO)
1576                         {
1577                                 //pPhotoId->Scale(Dimension(W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO));
1578                                 showSmallPhoto = true;
1579                         }
1580                 }
1581         }
1582         break;
1583
1584         default:
1585                 break;
1586         }
1587
1588         //Remove small photo label
1589         if (__pSmallPhotoLabel != null)
1590         {
1591                 RemoveControl(__pSmallPhotoLabel);
1592                 __pSmallPhotoLabel = null;
1593         }
1594
1595         //show photo - for Big Photo Id, Animated Call Image
1596         if (!showDefaultPhoto)
1597         {
1598                 if(showSmallPhoto == true)
1599                 {
1600                         ShowThumbnailImage(pPhotoId,photoLabel);
1601                 }
1602                 else
1603                 {
1604                         Label* pPhotoLbl = static_cast<Label*>(GetControl(photoLabel));
1605                         if (pPhotoLbl)
1606                         {
1607                                 Canvas* pCanvas = new (std::nothrow) Canvas;
1608                                 Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1609                                 pCanvas->Construct(canvasRect);
1610                                 //draw the contact bitmap
1611                                 pCanvas->DrawBitmap(canvasRect,*pPhotoId);
1612                                 Bitmap* pNewPhotoId = new Bitmap();
1613                                 pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1614                                 delete pCanvas;
1615
1616                                 pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1617                                 pPhotoLbl->Invalidate(true);
1618                                 delete pNewPhotoId;
1619                         }
1620                 }
1621         }
1622         else
1623         {
1624                 Bitmap* pDefaultPhoto = null;
1625                 switch (__formType)
1626                 {
1627                 case FORMTYPE_OUTGOINGCALL:
1628                 case FORMTYPE_ACTIVECALL:
1629                         pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_ACTIVE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO);
1630                         break;
1631
1632                 case FORMTYPE_MULTIPLECALLS:
1633                         pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_MULTIPLE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
1634                         break;
1635
1636                 case FORMTYPE_ACTIVECONFCALL:
1637                         pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BIG_BG_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO);
1638                         break;
1639
1640                 default:
1641                         break;
1642                 }
1643                 if (pDefaultPhoto != null)
1644                 {
1645                         Label* pPhotoLbl = static_cast<Label*>(GetControl(photoLabel));
1646                         if (pPhotoLbl)
1647                         {
1648                                 pPhotoLbl->SetBackgroundBitmap(*pDefaultPhoto);
1649                                 pPhotoLbl->Invalidate(true);
1650                         }
1651                         delete pDefaultPhoto;
1652                 }
1653         }
1654 }
1655
1656 void
1657 ActiveCallForm::ShowThumbnailImage(const Bitmap* pPhotoId,String& photoLabel)
1658 {
1659         Label* pPhotoLbl = static_cast<Label*>(GetControl(photoLabel));
1660
1661         if (pPhotoLbl != null && pPhotoId != null)
1662         {
1663                 Canvas* pCanvas = new (std::nothrow) Canvas;
1664                 Bitmap* pBackground = AppUtility::GetBitmapFromResourcesN(IDB_CALL_THUMBNAIL_BACKGROUND,W_CALL_THUMBNAIL,H_CALL_THUMBNAIL);
1665                 Bitmap* pShadow = AppUtility::GetBitmapFromResourcesN(IDB_CALL_THUMBNAIL_SHADOW,W_CALL_THUMBNAIL_SHADOW,H_CALL_THUMBNAIL_SHADOW);
1666                 Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1667                 pCanvas->Construct(canvasRect);
1668                 //draw the back ground
1669                 pCanvas->DrawBitmap(canvasRect,*pBackground);
1670                 //draw shadow (to be enabled after correct shadow image is provided )
1671                 //pCanvas->DrawBitmap(Rectangle((pPhotoLbl->GetBounds().width/2)-(W_CALL_THUMBNAIL_SHADOW/2),
1672                         //      (pPhotoLbl->GetBounds().height/2)-(H_CALL_THUMBNAIL_SHADOW/2),W_CALL_THUMBNAIL_SHADOW,H_CALL_THUMBNAIL_SHADOW),*pShadow);
1673                 //draw the contact bitmap
1674                 pCanvas->DrawBitmap(Rectangle((pPhotoLbl->GetBounds().width/2)-(W_SMALL_PHOTO/2),
1675                                 (pPhotoLbl->GetBounds().height/2)-(H_SMALL_PHOTO/2),W_SMALL_PHOTO,H_SMALL_PHOTO),*pPhotoId);
1676                 Bitmap* pNewPhotoId = new Bitmap();
1677                 pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1678                 delete pCanvas;
1679
1680                 pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1681                 pPhotoLbl->Invalidate(true);
1682                 delete pNewPhotoId;
1683                 delete pBackground;
1684                 delete pShadow;
1685         }
1686
1687 }
1688
1689 void
1690 ActiveCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
1691 {
1692         if (__pSmallPhotoLabel != null)
1693         {
1694                 RemoveControl(__pSmallPhotoLabel);
1695                 __pSmallPhotoLabel = null;
1696         }
1697         //Draw Small Photo and show on small photo label
1698         __pSmallPhotoLabel  = new (std::nothrow) Label();//static_cast<Label*>(GetControl(IDC_SMALL_PHOTO_LABEL));
1699         __pSmallPhotoLabel->Construct(Rectangle(X_PHOTO_LBL, Y_PHOTO_LBL, W_PHOTO_LBL, H_PHOTO_LBL), L"");
1700         __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0));
1701         __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId);
1702         // Add a Label to the Form
1703         AddControl(__pSmallPhotoLabel);
1704         __pSmallPhotoLabel->Invalidate(true);
1705 }
1706
1707 void
1708 ActiveCallForm::ShowTimerInfo(const String& timerLblName, bool isOnHold, long long startTime)
1709 {
1710         Label* pTimerLbl = static_cast<Label*>(GetControl(timerLblName));
1711
1712         if (__pActiveCallTimer == null)
1713         {
1714                 __pActiveCallTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
1715                 __pActiveCallTimer->Construct(*this);
1716         }
1717
1718         if (pTimerLbl != null)
1719         {
1720                 if (isOnHold == true)
1721                 {
1722                         pTimerLbl->SetText(AppUtility::GetResourceString(IDS_TIMER_ON_HOLD));
1723                         //update Hold button status
1724                         SetHoldButtonStatus(false);
1725                 }
1726                 else
1727                 {
1728                         //update Hold button status
1729                         SetHoldButtonStatus(true);
1730                         //current system time
1731                         long long currTime = 0;
1732                         SystemTime::GetTicks(currTime);
1733                         //Set call duration
1734                         TimeSpan diffSpan(abs(startTime - currTime));
1735
1736                         String activeCallTime(L"");
1737
1738                         long long hr = diffSpan.GetHours();
1739                         if (hr <= 9)
1740                         {
1741                                 activeCallTime.Append("0");
1742                         }
1743                         activeCallTime.Append(hr);
1744                         activeCallTime.Append(L":");
1745
1746                         long long min = diffSpan.GetMinutes();
1747                         if (min <= 9)
1748                         {
1749                                 activeCallTime.Append("0");
1750                         }
1751                         activeCallTime.Append(min);
1752                         activeCallTime.Append(L":");
1753
1754                         long long sec = diffSpan.GetSeconds();
1755                         if (sec <= 9)
1756                         {
1757                                 activeCallTime.Append("0");
1758                         }
1759                         activeCallTime.Append(sec);
1760
1761                         pTimerLbl->SetText(activeCallTime);
1762                         __pActiveCallTimer->StartAsRepeatable(TimeSpan::NUM_OF_TICKS_IN_SECOND);
1763                 }
1764                 pTimerLbl->Invalidate(true);
1765         }
1766 }
1767
1768 void
1769 ActiveCallForm::SetHoldButtonShowState(bool showState)
1770 {
1771         Label* pLblControl = static_cast<Label*>(GetControl(IDC_HOLD_LABEL));
1772         if(pLblControl != null)
1773         {
1774                 pLblControl->SetShowState(showState);
1775         }
1776         Button* pButtonControl = static_cast<Button*>(GetControl(IDC_HOLD_BUTTON));
1777         if(pButtonControl != null)
1778         {
1779                 pButtonControl->SetShowState(showState);
1780         }
1781 }
1782
1783 void
1784 ActiveCallForm::SetShowStateOnKeypad(bool showState)
1785 {
1786         Label* pLblControl = static_cast<Label*>(GetControl(IDC_CALLER1_LABEL));
1787         pLblControl->SetShowState(showState);
1788         pLblControl = static_cast<Label*>(GetControl(IDC_BACKGROUND_LABEL));
1789         pLblControl->SetShowState(showState);
1790         pLblControl = static_cast<Label*>(GetControl(IDC_CALLER1_TIME_LABEL));
1791         pLblControl->SetShowState(showState);
1792         if (__pSmallPhotoLabel != null)
1793         {
1794                 __pSmallPhotoLabel->SetShowState(showState);
1795         }
1796
1797         switch (__formType)
1798         {
1799         case FORMTYPE_ACTIVECALL:
1800         {
1801                 pLblControl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1802                 pLblControl->SetShowState(showState);
1803                 pLblControl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1804                 pLblControl->SetShowState(showState);
1805                 SetHoldButtonShowState(showState);
1806         }
1807         break;
1808
1809         case FORMTYPE_MULTIPLECALLS:
1810         {
1811                 pLblControl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1812                 pLblControl->SetShowState(showState);
1813                 pLblControl = static_cast<Label*>(GetControl(IDC_CALLER2_LABEL));
1814                 pLblControl->SetShowState(showState);
1815                 pLblControl = static_cast<Label*>(GetControl(IDC_NUMBER2_LABEL));
1816                 pLblControl->SetShowState(showState);
1817                 pLblControl = static_cast<Label*>(GetControl(IDC_CALLER2_TIME_LABEL));
1818                 pLblControl->SetShowState(showState);
1819                 pLblControl = static_cast<Label*>(GetControl(IDC_SWAP_LABEL));
1820                 pLblControl->SetShowState(showState);
1821                 pLblControl = static_cast<Label*>(GetControl(IDC_BACKGROUND_LABEL2));
1822                 pLblControl->SetShowState(showState);
1823                 if (__pActiveCallInfo != null && __pActiveCallInfo->IsConferenceCall() == false)
1824                 {
1825                         pLblControl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1826                         pLblControl->SetShowState(showState);
1827                 }
1828                 else
1829                 {
1830                         Button* pButtonControl = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1831                         pButtonControl->SetShowState(showState);
1832                 }
1833                 Button* pButtonControl = static_cast<Button*>(GetControl(IDC_SWAP_BUTTON));
1834                 pButtonControl->SetShowState(showState);
1835         }
1836         break;
1837
1838         case FORMTYPE_ACTIVECONFCALL:
1839         {
1840                 pLblControl = static_cast<Label*>(GetControl(IDC_PARTICIPANTS_LABEL));
1841                 pLblControl->SetShowState(showState);
1842                 SetHoldButtonShowState(showState);
1843                 Button* pButtonControl = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1844                 pButtonControl->SetShowState(showState);
1845         }
1846         break;
1847
1848         default:
1849                 break;
1850         }
1851 }
1852
1853 void
1854 ActiveCallForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
1855 {
1856         //Call default implementation of "Object.Equals()"
1857         //returns true, if they are pointing to same address.
1858         if (__pActiveCallTimer->Equals(timer))
1859         {
1860                 Label* pTimerLbl = static_cast<Label*>(GetControl(IDC_CALLER1_TIME_LABEL));
1861                 if (pTimerLbl)
1862                 {
1863                         String activeCallTime = pTimerLbl->GetText();
1864                         // Create a StringTokenizer instance
1865                         StringTokenizer strTokens(activeCallTime, L":");
1866
1867                         int count = strTokens.GetTokenCount(); // count == 3
1868                         String token;
1869                         int sec = 0;
1870                         int min = 0;
1871                         int hr = 0;
1872                         for (int index = 0; index < count; index++)
1873                         {
1874                                 switch (index)
1875                                 {
1876                                 case 0:
1877                                         strTokens.GetNextToken(token);
1878                                         Integer::Parse(token, hr);
1879                                         break;
1880
1881                                 case 1:
1882                                         strTokens.GetNextToken(token);
1883                                         Integer::Parse(token, min);
1884                                         break;
1885
1886                                 case 2:
1887                                         strTokens.GetNextToken(token);
1888                                         Integer::Parse(token, sec);
1889                                         break;
1890                                 }
1891                         }
1892                         //update all values
1893                         sec = sec + 1;
1894                         if (sec == IDI_MAX_SECONDS)
1895                         {
1896                                 sec = 0;
1897                                 min = min + 1;
1898                         }
1899                         if (min == IDI_MAX_MINS)
1900                         {
1901                                 min = 0;
1902                                 hr = hr + 1;
1903                         }
1904
1905                         //replace string
1906                         activeCallTime.Clear();
1907                         if (hr <= 9)
1908                         {
1909                                 activeCallTime.Append("0");
1910                         }
1911                         activeCallTime.Append(hr);
1912                         activeCallTime.Append(":");
1913                         if (min <= 9)
1914                         {
1915                                 activeCallTime.Append("0");
1916                         }
1917                         activeCallTime.Append(min);
1918                         activeCallTime.Append(":");
1919                         if (sec <= 9)
1920                         {
1921                                 activeCallTime.Append("0");
1922                         }
1923                         activeCallTime.Append(sec);
1924                         //update timer label
1925                         pTimerLbl->SetText(activeCallTime);
1926                         pTimerLbl->Invalidate(true);
1927                 }
1928         }
1929 }
1930
1931 ///////////////////////////////////////////////////////////
1932 ///////////     Options Menu List Functionality   /////////
1933 ///////////////////////////////////////////////////////////
1934 void
1935 ActiveCallForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)
1936 {
1937 }
1938
1939 void
1940 ActiveCallForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
1941 {
1942         //Goto conference call list form
1943         SceneManager* pSceneManager = SceneManager::GetInstance();
1944         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALLLIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
1945                          SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_KEEP), null);
1946 }
1947
1948 void
1949 ActiveCallForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
1950 {
1951 }
1952
1953 void
1954 ActiveCallForm::OnListViewItemLongPressed(ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
1955 {
1956 }
1957
1958 int
1959 ActiveCallForm::GetItemCount(void)
1960 {
1961         return IDI_MOREOPTIONS_LIST_ITEMS;
1962 }
1963
1964 ListItemBase*
1965 ActiveCallForm::CreateItem(int index, int itemWidth)
1966 {
1967         //create 1st Menu option
1968         CustomItem* pItem = new (std::nothrow) CustomItem();
1969         pItem->Construct(IDI_OPTIONMENU_DIMEN, LIST_ANNEX_STYLE_NORMAL);
1970
1971         //Set background 9-patch bitmap to option menu
1972         Bitmap* pBgBmp = AppUtility::GetBitmapFromResourcesN(IDB_POPUP_BG_ICON);
1973         if (pBgBmp != null && pBgBmp->IsNinePatchedBitmap())
1974         {
1975                 Canvas bgCanvas;
1976                 bgCanvas.Construct(Rectangle(IDI_OPTIONMENU_POS, IDI_OPTIONMENU_DIMEN));
1977                 bgCanvas.DrawNinePatchedBitmap(bgCanvas.GetBounds(), *pBgBmp);
1978         }
1979         else
1980         {
1981                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color(40, 45, 48));
1982         }
1983         delete pBgBmp;
1984         pBgBmp = null;
1985
1986         //Set bitmap to option menu
1987         Bitmap* pNormalConfCallBmp = AppUtility::GetBitmapFromResourcesN(IDB_MORE_MANAGE_CONFERENCE_ICON ,
1988                                                                                                                                          W_MGR_CONFCALL_BITMAP, H_MGR_CONFCALL_BITMAP);
1989         pItem->AddElement(Rectangle(16, 17, W_MGR_CONFCALL_BITMAP, H_MGR_CONFCALL_BITMAP), 1, *pNormalConfCallBmp, null, null);
1990         // Deallocate bitmaps
1991         delete pNormalConfCallBmp;
1992         pNormalConfCallBmp = null;
1993
1994         //Set text to menu option
1995         String confCallName = AppUtility::GetResourceString(IDS_MGR_CONF_CALL_LIST_STR);
1996
1997         TextElement* pTextElement = new (std::nothrow) TextElement();
1998         pTextElement->Construct(confCallName);
1999         pTextElement->SetTextColor(COLOR_POPUP_TEXT);
2000         //create font
2001         Font font;
2002         font.Construct(FONT_STYLE_PLAIN, IDI_POPUP_TEXT_SIZE);
2003         pTextElement->SetFont(font);
2004         //construct Enriched text
2005         EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText();
2006         FloatDimension textDimension;
2007         font.GetTextExtent(confCallName, confCallName.GetLength(), textDimension);
2008         textDimension.height = textDimension.height + font.GetDescender();
2009         pEnrichedText->Construct(textDimension);
2010         //add text element to enriched text
2011         pEnrichedText->Add(*pTextElement);
2012
2013         //Add Enriched text to pItem
2014         FloatPoint textPos(((2 * IDI_OPTIONMENU_ITEM_SPACING) + W_MGR_CONFCALL_BITMAP), ((IDI_OPTIONMENU_DIMEN.height - textDimension.height) / 2));
2015         pItem->AddElement(FloatRectangle(textPos, textDimension), 2, *pEnrichedText);
2016         // Cleans up
2017         pEnrichedText->RemoveAll(true);
2018         delete pEnrichedText;
2019         return pItem;
2020 }
2021
2022 bool
2023 ActiveCallForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
2024 {
2025         delete pItem;
2026         return true;
2027 }
2028
2029 void
2030 ActiveCallForm::OnForeground(void)
2031 {
2032         AppLogDebug("Enter");
2033         __pCallPresentor->OnAppForeground();
2034 }