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