Exception handling regarding NFC app-control declaration.
authorTae-Jeong Lee <taejeong.lee@samsung.com>
Tue, 22 Oct 2013 07:34:53 +0000 (16:34 +0900)
committerSoo-Hyun Choi <sh9.choi@samsung.com>
Wed, 23 Oct 2013 01:20:05 +0000 (10:20 +0900)
*** This is a workaroud patch that should be retained for Tizen 2.2 only ***

[Issue#]   N/A
[Problem]  Request from Tizen Device Web API team regarding NFC.
[Cause]    To support 'GSMA-NFC-Handset-APIs-Requirements' of  'Samsung Wallet',
           webapi team requested following exception processing from wrt side.

           When a webapp defined the app-control declaration in config.xml as below,
            - operation: http://tizen.org/appcontrol/operation/nfc/transaction
            - uri: nfc://secure/aid/<aid>
            - mime: NULL

           Its uri will be diverted based on the following rule.
            - nfc://secure/aid/<aid>  ->  nfc://secure/<SEName>/aid/<aid>

[Solution] This exception processing should be retained to tizen 2.2 only.

Change-Id: I052845742fb57f21f38981bba040b14cf4ed95e1

CMakeLists.txt
src/configuration_parser/widget_parser.cpp

index 24143a2..b7c9dd7 100644 (file)
@@ -41,6 +41,7 @@ OPTION(MULTIPROCESS_SERVICE_SUPPORT_INLINE "Process per service - inline mode su
 OPTION(CSP_SUPPORT "Support for csp policy" ON)
 OPTION(ALLOW_NAVIGATION_SUPPORT "Support for allow-navigation" ON)
 OPTION(SCHEMA_VALIDATION_SUPPORT "Support for XML schema validation" OFF)
+OPTION(NFC_APP_CONTROL_EXCEPTION "Enable exception handling for NFC app-control" ON)
 
 ############################# compiler flags ##################################
 
@@ -75,6 +76,10 @@ IF(SCHEMA_VALIDATION_SUPPORT)
     MESSAGE(STATUS "XML Schema validation of installed app enabled")
     ADD_DEFINITIONS("-DSCHEMA_VALIDATION_ENABLED")
 ENDIF(SCHEMA_VALIDATION_SUPPORT)
+IF(NFC_APP_CONTROL_EXCEPTION)
+    MESSAGE(STATUS "Exception handling for NFC app-control is enabled")
+    ADD_DEFINITIONS("-DNFC_EXCEPTION_HANDLING_FOR_TIZEN_2_2_ONLY")
+ENDIF(NFC_APP_CONTROL_EXCEPTION)
 
 # If supported for the target machine, emit position-independent code,suitable
 # for dynamic linking and avoiding any limit on the size of the global offset
index 62a640e..2503c8d 100644 (file)
@@ -1177,6 +1177,41 @@ class AppControlParser : public ElementParser
             ThrowMsg(Exception::ParseError, "service element must be unique");
         }
 
+#ifdef NFC_EXCEPTION_HANDLING_FOR_TIZEN_2_2_ONLY
+        // XXX This feature should be retained to Tizen 2.2 only.
+        // NFC exception handling which was requested from Tizen Device API team.
+
+        const DPL::String exceptionNfcOperation =
+                       L"http://tizen.org/appcontrol/operation/nfc/transaction";
+        const DPL::String exceptionNfcUri  = L"nfc://secure/aid/";
+        const DPL::String divertingNfcUri1 = L"nfc://secure/SIM1/aid/";
+        const DPL::String divertingNfcUri2 = L"nfc://secure/eSE/aid/";
+
+        if (m_appControl.m_operation == exceptionNfcOperation
+            && m_appControl.m_mimeList.empty()
+            && m_appControl.m_uriList.size() == 1
+            && (m_appControl.m_uriList.begin())->compare(0, exceptionNfcUri.length(), exceptionNfcUri) == 0)
+        {
+            DPL::String originalUri = *m_appControl.m_uriList.begin();
+            DPL::String newUri = originalUri;
+
+            newUri.replace(0, exceptionNfcUri.length(), divertingNfcUri1);
+            m_appControl.m_uriList.erase(m_appControl.m_uriList.begin());
+            m_appControl.m_uriList.insert(newUri);
+            m_data.appControlList.push_back(m_appControl);
+            _D("NFC exception : %ls -> %ls", originalUri.c_str(), newUri.c_str());
+
+            newUri = originalUri;
+            newUri.replace(0, exceptionNfcUri.length(), divertingNfcUri2);
+            m_appControl.m_uriList.erase(m_appControl.m_uriList.begin());
+            m_appControl.m_uriList.insert(newUri);
+            m_data.appControlList.push_back(m_appControl);
+            _D("NFC exception : %ls -> %ls", originalUri.c_str(), newUri.c_str());
+
+            return;
+        }
+#endif // NFC_EXCEPTION_HANDLING_FOR_TIZEN_2_2_ONLY
+
         m_data.appControlList.push_back(m_appControl);
     }