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