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