Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp151195rwr; Wed, 19 Apr 2023 19:39:06 -0700 (PDT) X-Google-Smtp-Source: AKy350arSWRM32fL7f1VJoozyLLC572MzV2g6Bm9+4BspK3pBfgS2Z681sfhEgFAg0rKUB2Kp4r5 X-Received: by 2002:a17:902:ea0e:b0:1a6:f755:a4bb with SMTP id s14-20020a170902ea0e00b001a6f755a4bbmr77457plg.0.1681958346741; Wed, 19 Apr 2023 19:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681958346; cv=none; d=google.com; s=arc-20160816; b=taIm40S1ZybPjcIZ0wePdh7hL0JhyWeGqWpm0ZblyyRbAsTFmLTnZlVrVrm4uM5338 HLYfwDJqp4PtJqFlNzGZgWLnHdO4/PMCJYguKXZ2fYiePQ0oJDzrqDF77Ev6e2kMcLIF QD6Z2IWd4Q95QDQYvrsP3GcAjQc0UgqUEsP/EOC3UcyA9Xz3su/u4m4Urdj/rjD9rnVs T4n/+8DOFXlhOqVrYB/EnLFm9zh17ea9ftJee8Eo5XoD4H7pYu4fs6sg3OqzcsEy1PqY 4Bg0gmLT3LYWv9Pc/FFHlnA3+CAeonWgdmcHx4ZtB/p6PsJfVB5D0qsRZHE7++NS4kP5 E70A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=77JUUzQXzcotRsLH4dY07i49UucoxKVcxmsQVMWb4B8=; b=gjp+ObLDBNE1xJ2HHxQiOJDX8DWPC/C1HdHAeZ3LI76TMIvnLu1kB7xJAnpI6743aE SPgT72i51WVwz6TptgGzgLm8eSFuDFYal8Jym7AWTbUhfmccZZqC+FEb99Y2AuRVPUHf x3wHSexZWVWIlQGhP6lt5xlFYUsmxZ1nOcU2LtfGmfv4uFmSh4dfWAFSPGUx0Wki+714 ZVMHisU4ASONHzHQ073A8TH0VLlRVY7QYHQ69RnKRly0yaLi+jkZRoXZfJu1D5Bpz5RC nnxw0GXOB9rPI1h1DMqXZDo+gPS8h9F3eihZNDkC4qXxro8cbpdGejHNsqFoYF/aoXCR b/ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="UHlNL9/U"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b2-20020a170902d50200b001a2911b43c7si517979plg.273.2023.04.19.19.38.39; Wed, 19 Apr 2023 19:39:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="UHlNL9/U"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229767AbjDTC0E (ORCPT + 99 others); Wed, 19 Apr 2023 22:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233134AbjDTC0C (ORCPT ); Wed, 19 Apr 2023 22:26:02 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3726146A5 for ; Wed, 19 Apr 2023 19:26:01 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-63b620188aeso681608b3a.0 for ; Wed, 19 Apr 2023 19:26:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681957560; x=1684549560; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=77JUUzQXzcotRsLH4dY07i49UucoxKVcxmsQVMWb4B8=; b=UHlNL9/UIQgL4lR2Sof7cKCi5uaObLICh7ups3tpTeJXgQmEjIAo7wGk0aPJ0R0ULc wm0P9wR3VpIqp5mo6gibnXe0x03DNbkbRZmA4tn/h7IvGoC30C8N77sH5l4YPgM+CcK+ Hx2PJj6WwbbgK1WjVXhzw3yw49ok0/sCj6+eWwEYWa1dVHXLekJIbs3OyZiuZN8tWm06 dxVf4CoUaaK+nt62bfcJSZ1B7UNwxX7nAcZd143BqEEYgsO2uPlMb9ps5oqlzm8bdyD6 N+QTFZYNb4epg7v9haflmlrZcoUjAcVdDJdfrAqPrnRoN+N4sSe3WmE7YnZQaIJXEqko PyWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681957560; x=1684549560; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=77JUUzQXzcotRsLH4dY07i49UucoxKVcxmsQVMWb4B8=; b=hTR7IvlJgk7KomSu05MTwjOulJclDbL4ffpaAxI1KZ/Fd/7JQgSeKGH0k2cjoowkGR 5oYYIUT6u+fqsiWhIy6Mog5yyI223Vm+W884zSw1BP0AanA5xUlcd0sZjIaQ1UEpLelm oVPBrTyxERZheU6tEGe1pb6I7jmqMcFl+2Lk5vgHjbkXljAi+DnsOaAvTFWJjBSKlzsO 0cR9MnuH12JD0cdQ+U1xk6YcKfgAZMSZdYWq5t2EZzX510M8qpWcD9k+NAC1fX0wAmsG G8vSRwpEHUydaaMw2Sm8YXtfpkfyB+5RKmlYPxQjBziZytCN5bEnTOEnIBjOY5maz18R raaw== X-Gm-Message-State: AAQBX9dBwxKxBM4Td531yvgZEhPsq6JryyULhSNFBPA5Ruj/MncKkiIu rvC4GR5Rp1r/XkqM/3mTTvHvYkT4k2F/vNAt X-Received: by 2002:a05:6a00:1a91:b0:63b:8324:df with SMTP id e17-20020a056a001a9100b0063b832400dfmr7290813pfv.0.1681957560262; Wed, 19 Apr 2023 19:26:00 -0700 (PDT) Received: from aaron-shen.localdomain ([183.63.252.58]) by smtp.gmail.com with ESMTPSA id g13-20020aa7874d000000b0063b8f17768dsm67112pfo.129.2023.04.19.19.25.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 19:25:59 -0700 (PDT) From: Guiting Shen To: linux-bluetooth@vger.kernel.org Cc: pmenzel@molgen.mpg.de, Guiting Shen Subject: [PATCH BlueZ v4] obexd: support to reply folder name to store file Date: Thu, 20 Apr 2023 10:25:54 +0800 Message-Id: <20230420022554.14159-1-aarongt.shen@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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 | 9 +++++---- obexd/src/manager.c | 10 ++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/doc/obex-agent-api.txt b/doc/obex-agent-api.txt index 3923da6df..5a9c6d417 100644 --- a/doc/obex-agent-api.txt +++ b/doc/obex-agent-api.txt @@ -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 + 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 diff --git a/obexd/src/manager.c b/obexd/src/manager.c index 849928603..73fd6b9af 100644 --- a/obexd/src/manager.c +++ b/obexd/src/manager.c @@ -632,8 +632,7 @@ static void agent_reply(DBusPendingCall *call, void *user_data) if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) agent_cancel(); - - if (dbus_error_has_name(&derr, OBEX_ERROR_REJECT)) + else if (dbus_error_has_name(&derr, OBEX_ERROR_REJECT)) agent->auth_reject = TRUE; dbus_error_free(&derr); @@ -651,7 +650,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); } } @@ -722,7 +724,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; -- 2.34.1