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