Added lm-data-objects.[ch] for parameter objects
authorMikael Hallendal <micke@imendio.com>
Tue, 21 Oct 2008 15:47:01 +0200
changeset 535 65e61128ef18
parent 534 19327ccf6099
child 536 d2e9e1df6d82
Added lm-data-objects.[ch] for parameter objects
loudmouth/Makefile.am
loudmouth/lm-data-objects.c
loudmouth/lm-data-objects.h
--- a/loudmouth/Makefile.am	Tue Oct 21 02:38:48 2008 +0200
+++ b/loudmouth/Makefile.am	Tue Oct 21 15:47:01 2008 +0200
@@ -6,13 +6,13 @@
 TEST_DIR=$(top_srcdir)/
 
 AM_CPPFLAGS =                           \
-    -I.                                 \
-    -I$(top_srcdir)                     \
-    $(LOUDMOUTH_CFLAGS)                 \
-    $(LIBIDN_CFLAGS)                    \
-    -DLM_COMPILATION                    \
-    -DRUNTIME_ENDIAN                    \
-    $(NULL)
+	-I.                                 \
+	-I$(top_srcdir)                     \
+	$(LOUDMOUTH_CFLAGS)                 \
+	$(LIBIDN_CFLAGS)                    \
+	-DLM_COMPILATION                    \
+	-DRUNTIME_ENDIAN                    \
+	$(NULL)
 
 noinst_PROGRAMS = test-dns
 
@@ -33,92 +33,94 @@
 endif
 
 libloudmouth_1_la_SOURCES =             \
-    lm-connection.c                     \
-    lm-debug.c                          \
-    lm-debug.h                          \
-    lm-dummy.c                          \
-    lm-dummy.h                          \
-    lm-error.c                          \
-    lm-marshal.c                        \
-    lm-marshal.h                        \
-    lm-message.c                        \
-    lm-message-handler.c                \
-    lm-message-node.c                   \
-    lm-message-queue.c                  \
-    lm-message-queue.h                  \
-    lm-misc.c                           \
-    lm-misc.h                           \
-    lm-parser.c                         \
-    lm-parser.h                         \
-                                        \
-    asyncns.c                           \
-    asyncns.h                           \
-    lm-resolver.c                       \
-    lm-resolver.h                       \
-    lm-asyncns-resolver.c               \
-    lm-asyncns-resolver.h               \
-    lm-blocking-resolver.c              \
-    lm-blocking-resolver.h              \
-                                        \
-    lm-internals.h                      \
-    lm-sha.c                            \
-    lm-sha.h                            \
-    lm-ssl-generic.c                    \
-    lm-ssl-base.c                       \
-    lm-ssl-base.h                       \
-    lm-ssl-internals.h                  \
-    $(ssl_sources)                      \
-    lm-utils.c                          \
-    lm-proxy.c                          \
-    lm-sock.h                           \
-    lm-sock.c                           \
-    lm-old-socket.c                     \
-    lm-old-socket.h                     \
-                                        \
-    lm-socket.c                         \
-    lm-socket.h                         \
-    lm-tcp-socket.c                     \
-    lm-tcp-socket.h                     \
-                                        \
-    lm-feature-ping.c                   \
-    lm-feature-ping.h                   \
-                                        \
-    lm-sasl.c                           \
-    lm-sasl.h                           \
-    lm-simple-io.c                      \
-    lm-simple-io.h                      \
-    lm-xmpp-writer.c                    \
-    lm-xmpp-writer.h                    \
-    md5.c                               \
-    md5.h                               \
-    $(NULL)
+	lm-connection.c                     \
+	lm-debug.c                          \
+	lm-debug.h                          \
+	lm-data-objects.c					\
+	lm-data-objects.h					\
+	lm-dummy.c                          \
+	lm-dummy.h                          \
+	lm-error.c                          \
+	lm-marshal.c                        \
+	lm-marshal.h                        \
+	lm-message.c                        \
+	lm-message-handler.c                \
+	lm-message-node.c                   \
+	lm-message-queue.c                  \
+	lm-message-queue.h                  \
+	lm-misc.c                           \
+	lm-misc.h                           \
+	lm-parser.c                         \
+	lm-parser.h                         \
+										\
+	asyncns.c                           \
+	asyncns.h                           \
+	lm-resolver.c                       \
+	lm-resolver.h                       \
+	lm-asyncns-resolver.c               \
+	lm-asyncns-resolver.h               \
+	lm-blocking-resolver.c              \
+	lm-blocking-resolver.h              \
+										\
+	lm-internals.h                      \
+	lm-sha.c                            \
+	lm-sha.h                            \
+	lm-ssl-generic.c                    \
+	lm-ssl-base.c                       \
+	lm-ssl-base.h                       \
+	lm-ssl-internals.h                  \
+	$(ssl_sources)                      \
+	lm-utils.c                          \
+	lm-proxy.c                          \
+	lm-sock.h                           \
+	lm-sock.c                           \
+	lm-old-socket.c                     \
+	lm-old-socket.h                     \
+										\
+	lm-socket.c                         \
+	lm-socket.h                         \
+	lm-tcp-socket.c                     \
+	lm-tcp-socket.h                     \
+										\
+	lm-feature-ping.c                   \
+	lm-feature-ping.h                   \
+										\
+	lm-sasl.c                           \
+	lm-sasl.h                           \
+	lm-simple-io.c                      \
+	lm-simple-io.h                      \
+	lm-xmpp-writer.c                    \
+	lm-xmpp-writer.h                    \
+	md5.c                               \
+	md5.h                               \
+	$(NULL)
 
 libloudmouthinclude_HEADERS =           \
