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                 Canvas* pCanvas = new (std::nothrow) Canvas;
1021                 Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1022                 pCanvas->Construct(canvasRect);
1023                 //draw the contact bitmap
1024                 pCanvas->DrawBitmap(canvasRect,*pPhotoId);
1025                 Bitmap* pNewPhotoId = new Bitmap();
1026                 pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1027                 delete pCanvas;
1028
1029                 pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1030                 pPhotoLbl->Invalidate(true);
1031                 delete pNewPhotoId;
1032         }
1033 }
1034
1035 void
1036 IncomingCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
1037 {
1038         //Draw Small Photo and show on small photo label
1039         __pSmallPhotoLabel  = new (std::nothrow) Label();//static_cast<Label*>(GetControl(IDC_SMALL_PHOTO_LABEL));
1040         __pSmallPhotoLabel->Construct(Rectangle(X_PHOTO_LBL, Y_PHOTO_LBL, W_PHOTO_LBL, H_PHOTO_LBL), L"");
1041         __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0));
1042         __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId);
1043         // Add a Label to the Form
1044         AddControl(*__pSmallPhotoLabel);
1045         __pSmallPhotoLabel->Invalidate(true);
1046 }
1047
1048 void
1049 IncomingCallForm::ShowTimerInfo(const String& timerLblName, const String& textToBeDisplayed)
1050 {
1051         Label* pTimerLbl = static_cast<Label*>(GetControl(timerLblName));
1052         if (pTimerLbl != null)
1053         {
1054                 pTimerLbl->SetText(textToBeDisplayed);
1055         }
1056 }
1057
1058 void
1059 IncomingCallForm::SetBitmapToRejectMessageButton(const String& btnName, const String& bgBitmap
1060                                                                                                 , const String& arrowBitmap, const String& messageIconBitmap, bool isButtonInPanel, bool setButtonPressBitmap)
1061 {
1062
1063         Button* pButton = null;
1064         if (isButtonInPanel == false)
1065         {
1066                 pButton = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
1067         }
1068         else
1069         {
1070                 Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
1071                 pButton = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
1072         }
1073         Bitmap* pHoldBmp = null;
1074         Canvas* pCanvas = null;
1075         pCanvas = new (std::nothrow) Canvas();
1076         pCanvas->Construct(Rectangle(0,0,pButton->GetBounds().width,pButton->GetBounds().height));
1077         //set bitmap to button
1078         pHoldBmp = AppUtility::GetBitmapFromResourcesN(bgBitmap);
1079         if (pHoldBmp)
1080         {
1081                 //scale bitmap to predefined size
1082                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1083                 pHoldBmp->Scale(Dimension(W_MESSAGE_BG_BITMAP, H_MESSAGE_BG_BITMAP));
1084                 pCanvas->DrawBitmap(Rectangle(Point(0, 0), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1085         }
1086         delete pHoldBmp;
1087         pHoldBmp = null;
1088         pHoldBmp = AppUtility::GetBitmapFromResourcesN(arrowBitmap);
1089         if (pHoldBmp)
1090         {
1091                 //scale bitmap to predefined size
1092                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1093                 pHoldBmp->Scale(Dimension(W_ARROW_BITMAP, H_ARROW_BITMAP));
1094                 pCanvas->DrawBitmap(Rectangle(Point((pButton->GetBounds().width / 2 - 6), 12), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1095         }
1096         delete pHoldBmp;
1097         pHoldBmp = null;
1098         pHoldBmp = AppUtility::GetBitmapFromResourcesN(messageIconBitmap);
1099         if (pHoldBmp)
1100         {
1101                 //scale bitmap to predefined size
1102                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1103                 pHoldBmp->Scale(Dimension(W_MESSAGE_BITMAP, H_MESSAGE_BITMAP));
1104                 pCanvas->DrawBitmap(Rectangle(Point(X_MESSAGE_BITMAP, Y_MESSAGE_BITMAP), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1105         }
1106
1107         //set button name
1108         String holdBtnName = AppUtility::GetResourceString(btnName);
1109         if (!holdBtnName.IsEmpty())
1110         {
1111                 Font font;
1112                 font.Construct(FONT_STYLE_PLAIN, pButton->GetTextSize());
1113                 Dimension textDimension;
1114                 font.GetTextExtent(holdBtnName, holdBtnName.GetLength(), textDimension);
1115                 textDimension.height = textDimension.height + font.GetDescender();
1116                 TextElement* pTextElement = new (std::nothrow) TextElement();
1117                 pTextElement->Construct(holdBtnName);
1118                 Color textColor(249, 249, 249);
1119                 if (setButtonPressBitmap)
1120                 {
1121                         textColor.SetAlpha(255);
1122                 }
1123                 else
1124                 {
1125                         textColor.SetAlpha(127);
1126                 }
1127
1128                 pTextElement->SetTextColor(textColor);
1129                 pTextElement->SetFont(font);
1130
1131                 EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText();
1132                 pEnrichedText->Construct(textDimension);
1133                 pEnrichedText->Add(*pTextElement);
1134
1135                 if (pHoldBmp)
1136                 {
1137                         Point textPos((X_MESSAGE_BITMAP + pHoldBmp->GetWidth() + MESSAGE_TEXT_X_MARGIN), Y_MESSAGE_BITMAP + MESSAGE_TEXT_Y_MARGIN);
1138                         pCanvas->DrawText(textPos, *pEnrichedText);
1139                 }
1140
1141                 // Cleans up
1142                 pEnrichedText->RemoveAll(true);
1143                 delete pEnrichedText;
1144         }
1145
1146         //set background bitmpa to button
1147         Bitmap* pActualBgBmp = new (std::nothrow) Bitmap();
1148         pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds());
1149         if (setButtonPressBitmap)
1150         {
1151                 pButton->SetPressedBackgroundBitmap(*pActualBgBmp);
1152         }
1153         else
1154         {
1155                 pButton->SetNormalBackgroundBitmap(*pActualBgBmp);
1156         }
1157         delete pActualBgBmp;
1158         delete pHoldBmp;
1159         delete pCanvas;
1160 }
1161
1162 /*!In OnTouchPressed, It creates the three visual elements and starts the animation of opacity and rotation variation
1163   */
1164 void
1165 IncomingCallForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1166 {
1167         __pCallPresentor->StopAlert();
1168         if (currentPosition.x < VALID_TOUCH_X_OFFSET && currentPosition.y < VALID_TOUCH_Y_OFFSET)
1169         {
1170                 Rectangle rect = source.GetBounds();
1171                 if (source.Equals(*__pAcceptLabel))
1172                 {
1173                         __isAnswerCallStarted = true;
1174                         __isRejectCallStarted = false;
1175                 }
1176                 else if (source.Equals(*__pRejectLabel))
1177                 {
1178                         __isAnswerCallStarted = false;
1179                         __isRejectCallStarted = true;
1180                 }
1181                 else
1182                 {
1183                         // touch event between the 2 labels. So Do nothing
1184                         return;
1185                 }
1186
1187                 if (__isAnswerCallStarted)
1188                 {
1189                         for (int index = 0; index < 7; index++)
1190                         {
1191                                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(index));
1192                                 String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
1193                                 VisualEleName.Append(index);
1194                                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(VisualEleName,true);
1195                                 switch (index)
1196                                 {
1197                                 case 0:
1198                                 case 1:
1199                                 {
1200                                         __pAcceptArrowVisElem->SetOpacity(1.0f);
1201                                 }
1202                                 break;
1203
1204                                 case 2:
1205                                 case 3:
1206                                 {
1207                                         __pAcceptArrowVisElem->SetOpacity(0.8f);
1208                                 }
1209                                 break;
1210
1211                                 case 4:
1212                                 case 5:
1213                                 case 6:
1214                                 {
1215                                         __pAcceptArrowVisElem->SetOpacity(0.6f);
1216                                 }
1217                                 break;
1218                                 }
1219
1220                         }
1221                 }
1222                 else
1223                 {
1224                         for (int index = 0; index < 7; index++)
1225                         {
1226                                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(index));
1227                                 String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
1228                                 VisualEleName.Append(index);
1229                                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(VisualEleName,true);
1230                                 switch (index)
1231                                 {
1232                                 case 0:
1233                                 case 1:
1234                                 {
1235                                         __pRejectArrowVisElem->SetOpacity(0.6f);
1236                                 }
1237                                 break;
1238
1239                                 case 2:
1240                                 case 3:
1241                                 {
1242                                         __pRejectArrowVisElem->SetOpacity(0.8f);
1243                                 }
1244                                 break;
1245
1246                                 case 4:
1247                                 case 5:
1248                                 case 6:
1249                                 {
1250                                         __pRejectArrowVisElem->SetOpacity(1.0f);
1251                                 }
1252                                 break;
1253                                 }
1254
1255                         }
1256                 }
1257         }
1258 }
1259
1260 // On Touch released, the animation and the visual elements disappear
1261 void
1262 IncomingCallForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1263 {
1264         if (__isAnswerCallStarted == true)
1265         {
1266                 if (currentPosition.x > REJECT_LABEL_X_OFFSET)
1267                 {
1268                         //Right reject icon
1269                         __pRejectFinalVisElem = new (std::nothrow) VisualElement();
1270                         __pRejectFinalVisElem->Construct();
1271                         __pRejectFinalVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1272                         __pRejectFinalVisElem->SetShowState(true);
1273                         __pRejectFinalVisElem->SetOpacity(1.00f);
1274                         __pRejectFinalVisElem->SetName(IDI_REJECT_FINAL_VISUAL_ELE_NAME);
1275                         __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectFinalVisElem);
1276                         Canvas* pCanvas = __pRejectFinalVisElem->GetCanvasN();
1277                         if(pCanvas != null)
1278                         {
1279                                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
1280                                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1281                                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, W_DIAL_LABEL), *__pAcceptCircle);
1282                                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pAcceptDial);
1283                                 delete pCanvas;
1284                         }
1285
1286                         __pAcceptVisElem->SetOpacity(0.0f);
1287                         //fetch already active call list
1288                         ArrayListT<CallInfo>* pCallList  = static_cast<ArrayListT<CallInfo>*>(__pCallPresentor->GetCallListN());
1289                         if (pCallList != null && pCallList->GetCount() > 0)
1290                         {
1291                                 //then atleast 1 active call exist.
1292                                 CallInfo phnCallInfo;
1293                                 pCallList->GetAt(0,phnCallInfo);
1294                                 //Check if only 1 call exist and it is on Hold
1295                                 if(pCallList->GetCount() == 1 && phnCallInfo.IsOnHold())
1296                                 {
1297                                         //directly accept call
1298                                         __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_CALL,__incomingCallHandle);
1299                                 }
1300                                 else
1301                                 {
1302                                         //Either 1 call exist and not "on Hold".
1303                                         //Or 2 calls exist.
1304                                         if(__pOptionPopup != null)
1305                                         {
1306                                                 delete __pOptionPopup;
1307                                                 __pOptionPopup = null;
1308                                         }
1309                                         __pOptionPopup = new (std::nothrow) CallOptionPopup(*this,*(__pCallPresentor));
1310                                         __pOptionPopup->Initialize();
1311                                         __pOptionPopup->SetShowState(true);
1312                                         __pOptionPopup->Draw();
1313                                         __pOptionPopup->Show();
1314                                 }
1315                                 pCallList->RemoveAll();
1316                         }
1317                         else
1318                         {
1319                                 //no active call - Accept the  incoming call
1320                                 __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_CALL,__incomingCallHandle);
1321                         }
1322                         delete pCallList;
1323                         pCallList = null;
1324                 }
1325                 else
1326                 {
1327                         __pAcceptVisElem->SetOpacity(1.0f);
1328                         __pRejectVisElem->SetOpacity(1.00f);
1329                         for (int i = 0; i < 7; i++)
1330                         {
1331                                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
1332                                 String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
1333                                 VisualEleName.Append(i);
1334                                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(VisualEleName,true);
1335                                 __pAcceptArrowVisElem->SetOpacity(0.0f);
1336
1337                         }
1338                 }
1339         }
1340         else if (__isRejectCallStarted == true)
1341         {
1342                 if (currentPosition.x < ACCEPT_LABEL_RELATIVE_POS)
1343                 {
1344                         //left dial icon
1345                         __pAcceptFinalVisElem = new (std::nothrow) VisualElement();
1346                         __pAcceptFinalVisElem->Construct();
1347                         __pAcceptFinalVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1348                         __pAcceptFinalVisElem->SetShowState(true);
1349                         __pAcceptFinalVisElem->SetOpacity(1.0f);
1350                         __pAcceptFinalVisElem->SetName(IDI_ACCEPT_FINAL_VISUAL_ELE_NAME);
1351                         __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptFinalVisElem);
1352                         Canvas* pCanvas = __pAcceptFinalVisElem->GetCanvasN();
1353                         if(pCanvas != null)
1354                         {
1355                                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
1356                                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1357                                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pRejectDial);
1358                                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pRejectCircle);
1359                                 delete pCanvas;
1360                         }
1361                         __pRejectVisElem->SetOpacity(0.0f);
1362                         //Reject the call
1363                         __pCallPresentor->RejectCall(__incomingCallHandle, false,*__pActiveContactNo);
1364                 }
1365                 else
1366                 {
1367                         __pAcceptVisElem->SetOpacity(1.0f);
1368                         __pRejectVisElem->SetOpacity(1.00f);
1369                         for (int i = 0; i < 7; i++)
1370                         {
1371                                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
1372                                 String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
1373                                 VisualEleName.Append(i);
1374                                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(VisualEleName,true);
1375                                 __pRejectArrowVisElem->SetOpacity(0.0f);
1376
1377                         }
1378                 }
1379         }
1380         __isAnswerCallStarted = false;
1381         __isRejectCallStarted = false;
1382 }
1383
1384 void
1385 IncomingCallForm::OnTouchMoved(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1386 {
1387         if (__isAnswerCallStarted == true)
1388         {
1389                 if (currentPosition.x > 170 && currentPosition.x < 578)
1390                 {
1391                         if (currentPosition.x > REJECT_LABEL_X_OFFSET)
1392                         {
1393                                 __pRejectVisElem->SetOpacity(0.60f);
1394                                 __pAcceptVisElem->SetOpacity(0.60f);
1395                         }
1396                         else
1397                         {
1398                                 __pRejectVisElem->SetOpacity(1.0f);
1399                                 __pAcceptVisElem->SetOpacity(1.0f);
1400                         }
1401                         for (int index = 0; index < 7; index++)
1402                         {
1403                                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(index));
1404                                 String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
1405                                 VisualEleName.Append(index);
1406                                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(VisualEleName,true);
1407                                 switch (index)
1408                                 {
1409                                 case 0:
1410                                 case 1:
1411                                 {
1412                                         if (currentPosition.x > 360)
1413                                         {
1414                                                 __pAcceptArrowVisElem->SetOpacity(0.6f);
1415                                         }
1416                                         else
1417                                         {
1418                                                 __pAcceptArrowVisElem->SetOpacity(1.0f);
1419                                         }
1420                                 }
1421                                 break;
1422
1423                                 case 2:
1424                                 case 3:
1425                                 {
1426                                         __pAcceptArrowVisElem->SetOpacity(0.8f);
1427                                 }
1428                                 break;
1429
1430                                 case 4:
1431                                 case 5:
1432                                 case 6:
1433                                 {
1434                                         if (currentPosition.x < 360)
1435                                         {
1436                                                 __pAcceptArrowVisElem->SetOpacity(0.6f);
1437                                         }
1438                                         else
1439                                         {
1440                                                 __pAcceptArrowVisElem->SetOpacity(1.0f);
1441                                         }
1442                                 }
1443                                 break;
1444                                 }
1445                         }
1446                 }
1447         }
1448         if (__isRejectCallStarted == true)
1449         {
1450                 if (currentPosition.x < 0 && currentPosition.x > -522)
1451                 {
1452                         if (currentPosition.x < ACCEPT_LABEL_RELATIVE_POS)
1453                         {
1454                                 __pRejectVisElem->SetOpacity(0.60f);
1455                                 __pAcceptVisElem->SetOpacity(0.60f);
1456                         }
1457                         else
1458                         {
1459                                 __pRejectVisElem->SetOpacity(1.0f);
1460                                 __pAcceptVisElem->SetOpacity(1.0f);
1461                         }
1462                         for (int index = 0; index < 7; index++)
1463                         {
1464                                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(index));
1465                                 String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
1466                                 VisualEleName.Append(index);
1467                                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(VisualEleName,true);
1468                                 switch (index)
1469                                 {
1470                                 case 0:
1471                                 case 1:
1472                                 {
1473                                         if (currentPosition.x > -180)
1474                                         {
1475                                                 __pRejectArrowVisElem->SetOpacity(0.6f);
1476                                         }
1477                                         else
1478                                         {
1479                                                 __pRejectArrowVisElem->SetOpacity(1.0f);
1480                                         }
1481                                 }
1482                                 break;
1483
1484                                 case 2:
1485                                 case 3:
1486                                 {
1487                                         __pRejectArrowVisElem->SetOpacity(0.8f);
1488                                 }
1489                                 break;
1490
1491                                 case 4:
1492                                 case 5:
1493                                 case 6:
1494                                 {
1495                                         if (currentPosition.x < -180)
1496                                         {
1497                                                 __pRejectArrowVisElem->SetOpacity(0.6f);
1498                                         }
1499                                         else
1500                                         {
1501                                                 __pRejectArrowVisElem->SetOpacity(1.0f);
1502                                         }
1503                                 }
1504                                 break;
1505                                 }
1506                         }
1507                 }
1508         }
1509 }
1510
1511 void
1512 IncomingCallForm::OnItemSelected(int itemIndex)
1513 {
1514         ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1515         pArgs->Construct();
1516
1517         //display name, mobile number
1518         Integer* argIndex = new (std::nothrow) Integer(itemIndex);
1519         pArgs->Add(argIndex);
1520         SendUserEvent(REQUEST_ITEM_SELECTED,pArgs);
1521 }
1522
1523 void
1524 IncomingCallForm::HandleMultipleCallSelection(int itemIndex)
1525 {
1526
1527         if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_VISUAL_ELE_NAME,true) == null)
1528         {
1529                 __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem);
1530         }
1531         if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_VISUAL_ELE_NAME,true) == null)
1532         {
1533                 __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem);
1534         }
1535
1536         __pAcceptVisElem->SetOpacity(1.0f);
1537         __pRejectVisElem->SetOpacity(1.00f);
1538
1539         for (int i = 0; i < 7; i++)
1540         {
1541                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
1542                 String RejectVisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
1543                 RejectVisualEleName.Append(i);
1544                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(RejectVisualEleName,true);
1545                 __pRejectArrowVisElem->SetOpacity(0.0f);
1546                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
1547                 String AcceptVisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
1548                 AcceptVisualEleName.Append(i);
1549                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(AcceptVisualEleName,true);
1550                 __pAcceptArrowVisElem->SetOpacity(0.0f);
1551         }
1552         if (__pRejectFinalVisElem != null)
1553         {
1554                 __pRejectFinalVisElem->Destroy();
1555                 __pRejectFinalVisElem = null;
1556         }
1557
1558         if (__pAcceptFinalVisElem != null)
1559         {
1560                 __pAcceptFinalVisElem->Destroy();
1561                 __pAcceptFinalVisElem = null;
1562         }
1563         if (__pOptionPopup)
1564         {
1565                 delete __pOptionPopup;
1566                 __pOptionPopup = null;
1567         }
1568         switch (itemIndex)
1569         {
1570         case ID_SECOND_INCOMING_CALL:
1571         {
1572                 //Accept call After putting on hold
1573                 __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_HOLD_ACCEPT,__incomingCallHandle);
1574         }
1575         break;
1576         case ID_SECOND_INCOMING_CALL + 1:
1577         {
1578                 //Accept call After ending active call
1579                 __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_END_ACTIVE_ACCEPT,__incomingCallHandle);
1580         }
1581         break;
1582         case ID_MULTI_PARTY_CALL:
1583         {
1584                 //Accept call After ending active call
1585                 __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_END_ACTIVE_ACCEPT,__incomingCallHandle);
1586         }
1587         break;
1588         case ID_MULTI_PARTY_CALL + 1:
1589         {
1590                 //Accept call After ending held call
1591                 __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_END_HELD_ACCEPT,__incomingCallHandle);
1592         }
1593         break;
1594         case ID_MULTI_PARTY_CALL + 2:
1595         {
1596                 //Accept call After ending all calls
1597                 __pCallPresentor->AcceptIncomingCall(CALL_ANSWER_END_ALL_ACCEPT,__incomingCallHandle);
1598         }
1599         break;
1600         default:
1601                 break;
1602         }
1603 }
1604
1605 void
1606 IncomingCallForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1607 {
1608         switch(requestId)
1609         {
1610                 case REQUEST_ITEM_SELECTED:
1611                 {
1612                         if(pArgs != null)
1613                         {
1614                                 Integer *index = static_cast<Integer*>(pArgs->GetAt(0));
1615                                 if(index != null)
1616                                 {
1617                                         HandleMultipleCallSelection(index->ToInt());
1618                                 }
1619                         }
1620
1621                 }
1622                 break;
1623         }
1624
1625 }