Example #1
0
/* ------------------------------------------------------------------------- */
char
service_init(struct game_t* game)
{
    assert(game);

    ptree_init_ptree(&game->services, NULL);

    /* ------------------------------------------------------------------------
     * Register built-in services
     * --------------------------------------------------------------------- */

    for(;;)
    {
        if(!(game->service.start = service_create(game->core, "start", game_start_wrapper,
                                   dynamic_call_create_type_info("void", 0, NULL)))) break;
        if(!(game->service.pause = service_create(game->core, "pause", game_pause_wrapper,
                                   dynamic_call_create_type_info("void", 0, NULL)))) break;
        if(!(game->service.exit  = service_create(game->core, "exit",  game_exit_wrapper,
                                   dynamic_call_create_type_info("void", 0, NULL)))) break;

        return 1;
    }

    return 0;
}
Example #2
0
JSBool 
js_createService(JSContext *cx, JSObject *obj, uintN argc, 
		 jsval *argv, jsval *rval)
{
  const char *title;
  const char *url;
  const char *type;
  const char *icon = NULL;
  JSObject *robj;
  JSBool enabled;

  if (!JS_ConvertArguments(cx, argc, argv, "sssb/s",
			   &title, &url, &type, &enabled, &icon))
    return JS_FALSE;

  js_plugin_t *jsp = JS_GetPrivate(cx, obj);

  js_service_t *jss = malloc(sizeof(js_service_t));
  jss->jss_ref = 2;
  jss->jss_s = service_create(title, url, type, icon, 0, enabled);
  LIST_INSERT_HEAD(&jsp->jsp_services, jss, jss_link);

  robj = JS_NewObjectWithGivenProto(cx, &service_class, NULL, NULL);
  *rval = OBJECT_TO_JSVAL(robj);

  JS_SetPrivate(cx, robj, jss);

  JS_DefineProperty(cx, robj, "enabled", BOOLEAN_TO_JSVAL(enabled),
		    NULL, setEnabled, JSPROP_PERMANENT);

  JS_DefineFunction(cx, robj, "destroy", destroy, 0, 0);
  return JS_TRUE;
}
static void export_service(struct gatt_db_attribute *attr, void *user_data)
{
	struct btd_gatt_client *client = user_data;
	struct service *service;

	if (gatt_db_service_get_claimed(attr))
		return;

	service = service_create(attr, client);
	if (!service)
		return;

	if (!create_characteristics(attr, service)) {
		error("Exporting characteristics failed");
		unregister_service(service);
		return;
	}

	queue_push_tail(client->services, service);

	/*
	 * Asynchronously update the "Characteristics" property of the service.
	 * If there are any pending reads to obtain the value of the "Extended
	 * Properties" descriptor then wait until they are complete.
	 */
	if (!service->chrcs_ready && queue_isempty(service->pending_ext_props))
		service->idle_id = g_idle_add(set_chrcs_ready, service);
}
Example #4
0
static void
bookmark_add(const char *title, const char *url, const char *type)
{
  bookmark_t *bm = calloc(1, sizeof(bookmark_t));
  prop_t *p = prop_create_root(NULL);
  prop_t *src = prop_create(p, "model");
 
  prop_set_string(prop_create(src, "type"), "bookmark");

  bm->bm_title_sub = bookmark_add_prop(src, "title",    title,   bm, set_title);
  bm->bm_url_sub   = bookmark_add_prop(src, "url",      url,     bm, set_url);
  bm->bm_type_sub  = bookmark_add_prop(src, "svctype",  type,    bm, set_type);

  bm->bm_service = service_create(title, url, type, NULL, 1, 1);

  prop_link(service_get_status_prop(bm->bm_service),
	    prop_create(src, "status"));

  prop_link(service_get_statustxt_prop(bm->bm_service),
	    prop_create(src, "statustxt"));


  prop_subscribe(PROP_SUB_TRACK_DESTROY | PROP_SUB_NO_INITIAL_UPDATE,
		 PROP_TAG_CALLBACK, bookmark_destroyed, bm,
		 PROP_TAG_ROOT, p,
		 PROP_TAG_MUTEX, &bookmark_mutex,
		 NULL);
  if(prop_set_parent(p, prop_create(bookmarks, "nodes")))
    abort();

}
Example #5
0
static void
set_status(disc_scanner_t *ds, disc_status_t status, const char *title)
{
  char buf[64];
  char url[URL_MAX];
  if(ds->ds_status == status)
    return;

  ds->ds_status = status;

  if(ds->ds_svc != NULL) {
    service_destroy(ds->ds_svc);
    ds->ds_svc = NULL;
  }

  switch(status) {
  case DISC_NO_DRIVE:
  case DISC_NO_DISC:
    break;

  case DISC_AUDIO:
    snprintf(buf, sizeof(buf), "Audio CD");
    snprintf(url, sizeof(url), "audiocd:%s", ds->ds_dev);
    ds->ds_svc = service_create(url, buf, url, "music", NULL, 0, 1,
				SVC_ORIGIN_MEDIA);
    break;

  case DISC_ISOFS:
    snprintf(buf, sizeof(buf), "DVD: %s", title);
    snprintf(url, sizeof(url), "dvd:%s", ds->ds_dev);

    ds->ds_svc = service_create(url, buf, url, "video", NULL, 0, 1,
				SVC_ORIGIN_MEDIA);
    break;

  case DISC_UNKNOWN_TYPE:
#if 0 /* FIXME: Must not pass url as NULL */
    snprintf(buf, sizeof(buf), "Unknown disc");
    ds->ds_svc = service_create(ds->ds_dev, buf, NULL, SVC_TYPE_VIDEO, NULL, 0);
#endif
    break;
  }
}
Eina_Bool Browser_Common_View::_share_via_nfc(std::string url)
{
	BROWSER_LOGD("[%s]", __func__);
	if (url.empty()) {
		show_msg_popup(BR_STRING_EMPTY);
		return EINA_FALSE;
	}

	struct ug_cbs cbs = {0, };
	cbs.layout_cb = __ug_layout_cb;
	cbs.result_cb = NULL;//__ug_result_cb;
	cbs.destroy_cb = __ug_destroy_cb;
	cbs.priv = (void *)this;

	char *share_url = (char *)strdup(url.c_str());
	if (!share_url) {
		BROWSER_LOGE("strdup failed");
		return EINA_FALSE;
	}

	service_h data = NULL;
	service_create(&data);
	if (data == NULL) {
		BROWSER_LOGE("fail to service_create.");
		return EINA_FALSE;
	}
	if (service_add_extra_data(data, "count", "1")) {
		BROWSER_LOGE("service_add_extra_data is failed.");
		service_destroy(data);
		return EINA_FALSE;
	}
	if (service_add_extra_data(data, "request_type", "data_buffer")) {
		BROWSER_LOGE("service_add_extra_data is failed.");
		service_destroy(data);
		return EINA_FALSE;
	}
	if (service_add_extra_data(data, "request_data", share_url)) {
		BROWSER_LOGE("service_add_extra_data is failed.");
		service_destroy(data);

		free(share_url);
		return EINA_FALSE;
	}

	if(!ug_create(NULL, "share-nfc-efl", UG_MODE_FULLVIEW, data, &cbs))
		BROWSER_LOGE("ug_create is failed.");

	if (service_destroy(data))
		BROWSER_LOGE("service_destroy is failed.");

	free(share_url);

	return EINA_TRUE;
}
Example #7
0
static void init(void)
{
	acl_socket_init();
	conf_load(__conf_file);
	//acl_msg_open("dgate.log", "dgate");
	acl_msg_stdout_enable(1);
	__service = service_create("0.0.0.0", 53, var_cfg_dns_neighbor_ip,
		var_cfg_dns_neighbor_port);
	printf("neighbor dns_ip: %s, dns_port: %d\r\n",
		var_cfg_dns_neighbor_ip, var_cfg_dns_neighbor_port);
}
Eina_Bool Browser_Common_View::_post_to_sns(std::string sns_name, std::string url)
{
	BROWSER_LOGD("sns_name=[%s],  url=[%s]", sns_name.c_str(), url.c_str());
	if (url.empty() || sns_name.empty()) {
		show_msg_popup(BR_STRING_EMPTY);
		return EINA_FALSE;
	}

	int index = 0;
	for (index = 0 ; index < m_sns_name_list.size() ; index++) {
		if (m_sns_name_list[index].find(sns_name) != string::npos)
			break;
	}

	if (m_sns_path_list[index].find("twitter") != string::npos
	    || m_sns_path_list[index].find("facebook") != string::npos) {

		int ret = 0;
		service_h service_handle = NULL;
		if (service_create(&service_handle) < 0) {
			BROWSER_LOGE("Fail to create service handle");
			return EINA_FALSE;
		}
		if (!service_handle) {
			BROWSER_LOGE("service handle is NULL");
			return EINA_FALSE;
		}
		if (service_set_operation(service_handle, SERVICE_OPERATION_SEND_TEXT) < 0) {
			BROWSER_LOGE("Fail to set service operation");
			service_destroy(service_handle);
			return EINA_FALSE;
		}
		if (service_add_extra_data(service_handle, SERVICE_DATA_TEXT, (char *)url.c_str()) < 0) {
			BROWSER_LOGE("Fail to set post data");
			service_destroy(service_handle);
			return EINA_FALSE;
		}
		if (service_set_package(service_handle, m_sns_path_list[index].c_str()) < 0) {
			BROWSER_LOGE("Fail to set SNS");
			service_destroy(service_handle);
			return EINA_FALSE;
		}
		if (service_send_launch_request(service_handle, NULL, NULL) < 0) {
			BROWSER_LOGE("Fail to launch service operation");
			service_destroy(service_handle);
			return EINA_FALSE;
		}
		service_destroy(service_handle);
	}

	return EINA_TRUE;
}
Eina_Bool Browser_Common_View::_add_to_contact(std::string number)
{
	if (number.empty()) {
		BROWSER_LOGE("number is null");
		return EINA_FALSE;
	}
	struct ug_cbs cbs = {0, };
	cbs.layout_cb = __ug_layout_cb;
	cbs.result_cb = NULL;//__ug_result_cb;
	cbs.destroy_cb = __ug_destroy_cb;
	cbs.priv = (void *)this;

	char *phone_number = (char *)strdup(number.c_str());
	if (!phone_number) {
		BROWSER_LOGE("strdup failed");
		return EINA_FALSE;
	}

	service_h data = NULL;
	service_create(&data);
	if (data == NULL) {
		BROWSER_LOGE("fail to service_create.");
		return EINA_FALSE;
	}
/*
type.
CT_UG_REQUEST_ADD = 21,
CT_UG_REQUEST_ADD_WITH_NUM = 22,
CT_UG_REQUEST_ADD_WITH_EMAIL = 23,
CT_UG_REQUEST_ADD_WITH_WEB = 24,
*/
	if (service_add_extra_data(data, "type", "22")) {
		BROWSER_LOGE("service_add_extra_data is failed.");
		service_destroy(data);
		return EINA_FALSE;
	}
	if (service_add_extra_data(data, "ct_num", number.c_str())) {
		BROWSER_LOGE("service_add_extra_data is failed.");
		service_destroy(data);
		return EINA_FALSE;
	}

	if (!ug_create(NULL, "contacts-details-efl", UG_MODE_FULLVIEW, data, &cbs))
		BROWSER_LOGE("ug_create is failed.");

	if (service_destroy(data))
		BROWSER_LOGE("service_destroy is failed.");

	free(phone_number);
}
Example #10
0
void service_start(const char *config) {
	initialize(config);
	worker_queue_init();
	timer_init(service_timer_dispatch, service_alloc);
	socket_init(service_alloc);

	struct module log_mod = {
		log_dispatch,
		log_create,
		log_release,
	};

	g.log = service_create(&log_mod, service_env_get("log"));
	service_create(&lua_mod, service_env_get("main"));

	int thread = atoi(service_env_get("thread"));

	start(thread);

	socket_unit();
	timer_unit();
	finalize();
}
Example #11
0
static void playMusic()
{
	service_h service;
	service_create(&service);
	service_set_operation(service, SERVICE_OPERATION_VIEW);
	service_set_package(service, SOUND_PLAYER_PKG_NAME);
	service_set_uri(service, "file:///opt/usr/media/Downloads/2.mp3");
	if (service_send_launch_request(service, NULL, NULL) == SERVICE_ERROR_NONE) {
		printf("Success\n");
	} else {
		printf("Fail\n");
	}
	service_destroy(service);
}
Example #12
0
static void
update_service(service_instance_t *si)
{
  if(si->si_service == NULL &&
     si->si_setting_enabled &&
     si->si_setting_title &&
     si->si_setting_type) {

    si->si_service = service_create(NULL, si->si_url, NULL, NULL,
				    si->si_probe, 0);
    prop_link(settings_get_value(si->si_setting_title), 
	      prop_create(si->si_service->s_root, "title"));
    prop_link(settings_get_value(si->si_setting_type), 
	      prop_create(si->si_service->s_root, "type"));
    prop_link(settings_get_value(si->si_setting_enabled), 
	      prop_create(si->si_service->s_root, "enabled"));
  }
}
void _rbutton_click_cb(void *data, Evas_Object *obj, void *event_info)
{
	service_h service;
	int ret;

	ret = service_create(&service);
	if (ret != SERVICE_ERROR_NONE) {
		INFO_LOG(UG_NAME_ERR, "service_create failed: %d", ret);
		return;
	}

	service_add_extra_data(service, "result", "rbutton_click");
	ug_send_result(ug_app_state->ug, service);

	service_destroy(service);

	wifi_exit();
}
Example #14
0
static void
check_disc_type(disc_scanner_t *ds)
{
  char *buf = memalign(32, 2048);
  char title[64];
  int r = DI_ReadDVD(buf, 1, 16);

  if(r) {
    notify_add(NOTIFY_ERROR, NULL, 5, "Unable to read disc, ejecting...");
    DI_Eject();

  } else {
    char *p = &buf[40];
    while(*p > 32 && p != &buf[72])
      p++;
    *p = 0;
    
    snprintf(title, sizeof(title), "DVD: %s", buf + 40);
    ds->ds_service = service_create(title, "dvd:/dev/di",
				    SVC_TYPE_VIDEO, NULL, 0);
    ds->ds_disc_ready = 1;
  }
  free(buf);
}
Example #15
0
static DWORD scmdatabase_load_services(struct scmdatabase *db)
{
    DWORD err;
    int i;

    for (i = 0; TRUE; i++)
    {
        WCHAR szName[MAX_SERVICE_NAME];
        struct service_entry *entry;
        HKEY hServiceKey;

        err = RegEnumKeyW(db->root_key, i, szName, MAX_SERVICE_NAME);
        if (err == ERROR_NO_MORE_ITEMS)
            break;

        if (err != 0)
        {
            WINE_ERR("Error %d reading key %d name - skipping\n", err, i);
            continue;
        }

        err = service_create(szName, &entry);
        if (err != ERROR_SUCCESS)
            break;

        WINE_TRACE("Loading service %s\n", wine_dbgstr_w(szName));
        err = RegOpenKeyExW(db->root_key, szName, 0, KEY_READ, &hServiceKey);
        if (err == ERROR_SUCCESS)
        {
            err = load_service_config(hServiceKey, entry);
            RegCloseKey(hServiceKey);
        }

        if (err != ERROR_SUCCESS)
        {
            WINE_ERR("Error %d reading registry key for service %s - skipping\n", err, wine_dbgstr_w(szName));
            free_service_entry(entry);
            continue;
        }

        if (entry->config.dwServiceType == 0)
        {
            /* Maybe an application only wrote some configuration in the service key. Continue silently */
            WINE_TRACE("Even the service type not set for service %s - skipping\n", wine_dbgstr_w(szName));
            free_service_entry(entry);
            continue;
        }

        if (!validate_service_config(entry))
        {
            WINE_ERR("Invalid configuration of service %s - skipping\n", wine_dbgstr_w(szName));
            free_service_entry(entry);
            continue;
        }

        entry->status.dwServiceType = entry->config.dwServiceType;
        entry->db = db;

        list_add_tail(&db->services, &entry->entry);
    }
    return ERROR_SUCCESS;
}
Eina_Bool Browser_Common_View::_send_via_message(std::string url, std::string to, Eina_Bool attach_file)
{
	BROWSER_LOGD("[%s], url[%s], to[%s]", __func__, url.c_str(), to.c_str());
	if (url.empty() && to.empty()) {
		show_msg_popup(BR_STRING_EMPTY);
		return EINA_FALSE;
	}

	service_h service_handle = NULL;
	if (service_create(&service_handle) < 0) {
		BROWSER_LOGE("Fail to create service handle");
		return EINA_FALSE;
	}

	if (!service_handle) {
		BROWSER_LOGE("Fail to create service handle");
		return EINA_FALSE;
	}

	if (!url.empty()) {
		if (attach_file) {
			if (service_set_operation(service_handle, SERVICE_OPERATION_SEND) < 0) {
				BROWSER_LOGE("Fail to set service operation");
				service_destroy(service_handle);
				return EINA_FALSE;
			}

			if (service_add_extra_data(service_handle, "ATTACHFILE", url.c_str())) {
				BROWSER_LOGE("Fail to set extra data");
				service_destroy(service_handle);
				return EINA_FALSE;
			}
		} else {
			if (service_set_operation(service_handle, SERVICE_OPERATION_SEND_TEXT) < 0) {
				BROWSER_LOGE("Fail to set service operation");
				service_destroy(service_handle);
				return EINA_FALSE;
			}

			if (service_add_extra_data(service_handle, SERVICE_DATA_TEXT, url.c_str()) < 0) {
				BROWSER_LOGE("Fail to set extra data");
				service_destroy(service_handle);
				return EINA_FALSE;
			}
		}
	}

	if (!to.empty()) {
		if (url.empty()) {
			if (service_set_operation(service_handle, SERVICE_OPERATION_SEND_TEXT) < 0) {
				BROWSER_LOGE("Fail to set service operation");
				service_destroy(service_handle);
				return EINA_FALSE;
			}
		}

		if (service_add_extra_data(service_handle, SERVICE_DATA_TO , to.c_str()) < 0) {
			BROWSER_LOGE("Fail to set extra data");
			service_destroy(service_handle);
			return EINA_FALSE;
		}
	}

	if (service_set_package(service_handle, SEC_MESSAGE) < 0) {//SEC_EMAIL
		BROWSER_LOGE("Fail to launch service operation");
		service_destroy(service_handle);
		return EINA_FALSE;
	}

	if (service_send_launch_request(service_handle, NULL, NULL) < 0) {
		BROWSER_LOGE("Fail to launch service operation");
		service_destroy(service_handle);
		return EINA_FALSE;
	}
	service_destroy(service_handle);

	return EINA_TRUE;
}
/*
 * Elevate from local admin to local system via Named Pipe Impersonation. We spawn a cmd.exe under local
 * system which then connects to our named pipe and we impersonate this client. This can be done by an
 * Administrator without the need for SeDebugPrivilege.  Works on 2000, XP, 2003 and 2008 for all local
 * administrators. On Vista and 7 it will only work if the host process has been elevated through UAC
 * first. Does not work on NT4.
 */
