From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH obexd] Remove test/main.c
Date: Thu, 1 Sep 2011 15:14:37 +0300 [thread overview]
Message-ID: <1314879277-4792-1-git-send-email-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
It is not useful anymore since gwobex will be removed and we
have already tools/test-client and tools/test-server for gobex.
---
Makefile.am | 6 -
test/main.c | 316 -----------------------------------------------------------
2 files changed, 0 insertions(+), 322 deletions(-)
delete mode 100644 test/main.c
diff --git a/Makefile.am b/Makefile.am
index 5f0b2eb..be888ec 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -104,12 +104,6 @@ plugindir = $(libdir)/obex/plugins
plugin_LTLIBRARIES =
-noinst_PROGRAMS += test/obex-test
-
-test_obex_test_SOURCES = $(gwobex_sources) test/main.c
-
-test_obex_test_LDADD = @OPENOBEX_LIBS@ @BLUEZ_LIBS@ @GLIB_LIBS@
-
src/plugin.$(OBJEXT): src/builtin.h
src/builtin.h: src/genbuiltin $(builtin_sources)
diff --git a/test/main.c b/test/main.c
deleted file mode 100644
index 37b307c..0000000
--- a/test/main.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- *
- * OBEX Test
- *
- * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <glib.h>
-
-#include <bluetooth/bluetooth.h>
-#include <bluetooth/rfcomm.h>
-#include <bluetooth/sdp.h>
-#include <bluetooth/sdp_lib.h>
-#include <gw-obex.h>
-
-enum {
- CONNECT,
- PULLPHONEBOOK,
- PULLVCARDLISTING,
- INVALID
-};
-
-static int sdp_search(const bdaddr_t *src, const bdaddr_t *dst,
- uint16_t uuid, uint8_t *channel)
-{
- sdp_session_t *session;
- sdp_list_t *search, *attributes, *rsp;
- uuid_t svclass;
- uint16_t attr;
- int err;
-
- session = sdp_connect(src, dst, SDP_WAIT_ON_CLOSE);
- if (session == NULL)
- return -1;
-
- sdp_uuid16_create(&svclass, uuid);
- search = sdp_list_append(NULL, &svclass);
-
- attr = SDP_ATTR_PROTO_DESC_LIST;
- attributes = sdp_list_append(NULL, &attr);
-
- err = sdp_service_search_attr_req(session, search,
- SDP_ATTR_REQ_INDIVIDUAL, attributes, &rsp);
- if (err < 0) {
- sdp_close(session);
- return -1;
- }
-
- for (; rsp; rsp = rsp->next) {
- sdp_record_t *rec = (sdp_record_t *) rsp->data;
- sdp_list_t *protos;
-
- if (!sdp_get_access_protos(rec, &protos)) {
- uint8_t ch = sdp_get_proto_port(protos, RFCOMM_UUID);
- if (ch > 0) {
- *channel = ch;
- sdp_close(session);
- return 0;
- }
- }
- }
-
- sdp_close(session);
-
- return -1;
-}
-
-static int rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst,
- uint8_t channel)
-{
- struct sockaddr_rc addr;
- int sk;
-
- sk = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
- if (sk < 0)
- return -EIO;
-
- memset(&addr, 0, sizeof(addr));
- addr.rc_family = AF_BLUETOOTH;
- bacpy(&addr.rc_bdaddr, src);
-
- if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- close(sk);
- return -EIO;
- }
-
- memset(&addr, 0, sizeof(addr));
- addr.rc_family = AF_BLUETOOTH;
- bacpy(&addr.rc_bdaddr, dst);
- addr.rc_channel = channel;
-
- if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- close(sk);
- return -EIO;
- }
-
- return sk;
-}
-
-static gchar *option_device = NULL;
-static gint option_channel = 0;
-static gchar *option_path = NULL;
-static gboolean option_ftp = FALSE;
-static gboolean option_pbap = FALSE;
-
-static gchar *option_connect = NULL;
-static gchar *option_pullphonebook = NULL;
-static gchar *option_setphonebook = NULL;
-static gchar *option_pullvcardlisting = NULL;
-
-static GOptionEntry options[] = {
- { "device", 'i', 0, G_OPTION_ARG_STRING, &option_device,
- "Specify local device interface", "DEV" },
- { "channel", 'C', 0, G_OPTION_ARG_INT, &option_channel,
- "Specify remote RFCOMM channel", "CHANNEL" },
- { "path", 'P', 0, G_OPTION_ARG_STRING, &option_path,
- "Specify initial path to set", "PATH" },
- { "ftp", 'f', 0, G_OPTION_ARG_NONE, &option_ftp,
- "Use File Transfer target" },
- { "pbap", 'p', 0, G_OPTION_ARG_NONE, &option_pbap,
- "Use Phonebook Access target" },
-
- { "connect", 0, 0, G_OPTION_ARG_STRING, &option_connect,
- "Connect remote OBEX session", "DEV" },
- { "pullphonebook", 0, 0, G_OPTION_ARG_STRING, &option_pullphonebook,
- "Pull phonebook from remote device", "DEV" },
- { "setphonebook", 0, 0, G_OPTION_ARG_STRING, &option_setphonebook,
- "Select phonebook on remote device", "DEV" },
- { "pullvcardlisting", 0, 0, G_OPTION_ARG_STRING, &option_pullvcardlisting,
- "Pull vCard listing from remote device", "DEV" },
-
- { NULL },
-};
-
-int main(int argc, char *argv[])
-{
- GOptionContext *context;
- GError *err = NULL;
- bdaddr_t src, dst;
- int sk;
-
- GwObex *obex;
- uint16_t uuid = OBEX_OBJPUSH_SVCLASS_ID;
- uint8_t channel;
- gchar *buf;
- const gchar *target = NULL;
- gint error, buf_len, target_len = 0;
- int mode = INVALID;
-
- context = g_option_context_new(NULL);
- g_option_context_add_main_entries(context, options, NULL);
-
- if (g_option_context_parse(context, &argc, &argv, &err) == FALSE) {
- if (err != NULL) {
- g_printerr("%s\n", err->message);
- g_error_free(err);
- } else
- g_printerr("An unknown error occurred\n");
- exit(EXIT_FAILURE);
- }
-
- g_option_context_free(context);
-
- if (option_device != NULL) {
- str2ba(option_device, &dst);
- g_free(option_device);
- } else
- bacpy(&src, BDADDR_ANY);
-
- bacpy(&dst, BDADDR_ANY);
-
- if (option_connect != NULL) {
- str2ba(option_connect, &dst);
- g_free(option_connect);
- mode = CONNECT;
- }
-
- if (option_pullphonebook != NULL) {
- str2ba(option_pullphonebook, &dst);
- g_free(option_pullphonebook);
- mode = PULLPHONEBOOK;
- option_pbap = TRUE;
- }
-
- if (option_setphonebook != NULL) {
- str2ba(option_setphonebook, &dst);
- g_free(option_setphonebook);
- mode = CONNECT;
- option_pbap = TRUE;
- if (option_path == NULL)
- option_path = g_strdup("telecom");
- }
-
- if (option_pullvcardlisting != NULL) {
- str2ba(option_pullvcardlisting, &dst);
- g_free(option_pullvcardlisting);
- mode = PULLVCARDLISTING;
- option_pbap = TRUE;
- //if (option_path == NULL)
- // option_path = g_strdup("telecom");
- }
-
- if (option_ftp == TRUE) {
- uuid = OBEX_FILETRANS_SVCLASS_ID;
- target = OBEX_FTP_UUID;
- target_len = OBEX_FTP_UUID_LEN;
- }
-
- if (option_pbap == TRUE) {
- uuid = PBAP_PSE_SVCLASS_ID;
- target = OBEX_PBAP_UUID;
- target_len = OBEX_PBAP_UUID_LEN;
- }
-
- if (bacmp(&dst, BDADDR_ANY) == 0) {
- fprintf(stderr, "Failed to provide action with address\n");
- exit(1);
- }
-
- if (option_channel < 1) {
- if (sdp_search(&src, &dst, uuid, &channel) < 0) {
- fprintf(stderr, "Failed to get RFCOMM channel\n");
- exit(1);
- }
- } else
- channel = option_channel;
-
- sk = rfcomm_connect(&src, &dst, channel);
- if (sk < 0) {
- fprintf(stderr, "Failed to connect RFCOMM channel\n");
- exit(1);
- }
-
- obex = gw_obex_setup_fd(sk, target, target_len, NULL, &error);
- if (obex == NULL) {
- fprintf(stderr, "Failed to create OBEX session\n");
- close(sk);
- exit(1);
- }
-
- if (option_path != NULL) {
- if (gw_obex_chdir(obex, option_path, &error) == FALSE) {
- fprintf(stderr, "Failed to change directory\n");
- gw_obex_close(obex);
- close(sk);
- exit(1);
- }
- }
-
- switch (mode) {
- case CONNECT:
- break;
-
- case PULLPHONEBOOK:
- {
- unsigned char apparam[] = { 0x04, 0x02, 0xff, 0xff };
- //unsigned char apparam[] = { 0x04, 0x02, 0x00, 0x00 };
-
- if (gw_obex_get_buf_with_apparam(obex,
- "telecom/pb.vcf", "x-bt/phonebook",
- apparam, sizeof(apparam),
- &buf, &buf_len, &error) == TRUE) {
- //printf("%s\n", buf);
- //g_free(buf);
- }
- }
- break;
-
- case PULLVCARDLISTING:
- {
- unsigned char apparam[] = { 0x04, 0x02, 0xff, 0xff };
-
- if (gw_obex_get_buf_with_apparam(obex,
- "", "x-bt/vcard-listing",
- apparam, sizeof(apparam),
- &buf, &buf_len, &error) == TRUE) {
- //printf("%s\n", buf);
- //g_free(buf);
- }
- }
- break;
- }
-
- gw_obex_close(obex);
-
- close(sk);
-
- g_free(option_path);
-
- return 0;
-}
--
1.7.6
next reply other threads:[~2011-09-01 12:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-01 12:14 Luiz Augusto von Dentz [this message]
2011-09-27 9:39 ` [PATCH obexd] Remove test/main.c Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1314879277-4792-1-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.