Removed Depricated APIs
[apps/osp/Call.git] / src / CallConfCallerListForm.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    CallConfCallerListForm.cpp
19  * @brief       Conference caller list form
20  */
21 #include <FSystem.h>
22 #include "CallConfCallerListForm.h"
23 #include "CallAppUtility.h"
24 #include "CallPresentationModel.h"
25 #include "CallSceneRegister.h"
26
27 using namespace Tizen::App;
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Base::Runtime;
31 using namespace Tizen::Base::Utility;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::System;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Controls;
36 using namespace Tizen::Ui::Scenes;
37
38 //Constants
39 const int W_HOLD_BITMAP = 78;
40 const int H_HOLD_BITMAP = 78;
41 const int W_BACK_BITMAP = 56;
42 const int H_BACK_BITMAP = 56;
43 const int X_BACK_BITMAP = 8;
44 const int Y_BACK_BITMAP = 8;
45 const int W_SPLIT_BITMAP = 74;
46 const int H_SPLIT_BITMAP = 74;
47 const int W_END_BITMAP = 80;
48 const int H_END_BITMAP = 74;
49 const int IDI_MAX_SECONDS = 60;
50 const int IDI_MAX_MINS = 60;
51 const int LIST_ITEM_HEIGHT = 112;
52 const int X_SPLIT_BUTTON_MARGIN = 26;
53 const int Y_SPLIT_BUTTON_MARGIN = 19;
54 const int X_END_BUTTON_PADDING = 26;
55 const int X_CALLER_LABEL = 116;
56 const int Y_CALLER_LABEL = 0;
57 const int W_CALLER_LABEL = 488;
58 const int H_CALLER_LABEL = 112;
59
60
61 static const wchar_t* IDL_CONFCALL_LIST_FORM = L"IDL_CONFCALL_LIST_FORM";
62 static const wchar_t* IDC_CALL_TIME_LABEL = L"IDC_CALL_TIME_LABEL";
63 static const wchar_t* IDB_SPLIT_NORMAL_BUTTON_ICON = L"C01-1_conference_split.png";
64 static const wchar_t* IDB_SPLIT_PRESS_BUTTON_ICON = L"C01-1_conference_split_press.png";
65 static const wchar_t* IDB_END_NORMAL_BUTTON_ICON = L"C01-1_conference_end.png";
66 static const wchar_t* IDB_END_PRESS_BUTTON_ICON = L"C01-1_conference_end_press.png";
67 static const wchar_t* IDC_END_CONFCALL_BUTTON = L"IDC_END_CONFCALL_BUTTON";
68 static const wchar_t* IDC_HOLD_CONFCALL_BUTTON = L"IDC_HOLD_CONFCALL_BUTTON";
69 static const wchar_t* IDC_CALLER1_PANEL = L"IDC_CALLER1_PANEL";
70 static const wchar_t* IDC__LINE_LABEL1 = L"IDC__LINE_LABEL1";
71 static const wchar_t* IDC_CALLER2_PANEL = L"IDC_CALLER2_PANEL";
72 static const wchar_t* IDC__LINE_LABEL2 = L"IDC__LINE_LABEL2";
73 static const wchar_t* IDC_CALLER3_PANEL = L"IDC_CALLER3_PANEL";
74 static const wchar_t* IDC__LINE_LABEL3 = L"IDC__LINE_LABEL3";
75 static const wchar_t* IDC_CALLER4_PANEL = L"IDC_CALLER4_PANEL";
76 static const wchar_t* IDC__LINE_LABEL4 = L"IDC__LINE_LABEL4";
77 static const wchar_t* IDC_CALLER5_PANEL = L"IDC_CALLER5_PANEL";
78 static const wchar_t* IDC__LINE_LABEL5 = L"IDC__LINE_LABEL5";
79 static const wchar_t* IDC_END_CALLER1 = L"IDC_END_CALLER1";
80 static const wchar_t* IDC_SPLIT_CALLER1 = L"IDC_SPLIT_CALLER1";
81 static const wchar_t* IDC_CALLER1_LABEL = L"IDC_CALLER1_LABEL";
82 static const wchar_t* IDC_END_CALLER2 = L"IDC_END_CALLER2";
83 static const wchar_t* IDC_SPLIT_CALLER2 = L"IDC_SPLIT_CALLER2";
84 static const wchar_t* IDC_CALLER2_LABEL = L"IDC_CALLER2_LABEL";
85 static const wchar_t* IDC_END_CALLER3 = L"IDC_END_CALLER3";
86 static const wchar_t* IDC_SPLIT_CALLER3 = L"IDC_SPLIT_CALLER3";
87 static const wchar_t* IDC_CALLER3_LABEL = L"IDC_CALLER3_LABEL";
88 static const wchar_t* IDC_END_CALLER4 = L"IDC_END_CALLER4";
89 static const wchar_t* IDC_SPLIT_CALLER4 = L"IDC_SPLIT_CALLER4";
90 static const wchar_t* IDC_CALLER4_LABEL = L"IDC_CALLER4_LABEL";
91 static const wchar_t* IDC_END_CALLER5 = L"IDC_END_CALLER5";
92 static const wchar_t* IDC_SPLIT_CALLER5 = L"IDC_SPLIT_CALLER5";
93 static const wchar_t* IDC_CALLER5_LABEL = L"IDC_CALLER5_LABEL";
94 static const wchar_t* IDC_CONF_CALL_LIST_TABLEVIEW = L"IDC_CONF_CALL_LIST_TABLEVIEW";
95
96 //color
97 const unsigned int COLOR_END_CALL_BG = Color32<180, 60, 60>::Value;
98 const unsigned int COLOR_END_CALL_BG_PRESS = Color32<61, 153, 208>::Value;
99 const unsigned int COLOR_SPLIT_CALL_BG = Color32<129, 140, 148>::Value;
100 const unsigned int COLOR_SPLIT_CALL_BG_PRESS = Color32<63, 155, 210>::Value;
101 ConfCallerListForm::ConfCallerListForm(void)
102 : BaseForm(FORMTYPE_CONFCALLLIST)
103 {
104         __pConfCallInfo = null;
105         __pConfCallTimer = null;
106         __isCallSplit = false;
107 }
108
109 ConfCallerListForm::~ConfCallerListForm(void)
110 {
111         if (__pConfCallTimer != null)
112         {
113                 __pConfCallTimer->Cancel();
114                 delete __pConfCallTimer;
115         }
116 }
117
118 void
119 ConfCallerListForm::Initialize(void)
120 {
121         Construct(IDL_CONFCALL_LIST_FORM);
122 }
123
124 result
125 ConfCallerListForm::OnInitializing(void)
126 {
127         result r = E_SUCCESS;
128         //Add action listener to buttons
129         AddActionListener(IDC_END_CONFCALL_BUTTON, IDA_END_CONF_CALL);
130         AddActionListener(IDC_HOLD_CONFCALL_BUTTON, IDA_HOLD_CONF_CALL);
131
132         Footer* pFooter = GetFooter();
133         if(pFooter != null)
134         {
135                 SetFormBackEventListener(this);
136         }
137         Label* pTimerLbl = static_cast<Label*>(GetControl(IDC_CALL_TIME_LABEL));
138         SetControlAlwaysOnTop(*pTimerLbl,true);
139
140         CreateTableView();
141         __pCallPresentor = CallPresentationModel::GetInstance();
142         return r;
143 }
144
145 void
146 ConfCallerListForm::CreateTableView(void)
147 {
148         __pList = static_cast <TableView*> (GetControl(IDC_CONF_CALL_LIST_TABLEVIEW));
149         __pList->SetItemProvider(this);
150         AddControl(__pList);
151 }
152
153 void
154 ConfCallerListForm::AddActionListener(const String& keyName, CommandIds cmdId)
155 {
156         Button* pButtonKeypad = static_cast<Button*>(GetControl(keyName));
157         if (pButtonKeypad != null)
158         {
159                 pButtonKeypad->SetActionId(cmdId);
160                 pButtonKeypad->AddActionEventListener(*this);
161         }
162 }
163
164 result
165 ConfCallerListForm::OnTerminating(void)
166 {
167         result r = E_SUCCESS;
168
169         if (__pCallPresentor != null)
170         {
171                 __pCallPresentor = null;
172         }
173
174         if (__pConfCallInfo != null)
175         {
176                 delete __pConfCallInfo;
177                 __pConfCallInfo = null;
178         }
179
180         //RemoveAllControls();
181         return r;
182 }
183
184 void
185 ConfCallerListForm::OnActionPerformed(const Control& source, int actionId)
186 {
187         SceneManager* pSceneManager = SceneManager::GetInstance();
188         AppAssert(pSceneManager);
189
190         switch (actionId)
191         {
192         case IDA_END_CONF_CALL:
193         {
194                 bool success = __pCallPresentor->EndConferenceCall();
195                 if (success == true)
196                 {
197                         delete __pConfCallInfo;
198                         __pConfCallInfo = null;
199                 }
200         }
201         break;
202
203         case IDA_HOLD_CONF_CALL:
204         {
205                 // User has pressed end conference call and we are waiting for TAPI response
206                 if(__pConfCallInfo == null)
207                 {
208                         return;
209                 }
210                 bool success = true;
211                 bool isCallOnHold = __pConfCallInfo->IsOnHold();
212                 if (isCallOnHold == false)
213                 {
214                         success = __pCallPresentor->HoldConferenceCall();
215                 }
216                 else
217                 {
218                         success = __pCallPresentor->ActivateConferenceCall();
219                 }
220
221                 //Check if request to Hold / UnHold call is successful.
222                 if(success == true)
223                 {
224                         //If success, then invert the Hold status in conference call
225                         isCallOnHold = !(isCallOnHold);
226                         __pConfCallInfo->SetOnHold(isCallOnHold);
227                         //update tableview
228                         __pList->UpdateTableView();
229                         SetHoldButtonStatus(isCallOnHold);
230                 }
231         }
232         break;
233
234         case IDA_BACK_EVENT:
235         {
236                 ArrayListT<AppCallInfo>* pCallList  = static_cast<ArrayListT<AppCallInfo>*>(__pCallPresentor->GetCallListN());
237                 int noOfCalls = pCallList->GetCount();
238
239                 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
240                 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
241                 pCallInfoList->Construct(noOfCalls);
242
243                 for (int index = 0; index < noOfCalls; index++)
244                 {
245                         //fetch call info and add to list
246                         AppCallInfo callInfo;
247                         result r = pCallList->GetAt(index, callInfo);
248                         if (r == E_SUCCESS)
249                         {
250                                 //copy call information to new instance
251                                 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
252                                 *pCaller = callInfo;
253                                 pCallInfoList->Add(pCaller);
254                         }
255                 }
256
257                 if (noOfCalls == 1)
258                 {
259                         //single active call - goto active call form
260                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL,
261                                         SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
262                 }
263                 else
264                 {
265                         //goto multiple active call form
266                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL,
267                                         SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
268                 }
269                 pCallList->RemoveAll();
270                 delete pCallList;
271         }
272         break;
273
274         case IDA_SPLIT_CALLER1:
275         case IDA_SPLIT_CALLER2:
276         case IDA_SPLIT_CALLER3:
277         case IDA_SPLIT_CALLER4:
278         case IDA_SPLIT_CALLER5:
279         {
280                 // User has pressed end conference call and we are waiting for TAPI response
281                 if(__pConfCallInfo == null)
282                 {
283                         break;
284                 }
285                 __isCallSplit = __pCallPresentor->SplitFromConference(SplitConfCallerCmdIds(actionId),__pConfCallInfo->GetCallerList());
286                 if(__isCallSplit == true)
287                 {
288                         __pList->UpdateTableView();
289                 }
290         }
291         break;
292
293         case IDA_END_CALLER1:
294         case IDA_END_CALLER2:
295         case IDA_END_CALLER3:
296         case IDA_END_CALLER4:
297         case IDA_END_CALLER5:
298         {
299                 // User has pressed end conference call and we are waiting for TAPI response
300                 if(__pConfCallInfo == null)
301                 {
302                         break;
303                 }
304                 __pCallPresentor->EndCallFromConference(EndConfCallerCmdIds(actionId),__pConfCallInfo->GetCallerList());
305         }
306         break;
307
308         default:
309                 break;
310         }
311 }
312
313 void
314 ConfCallerListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
315 {
316         //set itself as listener
317         __pCallPresentor->SetTelEventListener(this);
318         __isCallSplit = false;
319
320         AppLogDebug("Enter");
321
322         //DisableAllControls();
323         if (__pConfCallInfo != null)
324         {
325                 delete __pConfCallInfo;
326                 __pConfCallInfo = null;
327         }
328         //show 1st caller's info.
329         //Fetch Conference call info from telephony manager
330         __pConfCallInfo = __pCallPresentor->GetConferenceCallInfoN();
331         AppLogDebug("Enter %x",__pConfCallInfo);
332
333         //show active call timer
334         ShowTimerInfo(IDC_CALL_TIME_LABEL, __pConfCallInfo->GetCallConnectTime());
335
336         //Set the correct bitmap to the "hold" button based on the current state of the call
337         SetHoldButtonStatus(__pConfCallInfo->IsOnHold());
338         //disable Hold Button, if 2 active calls are present,Else enable it.
339         Button* pButtonHold = static_cast<Button*>(GetControl(IDC_HOLD_CONFCALL_BUTTON));
340         if(pButtonHold != null)
341         {
342                 if (__pCallPresentor->GetCurrentCallCount() == IDI_MAX_ACTIVE_CALLS)
343                 {
344                         pButtonHold->SetShowState(false);
345                 }
346                 else
347                 {
348                         pButtonHold->SetShowState(true);
349                 }
350                 pButtonHold->Invalidate(true);
351         }
352
353         __pList->UpdateTableView();
354         AddOrientationEventListener(*this);
355 }
356
357 void
358 ConfCallerListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
359 {
360         RemoveOrientationEventListener(*this);
361         if (__pConfCallTimer != null)
362         {
363                 __pConfCallTimer->Cancel();
364                 delete __pConfCallTimer;
365                 __pConfCallTimer = null;
366         }
367 }
368
369 result
370 ConfCallerListForm::OnDraw(void)
371 {
372         return E_SUCCESS;
373 }
374
375 void
376 ConfCallerListForm::SetHoldButtonStatus(bool isCallOnHold)
377 {
378         Button* pButtonHold = static_cast<Button*>(GetControl(IDC_HOLD_CONFCALL_BUTTON));
379         if(pButtonHold != null)
380         {
381                 Bitmap* pNormalBitmapToBeDrawn = null;
382                 Bitmap* pPressBitmapToBeDrawn = null;
383
384                 if (isCallOnHold == true)
385                 {
386                         pNormalBitmapToBeDrawn = AppUtility::GetBitmapFromResourcesN(IDB_UNHOLD_NORMAL_BUTTON_ICON,
387                                         W_HOLD_BITMAP, W_HOLD_BITMAP);
388                         pPressBitmapToBeDrawn = AppUtility::GetBitmapFromResourcesN(IDB_UNHOLD_PRESS_BUTTON_ICON,
389                                         W_HOLD_BITMAP, W_HOLD_BITMAP);
390                 }
391                 else
392                 {
393                         pNormalBitmapToBeDrawn = AppUtility::GetBitmapFromResourcesN(IDB_HOLD_NORMAL_BUTTON_ICON,
394                                         W_HOLD_BITMAP, W_HOLD_BITMAP);
395                         pPressBitmapToBeDrawn = AppUtility::GetBitmapFromResourcesN(IDB_HOLD_PRESS_BUTTON_ICON,
396                                         W_HOLD_BITMAP, W_HOLD_BITMAP);
397                 }
398
399                 if (pNormalBitmapToBeDrawn)
400                 {
401                         pButtonHold->SetNormalBitmap(Point(0, 0), *pNormalBitmapToBeDrawn);
402                 }
403                 if (pPressBitmapToBeDrawn)
404                 {
405                         pButtonHold->SetPressedBitmap(Point(0, 0), *pPressBitmapToBeDrawn);
406                 }
407
408                 pButtonHold->Invalidate(true);
409                 delete pNormalBitmapToBeDrawn;
410                 pNormalBitmapToBeDrawn = null;
411                 delete pPressBitmapToBeDrawn;
412                 pPressBitmapToBeDrawn = null;
413         }
414 }
415
416 void
417 ConfCallerListForm::HandleParticipantsChanged(void)
418 {
419         AppLogDebug("Enter");
420         AppCallInfo* pCallInfo = __pCallPresentor->GetConferenceCallInfoN();
421         if (pCallInfo == null)
422         {
423                 return;
424         }
425         if (__pConfCallInfo != null)
426         {
427                 delete __pConfCallInfo;
428                 __pConfCallInfo = null;
429         }
430         __pConfCallInfo = new (std::nothrow) AppCallInfo();
431         *__pConfCallInfo = *pCallInfo;
432         __pList->UpdateTableView();
433 }
434
435 void
436 ConfCallerListForm::DisableAllControls(void)
437 {
438         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_CALLER1_PANEL));
439         if (pKeysPanel != null)
440         {
441                 pKeysPanel->SetShowState(false);
442                 Label* pLineLabel1 = static_cast<Label*>(GetControl(IDC__LINE_LABEL1));
443                 pLineLabel1->SetShowState(false);
444                 pKeysPanel = null;
445         }
446         pKeysPanel = static_cast<Panel*>(GetControl(IDC_CALLER2_PANEL));
447         if (pKeysPanel != null)
448         {
449                 pKeysPanel->SetShowState(false);
450                 Label* pLineLabel1 = static_cast<Label*>(GetControl(IDC__LINE_LABEL2));
451                 pLineLabel1->SetShowState(false);
452                 pKeysPanel = null;
453         }
454         pKeysPanel = static_cast<Panel*>(GetControl(IDC_CALLER3_PANEL));
455         if (pKeysPanel != null)
456         {
457                 pKeysPanel->SetShowState(false);
458                 Label* pLineLabel1 = static_cast<Label*>(GetControl(IDC__LINE_LABEL3));
459                 pLineLabel1->SetShowState(false);
460                 pKeysPanel = null;
461         }
462         pKeysPanel = static_cast<Panel*>(GetControl(IDC_CALLER4_PANEL));
463         if (pKeysPanel != null)
464         {
465                 pKeysPanel->SetShowState(false);
466                 Label* pLineLabel1 = static_cast<Label*>(GetControl(IDC__LINE_LABEL4));
467                 pLineLabel1->SetShowState(false);
468                 pKeysPanel = null;
469         }
470         pKeysPanel = static_cast<Panel*>(GetControl(IDC_CALLER5_PANEL));
471         if (pKeysPanel != null)
472         {
473                 pKeysPanel->SetShowState(false);
474                 Label* pLineLabel1 = static_cast<Label*>(GetControl(IDC__LINE_LABEL5));
475                 pLineLabel1->SetShowState(false);
476                 pKeysPanel = null;
477         }
478 }
479
480 void
481 ConfCallerListForm::ShowTimerInfo(const String& timerLblName, long long startTime)
482 {
483         Label* pTimerLbl = static_cast<Label*>(GetControl(timerLblName));
484
485         if (__pConfCallTimer == null)
486         {
487                 __pConfCallTimer = new (std::nothrow) Timer();
488                 __pConfCallTimer->Construct(*this);
489         }
490
491         if (pTimerLbl != null)
492         {
493                 //current system time
494                 long long currTime = 0;
495                 SystemTime::GetTicks(currTime);
496                 //Set call duration
497                 TimeSpan diffSpan(abs(startTime - currTime));
498
499                 String activeCallTime(L"");
500
501                 long long hr = diffSpan.GetHours();
502                 if (hr <= 9) {
503                         activeCallTime.Append("0");
504                 }
505                 activeCallTime.Append(hr);
506                 activeCallTime.Append(L":");
507
508                 long long min = diffSpan.GetMinutes();
509                 if (min <= 9) {
510                         activeCallTime.Append("0");
511                 }
512                 activeCallTime.Append(min);
513                 activeCallTime.Append(L":");
514
515                 long long sec = diffSpan.GetSeconds();
516                 if (sec <= 9) {
517                         activeCallTime.Append("0");
518                 }
519                 activeCallTime.Append(sec);
520
521                 pTimerLbl->SetText(activeCallTime);
522                 __pConfCallTimer->StartAsRepeatable(TimeSpan::NUM_OF_TICKS_IN_SECOND);
523
524         }
525 }
526
527 void
528 ConfCallerListForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
529 {
530         //Call default implementation of "Object.Equals()"
531         //returns true, if they are pointing to same address.
532         if (__pConfCallTimer->Equals(timer))
533         {
534                 Label* pTimerLbl = static_cast<Label*>(GetControl(IDC_CALL_TIME_LABEL));
535                 if (pTimerLbl)
536                 {
537                         String activeCallTime = pTimerLbl->GetText();
538                         // Create a StringTokenizer instance
539                         StringTokenizer strTokens(activeCallTime, L":");
540
541                         int count = strTokens.GetTokenCount(); // count == 3
542                         String token;
543                         int sec = 0;
544                         int min = 0;
545                         int hr = 0;
546                         for (int index = 0; index < count; index++)
547                         {
548                                 switch (index)
549                                 {
550                                 case 0:
551                                         strTokens.GetNextToken(token);
552                                         Integer::Parse(token, hr);
553                                         break;
554
555                                 case 1:
556                                         strTokens.GetNextToken(token);
557                                         Integer::Parse(token, min);
558                                         break;
559
560                                 case 2:
561                                         strTokens.GetNextToken(token);
562                                         Integer::Parse(token, sec);
563                                         break;
564                                 }
565                         }
566                         //update all values
567                         sec = sec + 1;
568                         if (sec == IDI_MAX_SECONDS)
569                         {
570                                 sec = 0;
571                                 min = min + 1;
572                         }
573                         if (min == IDI_MAX_MINS)
574                         {
575                                 min = 0;
576                                 hr = hr + 1;
577                         }
578
579                         //replace string
580                         activeCallTime.Clear();
581                         if (hr <= 9)
582                         {
583                                 activeCallTime.Append("0");
584                         }
585                         activeCallTime.Append(hr);
586                         activeCallTime.Append(":");
587                         if (min <= 9)
588                         {
589                                 activeCallTime.Append("0");
590                         }
591                         activeCallTime.Append(min);
592                         activeCallTime.Append(":");
593                         if (sec <= 9)
594                         {
595                                 activeCallTime.Append("0");
596                         }
597                         activeCallTime.Append(sec);
598                         //update timer label
599                         pTimerLbl->SetText(activeCallTime);
600                         pTimerLbl->Invalidate(true);
601                 }
602         }
603 }
604
605 void
606 ConfCallerListForm::OnFormBackRequested(Form& source)
607 {
608         //If the call is split then wait for it to automatically go back once it split is success
609         if(__isCallSplit == true)
610         {
611                 return;
612         }
613         SceneManager* pSceneManager = SceneManager::GetInstance();
614         AppAssert(pSceneManager);
615
616
617         ArrayListT<AppCallInfo>* pCallList  = static_cast<ArrayListT<AppCallInfo>*>(__pCallPresentor->GetCallListN());
618         int noOfCalls = pCallList->GetCount();
619
620         //Ownership - To be deleted in 'OnSceneActivatedN' of next form
621         ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
622         pCallInfoList->Construct(noOfCalls);
623
624         for (int index = 0; index < noOfCalls; index++)
625         {
626                 //fetch call info and add to list
627                 AppCallInfo callInfo;
628                 result r = pCallList->GetAt(index, callInfo);
629                 if (r == E_SUCCESS)
630                 {
631                         //copy call information to new instance
632                         AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
633                         *pCaller = callInfo;
634                         pCallInfoList->Add(pCaller);
635                 }
636         }
637
638         if (noOfCalls == 1)
639         {
640                 //single active call - goto active call form
641                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL,
642                                 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
643         }
644         else
645         {
646                 //goto multiple active call form
647                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL,
648                                 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
649         }
650         pCallList->RemoveAll();
651         delete pCallList;
652
653 }
654
655 void
656 ConfCallerListForm::CreateItemAndAddActionListener( Button& splitButton,
657                 Button& endButton, Label& callerLabel, SplitConfCallerCmdIds splitCmdId,
658                 EndConfCallerCmdIds EndCmdId, const String& displayName)
659 {
660         Bitmap* pNormalSplitBitmap = null;
661         Bitmap* pPressSplitBitmap = null;
662         Bitmap* pNormalEndBitmap = null;
663         Bitmap* pPressEndBitmap = null;
664
665         pNormalSplitBitmap = AppUtility::GetBitmapFromResourcesN(IDB_SPLIT_NORMAL_BUTTON_ICON,
666                         W_SPLIT_BITMAP, H_SPLIT_BITMAP);
667         pPressSplitBitmap = AppUtility::GetBitmapFromResourcesN(IDB_SPLIT_PRESS_BUTTON_ICON,
668                         W_SPLIT_BITMAP, H_SPLIT_BITMAP);
669         pNormalEndBitmap = AppUtility::GetBitmapFromResourcesN(IDB_END_NORMAL_BUTTON_ICON,
670                         W_END_BITMAP, H_END_BITMAP);
671         pPressEndBitmap = AppUtility::GetBitmapFromResourcesN(IDB_END_PRESS_BUTTON_ICON,
672                         W_END_BITMAP, H_END_BITMAP);
673
674         bool isSplitAllowed = true;
675         if ((__pCallPresentor->IsSplitAllowed() == false) || (__pConfCallInfo->IsOnHold() == true) || (__isCallSplit == true))
676         {
677                 isSplitAllowed = false;
678         }
679
680         splitButton.SetActionId(splitCmdId);
681         splitButton.AddActionEventListener(*this);
682         splitButton.SetColor(BUTTON_STATUS_NORMAL,COLOR_SPLIT_CALL_BG);
683         splitButton.SetColor(BUTTON_STATUS_PRESSED,COLOR_SPLIT_CALL_BG_PRESS);
684         splitButton.SetNormalBitmap(Point(0, 0), *pNormalSplitBitmap);
685         splitButton.SetPressedBitmap(Point(0, 0), *pPressSplitBitmap);
686
687
688         bool isEnableEndButton = (__isCallSplit == false);
689         endButton.SetEnabled(isEnableEndButton);
690         endButton.SetActionId(EndCmdId);
691         endButton.AddActionEventListener(*this);
692         endButton.SetNormalBitmap(Point(0, 0), *pNormalEndBitmap);
693         endButton.SetColor(BUTTON_STATUS_NORMAL,COLOR_END_CALL_BG);
694         endButton.SetColor(BUTTON_STATUS_PRESSED,COLOR_END_CALL_BG_PRESS);
695         endButton.SetPressedBitmap(Point(0, 0), *pPressEndBitmap);
696
697
698         if (isSplitAllowed == false)
699         {
700                 splitButton.SetShowState(false);
701                 callerLabel.SetBounds(splitButton.GetBounds().x, callerLabel.GetBounds().y,
702                 callerLabel.GetBounds().width, callerLabel.GetBounds().height);
703         }
704         else
705         {
706                 splitButton.SetShowState(true);
707                 callerLabel.SetBounds((splitButton.GetBounds().x + splitButton.GetBounds().width), callerLabel.GetBounds().y,
708                                 callerLabel.GetBounds().width, callerLabel.GetBounds().height);
709         }
710
711
712         callerLabel.SetTextHorizontalAlignment(ALIGNMENT_LEFT);
713         callerLabel.SetText(displayName);
714         delete pNormalEndBitmap;
715         pNormalEndBitmap = null;
716         delete pPressEndBitmap;
717         pPressEndBitmap = null;
718         delete pNormalSplitBitmap;
719         pNormalSplitBitmap = null;
720         delete pPressSplitBitmap;
721         pPressSplitBitmap = null;
722 }
723
724 int
725 ConfCallerListForm::GetItemCount(void)
726 {
727         IListT<AppCallInfo>* pCallList = __pConfCallInfo->GetCallerList();
728         return pCallList->GetCount();
729 }
730
731 TableViewItem*
732 ConfCallerListForm::CreateItem(int itemIndex, int itemWidth)
733 {
734         AppLogDebug("%d %x",itemWidth,__pConfCallInfo);
735         IListT<AppCallInfo>* pCallList = __pConfCallInfo->GetCallerList();
736
737         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
738         TableViewItem* pItem = new (std::nothrow) TableViewItem();
739
740         pItem->Construct(Tizen::Graphics::Dimension(GetBounds().width, LIST_ITEM_HEIGHT), style);
741
742         Button *pSplitCallButton = new (std::nothrow) Button();
743         pSplitCallButton->Construct(Rectangle(X_SPLIT_BUTTON_MARGIN,Y_SPLIT_BUTTON_MARGIN,W_SPLIT_BITMAP,W_SPLIT_BITMAP));
744
745         Label *pCallLabel =  new (std::nothrow)Label();
746         pCallLabel->Construct(Rectangle(X_CALLER_LABEL,Y_CALLER_LABEL,W_CALLER_LABEL,H_CALLER_LABEL),L"");
747
748         Button *pEndCallButton =  new (std::nothrow)Button();
749         pEndCallButton->Construct(Rectangle(GetBounds().width-X_END_BUTTON_PADDING-W_SPLIT_BITMAP,Y_SPLIT_BUTTON_MARGIN,W_SPLIT_BITMAP,W_SPLIT_BITMAP));
750
751
752         AppCallInfo callInfo;
753         String pContactNo;
754         result r = pCallList->GetAt(itemIndex, callInfo);
755
756         if(callInfo.GetContactNumber().IsEmpty() == false)
757         {
758                 pContactNo.Append(callInfo.GetContactNumber());
759         }
760         else
761         {
762                 pContactNo.Append(AppUtility::GetResourceString(IDS_NUMBER_UNKNOWN));
763         }
764         //fetch contact details based on phone number
765         String* pDisplayName = callInfo.FetchCallerNameN();
766
767         if(pDisplayName != null)
768         {
769                 if ((pDisplayName->IsEmpty()) || r != E_SUCCESS)
770                 {
771                         pDisplayName->Append(pContactNo);
772                 }
773                 switch (itemIndex)
774                 {
775                         case 0:
776                         {
777                                 CreateItemAndAddActionListener(*pSplitCallButton,*pEndCallButton,*pCallLabel,
778                                                 IDA_SPLIT_CALLER1,IDA_END_CALLER1,*pDisplayName);
779                         }
780                         break;
781                         case 1:
782                         {
783                                 CreateItemAndAddActionListener(*pSplitCallButton,*pEndCallButton,*pCallLabel,
784                                                 IDA_SPLIT_CALLER2,IDA_END_CALLER2,*pDisplayName);
785                         }
786                         break;
787                         case 2:
788                         {
789                                 CreateItemAndAddActionListener(*pSplitCallButton,*pEndCallButton,*pCallLabel,
790                                                 IDA_SPLIT_CALLER3,IDA_END_CALLER3,*pDisplayName);
791                         }
792                         break;
793                         case 3:
794                         {
795                                 CreateItemAndAddActionListener(*pSplitCallButton,*pEndCallButton,*pCallLabel,
796                                                 IDA_SPLIT_CALLER4,IDA_END_CALLER4,*pDisplayName);
797                         }
798                         break;
799                         case 4:
800                         {
801                                 CreateItemAndAddActionListener(*pSplitCallButton,*pEndCallButton,*pCallLabel,
802                                                 IDA_SPLIT_CALLER5,IDA_END_CALLER5,*pDisplayName);
803                         }
804                         break;
805                         default:
806                                 break;
807                 }
808         }
809         pItem->AddControl(pSplitCallButton);
810         pItem->AddControl(pCallLabel);
811         pItem->AddControl(pEndCallButton);
812         if(pDisplayName != null)
813         {
814                 delete pDisplayName;
815                 pDisplayName = null;
816         }
817         return pItem;
818
819
820 }
821
822 bool
823 ConfCallerListForm::DeleteItem(int itemIndex, TableViewItem* pItem)
824 {
825         delete pItem;
826         pItem = null;
827         return true;
828 }
829
830 void
831 ConfCallerListForm::UpdateItem(int itemIndex, TableViewItem* pItem)
832 {
833         return ;
834 }
835
836 int
837 ConfCallerListForm::GetDefaultItemHeight(void)
838 {
839         return LIST_ITEM_HEIGHT;
840 }
841
842 void
843 ConfCallerListForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
844 {
845         AppLogDebug("Enter");
846         __pList->UpdateTableView();
847 }