Tizen 2.0 Release
[apps/osp/Phone.git] / src / PhnActiveCallForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (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 "PhnActiveCallForm.h"
26 #include "PhnCallButtonsPanel.h"
27 #include "PhnCallInfo.h"
28 #include "PhnAppUtility.h"
29 #include "PhnDtmfKeypadPanel.h"
30 #include "PhnCallPresentationModel.h"
31 #include "PhnSceneRegister.h"
32 #include "PhnTypes.h"
33
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Base::Utility;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Media;
40 using namespace Tizen::Social;
41 using namespace Tizen::System;
42 using namespace Tizen::Ui;
43 using namespace Tizen::Ui::Controls;
44 using namespace Tizen::Ui::Scenes;
45
46 //constants
47 const int IDI_MAX_SECONDS = 60;
48 const int IDI_MAX_MINS = 60;
49 const int W_HOLD_BITMAP = 78;
50 const int H_HOLD_BITMAP = 78;
51 //for Options menu list
52 const int IDI_POPUP_TEXT_SIZE = 33;
53 const unsigned int COLOR_POPUP_TEXT = Color32<255, 255, 255, 255>::Value;
54 const int IDI_MOREOPTIONS_LIST_ITEMS = 1;
55 const int W_OPTION_ANCHOR = 72;
56 const int H_OPTION_ANCHOR = 22;
57 const int W_MGR_CONFCALL_BITMAP = 64;
58 const int H_MGR_CONFCALL_BITMAP = 64;
59 const int X_DTMF_KEYPAD = 40;
60 const int IDI_YMARGIN_DTMF_KEYPAD = 26;
61 const int X_POPUP_ANCHOR = 632;
62 const int Y_POPUP_ANCHOR = 140;
63 const int W_POPUP_ANCHOR = 72;
64 const int H_POPUP_ANCHOR = 22;
65 const int IDI_OPTIONMENU_ITEM_SPACING = 16;
66 const Point IDI_OPTIONMENU_POS(238, 162);
67 const Dimension IDI_OPTIONMENU_DIMEN(466, 99);
68 const int X_PHOTO_LBL = 166;
69 const int Y_PHOTO_LBL = 232;
70 const int W_PHOTO_LBL = 388;
71 const int H_PHOTO_LBL = 388;
72 const int W_PHOTO_LABEL = 720;
73 const int H_PHOTO_LABEL = 720;
74
75 static const wchar_t* IDC_CONF_CALL_MORE_BUTTON = L"IDC_CONF_CALL_MORE_BUTTON";
76 static const wchar_t* IDC_HOLD_BUTTON = L"IDC_HOLD_BUTTON";
77 static const wchar_t* IDC_SWAP_BUTTON = L"IDC_SWAP_BUTTON";
78 static const wchar_t* IDC_HOLD_LABEL = L"IDC_HOLD_LABEL";
79 static const wchar_t* IDC_TEXTBOX = L"IDC_TEXTBOX";
80 static const wchar_t* IDC_LINE_LABEL = L"IDC_LINE_LABEL";
81 static const wchar_t* IDC_CALLER1_LABEL = L"IDC_CALLER1_LABEL";
82 static const wchar_t* IDC_BACKGROUND_LABEL = L"IDC_BACKGROUND_LABEL";
83 static const wchar_t* IDC_CALLER1_TIME_LABEL = L"IDC_CALLER1_TIME_LABEL";
84 static const wchar_t* IDC_NUMBER1_LABEL = L"IDC_NUMBER1_LABEL";
85 static const wchar_t* IDC_VOICE_CALL_ICON_LABEL = L"IDC_VOICE_CALL_ICON_LABEL";
86 static const wchar_t* IDC_CALLER2_LABEL = L"IDC_CALLER2_LABEL";
87 static const wchar_t* IDC_NUMBER2_LABEL = L"IDC_NUMBER2_LABEL";
88 static const wchar_t* IDC_CALLER2_TIME_LABEL = L"IDC_CALLER2_TIME_LABEL";
89 static const wchar_t* IDC_SWAP_LABEL = L"IDC_SWAP_LABEL";
90 static const wchar_t* IDC_BACKGROUND_LABEL2 = L"IDC_BACKGROUND_LABEL2";
91 static const wchar_t* IDC_PARTICIPANTS_LABEL = L"IDC_PARTICIPANTS_LABEL";
92 static const wchar_t* IDC_DIVIDER_LABEL = L"IDC_DIVIDER_LABEL";
93 static const wchar_t* IDC_CALLER1_BIGPHOTO_LABEL = L"IDC_CALLER1_BIGPHOTO_LABEL";
94 static const wchar_t* IDC_CALLER2_PHOTO_LABEL = L"IDC_CALLER2_PHOTO_LABEL";
95 static const wchar_t* IDC_CALLER1_PHOTO_LABEL = L"IDC_CALLER1_PHOTO_LABEL";
96
97 ActiveCallForm::ActiveCallForm(FormType formType)
98         : BaseForm(formType)
99 {
100         __pActiveCallTimer = null;
101         __pCallButtonsPanel = null;
102         __pDTMFKeypad = null;
103         __pMoreOptionsList = null;
104         __pMoreOptionsListAnchor = null;
105         __pSmallPhotoLabel = null;
106         __pActiveCallInfo = null;
107         __pHeldCallInfo = null;
108 }
109
110 ActiveCallForm::~ActiveCallForm(void)
111 {
112         if (__pActiveCallTimer != null)
113         {
114                 __pActiveCallTimer->Cancel();
115                 delete __pActiveCallTimer;
116         }
117         if (__pMoreOptionsList != null)
118         {
119                 RemoveControl(*__pMoreOptionsList);
120                 __pMoreOptionsList = null;
121         }
122         if (__pMoreOptionsListAnchor != null)
123         {
124                 RemoveControl(*__pMoreOptionsListAnchor);
125                 __pMoreOptionsListAnchor = null;
126         }
127         if (__pSmallPhotoLabel != null)
128         {
129                 RemoveControl(*__pSmallPhotoLabel);
130                 __pSmallPhotoLabel = null;
131         }
132         if (__pActiveCallInfo != null)
133         {
134                 delete __pActiveCallInfo;
135         }
136         if (__pHeldCallInfo != null)
137         {
138                 delete __pHeldCallInfo;
139         }
140         if(__pDTMFKeypad != null)
141         {
142                 RemoveControl(*__pDTMFKeypad);
143                 __pDTMFKeypad = null;
144         }
145 }
146
147 void
148 ActiveCallForm::Initialize(void)
149 {
150         switch (__formType)
151         {
152         case FORMTYPE_OUTGOINGCALL:
153                 Construct(IDL_OUTCALL_FORM);
154                 break;
155
156         case FORMTYPE_EMERGENCYOUTGOINGCALL:
157                 Construct(IDL_OUT_EMERGENCYCALL_FORM);
158                 break;
159
160         case FORMTYPE_ACTIVECALL:
161                 Construct(IDL_CALL_FORM);
162                 break;
163
164         case FORMTYPE_EMERGENCYACTIVECALL:
165                 Construct(IDL_EMERGENCY_CALL_FORM);
166                 break;
167
168         case FORMTYPE_MULTIPLECALLS:
169                 Construct(IDL_MULTIPLE_CALL_FORM);
170                 break;
171
172         case FORMTYPE_ACTIVECONFCALL:
173                 Construct(IDL_CONFCALL_FORM);
174                 break;
175
176         default:
177                 break;
178         }
179
180         //Initialize keypad and buttons
181         InitializeCallButtonsPanel();
182         //Hold Button - Shown on single active/conf call scene
183         InitializeHoldButton();
184         //Swap button for multiple call screen
185         InitializeSwapButton();
186         //Initialize manage conf. call list form
187         InitializeManageConfCallButton();
188 }
189
190 result
191 ActiveCallForm::OnInitializing(void)
192 {
193         result r = E_SUCCESS;
194
195         RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(GetParent()->GetLandscapeLayoutN());
196         if (pRelativeLayout != null)
197         {
198                 pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
199                 pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
200                 delete pRelativeLayout;
201         }
202         pRelativeLayout = dynamic_cast<RelativeLayout*>(GetParent()->GetPortraitLayoutN());
203         if (pRelativeLayout != null)
204         {
205                 pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
206                 pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
207                 delete pRelativeLayout;
208         }
209
210         __pCallPresentor = CallPresentationModel::GetInstance();
211
212         return r;
213 }
214
215 void
216 ActiveCallForm::ShowDTMFKeypad(void)
217 {
218         if(__pDTMFKeypad == null)
219         {
220                 Rectangle rect(X_DTMF_KEYPAD, 0, 0, 0);
221                 //update rect according to client screen area
222                 rect.width = GetClientAreaBounds().width - (2 * X_DTMF_KEYPAD);
223                 rect.height = GetClientAreaBounds().height - __pCallButtonsPanel->GetHeight() - IDI_YMARGIN_DTMF_KEYPAD;
224                 __pDTMFKeypad = new (std::nothrow) DtmfKeyPadPanel();
225                 __pDTMFKeypad->Initialize(this, rect);
226                 AddControl(*__pDTMFKeypad);
227         }
228         TextBox* pTextBox = static_cast<TextBox*>(__pDTMFKeypad->GetControl(IDC_TEXTBOX));
229         pTextBox->SetText(L"");
230         __pDTMFKeypad->SetShowState(true);
231         __pDTMFKeypad->Draw(true);
232         __pDTMFKeypad->Show();
233 }
234
235 void
236 ActiveCallForm::HideDTMFKeypad(void)
237 {
238         if(__pDTMFKeypad != null)
239         {
240                 __pDTMFKeypad->SetShowState(false);
241         }
242 }
243
244 result
245 ActiveCallForm::InitializeCallButtonsPanel(void)
246 {
247         __pCallButtonsPanel = new (std::nothrow) CallButtonsPanel();
248         __pCallButtonsPanel->ConstructPanel(this, __formType);
249
250         result r = AddControl(*__pCallButtonsPanel);
251         return r;
252 }
253
254 void
255 ActiveCallForm::InitializeSwapButton(void)
256 {
257         Button* pSwapBtn = static_cast<Button*>(GetControl(IDC_SWAP_BUTTON));
258         if (pSwapBtn)
259         {
260                 Bitmap* pSwapBmp = AppUtility::GetBitmapFromResourcesN(IDB_SWAP_ICON_NORMAL,
261                                                                                                                            W_HOLD_BITMAP, H_HOLD_BITMAP);
262                 if (pSwapBmp)
263                 {
264                         pSwapBtn->SetNormalBitmap(Point(0, 0), *pSwapBmp);
265                 }
266                 delete pSwapBmp;
267                 pSwapBmp = null;
268
269                 pSwapBmp = AppUtility::GetBitmapFromResourcesN(IDB_SWAP_ICON_PRESS,
270                                                                                                            W_HOLD_BITMAP, H_HOLD_BITMAP);
271                 if (pSwapBmp)
272                 {
273                         pSwapBtn->SetPressedBitmap(Point(0, 0), *pSwapBmp);
274                 }
275                 delete pSwapBmp;
276                 pSwapBmp = null;
277                 pSwapBtn->SetActionId(IDA_SWAP_CALLS);
278                 pSwapBtn->AddActionEventListener(*this);
279         }
280 }
281
282 void
283 ActiveCallForm::InitializeManageConfCallButton(void)
284 {
285         Button* pMoreBtn = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
286         if (pMoreBtn != null)
287         {
288                 pMoreBtn->SetActionId(IDA_MORE_OPTIONS_MENU);
289                 pMoreBtn->AddActionEventListener(*this);
290                 if (__formType == FORMTYPE_MULTIPLECALLS)
291                 {
292                         //Correct state will be set in OnSceneActivated based on the call
293                         pMoreBtn->SetShowState(false);
294                         Label* pLblControl = static_cast<Label*>(GetControl(IDC_DIVIDER_LABEL));
295                         if (pLblControl)
296                         {
297                                 pLblControl->SetShowState(false);
298                         }
299                 }
300                 else if (__formType == FORMTYPE_ACTIVECONFCALL)
301                 {
302                         pMoreBtn->SetShowState(true);
303                         Label* pLblControl = static_cast<Label*>(GetControl(IDC_DIVIDER_LABEL));
304                         if (pLblControl)
305                         {
306                                 pLblControl->SetShowState(true);
307                         }
308                 }
309         }
310 }
311
312 void
313 ActiveCallForm::InitializeHoldButton(void)
314 {
315         Button* pHoldBtn = static_cast<Button*>(GetControl(IDC_HOLD_BUTTON));
316         if (pHoldBtn != null)
317         {
318                 //set status of Hold Button
319                 SetHoldButtonStatus(true);
320                 pHoldBtn->AddActionEventListener(*this);
321         }
322 }
323
324 void
325 ActiveCallForm::SetHoldButtonStatus(bool toHoldCall)
326 {
327         //background bitmap & button name
328         String btnName("");
329         Bitmap* normalImg = null;
330         Bitmap* pressImg = null;
331         if (toHoldCall)
332         {
333                 btnName.Append(AppUtility::GetResourceString(IDS_HOLD_BTN_NAME));
334                 normalImg = AppUtility::GetBitmapFromResourcesN(IDB_HOLD_NORMAL_BUTTON_ICON,
335                                                                                                                 W_HOLD_BITMAP, H_HOLD_BITMAP);
336                 pressImg = AppUtility::GetBitmapFromResourcesN(IDB_HOLD_PRESS_BUTTON_ICON,
337                                                                                                            W_HOLD_BITMAP, H_HOLD_BITMAP);
338         }
339         else
340         {
341                 btnName.Append(AppUtility::GetResourceString(IDS_UNHOLD_BTN_NAME));
342                 normalImg = AppUtility::GetBitmapFromResourcesN(IDB_UNHOLD_NORMAL_BUTTON_ICON,
343                                                                                                                 W_HOLD_BITMAP, H_HOLD_BITMAP);
344                 pressImg = AppUtility::GetBitmapFromResourcesN(IDB_UNHOLD_PRESS_BUTTON_ICON,
345                                                                                                            W_HOLD_BITMAP, H_HOLD_BITMAP);
346         }
347
348         //Action id
349         CommandIds cmdId = IDA_HOLD_CALL;
350         switch (__formType)
351         {
352         case FORMTYPE_ACTIVECALL:
353         {
354                 cmdId = toHoldCall ? IDA_HOLD_CALL : IDA_UNHOLD_CALL;
355         }
356         break;
357
358         case FORMTYPE_ACTIVECONFCALL:
359         {
360                 cmdId = toHoldCall ? IDA_HOLD_CONF_CALL : IDA_UNHOLD_CONF_CALL;
361         }
362         break;
363
364         default:
365                 break;
366         }
367
368         //set background bitmap, button name & action id
369         Button* pHoldBtn = static_cast<Button*>(GetControl(IDC_HOLD_BUTTON));
370         Label* pHoldLbl = static_cast<Label*>(GetControl(IDC_HOLD_LABEL));
371         if (pHoldBtn)
372         {
373                 pHoldBtn->SetActionId(cmdId);
374                 pHoldBtn->SetNormalBitmap(Point(0, 0),*normalImg);
375                 pHoldBtn->SetPressedBitmap(Point(0, 0),*pressImg);
376         }
377         if (pHoldLbl)
378         {
379                 pHoldLbl->SetText(btnName);
380                 pHoldLbl->Invalidate(true);
381         }
382
383         //free the resources
384         delete normalImg;
385         normalImg = null;
386         delete pressImg;
387         pressImg = null;
388 }
389
390 void
391 ActiveCallForm::CreateMoreOptionsMenuList(void)
392 {
393         //create option list anchor
394         if (__pMoreOptionsListAnchor == null)
395         {
396                 Bitmap* pBgPopupArwBmp = AppUtility::GetBitmapFromResourcesN(IDB_POPUP_ARROW_ICON, W_OPTION_ANCHOR,
397                                                                                                                                          H_OPTION_ANCHOR);
398                 __pMoreOptionsListAnchor = new (std::nothrow) Label();
399                 __pMoreOptionsListAnchor->Construct(Rectangle(X_POPUP_ANCHOR, Y_POPUP_ANCHOR, W_POPUP_ANCHOR, H_POPUP_ANCHOR), L"");
400                 __pMoreOptionsListAnchor->SetBackgroundBitmap(*pBgPopupArwBmp);
401
402                 delete pBgPopupArwBmp;
403                 pBgPopupArwBmp = null;
404
405                 // Adds a Label to the Form
406                 AddControl(*__pMoreOptionsListAnchor);
407         }
408
409         //create options menu list
410         if (__pMoreOptionsList == null)
411         {
412                 __pMoreOptionsList = new (std::nothrow) ListView();
413                 __pMoreOptionsList->Construct(Rectangle(IDI_OPTIONMENU_POS, IDI_OPTIONMENU_DIMEN), false, SCROLL_STYLE_FADE_OUT);
414                 __pMoreOptionsList->SetItemProvider(*this);
415                 __pMoreOptionsList->AddListViewItemEventListener(*this);
416                 //Add option list to the form
417                 AddControl(*__pMoreOptionsList);
418         }
419         else
420         {
421                 //Hide option menu list
422                 DestroyMoreOptionsMenuList();
423         }
424 }
425
426 void
427 ActiveCallForm::DestroyMoreOptionsMenuList(void)
428 {
429         if (__pMoreOptionsListAnchor != null)
430         {
431                 //removes and delete the child control
432                 RemoveControl(*__pMoreOptionsListAnchor);
433                 __pMoreOptionsListAnchor = null;
434         }
435
436         if (__pMoreOptionsList != null)
437         {
438                 //removes and delete the child control
439                 RemoveControl(*__pMoreOptionsList);
440                 __pMoreOptionsList = null;
441         }
442 }
443
444 result
445 ActiveCallForm::OnTerminating(void)
446 {
447         result r = E_SUCCESS;
448         if (__pCallPresentor != null)
449         {
450                 __pCallPresentor = null;
451         }
452         return r;
453 }
454
455 void
456 ActiveCallForm::OnActionPerformed(const Control& source, int actionId)
457 {
458         SceneManager* pSceneManager = SceneManager::GetInstance();
459
460         String dtmfString;
461         switch (actionId)
462         {
463         case IDA_END_CALL:
464         {
465                 //End the currently active / dialing call
466                 if (__pActiveCallInfo->IsConferenceCall() == false)
467                 {
468                         String activeContactNo;
469                         activeContactNo.Append(__pActiveCallInfo->GetContactNumber());
470                         //In case of if its a hidden call
471                         if(__pActiveCallInfo->GetContactNumber().IsEmpty() == true)
472                         {
473                                 __pCallPresentor->EndCall(*__pActiveCallInfo->GetCallHandle());
474                         }
475                         else
476                         {
477                                 __pCallPresentor->EndCall(activeContactNo);
478                         }
479                 }
480                 else
481                 {
482                         __pCallPresentor->EndConferenceCall();
483                 }
484         }
485         break;
486
487         case IDA_END_CONF_CALL:
488         {
489                 AppAssert(__formType == FORMTYPE_ACTIVECONFCALL);
490                 __pCallPresentor->EndConferenceCall();
491         }
492         break;
493
494         case IDA_OPEN_NUMKEYPAD:
495         {
496                 SetShowStateOnKeypad(false);
497                 ShowDTMFKeypad();
498                 SetTextToDTMFTextField(L"");
499                 __pCallButtonsPanel->SetKeypadButtonState(IDA_CLOSE_NUMKEYPAD);
500         }
501         break;
502
503         case IDA_CLOSE_NUMKEYPAD:
504         {
505                 SetShowStateOnKeypad(true);
506                 HideDTMFKeypad();
507                 __pCallButtonsPanel->SetKeypadButtonState(IDA_OPEN_NUMKEYPAD);
508         }
509         break;
510
511         case IDA_ADD_CALL:
512         {
513                 //switch to Dialer Form to make an call
514                 if(__pCallPresentor->GetCurrentCallCount() == 1)
515                 {
516                 ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
517                 pArgs->Construct();
518                 String* formType = new (std::nothrow) String();
519                 formType->Append(__formType);
520                 pArgs->Add(formType);
521                 pSceneManager->GoForward( ForwardSceneTransition(IDSCN_DIALER, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
522                                 SCENE_HISTORY_OPTION_NO_HISTORY), pArgs);
523                 }
524         }
525         break;
526
527         case IDA_HOLD_CALL:
528         {
529                 bool success = true;
530                 if (__pActiveCallInfo->IsConferenceCall() == false)
531                 {
532                         if(__pActiveCallInfo->GetCallHandle() != null)
533                         {
534                                 success = __pCallPresentor->HoldCall(*__pActiveCallInfo->GetCallHandle());
535                         }
536                 }
537                 else
538                 {
539                         success = __pCallPresentor->HoldConferenceCall();
540                 }
541                 //reset hold status and "OnHold" text
542                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, success);
543                 if(__pActiveCallTimer != null)
544                 {
545                         __pActiveCallTimer->Cancel();
546                 }
547                 SetHoldButtonStatus(!success);
548         }
549         break;
550
551         case IDA_UNHOLD_CALL:
552         {
553                 bool success = false;
554                 if (__pActiveCallInfo->IsConferenceCall() == false)
555                 {
556                         if(__pActiveCallInfo->GetCallHandle() != null)
557                         {
558                                 success = __pCallPresentor->UnHoldCall(*__pActiveCallInfo->GetCallHandle());
559                         }
560                 }
561                 else
562                 {
563                         success = __pCallPresentor->ActivateConferenceCall();
564                 }
565                 //reset hold status and show call timer
566                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, !success, __activeCallStartTime);
567                 SetHoldButtonStatus(success);
568         }
569         break;
570
571         case IDA_HOLD_CONF_CALL:
572         {
573                 AppAssert(__formType == FORMTYPE_ACTIVECONFCALL);
574                 bool success = __pCallPresentor->HoldConferenceCall();
575                 //reset hold status and "OnHold" text
576                 SetHoldButtonStatus(!success);
577                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, success);
578                 if(__pActiveCallTimer != null)
579                 {
580                         __pActiveCallTimer->Cancel();
581                 }
582         }
583         break;
584
585         case IDA_UNHOLD_CONF_CALL:
586         {
587                 AppAssert(__formType == FORMTYPE_ACTIVECONFCALL);
588                 bool success = __pCallPresentor->ActivateConferenceCall();
589                 //reset hold status and show call timer
590                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, !success, __activeCallStartTime);
591                 SetHoldButtonStatus(success);
592         }
593         break;
594
595         case IDA_OPEN_CONTACTS:
596                 //Open Contacts APP
597                 break;
598
599         case IDA_MUTE:
600         {
601                 bool success = __pCallPresentor->SetMuteStatus(true);
602                 if (success)
603                 {
604                         __pCallButtonsPanel->SetMuteButtonState(IDA_UNMUTE);
605                 }
606         }
607         break;
608
609         case IDA_UNMUTE:
610         {
611                 bool success = __pCallPresentor->SetMuteStatus(false);
612                 if (success)
613                 {
614                         __pCallButtonsPanel->SetMuteButtonState(IDA_MUTE);
615                 }
616         }
617         break;
618
619         case IDA_SPEAKER:
620         {
621                 bool success = __pCallPresentor->SetSpeakerStatus(true);
622                 if (success)
623                 {
624                         __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER_OFF);
625                 }
626         }
627         break;
628
629         case IDA_SPEAKER_OFF:
630         {
631                 bool success = __pCallPresentor->SetSpeakerStatus(false);
632                 if (success)
633                 {
634                         __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER);
635                 }
636         }
637         break;
638
639         case IDA_JOIN_CALL:
640         {
641                 AppAssert(__formType == FORMTYPE_MULTIPLECALLS);
642                 __pCallPresentor->JoinCall();
643         }
644         break;
645
646         case IDA_SWAP_CALLS:
647         {
648                 AppAssert(__formType == FORMTYPE_MULTIPLECALLS);
649                 __pCallPresentor->SwapCalls();
650         }
651         break;
652
653         case IDA_MORE_OPTIONS_MENU:
654         {
655                 //Show 'more' options menu
656                 CreateMoreOptionsMenuList();
657         }
658         break;
659
660         case NUM_KEY0:
661         {
662                 dtmfString.Append(L"0");
663                 SetTextToDTMFTextField(dtmfString);
664                 __pCallPresentor->SendDTMFSignal(dtmfString);
665         }
666         break;
667
668         case NUM_KEY1:
669         {
670                 dtmfString.Append(L"1");
671                 SetTextToDTMFTextField(dtmfString);
672                 __pCallPresentor->SendDTMFSignal(dtmfString);
673         }
674         break;
675
676         case NUM_KEY2:
677         {
678                 dtmfString.Append(L"2");
679                 SetTextToDTMFTextField(dtmfString);
680                 __pCallPresentor->SendDTMFSignal(dtmfString);
681         }
682         break;
683
684         case NUM_KEY3:
685         {
686                 dtmfString.Append(L"3");
687                 SetTextToDTMFTextField(dtmfString);
688                 __pCallPresentor->SendDTMFSignal(dtmfString);
689         }
690         break;
691
692         case NUM_KEY4:
693         {
694                 dtmfString.Append(L"4");
695                 SetTextToDTMFTextField(dtmfString);
696                 __pCallPresentor->SendDTMFSignal(dtmfString);
697         }
698         break;
699
700         case NUM_KEY5:
701         {
702                 dtmfString.Append(L"5");
703                 SetTextToDTMFTextField(dtmfString);
704                 __pCallPresentor->SendDTMFSignal(dtmfString);
705         }
706         break;
707
708         case NUM_KEY6:
709         {
710                 dtmfString.Append(L"6");
711                 SetTextToDTMFTextField(dtmfString);
712                 __pCallPresentor->SendDTMFSignal(dtmfString);
713         }
714         break;
715
716         case NUM_KEY7:
717         {
718                 dtmfString.Append(L"7");
719                 SetTextToDTMFTextField(dtmfString);
720                 __pCallPresentor->SendDTMFSignal(dtmfString);
721         }
722         break;
723
724         case NUM_KEY8:
725         {
726                 dtmfString.Append(L"8");
727                 SetTextToDTMFTextField(dtmfString);
728                 __pCallPresentor->SendDTMFSignal(dtmfString);
729         }
730         break;
731
732         case NUM_KEY9:
733         {
734                 dtmfString.Append(L"9");
735                 SetTextToDTMFTextField(dtmfString);
736                 __pCallPresentor->SendDTMFSignal(dtmfString);
737         }
738         break;
739
740         case PAUSE_KEY:
741         {
742                 dtmfString.Append(L"*");
743                 SetTextToDTMFTextField(dtmfString);
744                 __pCallPresentor->SendDTMFSignal(dtmfString);
745         }
746         break;
747
748         case HASH_KEY:
749         {
750                 dtmfString.Append(L"#");
751                 SetTextToDTMFTextField(dtmfString);
752                 __pCallPresentor->SendDTMFSignal(dtmfString);
753         }
754         break;
755
756         default:
757                 break;
758         }
759 }
760
761 void
762 ActiveCallForm::SetTextToDTMFTextField(const String& dtmfStr)
763 {
764         if(__pDTMFKeypad != null)
765         {
766                 TextBox* pTextBox = static_cast<TextBox*>(__pDTMFKeypad->GetControl(IDC_TEXTBOX));
767                 pTextBox->AppendText(dtmfStr);
768                 pTextBox->Invalidate(true);
769         }
770 }
771
772 void
773 ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
774 {
775         //set itself as listener
776         __pCallPresentor->SetTelEventListener(this);
777         if (__pActiveCallInfo != null)
778         {
779                 delete __pActiveCallInfo;
780                 __pActiveCallInfo = null;
781         }
782         if (__pHeldCallInfo != null)
783         {
784                 delete __pHeldCallInfo;
785                 __pHeldCallInfo = null;
786         }
787         DestroyMoreOptionsMenuList();
788
789         switch (__formType)
790         {
791         case FORMTYPE_OUTGOINGCALL:
792         {
793                 String contactNo;
794                 contactNo.Append(*(static_cast<String*>(pArgs->GetAt(0))));
795                 __pActiveCallInfo = new (std::nothrow) CallInfo();
796                 __pActiveCallInfo->SetContactNumber(contactNo);
797                 Contact* pContact = __pCallPresentor->GetContactN(contactNo);
798                 if (pContact != null)
799                 {
800                         __pActiveCallInfo->SetContactInfo(*pContact);
801                         delete pContact;
802                 }
803                 ShowPersonDetails(contactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
804                 //make an normal outgoing call
805                 __pCallPresentor->DialCall(contactNo, false);
806         }
807         break;
808
809         case FORMTYPE_EMERGENCYOUTGOINGCALL:
810         {
811                 String* pContactNo = static_cast<String*>(pArgs->GetAt(0));
812                 __pActiveCallInfo = new (std::nothrow) CallInfo();
813                 long long phNumber = 0;
814                 LongLong::Parse(*pContactNo, phNumber);
815                 __pActiveCallInfo->SetContactNumber(*pContactNo);
816                 //make an emergency call
817                 __pCallPresentor->DialCall(*pContactNo, true);
818         }
819         break;
820
821         case FORMTYPE_ACTIVECALL:
822         {
823                 //get contact number
824                 CallInfo* pCall = static_cast<CallInfo*>(pArgs->GetAt(0));
825
826                 __pActiveCallInfo = new (std::nothrow) CallInfo();
827                 *__pActiveCallInfo =  *pCall;
828                 String activeContactNo;
829                 activeContactNo.Append(pCall->GetContactNumber());
830                 ShowPersonDetails(activeContactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
831
832                 //show call active time using Timer
833                 __activeCallStartTime = pCall->GetCallConnectTime();
834                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, pCall->IsOnHold(), __activeCallStartTime);
835         }
836         break;
837
838         case FORMTYPE_EMERGENCYACTIVECALL:
839         {
840                 //get contact number
841                 CallInfo* pCall = static_cast<CallInfo*>(pArgs->GetAt(0));
842
843                 __pActiveCallInfo = new (std::nothrow) CallInfo();
844                 *__pActiveCallInfo =  *pCall;
845
846                 //show call active time using Timer
847                 __activeCallStartTime = pCall->GetCallConnectTime();
848                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, pCall->IsOnHold(), __activeCallStartTime);
849         }
850         break;
851
852         case FORMTYPE_MULTIPLECALLS:
853         {
854                 Button* pMoreBtn = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
855                 if (pMoreBtn != null)
856                 {
857                         pMoreBtn->SetShowState(false);
858                 }
859                 Label* pLblControl = static_cast<Label*>(GetControl(IDC_DIVIDER_LABEL));
860                 if (pLblControl)
861                 {
862                         pLblControl->SetShowState(false);
863                 }
864                 //show caller's info.
865                 for (int index = 0; index < pArgs->GetCount();index++)
866                 {
867                         //Fetch call info
868                         CallInfo* pCallInfo = static_cast<CallInfo*>(pArgs->GetAt(index));
869
870                         String contactNo;
871                         contactNo.Append(pCallInfo->GetContactNumber());
872
873                         if (pCallInfo->IsOnHold() == false)
874                         {
875                                 __pActiveCallInfo = new (std::nothrow) CallInfo();
876                                 *__pActiveCallInfo =  *pCallInfo;
877
878                                 if (pCallInfo->IsConferenceCall() == false)
879                                 {
880                                         Label* pVoiceIconLbl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
881                                         if (pVoiceIconLbl)
882                                         {
883                                                 pVoiceIconLbl->SetShowState(true);
884                                         }
885                                         if (pMoreBtn != null)
886                                         {
887                                                 pMoreBtn->SetShowState(false);
888                                         }
889                                         Label* pLblControl = static_cast<Label*>(GetControl(IDC_DIVIDER_LABEL));
890                                         if (pLblControl)
891                                         {
892                                                 pLblControl->SetShowState(false);
893                                         }
894                                         ShowPersonDetails(contactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
895                                 }
896                                 else
897                                 {
898                                         // show display name on name Label
899                                         Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
900                                         if (pPeopleCountLbl)
901                                         {
902                                                 String count;
903                                                 count.Append(pCallInfo->GetCallerListCount());
904                                                 count.Append(" ");
905                                                 count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
906                                                 pPeopleCountLbl->SetText(count);
907                                         }
908                                         String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING");
909                                         Label* pNameLbl = static_cast<Label*>(GetControl(IDC_CALLER1_LABEL));
910                                         if (pNameLbl)
911                                         {
912                                                 pNameLbl->SetText(nameStr);
913                                         }
914                                         Label* pVoiceIconLbl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
915                                         if (pVoiceIconLbl)
916                                         {
917                                                 pVoiceIconLbl->SetShowState(false);
918                                         }
919                                         if (pMoreBtn != null)
920                                         {
921                                                 pMoreBtn->SetShowState(true);
922                                         }
923                                         if (pLblControl)
924                                         {
925                                                 pLblControl->SetShowState(true);
926                                         }
927                                         Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
928                                         if (pPhotoBitmap != null)
929                                         {
930                                                 Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_CALLER1_PHOTO_LABEL));
931                                                 if (pPhotoLbl)
932                                                 {
933                                                         pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap);
934                                                         pPhotoLbl->Invalidate(true);
935                                                 }
936                                                 delete pPhotoBitmap;
937                                         }
938                                 }
939                                 //show call active time using Timer
940                                 __activeCallStartTime = pCallInfo->GetCallConnectTime();
941                                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL,false,__activeCallStartTime);
942                         }
943                         else
944                         {
945                                 __pHeldCallInfo = new (std::nothrow) CallInfo();
946                                 *__pHeldCallInfo =  *pCallInfo;
947
948                                 if (pCallInfo->IsConferenceCall() == false)
949                                 {
950                                         ShowPersonDetails(contactNo, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pHeldCallInfo);
951                                 }
952                                 else
953                                 {
954                                         // show display name on name Label
955                                         Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER2_LABEL));
956                                         if (pPeopleCountLbl)
957                                         {
958                                                 String count;
959                                                 count.Append(pCallInfo->GetCallerListCount());
960                                                 count.Append(" ");
961                                                 count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
962                                                 pPeopleCountLbl->SetText(count);
963                                         }
964                                         String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING");
965                                         Label* pNameLbl = static_cast<Label*>(GetControl(IDC_CALLER2_LABEL));
966                                         if (pNameLbl)
967                                         {
968                                                 pNameLbl->SetText(nameStr);
969                                         }
970                                         Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
971                                         if (pPhotoBitmap != null)
972                                         {
973                                                 Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_CALLER2_PHOTO_LABEL));
974                                                 if (pPhotoLbl)
975                                                 {
976                                                         pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap);
977                                                         pPhotoLbl->Invalidate(true);
978                                                 }
979                                                 delete pPhotoBitmap;
980                                         }
981                                 }
982                                 //show "On Hold"
983                                 ShowTimerInfo(IDC_CALLER2_TIME_LABEL, true);
984                         }
985                 }
986         }
987         break;
988
989         case FORMTYPE_ACTIVECONFCALL:
990         {
991                 //get contact number
992                 CallInfo* pConfInfo = static_cast<CallInfo*>(pArgs->GetAt(0));
993                 int participantsCount = pConfInfo->GetCallerListCount();
994
995                 // show display name on name Label
996                 Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_PARTICIPANTS_LABEL));
997                 if (pPeopleCountLbl)
998                 {
999                         String count;
1000                         count.Append(participantsCount);
1001                         count.Append(" ");
1002                         count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1003                         pPeopleCountLbl->SetText(count);
1004                 }
1005
1006                 if(participantsCount >= IDI_MAX_CONF_CALL_PARTICIPANTS)
1007                 {
1008                         __pCallButtonsPanel->EnableAddCallButton(false);
1009                 }
1010                 else
1011                 {
1012                         __pCallButtonsPanel->EnableAddCallButton(true);
1013                 }
1014
1015                 //show call active time using Timer
1016                 __activeCallStartTime = pConfInfo->GetCallConnectTime();
1017                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL, pConfInfo->IsOnHold(),__activeCallStartTime);
1018         }
1019         break;
1020
1021         default:
1022                 break;
1023         }
1024
1025         //Hide DTMFKeypad, if visible and show caller info
1026         HideDTMFKeypad();
1027         SetShowStateOnKeypad(true);
1028         __pCallButtonsPanel->SetKeypadButtonState(IDA_OPEN_NUMKEYPAD);
1029
1030         //Set the correct speaker status
1031         if(__pCallPresentor->IsSpeakerOn() == true)
1032         {
1033                 __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER_OFF);
1034         }
1035         else
1036         {
1037                 __pCallButtonsPanel->SetSpeakerButtonState(IDA_SPEAKER);
1038         }
1039
1040         //Set the correct Mute status
1041         if (__pCallPresentor->IsCallMuted() == true)
1042         {
1043                 __pCallButtonsPanel->SetMuteButtonState(IDA_UNMUTE);
1044         }
1045         else
1046         {
1047                 __pCallButtonsPanel->SetMuteButtonState(IDA_MUTE);
1048         }
1049
1050         if (pArgs)
1051         {
1052                 pArgs->RemoveAll();
1053                 delete pArgs;
1054                 pArgs = null;
1055         }
1056 }
1057
1058 void
1059 ActiveCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1060 {
1061         // Add your scene deactivate code here
1062         if (__pActiveCallTimer != null)
1063         {
1064                 __pActiveCallTimer->Cancel();
1065                 delete __pActiveCallTimer;
1066                 __pActiveCallTimer = null;
1067         }
1068         if (__pSmallPhotoLabel != null)
1069         {
1070                 __pSmallPhotoLabel->SetShowState(false);
1071         }
1072         //Hide "Manage conf. Call" Context menu
1073         if (__pMoreOptionsListAnchor != null)
1074         {
1075                 __pMoreOptionsListAnchor->SetShowState(false);
1076         }
1077         if (__pMoreOptionsList != null)
1078         {
1079                 __pMoreOptionsList->SetShowState(false);
1080         }
1081 }
1082
1083 void
1084 ActiveCallForm::HandleCallSwapN(IList* pCallList)
1085 {
1086         if (pCallList != null)
1087         {
1088                 if (__pActiveCallInfo)
1089                 {
1090                         delete __pActiveCallInfo;
1091                         __pActiveCallInfo = null;
1092                 }
1093                 if (__pHeldCallInfo)
1094                 {
1095                         delete __pHeldCallInfo;
1096                         __pHeldCallInfo = null;
1097                 }
1098                 //show caller's info.
1099                 for (int index = 0; index < pCallList->GetCount();index++)
1100                 {
1101                         //Fetch call info
1102                         CallInfo* pCallInfo = static_cast<CallInfo*>(pCallList->GetAt(index));
1103
1104                         String contactNo;
1105                         contactNo.Append(pCallInfo->GetContactNumber());
1106
1107                         if (pCallInfo->IsOnHold() == false)
1108                         {
1109                                 __pActiveCallInfo = new (std::nothrow) CallInfo();
1110                                 *__pActiveCallInfo =  *pCallInfo;
1111
1112                                 if (pCallInfo->IsConferenceCall() == false)
1113                                 {
1114                                         Label* pVoiceIconLbl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1115                                         if (pVoiceIconLbl)
1116                                         {
1117                                                 pVoiceIconLbl->SetShowState(true);
1118                                         }
1119                                         Button* pMoreBtn = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1120                                         if (pMoreBtn != null)
1121                                         {
1122                                                 pMoreBtn->SetShowState(false);
1123                                         }
1124                                         Label* pLblControl = static_cast<Label*>(GetControl(IDC_DIVIDER_LABEL));
1125                                         if (pLblControl)
1126                                         {
1127                                                 pLblControl->SetShowState(false);
1128                                         }
1129                                         ShowPersonDetails(contactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
1130                                 }
1131                                 else
1132                                 {
1133                                         Label* pVoiceIconLbl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1134                                         if (pVoiceIconLbl)
1135                                         {
1136                                                 pVoiceIconLbl->SetShowState(false);
1137                                         }
1138                                         Button* pMoreBtn = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1139                                         if (pMoreBtn != null)
1140                                         {
1141                                                 pMoreBtn->SetShowState(true);
1142                                         }
1143                                         Label* pLblControl = static_cast<Label*>(GetControl(IDC_DIVIDER_LABEL));
1144                                         if (pLblControl)
1145                                         {
1146                                                 pLblControl->SetShowState(true);
1147                                         }
1148                                         // show display name on name Label
1149                                         Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1150                                         if (pPeopleCountLbl)
1151                                         {
1152                                                 String count;
1153                                                 count.Append(pCallInfo->GetCallerListCount());
1154                                                 count.Append(" ");
1155                                                 count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1156                                                 pPeopleCountLbl->SetText(count);
1157                                         }
1158                                         String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING");
1159                                         Label* pNameLbl = static_cast<Label*>(GetControl(IDC_CALLER1_LABEL));
1160                                         if (pNameLbl)
1161                                         {
1162                                                 pNameLbl->SetText(nameStr);
1163                                         }
1164                                         Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
1165                                         if (pPhotoBitmap != null)
1166                                         {
1167                                                 Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_CALLER1_PHOTO_LABEL));
1168                                                 if (pPhotoLbl)
1169                                                 {
1170                                                         pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap);
1171                                                 }
1172                                                 delete pPhotoBitmap;
1173                                         }
1174                                 }
1175                                 //show call active time using Timer
1176                                 __activeCallStartTime = pCallInfo->GetCallConnectTime();
1177                                 ShowTimerInfo(IDC_CALLER1_TIME_LABEL,false,__activeCallStartTime);
1178                         }
1179                         else
1180                         {
1181                                 __pHeldCallInfo = new (std::nothrow) CallInfo();
1182                                 *__pHeldCallInfo =  *pCallInfo;
1183
1184                                 if (pCallInfo->IsConferenceCall() == false)
1185                                 {
1186                                         ShowPersonDetails(contactNo, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pHeldCallInfo);
1187                                 }
1188                                 else
1189                                 {
1190                                         // show display name on name Label
1191                                         Label* pPeopleCountLbl = static_cast<Label*>(GetControl(IDC_NUMBER2_LABEL));
1192                                         if (pPeopleCountLbl)
1193                                         {
1194                                                 String count;
1195                                                 count.Append(pCallInfo->GetCallerListCount());
1196                                                 count.Append(" ");
1197                                                 count.Append(AppUtility::GetResourceString(IDS_PEOPLE_STR));
1198                                                 pPeopleCountLbl->SetText(count);
1199                                         }
1200                                         String nameStr = AppUtility::GetResourceString(L"IDS_CONFERENCE_CALL_STRING");
1201                                         Label* pNameLbl = static_cast<Label*>(GetControl(IDC_CALLER2_LABEL));
1202                                         if (pNameLbl)
1203                                         {
1204                                                 pNameLbl->SetText(nameStr);
1205                                         }
1206                                         Bitmap* pPhotoBitmap = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BG_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
1207                                         if (pPhotoBitmap != null)
1208                                         {
1209                                                 Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_CALLER2_PHOTO_LABEL));
1210                                                 if (pPhotoLbl)
1211                                                 {
1212                                                         pPhotoLbl->SetBackgroundBitmap(*pPhotoBitmap);
1213                                                 }
1214                                                 delete pPhotoBitmap;
1215                                         }
1216                                 }
1217                                 //show "On Hold"
1218                                 ShowTimerInfo(IDC_CALLER2_TIME_LABEL, true);
1219                         }
1220                 }
1221                 Invalidate(true);
1222         }
1223 }
1224
1225 void
1226 ActiveCallForm::ShowPersonDetails(const String& phoneNumber, const String& contactLblName, const String& nameLblName, bool isSecondCaller, CallInfo* pCallInfo)
1227 {
1228         //call individual methods to show contact number, caller name & photo
1229         ShowPhoneNumber(phoneNumber, contactLblName);
1230
1231         //fetch contact details based on phone number
1232         String* pDisplayName = pCallInfo->FetchCallerNameN();
1233         ShowCallerName(*pDisplayName, nameLblName);
1234
1235         Bitmap* pPhotoBitmap = pCallInfo->FetchCallerPhotoN();
1236         ShowCallerPhoto(pPhotoBitmap, isSecondCaller);
1237
1238         //free resources
1239         if (pDisplayName)
1240         {
1241                 delete pDisplayName;
1242                 pDisplayName = null;
1243         }
1244         if (pPhotoBitmap)
1245         {
1246                 delete pPhotoBitmap;
1247                 pPhotoBitmap = null;
1248         }
1249 }
1250
1251 void
1252 ActiveCallForm::ShowPhoneNumber(const String& phoneNumber, const String& contactLblName)
1253 {
1254         String formattedNumber = phoneNumber;
1255
1256         Label* pContactLbl = static_cast<Label*>(GetControl(contactLblName));
1257         if (pContactLbl)
1258         {
1259                 pContactLbl->SetText(formattedNumber);
1260                 pContactLbl->Invalidate(true);
1261         }
1262 }
1263
1264 void
1265 ActiveCallForm::ShowCallerName(const String& callerName, const String& nameLblName)
1266 {
1267         // show display name on name Label
1268         Label* pNameLbl = static_cast<Label*>(GetControl(nameLblName));
1269         if (pNameLbl)
1270         {
1271                 //passing an empty string to SetText fails in label,
1272                 //if previously valid text has been set
1273                 if (callerName.IsEmpty() == true && pNameLbl->GetText().IsEmpty() == false)
1274                 {
1275                         String stringToBeSet(L" ");
1276                         pNameLbl->SetText(stringToBeSet);
1277                 }
1278                 else
1279                 {
1280                         pNameLbl->SetText(callerName);
1281                 }
1282                 pNameLbl->Invalidate(true);
1283         }
1284 }
1285
1286 void
1287 ActiveCallForm::ShowCallerPhoto(Bitmap* pPhotoId, bool isSecondCaller)
1288 {
1289         //to check if default image is to be shown
1290         bool showDefaultPhoto = false;
1291         String photoLabel("");
1292
1293         switch (__formType)
1294         {
1295         case FORMTYPE_OUTGOINGCALL:
1296         case FORMTYPE_ACTIVECALL:
1297         {
1298                 if (pPhotoId == null)
1299                 {
1300                         //show default caller image
1301                         showDefaultPhoto = true;
1302                 }
1303                 photoLabel.Append(IDC_CALLER1_BIGPHOTO_LABEL);
1304         }
1305         break;
1306
1307         case FORMTYPE_MULTIPLECALLS:
1308         {
1309                 if (isSecondCaller)
1310                 {
1311                         photoLabel.Append(IDC_CALLER2_PHOTO_LABEL);
1312                 }
1313                 else
1314                 {
1315                         photoLabel.Append(IDC_CALLER1_PHOTO_LABEL);
1316                 }
1317
1318                 if (pPhotoId == null)
1319                 {
1320                         showDefaultPhoto = true;
1321                 }
1322                 else
1323                 {
1324                         if (pPhotoId->GetHeight() <= H_SMALL_PHOTO
1325                                 || pPhotoId->GetWidth() <= W_SMALL_PHOTO)
1326                         {
1327                                 pPhotoId->Scale(Dimension(W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO));
1328                         }
1329                 }
1330         }
1331         break;
1332
1333         default:
1334                 break;
1335         }
1336
1337         //Remove small photo label
1338         if (__pSmallPhotoLabel != null)
1339         {
1340                 RemoveControl(*__pSmallPhotoLabel);
1341                 __pSmallPhotoLabel = null;
1342         }
1343
1344         //show photo - for Big Photo Id, Animated Call Image
1345         if (!showDefaultPhoto)
1346         {
1347                 Label* pPhotoLbl = static_cast<Label*>(GetControl(photoLabel));
1348                 if (pPhotoLbl)
1349                 {
1350                         Canvas* pCanvas = new (std::nothrow) Canvas;
1351                         Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1352                         pCanvas->Construct(canvasRect);
1353                         //draw the contact bitmap
1354                         pCanvas->DrawBitmap(canvasRect,*pPhotoId);
1355                         Bitmap* pNewPhotoId = new Bitmap();
1356                         pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1357                         delete pCanvas;
1358
1359                         pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1360                         pPhotoLbl->Invalidate(true);
1361                         delete pNewPhotoId;
1362                 }
1363         }
1364         else
1365         {
1366                 Bitmap* pDefaultPhoto = null;
1367                 switch (__formType)
1368                 {
1369                 case FORMTYPE_OUTGOINGCALL:
1370                 case FORMTYPE_ACTIVECALL:
1371                         pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_ACTIVE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO);
1372                         break;
1373
1374                 case FORMTYPE_MULTIPLECALLS:
1375                         pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_MULTIPLE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,H_CONFERENCE_PHOTO);
1376                         break;
1377
1378                 case FORMTYPE_ACTIVECONFCALL:
1379                         pDefaultPhoto = AppUtility::GetBitmapFromResourcesN(IDB_CONFERENCE_BIG_BG_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO);
1380                         break;
1381
1382                 default:
1383                         break;
1384                 }
1385                 if (pDefaultPhoto != null)
1386                 {
1387                         Label* pPhotoLbl = static_cast<Label*>(GetControl(photoLabel));
1388                         if (pPhotoLbl)
1389                         {
1390                                 pPhotoLbl->SetBackgroundBitmap(*pDefaultPhoto);
1391                         }
1392                         delete pDefaultPhoto;
1393                 }
1394         }
1395 }
1396
1397 void
1398 ActiveCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
1399 {
1400         if (__pSmallPhotoLabel != null)
1401         {
1402                 RemoveControl(*__pSmallPhotoLabel);
1403                 __pSmallPhotoLabel = null;
1404         }
1405         //Draw Small Photo and show on small photo label
1406         __pSmallPhotoLabel  = new (std::nothrow) Label();//static_cast<Label*>(GetControl(IDC_SMALL_PHOTO_LABEL));
1407         __pSmallPhotoLabel->Construct(Rectangle(X_PHOTO_LBL, Y_PHOTO_LBL, W_PHOTO_LBL, H_PHOTO_LBL), L"");
1408         __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0));
1409         __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId);
1410         // Add a Label to the Form
1411         AddControl(*__pSmallPhotoLabel);
1412         __pSmallPhotoLabel->Invalidate(true);
1413 }
1414
1415 void
1416 ActiveCallForm::ShowTimerInfo(const String& timerLblName, bool isOnHold, long long startTime)
1417 {
1418         Label* pTimerLbl = static_cast<Label*>(GetControl(timerLblName));
1419
1420         if (__pActiveCallTimer == null)
1421         {
1422                 __pActiveCallTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
1423                 __pActiveCallTimer->Construct(*this);
1424         }
1425
1426         if (pTimerLbl != null)
1427         {
1428                 if (isOnHold == true)
1429                 {
1430                         pTimerLbl->SetText(L"On hold");
1431                         //update Hold button status
1432                         SetHoldButtonStatus(false);
1433                 }
1434                 else
1435                 {
1436                         //update Hold button status
1437                         SetHoldButtonStatus(true);
1438                         //current system time
1439                         long long currTime = 0;
1440                         SystemTime::GetTicks(currTime);
1441                         //Set call duration
1442                         TimeSpan diffSpan(abs(startTime - currTime));
1443
1444                         String activeCallTime(L"");
1445
1446                         long long hr = diffSpan.GetHours();
1447                         if (hr <= 9)
1448                         {
1449                                 activeCallTime.Append("0");
1450                         }
1451                         activeCallTime.Append(hr);
1452                         activeCallTime.Append(L":");
1453
1454                         long long min = diffSpan.GetMinutes();
1455                         if (min <= 9)
1456                         {
1457                                 activeCallTime.Append("0");
1458                         }
1459                         activeCallTime.Append(min);
1460                         activeCallTime.Append(L":");
1461
1462                         long long sec = diffSpan.GetSeconds();
1463                         if (sec <= 9)
1464                         {
1465                                 activeCallTime.Append("0");
1466                         }
1467                         activeCallTime.Append(sec);
1468
1469                         pTimerLbl->SetText(activeCallTime);
1470                         __pActiveCallTimer->StartAsRepeatable(TimeSpan::NUM_OF_TICKS_IN_SECOND);
1471                 }
1472                 pTimerLbl->Invalidate(true);
1473         }
1474 }
1475
1476 void
1477 ActiveCallForm::SetShowStateOnKeypad(bool showState)
1478 {
1479         Label* pLblControl = static_cast<Label*>(GetControl(IDC_LINE_LABEL));
1480         pLblControl->SetShowState(showState);
1481         pLblControl = static_cast<Label*>(GetControl(IDC_CALLER1_LABEL));
1482         pLblControl->SetShowState(showState);
1483         pLblControl = static_cast<Label*>(GetControl(IDC_BACKGROUND_LABEL));
1484         pLblControl->SetShowState(showState);
1485         pLblControl = static_cast<Label*>(GetControl(IDC_CALLER1_TIME_LABEL));
1486         pLblControl->SetShowState(showState);
1487         if (__pSmallPhotoLabel != null)
1488         {
1489                 __pSmallPhotoLabel->SetShowState(showState);
1490         }
1491
1492         switch (__formType)
1493         {
1494         case FORMTYPE_ACTIVECALL:
1495         {
1496                 pLblControl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1497                 pLblControl->SetShowState(showState);
1498                 pLblControl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1499                 pLblControl->SetShowState(showState);
1500                 pLblControl = static_cast<Label*>(GetControl(IDC_HOLD_LABEL));
1501                 pLblControl->SetShowState(showState);
1502                 Button* pButtonControl = static_cast<Button*>(GetControl(IDC_HOLD_BUTTON));
1503                 pButtonControl->SetShowState(showState);
1504         }
1505         break;
1506
1507         case FORMTYPE_MULTIPLECALLS:
1508         {
1509                 pLblControl = static_cast<Label*>(GetControl(IDC_NUMBER1_LABEL));
1510                 pLblControl->SetShowState(showState);
1511                 pLblControl = static_cast<Label*>(GetControl(IDC_CALLER2_LABEL));
1512                 pLblControl->SetShowState(showState);
1513                 pLblControl = static_cast<Label*>(GetControl(IDC_NUMBER2_LABEL));
1514                 pLblControl->SetShowState(showState);
1515                 pLblControl = static_cast<Label*>(GetControl(IDC_CALLER2_TIME_LABEL));
1516                 pLblControl->SetShowState(showState);
1517                 pLblControl = static_cast<Label*>(GetControl(IDC_SWAP_LABEL));
1518                 pLblControl->SetShowState(showState);
1519                 pLblControl = static_cast<Label*>(GetControl(IDC_BACKGROUND_LABEL2));
1520                 pLblControl->SetShowState(showState);
1521                 if (__pActiveCallInfo != null && __pActiveCallInfo->IsConferenceCall() == false)
1522                 {
1523                         pLblControl = static_cast<Label*>(GetControl(IDC_VOICE_CALL_ICON_LABEL));
1524                         pLblControl->SetShowState(showState);
1525                 }
1526                 else
1527                 {
1528                         Button* pButtonControl = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1529                         pButtonControl->SetShowState(showState);
1530                         pLblControl = static_cast<Label*>(GetControl(IDC_DIVIDER_LABEL));
1531                         pLblControl->SetShowState(showState);
1532                 }
1533                 Button* pButtonControl = static_cast<Button*>(GetControl(IDC_SWAP_BUTTON));
1534                 pButtonControl->SetShowState(showState);
1535         }
1536         break;
1537
1538         case FORMTYPE_ACTIVECONFCALL:
1539         {
1540                 pLblControl = static_cast<Label*>(GetControl(IDC_PARTICIPANTS_LABEL));
1541                 pLblControl->SetShowState(showState);
1542                 pLblControl = static_cast<Label*>(GetControl(IDC_HOLD_LABEL));
1543                 pLblControl->SetShowState(showState);
1544                 pLblControl = static_cast<Label*>(GetControl(IDC_DIVIDER_LABEL));
1545                 pLblControl->SetShowState(showState);
1546                 Button* pButtonControl = static_cast<Button*>(GetControl(IDC_HOLD_BUTTON));
1547                 pButtonControl->SetShowState(showState);
1548                 pButtonControl = static_cast<Button*>(GetControl(IDC_CONF_CALL_MORE_BUTTON));
1549                 pButtonControl->SetShowState(showState);
1550         }
1551         break;
1552
1553         default:
1554                 break;
1555         }
1556 }
1557
1558 void
1559 ActiveCallForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
1560 {
1561         //Call default implementation of "Object.Equals()"
1562         //returns true, if they are pointing to same address.
1563         if (__pActiveCallTimer->Equals(timer))
1564         {
1565                 Label* pTimerLbl = static_cast<Label*>(GetControl(IDC_CALLER1_TIME_LABEL));
1566                 if (pTimerLbl)
1567                 {
1568                         String activeCallTime = pTimerLbl->GetText();
1569                         // Create a StringTokenizer instance
1570                         StringTokenizer strTokens(activeCallTime, L":");
1571
1572                         int count = strTokens.GetTokenCount(); // count == 3
1573                         String token;
1574                         int sec = 0;
1575                         int min = 0;
1576                         int hr = 0;
1577                         for (int index = 0; index < count; index++)
1578                         {
1579                                 switch (index)
1580                                 {
1581                                 case 0:
1582                                         strTokens.GetNextToken(token);
1583                                         Integer::Parse(token, hr);
1584                                         break;
1585
1586                                 case 1:
1587                                         strTokens.GetNextToken(token);
1588                                         Integer::Parse(token, min);
1589                                         break;
1590
1591                                 case 2:
1592                                         strTokens.GetNextToken(token);
1593                                         Integer::Parse(token, sec);
1594                                         break;
1595                                 }
1596                         }
1597                         //update all values
1598                         sec = sec + 1;
1599                         if (sec == IDI_MAX_SECONDS)
1600                         {
1601                                 sec = 0;
1602                                 min = min + 1;
1603                         }
1604                         if (min == IDI_MAX_MINS)
1605                         {
1606                                 min = 0;
1607                                 hr = hr + 1;
1608                         }
1609
1610                         //replace string
1611                         activeCallTime.Clear();
1612                         if (hr <= 9)
1613                         {
1614                                 activeCallTime.Append("0");
1615                         }
1616                         activeCallTime.Append(hr);
1617                         activeCallTime.Append(":");
1618                         if (min <= 9)
1619                         {
1620                                 activeCallTime.Append("0");
1621                         }
1622                         activeCallTime.Append(min);
1623                         activeCallTime.Append(":");
1624                         if (sec <= 9)
1625                         {
1626                                 activeCallTime.Append("0");
1627                         }
1628                         activeCallTime.Append(sec);
1629                         //update timer label
1630                         pTimerLbl->SetText(activeCallTime);
1631                         pTimerLbl->Invalidate(true);
1632                 }
1633         }
1634 }
1635
1636 ///////////////////////////////////////////////////////////
1637 ///////////     Options Menu List Functionality   /////////
1638 ///////////////////////////////////////////////////////////
1639 void
1640 ActiveCallForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)
1641 {
1642 }
1643
1644 void
1645 ActiveCallForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
1646 {
1647         //Goto conference call list form
1648         SceneManager* pSceneManager = SceneManager::GetInstance();
1649         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALLLIST), null);
1650 }
1651
1652 void
1653 ActiveCallForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
1654 {
1655 }
1656
1657 void
1658 ActiveCallForm::OnListViewItemLongPressed(ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
1659 {
1660 }
1661
1662 int
1663 ActiveCallForm::GetItemCount(void)
1664 {
1665         return IDI_MOREOPTIONS_LIST_ITEMS;
1666 }
1667
1668 ListItemBase*
1669 ActiveCallForm::CreateItem(int index, int itemWidth)
1670 {
1671         //create 1st Menu option
1672         CustomItem* pItem = new (std::nothrow) CustomItem();
1673         pItem->Construct(IDI_OPTIONMENU_DIMEN, LIST_ANNEX_STYLE_NORMAL);
1674
1675         //Set background 9-patch bitmap to option menu
1676         Bitmap* pBgBmp = AppUtility::GetBitmapFromResourcesN(IDB_POPUP_BG_ICON);
1677         if (pBgBmp != null && pBgBmp->IsNinePatchedBitmap())
1678         {
1679                 Canvas bgCanvas;
1680                 bgCanvas.Construct(Rectangle(IDI_OPTIONMENU_POS, IDI_OPTIONMENU_DIMEN));
1681                 bgCanvas.DrawNinePatchedBitmap(bgCanvas.GetBounds(), *pBgBmp);
1682         }
1683         else
1684         {
1685                 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color(40, 45, 48));
1686         }
1687         delete pBgBmp;
1688         pBgBmp = null;
1689
1690         //Set bitmap to option menu
1691         Bitmap* pNormalConfCallBmp = AppUtility::GetBitmapFromResourcesN(IDB_MORE_MANAGE_CONFERENCE_ICON ,
1692                                                                                                                                          W_MGR_CONFCALL_BITMAP, H_MGR_CONFCALL_BITMAP);
1693         pItem->AddElement(Rectangle(16, 17, W_MGR_CONFCALL_BITMAP, H_MGR_CONFCALL_BITMAP), 1, *pNormalConfCallBmp, null, null);
1694         // Deallocate bitmaps
1695         delete pNormalConfCallBmp;
1696         pNormalConfCallBmp = null;
1697
1698         //Set text to menu option
1699         String confCallName = AppUtility::GetResourceString(IDS_MGR_CONF_CALL_LIST_STR);
1700
1701         TextElement* pTextElement = new (std::nothrow) TextElement();
1702         pTextElement->Construct(confCallName);
1703         pTextElement->SetTextColor(COLOR_POPUP_TEXT);
1704         //create font
1705         Font font;
1706         font.Construct(FONT_STYLE_PLAIN, IDI_POPUP_TEXT_SIZE);
1707         pTextElement->SetFont(font);
1708         //construct Enriched text
1709         EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText();
1710         Dimension textDimension;
1711         font.GetTextExtent(confCallName, confCallName.GetLength(), textDimension);
1712         textDimension.height = textDimension.height + font.GetDescender();
1713         pEnrichedText->Construct(textDimension);
1714         //add text element to enriched text
1715         pEnrichedText->Add(*pTextElement);
1716
1717         //Add Enriched text to pItem
1718         Point textPos(((2 * IDI_OPTIONMENU_ITEM_SPACING) + W_MGR_CONFCALL_BITMAP), ((IDI_OPTIONMENU_DIMEN.height - textDimension.height) / 2));
1719         pItem->AddElement(Rectangle(textPos, textDimension), 2, *pEnrichedText);
1720         // Cleans up
1721         pEnrichedText->RemoveAll(true);
1722         delete pEnrichedText;
1723         return pItem;
1724 }
1725
1726 bool
1727 ActiveCallForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
1728 {
1729         delete pItem;
1730         return true;
1731 }