Diff between 2e2d894dc9d192f319ad99d5e3e2fbef27f9fbe2 and e1892e63c2e74fa997a99cbc3a26a9c60d652025

Changed Files

File Additions Deletions Status
gobex/gobex.c +66 -0 added
gobex/gobex.h +35 -0 added

Full Patch

diff --git a/gobex/gobex.c b/gobex/gobex.c
new file mode 100644
index 0000000..8ae23b8
--- /dev/null
+++ b/gobex/gobex.c
@@ -0,0 +1,66 @@
+/*
+ *
+ *  OBEX library with GLib integration
+ *
+ *  Copyright (C) 2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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
+ *
+ */
+
+#include "gobex.h"
+
+struct _GObex {
+	gint ref_count;
+	GIOChannel *io;
+};
+
+GObex *g_obex_new(GIOChannel *io)
+{
+	GObex *obex;
+
+	if (io == NULL)
+		return NULL;
+
+	obex = g_new0(GObex, 1);
+
+	obex->io = io;
+	obex->ref_count = 1;
+
+	return obex;
+}
+
+GObex *g_obex_ref(GObex *obex)
+{
+	if (obex == NULL)
+		return NULL;
+
+	g_atomic_int_inc(&obex->ref_count);
+
+	return obex;
+}
+
+void g_obex_unref(GObex *obex)
+{
+	gboolean last_ref;
+
+	last_ref = g_atomic_int_dec_and_test(&obex->ref_count);
+
+	if (!last_ref)
+		return;
+
+	g_io_channel_unref(obex->io);
+
+	g_free(obex);
+}
diff --git a/gobex/gobex.h b/gobex/gobex.h
new file mode 100644
index 0000000..cdc7f77
--- /dev/null
+++ b/gobex/gobex.h
@@ -0,0 +1,35 @@
+/*
+ *
+ *  OBEX library with GLib integration
+ *
+ *  Copyright (C) 2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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
+ *
+ */
+
+#ifndef __GOBEX_H
+#define __GOBEX_H
+
+#include <stdint.h>
+#include <glib.h>
+
+typedef struct _GObex GObex;
+
+GObex *g_obex_new(GIOChannel *io);
+
+GObex *g_obex_ref(GObex *obex);
+void g_obex_unref(GObex *obex);
+
+#endif /* __GOBEX_H */