int _bt_opp_client_cancel_push(void)
{
	DBusGConnection *g_conn;
	DBusGProxy *client_proxy;

	retv_if(sending_info == NULL, BLUETOOTH_ERROR_NOT_IN_OPERATION);

	sending_info->is_canceled = TRUE;

	if (sending_info->transfer_info) {
		dbus_g_proxy_call_no_reply(sending_info->transfer_info->proxy,
					"Cancel", G_TYPE_INVALID);
	} else {
		retv_if(sending_info->sending_proxy == NULL,
					BLUETOOTH_ERROR_INTERNAL);

		g_conn = _bt_get_session_gconn();
		retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);

		client_proxy =	dbus_g_proxy_new_for_name(g_conn, BT_OBEX_SERVICE_NAME,
						"/", BT_OBEX_CLIENT_INTERFACE);

		retv_if(client_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);

		dbus_g_proxy_cancel_call(client_proxy,
					sending_info->sending_proxy);

		g_idle_add(__bt_cancel_push_cb, NULL);
	}

	return BLUETOOTH_ERROR_NONE;
}
static gboolean __bt_progress_callback(DBusGMethodInvocation *context,
					DBusGProxy *transfer,
					guint64 transferred,
					gpointer user_data)
{
	int percentage_progress;
	gint64 size;
	int result = BLUETOOTH_ERROR_NONE;

	dbus_g_method_return(context);

	retv_if(sending_info == NULL, TRUE);
	retv_if(sending_info->transfer_info == NULL, TRUE);

	size = sending_info->transfer_info->size;

	if (size != 0)
		percentage_progress = (int)(((gdouble)transferred /
				(gdouble)size) * 100);
	else
		percentage_progress = 0;

	/* Send the event in only error none case */
	_bt_send_event(BT_OPP_CLIENT_EVENT,
			BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS,
			DBUS_TYPE_INT32, &result,
			DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
			DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
			DBUS_TYPE_INT32, &percentage_progress,
			DBUS_TYPE_INT32, &sending_info->request_id,
			DBUS_TYPE_INVALID);

	return TRUE;
}
int _bt_unregister_obex_server(void)
{
	GError *g_error = NULL;

	retv_if(agent_info.obex_agent == NULL,
				BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST);

	retv_if(agent_info.proxy == NULL,
				BLUETOOTH_ERROR_INTERNAL);

	dbus_g_proxy_call(agent_info.proxy, "UnregisterAgent", &g_error,
			  DBUS_TYPE_G_OBJECT_PATH, BT_OBEX_SERVER_AGENT_PATH,
			  G_TYPE_INVALID, G_TYPE_INVALID);
	if (g_error != NULL) {
		BT_ERR("Agent unregistration failed: %s", g_error->message);
		g_error_free(g_error);
	}

	g_object_unref(agent_info.proxy);
	agent_info.proxy = NULL;

	g_object_unref(agent_info.obex_agent);
	agent_info.obex_agent = NULL;

	return BLUETOOTH_ERROR_NONE;
}
int _bt_obex_server_allocate(char *sender, const char *dest_path, int app_pid, gboolean is_native)
{
	if (__bt_check_folder_path(dest_path) == FALSE)
		return BLUETOOTH_ERROR_INVALID_PARAM;

	if (is_native == TRUE) {
		retv_if(agent_info.native_server,
				BLUETOOTH_ERROR_DEVICE_BUSY);

		/* Force to change the control to native */
		agent_info.native_server = g_malloc0(sizeof(bt_server_info_t));
		agent_info.native_server->dest_path = g_strdup(dest_path);
		agent_info.native_server->sender = g_strdup(sender);
		agent_info.native_server->app_pid = app_pid;
		agent_info.server_type = BT_NATIVE_SERVER;
		_bt_unregister_osp_server_in_agent(BT_OBEX_SERVER, NULL);
	} else {
		retv_if(agent_info.custom_server,
				BLUETOOTH_ERROR_DEVICE_BUSY);

		/* Force to change the control to custom */
		agent_info.custom_server = g_malloc0(sizeof(bt_server_info_t));
		agent_info.custom_server->dest_path = g_strdup(dest_path);
		agent_info.custom_server->sender = g_strdup(sender);
		agent_info.custom_server->app_pid = app_pid;
		agent_info.server_type = BT_CUSTOM_SERVER;
		_bt_register_osp_server_in_agent(BT_OBEX_SERVER, NULL);
	}

	return BLUETOOTH_ERROR_NONE;
}
menu_screen_error_e list_get_item(app_list *list, app_list_item **item)
{
	retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == list->list, MENU_SCREEN_ERROR_INVALID_PARAMETER);

	*item = eina_list_nth(list->list, list->cur_idx);

	return MENU_SCREEN_ERROR_OK;
}
menu_screen_error_e list_sort(app_list *list, int (*_sort_cb)(const void *d1, const void *d2))
{
	retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER);

	list->list = eina_list_sort(list->list, eina_list_count(list->list), _sort_cb);
	retv_if(NULL == list->list, MENU_SCREEN_ERROR_FAIL);

	return MENU_SCREEN_ERROR_OK;
}
menu_screen_error_e list_count(app_list *list, int *count)
{
	retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == list->list, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == count, MENU_SCREEN_ERROR_INVALID_PARAMETER);

	*count = eina_list_count(list->list);

	return MENU_SCREEN_ERROR_OK;
}
menu_screen_error_e list_remove_item(app_list *list, app_list_item *item)
{
	retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == list->list, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == item, MENU_SCREEN_ERROR_INVALID_PARAMETER);

	list->list = eina_list_remove(list->list, item);

	return MENU_SCREEN_ERROR_OK;
}
menu_screen_error_e list_is_ended(app_list *list, bool *flag)
{
	int count;

	retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == list->list, MENU_SCREEN_ERROR_INVALID_PARAMETER);

	count = eina_list_count(list->list);
	*flag = (list->cur_idx == count) ? true : false;

	return MENU_SCREEN_ERROR_OK;
}
static menu_screen_error_e _insert_page_at(Evas_Object *scroller, Evas_Object *page, int index)
{
	unsigned int nr_of_pages;
	Evas_Object *mapbuf;
	Evas_Object *box;

	retv_if(NULL == page, MENU_SCREEN_ERROR_FAIL);

	if (index < 0) {
		_D("Out of range");
		index = 0;
	}

	box = evas_object_data_get(scroller, "box");
	retv_if(NULL == box, MENU_SCREEN_ERROR_FAIL);

	nr_of_pages = page_scroller_count_page(scroller);
	if (index >= nr_of_pages) {
		_D("Out of range. index : %d, total : %d", index, nr_of_pages);
		mapbuf = evas_object_data_get(page, "mapbuf");
		if (mapbuf) {
			elm_box_pack_end(box, mapbuf);
		} else {
			elm_box_pack_end(box, page);
		}
	} else {
		Evas_Object *current;
		Evas_Object *current_mapbuf;
		const Eina_List *page_list;

		page_list = elm_box_children_get(box);
		retv_if(NULL == page_list, MENU_SCREEN_ERROR_FAIL);

		current = eina_list_nth(page_list, index);
		retv_if(NULL == current, MENU_SCREEN_ERROR_FAIL);

		current_mapbuf = mapbuf_get_mapbuf(current);
		mapbuf = mapbuf_get_mapbuf(page);

		if (current_mapbuf && mapbuf) {
			elm_box_pack_before(box, mapbuf, current_mapbuf);
		} else if (!current_mapbuf && !mapbuf) {
			elm_box_pack_before(box, page, current);
		} else {
			_D("Page has mapbuf, invalid");
		}
	}

	page_mark_dirty(page);

	return MENU_SCREEN_ERROR_OK;
}
static char *__bt_get_remote_device_name(const char *bdaddress)
{
	GError *error = NULL;
	char *device_path = NULL;
	char *name = NULL;
	GHashTable *hash = NULL;
	GValue *value;
	DBusGProxy *device_proxy;
	DBusGProxy *adapter_proxy;
	DBusGConnection *conn;

	retv_if(bdaddress == NULL, NULL);

	adapter_proxy = _bt_get_adapter_proxy();
	retv_if(adapter_proxy == NULL, NULL);

	conn = _bt_get_system_gconn();
	retv_if(conn == NULL, NULL);

	dbus_g_proxy_call(adapter_proxy, "FindDevice", NULL,
			  G_TYPE_STRING, bdaddress, G_TYPE_INVALID,
			  DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID);

	retv_if(device_path == NULL, NULL);

	device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
				      device_path, BT_DEVICE_INTERFACE);
	g_free(device_path);
	retv_if(device_proxy == NULL, NULL);
	if (!dbus_g_proxy_call(device_proxy, "GetProperties", &error,
			G_TYPE_INVALID,
			dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
			&hash, G_TYPE_INVALID)) {
		if (error) {
			BT_ERR( "error in GetBasicProperties [%s]\n", error->message);
			g_error_free(error);
		}
		g_object_unref(device_proxy);
		return NULL;
	}

	if (hash != NULL) {
		value = g_hash_table_lookup(hash, "Alias");
		name = value ? g_value_dup_string(value) : NULL;
		g_hash_table_destroy(hash);
	}

	g_object_unref(device_proxy);

	return name;
}
Beispiel #12
0
static menu_screen_error_e _animated_pack_item(Evas_Object *item, Evas_Object *scroller, Evas_Object *page, int from)
{
	Evas_Object *item_out_page = NULL;
	char buf[32];
	int to;
	int page_no;

	retv_if(NULL == item, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == scroller, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == page, MENU_SCREEN_ERROR_INVALID_PARAMETER);

	page_no = page_scroller_get_page_no(scroller, page);
	do {
		to = page_find_empty_near(page, from);
		if (to < 0) {
			int page_max_app;
			page_max_app = (int) evas_object_data_get(page, "page_max_app");
			to = page_max_app - 1;
			item_out_page = page_unpack_item_at(page, to);
		}

		for (to --; to >= from; to --) {
			Evas_Object *item_in_page;
			item_in_page = page_unpack_item_at(page, to);
			page_pack_item(page, to + 1, item_in_page);
			snprintf(buf, 32, "menu%d", to + 1);
			edje_object_signal_emit(_EDJ(page), STR_MOVE_PREV, buf);
			edje_object_signal_emit(_EDJ(page), STR_ANI_RETURN, buf);
		}

		page_pack_item(page, from, item);

		if (!item_out_page) break;

		page_no ++;
		page = page_scroller_get_page_at(scroller, page_no);
		if (!page) {
			int rotate;
			rotate = (int) evas_object_data_get(scroller, "rotate");
			page = page_create(scroller, page_no, rotate);
			retv_if(NULL == page, MENU_SCREEN_ERROR_FAIL);
			mapbuf_enable(page, 0);
		}

		from = 0;
		item = item_out_page;
		item_out_page = NULL;
	} while (page && item);

	return MENU_SCREEN_ERROR_OK;
}
menu_screen_error_e list_next(app_list *list)
{
	int count;

	retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == list->list, MENU_SCREEN_ERROR_INVALID_PARAMETER);

	count = eina_list_count(list->list);
	if (list->cur_idx + 1 == count) return MENU_SCREEN_ERROR_NO_DATA;

	list->cur_idx ++;

	return MENU_SCREEN_ERROR_OK;
}
Beispiel #14
0
HAPI Evas_Object* layout_load_edj(Evas_Object *parent, const char *edjname, const char *grpname)
{
	Evas_Object *eo;

	retv_if(NULL == parent, NULL);

	eo = elm_layout_add(parent);
	retv_if(NULL == eo, NULL);
	retv_if(EINA_FALSE == elm_layout_file_set(eo, edjname, grpname), NULL);

	evas_object_data_set(_EDJ(eo), "evas_object", eo);
	evas_object_show(eo);

	return eo;
}
int cts_inotify_subscribe(const char *path, void (*cb)(void *), void *data)
{
	int ret, wd;
	noti_info *noti, *same_noti = NULL;
	GSList *it;

	retv_if(NULL==path, CTS_ERR_ARG_NULL);
	retv_if(NULL==cb, CTS_ERR_ARG_NULL);
	retvm_if(cts_inoti_fd < 0, CTS_ERR_ENV_INVALID,
			"cts_inoti_fd(%d) is invalid", cts_inoti_fd);

	wd = cts_inotify_get_wd(cts_inoti_fd, path);
	retvm_if(-1 == wd, CTS_ERR_INOTIFY_FAILED,
			"cts_inotify_get_wd() Failed(%d)", errno);

	for (it=cts_noti_list;it;it=it->next)
	{
		if (it->data)
		{
			same_noti = it->data;
			if (same_noti->wd == wd && same_noti->cb == cb && same_noti->cb_data == data) {
				break;
			}
			else {
				same_noti = NULL;
			}
		}
	}

	if (same_noti) {
		cts_inotify_watch(cts_inoti_fd, path);
		ERR("The same callback(%s) is already exist", path);
		return CTS_ERR_ALREADY_EXIST;
	}

	ret = cts_inotify_watch(cts_inoti_fd, path);
	retvm_if(CTS_SUCCESS != ret, ret, "cts_inotify_watch() Failed");

	noti = calloc(1, sizeof(noti_info));
	retvm_if(NULL == noti, CTS_ERR_OUT_OF_MEMORY, "calloc() Failed");

	noti->wd = wd;
	noti->cb_data = data;
	noti->cb = cb;
	cts_noti_list = g_slist_append(cts_noti_list, noti);

	return CTS_SUCCESS;
}
static int __bt_get_transfer_properties(bt_transfer_info_t *transfer_info,
					const char *transfer_path)
{
	GHashTable *hash = NULL;
	GValue *value;
	DBusGProxy *transfer_proxy;
	char *bdaddress;

	BT_CHECK_PARAMETER(transfer_info, return);
	BT_CHECK_PARAMETER(transfer_path, return);

	transfer_proxy = __bt_get_transfer_proxy(transfer_path);

	retv_if(transfer_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);

	dbus_g_proxy_call(transfer_proxy, "GetProperties", NULL,
	                        G_TYPE_INVALID,
	                        dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
	                        &hash, G_TYPE_INVALID);

	if (hash == NULL) {
		g_object_unref(transfer_proxy);
		return BLUETOOTH_ERROR_INTERNAL;
	}

	value = g_hash_table_lookup(hash, "Operation");
	transfer_info->type = value ? g_strdup(g_value_get_string(value)) : NULL;
	if (!transfer_info->type)
		goto fail;

	value = g_hash_table_lookup(hash, "Filename");
	transfer_info->filename = value ? g_strdup(g_value_get_string(value)) : NULL;
	if (!transfer_info->filename)
		goto fail;

	value = g_hash_table_lookup(hash, "Size");
	transfer_info->file_size  = value ? g_value_get_uint64(value) : 0;

	transfer_info->path = g_strdup(transfer_path);
	transfer_info->transfer_id = __bt_get_transfer_id(transfer_path);

	value = g_hash_table_lookup(hash, "Address");
	bdaddress = value ? (char *)g_value_get_string(value) : NULL;
	if (!bdaddress)
		goto fail;

	transfer_info->device_name = __bt_get_remote_device_name(bdaddress);
	if (!transfer_info->device_name)
		transfer_info->device_name = g_strdup(bdaddress);

	g_hash_table_destroy(hash);
	g_object_unref(transfer_proxy);
	return BLUETOOTH_ERROR_NONE;

fail:
	g_hash_table_destroy(hash);
	g_object_unref(transfer_proxy);
	return BLUETOOTH_ERROR_INTERNAL;
}
int _bt_register_obex_server(void)
{
	DBusGConnection *g_conn;
	DBusGProxy *manager_proxy;
	GError *g_error = NULL;

	/* Get the session bus. */
	g_conn = _bt_get_session_gconn();
	retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);

	if (!agent_info.obex_agent) {
		agent_info.obex_agent = _bt_obex_agent_new();

		retv_if(agent_info.obex_agent == NULL, BLUETOOTH_ERROR_INTERNAL);

		_bt_obex_setup(agent_info.obex_agent, BT_OBEX_SERVER_AGENT_PATH);

		_bt_obex_set_authorize_cb(agent_info.obex_agent,
					__bt_authorize_cb, NULL);
	}

	manager_proxy = dbus_g_proxy_new_for_name(g_conn, BT_OBEX_SERVICE,
						"/", BT_OBEX_MANAGER);

	if (manager_proxy == NULL) {
		g_object_unref(agent_info.obex_agent);
		agent_info.obex_agent = NULL;
		return BLUETOOTH_ERROR_INTERNAL;
	}

	dbus_g_proxy_call(manager_proxy, "RegisterAgent", &g_error,
			  DBUS_TYPE_G_OBJECT_PATH, BT_OBEX_SERVER_AGENT_PATH,
			  G_TYPE_INVALID, G_TYPE_INVALID);
	if (g_error != NULL) {
		BT_ERR("Agent registration failed: %s\n", g_error->message);
		g_object_unref(agent_info.obex_agent);
		agent_info.obex_agent = NULL;
		g_object_unref(manager_proxy);
		g_error_free(g_error);
		return BLUETOOTH_ERROR_INTERNAL;
	}

	agent_info.proxy = manager_proxy;

	return BLUETOOTH_ERROR_NONE;
}
menu_screen_error_e list_first(app_list *list)
{
	retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER);

	list->cur_idx = 0;

	return MENU_SCREEN_ERROR_OK;
}
Beispiel #19
0
static menu_screen_error_e _find_position_by_name(Evas_Object *scroller, int *candidate_page, int *candidate_pos, void *data)
{
	Evas_Object *page;
	Evas_Object *item;
	register int page_no;
	register int position_no;
	unsigned int nr_of_pages;
	int page_max_app;
	app_info_t *ai = data;

	retv_if(NULL == scroller, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == candidate_page, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == candidate_pos, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == data, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == ai->name, MENU_SCREEN_ERROR_INVALID_PARAMETER);

	*candidate_page = 0;
	*candidate_pos = 0;
	nr_of_pages = page_scroller_count_page(scroller);
	page_max_app = (int) evas_object_data_get(scroller, "page_max_app");
	for (page_no = 0; page_no < nr_of_pages; page_no ++) {
		page = page_scroller_get_page_at(scroller, page_no);
		if (!page) {
			_D("Page is not found at %d", page_no);
			return MENU_SCREEN_ERROR_FAIL;
		}

		for (position_no = 0; position_no < page_max_app; position_no ++) {
			char *name;

			item = page_get_item_at(page, position_no);
			if (!item) {
				*candidate_page = page_no;
				*candidate_pos = position_no;
				return MENU_SCREEN_ERROR_OK;
			} else if ((name = item_get_name(item)) && strcmp(name, ai->name) > 0) {
				*candidate_page = page_no;
				*candidate_pos = position_no;
				return MENU_SCREEN_ERROR_OK;
			}
		}
	}

	return MENU_SCREEN_ERROR_OK;
}
int _bt_obex_server_cancel_transfer(int transfer_id)
{
	bt_transfer_info_t *transfer = NULL;
	DBusGProxy *proxy;

	transfer = __bt_find_transfer_by_id(transfer_id);
	retv_if(transfer == NULL, BLUETOOTH_ERROR_NOT_FOUND);

	proxy = __bt_get_transfer_proxy(transfer->path);

	retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);

	dbus_g_proxy_call_no_reply(proxy, "Cancel", G_TYPE_INVALID);

	g_object_unref(proxy);

	return BLUETOOTH_ERROR_NONE;
}
static ug_nfc_share_result_e ug_nfc_share_make_mime_type_data_from_file_path(const char *path, uint8_t *type_data, uint32_t *type_size)
{
	ug_nfc_share_result_e result = UG_NFC_SHARE_ERROR;
	char *extension = NULL;

	LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);

	retv_if(path == NULL, result);
	retv_if(type_data == NULL, result);
	retv_if(type_size == NULL, result);

	LOGD("typedata = %p, typesize = %d", type_data, *type_size);

	memset(type_data, 0, *type_size);
	*type_size = 0;

	extension = strrchr(path, '.');
	LOGD("extension = %s\n", GET_SAFE_STRING(extension));

	if (extension != NULL)
	{
		char *mime_str = NULL;

		if (mime_type_get_mime_type(extension+1, &mime_str) == MIME_TYPE_ERROR_NONE)
		{
			LOGD("mime_str[%s]", mime_str);

			*type_size = strlen(mime_str);
			memcpy(type_data, mime_str, *type_size);
			result = UG_NFC_SHARE_OK;
		}
		else
		{
			LOGD("ERROR :: mime_type_get_mime_type failed");
			result = UG_NFC_SHARE_ERROR;
		}
	}

	LOGD("mime type : %s", GET_SAFE_STRING((char *)type_data));

	LOGD("[%s(): %d] END >>>>", __FUNCTION__, __LINE__);

	return result;
}
static int __bt_get_transfer_id(const char *path)
{
	char *tmp = NULL;
	if (path == NULL)
		return -1;

	tmp = strrchr(path, 'r') + 1;
	retv_if(tmp == NULL, -1);

	return atoi(tmp);
}
Beispiel #23
0
static Evas_Object *_animated_unpack_item(Evas_Object *scroller, Evas_Object *page, unsigned int pos)
{
	Evas_Object *out = NULL;
	Evas_Object *item;
	Evas_Object *next_page;

	char buf[32];
	unsigned int page_max_app;
	unsigned int page_no;
	page_scroller_sort_type_e sort_type;

	out = page_unpack_item_at(page, pos);
	retv_if(NULL == out, NULL);

	page_no = page_scroller_get_page_no(scroller, page);
	page_max_app = (unsigned int) evas_object_data_get(scroller, "page_max_app");
	sort_type = (page_scroller_sort_type_e) evas_object_data_get(scroller, "sort_type");

	pos ++;
	while (page && page_no < MAX_PAGE_NO) {
		if (0 == page_count_item(page)) {
			page_destroy(scroller, page);
			break;
		}

		for (; pos < page_max_app; pos ++) {
			item = page_unpack_item_at(page, pos);
			if (NULL == item) continue;

			page_pack_item(page, pos - 1, item);
			snprintf(buf, 32, "menu%d", pos - 1);
			edje_object_signal_emit(_EDJ(page), STR_MOVE_NEXT, buf);
			edje_object_signal_emit(_EDJ(page), STR_ANI_RETURN, buf);
		}

		if (sort_type == PAGE_SCROLLER_SORT_MAX) {
			return NULL;
		}

		page_no ++;
		next_page = page_scroller_get_page_at(scroller, page_no);
		if (next_page) {
			item = page_unpack_item_at(next_page, 0);
			if (NULL == item) continue;

			page_pack_item(page, page_max_app - 1, item);
		} else break;

		pos = 1;
		page = next_page;
	}

	return out;
}
/**
 * This function make searchable string.
 * The string can use at contacts_svc_normalized_strstr().
 *
 * @param[in] src the string to convert
 * @param[out] dest The pointer to get normalized string.
 * @param[out] dest_len the size of dest.
 * @return #CTS_SUCCESS on success, Negative value(#cts_error) on error
 * @par example
 * @code
 	char normalized_str[512];
 	const char *name = "Test"

 	ret = contacts_svc_normalize_str(name, normalized_str, sizeof(normalized_str));

 	if(CTS_SUCCESS != ret)
 		printf("Error : contacts_svc_normalize_str() Failed(%d)", ret);
 	else
 		printf("original string is %s, normalized string is %s", name, normalized_str);
 * @endcode
 */
