diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c
index a98163d..fe775f4 100644
--- a/obexd/plugins/ftp.c
+++ b/obexd/plugins/ftp.c
static const guint8 PCSUITE_WHO[PCSUITE_WHO_SIZE] = {
'P','C',' ','S','u','i','t','e' };
-static gint get_by_type(struct OBEX_session *os, gchar *type)
+static gint get_by_type(struct OBEX_session *os, const gchar *type)
{
+ const char *folder = obex_get_folder(os);
+ const char *capability = obex_get_capability_path(os);
+
if (type == NULL)
return -ENOENT;
if (g_str_equal(type, CAP_TYPE))
- return obex_stream_start(os, os->server->capability);
+ return obex_stream_start(os, capability);
if (g_str_equal(type, LST_TYPE))
- return obex_stream_start(os, os->current_folder);
+ return obex_stream_start(os, folder);
return -ENOENT;
}
-static gint ftp_prepare_get(struct obex_session *os, gchar *file)
+static gint ftp_prepare_get(struct OBEX_session *os, gchar *file)
{
+ const char *root_folder = obex_get_root_folder(os);
+ const char *folder = obex_get_folder(os);
gboolean root;
- root = g_str_equal(os->server->folder, os->current_folder);
+ root = g_str_equal(root_folder, folder);
- if (!root || !os->server->symlinks) {
+ if (!root || !obex_get_symlinks(os)) {
struct stat dstat;
gint err;
static obex_rsp_t ftp_get(struct OBEX_session *os)
{
+ const char *folder = obex_get_folder(os);
+ const char *type = obex_get_type(os);
+ const char *name = obex_get_name(os);
gint err;
gchar *path;
- if (os->current_folder == NULL) {
+ if (folder == NULL) {
err = -ENOENT;
goto fail;
}
- err = get_by_type(os, os->type);
+ err = get_by_type(os, type);
if (err < 0) {
- if (!os->name)
+ if (!name)
goto fail;
- path = g_build_filename(os->current_folder, os->name, NULL);
+ path = g_build_filename(folder, name, NULL);
err = ftp_prepare_get(os, path);
path = g_build_filename(folder, name, NULL);
- if (os->driver->remove(path) < 0)
+ if (obex_remove(os, path) < 0)
ret = -errno;
g_free(path);
diff --git a/obexd/src/obex.c b/obexd/src/obex.c
index 9587388..0483c7d 100644
--- a/obexd/src/obex.c
+++ b/obexd/src/obex.c
os_set_response(obj, rsp);
}
-int obex_stream_start(struct OBEX_session *os, gchar *filename)
+int obex_stream_start(struct OBEX_session *os, const gchar *filename)
{
gint err;
gpointer object;
{
return os->server->symlinks;
}
+
+const char *obex_get_capability_path(struct OBEX_session *os)
+{
+ return os->server->capability;
+}
+
+int obex_remove(struct OBEX_session *os, const char *path)
+{
+ if (os->driver == NULL)
+ return -EINVAL;
+
+ return os->driver->remove(path);
+}
diff --git a/obexd/src/obex.h b/obexd/src/obex.h
index 4346657..72b0319 100644
--- a/obexd/src/obex.h
+++ b/obexd/src/obex.h
gint obex_session_start(GIOChannel *io, struct server *server);
struct obex_session *obex_get_session(gpointer object);
-int obex_stream_start(struct OBEX_session *os, gchar *filename);
+int obex_stream_start(struct OBEX_session *os, const gchar *filename);
gint obex_prepare_put(struct obex_session *os);
const char *obex_get_name(struct OBEX_session *os);
void obex_set_name(struct OBEX_session *os, const gchar *name);
void obex_set_folder(struct OBEX_session *os, const char *folder);
const char *obex_get_root_folder(struct OBEX_session *os);
gboolean obex_get_symlinks(struct OBEX_session *os);
+const char *obex_get_capability_path(struct OBEX_session *os);
+int obex_remove(struct OBEX_session *os, const char *path);
void server_free(struct server *server);
int tty_init(gint service, const gchar *folder, const gchar *capability,