Tizen 2.0 Release
[apps/osp/Phone.git] / src / PhnIncomingCallForm.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    PhnIncomingCallForm.cpp
19  * @brief       Incoming Call form implementation
20  */
21 #include <FBaseColIList.h>
22 #include <FMessaging.h>
23 #include "PhnIncomingCallForm.h"
24 #include "PhnAppUtility.h"
25 #include "PhnSettingsManager.h"
26 #include "PhnCallPresentationModel.h"
27 #include "PhnSceneRegister.h"
28 #include "PhnTypes.h"
29
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Messaging;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Animations;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::Ui::Scenes;
39
40 //Constants
41 const int W_DIAL_BITMAP = 102;
42 const int H_DIAL_BITMAP = 102;
43 const int W_CREATE_BITMAP = 56;
44 const int H_CREATE_BITMAP = 56;
45 const int X_CREATE_BITMAP = 8;
46 const int Y_CREATE_BITMAP = 8;
47 const int W_MESSAGE_BG_BITMAP = 720;
48 const int H_MESSAGE_BG_BITMAP = 92;
49 const int W_ARROW_BITMAP = 18;
50 const int H_ARROW_BITMAP = 12;
51 const int W_MESSAGE_BITMAP = 50;
52 const int H_MESSAGE_BITMAP = 50;
53 const int X_MESSAGE_BITMAP = 148;
54 const int Y_MESSAGE_BITMAP = 28;
55 const int MESSAGE_TEXT_X_MARGIN = 20;
56 const int MESSAGE_TEXT_Y_MARGIN = 7;
57 const int SEND_TEXT_X_MARGIN = 78;
58 const int SEND_TEXT_Y_MARGIN = 20;
59 const int SEND_BUTTON_ROUND_DIMENSION = 5;
60 const int W_DIAL_LABEL = 158;
61 const int H_DIAL_LABEL = 158;
62 const int DIAL_ICON_X_OFFSET = 23;
63 const int DIAL_ICON_Y_OFFSET = 23;
64 const int REJECT_LABEL_X_OFFSET = 542;
65 const int X_CALL_PANEL = 0;
66 const int Y_CALL_PANEL = 190;
67 const int H_CALL_PANEL = 158;
68 const int Y_ARROW_LABEL = 79;
69 const int W_ARROW_LABEL = 20;
70 const int H_ARROW_LABEL = 32;
71 const int VALID_TOUCH_X_OFFSET = 158;
72 const int VALID_TOUCH_Y_OFFSET = 158;
73 const int X_ARROW_LABEL_STARTPOS = 198;
74 const int ARROW_LABEL_X_MARGIN = 48;
75 const int ACCEPT_LABEL_RELATIVE_POS = -384; //relative pos of accept labels right to reject labels left
76 const int MAX_LIST_HEIGHT = 678;
77 const int H_REJECT_VIEW_FOOTER = 114;
78 const int X_LIST_TEXT_ITEM = 16;
79 const int W_LIST_TEXT_ITEM = 452;
80 const int H_LIST_TEXT_ITEM = 111;
81 const int X_SEND_TEXT_ITEM = 484;
82 const int Y_SEND_TEXT_ITEM = 20;
83 const int W_SEND_TEXT_ITEM = 220;
84 const int H_SEND_TEXT_ITEM = 72;
85 const int X_PHOTO_LBL = 166;
86 const int Y_PHOTO_LBL = 232;
87 const int W_PHOTO_LBL = 388;
88 const int H_PHOTO_LBL = 388;
89 const int W_PHOTO_LABEL = 720;
90 const int H_PHOTO_LABEL = 720;
91
92 const unsigned int COLOR_SEND_BUTTON_PRESSED = Color32<130, 142, 150>::Value;
93 const unsigned int COLOR_SEND_BUTTON_NORMAL = Color32<64, 156, 211>::Value;
94 const unsigned int COLOR_SWIPE_PANEL = Color32<0, 0, 0, 255>::Value;
95 const unsigned int COLOR_LIST_TEXT_NORMAL = Color32<0, 0, 0>::Value;
96 const unsigned int COLOR_LIST_TEXT_PRESSED = Color32<249, 249, 249>::Value;
97
98 const int FONT_SIZE_MSG_TXT = 32;
99
100 static const wchar_t* IDL_INCOMING_CALL_FORM = L"IDL_INCOMING_CALL_FORM";
101 static const wchar_t* IDB_REJECT_MESSAGE_BG = L"C01-1_Reject_message_bg.png";
102 static const wchar_t* IDB_REJECT_MESSAGE_UP_ARROW = L"C01-1_Reject_message_arrow_01.png";
103 static const wchar_t* IDB_REJECT_MESSAGE_DOWN_ARROW = L"C01-1_Reject_message_arrow_02.png";
104 static const wchar_t* IDB_REJECT_MESSAGE_ICON = L"C01-1_icon_Reject_with_Message.png";
105 static const wchar_t* IDB_ACCEPT_CIRCLE_ICON = L"C01-1_accept_left.png";
106 static const wchar_t* IDB_REJECT_CIRCLE_ICON = L"C01-1_reject_right.png";
107 static const wchar_t* IDB_CALL_ACCEPT_ICON = L"C01-1_accept_left_dial_answer.png";
108 static const wchar_t* IDB_CALL_REJECT_ICON = L"C01-1_reject_right_dial_decline.png";
109 static const wchar_t* IDB_ACCEPT_ARROW_ICON = L"C01-1_arrow_g.png";
110 static const wchar_t* IDB_REJECT_ARROW_ICON = L"C01-1_arrow_r.png";
111 static const wchar_t* IDB_CALL_BG = L"C01-1_calling_BG_01.png";
112 static const wchar_t* IDB_CREATE_BUTTON_ICON = L"C01-1_btn_create.png";
113 static const wchar_t* IDB_BACK_BUTTON_ICON = L"C01-1_btn_back.png";
114 static const wchar_t* IDC_REJECT_MESSAGE_BUTTON = L"IDC_REJECT_MESSAGE_BUTTON";
115 static const wchar_t* IDC_REJECT_PANEL = L"IDC_REJECT_PANEL";
116 static const wchar_t* IDC_BACK_BUTTON = L"IDC_BACK_BUTTON";
117 static const wchar_t* IDC_CREATE_BUTTON = L"IDC_CREATE_BUTTON";
118 static const wchar_t* IDC_REJECT_MESSAGE_CANCEL_BUTTON = L"IDC_REJECT_MESSAGE_CANCEL_BUTTON";
119 static const wchar_t* IDC_LIST_SCROLLPANEL = L"IDC_LIST_SCROLLPANEL";
120 static const wchar_t* IDC_MSG_TABLEVIEW = L"IDC_MSG_TABLEVIEW";
121 static const wchar_t* IDC_CALLER_LABEL = L"IDC_CALLER_LABEL";
122 static const wchar_t* IDC_NUMBER_LABEL = L"IDC_NUMBER_LABEL";
123 static const wchar_t* IDC_BIG_PHOTO_LABEL = L"IDC_BIG_PHOTO_LABEL";
124 const wchar_t* IDS_REJECT_MESSAGE_BTN = L"IDS_REJECT_MESSAGE_BTN";
125 const wchar_t* IDS_LIST_SEND_BUTTON = L"IDS_LIST_SEND_BUTTON";
126 const wchar_t* IDS_NO_MESSAGE_STR = L"IDS_NO_MESSAGE_STR";
127
128 const int ID_MULTI_PARTY_CALL = 505;
129 const int ID_SECOND_INCOMING_CALL = 503;
130
131 const wchar_t* IDI_FORM_VISUAL_ELE_NAME = L"FormVisEle";
132 const wchar_t* IDI_PANEL_VISUAL_ELE_NAME = L"PanelVisEle";
133 const wchar_t* IDI_ACCEPT_VISUAL_ELE_NAME = L"AcceptVisEle";
134 const wchar_t* IDI_REJECT_VISUAL_ELE_NAME = L"RejectVisEle";
135 const wchar_t* IDI_ACCEPT_ARROW_VISUAL_ELE_NAME = L"AcceptArrowVisEle";
136 const wchar_t* IDI_REJECT_ARROW_VISUAL_ELE_NAME = L"RejectArrowVisEle";
137 const wchar_t* IDI_REJECT_FINAL_VISUAL_ELE_NAME = L"RejectFinalVisEle";
138 const wchar_t* IDI_ACCEPT_FINAL_VISUAL_ELE_NAME = L"AcceptFinalVisEle";
139
140 class SmsListener
141         : public Object
142         , public ISmsListener
143 {
144 public:
145                 void  OnSmsMessageSent(result r)
146                 {
147                 }
148 };
149
150 IncomingCallForm::IncomingCallForm(void)
151         : BaseForm(FORMTYPE_INCOMINGCALL)
152 {
153         __pActiveContactNo = null;
154         __pRejectMessageList = null;
155         __incomingCallHandle = -1;
156         __isAnswerCallStarted = false;
157         __isRejectCallStarted = false;
158         __pAcceptArrowLabelsList = null;
159         __pRejectArrowLabelsList = null;
160         __pRejectCircle = null;
161         __pAcceptCircle = null;
162         __pAcceptDial = null;
163         __pRejectDial = null;
164         __pAcceptArrow = null;
165         __pRejectArrow = null;
166         __pAcceptLabel = null;
167         __pRejectLabel = null;
168         __pAcceptArrowLabel = null;
169         __pRejectArrowLabel = null;
170         __pCallHandlePanel = null;
171         __pAcceptVisElem = null;
172         __pRejectVisElem = null;
173         __pRejectFinalVisElem = null;
174         __pAcceptFinalVisElem = null;
175         __pAcceptArrowVisElem = null;
176         __pRejectArrowVisElem = null;
177         __pCallPresentor = null;
178         __pOptionPopup = null;
179         __pSmallPhotoLabel = null;
180 }
181
182 IncomingCallForm::~IncomingCallForm(void)
183 {
184 }
185
186 void
187 IncomingCallForm::Initialize(void)
188 {
189         Construct(IDL_INCOMING_CALL_FORM);
190 }
191
192 result
193 IncomingCallForm::OnInitializing(void)
194 {
195         result r = E_SUCCESS;
196         Canvas* pCanvas = null;
197
198         VisualElement* pFormVisElem = new (std::nothrow) VisualElement();
199         r = pFormVisElem->Construct();
200         pFormVisElem->SetBounds(FloatRectangle(GetClientAreaBounds().x, GetClientAreaBounds().y, GetClientAreaBounds().width, GetClientAreaBounds().height));
201         pFormVisElem->SetShowState(true);
202         pFormVisElem->SetOpacity(1.0f);
203         pFormVisElem->SetName(IDI_FORM_VISUAL_ELE_NAME);
204         GetVisualElement()->AttachChild(*pFormVisElem);
205         pCanvas = pFormVisElem->GetCanvasN();
206         if(pCanvas != null)
207         {
208                 pCanvas->Clear();
209                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
210                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
211                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(GetClientAreaBounds().x, GetClientAreaBounds().y, GetClientAreaBounds().width, GetClientAreaBounds().height));
212                 delete pCanvas;
213                 pCanvas = null;
214         }
215         HideRejectPanel();
216
217         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
218         if (pButtonRejectMessage)
219         {
220                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
221                                                                            IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, false);
222                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
223                                                                            IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, true);
224                 pButtonRejectMessage->SetActionId(IDA_SHOW_REJECT_CALL_MESSAGE_PANEL);
225                 pButtonRejectMessage->AddActionEventListener(*this);
226         }
227
228         //Get Reject list from Settings Manager
229         IMapT<int,String>* pMsgMap = SettingsManager::GetInstance()->GetRejectMessageListN();
230         if(pMsgMap != null)
231         {
232                 __pRejectMessageList = pMsgMap->GetValuesN();
233                 delete pMsgMap;
234                 pMsgMap = null;
235         }
236         InitializeTableView();
237
238         __pAcceptCircle = AppUtility::GetBitmapFromResourcesN(IDB_ACCEPT_CIRCLE_ICON, W_DIAL_LABEL, H_DIAL_LABEL);
239         __pRejectCircle = AppUtility::GetBitmapFromResourcesN(IDB_REJECT_CIRCLE_ICON, W_DIAL_LABEL, H_DIAL_LABEL);
240         __pAcceptDial = AppUtility::GetBitmapFromResourcesN(IDB_CALL_ACCEPT_ICON, W_DIAL_BITMAP, H_DIAL_BITMAP);
241         __pRejectDial = AppUtility::GetBitmapFromResourcesN(IDB_CALL_REJECT_ICON, W_DIAL_BITMAP, H_DIAL_BITMAP);
242         __pAcceptArrow = AppUtility::GetBitmapFromResourcesN(IDB_ACCEPT_ARROW_ICON, W_ARROW_LABEL, H_ARROW_LABEL);
243         __pRejectArrow = AppUtility::GetBitmapFromResourcesN(IDB_REJECT_ARROW_ICON, W_ARROW_LABEL, H_ARROW_LABEL);
244
245
246         //Panel for showing accept and reject call buttons.
247         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_BIG_PHOTO_LABEL, true));
248          int yPos = pPhotoLbl->GetX()+pPhotoLbl->GetHeight()+ Y_CALL_PANEL;
249
250         __pCallHandlePanel = new (std::nothrow) Panel();
251         r = __pCallHandlePanel->Construct(Rectangle(X_CALL_PANEL, yPos, GetClientAreaBounds().width, H_CALL_PANEL), GROUP_STYLE_NONE);
252         __pCallHandlePanel->AddTouchEventListener(*this);
253         AddControl(*__pCallHandlePanel);
254         __pCallHandlePanel->SetBackgroundColor(COLOR_SWIPE_PANEL);
255         VisualElement* pCallPanelVisElem = new (std::nothrow) VisualElement();
256         r = pCallPanelVisElem->Construct();
257         pCallPanelVisElem->SetBounds(FloatRectangle(X_CALL_PANEL, yPos, GetClientAreaBounds().width, H_CALL_PANEL));
258         pCallPanelVisElem->SetShowState(true);
259         pCallPanelVisElem->SetOpacity(1.0f);
260         pCallPanelVisElem->SetName(IDI_PANEL_VISUAL_ELE_NAME);
261         __pCallHandlePanel->GetVisualElement()->AttachChild(*pCallPanelVisElem);
262         pCanvas = pCallPanelVisElem->GetCanvasN();
263         if(pCanvas != null)
264         {
265                 pCanvas->Clear();
266                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
267                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
268                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(X_CALL_PANEL, yPos, GetClientAreaBounds().width, H_CALL_PANEL));
269                 delete pCanvas;
270                 pCanvas = null;
271         }
272         //Lock Label for animation
273         __pAcceptLabel = new (std::nothrow) Label();
274         r = __pAcceptLabel->Construct(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), L"");
275         __pAcceptLabel->SetBackgroundColor(COLOR_SWIPE_PANEL);
276         __pAcceptLabel->AddTouchEventListener(*this);
277         __pCallHandlePanel->AddControl(*__pAcceptLabel);
278         //left dial icon
279         __pAcceptVisElem = new (std::nothrow) VisualElement();
280         r = __pAcceptVisElem->Construct();
281         __pAcceptVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
282         __pAcceptVisElem->SetShowState(true);
283         __pAcceptVisElem->SetOpacity(1.0f);
284         __pAcceptVisElem->SetName(IDI_ACCEPT_VISUAL_ELE_NAME);
285         __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem);
286         pCanvas = __pAcceptVisElem->GetCanvasN();
287         if(pCanvas != null)
288         {
289                 pCanvas->Clear();
290                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
291                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
292                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
293                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pAcceptCircle);
294                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pAcceptDial);
295                 delete pCanvas;
296                 pCanvas = null;
297         }
298         //UnLock Label for animation
299         __pRejectLabel = new (std::nothrow) Label();
300         r = __pRejectLabel->Construct(Rectangle(REJECT_LABEL_X_OFFSET, 0, W_DIAL_LABEL, H_DIAL_LABEL), L"");
301         __pRejectLabel->AddTouchEventListener(*this);
302         __pCallHandlePanel->AddControl(*__pRejectLabel);
303         __pRejectLabel->SetBackgroundColor(COLOR_SWIPE_PANEL);
304         SetControlAlwaysAtBottom(*__pCallHandlePanel, true);
305
306         //Right reject icon
307         __pRejectVisElem = new (std::nothrow) VisualElement();
308         r = __pRejectVisElem->Construct();
309         __pRejectVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
310         __pRejectVisElem->SetShowState(true);
311         __pRejectVisElem->SetOpacity(1.00f);
312         __pRejectVisElem->SetName(IDI_REJECT_VISUAL_ELE_NAME);
313         __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem);
314         pCanvas = __pRejectVisElem->GetCanvasN();
315         if(pCanvas != null)
316         {
317                 pCanvas->Clear();
318                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
319                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
320                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
321                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pRejectDial);
322                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pRejectCircle);
323                 delete pCanvas;
324                 pCanvas = null;
325         }
326
327         //! Constructs an array list to store the unlock labels
328         __pAcceptArrowLabelsList = new (std::nothrow) ArrayList();
329         r = __pAcceptArrowLabelsList->Construct();
330
331         //! Constructs the Unlock Labels with the bitmap as background, adds the touch event Listener and adds them to the panel.
332         int x = X_ARROW_LABEL_STARTPOS;
333         for (int index = 0; index < 7; index++)
334         {
335                 __pAcceptArrowLabel = new (std::nothrow) Label();
336                 r = __pAcceptArrowLabel->Construct(Rectangle(x, Y_ARROW_LABEL, W_ARROW_LABEL, H_ARROW_LABEL), L"");
337                 __pAcceptArrowLabel->AddTouchEventListener(*this);
338                 __pCallHandlePanel->AddControl(*__pAcceptArrowLabel);
339                 __pAcceptArrowLabelsList->Add(*__pAcceptArrowLabel);
340                 __pAcceptArrowVisElem = new (std::nothrow) VisualElement();
341                 r = __pAcceptArrowVisElem->Construct();
342                 __pAcceptArrowVisElem->SetBounds(FloatRectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
343                 __pAcceptArrowVisElem->SetShowState(true);
344                 __pAcceptArrowVisElem->SetOpacity(0.0f);
345                 String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
346                 VisualEleName.Append(index);
347                 __pAcceptArrowVisElem->SetName(VisualEleName);
348                 __pAcceptArrowLabel->GetVisualElement()->AttachChild(*__pAcceptArrowVisElem);
349                 pCanvas = __pAcceptArrowVisElem->GetCanvasN();
350                 if(pCanvas != null)
351                 {
352                         pCanvas->Clear();
353                         pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
354                         pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
355                         pCanvas->DrawRectangle(Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
356                         pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
357                         pCanvas->DrawBitmap(Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL), *__pAcceptArrow);
358                         delete pCanvas;
359                         pCanvas = null;
360                 }
361                 x += ARROW_LABEL_X_MARGIN;
362         }
363         //! Constructs an array list to store the unlock labels
364         __pRejectArrowLabelsList = new (std::nothrow) ArrayList();
365         r = __pRejectArrowLabelsList->Construct();
366
367         x = X_ARROW_LABEL_STARTPOS;
368         for (int index = 0; index < 7; index++)
369         {
370                 __pRejectArrowLabel = new (std::nothrow) Label();
371                 r = __pRejectArrowLabel->Construct(Rectangle(x, Y_ARROW_LABEL, W_ARROW_LABEL, H_ARROW_LABEL), L"");
372                 __pRejectArrowLabel->AddTouchEventListener(*this);
373                 __pCallHandlePanel->AddControl(*__pRejectArrowLabel);
374                 __pRejectArrowLabelsList->Add(*__pRejectArrowLabel);
375                 __pRejectArrowVisElem = new (std::nothrow) VisualElement();
376                 r = __pRejectArrowVisElem->Construct();
377                 __pRejectArrowVisElem->SetBounds(FloatRectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
378                 __pRejectArrowVisElem->SetShowState(true);
379                 __pRejectArrowVisElem->SetOpacity(0.0f);
380                 String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
381                 VisualEleName.Append(index);
382                 __pRejectArrowVisElem->SetName(VisualEleName);
383                 __pRejectArrowLabel->GetVisualElement()->AttachChild(*__pRejectArrowVisElem);
384                 pCanvas = __pRejectArrowVisElem->GetCanvasN();
385                 if(pCanvas != null)
386                 {
387                         pCanvas->Clear();
388                         pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
389                         pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
390                         pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
391                         pCanvas->DrawBitmap(Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL), *__pRejectArrow);
392                         delete pCanvas;
393                         pCanvas = null;
394                 }
395                 x += ARROW_LABEL_X_MARGIN;
396         }
397
398         return r;
399 }
400
401 result
402 IncomingCallForm::OnTerminating(void)
403 {
404         result r = E_SUCCESS;
405
406         if (__pRejectMessageList != null)
407         {
408                 delete __pRejectMessageList;
409                 __pRejectMessageList = null;
410         }
411         if (__pActiveContactNo != null)
412         {
413                 delete __pActiveContactNo;
414                 __pActiveContactNo = null;
415         }
416         __incomingCallHandle = -1;
417         __pCallPresentor = null;
418
419         /* Deleting fails in A4RC* SDK. Remove if not necessary
420         if (__pAcceptVisElem != null)
421         {
422                 __pAcceptVisElem->Destroy();
423                 __pAcceptVisElem = null;
424         }
425
426         if (__pRejectVisElem != null)
427         {
428                 __pRejectVisElem->Destroy();
429                 __pRejectVisElem = null;
430         }
431
432         if (__pRejectFinalVisElem != null)
433         {
434                 __pRejectFinalVisElem->Destroy();
435                 __pRejectFinalVisElem = null;
436         }
437
438         if (__pAcceptFinalVisElem != null)
439         {
440                 __pAcceptFinalVisElem->Destroy();
441                 __pAcceptFinalVisElem = null;
442         }
443
444         for (int i = 0; i < 7; i++)
445         {
446                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
447                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement();
448                 if (__pRejectArrowVisElem != null)
449                 {
450                         __pRejectArrowVisElem->Destroy();
451                         __pRejectArrowVisElem = null;
452                 }
453
454                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
455                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement();
456                 if (__pAcceptArrowVisElem != null)
457                 {
458                         __pAcceptArrowVisElem->Destroy();
459                         __pAcceptArrowVisElem = null;
460                 }
461         }
462
463         if (__pAcceptArrowVisElem != null)
464         {
465                 __pAcceptArrowVisElem = null;
466         }
467
468         if (__pRejectArrowVisElem != null)
469         {
470                 __pRejectArrowVisElem = null;
471         }
472 */
473         if (__pAcceptArrowLabelsList != null)
474         {
475                 __pAcceptArrowLabelsList->RemoveAll(false);
476                 delete __pAcceptArrowLabelsList;
477                 __pAcceptArrowLabelsList = null;
478         }
479
480         if (__pRejectArrowLabelsList != null)
481         {
482                 __pRejectArrowLabelsList->RemoveAll(false);
483                 delete __pRejectArrowLabelsList;
484                 __pRejectArrowLabelsList = null;
485         }
486
487         if (__pRejectCircle != null)
488         {
489                 delete __pRejectCircle;
490                 __pRejectCircle = null;
491         }
492
493         if (__pAcceptCircle != null)
494         {
495                 delete __pAcceptCircle;
496                 __pAcceptCircle = null;
497         }
498
499         if (__pAcceptDial != null)
500         {
501                 delete __pAcceptDial;
502                 __pAcceptDial = null;
503         }
504
505         if (__pRejectDial != null)
506         {
507                 delete __pRejectDial;
508                 __pRejectDial = null;
509         }
510
511         if (__pAcceptArrow != null)
512         {
513                 delete __pAcceptArrow;
514                 __pAcceptArrow = null;
515         }
516
517         if (__pRejectArrow != null)
518         {
519                 delete __pRejectArrow;
520                 __pRejectArrow = null;
521         }
522         __pCallHandlePanel->RemoveTouchEventListener(*this);
523         __pAcceptLabel->RemoveTouchEventListener(*this);
524         __pRejectLabel->RemoveTouchEventListener(*this);
525         __pAcceptArrowLabel->RemoveTouchEventListener(*this);
526         __pRejectArrowLabel->RemoveTouchEventListener(*this);
527         __pAcceptLabel = null;
528         __pRejectLabel = null;
529         __pAcceptArrowLabel = null;
530         __pRejectArrowLabel = null;
531         __pCallHandlePanel = null;
532         return r;
533 }
534
535 void
536 IncomingCallForm::OnActionPerformed(const Control& source, int actionId)
537 {
538         switch (actionId)
539         {
540         case IDA_SHOW_REJECT_CALL_MESSAGE_PANEL: // applicable in all form states
541         {
542                 Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
543                 if (pKeysPanel)
544                 {
545                         pKeysPanel->SetShowState(true);
546                         ScrollPanel* pScrollPanel = static_cast<ScrollPanel*>(pKeysPanel->GetControl(IDC_LIST_SCROLLPANEL));
547                         TableView* pMessageList = static_cast<TableView*>(pScrollPanel->GetControl(IDC_MSG_TABLEVIEW));
548                         Rectangle tmpRect = pMessageList->GetBounds();
549                         SetControlAlwaysOnTop(*pKeysPanel,true);
550
551                         //Set Height to Reject Message Panel
552                         int listHeight = H_LIST_NORMAL_MENU_ITEM; //If no messages
553                         if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0)
554                         {
555                                 listHeight = H_LIST_NORMAL_MENU_ITEM * (__pRejectMessageList->GetCount()); //multiply by number of items
556                         }
557                         if (listHeight > MAX_LIST_HEIGHT)
558                         {
559                                 listHeight = MAX_LIST_HEIGHT;
560                         }
561
562                         pMessageList->SetBounds(tmpRect.x, tmpRect.y, tmpRect.width, listHeight);
563                         tmpRect = pScrollPanel->GetBounds();
564                         pScrollPanel->SetBounds(tmpRect.x, tmpRect.y, tmpRect.width, listHeight);
565                         tmpRect = pKeysPanel->GetBounds();
566                         pKeysPanel->SetBounds(tmpRect.x, tmpRect.y, tmpRect.width, H_MESSAGE_BG_BITMAP + H_REJECT_VIEW_FOOTER + listHeight);
567
568                         Button* pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
569                         pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL);
570                         pButtonReject->AddActionEventListener(*this);
571                         pButtonReject->SetEnabled(true);
572                         pButtonReject->SetFocus();
573
574                         pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_BACK_BUTTON));
575                         pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL);
576                         pButtonReject->AddActionEventListener(*this);
577                         pButtonReject->SetEnabled(true);
578                         pButtonReject->SetFocus();
579
580                         Button* pButtonCreate = static_cast<Button*>(pKeysPanel->GetControl(IDC_CREATE_BUTTON));
581                         pButtonCreate->SetActionId(IDA_CREATE_REJECT_CALL_MESSAGE);
582                         pButtonCreate->AddActionEventListener(*this);
583                         pButtonCreate->SetEnabled(true);
584                         pButtonCreate->SetFocus();
585
586                         pKeysPanel->SetFocus();
587                         pKeysPanel->Draw();
588                 }
589                 Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
590                 if (pButtonRejectMessage)
591                 {
592                         pButtonRejectMessage->SetShowState(false);
593                         pButtonRejectMessage->Invalidate(true);
594                         pButtonRejectMessage->Draw();
595                 }
596         }
597         break;
598
599         case IDA_CREATE_REJECT_CALL_MESSAGE:
600         {
601                 __pCallPresentor->RejectCall(__incomingCallHandle, true,*__pActiveContactNo);
602                 ArrayListT<CallInfo>* pCallList  = static_cast<ArrayListT<CallInfo>*>(__pCallPresentor->GetCallListN());
603                 if(pCallList != null && pCallList->GetCount() > 0)
604                 {
605                         __pCallPresentor->HandleCallConnected(*pCallList);
606                 }
607                 pCallList = null;
608         }
609         break;
610
611         case IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL:
612         {
613                 HideRejectPanel();
614                 SetFocus();
615                 Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
616                 if (pButtonRejectMessage)
617                 {
618                         pButtonRejectMessage->SetShowState(true);
619                         pButtonRejectMessage->Invalidate(true);
620                         pButtonRejectMessage->Draw();
621                 }
622                 RequestRedraw(true);
623         }
624         break;
625
626         case IDA_SEND_REJECT_MSG1:
627         case IDA_SEND_REJECT_MSG2:
628         case IDA_SEND_REJECT_MSG3:
629         case IDA_SEND_REJECT_MSG4:
630         case IDA_SEND_REJECT_MSG5:
631         case IDA_SEND_REJECT_MSG6:
632         {
633                 __pCallPresentor->RejectCall(__incomingCallHandle, false,*__pActiveContactNo);
634                 SmsListener* pSmsListener = new (std::nothrow) SmsListener();
635                 SmsManager* pSmsManager = new (std::nothrow) SmsManager();
636                 result r = pSmsManager->Construct(*pSmsListener);
637                 if (IsFailed(r) == false)
638                 {
639                         RecipientList recipient;
640                         recipient.Add(RECIPIENT_TYPE_TO,*__pActiveContactNo);
641                         SmsMessage smsMessage;
642                         String textToBeSent;
643                         //calculate msgIndex
644                         int msgIndex = IDA_SEND_REJECT_MSG1;
645                         msgIndex = actionId - msgIndex;
646                         __pRejectMessageList->GetAt(msgIndex, textToBeSent);
647                         r = smsMessage.SetText(textToBeSent);
648                         if (IsFailed(r) == false)
649                         {
650                                 r = pSmsManager->Send(smsMessage,recipient,true);
651                                 if (IsFailed(r) == true)
652                                 {
653                                         //todo: error message
654                                 }
655                         }
656                         else
657                         {
658                                 //todo: error message
659                         }
660                 }
661                 else
662                 {
663                         //todo: error message
664                 }
665                 delete pSmsListener;
666                 delete pSmsManager;
667                 /*ArrayListT<CallInfo>* pCallList  = static_cast<ArrayListT<CallInfo>*>(__pCallPresentor->GetCallListN());
668                 __pCallPresentor->HandleCallConnected(*pCallList);
669                 pCallList = null;*/
670         }
671         break;
672
673         default:
674                 break;
675         }
676 }
677
678 void
679 IncomingCallForm::OnSceneActivatedN(const SceneId& previousSceneId,     const SceneId& currentSceneId, IList* pArgs)
680 {
681         if(__pCallPresentor == null)
682         {
683                 __pCallPresentor = CallPresentationModel::GetInstance();
684         }
685         __pCallPresentor->SetTelEventListener(this);
686         HideRejectPanel();
687
688         if (__pRejectFinalVisElem != null)
689         {
690                 __pRejectFinalVisElem->Destroy();
691                 __pRejectFinalVisElem = null;
692         }
693
694         if (__pAcceptFinalVisElem != null)
695         {
696                 __pAcceptFinalVisElem->Destroy();
697                 __pAcceptFinalVisElem = null;
698         }
699         if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_VISUAL_ELE_NAME,true) == null)
700         {
701                 __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem);
702         }
703         if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_VISUAL_ELE_NAME,true) == null)
704         {
705                 __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem);
706         }
707
708         __pAcceptVisElem->SetOpacity(1.0f);
709         __pRejectVisElem->SetOpacity(1.00f);
710         for (int i = 0; i < 7; i++)
711         {
712                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
713                 String RejectVisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
714                 RejectVisualEleName.Append(i);
715                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(RejectVisualEleName,true);
716                 __pRejectArrowVisElem->SetOpacity(0.0f);
717                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
718                 String AcceptVisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
719                 AcceptVisualEleName.Append(i);
720                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(AcceptVisualEleName,true);
721                 __pAcceptArrowVisElem->SetOpacity(0.0f);
722         }
723
724
725         if (pArgs != null)
726         {
727                 //get Call Info
728                 CallInfo* pIncomingCall = static_cast<CallInfo*>(pArgs->GetAt(0));
729                 if (pIncomingCall != null)
730                 {
731                         //start alert with contact's custom ringtone
732                         __pCallPresentor->StartAlert(*pIncomingCall);
733                         //show contact number
734                         String contactNo;
735                         contactNo.Append(pIncomingCall->GetContactNumber());
736                         if (__pActiveContactNo)
737                         {
738                                 delete __pActiveContactNo;
739                                 __pActiveContactNo = null;
740                         }
741                         __incomingCallHandle = pIncomingCall->GetCallHandle()->ToLong();
742                         __pActiveContactNo = new (std::nothrow) String();
743                         __pActiveContactNo->Append(contactNo);
744                         //Show person details
745                         ShowPersonDetails(*__pActiveContactNo, IDC_NUMBER_LABEL, IDC_CALLER_LABEL, pIncomingCall);
746                         //Check if incoming call is hidden call, then do not show "Reject with Message" button
747                         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
748                         if (pButtonRejectMessage)
749                         {
750                                 //for hidden call, contact number is not present
751                                 bool showRejectMsgButton = (pIncomingCall->GetContactNumber().IsEmpty() == false);
752                                 pButtonRejectMessage->SetShowState(showRejectMsgButton);
753                                 pButtonRejectMessage->Invalidate(true);
754                         }
755                 }
756                 pArgs->RemoveAll();
757                 delete pArgs;
758                 pArgs = null;
759         }
760 }
761
762 void
763 IncomingCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
764 {
765         if (__pSmallPhotoLabel != null)
766         {
767                 RemoveControl(*__pSmallPhotoLabel);
768                 __pSmallPhotoLabel = null;
769         }
770         for (int i = 0; i < 7; i++)
771         {
772                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
773                 String RejectVisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
774                 RejectVisualEleName.Append(i);
775                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(RejectVisualEleName,true);
776                 __pRejectArrowVisElem->SetOpacity(0.0f);
777                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
778                 String AcceptVisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
779                 AcceptVisualEleName.Append(i);
780                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(AcceptVisualEleName,true);
781                 __pAcceptArrowVisElem->SetOpacity(0.0f);
782         }
783 }
784
785 result
786 IncomingCallForm::OnDraw(void)
787 {
788         Bitmap* pBackgroundWp = null;
789         // get a Canvas instance
790         Canvas* pCanvas = GetCanvasN();
791
792         pBackgroundWp = AppResource::GetInstance()->GetBitmapN(IDB_CALL_BG);
793
794         if (pCanvas)
795         {
796
797                 if (pBackgroundWp)
798                 {
799                         pCanvas->DrawBitmap(pCanvas->GetBounds(), *pBackgroundWp);
800                 }
801         }
802
803         delete pBackgroundWp;
804         pBackgroundWp = null;
805
806         delete pCanvas;
807         pCanvas = null;
808
809         return E_SUCCESS;
810 }
811
812 void
813 IncomingCallForm::HideRejectPanel(void)
814 {
815         Bitmap* pRejectMessageBitmap = null;
816         AppResource* pAppResource = AppResource::GetInstance();
817         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
818         if (pKeysPanel)
819         {
820                 pKeysPanel->SetShowState(false);
821                 Button* pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
822                 pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL);
823                 pButtonReject->AddActionEventListener(*this);
824                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
825                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, false);
826                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
827                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, true);
828
829                 pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_CREATE_BUTTON));
830                 pRejectMessageBitmap = pAppResource->GetBitmapN(IDB_CREATE_BUTTON_ICON);
831                 pRejectMessageBitmap->Scale(Dimension(W_CREATE_BITMAP, H_CREATE_BITMAP));
832                 pButtonReject->SetNormalBitmap(Point(X_CREATE_BITMAP, Y_CREATE_BITMAP), *pRejectMessageBitmap);
833                 delete pRejectMessageBitmap;
834                 pRejectMessageBitmap = null;
835
836                 pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_BACK_BUTTON));
837                 pRejectMessageBitmap = pAppResource->GetBitmapN(IDB_BACK_BUTTON_ICON);
838                 pRejectMessageBitmap->Scale(Dimension(W_CREATE_BITMAP, H_CREATE_BITMAP));
839                 pButtonReject->SetNormalBitmap(Point(X_CREATE_BITMAP, Y_CREATE_BITMAP), *pRejectMessageBitmap);
840                 pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL);
841                 pButtonReject->AddActionEventListener(*this);
842                 delete pRejectMessageBitmap;
843                 pRejectMessageBitmap = null;
844
845                 Button* pButtonCreate = static_cast<Button*>(pKeysPanel->GetControl(IDC_CREATE_BUTTON));
846                 pButtonCreate->SetActionId(IDA_CREATE_REJECT_CALL_MESSAGE);
847                 pButtonCreate->AddActionEventListener(*this);
848
849                 pKeysPanel->Invalidate(true);
850         }
851 }
852
853 void
854 IncomingCallForm::InitializeTableView(void)
855 {
856         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
857         ScrollPanel* pScrollPanel = static_cast<ScrollPanel*>(pKeysPanel->GetControl(IDC_LIST_SCROLLPANEL));
858
859         TableView* pMessageList = static_cast<TableView*>(pScrollPanel->GetControl(IDC_MSG_TABLEVIEW));
860         pMessageList->SetItemProvider(this);
861         pMessageList->AddTableViewItemEventListener(*this);
862         pScrollPanel->AddControl(*pMessageList);
863 }
864
865 ///////////////////////////////////////////////////////////////////////////////
866 /////                   Table View Functionality supporting functions                    /////
867 //////////////////////////////////////////////////////////////////////////////
868 int
869 IncomingCallForm::GetItemCount(void)
870 {
871         if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0)
872         {
873                 return (__pRejectMessageList->GetCount());
874         }
875         return 1;
876 }
877
878 TableViewItem*
879 IncomingCallForm::CreateItem(int itemIndex, int itemWidth)
880 {
881         //create a new item
882         TableViewItem* pItem = new (std::nothrow) TableViewItem();
883         pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL);
884         pItem->SetBackgroundColor(COLOR_SECONDDEPTH_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
885
886         //Message text item rectangle
887         Rectangle itemRect(X_LIST_TEXT_ITEM, 0, W_LIST_TEXT_ITEM, H_LIST_NORMAL_MENU_ITEM);
888
889         //Message
890         String itemName(L"");
891         bool isShowSendButton = true;
892         if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0)
893         {
894                 __pRejectMessageList->GetAt(itemIndex, itemName);
895         }
896         else
897         {
898                 itemName.Append(AppUtility::GetResourceString(IDS_NO_MESSAGE_STR));
899                 isShowSendButton = false;
900         }
901
902         Label* pMsgLbl = new (std::nothrow) Label();
903         pMsgLbl->Construct(itemRect, itemName);
904         pMsgLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
905         pMsgLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
906         pMsgLbl->SetTextConfig(FONT_SIZE_MSG_TXT, LABEL_TEXT_STYLE_NORMAL);
907         pMsgLbl->SetTextColor(COLOR_LIST_TEXT_NORMAL);//COLOR_LIST_TEXT_PRESSED
908         pItem->AddControl(*pMsgLbl);
909
910         //Send Button
911         if(isShowSendButton == true)
912         {
913                 String sendText = AppUtility::GetResourceString(IDS_LIST_SEND_BUTTON);
914                 Button* pSendButton = new (std::nothrow) Button();
915                 pSendButton->Construct(Rectangle(X_SEND_TEXT_ITEM, Y_SEND_TEXT_ITEM, W_SEND_TEXT_ITEM, H_SEND_TEXT_ITEM), sendText);
916                 pSendButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_SEND_BUTTON_PRESSED);
917                 pSendButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_SEND_BUTTON_NORMAL);
918                 //set action id and listener
919                 int actionId = IDA_SEND_REJECT_MSG1;
920                 switch(itemIndex)
921                 {
922                 case 0:
923                         actionId = IDA_SEND_REJECT_MSG1;
924                         break;
925                 case 1:
926                         actionId = IDA_SEND_REJECT_MSG2;
927                         break;
928                 case 2:
929                         actionId = IDA_SEND_REJECT_MSG3;
930                         break;
931                 case 3:
932                         actionId = IDA_SEND_REJECT_MSG4;
933                         break;
934                 case 4:
935                         actionId = IDA_SEND_REJECT_MSG5;
936                         break;
937                 case 5:
938                         actionId = IDA_SEND_REJECT_MSG6;
939                         break;
940                 }
941                 pSendButton->SetActionId(actionId);
942                 pSendButton->AddActionEventListener(*this);
943                 pItem->AddControl(*pSendButton);
944                 pItem->SetIndividualSelectionEnabled(pSendButton, true);
945         }
946
947         return pItem;
948 }
949
950 bool
951 IncomingCallForm::DeleteItem(int itemIndex, TableViewItem* pItem)
952 {
953         delete pItem;
954         pItem = null;
955         return true;
956 }
957
958 int
959 IncomingCallForm::GetDefaultItemHeight(void)
960 {
961         return H_LIST_NORMAL_MENU_ITEM;
962 }
963
964 void
965 IncomingCallForm::ShowPersonDetails(const String& phoneNumber, const String& contactLblName, const String& nameLblName, CallInfo* pCallInfo)
966 {
967         //call individual methods to show contact number, caller name & photo
968         SetTextToLabel(phoneNumber, contactLblName);
969
970         //fetch contact details based on phone number
971         String* pDisplayName = pCallInfo->FetchCallerNameN();
972         Bitmap* pPhotoBitmap = pCallInfo->FetchCallerPhotoN();
973         ShowCallerPhoto(pPhotoBitmap);
974
975         //free resources
976         if (pDisplayName)
977         {
978                 SetTextToLabel(*pDisplayName, nameLblName);
979                 delete pDisplayName;
980                 pDisplayName = null;
981         }
982
983         if (pPhotoBitmap)
984         {
985                 delete pPhotoBitmap;
986                 pPhotoBitmap = null;
987         }
988 }
989
990 void
991 IncomingCallForm::SetTextToLabel(const String& textToBeSet, const String& lblName)
992 {
993         Label* pContactLbl = static_cast<Label*>(GetControl(lblName));
994         //passing an empty string to SetText fails in label,
995         //if previously valid text has been set
996         if (textToBeSet.IsEmpty() == true && pContactLbl->GetText().IsEmpty() == false)
997         {
998                 String stringToBeSet(L" ");
999                 pContactLbl->SetText(stringToBeSet);
1000         }
1001
1002         else
1003         {
1004                 pContactLbl->SetText(textToBeSet);
1005         }
1006 }
1007
1008 void
1009 IncomingCallForm::ShowCallerPhoto(const Bitmap* pPhotoId)
1010 {
1011         //show photo - for Big Photo Id, Animated Call Image
1012         if (pPhotoId == null)
1013         {
1014                 pPhotoId = AppUtility::GetBitmapFromResourcesN(IDB_ACTIVE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO);
1015         }
1016
1017         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_BIG_PHOTO_LABEL));
1018         if (pPhotoLbl != null && pPhotoId != null)
1019         {
1020                 pPhotoLbl->SetBackgroundBitmap(*pPhotoId);
1021                 pPhotoLbl->Invalidate(true);
1022         }
1023 }
1024
1025 void
1026 IncomingCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
1027 {
1028         //Draw Small Photo and show on small photo label
1029         __pSmallPhotoLabel  = new (std::nothrow) Label();//static_cast<Label*>(GetControl(IDC_SMALL_PHOTO_LABEL));
1030         __pSmallPhotoLabel->Construct(Rectangle(X_PHOTO_LBL, Y_PHOTO_LBL, W_PHOTO_LBL, H_PHOTO_LBL), L"");
1031         __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0));
1032         __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId);
1033         // Add a Label to the Form
1034         AddControl(*__pSmallPhotoLabel);
1035         __pSmallPhotoLabel->Invalidate(true);
1036 }
1037
1038 void
1039 IncomingCallForm::ShowTimerInfo(const String& timerLblName, const String& textToBeDisplayed)
1040 {
1041         Label* pTimerLbl = static_cast<Label*>(GetControl(timerLblName));
1042         if (pTimerLbl != null)
1043         {
1044                 pTimerLbl->SetText(textToBeDisplayed);
1045         }
1046 }
1047
1048 void
1049 IncomingCallForm::SetBitmapToRejectMessageButton(const String& btnName, const String& bgBitmap
1050                                                                                                 , const String& arrowBitmap, const String& messageIconBitmap, bool isButtonInPanel, bool setButtonPressBitmap)
1051 {
1052
1053         Button* pButton = null;
1054         if (isButtonInPanel == false)
1055         {
1056                 pButton = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
1057         }
1058         else
1059         {
1060                 Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
1061                 pButton = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
1062         }
1063         Bitmap* pHoldBmp = null;
1064         Canvas* pCanvas = null;
1065         pCanvas = new (std::nothrow) Canvas();
1066         pCanvas->Construct(Rectangle(0,0,pButton->GetBounds().width,pButton->GetBounds().height));
1067         //set bitmap to button
1068         pHoldBmp = AppUtility::GetBitmapFromResourcesN(bgBitmap);
1069         if (pHoldBmp)
1070         {
1071                 //scale bitmap to predefined size
1072                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1073                 pHoldBmp->Scale(Dimension(W_MESSAGE_BG_BITMAP, H_MESSAGE_BG_BITMAP));
1074                 pCanvas->DrawBitmap(Rectangle(Point(0, 0), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1075         }
1076         delete pHoldBmp;
1077         pHoldBmp = null;
1078         pHoldBmp = AppUtility::GetBitmapFromResourcesN(arrowBitmap);
1079         if (pHoldBmp)
1080         {
1081                 //scale bitmap to predefined size
1082                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1083                 pHoldBmp->Scale(Dimension(W_ARROW_BITMAP, H_ARROW_BITMAP));
1084                 pCanvas->DrawBitmap(Rectangle(Point((pButton->GetBounds().width / 2 - 6), 12), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1085         }
1086         delete pHoldBmp;
1087         pHoldBmp = null;
1088         pHoldBmp = AppUtility::GetBitmapFromResourcesN(messageIconBitmap);
1089         if (pHoldBmp)
1090         {
1091                 //scale bitmap to predefined size
1092                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1093                 pHoldBmp->Scale(Dimension(W_MESSAGE_BITMAP, H_MESSAGE_BITMAP));
1094                 pCanvas->DrawBitmap(Rectangle(Point(X_MESSAGE_BITMAP, Y_MESSAGE_BITMAP), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1095         }
1096
1097         //set button name
1098         String holdBtnName = AppUtility::GetResourceString(btnName);
1099         if (!holdBtnName.IsEmpty())
1100         {
1101                 Font font;
1102                 font.Construct(FONT_STYLE_PLAIN, pButton->GetTextSize());
1103                 Dimension textDimension;
1104                 font.GetTextExtent(holdBtnName, holdBtnName.GetLength(), textDimension);
1105                 textDimension.height = textDimension.height + font.GetDescender();
1106                 TextElement* pTextElement = new (std::nothrow) TextElement();
1107                 pTextElement->Construct(holdBtnName);
1108                 Color textColor(249, 249, 249);
1109                 if (setButtonPressBitmap)
1110                 {
1111                         textColor.SetAlpha(255);
1112                 }
1113                 else
1114                 {
1115                         textColor.SetAlpha(127);
1116                 }
1117
1118                 pTextElement->SetTextColor(textColor);
1119                 pTextElement->SetFont(font);
1120
1121                 EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText();
1122                 pEnrichedText->Construct(textDimension);
1123                 pEnrichedText->Add(*pTextElement);
1124
1125                 if (pHoldBmp)
1126                 {
1127                         Point textPos((X_MESSAGE_BITMAP + pHoldBmp->GetWidth() + MESSAGE_TEXT_X_MARGIN), Y_MESSAGE_BITMAP + MESSAGE_TEXT_Y_MARGIN);
1128                         pCanvas->DrawText(textPos, *pEnrichedText);
1129                 }
1130
1131                 // Cleans up
1132                 pEnrichedText->RemoveAll(true);
1133                 delete pEnrichedText;
1134         }
1135
1136         //set background bitmpa to button
1137         Bitmap* pActualBgBmp = new (std::nothrow) Bitmap();
1138         pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds());
1139         if (setButtonPressBitmap)
1140         {
1141                 pButton->SetPressedBackgroundBitmap(*pActualBgBmp);
1142         }
1143         else
1144         {
1145                 pButton->SetNormalBackgroundBitmap(*pActualBgBmp);
1146         }
1147         delete pActualBgBmp;
1148         delete pHoldBmp;
1149         delete pCanvas;
1150 }
1151
1152 /*!In OnTouchPressed, It creates the three visual elements and starts the animation of opacity and rotation variation
1153   */
1154 void
1155 IncomingCallForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1156 {
1157         __pCallPresentor->StopAlert();
1158         if (currentPosition.x < VALID_TOUCH_X_OFFSET && currentPosition.y < VALID_TOUCH_Y_OFFSET)
1159         {
1160                 Rectangle rect = source.GetBounds();
1161                 if (source.Equals(*__pAcceptLabel))
1162                 {
1163                         __isAnswerCallStarted = true;
1164                         __isRejectCallStarted = false;
1165                 }
1166                 else if (source.Equals(*__pRejectLabel))
1167                 {
1168                         __isAnswerCallStarted = false;
1169                         __isRejectCallStarted = true;
1170                 }
1171                 else
1172                 {
1173                         // touch event between the 2 labels. So Do nothing
1174                         return;
1175                 }
1176
1177                 if (__isAnswerCallStarted)
1178                 {
1179                         for (int index = 0; index < 7; index++)
1180                         {
1181                                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(index));
1182                                 String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
1183                                 VisualEleName.Append(index);
1184                                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(VisualEleName,true);
1185                                 switch (index)
1186                                 {
1187                                 case 0:
1188                                 case 1:
1189                                 {
1190                                         __pAcceptArrowVisElem->SetOpacity(1.0f);
1191                                 }
1192                                 break;
1193
1194                                 case 2:
1195                                 case 3:
1196                                 {
1197                                         __pAcceptArrowVisElem->SetOpacity(0.8f);
1198                                 }
1199                                 break;
1200
1201                                 case 4:
1202                                 case 5:
1203                                 case 6:
1204                                 {
1205                                         __pAcceptArrowVisElem->SetOpacity(0.6f);
1206                                 }
1207                                 break;
1208                                 }
1209
1210                         }
1211                 }
1212                 else
1213                 {
1214                         for (int index = 0; index < 7; index++)
1215                         {
1216                                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(index));
1217                                 String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
1218                                 VisualEleName.Append(index);
1219                                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(VisualEleName,true);
1220                                 switch (index)
1221                                 {
1222                                 case 0:
1223                                 case 1:
1224                                 {
1225                                         __pRejectArrowVisElem->SetOpacity(0.6f);
1226                                 }
1227                                 break;
1228
1229                                 case 2:
1230                                 case 3:
1231                                 {
1232                                         __pRejectArrowVisElem->SetOpacity(0.8f);
1233                                 }
1234                                 break;
1235
1236                                 case 4:
1237                                 case 5:
1238                                 case 6:
1239                                 {
1240                                         __pRejectArrowVisElem->SetOpacity(1.0f);
1241                                 }
1242                                 break;
1243                                 }
1244
1245                         }
1246                 }
1247         }
1248 }
1249
1250 // On Touch released, the animation and the visual elements disappear
1251 void
1252 IncomingCallForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1253 {
1254         if (__isAnswerCallStarted == true)
1255         {
1256                 if (currentPosition.x > REJECT_LABEL_X_OFFSET)
1257                 {
1258                         //Right reject icon
1259                         __pRejectFinalVisElem = new (std::nothrow) VisualElement();
1260                         __pRejectFinalVisElem->Construct();
1261                         __pRejectFinalVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1262                         __pRejectFinalVisElem->SetShowState(true);
1263                         __pRejectFinalVisElem->SetOpacity(1.00f);
1264                         __pRejectFinalVisElem->SetName(IDI_REJECT_FINAL_VISUAL_ELE_NAME);
1265                         __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectFinalVisElem);
1266                         Canvas* pCanvas = __pRejectFinalVisElem->GetCanvasN();
1267                         if(pCanvas != null)
1268                         {
1269                                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
1270                                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1271                                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, W_DIAL_LABEL), *__pAcceptCircle);
1272                                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pAcceptDial);
1273                                 delete pCanvas;
1274                         }
1275
1276                         __pAcceptVisElem->SetOpacity(0.0f);
1277                         //fetch already active call list
1278                         ArrayListT<CallInfo>* pCallList  = static_cast<ArrayListT<CallInfo>*>(__pCallPresentor->GetCallListN());
1279                         if (pCallList != null && pCallList->GetCount() > 0)
1280                         {
1281                                 //then atleast 1 active call exist.
1282                                 CallInfo phnCallInfo;
1283                                 pCallList->GetAt(0,phnCallInfo);
1284                                 //Check if only 1 call exist and it is on Hold
1285                                 if(pCallList->GetCount() == 1 && phnCallInfo.IsOnHold())
1286                                 {
1287                                         //directly accept call
1288                                         __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_CALL,__incomingCallHandle);
1289                                 }
1290                                 else
1291                                 {
1292                                         //Either 1 call exist and not "on Hold".
1293                                         //Or 2 calls exist.
1294                                         if(__pOptionPopup != null)
1295                                         {
1296                                                 delete __pOptionPopup;
1297                                                 __pOptionPopup = null;
1298                                         }
1299                                         __pOptionPopup = new (std::nothrow) CallOptionPopup(*this,*(__pCallPresentor));
1300                                         __pOptionPopup->Initialize();
1301                                         __pOptionPopup->SetShowState(true);
1302                                         __pOptionPopup->Draw();
1303                                         __pOptionPopup->Show();
1304                                 }
1305                                 pCallList->RemoveAll();
1306                         }
1307                         else
1308                         {
1309                                 //no active call - Accept the  incoming call
1310                                 __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_CALL,__incomingCallHandle);
1311                         }
1312                         delete pCallList;
1313                         pCallList = null;
1314                 }
1315                 else
1316                 {
1317                         __pAcceptVisElem->SetOpacity(1.0f);
1318                         __pRejectVisElem->SetOpacity(1.00f);
1319                         for (int i = 0; i < 7; i++)
1320                         {
1321                                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
1322                                 String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
1323                                 VisualEleName.Append(i);
1324                                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(VisualEleName,true);
1325                                 __pAcceptArrowVisElem->SetOpacity(0.0f);
1326
1327                         }
1328                 }
1329         }
1330         else if (__isRejectCallStarted == true)
1331         {
1332                 if (currentPosition.x < ACCEPT_LABEL_RELATIVE_POS)
1333                 {
1334                         //left dial icon
1335                         __pAcceptFinalVisElem = new (std::nothrow) VisualElement();
1336                         __pAcceptFinalVisElem->Construct();
1337                         __pAcceptFinalVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1338                         __pAcceptFinalVisElem->SetShowState(true);
1339                         __pAcceptFinalVisElem->SetOpacity(1.0f);
1340                         __pAcceptFinalVisElem->SetName(IDI_ACCEPT_FINAL_VISUAL_ELE_NAME);
1341                         __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptFinalVisElem);
1342                         Canvas* pCanvas = __pAcceptFinalVisElem->GetCanvasN();
1343                         if(pCanvas != null)
1344                         {
1345                                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
1346                                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1347                                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pRejectDial);
1348                                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pRejectCircle);
1349                                 delete pCanvas;
1350                         }
1351                         __pRejectVisElem->SetOpacity(0.0f);
1352                         //Reject the call
1353                         __pCallPresentor->RejectCall(__incomingCallHandle, false,*__pActiveContactNo);
1354                 }
1355                 else
1356                 {
1357                         __pAcceptVisElem->SetOpacity(1.0f);
1358                         __pRejectVisElem->SetOpacity(1.00f);
1359                         for (int i = 0; i < 7; i++)
1360                         {
1361                                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
1362                                 String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
1363                                 VisualEleName.Append(i);
1364                                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(VisualEleName,true);
1365                                 __pRejectArrowVisElem->SetOpacity(0.0f);
1366
1367                         }
1368                 }
1369         }
1370         __isAnswerCallStarted = false;
1371         __isRejectCallStarted = false;
1372 }
1373
1374 void
1375 IncomingCallForm::OnTouchMoved(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1376 {
1377         if (__isAnswerCallStarted == true)
1378         {
1379                 if (currentPosition.x > 170 && currentPosition.x < 578)
1380                 {
1381                         if (currentPosition.x > REJECT_LABEL_X_OFFSET)
1382                         {
1383                                 __pRejectVisElem->SetOpacity(0.60f);
1384                                 __pAcceptVisElem->SetOpacity(0.60f);
1385                         }
1386                         else
1387                         {
1388                                 __pRejectVisElem->SetOpacity(1.0f);
1389                                 __pAcceptVisElem->SetOpacity(1.0f);
1390                         }
1391                         for (int index = 0; index < 7; index++)
1392                         {
1393                                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(index));
1394                                 String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
1395                                 VisualEleName.Append(index);
1396                                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(VisualEleName,true);
1397                                 switch (index)
1398                                 {
1399                                 case 0:
1400                                 case 1:
1401                                 {
1402                                         if (currentPosition.x > 360)
1403                                         {
1404                                                 __pAcceptArrowVisElem->SetOpacity(0.6f);
1405                                         }
1406                                         else
1407                                         {
1408                                                 __pAcceptArrowVisElem->SetOpacity(1.0f);
1409                                         }
1410                                 }
1411                                 break;
1412
1413                                 case 2:
1414                                 case 3:
1415                                 {
1416                                         __pAcceptArrowVisElem->SetOpacity(0.8f);
1417                                 }
1418                                 break;
1419
1420                                 case 4:
1421                                 case 5:
1422                                 case 6:
1423                                 {
1424                                         if (currentPosition.x < 360)
1425                                         {
1426                                                 __pAcceptArrowVisElem->SetOpacity(0.6f);
1427                                         }
1428                                         else
1429                                         {
1430                                                 __pAcceptArrowVisElem->SetOpacity(1.0f);
1431                                         }
1432                                 }
1433                                 break;
1434                                 }
1435                         }
1436                 }
1437         }
1438         if (__isRejectCallStarted == true)
1439         {
1440                 if (currentPosition.x < 0 && currentPosition.x > -522)
1441                 {
1442                         if (currentPosition.x < ACCEPT_LABEL_RELATIVE_POS)
1443                         {
1444                                 __pRejectVisElem->SetOpacity(0.60f);
1445                                 __pAcceptVisElem->SetOpacity(0.60f);
1446                         }
1447                         else
1448                         {
1449                                 __pRejectVisElem->SetOpacity(1.0f);
1450                                 __pAcceptVisElem->SetOpacity(1.0f);
1451                         }
1452                         for (int index = 0; index < 7; index++)
1453                         {
1454                                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(index));
1455                                 String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
1456                                 VisualEleName.Append(index);
1457                                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(VisualEleName,true);
1458                                 switch (index)
1459                                 {
1460                                 case 0:
1461                                 case 1:
1462                                 {
1463                                         if (currentPosition.x > -180)
1464                                         {
1465                                                 __pRejectArrowVisElem->SetOpacity(0.6f);
1466                                         }
1467                                         else
1468                                         {
1469                                                 __pRejectArrowVisElem->SetOpacity(1.0f);
1470                                         }
1471                                 }
1472                                 break;
1473
1474                                 case 2:
1475                                 case 3:
1476                                 {
1477                                         __pRejectArrowVisElem->SetOpacity(0.8f);
1478                                 }
1479                                 break;
1480
1481                                 case 4:
1482                                 case 5:
1483                                 case 6:
1484                                 {
1485                                         if (currentPosition.x < -180)
1486                                         {
1487                                                 __pRejectArrowVisElem->SetOpacity(0.6f);
1488                                         }
1489                                         else
1490                                         {
1491                                                 __pRejectArrowVisElem->SetOpacity(1.0f);
1492                                         }
1493                                 }
1494                                 break;
1495                                 }
1496                         }
1497                 }
1498         }
1499 }
1500
1501 void
1502 IncomingCallForm::OnItemSelected(int itemIndex)
1503 {
1504         ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1505         pArgs->Construct();
1506
1507         //display name, mobile number
1508         Integer* argIndex = new (std::nothrow) Integer(itemIndex);
1509         pArgs->Add(argIndex);
1510         SendUserEvent(REQUEST_ITEM_SELECTED,pArgs);
1511 }
1512
1513 void
1514 IncomingCallForm::HandleMultipleCallSelection(int itemIndex)
1515 {
1516
1517         if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_VISUAL_ELE_NAME,true) == null)
1518         {
1519                 __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem);
1520         }
1521         if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_VISUAL_ELE_NAME,true) == null)
1522         {
1523                 __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem);
1524         }
1525
1526         __pAcceptVisElem->SetOpacity(1.0f);
1527         __pRejectVisElem->SetOpacity(1.00f);
1528
1529         for (int i = 0; i < 7; i++)
1530         {
1531                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
1532                 String RejectVisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
1533                 RejectVisualEleName.Append(i);
1534                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(RejectVisualEleName,true);
1535                 __pRejectArrowVisElem->SetOpacity(0.0f);
1536                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
1537                 String AcceptVisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
1538                 AcceptVisualEleName.Append(i);
1539                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(AcceptVisualEleName,true);
1540                 __pAcceptArrowVisElem->SetOpacity(0.0f);
1541         }
1542         if (__pRejectFinalVisElem != null)
1543         {
1544                 __pRejectFinalVisElem->Destroy();
1545                 __pRejectFinalVisElem = null;
1546         }
1547
1548         if (__pAcceptFinalVisElem != null)
1549         {
1550                 __pAcceptFinalVisElem->Destroy();
1551                 __pAcceptFinalVisElem = null;
1552         }
1553         if (__pOptionPopup)
1554         {
1555                 delete __pOptionPopup;
1556                 __pOptionPopup = null;
1557         }
1558         switch (itemIndex)
1559         {
1560         case ID_SECOND_INCOMING_CALL:
1561         {
1562                 //Accept call After putting on hold
1563                 __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_HOLD_ACCEPT,__incomingCallHandle);
1564         }
1565         break;
1566         case ID_SECOND_INCOMING_CALL + 1:
1567         {
1568                 //Accept call After ending active call
1569                 __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_END_ACTIVE_ACCEPT,__incomingCallHandle);
1570         }
1571         break;
1572         case ID_MULTI_PARTY_CALL:
1573         {
1574                 //Accept call After ending active call
1575                 __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_END_ACTIVE_ACCEPT,__incomingCallHandle);
1576         }
1577         break;
1578         case ID_MULTI_PARTY_CALL + 1:
1579         {
1580                 //Accept call After ending held call
1581                 __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_END_HELD_ACCEPT,__incomingCallHandle);
1582         }
1583         break;
1584         case ID_MULTI_PARTY_CALL + 2:
1585         {
1586                 //Accept call After ending all calls
1587                 __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_END_ALL_ACCEPT,__incomingCallHandle);
1588         }
1589         break;
1590         default:
1591                 break;
1592         }
1593 }
1594
1595 void
1596 IncomingCallForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1597 {
1598         switch(requestId)
1599         {
1600                 case REQUEST_ITEM_SELECTED:
1601                 {
1602                         if(pArgs != null)
1603                         {
1604                                 Integer *index = static_cast<Integer*>(pArgs->GetAt(0));
1605                                 if(index != null)
1606                                 {
1607                                         HandleMultipleCallSelection(index->ToInt());
1608                                 }
1609                         }
1610
1611                 }
1612                 break;
1613         }
1614
1615 }