Re: [RESEND PATCH v2] obex: Add messages_get_message() implementation for MAP plugin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Amisha,

On Wed, Feb 26, 2025 at 2:11 AM Amisha Jain (QUIC)
<quic_amisjain@xxxxxxxxxxx> wrote:
>
> Hi Paul,
>
> > -----Original Message-----
> > From: Paul Menzel <pmenzel@xxxxxxxxxxxxx>
> > Sent: Monday, February 24, 2025 7:34 PM
> > To: Amisha Jain (QUIC) <quic_amisjain@xxxxxxxxxxx>
> > Cc: linux-bluetooth@xxxxxxxxxxxxxxx; Mohammed Sameer Mulla (QUIC)
> > <quic_mohamull@xxxxxxxxxxx>; Harish Bandi (QUIC)
> > <quic_hbandi@xxxxxxxxxxx>; Anubhav Gupta (QUIC)
> > <quic_anubhavg@xxxxxxxxxxx>
> > Subject: Re: [RESEND PATCH v2] obex: Add messages_get_message()
> > implementation for MAP plugin
> >
> > Dear Amisha,
> >
> >
> > Am 24.02.25 um 12:10 schrieb Amisha Jain:
> > > GET Message() operation should be supported for passing below PTS
> > > testcases -
> > >
> > > 1.MAP/MSE/MMB/BV-12-C
> > > Verify that the MSE can return an email message to the MCE.
> > > 2.MAP/MSE/MMB/BV-13-C
> > > Verify that the MSE can return a SMS message in native format to the MCE.
> >
> > a*n* SMS
> >
> > > 3.MAP/MSE/MMB/BV-14-C
> > > Verify that the MSE can return a SMS message with text trans-coded to
> > > UTF-8
> >
> > a*n*
> >
> > > to the MCE.
> >
> > I’d add a space after the bullet points (the dot).
> >
> > > Currently get message operation is not implemented, hence above
> > > testcases are failing.
> > > Added code to send the complete bmessage in response
> >
> > Should this be *message* or is *bmessage* some terminology?
> >
>
> This is 'bmessage', message format used by MAP to store messages.
> As per Spec, bMessages are application objects used by MAP for message transport.
> Exchanged messages shall use the bMessage format.
>
> > > to the get request for the requested message handle.
> > >
> > > ---
> > >   obexd/plugins/mas.c            |  4 ++--
> > >   obexd/plugins/messages-dummy.c | 27 ++++++++++++++++++++++++++-
> > >   2 files changed, 28 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c index
> > > 10b972d65..f63fcf6c6 100644
> > > --- a/obexd/plugins/mas.c
> > > +++ b/obexd/plugins/mas.c
> > > @@ -612,11 +612,11 @@ static void *message_open(const char *name, int
> > oflag, mode_t mode,
> > >             return NULL;
> > >     }
> > >
> > > +   mas->buffer = g_string_new("");
> > > +
> > >     *err = messages_get_message(mas->backend_data, name, 0,
> > >                     get_message_cb, mas);
> > >
> > > -   mas->buffer = g_string_new("");
> > > -
> > >     if (*err < 0)
> > >             return NULL;
> > >     else
> > > diff --git a/obexd/plugins/messages-dummy.c
> > > b/obexd/plugins/messages-dummy.c index e313c6163..665face3f 100644
> > > --- a/obexd/plugins/messages-dummy.c
> > > +++ b/obexd/plugins/messages-dummy.c
> > > @@ -516,7 +516,32 @@ int messages_get_message(void *session, const
> > char *handle,
> > >                                     messages_get_message_cb callback,
> > >                                     void *user_data)
> > >   {
> > > -   return -ENOSYS;
> > > +   struct session *s =  session;
> > > +   FILE *fp;
> > > +   char *path;
> > > +   char buffer[1024];
> > > +
> > > +   DBG(" ");
> > > +   path = g_build_filename(s->cwd_absolute, handle, NULL);
> > > +   fp = fopen(path, "r");
> > > +   if (fp == NULL) {
> > > +           DBG("fopen() failed");
> > > +           return -EBADR;
> > > +   }
> > > +
> > > +   /* 1024 is the maximum size of the line which is calculated to be more
> > > +    * sufficient*/
> >
> > I do not fully grok this sentence. Could you please rephrase?
> >
>
> Sure, this corresponds to max size of a line in a file, as we are reading the file line by line.
> Same way it is present in existing function - get_messages_listing().
>
> static gboolean get_messages_listing(void *d)
> {
>
>         struct message_listing_data *mld = d;
>         /* 1024 is the maximum size of the line which is calculated to be more
>          * sufficient*/
>         char buffer[1024];
>         GMarkupParseContext *ctxt;
>
> > > +   while (fgets(buffer, 1024, fp)) {
> > > +           if (callback)
> > > +                   callback(session, 0, 0, (const char*)buffer, user_data);
> > > +   }
> > > +
> > > +   if (callback)
> > > +           callback(session, 0, 0, NULL, user_data);

Btw, if the callback is NULL then perhaps we shouldn't be looping with
fgets, I also thinking that perhaps the whole think about reading the
messages and copying it over to a buffer perhaps could be avoided,
perhaps using mmap is better here, although this is just the dummy
implementation with perhaps doesn't care so much about doing things in
a 'proper' way.

> > > +
> > > +   g_free(path);
> > > +   fclose(fp);
> > > +   return 0;
> > >   }
> > >
> > >   int messages_update_inbox(void *session, messages_status_cb
> > > callback,
> >
> >
> > Kind regards,
> >
> > Paul
>
> Thanks,
> Amisha



-- 
Luiz Augusto von Dentz





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux