linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ] obexd/ftp: Update ftp transfer progress
@ 2014-10-28 14:19 Bharat Panda
  2014-10-30 14:19 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 3+ messages in thread
From: Bharat Panda @ 2014-10-28 14:19 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: cpgs, Bharat Panda

Adds support for updating file transfer progress for FTP
---
 obexd/plugins/ftp.c | 21 ++++++++++++++++++++-
 obexd/plugins/ftp.h |  1 +
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c
index 773861d..2004a77 100644
--- a/obexd/plugins/ftp.c
+++ b/obexd/plugins/ftp.c
@@ -59,6 +59,7 @@ static const uint8_t FTP_TARGET[TARGET_SIZE] = {
 
 struct ftp_session {
 	struct obex_session *os;
+	struct obex_transfer *transfer;
 	char *folder;
 };
 
@@ -116,6 +117,8 @@ void *ftp_connect(struct obex_session *os, int *err)
 	if (err)
 		*err = 0;
 
+	ftp->transfer = manager_register_transfer(os);
+
 	DBG("session %p created", ftp);
 
 	return ftp;
@@ -136,6 +139,9 @@ int ftp_get(struct obex_session *os, void *user_data)
 	if (ret < 0)
 		return ret;
 
+	if (type == NULL)
+		manager_emit_transfer_started(ftp->transfer);
+
 	return 0;
 }
 
@@ -181,6 +187,9 @@ int ftp_chkput(struct obex_session *os, void *user_data)
 
 	ret = obex_put_stream_start(os, path);
 
+	if (ret == 0)
+		manager_emit_transfer_started(ftp->transfer);
+
 	g_free(path);
 
 	return ret;
@@ -471,10 +480,19 @@ void ftp_disconnect(struct obex_session *os, void *user_data)
 
 	manager_unregister_session(os);
 
+	manager_unregister_transfer(ftp->transfer);
+
 	g_free(ftp->folder);
 	g_free(ftp);
 }
 
+void ftp_progress(struct obex_session *os, void *user_data)
+{
+	struct ftp_session *ftp = user_data;
+
+	manager_emit_transfer_progress(ftp->transfer);
+}
+
 static struct obex_service_driver ftp = {
 	.name = "File Transfer server",
 	.service = OBEX_FTP,
@@ -486,7 +504,8 @@ static struct obex_service_driver ftp = {
 	.chkput = ftp_chkput,
 	.setpath = ftp_setpath,
 	.action = ftp_action,
-	.disconnect = ftp_disconnect
+	.disconnect = ftp_disconnect,
+	.progress = ftp_progress
 };
 
 static int ftp_init(void)
diff --git a/obexd/plugins/ftp.h b/obexd/plugins/ftp.h
index f06de84..c0e97a7 100644
--- a/obexd/plugins/ftp.h
+++ b/obexd/plugins/ftp.h
@@ -28,3 +28,4 @@ int ftp_put(struct obex_session *os, void *user_data);
 int ftp_setpath(struct obex_session *os, void *user_data);
 void ftp_disconnect(struct obex_session *os, void *user_data);
 int ftp_action(struct obex_session *os, void *user_data);
+void ftp_progress(struct obex_session *os, void *user_data);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH ] obexd/ftp: Update ftp transfer progress
  2014-10-28 14:19 [PATCH ] obexd/ftp: Update ftp transfer progress Bharat Panda
@ 2014-10-30 14:19 ` Luiz Augusto von Dentz
  2014-10-31  7:08   ` Bharat Bhusan Panda
  0 siblings, 1 reply; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2014-10-30 14:19 UTC (permalink / raw)
  To: Bharat Panda; +Cc: linux-bluetooth@vger.kernel.org, cpgs

Hi,

On Tue, Oct 28, 2014 at 4:19 PM, Bharat Panda <bharat.panda@samsung.com> wrote:
> Adds support for updating file transfer progress for FTP

What this is really doing is enabling transfer management for FTP,
please change the description.

