diff mbox series

[v1] obex: Add messages_get_message() implementation for MAP plugin

Message ID 20250219184758.115316-1-quic_amisjain@quicinc.com (mailing list archive)
State Superseded
Headers show
Series [v1] obex: Add messages_get_message() implementation for MAP plugin | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Amisha Jain Feb. 19, 2025, 6:47 p.m. UTC
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.
3.MAP/MSE/MMB/BV-14-C
Verify that the MSE can return a SMS message with text trans-coded to UTF-8
to the MCE.

Currently get message operation is not implemented, hence above
testcases are failing.
Added code to send the complete bmessage in response
to the get request for the requested message handle.

---
 obexd/plugins/mas.c            |  4 ++--
 obexd/plugins/messages-dummy.c | 32 +++++++++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 3 deletions(-)

Comments

bluez.test.bot@gmail.com Feb. 19, 2025, 8:07 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=935687

---Test result---

Test Summary:
CheckPatch                    PENDING   0.20 seconds
GitLint                       PENDING   0.22 seconds
BuildEll                      PASS      21.01 seconds
BluezMake                     PASS      1519.07 seconds
MakeCheck                     PASS      13.08 seconds
MakeDistcheck                 PASS      159.74 seconds
CheckValgrind                 PASS      218.23 seconds
CheckSmatch                   PASS      287.86 seconds
bluezmakeextell               PASS      100.10 seconds
IncrementalBuild              PENDING   0.28 seconds
ScanBuild                     PASS      868.75 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz Feb. 19, 2025, 8:22 p.m. UTC | #2
Hi Amisha,

On Wed, Feb 19, 2025 at 1:48 PM Amisha Jain <quic_amisjain@quicinc.com> wrote:
>
> 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.
> 3.MAP/MSE/MMB/BV-14-C
> Verify that the MSE can return a SMS message with text trans-coded to UTF-8
> to the MCE.
>
> Currently get message operation is not implemented, hence above
> testcases are failing.
> Added code to send the complete bmessage in response
> to the get request for the requested message handle.
>
> ---
>  obexd/plugins/mas.c            |  4 ++--
>  obexd/plugins/messages-dummy.c | 32 +++++++++++++++++++++++++++++++-
>  2 files changed, 33 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..93648831a 100644
> --- a/obexd/plugins/messages-dummy.c
> +++ b/obexd/plugins/messages-dummy.c
> @@ -516,7 +516,37 @@ 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)

The Coding style is if () {, so not a new line.

> +       {
> +               DBG("fopen() failed");
> +               return -EBADR;
> +       }
> +
> +       /* 1024 is the maximum size of the line which is calculated to be more
> +        * sufficient*/
> +       while (fgets(buffer, 1024, fp)) {
> +               if (callback)

Ditto, for the while statement you got it right so it beats me why you
are doing it differently for if statements, that said if it just one
line you don't need braces.

> +               {
> +                       callback(session, 0, 0, (const char*)buffer, user_data);
> +               }
> +       }
> +
> +       if (callback)
> +       {
> +               callback(session, 0, 0, NULL, user_data);
> +       }
> +
> +       g_free(path);
> +       fclose(fp);
> +       return 0;
>  }
>
>  int messages_update_inbox(void *session, messages_status_cb callback,
> --
> 2.34.1
>
>
diff mbox series

Patch

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..93648831a 100644
--- a/obexd/plugins/messages-dummy.c
+++ b/obexd/plugins/messages-dummy.c
@@ -516,7 +516,37 @@  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*/
+	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);
+	}
+
+	g_free(path);
+	fclose(fp);
+	return 0;
 }
 
 int messages_update_inbox(void *session, messages_status_cb callback,