-    lm-connection.h                     \
-    lm-error.h                          \
-    lm-message.h                        \
-    lm-message-handler.h                \
-    lm-message-node.h                   \
-    lm-utils.h                          \
-    lm-proxy.h                          \
-    lm-ssl.h                            \
-    loudmouth.h                         \
-    $(NULL)
+	lm-connection.h                     \
+	lm-error.h                          \
+	lm-message.h                        \
+	lm-message-handler.h                \
+	lm-message-node.h                   \
+	lm-utils.h                          \
+	lm-proxy.h                          \
+	lm-ssl.h                            \
+	loudmouth.h                         \
+	$(NULL)
 
 libloudmouth_1_la_LIBADD =              \
-    $(LOUDMOUTH_LIBS)                   \
-    $(LIBIDN_LIBS)                      \
-    -lresolv
+	$(LOUDMOUTH_LIBS)                   \
+	$(LIBIDN_LIBS)                      \
+	-lresolv
 
 libloudmouth_1_la_LDFLAGS =                                 \
-    -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)    \
-    -export-symbols $(srcdir)/loudmouth.sym
+	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)    \
+	-export-symbols $(srcdir)/loudmouth.sym
 
 libloudmouthincludedir = $(includedir)/loudmouth-1.0/loudmouth
 
 MARSHAL=lm
 
 EXTRA_DIST +=                           \
-    lm-ssl-gnutls.c                     \
-    lm-ssl-openssl.c                    \
-    loudmouth.sym
+	lm-ssl-gnutls.c                     \
+	lm-ssl-openssl.c                    \
+	loudmouth.sym
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/lm-data-objects.c	Tue Oct 21 15:47:01 2008 +0200
@@ -0,0 +1,109 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2008 Imendio AB
+ *
+ * This program 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 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 this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include "lm-data-objects.h"
+
+static void auth_parameters_free (LmAuthParameters *params);
+
+struct LmAuthParameters {
+    gchar *username;
+    gchar *password;
+    gchar *resource;
+    
+    guint  ref_count;
+};
+
+static void
+auth_parameters_free (LmAuthParameters *params)
+{
+    g_free (params->username);
+    g_free (params->password);
+    g_free (params->resource);
+    
+    g_slice_free (LmAuthParameters, params);
+}
+
+LmAuthParameters *
+lm_auth_parameters_new (const gchar *username,
+                        const gchar *password,
+                        const gchar *resource)
+{
+    LmAuthParameters *params;
+    
+    params = g_slice_new0 (LmAuthParameters);
+    params->username = g_strdup (username);
+    params->password = g_strdup (password);
+    
+    if (resource) {
+        params->resource = g_strdup (resource);
+    }
+    
+    params->ref_count = 1;
+    
+    return params;
+}
+
+const gchar *
+lm_auth_parameters_get_username (LmAuthParameters *params)
+{
+    g_return_val_if_fail (params != NULL, NULL);
+    
+    return params->username;
+}
+
+const gchar *
+lm_auth_parameters_get_password (LmAuthParameters *params)
+{
+    g_return_val_if_fail (params != NULL, NULL);
+    
+    return params->password;
+}
+
+const gchar *
+lm_auth_parameters_get_resource (LmAuthParameters *params)
+{
+    g_return_val_if_fail (params != NULL, NULL);
+    
+    return params->resource;
+}
+
+LmAuthParameters *
+lm_auth_parameters_ref (LmAuthParameters *params)
+{
+    g_return_val_if_fail (params != NULL, NULL);
+    
+    params->ref_count++;
+    
+    return params;
+}
+
+void
+lm_auth_parameters_unref (LmAuthParameters *params)
+{
+    g_return_if_fail (params != NULL);
+    
+    params->ref_count--;
+
+    if (params->ref_count == 0) {
+        auth_parameters_free (params);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/lm-data-objects.h	Tue Oct 21 15:47:01 2008 +0200
@@ -0,0 +1,34 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2008 Imendio AB
+ *
+ * This program 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 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 this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+
+typedef struct LmAuthParameters LmAuthParameters;
+
+LmAuthParameters * lm_auth_parameters_new (const gchar *username,
+                                           const gchar *password,
+                                           const gchar *resource);
+
+const gchar *      lm_auth_parameters_get_username (LmAuthParameters *params);
+const gchar *      lm_auth_parameters_get_password (LmAuthParameters *params);
+const gchar *      lm_auth_parameters_get_resource (LmAuthParameters *params);
+
+LmAuthParameters * lm_auth_parameters_ref          (LmAuthParameters *params);
+void               lm_auth_parameters_unref        (LmAuthParameters *params);
\ No newline at end of file