DWORD elevate_via_service_namedpipe(Remote * remote, Packet * packet)
{
	DWORD dwResult              = ERROR_SUCCESS;
	char * cpServiceName        = NULL;
	THREAD * pThread            = NULL;
	HANDLE hSem                 = NULL;
	char cServiceArgs[MAX_PATH] = {0};
	char cServicePipe[MAX_PATH] = {0};
	OSVERSIONINFO os            = {0};

	do {
		os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

		if (!GetVersionEx(&os)) {
			BREAK_ON_ERROR("[ELEVATE] elevate_via_service_namedpipe: GetVersionEx failed")
		}

		// filter out Windows NT4
		if (os.dwMajorVersion == 4 && os.dwMinorVersion == 0) {
			SetLastError(ERROR_ACCESS_DENIED);
			BREAK_ON_ERROR("[ELEVATE] elevate_via_service_namedpipe: Windows NT4 not supported.")
		}

		cpServiceName = packet_get_tlv_value_string(packet, TLV_TYPE_ELEVATE_SERVICE_NAME);
		if (!cpServiceName) {
			BREAK_WITH_ERROR("[ELEVATE] elevate_via_service_namedpipe. invalid arguments",
				ERROR_BAD_ARGUMENTS);
		}

		_snprintf_s(cServicePipe, sizeof(cServicePipe), MAX_PATH,
			"\\\\.\\pipe\\%s", cpServiceName);

		_snprintf_s(cServiceArgs, sizeof(cServiceArgs), MAX_PATH,
			"cmd.exe /c echo %s > %s", cpServiceName, cServicePipe);

		hSem = CreateSemaphore(NULL, 0, 1, NULL);
		pThread = thread_create(elevate_namedpipe_thread, &cServicePipe, remote, hSem);
		if (!pThread) {
			BREAK_WITH_ERROR("[ELEVATE] elevate_via_service_namedpipe. thread_create failed",
				ERROR_INVALID_HANDLE);
		}

		if (!thread_run(pThread)) {
			BREAK_WITH_ERROR("[ELEVATE] elevate_via_service_namedpipe. thread_run failed",
				ERROR_ACCESS_DENIED);
		}

		//wait for the thread to create the pipe(if it times out terminate)
                if (hSem) {
		        if (WaitForSingleObject(hSem, 500) != WAIT_OBJECT_0) {
			        BREAK_WITH_ERROR("[ELEVATE] elevate_via_service_namedpipe. WaitForSingleObject failed",
					ERROR_ACCESS_DENIED);
			}
                } else {
                        Sleep(500);
		}

		// start the elevator service (if it doesnt start first time we need to create it and then start it).
		if (service_start(cpServiceName) != ERROR_SUCCESS) {
			dprintf("[ELEVATE] service starting failed, attempting to create");
			if (service_create(cpServiceName, cServiceArgs) != ERROR_SUCCESS) {
				BREAK_ON_ERROR("[ELEVATE] elevate_via_service_namedpipe. service_create failed");
			}
			dprintf("[ELEVATE] creation of service succeeded, attempting to start");
			// we dont check a return value for service_start as we expect it to fail as cmd.exe is not
			// a valid service and it will never signal to the service manager that is is a running service.
			service_start(cpServiceName);
		}

		// signal our thread to terminate if it is still running
		thread_sigterm(pThread);

		// and wait for it to terminate...
		thread_join(pThread);

		// get the exit code for our pthread
		dprintf("[ELEVATE] dwResult before exit code: %u", dwResult);
		if (!GetExitCodeThread(pThread->handle, &dwResult)) {
			BREAK_WITH_ERROR("[ELEVATE] elevate_via_service_namedpipe. GetExitCodeThread failed",
				ERROR_INVALID_HANDLE);
		}
		dprintf("[ELEVATE] dwResult after exit code: %u", dwResult);

	} while (0);
    if( first )
    {
      first = 0;
      xSemaphoreTake( exti_0_semaphor, portMAX_DELAY );
    }

    xSemaphoreTake( exti_0_semaphor, portMAX_DELAY );
  }
}

