From 75a566dd7a2e6519e707da6dd7eac81c4d6e01b6 Mon Sep 17 00:00:00 2001 From: Abhijit RD Date: Mon, 18 Nov 2013 15:35:53 +0530 Subject: [PATCH] Selective Application Launch Added the server side code for selective application launch Change-Id: I069ebf4e9a0a078d03a20157f9004d33b5a208e9 Signed-off-by: Abhijit R D --- common/include/net_nfc_typedef.h | 1 + daemon/net_nfc_server_util.c | 48 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) mode change 100644 => 100755 daemon/net_nfc_server_util.c diff --git a/common/include/net_nfc_typedef.h b/common/include/net_nfc_typedef.h index 1032360..a8d4ed7 100644 --- a/common/include/net_nfc_typedef.h +++ b/common/include/net_nfc_typedef.h @@ -302,6 +302,7 @@ typedef enum } net_nfc_event_filter_e; +#define NET_NFC_APPLICATION_RECORD "tizen.org:app" /* ************************************** LLCP defines diff --git a/daemon/net_nfc_server_util.c b/daemon/net_nfc_server_util.c old mode 100644 new mode 100755 index 9014fc5..107cd74 --- a/daemon/net_nfc_server_util.c +++ b/daemon/net_nfc_server_util.c @@ -245,8 +245,17 @@ static bool _net_nfc_app_util_get_operation_from_record( break; case NET_NFC_RECORD_EXTERNAL_RTD : /* external type */ + if(strncmp((char*)record->type_s.buffer, NET_NFC_APPLICATION_RECORD, + record->type_s.length)==0) + { + //use APPSVC_OPERATION_VIEW in case of Selective App launch + op_text = APPSVC_OPERATION_VIEW; + } + else + { op_text = "http://tizen.org/appcontrol/operation/nfc/external"; - break; + } + break; case NET_NFC_RECORD_EMPTY : /* empty_tag */ op_text = "http://tizen.org/appcontrol/operation/nfc/empty"; @@ -489,7 +498,28 @@ static bool _net_nfc_app_util_get_data_from_record(ndef_record_s *record, char * case NET_NFC_RECORD_MIME_TYPE : case NET_NFC_RECORD_URI : /* Absolute URI */ + break; case NET_NFC_RECORD_EXTERNAL_RTD : /* external type */ + { + NFC_DBG("NDEF Message with external type"); + if(strncmp((char*)record->type_s.buffer, NET_NFC_APPLICATION_RECORD, + record->type_s.length)==0) + { + uint8_t *buffer_temp = record->payload_s.buffer; + uint32_t buffer_length = record->payload_s.length; + if(buffer_length > length) + { + result= false; + } + else + { + //Copy application id into data + memcpy(data,buffer_temp,MIN(buffer_length,length)); + result = true; + } + } + } + break; case NET_NFC_RECORD_EMPTY : /* empy msg. discard it */ result = true; break; @@ -596,6 +626,7 @@ ERROR : return result; } + static bool net_nfc_app_util_is_dir(const char* path_name) { struct stat statbuf = { 0 }; @@ -676,7 +707,7 @@ int net_nfc_app_util_appsvc_launch(const char *operation, const char *uri, const int result = -1; bundle *bd = NULL; - + bool specific_app_launch = false; bd = bundle_create(); if (NULL == bd) return result; @@ -685,6 +716,12 @@ int net_nfc_app_util_appsvc_launch(const char *operation, const char *uri, const { NFC_DBG("operation : %s", operation); appsvc_set_operation(bd, operation); + if(strncmp(operation, APPSVC_OPERATION_VIEW,strlen(APPSVC_OPERATION_VIEW))==0) + { + appsvc_set_appid(bd, data); + specific_app_launch = true; + goto LAUNCH; + } } if (uri != NULL && strlen(uri) > 0) @@ -708,8 +745,15 @@ int net_nfc_app_util_appsvc_launch(const char *operation, const char *uri, const bundle_add(bd, OSP_K_COND, OSP_K_COND_TYPE); bundle_add(bd, OSP_K_LAUNCH_TYPE, osp_launch_type_condition); +LAUNCH: result = appsvc_run_service(bd, 0, NULL, NULL); + /*if the app could not be found*/ + if(specific_app_launch && result == APPSVC_RET_ENOMATCH) + { + /*TODO: tizen store launch*/ + } + bundle_free(bd); return result; -- 2.7.4