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