2004-05-28 Mikael Hallendal <micke@imendio.com>
* configure.in:
- Correctly inform whether SSL support was enabled or not.
2004-05-28 Mikael Hallendal <micke@imendio.com>
* src/lm-sha.c: Fixed lvalue cast that wasn't approved by newer GCC.
2004-05-10 Mikael Hallendal <micke@imendio.com>
* configure.in: Enable Mono on request
* mono/*:
- Updated the bindings some.
- Removed the autogenerated, it's such a small API that I figured
it was easier to wrap it manually.
2004-04-30 Mikael Hallendal <micke@imendio.com>
* loudmouth/lm-parser.c (parser_end_node_cb): Unref the message node.
2004-04-29 Mikael Hallendal <micke@imendio.com>
* examples/lm-change-password.c:
* examples/Makefile.am:
- Added a small tool to change the password on a jabber account.
2004-04-27 Mikael Hallendal <micke@imendio.com>
* Ignore on autogenerated files.
2004-04-20 Mikael Hallendal <micke@imendio.com>
* loudmouth/*.[ch]: Updated copyright information
2004-04-20 Mikael Hallendal <micke@imendio.com>
* configure.in: Now depend on Glib 2.4
* loudmouth/lm-queue.[ch]: Removed, use the new GQueue in Glib 2.4
* loudmouth/lm-connection.[ch]: Use GQueue instead of LmQueue.
2004-04-16 Mikael Hallendal <micke@imendio.com>
* configure.in: Added libtasn1 requirement
* loudmouth.spec.in: Added requirement on libtasn if built with SSL.
2004-04-04 Mikael Hallendal <micke@imendio.com>
* loudmouth/lm-sha.c: Commited compile fix from Sjoerd.
2004-03-20 Mikael Hallendal <micke@imendio.com>
* docs/reference/loudmouth-sections.txt:
- Added lm_connection_get_state
- Added LmConnectionState
--- a/ChangeLog Thu Mar 18 00:06:01 2004 +0000
+++ b/ChangeLog Mon Aug 02 23:57:41 2004 +0000
@@ -1,3 +1,69 @@
+2004-08-03 Mikael Hallendal <micke@imendio.com>
+
+ * Synced from SVN. Going to continue working on it here.
+
+2004-06-15 Mikael Hallendal <micke@imendio.com>
+
+ * README: Updated GnuTLS dependency.
+ * mono/*: Some work on the mono bindings.
+
+2004-05-28 Mikael Hallendal <micke@imendio.com>
+
+ * configure.in:
+ - Correctly inform whether SSL support was enabled or not.
+
+2004-05-28 Mikael Hallendal <micke@imendio.com>
+
+ * src/lm-sha.c: Fixed lvalue cast that wasn't approved by newer GCC.
+
+2004-05-10 Mikael Hallendal <micke@imendio.com>
+
+ * configure.in: Enable Mono on request
+
+ * mono/*:
+ - Updated the bindings some.
+ - Removed the autogenerated, it's such a small API that I figured
+ it was easier to wrap it manually.
+
+2004-04-30 Mikael Hallendal <micke@imendio.com>
+
+ * loudmouth/lm-parser.c (parser_end_node_cb): Unref the message node.
+
+2004-04-29 Mikael Hallendal <micke@imendio.com>
+
+ * examples/lm-change-password.c:
+ * examples/Makefile.am:
+ - Added a small tool to change the password on a jabber account.
+
+2004-04-27 Mikael Hallendal <micke@imendio.com>
+
+ * Ignore on autogenerated files.
+
+2004-04-20 Mikael Hallendal <micke@imendio.com>
+
+ * loudmouth/*.[ch]: Updated copyright information
+
+2004-04-20 Mikael Hallendal <micke@imendio.com>
+
+ * configure.in: Now depend on Glib 2.4
+ * loudmouth/lm-queue.[ch]: Removed, use the new GQueue in Glib 2.4
+ * loudmouth/lm-connection.[ch]: Use GQueue instead of LmQueue.
+
+2004-04-16 Mikael Hallendal <micke@imendio.com>
+
+ * configure.in: Added libtasn1 requirement
+ * loudmouth.spec.in: Added requirement on libtasn if built with SSL.
+
+2004-04-04 Mikael Hallendal <micke@imendio.com>
+
+ * loudmouth/lm-sha.c: Commited compile fix from Sjoerd.
+
+2004-03-20 Mikael Hallendal <micke@imendio.com>
+
+ * docs/reference/loudmouth-sections.txt:
+ - Added lm_connection_get_state
+ - Added LmConnectionState
+
2004-03-17 Mikael Hallendal <micke@imendio.com>
* Synced from SVN.
--- a/README Thu Mar 18 00:06:01 2004 +0000
+++ b/README Mon Aug 02 23:57:41 2004 +0000
@@ -21,7 +21,7 @@
ftp://ftp.gnome.org/pub/GNOME/sources/gtk-doc/1.0
If you want SSL-support you'll also need:
-GnuTLS >= 0.8.9 (might have to be built with '--with-included-libtasn1')
+GnuTLS >= 1.0.0might have to be built with '--with-included-libtasn1')
Building:
=========
--- a/configure.in Thu Mar 18 00:06:01 2004 +0000
+++ b/configure.in Mon Aug 02 23:57:41 2004 +0000
@@ -27,11 +27,13 @@
AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)
-GLIB2_REQUIRED=2.0.0
+GLIB2_REQUIRED=2.4.0
GNUTLS_REQUIRED=1.0.0
+LIBTASN1_REQUIRED=0.2.6
AC_SUBST(GLIB2_REQUIRED)
AC_SUBST(GNUTLS_REQUIRED)
+AC_SUBST(LIBTASN1_REQUIRED)
LM_CHECK_TIMEZONE
@@ -101,12 +103,14 @@
ac_ssl=yes
)
+enable_ssl=no
if test x$ac_ssl != xno; then
AM_PATH_LM_LIBGNUTLS($GNUTLS_REQUIRED, have_libgnutls=yes, have_libgnutls=no)
if test x$have_libgnutls = xyes; then
CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
LIBS="$LIBS $LIBGNUTLS_LIBS"
AC_DEFINE(HAVE_GNUTLS, 1, [whether to use GnuTSL support.])
+ enable_ssl=yes
else
echo "Couldn't find GnuTLS, disabling SSL support"
fi
@@ -150,27 +154,25 @@
dnl --------------
dnl | mono setup |--------------------------------------------
dnl --------------
-dnl AC_ARG_ENABLE(mono, [ --enable-mono build mono bindings [default=auto]], enable_mono="$enableval", enable_mono=auto)
+AC_ARG_ENABLE(mono, [ --enable-mono build mono bindings [default=auto]], enable_mono="$enableval", enable_mono=auto)
-dnl if test "x$enable_mono" != "xno"; then
-dnl PKG_CHECK_MODULES(,gtk-sharp,have_mono=yes,have_mono=no)
-dnl dnl
-dnl if test "x$have_mono" = "xyes"; then
-dnl AC_PATH_PROG(GAPI_FIXUP, gapi-fixup, no)
-dnl AC_PATH_PROG(GAPI_CODEGEN, gapi-codegen, no)
-dnl AC_PATH_PROG(MCS, mcs, no)
-dnl AC_PATH_PROG(MONO, mono, no)
-dnl fi
-dnl else
-dnl have_mono=no
-dnl fi
+if test "x$enable_mono" != "xno"; then
+ PKG_CHECK_MODULES(,gtk-sharp,have_mono=yes,have_mono=no)
+
+ if test "x$have_mono" = "xyes"; then
+ AC_PATH_PROG(MCS, mcs, no)
+ AC_PATH_PROG(MONO, mono, no)
+ fi
+else
+ have_mono=no
+fi
-dnl if test "x$enable_mono" = "xyes"; then
-dnl AC_MSG_CHECKING(for mono environment)
-dnl if test "x$have_mono" = "xno"; then
-dnl AC_MSG_ERROR([not found])
-dnl fi
-dnl fi
+if test "x$enable_mono" = "xyes"; then
+ AC_MSG_CHECKING(for mono environment)
+ if test "x$have_mono" = "xno"; then
+ AC_MSG_ERROR([not found])
+ fi
+fi
AM_CONDITIONAL(HAVE_MONO, test x$have_mono = xyes)
@@ -180,12 +182,11 @@
docs/reference/Makefile
loudmouth/Makefile
examples/Makefile
+mono/Makefile
+mono/loudmouth-sharp.pc
loudmouth-1.0.pc
loudmouth.spec])
-dnl mono/Makefile
-dnl mono/loudmouth/Makefile
-
dnl ==========================================================================
echo "
@@ -196,20 +197,20 @@
compiler: ${CC}
"
-dnl if test x$enable_mono = xyes ; then
-dnl echo \
-dnl " mcs: ${MCS}
-dnl mcsflags: ${MCSFLAGS}
-dnl "
-dnl else
-dnl echo \
-dnl " mcs: (not enabled)
-dnl "
-dnl fi
+if test x$enable_mono = xyes ; then
+echo \
+" mcs: ${MCS}
+ mcsflags: ${MCSFLAGS}
+"
+else
+echo \
+" mcs: (not enabled)
+"
+fi
echo \
-" Enable SSL ${ac_ssl}"
+" Enable SSL ${enable_ssl}"
echo \
" Enable Debug: ${enable_debug}
"
--- a/docs/reference/loudmouth-sections.txt Thu Mar 18 00:06:01 2004 +0000
+++ b/docs/reference/loudmouth-sections.txt Mon Aug 02 23:57:41 2004 +0000
@@ -7,6 +7,7 @@
LmHandlerResult
LmHandlerPriority
LmDisconnectReason
+LmConnectionState
LmResultFunction
LmDisconnectFunction
lm_connection_new
@@ -32,6 +33,7 @@
lm_connection_unregister_message_handler
lm_connection_set_disconnect_function
lm_connection_send_raw
+lm_connection_get_state
lm_connection_ref
lm_connection_unref
</SECTION>
--- a/docs/reference/tmpl/lm-connection.sgml Thu Mar 18 00:06:01 2004 +0000
+++ b/docs/reference/tmpl/lm-connection.sgml Mon Aug 02 23:57:41 2004 +0000
@@ -107,6 +107,17 @@
@LM_DISCONNECT_REASON_ERROR: A generic error somewhere in the transport layer.
@LM_DISCONNECT_REASON_UNKNOWN: An unknown error.
+<!-- ##### ENUM LmConnectionState ##### -->
+<para>
+
+</para>
+
+@LM_CONNECTION_STATE_DISCONNECTED:
+@LM_CONNECTION_STATE_CONNECTING:
+@LM_CONNECTION_STATE_CONNECTED:
+@LM_CONNECTION_STATE_AUTHENTICATING:
+@LM_CONNECTION_STATE_AUTHENTICATED:
+
<!-- ##### USER_FUNCTION LmResultFunction ##### -->
<para>
Callback for informing if an asynchronous operation was successful.
@@ -365,6 +376,15 @@
@Returns:
+<!-- ##### FUNCTION lm_connection_get_state ##### -->
+<para>
+
+</para>
+
+@connection:
+@Returns:
+
+
<!-- ##### FUNCTION lm_connection_ref ##### -->
<para>
--- a/docs/reference/tmpl/lm-proxy.sgml Thu Mar 18 00:06:01 2004 +0000
+++ b/docs/reference/tmpl/lm-proxy.sgml Mon Aug 02 23:57:41 2004 +0000
@@ -35,6 +35,7 @@
The type of the proxy.
</para>
+@LM_PROXY_TYPE_NONE:
@LM_PROXY_TYPE_HTTP: An HTTP proxy.
<!-- ##### FUNCTION lm_proxy_new ##### -->
--- a/examples/Makefile.am Thu Mar 18 00:06:01 2004 +0000
+++ b/examples/Makefile.am Mon Aug 02 23:57:41 2004 +0000
@@ -6,7 +6,8 @@
test-lm \
test-http-proxy \
lm-send-sync \
- lm-send-async
+ lm-send-async \
+ lm-change-password
test_lm_SOURCES = test-lm.c
@@ -16,6 +17,8 @@
lm_send_async_SOURCES = lm-send-async.c
+lm_change_password_SOURCES = lm-change-password.c
+
LDADD = \
$(LOUDMOUTH_LIBS) \
$(top_builddir)/loudmouth/libloudmouth-1.la
--- a/loudmouth.spec.in Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth.spec.in Mon Aug 02 23:57:41 2004 +0000
@@ -6,7 +6,7 @@
Summary: Loadmouth is a Jabber client written in C.
Name: %name
Version: %ver
-Release: imendio.1
+Release: imendio.2
Vendor: Imendio
URL: http://www.imendio.com/projects/loudmouth
Source0: %{name}-%{ver}.tar.gz
@@ -19,7 +19,9 @@
%if %{with_ssl}
Requires: gnutls >= @GNUTLS_REQUIRED@
+Requires: libtasn1 >= @LIBTASN1_REQUIRED@
BuildRequires: gnutls-devel >= @GNUTLS_REQUIRED@
+BuildRequires: libtasn1-devel >= @LIBTASN1_REQUIRED@
%endif
%description
--- a/loudmouth/Makefile.am Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/Makefile.am Mon Aug 02 23:57:41 2004 +0000
@@ -26,8 +26,6 @@
lm-ssl.c \
lm-utils.c \
lm-proxy.c \
- lm-queue.c \
- lm-queue.h \
$(NULL)
libloudmouthinclude_HEADERS = \
--- a/loudmouth/lm-connection.c Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-connection.c Mon Aug 02 23:57:41 2004 +0000
@@ -40,7 +40,6 @@
#include "lm-internals.h"
#include "lm-parser.h"
#include "lm-sha.h"
-#include "lm-queue.h"
#include "lm-connection.h"
#define IN_BUFFER_SIZE 1024
@@ -88,7 +87,7 @@
LmCallback *disconnect_cb;
- LmQueue *incoming_messages;
+ GQueue *incoming_messages;
GSource *incoming_source;
LmConnectionState state;
@@ -259,7 +258,7 @@
_lm_message_type_to_string (lm_message_get_type (m)),
lm_message_node_get_attribute (m->node, "from"));
- lm_queue_push_tail (connection->incoming_messages, m);
+ g_queue_push_tail (connection->incoming_messages, m);
}
gboolean
@@ -976,7 +975,7 @@
connection = ((LmIncomingSource *)source)->connection;
- return !lm_queue_is_empty (connection->incoming_messages);
+ return !g_queue_is_empty (connection->incoming_messages);
}
static gboolean
@@ -995,7 +994,7 @@
connection = ((LmIncomingSource *) source)->connection;
- m = (LmMessage *) lm_queue_pop_head (connection->incoming_messages);
+ m = (LmMessage *) g_queue_pop_head (connection->incoming_messages);
if (m) {
connection_handle_message (connection, m);
@@ -1059,7 +1058,7 @@
connection->ssl = NULL;
connection->proxy = NULL;
connection->disconnect_cb = NULL;
- connection->incoming_messages = lm_queue_new ();
+ connection->incoming_messages = g_queue_new ();
connection->cancel_open = FALSE;
connection->state = LM_CONNECTION_STATE_DISCONNECTED;
@@ -1668,20 +1667,21 @@
g_main_context_iteration (connection->context, TRUE);
- if (lm_queue_is_empty (connection->incoming_messages)) {
+ if (g_queue_is_empty (connection->incoming_messages)) {
continue;
}
- for (n = 0; n < connection->incoming_messages->length; n++) {
+ for (n = 0; n < g_queue_get_length (connection->incoming_messages); n++) {
LmMessage *m;
- m = lm_queue_peek_nth (connection->incoming_messages, n);
+ m = (LmMessage *) g_queue_peek_nth (connection->incoming_messages, n);
m_id = lm_message_node_get_attribute (m->node, "id");
if (m_id && strcmp (m_id, id) == 0) {
reply = m;
- lm_queue_remove_nth (connection->incoming_messages, n);
+ g_queue_pop_nth (connection->incoming_messages,
+ n);
break;
}
}
--- a/loudmouth/lm-connection.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-connection.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,7 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2003 Imendio HB
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-debug.c Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-debug.c Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-debug.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-debug.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-error.c Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-error.c Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-error.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-error.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-internals.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-internals.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-message-handler.c Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-message-handler.c Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-message-handler.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-message-handler.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,7 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2003 Imendio HB
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-message-node.c Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-message-node.c Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-message-node.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-message-node.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-message.c Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-message.c Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-message.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-message.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,7 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2003 Imendio HB
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-parser.c Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-parser.c Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
@@ -159,13 +159,16 @@
}
lm_message_unref (m);
- lm_message_node_unref (parser->cur_root);
+ lm_message_node_unref (parser->cur_root);
+
parser->cur_node = parser->cur_root = NULL;
} else {
LmMessageNode *tmp_node;
tmp_node = parser->cur_node;
parser->cur_node = parser->cur_node->parent;
+
+ lm_message_node_unref (tmp_node);
}
}
@@ -214,7 +217,7 @@
return NULL;
}
- parser->m_parser = g_new0 (GMarkupParser, 1);
+ parser->m_parser = g_new0 (GMarkupParser, 1);
if (!parser->m_parser) {
g_free (parser);
return NULL;
--- a/loudmouth/lm-parser.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-parser.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-proxy.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-proxy.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,7 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2004 Imendio HB
- * Copyright (C) 2004 Josh Beam <josh@3ddrome.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-queue.c Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-queue.c Mon Aug 02 23:57:41 2004 +0000
@@ -1,300 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * LmQueue: Double ended queue implementation, piggy backed on GList.
- * Copyright (C) 1998 Tim Janik
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/* This file is copied from gqueue.c in Glib */
-
-#include "config.h"
-
-#include "glib.h"
-#include "lm-queue.h"
-
-G_LOCK_DEFINE_STATIC (queue_memchunk);
-static GMemChunk *queue_memchunk = NULL;
-static GTrashStack *free_queue_nodes = NULL;
-
-LmQueue*
-lm_queue_new (void)
-{
- LmQueue *queue;
-
- G_LOCK (queue_memchunk);
- queue = g_trash_stack_pop (&free_queue_nodes);
-
- if (!queue)
- {
- if (!queue_memchunk)
- queue_memchunk = g_mem_chunk_new ("GLib LmQueue chunk",
- sizeof (GNode),
- sizeof (GNode) * 128,
- G_ALLOC_ONLY);
- queue = g_chunk_new (LmQueue, queue_memchunk);
- }
- G_UNLOCK (queue_memchunk);
-
- queue->head = NULL;
- queue->tail = NULL;
- queue->length = 0;
-
- return queue;
-}
-
-void
-lm_queue_free (LmQueue *queue)
-{
- g_return_if_fail (queue != NULL);
-
- g_list_free (queue->head);
-
-#ifdef ENABLE_GC_FRIENDLY
- queue->head = NULL;
- queue->tail = NULL;
-#endif /* ENABLE_GC_FRIENDLY */
-
- G_LOCK (queue_memchunk);
- g_trash_stack_push (&free_queue_nodes, queue);
- G_UNLOCK (queue_memchunk);
-}
-
-void
-lm_queue_push_head (LmQueue *queue,
- LmMessage *m)
-{
- g_return_if_fail (queue != NULL);
-
- queue->head = g_list_prepend (queue->head, m);
- if (!queue->tail)
- queue->tail = queue->head;
- queue->length++;
-}
-
-void
-lm_queue_push_head_link (LmQueue *queue,
- GList *link)
-{
- g_return_if_fail (queue != NULL);
- g_return_if_fail (link != NULL);
- g_return_if_fail (link->prev == NULL);
- g_return_if_fail (link->next == NULL);
-
- link->next = queue->head;
- if (queue->head)
- queue->head->prev = link;
- else
- queue->tail = link;
- queue->head = link;
- queue->length++;
-}
-
-void
-lm_queue_push_tail (LmQueue *queue,
- LmMessage *m)
-{
- g_return_if_fail (queue != NULL);
-
- queue->tail = g_list_append (queue->tail, m);
- if (queue->tail->next)
- queue->tail = queue->tail->next;
- else
- queue->head = queue->tail;
- queue->length++;
-}
-
-void
-lm_queue_push_tail_link (LmQueue *queue,
- GList *link)
-{
- g_return_if_fail (queue != NULL);
- g_return_if_fail (link != NULL);
- g_return_if_fail (link->prev == NULL);
- g_return_if_fail (link->next == NULL);
-
- link->prev = queue->tail;
- if (queue->tail)
- queue->tail->next = link;
- else
- queue->head = link;
- queue->tail = link;
- queue->length++;
-}
-
-LmMessage *
-lm_queue_pop_head (LmQueue *queue)
-{
- g_return_val_if_fail (queue != NULL, NULL);
-
- if (queue->head)
- {
- GList *node = queue->head;
- gpointer data = node->data;
-
- queue->head = node->next;
- if (queue->head)
- queue->head->prev = NULL;
- else
- queue->tail = NULL;
- g_list_free_1 (node);
- queue->length--;
-
- return (LmMessage *) data;
- }
-
- return NULL;
-}
-
-GList*
-lm_queue_pop_head_link (LmQueue *queue)
-{
- g_return_val_if_fail (queue != NULL, NULL);
-
- if (queue->head)
- {
- GList *node = queue->head;
-
- queue->head = node->next;
- if (queue->head)
- {
- queue->head->prev = NULL;
- node->next = NULL;
- }
- else
- queue->tail = NULL;
- queue->length--;
-
- return node;
- }
-
- return NULL;
-}
-
-LmMessage *
-lm_queue_pop_tail (LmQueue *queue)
-{
- g_return_val_if_fail (queue != NULL, NULL);
-
- if (queue->tail)
- {
- GList *node = queue->tail;
- gpointer data = node->data;
-
- queue->tail = node->prev;
- if (queue->tail)
- queue->tail->next = NULL;
- else
- queue->head = NULL;
- queue->length--;
- g_list_free_1 (node);
-
- return (LmMessage *) data;
- }
-
- return NULL;
-}
-
-GList*
-lm_queue_pop_tail_link (LmQueue *queue)
-{
- g_return_val_if_fail (queue != NULL, NULL);
-
- if (queue->tail)
- {
- GList *node = queue->tail;
-
- queue->tail = node->prev;
- if (queue->tail)
- {
- queue->tail->next = NULL;
- node->prev = NULL;
- }
- else
- queue->head = NULL;
- queue->length--;
-
- return node;
- }
-
- return NULL;
-}
-
-gboolean
-lm_queue_is_empty (LmQueue *queue)
-{
- g_return_val_if_fail (queue != NULL, TRUE);
-
- return queue->head == NULL;
-}
-
-LmMessage *
-lm_queue_peek_head (LmQueue *queue)
-{
- g_return_val_if_fail (queue != NULL, NULL);
-
- return (LmMessage *) queue->head ? queue->head->data : NULL;
-}
-
-LmMessage *
-lm_queue_peek_tail (LmQueue *queue)
-{
- g_return_val_if_fail (queue != NULL, NULL);
-
- return (LmMessage *) queue->tail ? queue->tail->data : NULL;
-}
-
-LmMessage *
-lm_queue_peek_nth (LmQueue *queue, int n)
-{
- gpointer data;
-
- g_return_val_if_fail (queue != NULL, NULL);
- g_return_val_if_fail (n >= 0, NULL);
-
- data = g_list_nth_data (queue->head, n);
-
- return (LmMessage *) data;
-}
-
-LmMessage *
-lm_queue_remove_nth (LmQueue *queue, int n)
-{
- GList *link;
- gpointer data;
-
- g_return_val_if_fail (queue != NULL, NULL);
- g_return_val_if_fail (n >= 0, NULL);
- g_return_val_if_fail (n < queue->length, NULL);
-
- if (n == 0) {
- return lm_queue_pop_head (queue);
- }
-
- if (n == queue->length - 1) {
- return lm_queue_pop_tail (queue);
- }
-
- link = g_list_nth (queue->head, n);
- data = link->data;
-
- queue->head = g_list_delete_link (queue->head, link);
- queue->length--;
-
- return (LmMessage *) data;
-}
-
--- a/loudmouth/lm-queue.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-queue.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,75 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/* This file is copied from gqueue.h in Glib */
-
-#ifndef __lm_queue_H__
-#define __lm_queue_H__
-
-#include <glib/glist.h>
-
-#include "lm-message.h"
-
-G_BEGIN_DECLS
-
-typedef struct _LmQueue LmQueue;
-
-struct _LmQueue
-{
- GList *head;
- GList *tail;
- guint length;
-};
-
-/* Queues
- */
-LmQueue* lm_queue_new (void);
-void lm_queue_free (LmQueue *queue);
-void lm_queue_push_head (LmQueue *queue,
- LmMessage *message);
-void lm_queue_push_tail (LmQueue *queue,
- LmMessage *message);
-LmMessage * lm_queue_pop_head (LmQueue *queue);
-LmMessage * lm_queue_pop_tail (LmQueue *queue);
-gboolean lm_queue_is_empty (LmQueue *queue);
-LmMessage * lm_queue_peek_head (LmQueue *queue);
-LmMessage * lm_queue_peek_tail (LmQueue *queue);
-void lm_queue_push_head_link (LmQueue *queue,
- GList *link_);
-void lm_queue_push_tail_link (LmQueue *queue,
- GList *link_);
-
-LmMessage * lm_queue_peek_nth (LmQueue *queue,
- int n);
-LmMessage * lm_queue_remove_nth (LmQueue *queue,
- int n);
-
-GList* lm_queue_pop_head_link (LmQueue *queue);
-GList* lm_queue_pop_tail_link (LmQueue *queue);
-
-G_END_DECLS
-
-#endif /* __lm_queue_H__ */
--- a/loudmouth/lm-sha.c Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-sha.c Mon Aug 02 23:57:41 2004 +0000
@@ -69,7 +69,7 @@
#endif
void SHA1Init (SHA1Context *sc);
-void SHA1Update (SHA1Context *sc, const void *data, guint32 len);
+void SHA1Update (SHA1Context *sc, const void *udata, guint32 len);
void SHA1Final (SHA1Context *sc, guint8 hash[SHA1_HASH_SIZE]);
#ifdef __cplusplus
@@ -492,11 +492,12 @@
}
void
-SHA1Update (SHA1Context *sc, const void *data, guint32 len)
+SHA1Update (SHA1Context *sc, const void *udata, guint32 len)
{
guint32 bufferBytesLeft;
guint32 bytesToCopy;
int needBurn = 0;
+ guint8 *data = (guint8 *)udata;
#ifdef SHA1_FAST_COPY
if (sc->bufferLength) {
@@ -511,7 +512,7 @@
sc->totalLength += bytesToCopy * 8L;
sc->bufferLength += bytesToCopy;
- ((guint8 *) data) += bytesToCopy;
+ data += bytesToCopy;
len -= bytesToCopy;
if (sc->bufferLength == 64L) {
@@ -527,7 +528,7 @@
SHA1Guts (sc, data);
needBurn = 1;
- ((guint8 *) data) += 64L;
+ data += 64L;
len -= 64L;
}
@@ -551,7 +552,7 @@
sc->totalLength += bytesToCopy * 8L;
sc->bufferLength += bytesToCopy;
- ((guint8 *) data) += bytesToCopy;
+ data += bytesToCopy;
len -= bytesToCopy;
if (sc->bufferLength == 64L) {
--- a/loudmouth/lm-sha.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-sha.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-ssl.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-ssl.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,7 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2003-2004 Imendio HB
- * Copyright (C) 2003-2004 Sjoerd Simons <sjoerd@luon.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-utils.c Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-utils.c Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/lm-utils.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/lm-utils.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/loudmouth/loudmouth.h Thu Mar 18 00:06:01 2004 +0000
+++ b/loudmouth/loudmouth.h Mon Aug 02 23:57:41 2004 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2003 Imendio HB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
--- a/mono/Connection.cs Thu Mar 18 00:06:01 2004 +0000
+++ b/mono/Connection.cs Mon Aug 02 23:57:41 2004 +0000
@@ -1,9 +1,18 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Collections;
+
namespace Loudmouth {
- using System;
- using System.Runtime.InteropServices;
- using System.Collections;
+ public delegate void ElementHandler (Element element);
+ public delegate void MessageHandler (Message message);
+ public delegate void PresenceHandler (Presence presence);
+ public delegate void IQHandler (IQ iq);
+ public delegate void ResultFunction (bool success);
+ public delegate void DisconnectionFunction ();
- public class Connection : Object {
+ public class Connection {
+ private IntPtr _obj;
+
private Hashtable _asyncHandlers;
private ResultFunction result_func;
@@ -25,12 +34,9 @@
}
}
- public bool UseSSL {
+ public bool IsOpen {
get {
- return lm_connection_get_use_ssl(this._obj);
- }
- set {
- lm_connection_set_use_ssl(this._obj, value);
+ return lm_connection_is_open (this._obj);
}
}
@@ -39,24 +45,25 @@
return lm_connection_is_authenticated(this._obj);
}
}
-
+
private delegate int _ElementHandler (IntPtr h, IntPtr con, IntPtr elementObj, IntPtr ignored);
private delegate void _ResultFunction (IntPtr con, bool success, IntPtr ptr);
private delegate void _DisconnectFunction (IntPtr con, int reason, IntPtr ignored);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern int lm_message_get_type (IntPtr obj);
- private int HandleElement (IntPtr h, IntPtr con, IntPtr elementObj, IntPtr ignored) {
- switch (lm_message_get_type(elementObj)) {
- case (int)Element.ElementType.MESSAGE:
- IncomingMessage(new Message(elementObj));
+ private int HandleElement (IntPtr h, IntPtr con, IntPtr elementObj, IntPtr ignored)
+ {
+ switch (lm_message_get_type (elementObj)) {
+ case (int) Element.ElementType.MESSAGE:
+ EmitIncomingMessage (new Message (elementObj));
break;
- case (int)Element.ElementType.PRESENCE:
- IncomingPresence(new Presence(elementObj));
+ case (int) Element.ElementType.PRESENCE:
+ EmitIncomingPresence (new Presence (elementObj));
break;
- case (int)Element.ElementType.IQ:
- IncomingIQ(new IQ(elementObj));
+ case (int) Element.ElementType.IQ:
+ EmitIncomingIQ (new IQ (elementObj));
break;
}
@@ -78,63 +85,83 @@
func(success);
}
- public delegate void ElementHandler (Element element);
- public delegate void MessageHandler (Message message);
- public delegate void PresenceHandler (Presence presence);
- public delegate void IQHandler (IQ iq);
- public delegate void ResultFunction (bool success);
- public delegate void DisconnectionFunction (int reason);
-
public event MessageHandler IncomingMessage;
public event PresenceHandler IncomingPresence;
public event IQHandler IncomingIQ;
public event DisconnectionFunction Disconnected;
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern IntPtr lm_connection_new (string name);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern bool lm_connection_open (IntPtr obj, _ResultFunction func, IntPtr ptr, IntPtr ignored2, IntPtr errPtr);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern bool lm_connection_open_and_block (IntPtr obj, IntPtr errPtr);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern bool lm_connection_close (IntPtr obj, IntPtr errPtr);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern bool lm_connection_authenticate (IntPtr obj, string username, string password, string resource, _ResultFunction func, IntPtr ignored, IntPtr ignored2, IntPtr errPtr);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern bool lm_connection_authenticate_and_block (IntPtr obj, string username, string password, string resource, IntPtr errPtr);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
+ private static extern bool lm_connection_is_open (IntPtr obj);
+ [DllImport ("libloudmouth-1.so")]
private static extern bool lm_connection_is_authenticated (IntPtr obj);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern void lm_connection_set_server (IntPtr obj, string server);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern string lm_connection_get_server (IntPtr obj);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern void lm_connection_set_port (IntPtr obj, uint port);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern uint lm_connection_get_port (IntPtr obj);
- [DllImport ("libloudmouth.so")]
- private static extern void lm_connection_set_use_ssl (IntPtr obj, bool use_ssl);
- [DllImport ("libloudmouth.so")]
- private static extern bool lm_connection_get_use_ssl (IntPtr obj);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
+ private static extern void lm_connection_set_ssl (IntPtr obj, IntPtr ssl);
+ [DllImport ("libloudmouth-1.so")]
+ private static extern IntPtr lm_connection_get_ssl (IntPtr obj);
+ [DllImport ("libloudmouth-1.so")]
+ private static extern void lm_connection_set_proxy (IntPtr obj, IntPtr proxy);
+ [DllImport ("libloudmouth-1.so")]
+ private static extern IntPtr lm_connection_get_proxy (IntPtr obj);
+ [DllImport ("libloudmouth-1.so")]
private static extern bool lm_connection_send (IntPtr obj, IntPtr message, IntPtr errPtr);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern bool lm_connection_send_with_reply (IntPtr obj, IntPtr message, IntPtr handler, IntPtr errPtr);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern IntPtr lm_connection_send_with_reply_and_block (IntPtr obj, IntPtr message, IntPtr errPtr);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern void lm_connection_register_message_handler (IntPtr obj, IntPtr handler, int type, int priority);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
+ private static extern void lm_connection_set_disconnect_function (IntPtr obj, _DisconnectFunction func, IntPtr u, IntPtr n);
+ [DllImport ("libloudmouth-1.so")]
+ private static extern bool lm_connection_send_raw (IntPtr obj, string msg, IntPtr errPtr);
+ [DllImport ("libloudmouth-1.so")]
+ private static extern void lm_connection_unref (IntPtr obj);
+ [DllImport ("libloudmouth-1.so")]
private static extern IntPtr lm_message_handler_new (_ElementHandler handler, IntPtr u, IntPtr n);
- public Connection (string server) {
- this._obj = lm_connection_new(server);
- this._asyncHandlers = new Hashtable();
- IntPtr h = lm_message_handler_new(new _ElementHandler (this.HandleElement), IntPtr.Zero, IntPtr.Zero);
- lm_connection_register_message_handler(this._obj, h, (int)Element.ElementType.MESSAGE, 1);
- h = lm_message_handler_new(new _ElementHandler(this.HandleElement), IntPtr.Zero, IntPtr.Zero);
- lm_connection_register_message_handler(this._obj, h, (int)Element.ElementType.PRESENCE, 1);
- h = lm_message_handler_new(new _ElementHandler(this.HandleElement), IntPtr.Zero, IntPtr.Zero);
- lm_connection_register_message_handler(this._obj, h, (int)Element.ElementType.IQ, 1);
+
+ private void SetupConnection (string server, uint port)
+ {
+ this._obj = lm_connection_new (server);
+ this.Port = port;
+
+ this._asyncHandlers = new Hashtable ();
+
+ IntPtr h = lm_message_handler_new (new _ElementHandler (this.HandleElement), IntPtr.Zero, IntPtr.Zero);
+ lm_connection_register_message_handler (this._obj, h, (int)Element.ElementType.MESSAGE, 1);
+ h = lm_message_handler_new (new _ElementHandler(this.HandleElement), IntPtr.Zero, IntPtr.Zero);
+ lm_connection_register_message_handler (this._obj, h, (int)Element.ElementType.PRESENCE, 1);
+ h = lm_message_handler_new (new _ElementHandler (this.HandleElement), IntPtr.Zero, IntPtr.Zero);
+ lm_connection_register_message_handler (this._obj, h, (int)Element.ElementType.IQ, 1);
+ }
+
+ public Connection (string server)
+ {
+ SetupConnection (server, 5222);
+ }
+
+ public Connection (string server, uint port)
+ {
+ SetupConnection (server, port);
}
public void Open (ResultFunction func) {
@@ -189,6 +216,35 @@
}
public void SendRaw (string raw) {
+ lm_connection_send_raw (this._obj, raw, IntPtr.Zero);
+ }
+
+ private void EmitIncomingMessage (Message m)
+ {
+ if (IncomingMessage != null) {
+ IncomingMessage (m);
+ }
+ }
+
+ private void EmitIncomingPresence (Presence p)
+ {
+ if (IncomingPresence != null) {
+ IncomingPresence (p);
+ }
+ }
+
+ private void EmitIncomingIQ (IQ iq)
+ {
+ if (IncomingIQ != null) {
+ IncomingIQ (iq);
+ }
+ }
+
+ private void EmitDisconnected ()
+ {
+ if (Disconnected != null) {
+ Disconnected ();
+ }
}
}
}
--- a/mono/ElementNode.cs Thu Mar 18 00:06:01 2004 +0000
+++ b/mono/ElementNode.cs Mon Aug 02 23:57:41 2004 +0000
@@ -1,8 +1,11 @@
+using System;
+using System.Runtime.InteropServices;
+
namespace Loudmouth {
- using System;
- using System.Runtime.InteropServices;
- public class ElementNode : Object {
+ public class ElementNode {
+ private IntPtr _obj;
+
public string Value {
get {
return lm_message_node_get_value (this._obj);
@@ -12,22 +15,20 @@
}
}
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern string lm_message_node_get_value (IntPtr obj);
-
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern void lm_message_node_set_value (IntPtr obj, string value);
-
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern IntPtr lm_message_node_add_child (IntPtr obj, string name, string value);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern void lm_message_node_set_attribute (IntPtr obj, string name, string value);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern string lm_message_node_get_attribute (IntPtr obj, string name);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern IntPtr lm_message_node_get_child (IntPtr obj, string name);
- [DllImport ("libloudmouth.so")]
+ [DllImport ("libloudmouth-1.so")]
private static extern IntPtr lm_message_node_find_child (IntPtr obj, string name);
public ElementNode (IntPtr obj) {
--- a/mono/Elements.cs Thu Mar 18 00:06:01 2004 +0000
+++ b/mono/Elements.cs Mon Aug 02 23:57:41 2004 +0000
@@ -1,7 +1,11 @@
+using System;
+using System.Runtime.InteropServices;
+
namespace Loudmouth {
- using System;
- using System.Runtime.InteropServices;
- public class Element : Object {
+
+ public class Element {
+ protected IntPtr _obj;
+
public enum ElementType {
MESSAGE,
PRESENCE,
@@ -12,11 +16,12 @@
}
public enum ElementSubType {
- NOT_SET = -1,
- CHAT = 0,
+ NOT_SET = -10,
+ AVAILABLE = -1,
+ NORMAL = 0,
+ CHAT,
GROUPCHAT,
HEADLINE,
- AVAILABLE,
UNAVAILABLE,
PROBE,
SUBSCRIBE,
@@ -35,45 +40,9 @@
}
}
- private Element () {}
-
- protected Element (IntPtr obj) : base (obj) {
- }
-
- [DllImport ("libloudmouth.so")]
- private static extern int lm_message_get_type (IntPtr obj);
-
- [DllImport ("libloudmouth.so")]
- private static extern IntPtr lm_message_new (string to, ElementType type);
-
- protected Element (string to, ElementType type) {
- _obj = lm_message_new (to, type);
- }
-
- [DllImport ("libloudmouth.so")]
- private static extern IntPtr lm_message_new_with_sub_type (string to, ElementType type, ElementSubType sub);
-
- protected Element (string to, ElementType type, ElementSubType sub) {
- _obj = lm_message_new_with_sub_type(to, type, sub);
- }
-
- [DllImport ("libloudmouth.so")]
- private static extern ElementSubType lm_message_get_sub_type (IntPtr obj);
-
- protected ElementSubType GetElementSubType () {
- return lm_message_get_sub_type(this._obj);
- }
-
- [DllImport ("libloudmouth.so")]
- private static extern IntPtr lm_message_get_node (IntPtr obj);
-
- public ElementNode GetNode () {
- return new ElementNode(lm_message_get_node (this._obj));
- }
-
public string this[string data] {
get {
- ElementNode node = this.GetNode();
+ ElementNode node = this.GetNode ();
return node[data];
}
set {
@@ -82,11 +51,43 @@
}
}
- public override string ToString () {
+ protected Element (IntPtr obj)
+ {
+ this._obj = obj;
+ }
+
+ protected Element (string to, ElementType type)
+ {
+ _obj = lm_message_new (to, type);
+ }
+
+ protected Element (string to, ElementType type, ElementSubType sub)
+ {
+ _obj = lm_message_new_with_sub_type (to, type, sub);
+ }
+
+ protected ElementSubType GetElementSubType ()
+ {
+ return lm_message_get_sub_type (this._obj);
+ }
+
+ public ElementNode GetNode ()
+ {
+ return new ElementNode(lm_message_get_node (this._obj));
+ }
+
+ public IntPtr GetObject ()
+ {
+ return _obj;
+ }
+
+ public override string ToString ()
+ {
return "<Element: " + this.Kind + ":" + this.GetElementSubType() + ">";
}
- public static Element CreateElement (IntPtr obj) {
+ public static Element CreateElement (IntPtr obj)
+ {
switch (lm_message_get_type(obj)) {
case (int)Element.ElementType.MESSAGE:
return new Message(obj);
@@ -97,7 +98,18 @@
}
return null;
}
- }
+
+ [DllImport ("libloudmouth-1.so")]
+ private static extern int lm_message_get_type (IntPtr obj);
+ [DllImport ("libloudmouth-1.so")]
+ private static extern IntPtr lm_message_new (string to, ElementType type);
+ [DllImport ("libloudmouth-1.so")]
+ private static extern IntPtr lm_message_new_with_sub_type (string to, ElementType type, ElementSubType sub);
+ [DllImport ("libloudmouth-1.so")]
+ private static extern ElementSubType lm_message_get_sub_type (IntPtr obj);
+ [DllImport ("libloudmouth-1.so")]
+ private static extern IntPtr lm_message_get_node (IntPtr obj);
+ }
public class Message : Element {
public MessageType Type {
@@ -125,16 +137,16 @@
HEADLINE = Element.ElementSubType.HEADLINE
}
- public Message (IntPtr obj) :
- base (obj) {
- }
+ public Message (IntPtr obj) : base (obj)
+ {
+ }
- public Message (string to) :
- base (to, Element.ElementType.MESSAGE, Element.ElementSubType.NOT_SET) {
- }
+ public Message (string to) : base (to, Element.ElementType.MESSAGE, Element.ElementSubType.NOT_SET)
+ {
+ }
- public Message (string to, MessageType type) :
- base (to, Element.ElementType.MESSAGE, (Element.ElementSubType) type) {
+ public Message (string to, MessageType type) : base (to, Element.ElementType.MESSAGE, (Element.ElementSubType) type)
+ {
}
}
@@ -149,19 +161,24 @@
UNSUBSCRIBED = Element.ElementSubType.UNSUBSCRIBED,
}
- public Presence (IntPtr obj) : base (obj) {
+ public Presence (IntPtr obj) : base (obj)
+ {
}
- public Presence () : base (null, Element.ElementType.PRESENCE, Element.ElementSubType.AVAILABLE) {}
+ public Presence () : base (null, Element.ElementType.PRESENCE, Element.ElementSubType.AVAILABLE)
+ {
+ }
- public Presence (PresenceType type) : base (null, Element.ElementType.PRESENCE, (Element.ElementSubType) type) {}
-
- public Presence (string to) :
- base (to, Element.ElementType.PRESENCE) {
+ public Presence (PresenceType type) : base (null, Element.ElementType.PRESENCE, (Element.ElementSubType) type)
+ {
}
- public Presence (string to, PresenceType type) :
- base (to, Element.ElementType.PRESENCE, (Element.ElementSubType) type) {
+ public Presence (string to) : base (to, Element.ElementType.PRESENCE)
+ {
+ }
+
+ public Presence (string to, PresenceType type) : base (to, Element.ElementType.PRESENCE, (Element.ElementSubType) type)
+ {
}
}
@@ -191,19 +208,24 @@
RESULT = Element.ElementSubType.RESULT
}
- public IQ (IntPtr obj) : base (obj) {
+ public IQ (IntPtr obj) : base (obj)
+ {
}
- public IQ () :
- base (null, Element.ElementType.IQ, Element.ElementSubType.GET) {}
+ public IQ () : base (null, Element.ElementType.IQ, Element.ElementSubType.GET)
+ {
+ }
- public IQ (string to) :
- base (to, Element.ElementType.IQ, Element.ElementSubType.GET) {}
+ public IQ (string to) : base (to, Element.ElementType.IQ, Element.ElementSubType.GET)
+ {
+ }
+
+ public IQ (string to, IQType type) : base (to, Element.ElementType.IQ, (Element.ElementSubType) type)
+ {
+ }
- public IQ (string to, IQType type) :
- base (to, Element.ElementType.IQ, (Element.ElementSubType) type) {}
-
- public IQ (IQType type) :
- base (null, Element.ElementType.IQ, (Element.ElementSubType) type) {}
+ public IQ (IQType type) : base (null, Element.ElementType.IQ, (Element.ElementSubType) type)
+ {
+ }
}
}
--- a/mono/Makefile.am Thu Mar 18 00:06:01 2004 +0000
+++ b/mono/Makefile.am Mon Aug 02 23:57:41 2004 +0000
@@ -1,2 +1,29 @@
-SUBDIRS = loudmouth
+LOUDMOUTH_CSFILES = \
+ Account.cs \
+ Connection.cs \
+ Elements.cs \
+ ElementNode.cs \
+ Object.cs
+
+loudmouthlibdir = $(prefix)/lib
+
+loudmouth-sharp.dll: $(LOUDMOUTH_CSFILES)
+ $(MCS) /target:library $(LOUDMOUTH_CSFILES) -o loudmouth-sharp.dll
+
+all: loudmouth-sharp.dll
+install-data-local: loudmouth-sharp.dll
+ $(mkinstalldirs) $(DESTDIR)$(loudmouthlibdir)
+ $(INSTALL_DATA) loudmouth-sharp.dll $(DESTDIR)$(loudmouthlibdir)/loudmouth-sharp.dll
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = loudmouth-sharp.pc
+
+EXTRA_DIST = \
+ $(LOUDMOUTH_CSFILES) \
+ loudmouth-sharp.pc.in
+
+CLEANFILES = loudmouth-sharp.dll
+
+
+