We never actually shipped the result from glib/ to be easily compilable, it has
no known dependencies.
---
.gitignore | 6 -
CMakeLists.txt | 22 +-
CMakeModules/FindGlib.cmake | 94 ----
Makefile.am | 8 +-
acinclude.m4 | 14 -
configure.ac | 3 +-
glib/CMakeLists.txt | 139 ------
glib/Makefile.am | 42 --
glib/obex-client.c | 589 -------------------------
glib/obex-client.h | 163 -------
glib/obex-debug.h | 28 --
glib/obex-error.c | 226 ----------
glib/obex-error.h | 31 --
glib/obex-lowlevel.c | 1014 -------------------------------------------
glib/obex-lowlevel.h | 50 ---
glib/obex-marshal.list | 1 -
glib/test-client.c | 237 ----------
glib/test-lowlevel.c | 104 -----
openobex-glib.pc.in | 12 -
19 files changed, 8 insertions(+), 2775 deletions(-)
delete mode 100644 CMakeModules/FindGlib.cmake
delete mode 100644 glib/CMakeLists.txt
delete mode 100644 glib/Makefile.am
delete mode 100644 glib/obex-client.c
delete mode 100644 glib/obex-client.h
delete mode 100644 glib/obex-debug.h
delete mode 100644 glib/obex-error.c
delete mode 100644 glib/obex-error.h
delete mode 100644 glib/obex-lowlevel.c
delete mode 100644 glib/obex-lowlevel.h
delete mode 100644 glib/obex-marshal.list
delete mode 100644 glib/test-client.c
delete mode 100644 glib/test-lowlevel.c
delete mode 100644 openobex-glib.pc.in
diff --git a/.gitignore b/.gitignore
index 643a070..2e6307f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,12 +24,6 @@ stamp-h1
autom4te.cache
openobex.pc
-openobex-glib.pc
-
-glib/obex-marshal.h
-glib/obex-marshal.c
-glib/test-lowlevel
-glib/test-client
ircp/ircp
apps/irxfer
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bf312a6..5a2bde4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -134,13 +134,11 @@ if ( OPENOBEX_USB AND UNIX AND NOT WIN32 )
endforeach ( lib )
endif ( PKGCONFIG_LIBUSB_FOUND )
endif ( OPENOBEX_USB AND UNIX AND NOT WIN32 )
-foreach ( file openobex openobex-glib )
- configure_file (
- ${CMAKE_CURRENT_SOURCE_DIR}/${file}.pc.in
- ${CMAKE_CURRENT_BINARY_DIR}/${file}.pc
- @ONLY
- )
-endforeach ( file )
+configure_file (
+ ${CMAKE_CURRENT_SOURCE_DIR}/openobex.pc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/openobex.pc
+ @ONLY
+)
if ( NOT PKGCONFIG_INSTALL_DIR )
set ( PKGCONFIG_INSTALL_DIR lib${LIB_SUFFIX}/pkgconfig
@@ -198,16 +196,6 @@ endif ( BUILD_DOCUMENTATION )
#
-# build the glib binding library
-# not enabled by default because it requires an additional dependency
-#
-#option ( BUILD_GLIB_BINDING "Build the glib binding library")
-#if ( BUILD_GLIB_BINDING )
-# add_subdirectory ( glib )
-#endif ( BUILD_GLIB_BINDING )
-
-
-#
# The following adds CPack support
#
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenObex" )
diff --git a/CMakeModules/FindGlib.cmake b/CMakeModules/FindGlib.cmake
deleted file mode 100644
index 89a3eab..0000000
--- a/CMakeModules/FindGlib.cmake
+++ /dev/null
@@ -1,94 +0,0 @@
-
-set ( GLIB_COMPONENTS glib-2.0 )
-foreach ( c ${Glib_FIND_COMPONENTS} )
- list ( APPEND GLIB_COMPONENTS "g${c}-2.0" )
-endforeach ( c )
-
-find_package ( PkgConfig )
-
-if ( PKG_CONFIG_FOUND )
- pkg_check_modules ( PKGCONFIG_GLIB REQUIRED ${GLIB_COMPONENTS} )
-endif ( PKG_CONFIG_FOUND )
-
-if ( PKG_CONFIG_GLIB_FOUND )
- set ( Glib_FOUND ${PKG_CONFIG_GLIB_FOUND} )
- set ( Glib_INCLUDE_DIRS ${PKG_CONFIG_GLIB_INCLUDE_DIRS} )
- foreach ( i ${PKGCONFIG_GLIB_LIBRARIES} )
- find_library ( ${i}_LIBRARY
- NAMES ${i}
- PATHS ${PKGCONFIG_GLIB_LIBRARY_DIRS}
- )
- if ( ${i}_LIBRARY )
- list ( APPEND Glib_LIBRARIES ${${i}_LIBRARY} )
- endif ( ${i}_LIBRARY )
- mark_as_advanced ( ${i}_LIBRARY )
- endforeach ( i )
- mark_as_advanced ( Glib_LIBRARIES )
-
-else ( PKG_CONFIG_GLIB_FOUND )
- find_path ( GLIB_INCLUDE_PATH
- NAMES
- glib.h
- PATHS
- $ENV{GLIB_ROOT_DIR}/include
- PATH_SUFFIXES
- glib-2.0
- )
- mark_as_advanced ( GLIB_INCLUDE_PATH )
-
- foreach ( i ${GLIB_COMPONENTS} )
- find_library ( ${i}_LIBRARY
- NAMES
- ${i}
- PATHS
- $ENV{GLIB_ROOT_DIR}/lib
- )
- if ( ${i}_LIBRARY )
- list ( APPEND Glib_LIBRARIES ${${i}_LIBRARY} )
- endif ( ${i}_LIBRARY )
- mark_as_advanced ( ${i}_LIBRARY )
- endforeach ( i )
- mark_as_advanced ( Glib_LIBRARIES )
-
- if ( glib-2.0_LIBRARY )
- get_filename_component ( glib-2.0_LIBRARY_PATH "${glib-2.0_LIBRARY}" PATH )
- find_path ( GLIBCONFIG_INCLUDE_PATH
- NAMES
- glibconfig.h
- PATHS
- ${glib-2.0_LIBRARY_PATH}/glib-2.0/include
- NO_DEFAULT_PATH
- )
- mark_as_advanced ( GLIBCONFIG_INCLUDE_PATH )
- endif ( glib-2.0_LIBRARY )
-
- set ( Glib_INCLUDE_DIRS
- ${GLIB_INCLUDE_PATH}
- ${GLIBCONFIG_INCLUDE_PATH}
- )
-
- if ( Glib_INCLUDE_DIRS AND Glib_LIBRARIES )
- set ( Glib_FOUND true )
- endif ( Glib_INCLUDE_DIRS AND Glib_LIBRARIES )
-endif ( PKG_CONFIG_GLIB_FOUND )
-
-if ( Glib_FOUND )
- set ( CMAKE_REQUIRED_INCLUDES "${Glib_INCLUDE_DIRS}" )
- check_include_file ( glib.h Glib_FOUND )
-endif ( Glib_FOUND )
-
-if ( NOT Glib_FOUND )
- if ( NOT Glib_FIND_QUIETLY )
- message ( STATUS "Glib not found, try setting GLIB_ROOT_DIR environment variable." )
- endif ( NOT Glib_FIND_QUIETLY )
- if ( Glib_FIND_REQUIRED )
- message ( FATAL_ERROR "" )
- endif ( Glib_FIND_REQUIRED )
-endif ( NOT Glib_FOUND )
-
-find_program ( GLIB_GENMARSHAL_EXECUTABLE
- NAMES glib-genmarshal
- PATHS ${GLIB2_PREFIX}
- PATH_SUFFIXES bin
-)
-mark_as_advanced ( GLIB_GENMARSHAL_EXECUTABLE )
diff --git a/Makefile.am b/Makefile.am
index 76dc85e..f62077f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,20 +1,16 @@
-SUBDIRS = include lib glib apps udev doc
+SUBDIRS = include lib apps udev doc
pkgconfigdir = $(libdir)/pkgconfig
-if GLIB
-pkgconfig_DATA = openobex.pc openobex-glib.pc
-else
pkgconfig_DATA = openobex.pc
-endif
DISTCHECK_CONFIGURE_FLAGS = --enable-apps
EXTRA_DIST = openobex.m4 \
INSTALL.txt INSTALL_Win32.txt \
CMakeLists.txt \
- CMakeModules/FindBluetooth.cmake CMakeModules/FindGlib.cmake \
+ CMakeModules/FindBluetooth.cmake \
CMakeModules/FindIrda.cmake CMakeModules/FindLibUSB.cmake \
CMakeModules/FindXslt.cmake CMakeModules/UseXslt.cmake \
CMakeModules/FindDocbook.cmake CMakeModules/UseDocbook.cmake \
diff --git a/acinclude.m4 b/acinclude.m4
index 3da248a..e2009f9 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -210,14 +210,6 @@ AC_DEFUN([AC_PATH_USB1], [
fi
])
-dnl AC_DEFUN([AC_PATH_GLIB], [
-dnl PKG_CHECK_MODULES(GLIB, glib-2.0 gobject-2.0 gthread-2.0, glib_found=yes, glib_found=no)
-dnl AC_SUBST(GLIB_CFLAGS)
-dnl AC_SUBST(GLIB_LIBS)
-dnl GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
-dnl AC_SUBST(GLIB_GENMARSHAL)
-dnl ])
-
AC_DEFUN([AC_VISIBILITY], [
case $host in
*-*-mingw32*)
@@ -238,7 +230,6 @@ AC_DEFUN([AC_ARG_OPENOBEX], [
irda_enable=yes
bluetooth_enable=yes
usb_enable=yes
- glib_enable=no
apps_enable=no
apps_doc_enable=no
debug_enable=no
@@ -261,10 +252,6 @@ AC_DEFUN([AC_ARG_OPENOBEX], [
usb_enable=${enableval}
])
- dnl AC_ARG_ENABLE(glib, AC_HELP_STRING([--enable-glib], [enable GLib bindings]), [
- dnl glib_enable=${enableval}
- dnl ])
-
AC_ARG_ENABLE(apps, AC_HELP_STRING([--enable-apps], [enable test applications]), [
apps_enable=${enableval}
apps_doc_enable=${enableval}
@@ -334,7 +321,6 @@ AC_DEFUN([AC_ARG_OPENOBEX], [
apps_doc_enable=no
fi
- AM_CONDITIONAL(GLIB, test "${glib_enable}" = "yes" && test "${glib_found}" = "yes")
AM_CONDITIONAL(APPS, test "${apps_enable}" = "yes")
AM_CONDITIONAL(APPS_DOC, test "${apps_doc_enable}" = "yes")
case $host in
diff --git a/configure.ac b/configure.ac
index 34cf7cd..91909f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,9 +39,8 @@ AC_ARG_OPENOBEX
AC_OUTPUT(Makefile
include/Makefile include/openobex/Makefile
lib/Makefile
- glib/Makefile
apps/Makefile apps/lib/Makefile apps/obex_test/Makefile
apps/ircp/Makefile
doc/Makefile doc/Doxyfile
udev/Makefile udev/openobex.rules
- openobex.pc openobex-glib.pc)
+ openobex.pc)
diff --git a/glib/CMakeLists.txt b/glib/CMakeLists.txt
deleted file mode 100644
index ec5223e..0000000
--- a/glib/CMakeLists.txt
+++ /dev/null
@@ -1,139 +0,0 @@
-
-set ( openobex-glib_VERSION 1.0.0 )
-set ( openobex-glib_SOVERSION 0 )
-
-find_package ( Glib REQUIRED object thread)
-
-set ( GENERATED_SOURCES
- obex-marshal.c
- obex-marshal.h
-)
-set_property ( SOURCE ${GENERATED_SOURCES} PROPERTY
- GENERATED true
-)
-
-if ( GLIB_GENMARSHAL_EXECUTABLE )
- add_custom_command (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/obex-marshal.c
- COMMAND ${GLIB_GENMARSHAL_EXECUTABLE}
- ARGS --prefix=obex_marshal obex-marshal.list --body
- > ${CMAKE_CURRENT_BINARY_DIR}/obex-marshal.c
- MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/obex-marshal.list
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- VERBATIM
- )
- add_custom_command (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/obex-marshal.h
- COMMAND ${GLIB_GENMARSHAL_EXECUTABLE}
- ARGS --prefix=obex_marshal obex-marshal.list --header
- > ${CMAKE_CURRENT_BINARY_DIR}/obex-marshal.h
- MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/obex-marshal.list
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- VERBATIM
- )
-
-else ( GLIB_GENMARSHAL_EXECUTABLE )
- message ( FATAL_ERROR "glib-genmarshal not found but needed." )
-endif ( GLIB_GENMARSHAL_EXECUTABLE )
-
-set ( SOURCES
- obex-client.c
- obex-error.c
- obex-lowlevel.c
- ${GENERATED_SOURCES}
-)
-
-set ( HEADERS
- obex-client.h
- obex-debug.h
- obex-error.h
- obex-lowlevel.h
-)
-
-set ( openobex-glib_PUBLIC_HEADER
- obex-client.h
-)
-
-include_directories (
- ${CMAKE_CURRENT_BINARY_DIR}
- ${Glib_INCLUDE_DIRS}
-)
-
-if ( COMPILER_SUPPORT_NOUNDEFINED )
- set ( openobex-glib_LINK_FLAGS
- "${openobex-glib_LINK_FLAGS} ${LINKER_FLAG_NOUNDEFINED}"
- )
-endif ( COMPILER_SUPPORT_NOUNDEFINED )
-
-add_library ( openobex-glib
- ${SOURCES}
-)
-
-target_link_libraries ( openobex-glib
- ${Glib_LIBRARIES}
- openobex
-)
-
-foreach ( i VERSION SOVERSION PUBLIC_HEADER LINK_FLAGS )
- if ( DEFINED openobex-glib_${i} )
- set_property ( TARGET openobex-glib PROPERTY ${i} ${openobex-glib_${i}} )
- endif ( DEFINED openobex-glib_${i} )
-endforeach ( i )
-
-set_property ( TARGET openobex-glib PROPERTY
- DEFINE_SYMBOL OPENOBEX_GLIB_EXPORTS
-)
-
-if ( WIN32 )
- target_link_libraries ( openobex-glib
- ws2_32
- )
-endif ( WIN32 )
-
-install ( TARGETS openobex-glib
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib
- PUBLIC_HEADER DESTINATION include/openobex
- COMPONENT bindings
-)
-install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/obex-client.h
- DESTINATION include/openobex
- COMPONENT bindings
-)
-
-#
-# Copy the .pc file to install it only if the lib gets installed
-#
-add_custom_command ( TARGET openobex-glib
- COMMAND ${CMAKE_COMMAND}
- ARGS -E copy_if_different ${CMAKE_BINARY_DIR}/openobex-glib.pc
- ${CMAKE_CURRENT_BINARY_DIR}/openobex-glib.pc
- VERBATIM
-)
-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/openobex-glib.pc
- DESTINATION ${PKGCONFIG_INSTALL_DIR}
- OPTIONAL
-)
-
-
-
-#
-# These are some test apps for the library above.
-#
-set ( openobex-glib_TESTS
- test-client
- test-lowlevel
-)
-foreach ( prog ${openobex-glib_TESTS} )
- add_executable ( openobex-glib-${prog} EXCLUDE_FROM_ALL
- ${prog}.c
- )
- target_link_libraries ( openobex-glib-${prog}
- openobex-glib
- ${Glib_LIBRARIES}
- )
-endforeach ( prog )
-add_custom_target ( openobex-glib-tests
- DEPENDS ${openobex-glib_TESTS}
-)
diff --git a/glib/Makefile.am b/glib/Makefile.am
deleted file mode 100644
index ed46dc8..0000000
--- a/glib/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-
-includedir = @includedir@...
-
-if GLIB
-include_HEADERS = obex-client.h
-
-lib_LTLIBRARIES = libopenobex-glib.la
-
-libopenobex_glib_la_SOURCES = obex-lowlevel.h obex-lowlevel.c obex-client.c obex-debug.h obex-error.c obex-error.h
-
-libopenobex_glib_la_LDFLAGS = -no-undefined -version-info 1:0:0
-
-libopenobex_glib_la_LIBADD = @GLIB_LIBS@ $(top_builddir)/lib/libopenobex.la @EXTRA_LIBS@
-
-BUILT_SOURCES = obex-marshal.h obex-marshal.c
-
-nodist_libopenobex_glib_la_SOURCES = $(BUILT_SOURCES)
-
-CLEANFILES = $(BUILT_SOURCES)
-
-noinst_PROGRAMS = test-lowlevel test-client
-
-test_lowlevel_LDADD = libopenobex-glib.la
-
-test_client_LDADD = @GLIB_LIBS@ libopenobex-glib.la
-endif
-
-AM_CFLAGS = @GLIB_CFLAGS@
-
-INCLUDES = -I$(top_srcdir)/include
-
-EXTRA_DIST = obex-marshal.list CMakeLists.txt
-
-MAINTAINERCLEANFILES = Makefile.in
-
-if GLIB
-obex-marshal.h: obex-marshal.list
- $(GLIB_GENMARSHAL) --prefix=obex_marshal $< --header > $@
-
-obex-marshal.c: obex-marshal.list
- $(GLIB_GENMARSHAL) --prefix=obex_marshal $< --body > $@
-endif
diff --git a/glib/obex-client.c b/glib/obex-client.c
deleted file mode 100644
index 6ab7cfe..0000000
--- a/glib/obex-client.c
+++ /dev/null
@@ -1,589 +0,0 @@
-/**
- \file glib/obex-client.c
- OpenOBEX glib bindings client code.
- OpenOBEX library - Free implementation of the Object Exchange protocol.
-
- Copyright (C) 2005-2006 Marcel Holtmann <marcel@...>
-
- OpenOBEX is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with OpenOBEX. If not, see <http://www.gnu.org/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <errno.h>
-
-#include "obex-debug.h"
-#include "obex-lowlevel.h"
-#include "obex-error.h"
-#include "obex-marshal.h"
-#include "obex-client.h"
-
-#define OBEX_CLIENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
- OBEX_TYPE_CLIENT, ObexClientPrivate))
-
-typedef struct _ObexClientPrivate ObexClientPrivate;
-
-struct _ObexClientPrivate {
- gboolean auto_connect;
-
-#ifdef G_THREADS_ENABLED
- GMutex *mutex;
-#endif
-
- GMainContext *context;
- GIOChannel *channel;
- obex_t *handle;
-
- gpointer watch_data;
- ObexClientFunc watch_func;
- GDestroyNotify watch_destroy;
-
- GSource *idle_source;
-
- gboolean connected;
-};
-
-G_DEFINE_TYPE(ObexClient, obex_client, G_TYPE_OBJECT)
-
-static void obex_client_init(ObexClient *self)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
-
-#ifdef G_THREADS_ENABLED
- priv->mutex = g_mutex_new();
-#endif
-
- priv->auto_connect = TRUE;
-
- priv->context = g_main_context_default();
- g_main_context_ref(priv->context);
-
- priv->connected = FALSE;
-}
-
-static void obex_client_finalize(GObject *object)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(object);
-
- if (priv->connected == TRUE && priv->auto_connect == TRUE)
- obex_disconnect(priv->handle);
-
- if (priv->idle_source) {
- g_source_destroy(priv->idle_source);
- priv->idle_source = NULL;
- }
-
- obex_close(priv->handle);
- priv->handle = NULL;
-
- g_main_context_unref(priv->context);
- priv->context = NULL;
-
-#ifdef G_THREADS_ENABLED
- g_mutex_free(priv->mutex);
-#endif
-}
-
-enum {
- PROP_0,
- PROP_AUTO_CONNECT
-};
-
-static void obex_client_set_property(GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(object);
-
- switch (prop_id) {
- case PROP_AUTO_CONNECT:
- priv->auto_connect = g_value_get_boolean(value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void obex_client_get_property(GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(object);
-
- switch (prop_id) {
- case PROP_AUTO_CONNECT:
- g_value_set_boolean(value, priv->auto_connect);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-enum {
- CONNECTED_SIGNAL,
- DISCONNECT_SIGNAL,
- CANCELED_SIGNAL,
- PROGRESS_SIGNAL,
- IDLE_SIGNAL,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static void obex_client_class_init(ObexClientClass *klass)
-{
-#ifdef G_THREADS_ENABLED
- if (!g_thread_supported())
- g_thread_init(NULL);
-#endif
-
- g_type_class_add_private(klass, sizeof(ObexClientPrivate));
-
- G_OBJECT_CLASS(klass)->finalize = obex_client_finalize;
-
- G_OBJECT_CLASS(klass)->set_property = obex_client_set_property;
- G_OBJECT_CLASS(klass)->get_property = obex_client_get_property;
-
- g_object_class_install_property(G_OBJECT_CLASS(klass),
- PROP_AUTO_CONNECT, g_param_spec_boolean("auto-connect",
- NULL, NULL, TRUE, G_PARAM_READWRITE));
-
- signals[CONNECTED_SIGNAL] = g_signal_new("connected",
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(ObexClientClass, connected),
- NULL, NULL,
- obex_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[DISCONNECT_SIGNAL] = g_signal_new("disconnect",
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(ObexClientClass, disconnect),
- NULL, NULL,
- obex_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[CANCELED_SIGNAL] = g_signal_new("canceled",
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(ObexClientClass, canceled),
- NULL, NULL,
- obex_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[PROGRESS_SIGNAL] = g_signal_new("progress",
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(ObexClientClass, progress),
- NULL, NULL,
- obex_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[IDLE_SIGNAL] = g_signal_new("idle",
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(ObexClientClass, idle),
- NULL, NULL,
- obex_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static gboolean obex_client_callback(GIOChannel *source,
- GIOCondition cond, gpointer data)
-{
- ObexClient *self = data;
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
-
- if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
- debug("link error");
- return FALSE;
- }
-
- if (OBEX_HandleInput(priv->handle, 1) < 0)
- debug("input error");
- else
- obex_do_callback(priv->handle);
-
- return TRUE;
-}
-
-static gboolean obex_client_put_idle(ObexClient *self)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
-
- debug("obex_client_put_idle");
-
- g_source_destroy(priv->idle_source);
- priv->idle_source = NULL;
-
- if (priv->watch_func)
- priv->watch_func(self, OBEX_CLIENT_COND_OUT, priv->watch_data);
-
- return FALSE;
-}
-
-ObexClient *obex_client_new(void)
-{
- return OBEX_CLIENT(g_object_new(OBEX_TYPE_CLIENT, NULL));
-}
-
-void obex_client_destroy(ObexClient *self)
-{
- g_object_unref(self);
-}
-
-void obex_client_set_auto_connect(ObexClient *self, gboolean auto_connect)
-{
- g_object_set(self, "auto-connect", auto_connect, NULL);
-}
-
-gboolean obex_client_get_auto_connect(ObexClient *self)
-{
- gboolean auto_connect;
-
- g_object_get(self, "auto-connect", &auto_connect, NULL);
-
- return auto_connect;
-}
-
-void obex_client_add_watch_full(ObexClient *self,
- ObexClientCondition condition, ObexClientFunc func,
- gpointer data, GDestroyNotify notify)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
-
- priv->watch_data = data;
- priv->watch_func = func;
- priv->watch_destroy = notify;
-}
-
-void obex_client_add_watch(ObexClient *self, ObexClientCondition condition,
- ObexClientFunc func, gpointer data)
-{
- obex_client_add_watch_full(self, condition, func, data, NULL);
-}
-
-static void obex_connect_cfm(obex_t *handle, void *user_data)
-{
- ObexClient *self = user_data;
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
-
- debug("connected");
-
- priv->connected = TRUE;
-
- g_signal_emit(self, signals[CONNECTED_SIGNAL], 0, NULL);
-}
-
-static void obex_disconn_ind(obex_t *handle, void *user_data)
-{
- ObexClient *self = user_data;
-
- debug("disconnect");
-
- g_signal_emit(self, signals[DISCONNECT_SIGNAL], 0, NULL);
-}
-
-static void obex_progress_ind(obex_t *handle, void *user_data)
-{
- ObexClient *self = user_data;
-
- debug("progress");
-
- g_signal_emit(self, signals[PROGRESS_SIGNAL], 0, NULL);
-}
-
-static void obex_command_ind(obex_t *handle, int event, void *user_data)
-{
- ObexClient *self = user_data;
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
-
- if (!priv->watch_func)
- return;
-
- switch (event) {
- case OBEX_EV_LINKERR:
- case OBEX_EV_PARSEERR:
- priv->watch_func(self, OBEX_CLIENT_COND_ERR, priv->watch_data);
- break;
-
- case OBEX_EV_STREAMAVAIL:
- priv->watch_func(self, OBEX_CLIENT_COND_IN, priv->watch_data);
- break;
-
- case OBEX_EV_STREAMEMPTY:
- priv->watch_func(self, OBEX_CLIENT_COND_OUT, priv->watch_data);
- break;
-
- case OBEX_EV_ABORT:
- case OBEX_EV_REQDONE:
- priv->watch_func(self, OBEX_CLIENT_COND_DONE, priv->watch_data);
- break;
-
- default:
- debug("unhandled event %d", event);
- break;
- }
-}
-
-static obex_callback_t callback = {
- &obex_connect_cfm,
- &obex_disconn_ind,
- &obex_progress_ind,
- &obex_command_ind,
-};
-
-gboolean obex_client_attach_fd(ObexClient *self, int fd, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- GSource *source;
-
- priv->handle = obex_open(fd, &callback, self);
- if (priv->handle == NULL) {
- err2gerror(errno, error);
- return FALSE;
- }
-
- priv->channel = g_io_channel_unix_new(fd);
-
- source = g_io_create_watch(priv->channel,
- G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL);
-
- g_source_set_callback(source, (GSourceFunc) obex_client_callback,
- self, NULL);
-
- g_source_attach(source, priv->context);
-
- g_source_unref(source);
-
- return TRUE;
-}
-
-gboolean obex_client_connect(ObexClient *self, const guchar *target,
- gsize size, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- int err;
-
- err = obex_connect(priv->handle, target, size);
- if (err < 0) {
- err2gerror(-err, error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean obex_client_disconnect(ObexClient *self, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- int err;
-
- err = obex_disconnect(priv->handle);
- if (err < 0) {
- err2gerror(-err, error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean obex_client_put_object(ObexClient *self, const gchar *type,
- const gchar *name, gint size,
- time_t mtime, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- gboolean add_idle = FALSE;
- int err;
-
- if (priv->connected == FALSE && priv->auto_connect == TRUE)
- obex_connect(priv->handle, NULL, 0);
- else
- add_idle = TRUE;
-
- err = obex_put(priv->handle, type, name, size, mtime);
- if (err < 0) {
- err2gerror(-err, error);
- return FALSE;
- }
-
- /* So the application gets OBEX_CLIENT_COND_OUT immediately when
- * returning to the mainloop */
- if (add_idle) {
- priv->idle_source = g_idle_source_new();
- g_source_set_callback(priv->idle_source, (GSourceFunc) obex_client_put_idle,
- self, NULL);
- g_source_attach(priv->idle_source, priv->context);
- g_source_unref(priv->idle_source);
- }
-
- return TRUE;
-}
-
-gboolean obex_client_get_object(ObexClient *self, const gchar *type,
- const gchar *name, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- int err;
-
- if (priv->connected == FALSE && priv->auto_connect == TRUE)
- obex_connect(priv->handle, NULL, 0);
-
- err = obex_get(priv->handle, type, name);
- if (err < 0) {
- err2gerror(-err, error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean obex_client_read(ObexClient *self, gchar *buf, gsize count,
- gsize *bytes_read, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- int err;
-
- err = obex_read(priv->handle, buf, count, bytes_read);
- if (err < 0) {
- err2gerror(-err, error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean obex_client_write(ObexClient *self, const gchar *buf, gsize count,
- gsize *bytes_written, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- int err;
-
- err = obex_write(priv->handle, buf, count, bytes_written);
- if (err < 0) {
- err2gerror(-err, error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean obex_client_flush(ObexClient *self, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- int err;
-
- err = obex_flush(priv->handle);
- if (err < 0) {
- err2gerror(-err, error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean obex_client_abort(ObexClient *self, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- int err;
-
- err = obex_abort(priv->handle);
- if (err < 0) {
- err2gerror(-err, error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean obex_client_close(ObexClient *self, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- int err;
-
- debug("");
-
- err = obex_close_transfer(priv->handle);
- if (err < 0) {
- err2gerror(-err, error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean obex_client_get_error(ObexClient *self, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- int rsp;
-
- rsp = obex_get_response(priv->handle);
- if (rsp == OBEX_RSP_SUCCESS)
- return TRUE;
-
- rsp2gerror(rsp, error);
-
- return FALSE;
-}
-
-gboolean obex_client_mkdir(ObexClient *self, const gchar *path, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- int err;
-
- debug("");
-
- err = obex_setpath(priv->handle, path, 1);
- if (err < 0) {
- err2gerror(-err, error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean obex_client_chdir(ObexClient *self, const gchar *path, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- int err;
-
- debug("");
-
- err = obex_setpath(priv->handle, path, 0);
- if (err < 0) {
- err2gerror(-err, error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean obex_client_delete(ObexClient *self, const gchar *name, GError **error)
-{
- ObexClientPrivate *priv = OBEX_CLIENT_GET_PRIVATE(self);
- int err;
-
- debug("");
-
- err = obex_delete(priv->handle, name);
- if (err < 0) {
- err2gerror(-err, error);
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/glib/obex-client.h b/glib/obex-client.h
deleted file mode 100644
index 28ebd1d..0000000
--- a/glib/obex-client.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- \file glib/obex-client.h
- OpenOBEX glib bindings client code.
- OpenOBEX library - Free implementation of the Object Exchange protocol.
-
- Copyright (C) 2005-2006 Marcel Holtmann <marcel@...>
-
- OpenOBEX is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with OpenOBEX. If not, see <http://www.gnu.org/>.
- */
-
-#ifndef __OBEX_CLIENT_H
-#define __OBEX_CLIENT_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-GQuark obex_error_quark(void);
-
-#define OBEX_ERROR obex_error_quark()
-
-enum {
- OBEX_ERROR_NO_MEMORY,
- OBEX_ERROR_BUSY,
- OBEX_ERROR_INVALID_PARAMS,
- OBEX_ERROR_ALREADY_CONNECTED,
- OBEX_ERROR_NOT_CONNECTED,
- OBEX_ERROR_LINK_FAILURE,
- OBEX_ERROR_ABORTED,
-
- /* Errors derived from OBEX response codes */
- OBEX_ERROR_BAD_REQUEST,
- OBEX_ERROR_UNAUTHORIZED,
- OBEX_ERROR_PAYMENT_REQUIRED,
- OBEX_ERROR_FORBIDDEN,
- OBEX_ERROR_NOT_FOUND,
- OBEX_ERROR_NOT_ALLOWED,
- OBEX_ERROR_NOT_ACCEPTABLE,
- OBEX_ERROR_PROXY_AUTH_REQUIRED,
- OBEX_ERROR_REQUEST_TIME_OUT,
- OBEX_ERROR_CONFLICT,
- OBEX_ERROR_GONE,
- OBEX_ERROR_LENGTH_REQUIRED,
- OBEX_ERROR_PRECONDITION_FAILED,
- OBEX_ERROR_ENTITY_TOO_LARGE,
- OBEX_ERROR_URL_TOO_LARGE,
- OBEX_ERROR_UNSUPPORTED_MEDIA_TYPE,
- OBEX_ERROR_INTERNAL_SERVER_ERROR,
- OBEX_ERROR_NOT_IMPLEMENTED,
- OBEX_ERROR_BAD_GATEWAY,
- OBEX_ERROR_SERVICE_UNAVAILABLE,
- OBEX_ERROR_GATEWAY_TIMEOUT,
- OBEX_ERROR_VERSION_NOT_SUPPORTED,
- OBEX_ERROR_DATABASE_FULL,
- OBEX_ERROR_DATABASE_LOCKED,
-
- OBEX_ERROR_FAILED
-};
-
-#define OBEX_TYPE_CLIENT (obex_client_get_type())
-#define OBEX_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- OBEX_TYPE_CLIENT, ObexClient))
-#define OBEX_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \
- OBEX_TYPE_CLIENT, ObexClientClass))
-#define OBEX_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
- OBEX_TYPE_CLIENT))
-#define OBEX_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), \
- OBEX_TYPE_CLIENT))
-#define OBEX_GET_CLIENT_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), \
- OBEX_TYPE_CLIENT, ObexClientClass))
-
-typedef struct _ObexClient ObexClient;
-typedef struct _ObexClientClass ObexClientClass;
-
-struct _ObexClient {
- GObject parent;
-};
-
-struct _ObexClientClass {
- GObjectClass parent_class;
-
- void (*connected)(ObexClient *self);
- void (*disconnect)(ObexClient *self);
- void (*canceled)(ObexClient *self);
- void (*progress)(ObexClient *self);
- void (*idle)(ObexClient *self);
-};
-
-GType obex_client_get_type(void);
-
-ObexClient *obex_client_new(void);
-
-void obex_client_destroy(ObexClient *self);
-
-void obex_client_set_auto_connect(ObexClient *self, gboolean auto_connect);
-
-gboolean obex_client_get_auto_connect(ObexClient *self);
-
-typedef enum {
- OBEX_CLIENT_COND_IN = 1 << 0,
- OBEX_CLIENT_COND_OUT = 1 << 1,
- OBEX_CLIENT_COND_DONE = 1 << 2,
- OBEX_CLIENT_COND_ERR = 1 << 3,
-} ObexClientCondition;
-
-typedef void (*ObexClientFunc)(ObexClient *client,
- ObexClientCondition condition, gpointer data);
-
-void obex_client_add_watch(ObexClient *self, ObexClientCondition condition,
- ObexClientFunc func, gpointer data);
-
-void obex_client_add_watch_full(ObexClient *self,
- ObexClientCondition condition, ObexClientFunc func,
- gpointer data, GDestroyNotify notify);
-
-gboolean obex_client_attach_fd(ObexClient *self, int fd, GError **error);
-
-gboolean obex_client_connect(ObexClient *self, const guchar *target,
- gsize size, GError **error);
-
-gboolean obex_client_disconnect(ObexClient *self, GError **error);
-
-gboolean obex_client_put_object(ObexClient *self, const gchar *type,
- const gchar *name, gint size,
- time_t mtime, GError **error);
-
-gboolean obex_client_get_object(ObexClient *self, const gchar *type,
- const gchar *name, GError **error);
-
-gboolean obex_client_read(ObexClient *self, gchar *buf, gsize count,
- gsize *bytes_read, GError **error);
-
-gboolean obex_client_write(ObexClient *self, const gchar *buf, gsize count,
- gsize *bytes_written, GError **error);
-
-gboolean obex_client_flush(ObexClient *self, GError **error);
-
-gboolean obex_client_abort(ObexClient *self, GError **error);
-
-gboolean obex_client_close(ObexClient *self, GError **error);
-
-gboolean obex_client_get_error(ObexClient *self, GError **error);
-
-gboolean obex_client_mkdir(ObexClient *self, const gchar *path, GError **error);
-
-gboolean obex_client_chdir(ObexClient *self, const gchar *path, GError **error);
-
-gboolean obex_client_delete(ObexClient *self, const gchar *name, GError **error);
-
-G_END_DECLS
-
-#endif /* __OBEX_CLIENT_H */
diff --git a/glib/obex-debug.h b/glib/obex-debug.h
deleted file mode 100644
index 7c1f3d9..0000000
--- a/glib/obex-debug.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- \file glib/obex-debug.h
- OpenOBEX glib bindings debug code.
- OpenOBEX library - Free implementation of the Object Exchange protocol.
-
- Copyright (C) 2005-2006 Marcel Holtmann <marcel@...>
-
- OpenOBEX is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with OpenOBEX. If not, see <http://www.gnu.org/>.
- */
-
-#include <stdio.h>
-
-#if defined(_MSC_VER) && _MSC_VER < 1400
-static void debug (char *fmt, ...) {}
-#else
-#define debug(fmt, ...) fprintf(stderr, "== %s: " fmt "\n" , __FUNCTION__ , ## __VA_ARGS__)
-#endif
diff --git a/glib/obex-error.c b/glib/obex-error.c
deleted file mode 100644
index cba70b4..0000000
--- a/glib/obex-error.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- \file glib/obex-error.c
- OpenOBEX glib bindings error handling code.
- OpenOBEX library - Free implementation of the Object Exchange protocol.
-
- Copyright (C) 2005-2006 Marcel Holtmann <marcel@...>
-
- OpenOBEX is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with OpenOBEX. If not, see <http://www.gnu.org/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef _WIN32
-#include <winsock2.h>
-#define EISCONN WSAEISCONN
-#define ENOTCONN WSAENOTCONN
-#endif
-
-#include <errno.h>
-
-#include "obex-debug.h"
-#include "obex-client.h"
-#include "obex-error.h"
-
-GQuark obex_error_quark(void)
-{
- static GQuark q = 0;
-
- if (q == 0)
- q = g_quark_from_static_string("obex-error-quark");
-
- return q;
-}
-
-void err2gerror(int err, GError **gerr)
-{
- debug("%s", g_strerror(err));
-
- if (!gerr)
- return;
-
- switch (err) {
- case ENOMEM:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_NO_MEMORY,
- "Out of memory");
- break;
-
- case EBUSY:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_BUSY,
- "Busy performing another operation");
- break;
-
- case EINVAL:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_INVALID_PARAMS,
- "Invalid parameters were given");
- break;
-
- case EISCONN:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_ALREADY_CONNECTED,
- "Already connected");
- break;
-
- case ENOTCONN:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_NOT_CONNECTED,
- "Not connected");
- break;
-
- case EINTR:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_ABORTED,
- "The operation was aborted");
- break;
-
- default:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_FAILED,
- "Failed");
- break;
- }
-}
-
-void rsp2gerror(int rsp, GError **gerr)
-{
- if (!gerr)
- return;
-
- switch (rsp) {
- case 0x40:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_BAD_REQUEST,
- "Bad Request - server couldn't understand request");
- break;
-
- case 0x41:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_UNAUTHORIZED,
- "Unauthorized");
- break;
-
- case 0x42:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_PAYMENT_REQUIRED,
- "Payment required");
- break;
-
- case 0x43:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_FORBIDDEN,
- "Forbidden - operation is understood but refused");
- break;
-
- case 0x44:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_NOT_FOUND,
- "Not Found");
- break;
-
- case 0x45:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_NOT_ALLOWED,
- "Method not allowed");
- break;
-
- case 0x46:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_NOT_ACCEPTABLE,
- "Not Acceptable");
- break;
-
- case 0x47:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_PROXY_AUTH_REQUIRED,
- "Proxy Authentication required");
- break;
-
- case 0x48:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_REQUEST_TIME_OUT,
- "Request Time Out");
- break;
-
- case 0x49:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_CONFLICT,
- "Conflict");
- break;
-
- case 0x4A:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_GONE,
- "Gone");
- break;
-
- case 0x4B:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_LENGTH_REQUIRED,
- "Length Required");
- break;
-
- case 0x4C:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_PRECONDITION_FAILED,
- "Precondition failed");
- break;
-
- case 0x4D:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_ENTITY_TOO_LARGE,
- "Requested entity too large");
- break;
-
- case 0x4E:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_URL_TOO_LARGE,
- "Request URL too large");
- break;
-
- case 0x4F:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media type");
- break;
-
- case 0x50:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_INTERNAL_SERVER_ERROR,
- "Internal Server Error");
- break;
-
- case 0x51:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_NOT_IMPLEMENTED,
- "Not Implemented");
- break;
-
- case 0x52:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_BAD_GATEWAY,
- "Bad Gateway");
- break;
-
- case 0x53:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_SERVICE_UNAVAILABLE,
- "Service Unavailable");
- break;
-
- case 0x54:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_GATEWAY_TIMEOUT,
- "Gateway Timeout");
- break;
-
- case 0x55:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_VERSION_NOT_SUPPORTED,
- "HTTP version not supported");
- break;
-
- case 0x60:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_DATABASE_FULL,
- "Database Full");
- break;
-
- case 0x61:
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_DATABASE_LOCKED,
- "Database Locked");
- break;
-
- default:
- debug("Unmapped OBEX response: %d", rsp);
- g_set_error(gerr, OBEX_ERROR, OBEX_ERROR_FAILED,
- "Failed");
- break;
- }
-}
-
diff --git a/glib/obex-error.h b/glib/obex-error.h
deleted file mode 100644
index b6ec5ca..0000000
--- a/glib/obex-error.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- \file glib/obex-error.h
- OpenOBEX glib bindings error handling code.
- OpenOBEX library - Free implementation of the Object Exchange protocol.
-
- Copyright (C) 2005-2006 Marcel Holtmann <marcel@...>
-
- OpenOBEX is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with OpenOBEX. If not, see <http://www.gnu.org/>.
- */
-
-#ifndef __OBEX_ERROR_H
-#define __OBEX_ERROR_H
-
-#include <glib.h>
-
-void err2gerror(int err, GError **gerr);
-
-void rsp2gerror(int rsp, GError **gerr);
-
-#endif /* __OBEX_ERROR_H */
diff --git a/glib/obex-lowlevel.c b/glib/obex-lowlevel.c
deleted file mode 100644
index 65172fc..0000000
--- a/glib/obex-lowlevel.c
+++ /dev/null
@@ -1,1014 +0,0 @@
-/**
- \file glib/obex-lowlevel.c
- OpenOBEX glib bindings low level code.
- OpenOBEX library - Free implementation of the Object Exchange protocol.
-
- Copyright (C) 2005-2006 Marcel Holtmann <marcel@...>
-
- OpenOBEX is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with OpenOBEX. If not, see <http://www.gnu.org/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <malloc.h>
-#include <string.h>
-#include <time.h>
-
-#ifdef _WIN32
-#include <winsock2.h>
-static struct tm * gmtime_r ( time_t *t, struct tm *result)
-{
- if (result) {
- const time_t t2 = *t;
- struct tm *tmp = gmtime(&t2);
- if (!tmp)
- return NULL;
- memcpy(result, &tmp, sizeof(result));
- }
- return result;
-}
-#define snprintf _snprintf
-#define EISCONN WSAEISCONN
-#define ENOTCONN WSAENOTCONN
-#else
-#include <arpa/inet.h>
-#endif
-
-#include <glib.h>
-
-#include "obex-debug.h"
-#include "obex-lowlevel.h"
-
-#define BUF_SIZE 32767
-
-#define CID_INVALID 0xFFFFFFFF
-
-#define OBEX_TIMEOUT 1
-
-enum {
- OBEX_CONNECTED = 1, /* Equal to TCP_ESTABLISHED */
- OBEX_OPEN,
- OBEX_BOUND,
- OBEX_LISTEN,
- OBEX_CONNECT,
- OBEX_CONNECT2,
- OBEX_CONFIG,
- OBEX_DISCONN,
- OBEX_CLOSED
-};
-
-#pragma pack(1)
-typedef struct obex_setpath_hdr {
- uint8_t flags;
- uint8_t constants;
-} obex_setpath_hdr_t;
-#pragma pack()
-
-#pragma pack(1)
-typedef struct obex_connect_hdr {
- uint8_t version;
- uint8_t flags;
- uint16_t mtu;
-} obex_connect_hdr_t;
-#pragma pack()
-
-typedef struct {
- int event;
-} obex_ev_t;
-
-typedef struct {
- unsigned long state;
- uint32_t cid;
-
- void *user_data;
- obex_callback_t *callback;
-
- obex_object_t *pending;
-
- int obex_rsp; /* Response to last OBEX command */
-
- /* Transfer related variables */
- char buf[BUF_SIZE]; /* Data buffer for put and get requests */
- int data_start; /* Offset of data in buffer */
- int data_length; /* Length of actual data in buffer */
- int counter; /* Total bytes transfered so far */
- int target_size; /* Final length of object under transfer */
- time_t modtime; /* Modification time of object under transfer */
- int tx_max; /* Maximum size for sent chunks of data */
- int close; /* If the user has called obex_close */
- GSList *events; /* Events to signal when HandleInput returns */
-} obex_context_t;
-
-static void queue_event(obex_context_t *context, int e)
-{
- obex_ev_t *event;
-
- event = malloc(sizeof(obex_ev_t));
- if (!event)
- return;
-
- memset(event, 0, sizeof(obex_ev_t));
-
- event->event = e;
-
- context->events = g_slist_append(context->events, event);
-}
-
-static int make_iso8601(time_t time, char *str, int len) {
- struct tm tm;
-#if defined(HAVE_TIMEZONE) && defined(USE_LOCALTIME)
- time_t tz_offset = 0;
-
- tzset();
-
- tz_offset = -timezone;
- if (daylight > 0)
- tz_offset += 3600;
- time += tz_offset;
-#endif
-
- if (gmtime_r(&time, &tm) == NULL)
- return -1;
-
- tm.tm_year += 1900;
- tm.tm_mon++;
-
- return snprintf(str, len,
-#ifdef USE_LOCALTIME
- "%04u%02u%02uT%02u%02u%02u",
-#else
- "%04u%02u%02uT%02u%02u%02uZ",
-#endif
- tm.tm_year, tm.tm_mon, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec);
-}
-
-time_t parse_iso8601(const char *str, int len)
-{
- char *tstr, tz;
- struct tm tm;
- int nr;
- time_t time, tz_offset = 0;
-
- memset(&tm, 0, sizeof(struct tm));
-
- /* According to spec the time doesn't have to be null terminated */
- tstr = malloc(len + 1);
- if (!tstr)
- return -1;
-
- strncpy(tstr, str, len);
- tstr[len] = '\0';
-
- nr = sscanf(tstr, "%04u%02u%02uT%02u%02u%02u%c",
- &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
- &tm.tm_hour, &tm.tm_min, &tm.tm_sec,
- &tz);
-
- free(tstr);
-
- /* Fixup the tm values */
- tm.tm_year -= 1900; /* Year since 1900 */
- tm.tm_mon--; /* Months since January, values 0-11 */
- tm.tm_isdst = -1; /* Daylight savings information not avail */
-
- if (nr < 6) {
- /* Invalid time format */
- return -1;
- }
-
- time = mktime(&tm);
-
-#if defined(HAVE_TM_GMTOFF)
- tz_offset = tm.tm_gmtoff;
-#elif defined(HAVE_TIMEZONE)
- tz_offset = -timezone;
- if (tm.tm_isdst > 0)
- tz_offset += 3600;
-#endif
-
- if (nr == 7) { /* Date/Time was in localtime (to remote device)
- * already. Since we don't know anything about the
- * timezone on that one we won't try to apply UTC offset
- */
- time += tz_offset;
- }
-
- return time;
-}
-
-static void get_target_size_and_time(obex_t *handle, obex_object_t *object,
- obex_context_t *context) {
- obex_headerdata_t hv;
- uint8_t hi;
- unsigned int hlen;
-
- context->target_size = -1;
- context->modtime = -1;
-
- while (OBEX_ObjectGetNextHeader(handle, object, &hi, &hv, &hlen)) {
- switch (hi) {
- case OBEX_HDR_LENGTH:
- context->target_size = hv.bq4;
- break;
- case OBEX_HDR_TIME:
- context->modtime = parse_iso8601((char *) hv.bs, hlen);
- break;
- default:
- break;
- }
- }
-
- OBEX_ObjectReParseHeaders(handle, object);
-}
-
-static void obex_progress(obex_t *handle, obex_object_t *object)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
-
- if (context->callback && context->callback->progress_ind)
- context->callback->progress_ind(handle, context->user_data);
-}
-
-static void obex_connect_done(obex_t *handle,
- obex_object_t *object, int response)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- obex_headerdata_t hd;
- uint32_t hl;
- uint8_t hi, *ptr;
-
- if (response != OBEX_RSP_SUCCESS)
- return;
-
- context->state = OBEX_CONNECTED;
-
- if (OBEX_ObjectGetNonHdrData(object, &ptr) == sizeof(obex_connect_hdr_t)) {
- obex_connect_hdr_t *chdr = (obex_connect_hdr_t *) ptr;
- uint16_t mtu = ntohs(chdr->mtu);
- int new_size;
-
- debug("Connect success. Version: 0x%02x. Flags: 0x%02x OBEX packet length: %d",
- chdr->version, chdr->flags, mtu);
-
- /* Leave space for headers */
- new_size = mtu - 200;
- if (new_size < context->tx_max) {
- debug("Resizing stream chunks to %d", new_size);
- context->tx_max = new_size;
- }
- }
-
- while (OBEX_ObjectGetNextHeader(handle, object, &hi, &hd, &hl)) {
- switch (hi) {
- case OBEX_HDR_CONNECTION:
- context->cid = hd.bq4;
- break;
- case OBEX_HDR_WHO:
- break;
- }
- }
-
- if (context->callback && context->callback->connect_cfm)
- context->callback->connect_cfm(handle, context->user_data);
-}
-
-static void obex_disconnect_done(obex_t *handle,
- obex_object_t *object, int response)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
-
- context->state = OBEX_CLOSED;
-}
-
-void obex_do_callback(obex_t *handle)
-{
- GSList *l;
- obex_context_t *context = OBEX_GetUserData(handle);
-
- if (!context->events || ! context->callback || ! context->callback->command_ind)
- return;
-
- for (l = context->events; l != NULL; l = l->next) {
- obex_ev_t *event = l->data;
- context->callback->command_ind(handle, event->event, context->user_data);
- free(event);
- }
-
- g_slist_free(context->events);
- context->events = NULL;
-}
-
-static void obex_readstream(obex_t *handle, obex_object_t *object)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- const uint8_t *buf;
- int actual, free_space;
-
- if (context->counter == 0)
- get_target_size_and_time(handle, object, context);
-
- actual = OBEX_ObjectReadStream(handle, object, &buf);
- if (actual <= 0) {
- debug("Error or no data on OBEX stream");
- return;
- }
-
- context->counter += actual;
-
- debug("obex_readstream: got %d bytes (%d in total)", actual, context->counter);
-
- free_space = sizeof(context->buf) - (context->data_start + context->data_length);
- if (actual > free_space) {
- /* This should never happen */
- debug("Out of buffer space: actual=%d, free=%d", actual, free_space);
- return;
- }
-
- memcpy(&context->buf[context->data_start], buf, actual);
- context->data_length += actual;
-
- debug("OBEX_SuspendRequest");
- OBEX_SuspendRequest(handle, object);
-
- queue_event(context, OBEX_EV_STREAMAVAIL);
-}
-
-static void obex_writestream(obex_t *handle, obex_object_t *object)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- obex_headerdata_t hv;
-
- if (context->data_length > 0) {
- int send_size = context->data_length > context->tx_max ?
- context->tx_max : context->data_length;
-
- hv.bs = (uint8_t *) &context->buf[context->data_start];
- OBEX_ObjectAddHeader(handle, object, OBEX_HDR_BODY,
- hv, send_size, OBEX_FL_STREAM_DATA);
-
- context->counter += send_size;
- context->data_length -= send_size;
-
- if (context->data_length == 0)
- context->data_start = 0;
- else
- context->data_start += send_size;
-
- if (!context->close && context->data_length == 0) {
- debug("OBEX_SuspendRequest");
- OBEX_SuspendRequest(handle, object);
- queue_event(context, OBEX_EV_STREAMEMPTY);
- }
- }
- else {
- if (context->counter < context->target_size)
- debug("Sending stream end but only %d/%d bytes sent",
- context->counter, context->target_size);
- hv.bs = NULL;
- OBEX_ObjectAddHeader(handle, object, OBEX_HDR_BODY, hv, 0,
- OBEX_FL_STREAM_DATAEND);
- }
-}
-
-static void obex_event(obex_t *handle, obex_object_t *object,
- int mode, int event, int command, int response)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
-
- switch (event) {
- case OBEX_EV_PROGRESS:
- obex_progress(handle, object);
- break;
-
- case OBEX_EV_REQHINT:
- OBEX_ObjectSetRsp(object, OBEX_RSP_NOT_IMPLEMENTED, response);
- break;
-
- case OBEX_EV_REQ:
- OBEX_ObjectSetRsp(object, OBEX_RSP_NOT_IMPLEMENTED, response);
- break;
-
- case OBEX_EV_REQDONE:
- debug("OBEX_EV_REQDONE");
-
- context->obex_rsp = response;
- queue_event(context, OBEX_EV_REQDONE);
-
- if (context->pending && OBEX_Request(handle, context->pending) == 0) {
- if (OBEX_ObjectGetCommand(handle, context->pending) == OBEX_CMD_PUT)
- queue_event(context, OBEX_EV_STREAMEMPTY);
- context->pending = NULL;
- }
-
- switch (command) {
- case OBEX_CMD_CONNECT:
- obex_connect_done(handle, object, response);
- break;
- case OBEX_CMD_DISCONNECT:
- obex_disconnect_done(handle, object, response);
- break;
- case OBEX_CMD_PUT:
- case OBEX_CMD_GET:
- break;
- case OBEX_CMD_SETPATH:
- break;
- case OBEX_CMD_SESSION:
- break;
- case OBEX_CMD_ABORT:
- break;
- }
- break;
-
- case OBEX_EV_LINKERR:
- OBEX_TransportDisconnect(handle);
- break;
-
- case OBEX_EV_PARSEERR:
- OBEX_TransportDisconnect(handle);
- break;
-
- case OBEX_EV_ACCEPTHINT:
- break;
-
- case OBEX_EV_ABORT:
- queue_event(context, OBEX_EV_ABORT);
- break;
-
- case OBEX_EV_STREAMEMPTY:
- debug("OBEX_EV_STREAMEMPTY");
- obex_writestream(handle, object);
- break;
-
- case OBEX_EV_STREAMAVAIL:
- debug("OBEX_EV_STREAMAVAIL");
- obex_readstream(handle, object);
- break;
-
- case OBEX_EV_UNEXPECTED:
- break;
-
- case OBEX_EV_REQCHECK:
- break;
- }
-}
-
-obex_t *obex_open(int fd, obex_callback_t *callback, void *data)
-{
- obex_t *handle;
- obex_context_t *context;
-
- context = malloc(sizeof(*context));
- if (!context)
- return NULL;
-
- memset(context, 0, sizeof(*context));
-
- context->state = OBEX_OPEN;
- context->cid = CID_INVALID;
-
- handle = OBEX_Init(OBEX_TRANS_FD, obex_event, 0);
- if (!handle) {
- free(context);
- return NULL;
- }
-
- context->user_data = data;
- context->callback = callback;
- context->tx_max = sizeof(context->buf);
-
- OBEX_SetUserData(handle, context);
-
- OBEX_SetTransportMTU(handle, sizeof(context->buf), sizeof(context->buf));
-
- if (FdOBEX_TransportSetup(handle, fd, fd, 0) < 0) {
- OBEX_Cleanup(handle);
- return NULL;
- }
-
- return handle;
-}
-
-void obex_close(obex_t *handle)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- g_return_if_fail(context != NULL);
-
- OBEX_SetUserData(handle, NULL);
-
- if (context->pending)
- OBEX_ObjectDelete(handle, context->pending);
-
- free(context);
-
- OBEX_Cleanup(handle);
-}
-
-void obex_poll(obex_t *handle)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- unsigned long state = context->state;
-
- while (1) {
- OBEX_HandleInput(handle, OBEX_TIMEOUT);
- if (context->state != state)
- break;
- }
-
- obex_do_callback(handle);
-}
-
-static int obex_send_or_queue(obex_t *handle, obex_object_t *object)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- int err;
-
- err = OBEX_Request(handle, object);
-
- if (err == -EBUSY && !context->pending) {
- context->pending = object;
- return 0;
- }
-
- return err;
-}
-
-int obex_connect(obex_t *handle, const unsigned char *target, size_t size)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- obex_object_t *object;
- obex_headerdata_t hd;
- int err, ret;
- g_return_val_if_fail(context != NULL, -1);
-
- if (context->state != OBEX_OPEN && context->state != OBEX_CLOSED)
- return -EISCONN;
-
- object = OBEX_ObjectNew(handle, OBEX_CMD_CONNECT);
- if (!object)
- return -ENOMEM;
-
- if (target) {
- hd.bs = target;
-
- err = OBEX_ObjectAddHeader(handle, object,
- OBEX_HDR_TARGET, hd, size, OBEX_FL_FIT_ONE_PACKET);
- if (err < 0) {
- OBEX_ObjectDelete(handle, object);
- return err;
- }
- }
-
- context->state = OBEX_CONNECT;
-
- ret = obex_send_or_queue(handle, object);
- if (ret < 0)
- OBEX_ObjectDelete(handle, object);
-
- return ret;
-}
-
-int obex_disconnect(obex_t *handle)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- obex_object_t *object;
- int ret;
- g_return_val_if_fail(context != NULL, -1);
-
- if (context->state != OBEX_CONNECTED)
- return -ENOTCONN;
-
- object = OBEX_ObjectNew(handle, OBEX_CMD_DISCONNECT);
- if (!object)
- return -ENOMEM;
-
- context->state = OBEX_DISCONN;
-
- if (context->callback && context->callback->disconn_ind)
- context->callback->disconn_ind(handle, context->user_data);
-
- ret = obex_send_or_queue(handle, object);
- if (ret < 0)
- OBEX_ObjectDelete(handle, object);
-
- return ret;
-}
-
-int obex_delete(obex_t *handle, const char *name)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- obex_object_t *object;
- obex_headerdata_t hd;
- int err;
- g_return_val_if_fail(context != NULL, -1);
-
- if (context->state != OBEX_OPEN && context->state != OBEX_CONNECT
- && context->state != OBEX_CONNECTED)
- return -ENOTCONN;
-
- object = OBEX_ObjectNew(handle, OBEX_CMD_PUT);
- if (!object)
- return -ENOMEM;
-
- if (context->cid != CID_INVALID) {
- hd.bq4 = context->cid;
- OBEX_ObjectAddHeader(handle, object,
- OBEX_HDR_CONNECTION, hd, 4, OBEX_FL_FIT_ONE_PACKET);
- }
-
- if (name) {
- int len, ulen = (strlen(name) + 1) * 2;
- uint8_t *unicode = malloc(ulen);
-
- if (!unicode) {
- OBEX_ObjectDelete(handle, object);
- return -ENOMEM;
- }
-
- len = OBEX_CharToUnicode(unicode, (uint8_t *) name, ulen);
- hd.bs = unicode;
-
- err = OBEX_ObjectAddHeader(handle, object,
- OBEX_HDR_NAME, hd, len, OBEX_FL_FIT_ONE_PACKET);
- if (err < 0) {
- OBEX_ObjectDelete(handle, object);
- free(unicode);
- return err;
- }
-
- free(unicode);
- }
-
- err = obex_send_or_queue(handle, object);
- if (err < 0)
- OBEX_ObjectDelete(handle, object);
-
- return err;
-}
-
-int obex_put(obex_t *handle, const char *type, const char *name, int size, time_t mtime)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- obex_object_t *object;
- obex_headerdata_t hd;
- int err, cmd;
- g_return_val_if_fail(context != NULL, -1);
-
- if (context->state != OBEX_OPEN && context->state != OBEX_CONNECT
- && context->state != OBEX_CONNECTED)
- return -ENOTCONN;
-
- cmd = OBEX_ObjectGetCommand(handle, NULL);
- if (cmd == OBEX_CMD_GET || cmd == OBEX_CMD_PUT)
- return -EBUSY;
-
- /* Initialize transfer variables */
- context->data_start = 0;
- context->data_length = 0;
- context->counter = 0;
- context->target_size = size;
- context->modtime = mtime;
- context->close = 0;
-
- object = OBEX_ObjectNew(handle, OBEX_CMD_PUT);
- if (!object)
- return -ENOMEM;
-
- if (context->cid != CID_INVALID) {
- hd.bq4 = context->cid;
- OBEX_ObjectAddHeader(handle, object,
- OBEX_HDR_CONNECTION, hd, 4, OBEX_FL_FIT_ONE_PACKET);
- }
-
- if (type) {
- int len = strlen(type) + 1;
-
- hd.bs = (uint8_t *) type;
-
- err = OBEX_ObjectAddHeader(handle, object,
- OBEX_HDR_TYPE, hd, len, OBEX_FL_FIT_ONE_PACKET);
- if (err < 0) {
- OBEX_ObjectDelete(handle, object);
- return err;
- }
- }
-
- if (name) {
- int len, ulen = (strlen(name) + 1) * 2;
- uint8_t *unicode = malloc(ulen);
-
- if (!unicode) {
- OBEX_ObjectDelete(handle, object);
- return -ENOMEM;
- }
-
- len = OBEX_CharToUnicode(unicode, (uint8_t *) name, ulen);
- hd.bs = unicode;
-
- err = OBEX_ObjectAddHeader(handle, object,
- OBEX_HDR_NAME, hd, len, OBEX_FL_FIT_ONE_PACKET);
- if (err < 0) {
- OBEX_ObjectDelete(handle, object);
- free(unicode);
- return err;
- }
-
- free(unicode);
- }
-
- /* Add a time header if possible */
- if (context->modtime >= 0) {
- char tstr[17];
- int len;
-
- len = make_iso8601(context->modtime, tstr, sizeof(tstr));
-
- if (len >= 0) {
- debug("Adding time header: %s", tstr);
- hd.bs = (uint8_t *) tstr;
- OBEX_ObjectAddHeader(handle, object, OBEX_HDR_TIME, hd, len, 0);
- }
- }
-
- /* Add a length header if possible */
- if (context->target_size > 0) {
- debug("Adding length header: %d", context->target_size);
- hd.bq4 = (uint32_t) context->target_size;
- OBEX_ObjectAddHeader(handle, object, OBEX_HDR_LENGTH, hd, 4, 0);
- }
-
- hd.bs = NULL;
- OBEX_ObjectAddHeader(handle, object, OBEX_HDR_BODY, hd, 0, OBEX_FL_STREAM_START);
-
- /* We need to suspend until the user has provided some data
- * by calling obex_client_write */
- debug("OBEX_SuspendRequest");
- OBEX_SuspendRequest(handle, object);
-
- err = obex_send_or_queue(handle, object);
- if (err < 0)
- OBEX_ObjectDelete(handle, object);
-
- return err;
-}
-
-int obex_get(obex_t *handle, const char *type, const char *name)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- obex_object_t *object;
- obex_headerdata_t hd;
- int err, cmd;
- g_return_val_if_fail(context != NULL, -1);
-
- if (context->state != OBEX_OPEN && context->state != OBEX_CONNECT
- && context->state != OBEX_CONNECTED)
- return -ENOTCONN;
-
- cmd = OBEX_ObjectGetCommand(handle, NULL);
- if (cmd == OBEX_CMD_GET || cmd == OBEX_CMD_PUT)
- return -EBUSY;
-
- /* Initialize transfer variables */
- context->data_start = 0;
- context->data_length = 0;
- context->counter = 0;
- context->target_size = -1;
- context->modtime = -1;
- context->close = 0;
-
- object = OBEX_ObjectNew(handle, OBEX_CMD_GET);
- if (!object)
- return -ENOMEM;
-
- if (context->cid != CID_INVALID) {
- hd.bq4 = context->cid;
- OBEX_ObjectAddHeader(handle, object,
- OBEX_HDR_CONNECTION, hd, 4, OBEX_FL_FIT_ONE_PACKET);
- }
-
- if (type) {
- int len = strlen(type) + 1;
-
- hd.bs = (uint8_t *) type;
-
- err = OBEX_ObjectAddHeader(handle, object,
- OBEX_HDR_TYPE, hd, len, OBEX_FL_FIT_ONE_PACKET);
- if (err < 0) {
- OBEX_ObjectDelete(handle, object);
- return err;
- }
- }
-
- if (name) {
- int len, ulen = (strlen(name) + 1) * 2;
- uint8_t *unicode = malloc(ulen);
-
- if (!unicode) {
- OBEX_ObjectDelete(handle, object);
- return -ENOMEM;
- }
-
- len = OBEX_CharToUnicode(unicode, (uint8_t *) name, ulen);
- hd.bs = unicode;
-
- err = OBEX_ObjectAddHeader(handle, object,
- OBEX_HDR_NAME, hd, len, OBEX_FL_FIT_ONE_PACKET);
- if (err < 0) {
- OBEX_ObjectDelete(handle, object);
- free(unicode);
- return err;
- }
-
- free(unicode);
- }
-
- OBEX_ObjectReadStream(handle, object, NULL);
-
- err = obex_send_or_queue(handle, object);
- if (err < 0)
- OBEX_ObjectDelete(handle, object);
-
- return err;
-}
-
-int obex_read(obex_t *handle, char *buf, size_t count, size_t *bytes_read)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
-
- if (OBEX_ObjectGetCommand(handle, NULL) != OBEX_CMD_GET)
- return -EINVAL;
-
- if (context->data_length == 0)
- return -EAGAIN;
-
- *bytes_read = count < context->data_length ? count : context->data_length;
-
- memcpy(buf, &context->buf[context->data_start], *bytes_read);
-
- context->data_length -= *bytes_read;
-
- if (context->data_length)
- context->data_start += *bytes_read;
- else {
- context->data_start = 0;
- debug("OBEX_ResumeRequest");
- OBEX_ResumeRequest(handle);
- }
-
- return 0;
-}
-
-int obex_write(obex_t *handle, const char *buf, size_t count, size_t *bytes_written)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- int free_space;
-
- if (OBEX_ObjectGetCommand(handle, NULL) != OBEX_CMD_PUT)
- return -EINVAL;
-
- free_space = sizeof(context->buf) - (context->data_start + context->data_length);
-
- *bytes_written = count > free_space ? free_space : count;
-
- memcpy(&context->buf[context->data_start + context->data_length], buf, *bytes_written);
-
- context->data_length += *bytes_written;
-
- if (context->data_length >= context->tx_max || *bytes_written == free_space) {
- debug("OBEX_ResumeRequest");
- OBEX_ResumeRequest(handle);
- }
-
- return 0;
-}
-
-int obex_flush(obex_t *handle)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
-
- if (OBEX_ObjectGetCommand(handle, NULL) != OBEX_CMD_PUT)
- return -EINVAL;
-
- if (context->data_length) {
- debug("OBEX_ResumeRequest");
- OBEX_ResumeRequest(handle);
- }
-
- return 0;
-}
-
-int obex_abort(obex_t *handle)
-{
- int cmd;
-
- cmd = OBEX_ObjectGetCommand(handle, NULL);
- if (cmd != OBEX_CMD_PUT || cmd != OBEX_CMD_GET)
- return -EINVAL;
-
- return OBEX_CancelRequest(handle, 1);
-}
-
-int obex_close_transfer(obex_t *handle)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- int cmd;
-
- cmd = OBEX_ObjectGetCommand(handle, NULL);
- if (cmd != OBEX_CMD_PUT && cmd != OBEX_CMD_GET)
- return -EINVAL;
-
- context->close = 1;
-
- debug("OBEX_ResumeRequest");
- OBEX_ResumeRequest(handle);
-
- return 0;
-}
-
-int obex_get_response(obex_t *handle)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- int rsp;
-
- rsp = context->obex_rsp;
- context->obex_rsp = OBEX_RSP_SUCCESS;
-
- return rsp;
-}
-
-int obex_setpath(obex_t *handle, const char *path, int create)
-{
- obex_context_t *context = OBEX_GetUserData(handle);
- obex_object_t *object;
- obex_headerdata_t hd;
- obex_setpath_hdr_t sphdr;
- int ret;
- g_return_val_if_fail(context != NULL, -1);
-
- if (context->state != OBEX_CONNECTED)
- return -ENOTCONN;
-
- object = OBEX_ObjectNew(handle, OBEX_CMD_SETPATH);
- if (!object)
- return -ENOMEM;
-
- if (context->cid != CID_INVALID) {
- hd.bq4 = context->cid;
- OBEX_ObjectAddHeader(handle, object, OBEX_HDR_CONNECTION, hd, 4, 0);
- }
-
- memset(&sphdr, 0, sizeof(obex_setpath_hdr_t));
-
- if (strcmp(path, "..") == 0) {
- /* Can't create parent dir */
- if (create)
- return -EINVAL;
- sphdr.flags = 0x03;
- } else {
- int len, ulen = (strlen(path) + 1) * 2;
- uint8_t *unicode = malloc(ulen);
-
- if (!create)
- sphdr.flags = 0x02;
-
- if (!unicode) {
- OBEX_ObjectDelete(handle, object);
- return -ENOMEM;
- }
-
- len = OBEX_CharToUnicode(unicode, (uint8_t *) path, ulen);
- hd.bs = unicode;
-
- ret = OBEX_ObjectAddHeader(handle, object, OBEX_HDR_NAME, hd, len, 0);
- if (ret < 0) {
- OBEX_ObjectDelete(handle, object);
- free(unicode);
- return ret;
- }
-
- free(unicode);
- }
-
- OBEX_ObjectSetNonHdrData(object, (uint8_t *) &sphdr, 2);
-
- ret = obex_send_or_queue(handle, object);
- if (ret < 0)
- OBEX_ObjectDelete(handle, object);
-
- return ret;
-}
diff --git a/glib/obex-lowlevel.h b/glib/obex-lowlevel.h
deleted file mode 100644
index 594b6fa..0000000
--- a/glib/obex-lowlevel.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- \file glib/obex-lowlevel.h
- OpenOBEX glib bindings low level code.
- OpenOBEX library - Free implementation of the Object Exchange protocol.
-
- Copyright (C) 2005-2006 Marcel Holtmann <marcel@...>
-
- OpenOBEX is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with OpenOBEX. If not, see <http://www.gnu.org/>.
- */
-
-#include <openobex/obex.h>
-
-#ifdef OBEX_CLIENT
-#undef OBEX_CLIENT
-#endif
-
-typedef struct {
- void (*connect_cfm)(obex_t *handle, void *data);
- void (*disconn_ind)(obex_t *handle, void *data);
- void (*progress_ind)(obex_t *handle, void *data);
- void (*command_ind)(obex_t *handle, int event, void *data);
-} obex_callback_t;
-
-obex_t *obex_open(int fd, obex_callback_t *callback, void *data);
-void obex_close(obex_t *handle);
-void obex_poll(obex_t *handle);
-int obex_connect(obex_t *handle, const unsigned char *target, size_t size);
-int obex_disconnect(obex_t *handle);
-int obex_put(obex_t *handle, const char *type, const char *name, int size, time_t mtime);
-int obex_get(obex_t *handle, const char *type, const char *name);
-int obex_write(obex_t *handle, const char *buf, size_t count, size_t *bytes_written);
-int obex_read(obex_t *handle, char *buf, size_t count, size_t *bytes_read);
-int obex_abort(obex_t *handle);
-int obex_flush(obex_t *handle);
-int obex_close_transfer(obex_t *handle);
-int obex_get_response(obex_t *handle);
-void obex_do_callback(obex_t *handle);
-int obex_setpath(obex_t *handle, const char *path, int create);
-int obex_delete(obex_t *handle, const char *name);
diff --git a/glib/obex-marshal.list b/glib/obex-marshal.list
deleted file mode 100644
index 5b76282..0000000
--- a/glib/obex-marshal.list
+++ /dev/null
@@ -1 +0,0 @@
-VOID:VOID
diff --git a/glib/test-client.c b/glib/test-client.c
deleted file mode 100644
index ca93948..0000000
--- a/glib/test-client.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/**
- \file glib/test-client.c
- OpenOBEX glib bindings client test code.
- OpenOBEX library - Free implementation of the Object Exchange protocol.
-
- Copyright (C) 2005-2006 Marcel Holtmann <marcel@...>
-
- OpenOBEX 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 OpenOBEX. If not, see <http://www.gnu.org/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifdef _WIN32
-#include <windows.h>
-#include <io.h>
-#else
-#include <termios.h>
-#endif
-
-#include "obex-client.h"
-
-#define FTP_UUID (guchar *) \
- "\xF9\xEC\x7B\xC4\x95\x3C\x11\xD2\x98\x4E\x52\x54\x00\xDC\x9E\x09"
-
-static GMainLoop *mainloop;
-
-static void sig_term(int sig)
-{
- g_main_loop_quit(mainloop);
-}
-
-static int open_device(const char *device)
-{
- int fd;
-#ifdef _WIN32
- HANDLE h;
- DCB ti;
-
- h = CreateFile(device,
- GENERIC_READ|GENERIC_WRITE,
- 0,NULL,OPEN_EXISTING,0,NULL);
- if (h == INVALID_HANDLE_VALUE)
- return -1;
-
- //TODO: tcflush-equivalent function?
- ti.StopBits = ONESTOPBIT;
- ti.Parity = NOPARITY;
- ti.ByteSize = 8;
- ti.fNull = FALSE;
- SetCommState(h,&ti);
- fd = _open_osfhandle((intptr_t)h,0);
-#else
- struct termios ti;
-
- fd = open(device, O_RDWR | O_NOCTTY);
- if (fd < 0)
- return fd;
-
- tcflush(fd, TCIOFLUSH);
-
- cfmakeraw(&ti);
- tcsetattr(fd, TCSANOW, &ti);
-#endif
- return fd;
-}
-
-static void transfer(ObexClient *client, ObexClientCondition cond, gpointer data)
-{
- GError *gerr = NULL;
- int err, *io = data;
-
- if (cond & OBEX_CLIENT_COND_IN) {
- gchar buf[1024];
- gsize len;
-
- printf("OBEX_CLIENT_COND_IN\n");
-
- do {
- obex_client_read(client, buf, sizeof(buf), &len, &gerr);
-
- if (gerr != NULL) {
- printf("obex_client_read failed: %s\n", gerr->message);
- g_error_free(gerr);
- gerr = NULL;
- break;
- }
-
- printf("Data buffer with size %zd available\n", len);
-
- if (len > 0 && *io >= 0)
- err = write(*io, buf, len);
-
- } while (len == sizeof(buf));
- }
-
- if (cond & OBEX_CLIENT_COND_OUT) {
- char buf[10000];
- ssize_t actual;
-
- printf("OBEX_CLIENT_COND_OUT\n");
-
- if (*io < 0) {
- printf("No data to send!\n");
- return;
- }
-
- actual = read(*io, buf, sizeof(buf));
- if (actual == 0) {
- obex_client_close(client, &gerr);
- if (gerr != NULL) {
- printf("obex_client_close failed: %s\n",
- gerr->message);
- g_error_free(gerr);
- gerr = NULL;
- }
- close(*io);
- *io = -1;
- } else if (actual > 0) {
- gsize written;
-
- obex_client_write(client, buf, actual, &written, &gerr);
-
- if (gerr != NULL) {
- printf("writing data failed: %s\n", gerr->message);
- g_error_free(gerr);
- gerr = NULL;
- } else if (written < actual)
- printf("Only %zd/%zd bytes were accepted by obex_client_write!\n",
- written, actual);
- else
- obex_client_flush(client, NULL);
-
- }
- else
- fprintf(stderr, "read: %s\n", strerror(errno));
- }
-
- if (cond & OBEX_CLIENT_COND_DONE) {
- obex_client_get_error(client, &gerr);
- if (gerr != NULL) {
- printf("Operation failed: %s\n", gerr->message);
- g_error_free(gerr);
- gerr = NULL;
- }
- else
- printf("Operation completed with success\n");
- }
-
- if (cond & OBEX_CLIENT_COND_ERR)
- printf("Error in transfer\n");
-}
-
-int main(int argc, char *argv[])
-{
- ObexClient *client;
- int fd, io = -1;
-#ifndef _WIN32
- struct sigaction sa;
-#endif
-
- g_type_init();
-
- fd = open_device("/dev/rfcomm42");
- if (fd < 0) {
- perror("Can't open device");
- exit(EXIT_FAILURE);
- }
-
- mainloop = g_main_loop_new(NULL, FALSE);
-
- client = obex_client_new();
-
- obex_client_add_watch(client, 0, transfer, &io);
-
- obex_client_attach_fd(client, fd, NULL);
-
- if (argc > 1) {
- struct stat s;
-
- if (stat(argv[1], &s) < 0) {
- fprintf(stderr, "stat(%s): %s\n", argv[1], strerror(errno));
- return 1;
- }
-
- io = open(argv[1], O_RDONLY);
- if (io < 0) {
- fprintf(stderr, "open(%s): %s\n", argv[1], strerror(errno));
- return 1;
- }
-
- obex_client_put_object(client, NULL, argv[1], s.st_size, s.st_mtime, NULL);
- }
- else
- obex_client_get_object(client, NULL, "telecom/devinfo.txt", NULL);
-
-
-#ifndef _WIN32
- memset(&sa, 0, sizeof(sa));
- sa.sa_handler = sig_term;
- sigaction(SIGTERM, &sa, NULL);
- sigaction(SIGINT, &sa, NULL);
-#endif
-
- g_main_loop_run(mainloop);
-
- obex_client_destroy(client);
-
- if (io >= 0)
- close(io);
-
- close(fd);
-
- return 0;
-}
diff --git a/glib/test-lowlevel.c b/glib/test-lowlevel.c
deleted file mode 100644
index d0bf80b..0000000
--- a/glib/test-lowlevel.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- \file glib/test-lowlevel.c
- OpenOBEX glib bindings low level test code.
- OpenOBEX library - Free implementation of the Object Exchange protocol.
-
- Copyright (C) 2005-2006 Marcel Holtmann <marcel@...>
-
- OpenOBEX 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 OpenOBEX. If not, see <http://www.gnu.org/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#ifdef _WIN32
-#include <io.h>
-#define SOME_TTY "COM4"
-#else
-#include <termios.h>
-#define SOME_TTY "/dev/rfcomm42"
-#endif
-
-#include "obex-lowlevel.h"
-
-static int open_device(const char *device)
-{
- int fd;
-#ifdef _WIN32
- HANDLE h;
- DCB ti;
-
- h = CreateFile(device,
- GENERIC_READ|GENERIC_WRITE,
- 0,NULL,OPEN_EXISTING,0,NULL);
- if (h == INVALID_HANDLE_VALUE)
- return -1;
-
- //TODO: tcflush-equivalent function?
- ti.StopBits = ONESTOPBIT;
- ti.Parity = NOPARITY;
- ti.ByteSize = 8;
- ti.fNull = FALSE;
- SetCommState(h,&ti);
- fd = _open_osfhandle((intptr_t)h,0);
-#else
- struct termios ti;
-
- fd = open(device, O_RDWR | O_NOCTTY);
- if (fd < 0)
- return fd;
-
- tcflush(fd, TCIOFLUSH);
-
- cfmakeraw(&ti);
- tcsetattr(fd, TCSANOW, &ti);
-#endif
- return fd;
-}
-
-int main(int argc, char *argv[])
-{
- obex_t *handle;
- int fd;
-
- fd = open_device(SOME_TTY);
- if (fd < 0) {
- perror("Can't open device");
- exit(EXIT_FAILURE);
- }
-
- handle = obex_open(fd, NULL, NULL);
-
- obex_connect(handle, NULL, 0);
- obex_poll(handle);
-
- obex_get(handle, NULL, "telecom/devinfo.txt");
- obex_poll(handle);
-
- obex_disconnect(handle);
- obex_poll(handle);
-
- obex_close(handle);
-
- close(fd);
-
- return 0;
-}
diff --git a/openobex-glib.pc.in b/openobex-glib.pc.in
deleted file mode 100644
index 9ee3e87..0000000
--- a/openobex-glib.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: OpenOBEX
-Description: GLib integration of the Object Exchange protocol
-Version: @VERSION@
-Requires: glib-2.0
-Requires.private: openobex
-Libs: -L${libdir} -lopenobex-glib
-Cflags: -I${includedir}
--
1.7.5.4
|