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