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