obexd: AuthorizePush: Support to return folder name for file storage
authorGuiting Shen <aarongt.shen@gmail.com>
Thu, 20 Apr 2023 09:55:57 +0000 (17:55 +0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 5 Jan 2024 10:41:34 +0000 (16:11 +0530)
The obex agent usually returns the full path by getting the default
folder and filename from the Filename property of the transfer object
which is not convenient.

The patch helps that the obex agent can return the folder name suffixed
with '/' or new full path or even null which will use the default name
if new_name is NULL and the default folder if the new_folder is NULL in
opp_chkput().

doc/obex-agent-api.txt
obexd/src/manager.c

index 3923da6..7c72092 100755 (executable)
@@ -46,10 +46,11 @@ Methods             void Release()
                        This method gets called when the service daemon
                        needs to accept/reject a Bluetooth object push request.
 
-                       Returns the full path (including the filename) where
-                       the object shall be stored. The tranfer object will
-                       contain a Filename property that contains the default
-                       location and name that can be returned.
+                       Returns the full path (including the filename) or the
+                       folder name suffixed with '/' where the object shall
+                       be stored. The transfer object will contain a Filename
+                       property that contains the default location and name
+                       that can be returned.
 
                        Possible errors: org.bluez.obex.Error.Rejected
                                         org.bluez.obex.Error.Canceled
index 3efb498..22000d8 100755 (executable)
@@ -784,7 +784,10 @@ static void agent_reply(DBusPendingCall *call, void *user_data)
                        agent->new_name = g_strdup(name);
                        agent->new_folder = NULL;
                } else {
-                       agent->new_name = g_strdup(slash + 1);
+                       if (strlen(slash) == 1)
+                               agent->new_name = NULL;
+                       else
+                               agent->new_name = g_strdup(slash + 1);
                        agent->new_folder = g_strndup(name, slash - name);
                }
        }
@@ -855,7 +858,7 @@ int manager_request_authorization(struct obex_transfer *transfer,
 
        dbus_pending_call_unref(call);
 
-       if (!agent || !agent->new_name || agent->auth_reject)
+       if (!agent || agent->auth_reject)
                return -EPERM;
 
        *new_folder = agent->new_folder;