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