Fix for 45866
[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_CONF_CALL_LIST_TABLEVIEW = L"IDC_CONF_CALL_LIST_TABLEVIEW";
80
81 //color
82 const unsigned int COLOR_END_CALL_BG = Color32<180, 60, 60>::Value;
83 const unsigned int COLOR_END_CALL_BG_PRESS = Color32<61, 153, 208>::Value;
84 const unsigned int COLOR_SPLIT_CALL_BG = Color32<129, 140, 148>::Value;
85 const unsigned int COLOR_SPLIT_CALL_BG_PRESS = Color32<63, 155, 210>::Value;
86 ConfCallerListForm::ConfCallerListForm(void)
87 : BaseForm(FORMTYPE_CONFCALLLIST)
88 {
89         __pConfCallInfo = null;
90         __pConfCallTimer = null;
91         __isCallSplit = false;
92         __pAddressbook = null;
93 }
94
95 ConfCallerListForm::~ConfCallerListForm(void)
96 {
97         if (__pConfCallTimer != null)
98         {
99                 __pConfCallTimer->Cancel();
100                 delete __pConfCallTimer;
101         }
102 }
103
104 void
105 ConfCallerListForm::Initialize(void)
106 {
107         Construct(IDL_CONFCALL_LIST_FORM);
108 }
109
110 result
111 ConfCallerListForm::OnInitializing(void)
112 {
113         result r = E_SUCCESS;
114         //Add action listener to buttons
115         AddActionListener(IDC_END_CONFCALL_BUTTON, IDA_END_CONF_CALL);
116         AddActionListener(IDC_HOLD_CONFCALL_BUTTON, IDA_HOLD_CONF_CALL);
117
118         Footer* pFooter = GetFooter();
119         if(pFooter != null)
120         {
121                 SetFormBackEventListener(this);
122         }
123         Label* pTimerLbl = static_cast<Label*>(GetControl(IDC_CALL_TIME_LABEL));
124         SetControlAlwaysOnTop(*pTimerLbl,true);
125
126         CreateTableView();
127         __pCallPresentor = CallPresentationModel::GetInstance();
128         return r;
129 }
130
131 void
132 ConfCallerListForm::CreateTableView(void)
133 {
134         __pList = static_cast <TableView*> (GetControl(IDC_CONF_CALL_LIST_TABLEVIEW));
135         __pList->SetItemProvider(this);
136         AddControl(__pList);
137 }
138
139 void
140 ConfCallerListForm::AddActionListener(const String& keyName, CommandIds cmdId)
141 {
142         Button* pButtonKeypad = static_cast<Button*>(GetControl(keyName));
143         if (pButtonKeypad != null)
144         {
145                 pButtonKeypad->SetActionId(cmdId);
146                 pButtonKeypad->AddActionEventListener(*this);
147         }
148 }
149
150 result
151 ConfCallerListForm::OnTerminating(void)
152 {
153         result r = E_SUCCESS;
154
155         if (__pCallPresentor != null)
156         {
157                 __pCallPresentor = null;
158         }
159
160         if (__pConfCallInfo != null)
161         {
162                 delete __pConfCallInfo;
163                 __pConfCallInfo = null;
164         }
165
166         //RemoveAllControls();
167         return r;
168 }
169
170 void
171 ConfCallerListForm::OnActionPerformed(const Control& source, int actionId)
172 {
173         SceneManager* pSceneManager = SceneManager::GetInstance();
174         AppAssert(pSceneManager);
175
176         switch (actionId)
177         {
178         case IDA_END_CONF_CALL:
179         {
180                 bool success = __pCallPresentor->EndConferenceCall();
181                 if (success == true)
182                 {
183                         delete __pConfCallInfo;
184                         __pConfCallInfo = null;
185                 }
186         }
187         break;
188
189         case IDA_HOLD_CONF_CALL:
190         {
191                 // User has pressed end conference call and we are waiting for TAPI response
192                 if(__pConfCallInfo == null)
193                 {
194                         return;
195                 }
196                 bool success = true;
197                 bool isCallOnHold = __pConfCallInfo->IsOnHold();
198                 if (isCallOnHold == false)
199                 {
200                         success = __pCallPresentor->HoldConferenceCall();
201                 }
202                 else
203                 {
204                         success = __pCallPresentor->ActivateConferenceCall();
205                 }
206
207                 //Check if request to Hold / UnHold call is successful.
208                 if(success == true)
209                 {
210                         //If success, then invert the Hold status in conference call
211                         isCallOnHold = !(isCallOnHold);
212                         __pConfCallInfo->SetOnHold(isCallOnHold);
213                         //update tableview
214                         __pList->UpdateTableView();
215                         SetHoldButtonStatus(isCallOnHold);
216                 }
217         }
218         break;
219
220         case IDA_BACK_EVENT:
221         {
222                 ArrayListT<AppCallInfo>* pCallList  = static_cast<ArrayListT<AppCallInfo>*>(__pCallPresentor->GetCallListN());
223                 int noOfCalls = pCallList->GetCount();
224
225                 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
226                 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
227                 pCallInfoList->Construct(noOfCalls);
228
229                 for (int index = 0; index < noOfCalls; index++)
230                 {
231                         //fetch call info and add to list
232                         AppCallInfo callInfo;
233                         result r = pCallList->GetAt(index, callInfo);
234                         if (r == E_SUCCESS)
235                         {
236                                 //copy call information to new instance
237                                 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
238                                 *pCaller = callInfo;
239                                 pCallInfoList->Add(pCaller);
240                         }
241                 }
242
243                 if (noOfCalls == 1)
244                 {
245                         //single active call - goto active call form
246                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL,
247                                         SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
248                 }
249                 else
250                 {
251                         //goto multiple active call form
252                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL,
253                                         SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_DESTROY), pCallInfoList);
254                 }
255                 pCallList->RemoveAll();
256                 delete pCallList;
257         }
258         break;
259
260         case IDA_SPLIT_CALLER1:
261         case IDA_SPLIT_CALLER2:
262         case IDA_SPLIT_CALLER3:
263         case IDA_SPLIT_CALLER4:
264         case IDA_SPLIT_CALLER5:
265         {
266                 // User has pressed end conference call and we are waiting for TAPI response
267                 if(__pConfCallInfo == null)
268                 {
269                         break;
270                 }
271                 __isCallSplit = __pCallPresentor->SplitFromConference(SplitConfCallerCmdIds(actionId),__pConfCallInfo->GetCallerList());
272                 if(__isCallSplit == true)
273                 {
274                         __pList->UpdateTableView();
275                 }
276         }
277         break;
278
279         case IDA_END_CALLER1:
280         case IDA_END_CALLER2:
281         case IDA_END_CALLER3:
282         case IDA_END_CALLER4:
283         case IDA_END_CALLER5:
284         {
285                 __pList->SetEnabled(false);
286                 // User has pressed end conference call and we are waiting for TAPI response
287                 if(__pConfCallInfo == null)
288                 {
289                         break;
290                 }
291                 __pCallPresentor->EndCallFromConference(EndConfCallerCmdIds(actionId),__pConfCallInfo->GetCallerList());
292         }
293         break;
294
295         default:
296                 break;
297         }
298 }
299
300 void
301 ConfCallerListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
302 {
303         //set itself as listener
304         __pCallPresentor->SetTelEventListener(this);
305         __isCallSplit = false;
306
307         AppLogDebug("Enter");
308
309         //DisableAllControls();
310         if (__pConfCallInfo != null)
311         {
312                 delete __pConfCallInfo;
313                 __pConfCallInfo = null;
314         }
315         //show 1st caller's info.
316         //Fetch Conference call info from telephony manager
317         __pConfCallInfo = __pCallPresentor->GetConferenceCallInfoN();
318         AppLogDebug("Enter %x",__pConfCallInfo);
319
320         AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
321         __pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);
322         if(__pAddressbook != null)
323         {
324                 __pAddressbook->SetAddressbookChangeEventListener(this);
325         }
326
327         //show active call timer
328         ShowTimerInfo(IDC_CALL_TIME_LABEL, __pConfCallInfo->GetCallConnectTime());
329
330         //Set the correct bitmap to the "hold" button based on the current state of the call
331         SetHoldButtonStatus(__pConfCallInfo->IsOnHold());
332         //disable Hold Button, if 2 active calls are present,Else enable it.
333         Button* pButtonHold = static_cast<Button*>(GetControl(IDC_HOLD_CONFCALL_BUTTON));
334         if(pButtonHold != null)
335         {
336                 if (__pCallPresentor->GetCurrentCallCount() == IDI_MAX_ACTIVE_CALLS)
337                 {
338                         pButtonHold->SetShowState(false);
339                 }
340                 else
341                 {
342                         pButtonHold->SetShowState(true);
343                 }
344                 pButtonHold->Invalidate(true);
345         }
346
347         __pList->UpdateTableView();
348         __pList->SetEnabled(true);
349         AddOrientationEventListener(*this);
350 }
351
352 void
353 ConfCallerListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
354 {
355         RemoveOrientationEventListener(*this);
356         if (__pConfCallTimer != null)
357         {
358                 __pConfCallTimer->Cancel();
359                 delete __pConfCallTimer;
360                 __pConfCallTimer = null;
361         }
362         if(__pAddressbook != null)
363         {
364                 __pAddressbook->SetAddressbookChangeEventListener(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         __pList->SetEnabled(true);
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::OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList)
657 {
658         __pList->UpdateTableView();
659 }
660
661 void
662 ConfCallerListForm::OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList)
663 {
664         //No implementation
665 }
666
667 void
668 ConfCallerListForm::CreateItemAndAddActionListener( Button& splitButton,
669                 Button& endButton, Label& callerLabel, SplitConfCallerCmdIds splitCmdId,
670                 EndConfCallerCmdIds EndCmdId, const String& displayName)
671 {
672         Bitmap* pNormalSplitBitmap = null;
673         Bitmap* pPressSplitBitmap = null;
674         Bitmap* pNormalEndBitmap = null;
675         Bitmap* pPressEndBitmap = null;
676
677         pNormalSplitBitmap = AppUtility::GetBitmapFromResourcesN(IDB_SPLIT_NORMAL_BUTTON_ICON,
678                         W_SPLIT_BITMAP, H_SPLIT_BITMAP);
679         pPressSplitBitmap = AppUtility::GetBitmapFromResourcesN(IDB_SPLIT_PRESS_BUTTON_ICON,
680                         W_SPLIT_BITMAP, H_SPLIT_BITMAP);
681         pNormalEndBitmap = AppUtility::GetBitmapFromResourcesN(IDB_END_NORMAL_BUTTON_ICON,
682                         W_END_BITMAP, H_END_BITMAP);
683         pPressEndBitmap = AppUtility::GetBitmapFromResourcesN(IDB_END_PRESS_BUTTON_ICON,
684                         W_END_BITMAP, H_END_BITMAP);
685
686         bool isSplitAllowed = true;
687         if ((__pCallPresentor->IsSplitAllowed() == false) || (__pConfCallInfo->IsOnHold() == true) || (__isCallSplit == true))
688         {
689                 isSplitAllowed = false;
690         }
691
692         splitButton.SetActionId(splitCmdId);
693         splitButton.AddActionEventListener(*this);
694         splitButton.SetColor(BUTTON_STATUS_NORMAL,COLOR_SPLIT_CALL_BG);
695         splitButton.SetColor(BUTTON_STATUS_PRESSED,COLOR_SPLIT_CALL_BG_PRESS);
696         splitButton.SetNormalBitmap(Point(0, 0), *pNormalSplitBitmap);
697         splitButton.SetPressedBitmap(Point(0, 0), *pPressSplitBitmap);
698
699
700         bool isEnableEndButton = (__isCallSplit == false);
701         endButton.SetEnabled(isEnableEndButton);
702         endButton.SetActionId(EndCmdId);
703         endButton.AddActionEventListener(*this);
704         endButton.SetNormalBitmap(Point(0, 0), *pNormalEndBitmap);
705         endButton.SetColor(BUTTON_STATUS_NORMAL,COLOR_END_CALL_BG);
706         endButton.SetColor(BUTTON_STATUS_PRESSED,COLOR_END_CALL_BG_PRESS);
707         endButton.SetPressedBitmap(Point(0, 0), *pPressEndBitmap);
708
709
710         if (isSplitAllowed == false)
711         {
712                 splitButton.SetShowState(false);
713                 callerLabel.SetBounds(splitButton.GetBounds().x, callerLabel.GetBounds().y,
714                 callerLabel.GetBounds().width, callerLabel.GetBounds().height);
715         }
716         else
717         {
718                 splitButton.SetShowState(true);
719                 callerLabel.SetBounds((splitButton.GetBounds().x + splitButton.GetBounds().width), callerLabel.GetBounds().y,
720                                 callerLabel.GetBounds().width, callerLabel.GetBounds().height);
721         }
722
723
724         callerLabel.SetTextHorizontalAlignment(ALIGNMENT_LEFT);
725         callerLabel.SetText(displayName);
726         delete pNormalEndBitmap;
727         pNormalEndBitmap = null;
728         delete pPressEndBitmap;
729         pPressEndBitmap = null;
730         delete pNormalSplitBitmap;
731         pNormalSplitBitmap = null;
732         delete pPressSplitBitmap;
733         pPressSplitBitmap = null;
734 }
735
736 int
737 ConfCallerListForm::GetItemCount(void)
738 {
739         IListT<AppCallInfo>* pCallList = __pConfCallInfo->GetCallerList();
740         return pCallList->GetCount();
741 }
742
743 TableViewItem*
744 ConfCallerListForm::CreateItem(int itemIndex, int itemWidth)
745 {
746         AppLogDebug("%d %x",itemWidth,__pConfCallInfo);
747         IListT<AppCallInfo>* pCallList = __pConfCallInfo->GetCallerList();
748
749         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
750         TableViewItem* pItem = new (std::nothrow) TableViewItem();
751
752         pItem->Construct(Tizen::Graphics::Dimension(GetBounds().width, LIST_ITEM_HEIGHT), style);
753
754         Button *pSplitCallButton = new (std::nothrow) Button();
755         pSplitCallButton->Construct(Rectangle(X_SPLIT_BUTTON_MARGIN,Y_SPLIT_BUTTON_MARGIN,W_SPLIT_BITMAP,W_SPLIT_BITMAP));
756
757         Label *pCallLabel =  new (std::nothrow)Label();
758         pCallLabel->Construct(Rectangle(X_CALLER_LABEL,Y_CALLER_LABEL,W_CALLER_LABEL,H_CALLER_LABEL),L"");
759
760         Button *pEndCallButton =  new (std::nothrow)Button();
761         pEndCallButton->Construct(Rectangle(GetBounds().width-X_END_BUTTON_PADDING-W_SPLIT_BITMAP,Y_SPLIT_BUTTON_MARGIN,W_SPLIT_BITMAP,W_SPLIT_BITMAP));
762
763
764         AppCallInfo callInfo;
765         String pContactNo;
766         result r = pCallList->GetAt(itemIndex, callInfo);
767
768         if(callInfo.GetContactNumber().IsEmpty() == false)
769         {
770                 pContactNo.Append(callInfo.GetContactNumber());
771         }
772         else
773         {
774                 pContactNo.Append(AppUtility::GetResourceString(IDS_NUMBER_UNKNOWN));
775         }
776         //fetch contact details based on phone number
777         String* pDisplayName = callInfo.FetchLatestCallerNameN(pContactNo);
778
779         if(pDisplayName != null)
780         {
781                 if ((pDisplayName->IsEmpty()) || r != E_SUCCESS)
782                 {
783                         pDisplayName->Append(pContactNo);
784                 }
785                 switch (itemIndex)
786                 {
787                         case 0:
788                         {
789                                 CreateItemAndAddActionListener(*pSplitCallButton,*pEndCallButton,*pCallLabel,
790                                                 IDA_SPLIT_CALLER1,IDA_END_CALLER1,*pDisplayName);
791                         }
792                         break;
793                         case 1:
794                         {
795                                 CreateItemAndAddActionListener(*pSplitCallButton,*pEndCallButton,*pCallLabel,
796                                                 IDA_SPLIT_CALLER2,IDA_END_CALLER2,*pDisplayName);
797                         }
798                         break;
799                         case 2:
800                         {
801                                 CreateItemAndAddActionListener(*pSplitCallButton,*pEndCallButton,*pCallLabel,
802                                                 IDA_SPLIT_CALLER3,IDA_END_CALLER3,*pDisplayName);
803                         }
804                         break;
805                         case 3:
806                         {
807                                 CreateItemAndAddActionListener(*pSplitCallButton,*pEndCallButton,*pCallLabel,
808                                                 IDA_SPLIT_CALLER4,IDA_END_CALLER4,*pDisplayName);
809                         }
810                         break;
811                         case 4:
812                         {
813                                 CreateItemAndAddActionListener(*pSplitCallButton,*pEndCallButton,*pCallLabel,
814                                                 IDA_SPLIT_CALLER5,IDA_END_CALLER5,*pDisplayName);
815                         }
816                         break;
817                         default:
818                                 break;
819                 }
820         }
821         pItem->AddControl(pSplitCallButton);
822         pItem->AddControl(pCallLabel);
823         pItem->AddControl(pEndCallButton);
824         if(pDisplayName != null)
825         {
826                 delete pDisplayName;
827                 pDisplayName = null;
828         }
829         return pItem;
830
831
832 }
833
834 bool
835 ConfCallerListForm::DeleteItem(int itemIndex, TableViewItem* pItem)
836 {
837         delete pItem;
838         pItem = null;
839         return true;
840 }
841
842 void
843 ConfCallerListForm::UpdateItem(int itemIndex, TableViewItem* pItem)
844 {
845         return ;
846 }
847
848 int
849 ConfCallerListForm::GetDefaultItemHeight(void)
850 {
851         return LIST_ITEM_HEIGHT;
852 }
853
854 void
855 ConfCallerListForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
856 {
857         AppLogDebug("Enter");
858         __pList->UpdateTableView();
859 }