> ---
>  obexd/plugins/ftp.c | 21 ++++++++++++++++++++-
>  obexd/plugins/ftp.h |  1 +
>  2 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c
> index 773861d..2004a77 100644
> --- a/obexd/plugins/ftp.c
> +++ b/obexd/plugins/ftp.c
> @@ -59,6 +59,7 @@ static const uint8_t FTP_TARGET[TARGET_SIZE] = {
>
>  struct ftp_session {
>         struct obex_session *os;
> +       struct obex_transfer *transfer;
>         char *folder;
>  };
>
> @@ -116,6 +117,8 @@ void *ftp_connect(struct obex_session *os, int *err)
>         if (err)
>                 *err = 0;
>
> +       ftp->transfer = manager_register_transfer(os);
> +
>         DBG("session %p created", ftp);
>
>         return ftp;
> @@ -136,6 +139,9 @@ int ftp_get(struct obex_session *os, void *user_data)
>         if (ret < 0)
>                 return ret;
>
> +       if (type == NULL)
> +               manager_emit_transfer_started(ftp->transfer);

Please add a comment before the code above saying that we only care
about actual file transfers not other operations.

>         return 0;
>  }
>
> @@ -181,6 +187,9 @@ int ftp_chkput(struct obex_session *os, void *user_data)
>
>         ret = obex_put_stream_start(os, path);
>
> +       if (ret == 0)
> +               manager_emit_transfer_started(ftp->transfer);
> +
>         g_free(path);
>
>         return ret;
> @@ -471,10 +480,19 @@ void ftp_disconnect(struct obex_session *os, void *user_data)
>
>         manager_unregister_session(os);
>
> +       manager_unregister_transfer(ftp->transfer);
> +
>         g_free(ftp->folder);
>         g_free(ftp);
>  }
>
> +void ftp_progress(struct obex_session *os, void *user_data)
> +{
> +       struct ftp_session *ftp = user_data;
> +
> +       manager_emit_transfer_progress(ftp->transfer);
> +}
> +
>  static struct obex_service_driver ftp = {
>         .name = "File Transfer server",
>         .service = OBEX_FTP,
> @@ -486,7 +504,8 @@ static struct obex_service_driver ftp = {
>         .chkput = ftp_chkput,
>         .setpath = ftp_setpath,
>         .action = ftp_action,
> -       .disconnect = ftp_disconnect
> +       .disconnect = ftp_disconnect,
> +       .progress = ftp_progress

For consistency, please add progress after connect so it appears in
the same sequence as they are defined by service.h

>  };
>
>  static int ftp_init(void)
> diff --git a/obexd/plugins/ftp.h b/obexd/plugins/ftp.h
> index f06de84..c0e97a7 100644
> --- a/obexd/plugins/ftp.h
> +++ b/obexd/plugins/ftp.h
> @@ -28,3 +28,4 @@ int ftp_put(struct obex_session *os, void *user_data);
>  int ftp_setpath(struct obex_session *os, void *user_data);
>  void ftp_disconnect(struct obex_session *os, void *user_data);
>  int ftp_action(struct obex_session *os, void *user_data);
> +void ftp_progress(struct obex_session *os, void *user_data);

If you are not planning on using ftp_progress anywhere else please
make it static.

> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH ] obexd/ftp: Update ftp transfer progress
  2014-10-30 14:19 ` Luiz Augusto von Dentz
@ 2014-10-31  7:08   ` Bharat Bhusan Panda
  0 siblings, 0 replies; 3+ messages in thread
From: Bharat Bhusan Panda @ 2014-10-31  7:08 UTC (permalink / raw)
  To: 'Luiz Augusto von Dentz'; +Cc: linux-bluetooth, cpgs

Hi Luiz,

> -----Original Message-----
> From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-
> owner@vger.kernel.org] On Behalf Of Luiz Augusto von Dentz
> Sent: Thursday, October 30, 2014 7:49 PM
> To: Bharat Panda
> Cc: linux-bluetooth@vger.kernel.org; cpgs@samsung.com
> Subject: Re: [PATCH ] obexd/ftp: Update ftp transfer progress
> 
> Hi,
> 
> On Tue, Oct 28, 2014 at 4:19 PM, Bharat Panda
> <bharat.panda@samsung.com> wrote:
> > Adds support for updating file transfer progress for FTP
> 
> What this is really doing is enabling transfer management for FTP, please
> change the description.

