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