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