> 
> > ---
> >  obexd/plugins/ftp.c | 21 ++++++++++++++++++++-  obexd/plugins/ftp.h
> |
> > 1 +
> >  2 files changed, 21 insertions(+), 1 deletion(-)
> >
> > diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c index
> > 773861d..2004a77 100644
> > --- a/obexd/plugins/ftp.c
> > +++ b/obexd/plugins/ftp.c
> > @@ -59,6 +59,7 @@ static const uint8_t FTP_TARGET[TARGET_SIZE] = {
> >
> >  struct ftp_session {
> >         struct obex_session *os;
> > +       struct obex_transfer *transfer;
> >         char *folder;
> >  };
> >
> > @@ -116,6 +117,8 @@ void *ftp_connect(struct obex_session *os, int
> *err)
> >         if (err)
> >                 *err = 0;
> >
> > +       ftp->transfer = manager_register_transfer(os);
> > +
> >         DBG("session %p created", ftp);
> >
> >         return ftp;
> > @@ -136,6 +139,9 @@ int ftp_get(struct obex_session *os, void
> *user_data)
> >         if (ret < 0)
> >                 return ret;
> >
> > +       if (type == NULL)
> > +               manager_emit_transfer_started(ftp->transfer);
> 
> Please add a comment before the code above saying that we only care about
> actual file transfers not other operations.
> 
> >         return 0;
> >  }
> >
> > @@ -181,6 +187,9 @@ int ftp_chkput(struct obex_session *os, void
> > *user_data)
> >
> >         ret = obex_put_stream_start(os, path);
> >
> > +       if (ret == 0)
> > +               manager_emit_transfer_started(ftp->transfer);
> > +
> >         g_free(path);
> >
> >         return ret;
> > @@ -471,10 +480,19 @@ void ftp_disconnect(struct obex_session *os,
> > void *user_data)
> >
> >         manager_unregister_session(os);
> >
> > +       manager_unregister_transfer(ftp->transfer);
> > +
> >         g_free(ftp->folder);
> >         g_free(ftp);
> >  }
> >
> > +void ftp_progress(struct obex_session *os, void *user_data) {
> > +       struct ftp_session *ftp = user_data;
> > +
> > +       manager_emit_transfer_progress(ftp->transfer);
> > +}
> > +
> >  static struct obex_service_driver ftp = {
> >         .name = "File Transfer server",
> >         .service = OBEX_FTP,
> > @@ -486,7 +504,8 @@ static struct obex_service_driver ftp = {
> >         .chkput = ftp_chkput,
> >         .setpath = ftp_setpath,
> >         .action = ftp_action,
> > -       .disconnect = ftp_disconnect
> > +       .disconnect = ftp_disconnect,
> > +       .progress = ftp_progress
> 
> For consistency, please add progress after connect so it appears in the same
> sequence as they are defined by service.h
> 
> >  };
> >
> >  static int ftp_init(void)
> > diff --git a/obexd/plugins/ftp.h b/obexd/plugins/ftp.h index
> > f06de84..c0e97a7 100644
> > --- a/obexd/plugins/ftp.h
> > +++ b/obexd/plugins/ftp.h
> > @@ -28,3 +28,4 @@ int ftp_put(struct obex_session *os, void
> > *user_data);  int ftp_setpath(struct obex_session *os, void
> > *user_data);  void ftp_disconnect(struct obex_session *os, void
> > *user_data);  int ftp_action(struct obex_session *os, void
> > *user_data);
> > +void ftp_progress(struct obex_session *os, void *user_data);
> 
> If you are not planning on using ftp_progress anywhere else please make it
> static.
Yes this won't be used anywhere else. I will make it static.

I have made changes accordingly and submitted v3 patch for the same.

Thanks
Best Regards,
Bharat


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-31  7:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-28 14:19 [PATCH ] obexd/ftp: Update ftp transfer progress Bharat Panda
2014-10-30 14:19 ` Luiz Augusto von Dentz
2014-10-31  7:08   ` Bharat Bhusan Panda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).