API int contacts_svc_normalize_str(const char *src, char *dest, const int dest_len)
{
	int ret;
	retv_if(NULL == dest, CTS_ERR_ARG_NULL);
	retvm_if(dest_len <= 0, CTS_ERR_ARG_INVALID, "dest_len(%d) is Invalid", dest_len);

	ret = cts_normalize_str(src, dest, dest_len);
	retvm_if(ret < CTS_SUCCESS, ret, "cts_normalize_str() Failed(%d)", ret);

	return CTS_SUCCESS;
}
nfc_ndef_message_h ug_nfc_share_get_current_ndef(void *data)
{
	ugdata_t *ug_data = (ugdata_t *)data;

	LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);

	retv_if(ug_data == NULL, NULL);

	LOGD("[%s(): %d] END >>>>", __FUNCTION__, __LINE__);

	return ug_data->current_ndef;
}
menu_screen_error_e list_get_values(const char *package, app_info_t *ai)
{
	ail_appinfo_h appinfo_h;
	char *exec;
	char *name;
	char *icon;
	ail_error_e ret;

	retv_if(NULL == package, MENU_SCREEN_ERROR_FAIL);
	retv_if(NULL == ai, MENU_SCREEN_ERROR_FAIL);
	retv_if(NULL == (ai->package = strdup(package)), MENU_SCREEN_ERROR_FAIL);

	ret = ail_package_get_appinfo(ai->package, &appinfo_h);
	if (AIL_ERROR_OK == ret) {
		do {
			break_if(ail_appinfo_get_str(appinfo_h, AIL_PROP_EXEC_STR, &exec) < 0);
			break_if(ail_appinfo_get_str(appinfo_h, AIL_PROP_NAME_STR, &name) < 0);
			break_if(ail_appinfo_get_str(appinfo_h, AIL_PROP_ICON_STR, &icon) < 0);
			break_if(ail_appinfo_get_bool(appinfo_h, AIL_PROP_NODISPLAY_BOOL, &ai->nodisplay) < 0);
			break_if(ail_appinfo_get_bool(appinfo_h, AIL_PROP_X_SLP_REMOVABLE_BOOL, &ai->x_slp_removable) < 0);
			break_if(ail_appinfo_get_bool(appinfo_h, AIL_PROP_X_SLP_TASKMANAGE_BOOL, &ai->x_slp_taskmanage) < 0);

			break_if(NULL == exec || NULL == (ai->exec = strdup(exec)));
			break_if(NULL == name || NULL == (ai->name = strdup(name)));
			break_if(NULL == icon || NULL == (ai->icon = strdup(icon)));

			ail_package_destroy_appinfo(appinfo_h);

			return MENU_SCREEN_ERROR_OK;
		} while(0);

		ail_package_destroy_appinfo(appinfo_h);
		list_free_values(ai);
		return MENU_SCREEN_ERROR_FAIL;
	} else if (AIL_ERROR_NO_DATA == ret) {
		return MENU_SCREEN_ERROR_OK;
	}

	return MENU_SCREEN_ERROR_FAIL;
}
int cts_inotify_unsubscribe_with_data(const char *path,
		void (*cb)(void *), void *user_data)
{
	int ret, wd;

	retv_if(NULL==path, CTS_ERR_ARG_NULL);
	retv_if(NULL==cb, CTS_ERR_ARG_NULL);
	retvm_if(cts_inoti_fd < 0, CTS_ERR_ENV_INVALID,
			"cts_inoti_fd(%d) is invalid", cts_inoti_fd);

	wd = cts_inotify_get_wd(cts_inoti_fd, path);
	retvm_if(-1 == wd, CTS_ERR_INOTIFY_FAILED,
			"cts_inotify_get_wd() Failed(%d)", errno);

	ret = del_noti_with_data(&cts_noti_list, wd, cb, user_data);
	warn_if(ret < CTS_SUCCESS, "del_noti_with_data() Failed(%d)", ret);

	if (0 == ret)
		return inotify_rm_watch(cts_inoti_fd, wd);

	return cts_inotify_watch(cts_inoti_fd, path);
}
Beispiel #28
0
static menu_screen_error_e _find_position_by_default(Evas_Object *scroller, int *candidate_page, int *candidate_pos, void *data)
{
	Evas_Object *page;
	Evas_Object *item;
	register unsigned int page_no;
	register unsigned int position_no;
	unsigned int nr_of_pages;
	int page_max_app;

	retv_if(NULL == scroller, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == candidate_page, MENU_SCREEN_ERROR_INVALID_PARAMETER);
	retv_if(NULL == candidate_pos, MENU_SCREEN_ERROR_INVALID_PARAMETER);

	*candidate_page = 0;
	*candidate_pos = 0;
	nr_of_pages = page_scroller_count_page(scroller);
	page_max_app = (int) evas_object_data_get(scroller, "page_max_app");
	for (page_no = 0; page_no < nr_of_pages; page_no ++) {
		page = page_scroller_get_page_at(scroller, page_no);
		if (!page) {
			_D("Page is not found at %d", page_no);
			return MENU_SCREEN_ERROR_FAIL;
		}

		for (position_no = 0; position_no < page_max_app; position_no ++) {
			item = page_get_item_at(page, position_no);
			if (!item) {
				*candidate_page = page_no;
				*candidate_pos = position_no;
				return MENU_SCREEN_ERROR_OK;
			}
		}
	}

	*candidate_page = page_no;
	*candidate_pos = 0;

	return MENU_SCREEN_ERROR_OK;
}
Beispiel #29
0
inline char *sql_get_locale(void)
{
	char *l;
	char *r;
	char buf[6];

	retv_if ((l = vconf_get_str(VCONFKEY_LANGSET)) == NULL, NULL);
	snprintf(buf, sizeof(buf), "%s", l);
	free(l);

	r = strdup(buf);

	return r;
}
int _bt_obex_server_accept_authorize(const char *filename, gboolean is_native)
{
	char file_path[BT_FILE_PATH_MAX] = { 0 };
	bt_server_info_t *server_info;

	BT_CHECK_PARAMETER(filename, return);

	retv_if(agent_info.auth_info == NULL, BLUETOOTH_ERROR_INTERNAL);

	retv_if(agent_info.auth_info->reply_context == NULL,
				BLUETOOTH_ERROR_INTERNAL);

	if (is_native == TRUE)
		server_info = agent_info.native_server;
	else
		server_info = agent_info.custom_server;

	retv_if(server_info == NULL, BLUETOOTH_ERROR_INTERNAL);

	if (server_info->dest_path != NULL)
		snprintf(file_path, sizeof(file_path), "%s/%s",
			server_info->dest_path, filename);
	else
		snprintf(file_path, sizeof(file_path), "%s", filename);

	if (g_strcmp0(agent_info.auth_info->filename, filename)) {
		g_free(agent_info.auth_info->filename);
		agent_info.auth_info->filename = g_strdup(filename);
	}

	dbus_g_method_return(agent_info.auth_info->reply_context,
				file_path);

	agent_info.auth_info->reply_context = NULL;

	return BLUETOOTH_ERROR_NONE;
}