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