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