SLPAPI int aul_forward_app(const char* pkgname, bundle *kb)
{
	char *caller;
	int ret;
	bundle *dupb;
	bundle *outb;
	char tmp_pid[MAX_PID_STR_BUFSZ];

	if(pkgname == NULL || kb == NULL)
		return AUL_R_EINVAL;
	
	caller = (char *)bundle_get_val(kb, AUL_K_CALLER_PID);
	if(caller == NULL) {
		_E("original msg doest not have caller pid");
		return AUL_R_EINVAL;
	}
	
	bundle_del(kb, AUL_K_ORG_CALLER_PID);
	bundle_add(kb, AUL_K_ORG_CALLER_PID, caller);

	dupb = bundle_dup(kb);
	if(dupb == NULL) {
		_E("bundle duplicate fail");
		return AUL_R_EINVAL;
	}
	
	if(bundle_get_val(kb, AUL_K_WAIT_RESULT) != NULL) {
		ret = app_request_to_launchpad(APP_START_RES, pkgname, kb);
		if(ret < 0) 
			goto end;	
	} else {
		ret = app_request_to_launchpad(APP_START, pkgname, kb);
		goto end;
	}
		
//	bundle_iterate(dupb, __iterate, NULL);

	snprintf(tmp_pid, MAX_PID_STR_BUFSZ,"%d",ret);

	ret = aul_create_result_bundle(dupb, &outb);
	if(ret < 0)
		return ret;

	bundle_del(outb, AUL_K_FWD_CALLEE_PID);		
	bundle_add(outb, AUL_K_FWD_CALLEE_PID, tmp_pid);

//	bundle_iterate(outb, __iterate, NULL);

	ret = aul_send_result(outb, 1);

	bundle_free(outb);
end:
	bundle_free(dupb);

	return ret;
}
Ejemplo n.º 2
0
void iotjs_tizen_app_control_cb(app_control_h app_control, void* user_data) {
  DDDLOG("%s", __func__);

  iotjs_environment_t* env = iotjs_environment_get();

  if (env->state != kRunningMain && env->state != kRunningLoop) {
    return;
  }

  const char* event_emitter_name = IOTJS_MAGIC_STRING_TIZEN;
  const char* event_name = IOTJS_MAGIC_STRING_APP_CONTROL;

  jerry_value_t tizen = iotjs_module_get(event_emitter_name);
  jerry_value_t fn = iotjs_jval_get_property(tizen, IOTJS_MAGIC_STRING_EMIT);

  if (jerry_value_is_function(fn) == false) {
    DDDLOG("tizen module is not loaded");
    goto exit;
  }

  // parse app control
  char* json = NULL;
  bundle* b = NULL;

  app_control_export_as_bundle(app_control, &b);

  if (BUNDLE_ERROR_NONE != bundle_to_json(b, &json)) {
    DDLOG("bundle_to_json failed");
    bundle_free(b);
    return;
  }
  DDDLOG("JSON: %s", json);

  // call emit
  jerry_value_t jargv[2] = { jerry_create_string(
                                 (const jerry_char_t*)event_name),
                             jerry_create_string((const jerry_char_t*)json) };

  iotjs_invoke_callback(fn, tizen, jargv, 2);
  jerry_release_value(jargv[0]);
  jerry_release_value(jargv[1]);

  free(json);
  bundle_free(b);

exit:
  jerry_release_value(fn);
}
int _cals_alarm_add_to_alarmmgr(struct cals_time *start_time, cal_alarm_info_t *alarm_info)
{
	int ret;
	long long int iv;
	bundle *b;
	alarm_id_t alarm_id = 0;

	iv = _cals_get_interval(alarm_info, start_time);
	if (iv < 0) {
		DBG("Tried to register past event, so passed registration");
		return 0;

	} else if (iv == 0) {
		DBG("Set no alarm");
		return 0;
	}

	b = _get_appsvc(PKG_CALENDAR_APP);
	if (!b) {
		ERR("_get_appsvc failed");
		return CAL_ERR_FAIL;
	}

	ret = alarmmgr_add_alarm_appsvc(ALARM_TYPE_DEFAULT, (long int)iv, 0, b, &alarm_id);
	bundle_free(b);

	if (ret) {
		ERR("alarmmgr_add_alarm_appsvc failed (%d)", ret);
		return CAL_ERR_ALARMMGR_FAILED;
	}
	DBG("Set alarm id(%d)", alarm_id);
	alarm_info->alarm_id = alarm_id;

	return 0;
}
Ejemplo n.º 4
0
int
main (int argc, char **argv)
{
  const char *typestr = NULL;

  program_init (argc, argv);
  program_getoptuint ('i', &iterations);
  program_getoptuint ('l', &layer);
  program_getoptuint ('v', &vector);
  program_getoptuint ('w', &window);
  program_getoptstr ('t', &typestr);

  if (typestr) {
    for (type = 0; type < NUM_MODELS; type++) {
      if (strcasecmp (typestr, model_name[type]) == 0)
        break;
    }
    if (type == NUM_MODELS)
      fatal ("unkown model %s", typestr);
  }

  b = bundle_open (program_poparg ());
  if (b == NULL)
    fatal ("bundle_open");
  program_run ();
  bundle_save (b);
  bundle_free (b);
  return 0;
}
static void _launch_video_call( struct tnoti_call_status_incoming* incoming )
{
	char id[2] = {0, };
	char cli[2] = {0, };
	char forward[2] = {0, };
	char number[83] = {0, };
	int ret = 0;

	bundle *kb  = 0;

	dbg("Func Entrance");

	snprintf( id, 2, "%d", incoming->id );
	dbg("id : [%s]", id );
	snprintf( number, 83, "%s", incoming->cli.number );
	dbg("number : [%s]", number );
	snprintf( cli, 2, "%d", incoming->cli.mode );
	dbg("cli : [%s]", id );
	snprintf( forward, 2, "%d", incoming->forward );
	dbg("forward : [%s]", forward );

	kb = bundle_create();
	bundle_add(kb, "KEY_CALL_TYPE", "mt");
	bundle_add(kb, "KEY_CALL_HANDLE", id);
	bundle_add(kb, "KEY_CALLING_PARTY_NUMBER", number);
	bundle_add(kb, "KEY_CLI_CAUSE", cli);
	bundle_add(kb, "KEY_FORWARDED", forward);

	ret = aul_launch_app("com.samsung.vtmain", kb);
	bundle_free(kb);

	dbg("VT AUL return %d",ret);
}
Ejemplo n.º 6
0
static iotjs_error_t tizen_send_launch_request(const char* json,
                                               void* hbridge) {
  DDDLOG("%s", __func__);

  bundle* b;
  int ret;

  ret = bundle_from_json(json, &b);
  if (ret != BUNDLE_ERROR_NONE) {
    DDLOG("bundle_from_json failed");
    return IOTJS_ERROR_INVALID_PARAMETER;
  }

  app_control_h app_control = NULL;

  app_control_create(&app_control);
  app_control_import_from_bundle(app_control, b);

  ret = app_control_send_launch_request(app_control, NULL, NULL);

  if (ret != APP_CONTROL_ERROR_NONE) {
    DDDLOG("app_control_send_launch_request failed");
    switch (ret) {
      case APP_CONTROL_ERROR_INVALID_PARAMETER:
        iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_INVALID_PARAMETER");
        break;
      case APP_CONTROL_ERROR_OUT_OF_MEMORY:
        iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_OUT_OF_MEMORY");
        break;
      case APP_CONTROL_ERROR_APP_NOT_FOUND:
        iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_APP_NOT_FOUND");
        break;
      case APP_CONTROL_ERROR_LAUNCH_REJECTED:
        iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_LAUNCH_REJECTED");
        break;
      case APP_CONTROL_ERROR_LAUNCH_FAILED:
        iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_LAUNCH_FAILED");
        break;
      case APP_CONTROL_ERROR_TIMED_OUT:
        iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_TIMED_OUT");
        break;
      case APP_CONTROL_ERROR_PERMISSION_DENIED:
        iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_PERMISSION_DENIED");
        break;
      default:
        iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_UNKNOWN");
        break;
    }
    return IOTJS_ERROR_RESULT_FAILED;
  }

  bundle_free(b);
  app_control_destroy(app_control);

  return IOTJS_ERROR_NONE;
}
gboolean _invoke_get_list(gpointer data)
{
	bundle *bd = (bundle *)data;

	appsvc_get_list(bd, _pkglist_iter_fn, (bundle *)bd);

	bundle_free(bd);

	return 0;
}
Ejemplo n.º 8
0
static int sendResponMessage(void *data){
	app_data *appdata = data;
	bundle *resp_dir = bundle_create();

	RETVM_IF(bundle_add_str(resp_dir, "folder_path", send_folders) != 0,
			SVC_RES_FAIL, "Failed to add data by key to bundle");
	_app_send_response(appdata, resp_dir);
	bundle_free(resp_dir);
	return SVC_RES_OK;
}
Ejemplo n.º 9
0
static int _on_proxy_client_msg_received_cb(void *data, bundle *const rec_msg)
{
	dlog_print(DLOG_INFO ,"tdlna", "_on_proxy_client_msg_received_cb 실행");
    int result = SVC_RES_FAIL;
    RETVM_IF(!data, result, "Data is NULL");

    app_data *app = data;
    req_operation req_operation = REQ_OPER_NONE;

    bundle *resp_msg = bundle_create();
    RETVM_IF(!resp_msg, result, "Failed to create bundle");

    result = _app_process_received_message(rec_msg, resp_msg, &req_operation);
    if (result != SVC_RES_OK)
    {

        ERR("Failed to generate response bundle");
        bundle_free(resp_msg);
        return result;
    }

    result = _app_execute_operation(app, req_operation);
    if(result == SVC_RES_OK)
    {
        result = _app_send_response(app, resp_msg);
        if (result != SVC_RES_OK)
        {
            ERR("Failed to send message to remote application");
        }
    }
    else
    {
        ERR("Failed to execute operation");
    }
    bundle_free(resp_msg);

    return result;
}
Ejemplo n.º 10
0
int
main (int argc, char **argv)
{
  program_init (argc, argv);
  program_getoptuint ('m', &min);

  b = bundle_open (program_poparg ());
  if (b == NULL)
    fatal ("bundle_open");
  program_run ();
  bundle_save (b);
  bundle_free (b);
  return 0;
}
int wlan_manager_network_syspopup_message(const char *title, const char *content, const char *type)
{
	int ret = 0;
	bundle *b = bundle_create();

	bundle_add(b, "_SYSPOPUP_TITLE_", title);
	bundle_add(b, "_SYSPOPUP_CONTENT_", content);
	bundle_add(b, "_SYSPOPUP_TYPE_", type);

	ret = syspopup_launch("net-popup", b);
	bundle_free(b);

	return ret;
}
SLPAPI int aul_create_result_bundle(bundle *inb, bundle **outb)
{
	const char *pid_str;

	*outb = NULL;
	
	if(inb == NULL){
		_E("return msg create fail");
		return AUL_R_EINVAL;
	}

	*outb = bundle_create();
	if (*outb == NULL) {
		_E("return msg create fail");
		return AUL_R_ERROR;
	}

	if(bundle_get_val(inb, AUL_K_WAIT_RESULT) != NULL) {
		bundle_add(*outb, AUL_K_SEND_RESULT, "1");
		_D("original msg is msg with result");
	} else {
		_D("original msg is not msg with result");
	}
	

	pid_str = bundle_get_val(inb, AUL_K_ORG_CALLER_PID);
	if(pid_str) {
		bundle_add(*outb, AUL_K_ORG_CALLER_PID, pid_str);
		goto end;
	}
	
	pid_str = bundle_get_val(inb, AUL_K_CALLER_PID);
	if (pid_str == NULL) {
		_E("original msg doest not have caller pid");
		bundle_free(*outb);
		*outb = NULL;
		return AUL_R_EINVAL;
	}
	bundle_add(*outb, AUL_K_CALLER_PID, pid_str);

end:
	return AUL_R_OK;
}
static gboolean __bt_system_popup_timer_cb(gpointer user_data)
{
	int ret = 0;
	bundle *b = (bundle *) user_data;

	if (NULL == b) {
		ERR("There is some problem with the user data..popup can not be created\n");
		return FALSE;
	}
	ret = syspopup_launch("bt-syspopup", b);

	if (0 > ret) {
		ERR("launching sys-popup failed\n");
		return TRUE;
	} else {
		DBG("Hurray Popup launched \n");
		bundle_free(b);
		return FALSE;
	}
}
static int __send_to_cancel(int pid)
{
	/* Say "Your result request is cancel!" to caller */
	bundle *kb;
	int ret;
	char tmp_pid[MAX_PID_STR_BUFSZ];

	kb = bundle_create();
	if (kb == NULL)
		return AUL_R_ERROR;
	bundle_add(kb, AUL_K_SEND_RESULT, "1");

	snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", pid);
	bundle_add(kb, AUL_K_CALLER_PID, tmp_pid);

	ret = app_send_cmd(LAUNCHPAD_PID, APP_CANCEL, kb);

	bundle_free(kb);
	return ret;
}
bundle *_get_appsvc(const char *pkg)
{
	int r;
	bundle *b;

	b = bundle_create();
	if (!b) {
		ERR("bundle_create failed");
		return NULL;
	}

	r = appsvc_set_pkgname(b, pkg);
	appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
	if (r) {
		bundle_free(b);
		ERR("appsvc_set_pkgname failed (%d)", r);
		return NULL;
	}

	return b;
}
void _send_values(const char* sensor_name, const float val1, const float val2, const float val3)
{
   int error = MESSAGE_PORT_ERROR_NONE;
   char str[100];
   bundle *b = bundle_create();

   sprintf (str, "%.4f %.4f %.4f", val1, val2, val3);
   LOGE("%s", str);

   bundle_add_str(b, sensor_name, str);

   error = message_port_send_message(REMOTE_APP_ID, REMOTE_PORT, b);
   if (error != MESSAGE_PORT_ERROR_NONE)
   {
      LOGE("message_port_check_remote_port error : %d", error);
   }
   else
   {
      LOGE("Send message done");
   }

   bundle_free(b);
}
int net_nfc_app_util_appsvc_launch(const char *operation, const char *uri, const char *mime, const char *data)
{
	int result = -1;

	bundle *bd = NULL;

	bd = bundle_create();
	if (bd == NULL)
		return result;

	if (operation != NULL)
	{
		appsvc_set_operation(bd, operation);
	}

	if (uri != NULL)
	{
		appsvc_set_uri(bd, uri);
	}

	if (mime != NULL)
	{
		appsvc_set_mime(bd, mime);
	}

	if (data != NULL)
	{
		appsvc_add_data(bd, "data", data);
	}

	result = appsvc_run_service(bd, 0, NULL, NULL);

	bundle_free(bd);

	return result;
}
Ejemplo n.º 18
0
int adtn_sendto(int fd, const void *buffer, size_t buffer_l, const sock_addr_t addr)
{
	int ret = -1;
	int shm_fd = -1;
	char *first_oc, *bundle_name;
	char full_dest[ENDPOINT_LENGTH] = {0};
	char full_src[ENDPOINT_LENGTH] = {0};
	struct common *shm;
	bunsock_s *identifier;
	bundle_s *bundle = NULL;
	payload_block_s *payload;

	if (addr.id == NULL || strcmp(addr.id, "") == 0 || buffer_l <= 0 || (buffer_l > 0 && buffer == NULL)) {
		errno = EINVAL;
		goto end;
	}
	HASH_FIND_INT( sockStore, &fd, identifier);
	if (!identifier) {
		errno = ENOTSOCK;
		goto end;
	}
	if (load_shared_memory_from_path(identifier->data_path, &shm, &shm_fd, false) != 0) {
		errno = ENOENT;
		goto end;
	}

	first_oc = strchr(addr.id, ':');
	if (!first_oc) {
		snprintf(full_dest, ENDPOINT_LENGTH - 1, "%s:%d", addr.id, addr.adtn_port);
	} else {
		if ( (strlen(first_oc + 1) == 0) || (strlen(first_oc + 1) > 6) || (strtol(first_oc + 1, NULL, 10) <= 0)) {
			errno = EINVAL;
			goto end;
		}
		snprintf(full_dest, ENDPOINT_LENGTH - 1, "%s:%d", addr.id, addr.adtn_port);
	}
	snprintf(full_src, ENDPOINT_LENGTH - 1, "%s:%d", identifier->addr.id, identifier->addr.adtn_port);
	bundle = bundle_new();
	if (identifier->sopt.dest) {
		bundle_set_destination(bundle, identifier->sopt.dest);
	} else {
		bundle_set_destination(bundle, full_dest);
	}
	if (identifier->sopt.source) {
		bundle_set_source(bundle, identifier->sopt.source);
	} else {
		bundle_set_source(bundle, full_src);
	}
	bundle_set_proc_flags(bundle, identifier->sopt.proc_flags);
	bundle_set_lifetime(bundle, identifier->sopt.lifetime);
	if (identifier->sopt.report)
		bundle_set_report(bundle, identifier->sopt.report);
	if (identifier->sopt.custom)
		bundle_set_custom(bundle, identifier->sopt.custom);
	payload = bundle_new_payload_block();
	bundle_set_payload(payload, (uint8_t *) buffer, buffer_l);
	bundle_add_ext_block(bundle, (ext_block_s *) payload);
	if (bundle_add_codes(bundle, identifier) != 0) {
		goto end;
	}
	bundle_name = generate_bundle_name(shm->platform_id);
	if (delegate_bundle(bundle_name, bundle, shm->data_path, identifier) != 0) {
		goto end;
	}
	free(bundle_name);
	ret = buffer_l;
end:

	if (shm_fd != -1)
		close(shm_fd);
	if (bundle)
		bundle_free(bundle);
	return ret;
}
Ejemplo n.º 19
0
static int _app_execute_operation(app_data *appdata, req_operation operation_type)
{
	dlog_print(DLOG_INFO ,"tdlna", "_app_execute_operation 실행");
	bundle *resp_msg = bundle_create();

    RETVM_IF(!appdata, SVC_RES_FAIL, "Application data is NULL");

    char *resp_key_val = NULL;

	char respStr[50];
    switch (operation_type)
    {
		case REQ_OPER_STATE:
			dlog_print(DLOG_INFO, "tdlna", "현재 상태 얻기");
			if ((appdata->run_tdlna) == 0) {
				// 서비스가 꺼져있는 상태라면
				dlog_print(DLOG_INFO, "tdlna", "서비스 상태 조회 %d", appdata->run_tdlna);
				resp_key_val = "STATE:OFF";
			} else {
				resp_key_val = "STATE:ON";
				dlog_print(DLOG_INFO, "tdlna", "서비스 상태 조회 %d", appdata->run_tdlna);
			}
			break;

		case REQ_OPER_FOLDER:
			dlog_print(DLOG_INFO, "tdlna", "미디어 정보 얻기");
			send_folders[0] = '\0';//초기화
			if(media_Directory(appdata)){//미디어 폴더 경로를 sendFolder함수로 전달해줌
				//폴더검색후
				sendResponMessage(appdata);
	        	dlog_print(DLOG_INFO,"tdlna","미디어 폴더 전송:%s",send_folders);
			}
			resp_key_val = "미디어 폴더 요청";

		break;

        case REQ_OPER_META_GET_APP:
        	dlog_print(DLOG_INFO,"tdlna","메타정보 가져오기 실행 ");
//------------------------------------------------------------------------------------------------------김태형~~!!!
        	char* testDir;
        	mediaDirectory_folder(&testDir,2);
        	dlog_print(DLOG_INFO,"tdlna","비디오 폴더 이어붙인것:%s",testDir);
//-------------------------------------------------------------------------------------------------------

 //       	_media_search(appdata);

//        	Meta_Get_from_path(appdata,"/opt/usr/media/DCIM/Camera/%");


//        	int videoC = 0,imageC=0,musicC = 0 ;
//        	media_Count(&videoC,&imageC,&musicC,"/opt/usr/media/DCIM/Camera/%");

        	break;
        case REQ_OPER_DLNA_APP://실행 요청시
        	dlog_print(DLOG_INFO,"tdlna","dlna on 처리");

        	if(!(appdata->run_tdlna)){
        		// 서비스가 꺼져있는 상태라면
        		if(appdata->tdlna_td != 0){
        			dlog_print(DLOG_ERROR,"tdlna", "이전 실행된 서비스가 정상적으로 종료되지 않았습니다.");
        			return 0;
        		}
        		if(serviceOn(appdata)){
        			dlog_print(DLOG_INFO,"tdlna","★ 서비스 ON ★ %d", appdata->run_tdlna);
        			resp_key_val = "DLNA:ON";
        		}else{
					dlog_print(DLOG_INFO,"tdlna","★ 실행 실패! ★ %d", appdata->run_tdlna);
					resp_key_val = "DLNA:Failed";
        		}
        	}
        	else{
        		resp_key_val = "DLNA:RUNNING";
        		dlog_print(DLOG_INFO,"tdlna","★ 이미 실행중 ★ %d", appdata->run_tdlna);
        	}
        	break;

        case REQ_OPER_DLNA_APP_OFF://종료 요청시
			if (!(appdata->run_tdlna)) {// 서비스가 꺼져있는 상태라면
				resp_key_val = "DLNA:OFF";
				dlog_print(DLOG_INFO, "tdlna", "★ 이미 종료상태★ %d",appdata->run_tdlna);
			} else {
				serviceOff(appdata);
				resp_key_val = "DLNA:OFF";
				dlog_print(DLOG_INFO, "tdlna", "★ 서비스 OFF ★ %d",appdata->run_tdlna);
			}
			break;
        case REQ_OPER_DEVICE_ID://tDlnaName 주기
			if(deviceName){
				strcpy(appdata->deviceName, deviceName);
				setDeviceProperty(appdata);//tdlnamain으로 전달
				sprintf(respStr, "%s%s", "tDlnaName/", deviceName);
			}else
				sprintf(respStr, "%s%s", "tDlnaName/", "nameError!");
			resp_key_val = respStr;
			dlog_print(DLOG_INFO, "tdlna", "resp_key_val값 가져오기 %s",resp_key_val);
			break;
        case REQ_SHARED_FOLDER:
			resp_key_val = "공유폴더!";
			dlog_print(DLOG_INFO, "tdlna", "%s 폴더 공유 실행",shared_folder);
			insertSharingList();
//			_META *test;
//			int testC=0;
//			testC= Meta_Get_from_path(appdata,shared_folder,2,&test);
//			dlog_print(DLOG_INFO, "tdlna", "리스트갯수:%d",testC);
//			dlog_print(DLOG_INFO, "tdlna", "리스트 1 :%s",test[1].path);
//			free(test);
        	break;
        case REQ_UNSHARED_FOLDER:
         	resp_key_val = "공유해제 폴더!";
			dlog_print(DLOG_INFO, "tdlna", "%s 폴더 공유 해제 실행",shared_folder);
			deleteSharingList();
         	//공유 해제 폴더 처리 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
			break;
        default:
            DBG("Unknown request id");
            return SVC_RES_FAIL;
            break;
    }
    RETVM_IF(bundle_add_str(resp_msg, "server", resp_key_val) != 0, SVC_RES_FAIL, "Failed to add data by key to bundle");
    _app_send_response(appdata, resp_msg);
    bundle_free(resp_msg);
    return SVC_RES_OK;
}
int _bt_set_notification_app_launch(notification_h noti,
					bt_qp_launch_type_t type,
					const char *transfer_type,
					const char *filename,
					const char *progress_cnt)
{
	DBG("+\n");
	if (!noti)
		return -1;

	if (!transfer_type)
		return -1;

	notification_error_e ret = NOTIFICATION_ERROR_NONE;
	bundle *b = NULL;
	b = bundle_create();
	if (!b)
		return -1;

	if (type == CREATE_PROGRESS) {
		int group_id = 0;
		int priv_id = 0;
		double percentage = 0;
		char progress[BT_PERCENT_STR_LEN] = { 0 };
		char priv_id_str[BT_PRIV_ID_STR_LEN] = { 0 };

		if (!filename) {
			bundle_free(b);
			return -1;
		}

		ret = notification_get_progress(noti, &percentage);
		if (ret != NOTIFICATION_ERROR_NONE)
			ERR("Fail to notification_update_progress\n");
		else
			snprintf(progress, BT_PERCENT_STR_LEN, "%d", (int)percentage);

		ret = notification_get_id(noti, &group_id, &priv_id);
		if (ret != NOTIFICATION_ERROR_NONE)
			ERR("Fail to notification_update_progress\n");
		else
			snprintf(priv_id_str, BT_PRIV_ID_STR_LEN, "%d", priv_id);

		appsvc_set_pkgname(b, UI_PACKAGE);
		appsvc_add_data(b, "launch-type", "ongoing");
		appsvc_add_data(b, "percentage", progress);
		appsvc_add_data(b, "filename", filename);
		appsvc_add_data(b, "transfer_type", transfer_type);
		appsvc_add_data(b, "transfer_id", priv_id_str);
		if (g_strcmp0(transfer_type, NOTI_TR_TYPE_OUT) == 0)  {
			if (!progress_cnt) {
				bundle_free(b);
				return -1;
			}
			appsvc_add_data(b, "progress_cnt", progress_cnt);
		}
	} else if (type == CREATE_TR_LIST) {
		appsvc_set_pkgname(b, UI_PACKAGE);
		appsvc_add_data(b, "launch-type", "transfer_list");
		appsvc_add_data(b, "transfer_type", transfer_type);
	} else {
		bundle_free(b);
		return -1;
	}

	ret = notification_set_execute_option(noti,
					NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
					NULL, NULL, b);
	if (ret != NOTIFICATION_ERROR_NONE) {
		ERR("Fail to notification_set_execute_option\n");
	}

	bundle_free(b);
	DBG("-\n");
	return ret;
}
int _bt_launch_system_popup(bt_app_event_type_t event_type,
			    bt_app_sys_popup_params_t *popup_params,
			    void *cb,
			    void *data)
{
	int ret = 0;
	bundle *b = NULL;
	char event_str[BT_SYSPOPUP_EVENT_LEN_MAX] = { 0 };
	struct bt_appdata *ad = app_state;

	DBG("+\n");
	if(cb == NULL)
		return -1;

	b = bundle_create();
	if(b == NULL)
		return -1;

	bundle_add(b, "title", popup_params->title);
	bundle_add(b, "type", popup_params->type);
	bundle_add(b, "file", popup_params->file);
	bundle_add(b, "device_name", popup_params->device_name);

	switch (event_type) {
	case BT_APP_EVENT_CONFIRM_MODE_REQUEST:
		strncpy(event_str, "app-confirm-request", sizeof(event_str));
		break;
	case BT_APP_EVENT_FILE_RECIEVED:
		strncpy(event_str, "file-recieved", sizeof(event_str));
		break;
	case BT_APP_EVENT_INFORMATION:
		strncpy(event_str, "bt-information", sizeof(event_str));
		break;
	default:
		break;
	}

	bundle_add(b, "event-type", event_str);

	/*The system popup launch function is not able to launch second popup
	  * if first popup is being processed still, this due to the check
	  * in AUL module to restrict multiple launching of syspopup,
	  * to solve this problem after discussion it is decided that  if
	  * the popup launch fails then it will be retried
	  * after small timeout. */
	ret = syspopup_launch("bt-syspopup", b);
	if (0 > ret) {
		ERR("Popup launch failed...retry = %d\n", ret);
		g_timeout_add(BT_POPUP_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS,
			      (GSourceFunc) __bt_system_popup_timer_cb, b);
	} else {
		bundle_free(b);
	}

	ad->popups.popup_cb = (bt_app_cb) cb;
	ad->popups.popup_cb_data = data;
	ad->popups.syspopup_request = TRUE;

	DBG("-\n");
	return 0;
}
Ejemplo n.º 22
0
SLPAPI int aul_open_service(const char *svcname, bundle *kb,
			    aul_service_res_fn cbfunc, void *userdata)
{
	char defapp[MAX_LOCAL_BUFSZ];
	int must_free = 0;
	int ret = AUL_R_ERROR;
	ail_appinfo_h handle;
	ail_error_e ail_ret;

	if (svcname == NULL)
		return AUL_R_EINVAL;

	if (!is_supported_svc(svcname))
		return AUL_R_EINVAL;

	if (kb == NULL) {
		kb = bundle_create();
		must_free = 1;
	}
	bundle_add(kb, AUL_K_SERVICE_NAME, svcname);

 retry:
	if (aul_get_defapp_for_service(svcname, defapp, sizeof(defapp)) < 0) {
		_D("service : %s, no default app", svcname);
		if (must_free) {
			bundle_free(kb);
			kb = NULL;
		}
		return ret;
	} else {
		ail_ret = ail_package_get_appinfo(defapp, &handle);

		if (ail_ret == AIL_ERROR_OK) {
			ail_destroy_appinfo(handle);
			_D("svcname: %s, defapp : %s", svcname, defapp);
			
			if (cbfunc) {
				_D("svcname: %s, defapp : %s - with result",
				   svcname, defapp);
				ret =
				    aul_launch_app_with_result(defapp, kb,
							       cbfunc,
							       userdata);
			} else {
				_D("svcname: %s, defapp : %s - no result",
				   svcname, defapp);
				ret = aul_launch_app(defapp, kb);
			}
		} else if (ail_ret == AIL_ERROR_NO_DATA) {
			_D("defapp %s for svcname: %s does NOT exist", defapp,
			   svcname);
			svc_delete_with_pkgname(defapp);
			ail_destroy_appinfo(handle);
			goto retry;
		} else {
			_E("ail_get_appinfo with %s failed", defapp);
			if (must_free) {
				bundle_free(kb);
				kb = NULL;
			}
			return ret;
		}	
	}
	if (must_free)
		bundle_free(kb);

	return ret;

}
static void _launch_voice_call( struct tnoti_call_status_incoming* incoming )
{
	char id[2] = {0, };
	char cli[2] = {0, };
	char forward[2] = {0, };
	char active_line[2] = {0, };
	char cna[2] = {0, };
	char number[83] = {0, };
	char name[83] = {0, };
//	int ret = 0;

	bundle *kb  = 0;

	snprintf( id, 2, "%d", incoming->id );
	dbg("id : [%s]", id );
	snprintf( cli, 2, "%d", incoming->cli.mode );
	dbg("cli : [%s]", id );
	snprintf( number, 83, "%s", incoming->cli.number );
	dbg("number : [%s]", number );
	snprintf( forward, 2, "%d", incoming->forward );
	dbg("forward : [%s]", forward );
	snprintf( active_line, 2, "%d", incoming->active_line );
	dbg("active_line : [%s]", active_line );

	if ( incoming->cna.mode == CALL_CNA_MODE_PRESENT )
		snprintf( cna, 2, "%d", 0 );
	else
		snprintf( cna, 2, "%d", 1 );

	dbg("cna : [%s]", cna );
	snprintf( name, 83, "%s", incoming->cna.name );
	dbg("name : [%s]", name );

	kb = bundle_create();

#if 0
	/* AUL */
	bundle_add(kb, "launch-type", "MT");
	bundle_add(kb, "handle", id);
	bundle_add(kb, "number", number);
	bundle_add(kb, "name_mode", cna);
	bundle_add(kb, "name", name);
	bundle_add(kb, "clicause", cli);
	bundle_add(kb, "fwded", forward);
	bundle_add(kb, "activeline", active_line);

	ret = aul_launch_app("com.samsung.call", kb);
	dbg("aul_launch_app [ voice call ] : %d", ret );
#else
	/* AppSvc */
	appsvc_set_operation(kb, APPSVC_OPERATION_CALL);
	appsvc_set_uri(kb,"tel:MT");

	appsvc_add_data(kb, "launch-type", "MT");
	appsvc_add_data(kb, "handle", id);
	appsvc_add_data(kb, "number", number);
	appsvc_add_data(kb, "name_mode", cna);
	appsvc_add_data(kb, "name", name);
	appsvc_add_data(kb, "clicause", cli);
	appsvc_add_data(kb, "fwded", forward);
	appsvc_add_data(kb, "activeline", active_line);

	appsvc_run_service(kb, 0, NULL, NULL);
#endif
	bundle_free(kb);
}