Fixed N_SE-38563, N_SE-38552
[apps/osp/Settings.git] / src / StNfcForm.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                StNfcForm.cpp
19  * @brief               This is the implementation file for NfcForm class.
20  */
21
22 #include <FSystem.h>
23 #include "StNfcForm.h"
24 #include "StResourceManager.h"
25 #include "StSettingScenesList.h"
26 #include "StTypes.h"
27
28 using namespace Tizen::App;
29 using namespace Tizen::App::Package;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::System;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Controls;
36 using namespace Tizen::Ui::Scenes;
37
38 static const int ID_GROUP_NFC = 0;
39 static const int ID_GROUP_NFC_ITEM_COUNT = 1;
40
41 static const int ID_GROUP_NFC_HELP = 1;
42 static const int ID_GROUP_NFC_HELP_TEXT_LABEL = -1;
43
44 static const int ID_GROUP_NFC_PREDEFINED_ITEM = 2;
45 static const int ID_GROUP_NFC_PREDEFINED_ITEM_COUNT = 1;
46 static const int ID_GROUP_ITEM_NFC_PREDEFINED_ITEM = 0;
47
48 static const int ID_GROUP_NFC_PREDEFINED_ITEM_HELP = 3;
49 static const int ID_GROUP_NFC_PREDEFINED_ITEM_HELP_TEXT_LABEL = -1;
50
51 static const int NFC_NOT_SUPPORT_PREDEFINED_ITEM_GROUP_COUNT = 2;
52 static const int NFC_SUPPORT_PREDEFINED_ITEM_GROUP_COUNT = 4;
53 static const int W_TEXT_GAP = 30;
54 static const int H_TEXT_GAP = 20;
55
56 NfcForm::NfcForm(void)
57         : __pNfcPresentationModelInstance(null)
58         , __pNfcPredefinedItemPresentationModelInstance(null)
59         , __isPredefinedItem(false)
60         , __isNfcBusy(false)
61 {
62 }
63
64 NfcForm::~NfcForm(void)
65 {
66 }
67
68 void
69 NfcForm::CreateFooter(void)
70 {
71         Footer* pFooter = GetFooter();
72         AppAssert(pFooter);
73
74         pFooter->SetBackButton();
75         SetFormBackEventListener(this);
76 }
77
78 result
79 NfcForm::OnInitializing(void)
80 {
81         CreateHeader(ResourceManager::GetString(L"IDS_NFC_BODY_NFC"));
82         CreateFooter();
83         CreateTableView();
84
85         return E_SUCCESS;
86 }
87
88 result
89 NfcForm::OnTerminating(void)
90 {
91         SetFormBackEventListener(null);
92         return E_SUCCESS;
93 }
94
95 void
96 NfcForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
97 {
98         if (__pNfcPresentationModelInstance == null)
99         {
100                 __pNfcPresentationModelInstance = NfcPresentationModel::GetInstance();
101                 if (__pNfcPresentationModelInstance != null)
102                 {
103                         __pNfcPresentationModelInstance->SetNfcEventListener(this);
104                 }
105         }
106         if (__pNfcPredefinedItemPresentationModelInstance == null)
107         {
108                 __pNfcPredefinedItemPresentationModelInstance = NfcPredefinedItemPresentationModel::GetInstance();
109         }
110
111         if (__pNfcPredefinedItemPresentationModelInstance == null)
112         {
113                 AppLogDebug("__pNfcPredefinedItemPresentationModelInstance == null");
114                 return;
115         }
116
117         if (__pNfcPredefinedItemPresentationModelInstance != null)
118         {
119                 __pNfcPredefinedItemPresentationModelInstance->InitReservedPushCandidatesList();
120                 __pResevedPushCandidatesAppidList = __pNfcPredefinedItemPresentationModelInstance->GetAllListReservedPushCandidatesAppIdList();
121                 if (__pResevedPushCandidatesAppidList != null)
122                 {
123                         if (__pResevedPushCandidatesAppidList->GetCount() > 0)
124                         {
125                                 __isPredefinedItem = true;
126                         }
127                 }
128         }
129         __pTableView->UpdateTableView();
130         bool nfcActivated = false;
131         if (__pNfcPresentationModelInstance != null)
132         {
133                 nfcActivated = __pNfcPresentationModelInstance->IsNfcActivated();
134                 __pTableView->SetItemChecked(0, 0, nfcActivated);
135         }
136         if (__isPredefinedItem)
137         {
138                 __pTableView->SetItemEnabled(ID_GROUP_NFC_PREDEFINED_ITEM, 0, nfcActivated);
139                 bool NfcReservedPushActivated = __pNfcPredefinedItemPresentationModelInstance->IsNfcReservedPushActivated();
140                 __pTableView->SetItemChecked(ID_GROUP_NFC_PREDEFINED_ITEM, ID_GROUP_ITEM_NFC_PREDEFINED_ITEM, NfcReservedPushActivated);
141         }
142 }
143
144 void
145 NfcForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
146 {
147         __pNfcPresentationModelInstance->SetNfcEventListener(null);
148 }
149
150 void
151 NfcForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
152 {
153         SceneManager* pSceneManager = SceneManager::GetInstance();
154         AppAssert(pSceneManager);
155
156         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
157 }
158
159 int
160 NfcForm::GetGroupCount(void)
161 {
162         int groupCount = 0;
163         if (__isPredefinedItem)
164         {
165                 groupCount = NFC_SUPPORT_PREDEFINED_ITEM_GROUP_COUNT;
166         }
167         else
168         {
169                 groupCount = NFC_NOT_SUPPORT_PREDEFINED_ITEM_GROUP_COUNT;
170         }
171         return groupCount;
172 }
173
174 int
175 NfcForm::GetItemCount(int groupIndex)
176 {
177         int itemCount = 0;
178         if (groupIndex == ID_GROUP_NFC)
179         {
180                 itemCount = ID_GROUP_NFC_ITEM_COUNT;
181         }
182         else if (groupIndex == ID_GROUP_NFC_PREDEFINED_ITEM)
183         {
184                 itemCount = ID_GROUP_NFC_PREDEFINED_ITEM_COUNT;
185         }
186         return itemCount;
187 }
188
189 TableViewGroupItem*
190 NfcForm::CreateGroupItem(int groupIndex, int itemWidth)
191 {
192         AppLogDebug("ENTER");
193         AppLogDebug("group[%d] width[%d]", groupIndex, itemWidth);
194
195         int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
196         int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
197         LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
198         Rectangle itemMainRectangle;
199         int fontSize = GetFontSize();
200         String groupText;
201         Label* pLabel = null;
202
203         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
204
205         switch (groupIndex)
206         {
207         case ID_GROUP_NFC:
208                 {
209                         yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
210                         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
211                 }
212                 break;
213
214         case ID_GROUP_NFC_HELP:
215                 {
216                         yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP / DIVIDE_BY_TWO;
217                         groupText = ResourceManager::GetString(L"IDS_NFC_BODY_WHEN_NFC_IS_ON_YOU_CAN_SEND_OR_RECEIVE_DATA_WHEN_YOUR_DEVICE_TOUCHES_OTHER_NFC_CAPABLE_DEVICES_OR_NFC_TAGS");
218                         itemHeight = GetHeightForStringArea(groupText, itemWidth - W_TEXT_GAP, fontSize) + H_TEXT_GAP;
219                 }
220                 break;
221
222         case ID_GROUP_NFC_PREDEFINED_ITEM:
223                 {
224                         yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
225                         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
226                 }
227                 break;
228
229         case ID_GROUP_NFC_PREDEFINED_ITEM_HELP:
230                 {
231                         yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP / DIVIDE_BY_TWO;
232                         groupText = ResourceManager::GetString(L"IDS_NFC_BODY_YOU_CAN_BEAM_PREDEFINED_ITEMS_TO_ANOTHER_NFC_DEVICE_JUST_BRING_THE_DEVICES_CLOSE_TOGETHER_MSG");
233                         itemHeight = GetHeightForStringArea(groupText, itemWidth - W_TEXT_GAP, fontSize) + H_TEXT_GAP;
234                 }
235                 break;
236
237         default:
238                 {
239                         yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
240                         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
241                 }
242                 break;
243         }
244
245         itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
246         itemMainRectangle.y = yItemOffset;
247         itemMainRectangle.width = itemWidth;
248         itemMainRectangle.height = itemHeight + H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
249
250         RelativeLayout relativeLayout;
251         relativeLayout.Construct();
252
253         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
254         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
255
256         pLabel = new (std::nothrow) Label();
257         pLabel->Construct(itemMainRectangle, groupText);
258         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
259         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
260         pLabel->SetTextConfig(fontSize, style);
261         pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
262
263         pItem->AddControl(pLabel);
264         pItem->SetEnabled(false);
265         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, 0, 0, 0);
266         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
267         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
268
269         return pItem;
270 }
271
272 TableViewItem*
273 NfcForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
274 {
275         AppLogDebug("group[%d] item[%d] width[%d]", groupIndex, itemIndex, itemWidth);
276         int itemHeight = H_GROUP_ITEM_DEFAULT;
277         int fontSize = GetFontSize();
278         Rectangle itemMainRectangle;
279         Rectangle itemSubRectangle;
280
281         String itemMainText;
282         String itemSubText;
283
284         ItemTypeOneLine(itemMainRectangle);
285         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
286
287         TableViewItem* pItem = new (std::nothrow) TableViewItem();
288         if (pItem == null)
289         {
290                 return null;
291         }
292
293         switch (groupIndex)
294         {
295         case ID_GROUP_NFC:
296                 {
297                         itemMainText = ResourceManager::GetString(L"IDS_NFC_BODY_NFC");
298                         style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
299                 }
300                 break;
301
302         case ID_GROUP_NFC_PREDEFINED_ITEM:
303                 {
304                         if (__pResevedPushCandidatesAppidList->GetCount() != 0)
305                         {
306                                 int selectItemIndex = __pNfcPredefinedItemPresentationModelInstance->GetSelectNfcReservedPushCandidatesAppIdIndex();
307                                 itemSubText = *static_cast<String*>(__pResevedPushCandidatesAppidList->GetAt(selectItemIndex));
308                         }
309                         ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
310                         itemMainText = ResourceManager::GetString(L"IDS_NFC_BODY_PREDEFINED_ITEM_ABB");
311                         style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
312                 }
313                 break;
314
315         default:
316                 {
317                         AppLogDebug("CreateItem is error");
318                         delete pItem;
319                         return null;
320                 }
321         }
322
323         RelativeLayout relativeLayout;
324         relativeLayout.Construct();
325
326         result r = pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
327         if (IsFailed(r))
328         {
329                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
330                 delete pItem;
331                 return null;
332         }
333
334         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
335
336         Label* pLabel = new (std::nothrow) Label();
337         if (pLabel == null)
338         {
339                 AppLogDebug("pLabel is null");
340                 return pItem;
341         }
342
343         r = pLabel->Construct(itemMainRectangle, itemMainText);
344         if (IsFailed(r))
345         {
346                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
347                 delete pLabel;
348                 return pItem;
349         }
350
351         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
352         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
353         pLabel->SetTextColor(COLOR_MAIN_TEXT);
354
355         pItem->AddControl(pLabel);
356         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
357         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
358         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
359
360         if (groupIndex == ID_GROUP_NFC_PREDEFINED_ITEM)
361         {
362                 Label* pSecondLineLabel = new (std::nothrow) Label();
363                 if (pSecondLineLabel == null)
364                 {
365                         AppLogDebug("pLabel is null");
366                         return pItem;
367                 }
368
369                 r = pSecondLineLabel->Construct(itemSubRectangle, itemSubText);
370                 if (IsFailed(r))
371                 {
372                         AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
373                         delete pSecondLineLabel;
374                         return pItem;
375                 }
376
377                 pSecondLineLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
378                 pSecondLineLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
379                 pSecondLineLabel->SetTextColor(COLOR_SUB_TEXT);
380
381                 pItem->AddControl(pSecondLineLabel);
382                 relativeLayout.SetMargin(*pSecondLineLabel, itemSubRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
383                 relativeLayout.SetRelation(*pSecondLineLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
384                 relativeLayout.SetRelation(*pSecondLineLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
385         }
386         return pItem;
387 }
388
389 bool
390 NfcForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
391 {
392         AppLogDebug("ENTER");
393
394         delete pItem;
395         pItem = null;
396
397         return true;
398 }
399
400 bool
401 NfcForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
402 {
403         AppLogDebug("ENTER");
404
405         delete pItem;
406         pItem = null;
407
408         return true;
409 }
410
411 void
412 NfcForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
413 {
414         AppLogDebug("groupIndex [%d] itemIndex [%d]", groupIndex, itemIndex);
415         if ((groupIndex != 0)
416                 && (itemIndex != 0))
417         {
418                 AppLogDebug("OnGroupedTableViewGroupItemStateChanged is Error");
419                 return;
420         }
421         if (__pNfcPresentationModelInstance == null)
422         {
423                 AppLogDebug("__pNfcPresentationModelInstance is null");
424                 return;
425         }
426
427         switch (groupIndex)
428         {
429         case ID_GROUP_NFC:
430                 {
431                         if (__isNfcBusy)
432                         {
433                                 AppLogDebug("nfc turn on or off");
434                                 __pTableView->SetItemChecked(groupIndex, itemIndex, !__pTableView->IsItemChecked(groupIndex, itemIndex));
435                                 return;
436                         }
437                         __isNfcBusy = true;
438                         ToggleNfcActivateStatus(status);
439                         __pTableView->UpdateTableView();
440                 }
441                 break;
442
443         case ID_GROUP_NFC_PREDEFINED_ITEM:
444                 {
445                         bool NfcReservedPushActivated = __pNfcPredefinedItemPresentationModelInstance->IsNfcReservedPushActivated();
446                         __pTableView->SetItemChecked(ID_GROUP_NFC_PREDEFINED_ITEM, ID_GROUP_ITEM_NFC_PREDEFINED_ITEM, NfcReservedPushActivated);
447                         SceneManager* pSceneManager = SceneManager::GetInstance();
448                         AppAssert(pSceneManager);
449                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_NFC_PREDEFINED_ITEM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
450                 }
451                 break;
452
453         default:
454                 {
455                         AppLogDebug("OnGroupedTableViewItemStateChanged is error");
456                 }
457                 break;
458         }
459 }
460
461 void
462 NfcForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
463 {
464 }
465
466 int
467 NfcForm::GetDefaultGroupItemHeight(void)
468 {
469         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
470 }
471
472 int
473 NfcForm::GetDefaultItemHeight(void)
474 {
475         return H_GROUP_ITEM_DEFAULT;
476 }
477
478 void
479 NfcForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
480 {
481         if ((groupIndex != ID_GROUP_NFC_HELP)
482                 && (groupIndex != ID_GROUP_NFC_PREDEFINED_ITEM_HELP))
483         {
484                 AppLogDebug("groupIndex is not ID_GROUP_FONT_TEXT");
485                 return;
486         }
487
488         Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
489         if (pLabel == null)
490         {
491                 AppLogDebug("pLabel is null");
492                 return;
493         }
494
495         Rectangle clientRect = GetClientAreaBounds();
496         Rectangle itemRect = pItem->GetBounds();
497         String groupText = pLabel->GetText();
498         int fontSize = GetFontSize();
499         int itemHeight = GetHeightForStringArea(groupText, clientRect.width - W_TEXT_GAP, fontSize) + H_TEXT_GAP;
500
501         itemRect.height = itemHeight + H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
502
503         pLabel->SetBounds(clientRect.x, H_GROUP_INDEX_HELP_TEXT_TOP_GAP, clientRect.width, itemHeight);
504         pItem->SetBounds(itemRect);
505 }
506
507 void
508 NfcForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
509 {
510 }
511
512 void
513 NfcForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
514 {
515 }
516
517 void
518 NfcForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
519 {
520 }
521
522 void
523 NfcForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
524 {
525         __pTableView->RefreshItem(ID_GROUP_NFC_HELP, ID_GROUP_NFC_HELP_TEXT_LABEL, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
526         if (__isPredefinedItem)
527         {
528                 __pTableView->RefreshItem(ID_GROUP_NFC_PREDEFINED_ITEM_HELP, ID_GROUP_NFC_PREDEFINED_ITEM_HELP_TEXT_LABEL, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
529         }
530         Invalidate(true);
531 }
532
533 void
534 NfcForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
535 {
536         if (requestId == FRFRESH_REQUEST_EVENT)
537         {
538                 if (__pTableView)
539                 {
540                         __pTableView->UpdateTableView();
541                         bool nfcActivated = false;
542                         if (__pNfcPresentationModelInstance != null)
543                         {
544                                 nfcActivated = __pNfcPresentationModelInstance->IsNfcActivated();
545                         }
546                         __pTableView->SetItemChecked(0, 0, nfcActivated);
547                         if (__isPredefinedItem)
548                         {
549                                 __pTableView->SetItemEnabled(ID_GROUP_NFC_PREDEFINED_ITEM, 0, nfcActivated);
550                                 bool NfcReservedPushActivated = __pNfcPredefinedItemPresentationModelInstance->IsNfcReservedPushActivated();
551                                 __pTableView->SetItemChecked(ID_GROUP_NFC_PREDEFINED_ITEM, ID_GROUP_ITEM_NFC_PREDEFINED_ITEM, NfcReservedPushActivated);
552                         }
553                 }
554                 if (pArgs)
555                 {
556                         pArgs->RemoveAll(true);
557                         delete pArgs;
558                 }
559         }
560 }
561
562 result
563 NfcForm::ToggleNfcActivateStatus(Tizen::Ui::Controls::TableViewItemStatus itemStatus)
564 {
565         if (__pNfcPresentationModelInstance == null)
566         {
567                 AppLogDebug("__pNfcPresentationModelInstance is null");
568                 return E_FAILURE;
569         }
570         result r = E_SUCCESS;
571
572         switch (itemStatus)
573         {
574         case TABLE_VIEW_ITEM_STATUS_CHECKED:
575                 {
576                         r = __pNfcPresentationModelInstance->ActivateNfc();
577                         if (IsFailed(r))
578                         {
579                                 AppLogDebug("Nfc active is failed %s", GetErrorMessage(r));
580                                 __isNfcBusy = false;
581                         }
582
583                         if (__isPredefinedItem)
584                         {
585                                 __pTableView->SetItemEnabled(ID_GROUP_NFC_PREDEFINED_ITEM, 0, true);
586                         }
587                 }
588                 break;
589
590         case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
591                 {
592                         r = __pNfcPresentationModelInstance->DeactivateNfc();
593                         if (IsFailed(r))
594                         {
595                                 AppLogDebug("Nfc deactive is failed %s", GetErrorMessage(r));
596                                 __isNfcBusy = false;
597                         }
598
599                         if (__isPredefinedItem)
600                         {
601                                 __pTableView->SetItemEnabled(ID_GROUP_NFC_PREDEFINED_ITEM, 0, false);
602                         }
603                 }
604                 break;
605
606         default:
607                 break;
608         }
609
610         return E_SUCCESS;
611 }
612
613 void
614 NfcForm::OnNfcPresentationModelEventCompleted(NfcPresentationModelEvent requestEvent, result r)
615 {
616         AppLog("requestEvent = %d", requestEvent);
617         if ((requestEvent == NFC_PRESENTATION_MODEL_EVENT_ACTIVATED)
618                 || (requestEvent == NFC_PRESENTATION_MODEL_EVENT_DEACTIVATED))
619         {
620                 __isNfcBusy = false;
621         }
622 }