// this function is called before FreeRTOS scheduler starts, in main function
// return 0 if failed
//==============================================================================
int transceiver_service_create( void )
{
  thread_t thread =
  {
      .thread_name = transceiver_thread,
      .name = services_names[1],
      .stack_depth = 128,
      .params = NULL,
      .priority = 2,
      .hndl = NULL	// we aren't interesting in this handle
      };

  // currently transceiver service doesn't serve any requests, hw works only as receiver !!!
  cur_serv_id = service_create( &thread, NULL );

  return cur_serv_id;
}
Eina_Bool Browser_Common_View::_launch_streaming_player(const char *url, const char *cookie)
{
	BROWSER_LOGD("%s", __func__);
	if (!url || strlen(url) == 0) {
		BROWSER_LOGE("url is empty");
		return EINA_FALSE;
	}

	bool is_running = false;
	if (app_manager_is_running(SEC_VT_CALL, &is_running) < 0) {
		BROWSER_LOGE("Fail to get app running information\n");
		return EINA_FALSE;
	}
	if (is_running) {
		BROWSER_LOGE("video-call is running......\n");
		show_msg_popup(BR_STRING_WARNING_VIDEO_PLAYER);
		return EINA_FALSE;
	}

	service_h service_handle = NULL;

	if (service_create(&service_handle) < 0) {
		BROWSER_LOGE("Fail to create service handle");
		return EINA_FALSE;
	}

	if (!service_handle) {
		BROWSER_LOGE("service handle is NULL");
		return EINA_FALSE;
	}

	BROWSER_LOGD("url=[%s]", url);
	if (service_add_extra_data(service_handle, "path", url) < 0) {
		BROWSER_LOGE("Fail to set extra data");
		service_destroy(service_handle);
		return EINA_FALSE;
	}

	if (cookie && strlen(cookie)) {
		if (service_add_extra_data(service_handle, "cookie", cookie) < 0) {
			BROWSER_LOGE("Fail to set extra data");
			service_destroy(service_handle);
			return EINA_FALSE;
		}
	}

	if (service_set_package(service_handle,SEC_STREAMING_PLAYER) < 0) {
		BROWSER_LOGE("Fail to set package");
		service_destroy(service_handle);
		return EINA_FALSE;
	}

	if (service_send_launch_request(service_handle, NULL, NULL) < 0) {
		BROWSER_LOGE("Fail to launch service operation");
		service_destroy(service_handle);
		return EINA_FALSE;
	}

	service_destroy(service_handle);

	return EINA_TRUE;
}
Eina_Bool Browser_Common_View::_send_via_email(std::string url, Eina_Bool attach_file)
{
	BROWSER_LOGD("[%s], url[%s]", __func__, url.c_str());
	if (url.empty()) {
		show_msg_popup(BR_STRING_EMPTY);
		return EINA_FALSE;
	}

	service_h service_handle = NULL;
	if (service_create(&service_handle) < 0) {
		BROWSER_LOGE("Fail to create service handle");
		return EINA_FALSE;
	}

	if (!service_handle) {
		BROWSER_LOGE("Fail to create service handle");
		return EINA_FALSE;
	}

	if (attach_file) {
		if (service_set_operation(service_handle, SERVICE_OPERATION_SEND) < 0) {
			BROWSER_LOGE("Fail to set service operation");
			service_destroy(service_handle);
		return EINA_FALSE;
	}

		if (service_set_uri(service_handle, url.c_str()) < 0) {
			BROWSER_LOGE("Fail to set uri");
			service_destroy(service_handle);
			return EINA_FALSE;
		}
	} else {
		if (service_set_operation(service_handle, SERVICE_OPERATION_SEND_TEXT) < 0) {
			BROWSER_LOGE("Fail to set service operation");
			service_destroy(service_handle);
			return EINA_FALSE;
		}

		if (strstr(url.c_str(), BROWSER_MAIL_TO_SCHEME)) {
			if (service_add_extra_data(service_handle, SERVICE_DATA_TO, url.c_str() + strlen(BROWSER_MAIL_TO_SCHEME)) < 0) {
				BROWSER_LOGE("Fail to set mailto data");
				service_destroy(service_handle);
				return EINA_FALSE;
			}
		} else {
			if (service_add_extra_data(service_handle, SERVICE_DATA_TEXT, url.c_str()) < 0) {
				BROWSER_LOGE("Fail to set extra data");
				service_destroy(service_handle);
				return EINA_FALSE;
			}
		}
	}

	if (service_set_package(service_handle, SEC_EMAIL) < 0) {
		BROWSER_LOGE("Fail to launch service operation");
		service_destroy(service_handle);
		return EINA_FALSE;
	}

	if (service_send_launch_request(service_handle, NULL, NULL) < 0) {
		BROWSER_LOGE("Fail to launch service operation");
		service_destroy(service_handle);
		return EINA_FALSE;
	}
	service_destroy(service_handle);

	return EINA_TRUE;
}
Example #21
0
static void cmd_init(struct http_channel *c)
{
    struct http_request *r = c->request;
    const char *clear = http_argbyname(r, "clear");
    const char *content_type = http_lookup_header(r->headers, "Content-Type");
    unsigned int sesid;
    struct http_session *s;
    struct http_response *rs = c->response;
    struct conf_service *service = 0; /* no service (yet) */

    if (r->content_len && content_type &&
            !yaz_strcmp_del("text/xml", content_type, "; "))
    {
        xmlDoc *doc = xmlParseMemory(r->content_buf, r->content_len);
        xmlNode *root_n;
        if (!doc)
        {
            error(rs, PAZPAR2_MALFORMED_SETTING, 0);
            return;
        }
        root_n = xmlDocGetRootElement(doc);
        service = service_create(c->server, root_n);
        xmlFreeDoc(doc);
        if (!service)
        {
            error(rs, PAZPAR2_MALFORMED_SETTING, 0);
            return;
        }
    }

    if (!service)
    {
        const char *service_name = http_argbyname(c->request, "service");
        service = locate_service(c->server, service_name);
        if (!service)
        {
            error(rs, PAZPAR2_NO_SERVICE, service_name ? service_name : "unnamed");
            return;
        }
    }
    sesid = make_sessionid();
    s = http_session_create(service, c->http_sessions, sesid);

    yaz_log(c->http_sessions->log_level, "Session init %u ", sesid);
    if (!clear || *clear == '0')
        session_init_databases(s->psession);
    else
        yaz_log(YLOG_LOG, "Session %u init: No databases preloaded", sesid);

    if (process_settings(s->psession, c->request, c->response) < 0)
        return;

    response_open(c, "init");
    wrbuf_printf(c->wrbuf, "<session>%d", sesid);
    if (c->server->server_id)
    {
        wrbuf_puts(c->wrbuf, ".");
        wrbuf_puts(c->wrbuf, c->server->server_id);
    }
    wrbuf_puts(c->wrbuf, "</session>"
               "<protocol>" PAZPAR2_PROTOCOL_VERSION "</protocol>");

    wrbuf_printf(c->wrbuf, "<keepAlive>%d</keepAlive>\n", 1000 * ((s->psession->service->session_timeout >= 20) ?
                 (s->psession->service->session_timeout - 10) : 50));
    response_close(c, "init");
}
Example #22
0
JNIEXPORT void JNICALL
Java_com_lonelycoder_mediaplayer_Core_coreInit(JNIEnv *env, jobject obj, jstring j_settings, jstring j_cachedir, jstring j_sdcard, jstring j_android_id, jint time_24hrs)
{
  char path[PATH_MAX];
  trace_arch(TRACE_INFO, "Core", "Native core initializing");
  gconf.trace_level = TRACE_DEBUG;
  gconf.time_format_system = time_24hrs ? TIME_FORMAT_24 : TIME_FORMAT_12;

  struct timeval tv;
  gettimeofday(&tv, NULL);
  srand(tv.tv_usec);

  const char *settings   = (*env)->GetStringUTFChars(env, j_settings, 0);
  const char *cachedir   = (*env)->GetStringUTFChars(env, j_cachedir, 0);
  const char *sdcard     = (*env)->GetStringUTFChars(env, j_sdcard, 0);
  const char *android_id = (*env)->GetStringUTFChars(env, j_android_id, 0);

  gconf.persistent_path = strdup(settings);
  gconf.cache_path      = strdup(cachedir);

  snprintf(path, sizeof(path), "%s/Download", sdcard);
  mkdir(path, 0770);
  snprintf(path, sizeof(path), "%s/Download/movian_upgrade.apk", sdcard);
  gconf.upgrade_path = strdup(path);
  unlink(gconf.upgrade_path);

  uint8_t digest[16];

  md5_decl(ctx);
  md5_init(ctx);

  md5_update(ctx, (const void *)android_id, strlen(android_id));
  md5_update(ctx, (const void *)android_serialno, strlen(android_serialno));

  md5_final(ctx, digest);
  bin2hex(gconf.device_id, sizeof(gconf.device_id), digest, sizeof(digest));


  (*env)->ReleaseStringUTFChars(env, j_settings, settings);
  (*env)->ReleaseStringUTFChars(env, j_cachedir, cachedir);
  (*env)->ReleaseStringUTFChars(env, j_sdcard,   sdcard);
  (*env)->ReleaseStringUTFChars(env, j_android_id, android_id);


  gconf.concurrency =   sysconf(_SC_NPROCESSORS_CONF);

  setlocale(LC_ALL, "");

  signal(SIGPIPE, SIG_IGN);

  main_init();

  jclass c = (*env)->FindClass(env, "com/lonelycoder/mediaplayer/Core");
  STCore = (*env)->NewGlobalRef(env, c);

  prop_jni_init(env);

  service_create("music", "Music", "file:///sdcard/Music",
                 "music", NULL, 0, 1, SVC_ORIGIN_SYSTEM);

  service_create("music", "Movies", "file:///sdcard/Movies",
                 "video", NULL, 0, 1, SVC_ORIGIN_SYSTEM);

  android_nav = nav_spawn();
}