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