summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-04-19 15:33:16 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-05-09 12:14:11 +0200
commit5abd182c71d56445f303c04338a1e0a2167832de (patch)
tree4160e4443a3671157fd6060df2ff2d7921ab8f06
parent3320966b2adc98407e488c34e6e7342830ec11c7 (diff)
downloadtelepathy-glib-5abd182c71d56445f303c04338a1e0a2167832de.tar.gz
add TpTLSCertificateRejection
-rw-r--r--docs/reference/telepathy-glib-docs.sgml1
-rw-r--r--docs/reference/telepathy-glib-sections.txt22
-rw-r--r--telepathy-glib/Makefile.am3
-rw-r--r--telepathy-glib/introspection.am1
-rw-r--r--telepathy-glib/tls-certificate-rejection-internal.h30
-rw-r--r--telepathy-glib/tls-certificate-rejection.c309
-rw-r--r--telepathy-glib/tls-certificate-rejection.h81
7 files changed, 447 insertions, 0 deletions
diff --git a/docs/reference/telepathy-glib-docs.sgml b/docs/reference/telepathy-glib-docs.sgml
index d010d40b9..6e4d97d75 100644
--- a/docs/reference/telepathy-glib-docs.sgml
+++ b/docs/reference/telepathy-glib-docs.sgml
@@ -103,6 +103,7 @@
<xi:include href="xml/room-list.xml"/>
<xi:include href="xml/room-info.xml"/>
<xi:include href="xml/tls-certificate.xml"/>
+ <xi:include href="xml/tls-certificate-rejection.xml"/>
</chapter>
<chapter id="ch-service-dbus">
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 89895df56..47e4b2210 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -7363,3 +7363,25 @@ TpTLSCertificateClassPrivate
TpTLSCertificatePrivate
tp_tls_certificate_get_type
</SECTION>
+
+<SECTION>
+<FILE>tls-certificate-rejection</FILE>
+<INCLUDE>telepathy-glib/telepathy-glib.h</INCLUDE>
+<TITLE>TpTLSCertificateRejection</TITLE>
+TpTLSCertificateRejection
+tp_tls_certificate_rejection_get_dbus_error
+tp_tls_certificate_rejection_get_details
+tp_tls_certificate_rejection_get_error
+tp_tls_certificate_rejection_get_reason
+<SUBSECTION Standard>
+TP_IS_TLS_CERTIFICATE_REJECTION
+TP_IS_TLS_CERTIFICATE_REJECTION_CLASS
+TP_TLS_CERTIFICATE_REJECTION
+TP_TLS_CERTIFICATE_REJECTION_CLASS
+TP_TLS_CERTIFICATE_REJECTION_GET_CLASS
+TP_TYPE_TLS_CERTIFICATE_REJECTION
+TpTLSCertificateRejectionClass
+tp_tls_certificate_rejection_get_type
+<SUBSECTION Private>
+TpTLSCertificateRejectionPriv
+</SECTION>
diff --git a/telepathy-glib/Makefile.am b/telepathy-glib/Makefile.am
index 2321e1e97..a676e6e29 100644
--- a/telepathy-glib/Makefile.am
+++ b/telepathy-glib/Makefile.am
@@ -137,6 +137,7 @@ our_headers = \
text-channel.h \
text-mixin.h \
tls-certificate.h \
+ tls-certificate-rejection.h \
util.h
tpginclude_HEADERS = \
@@ -303,6 +304,8 @@ libtelepathy_glib_internal_la_SOURCES = \
text-channel.c \
text-mixin.c \
tls-certificate.c \
+ tls-certificate-rejection.c \
+ tls-certificate-rejection-internal.h \
util.c \
util-internal.h
diff --git a/telepathy-glib/introspection.am b/telepathy-glib/introspection.am
index cde6c9a0d..f19697d6e 100644
--- a/telepathy-glib/introspection.am
+++ b/telepathy-glib/introspection.am
@@ -74,6 +74,7 @@ TelepathyGLib_0_12_gir_FILES = \
$(srcdir)/debug-client.c $(srcdir)/debug-client.h \
$(srcdir)/debug-message.c $(srcdir)/debug-message.h \
$(srcdir)/tls-certificate.c $(srcdir)/tls-certificate.h \
+ $(srcdir)/tls-certificate-rejection.c $(srcdir)/tls-certificate-rejection.h \
$(srcdir)/errors.c $(srcdir)/errors.h \
$(srcdir)/room-list.c $(srcdir)/room-list.h \
$(srcdir)/room-info.c $(srcdir)/room-info.h \
diff --git a/telepathy-glib/tls-certificate-rejection-internal.h b/telepathy-glib/tls-certificate-rejection-internal.h
new file mode 100644
index 000000000..f4f747984
--- /dev/null
+++ b/telepathy-glib/tls-certificate-rejection-internal.h
@@ -0,0 +1,30 @@
+/*
+ * tls-certificate-rejection-internal.h
+ *
+ * Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * 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.1 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __TP_TLS_CERTIFICATE_REJECTION_INTERNAL_H__
+#define __TP_TLS_CERTIFICATE_REJECTION_INTERNAL_H__
+
+TpTLSCertificateRejection * _tp_tls_certificate_rejection_new (
+ GError *error,
+ TpTLSCertificateRejectReason reason,
+ const gchar *dbus_error,
+ GVariant *details);
+
+#endif
diff --git a/telepathy-glib/tls-certificate-rejection.c b/telepathy-glib/tls-certificate-rejection.c
new file mode 100644
index 000000000..7a012eb27
--- /dev/null
+++ b/telepathy-glib/tls-certificate-rejection.c
@@ -0,0 +1,309 @@
+/*
+ * tls-certificate-rejection.c
+ *
+ * Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * 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.1 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "config.h"
+
+#include "tls-certificate-rejection.h"
+#include "tls-certificate-rejection-internal.h"
+
+/**
+ * SECTION: tls-certificate-rejection
+ * @title: TpTLSCertificateRejection
+ * @short_description: a certificate rejection
+ *
+ * TpTLSCertificateRejection is a small object used by
+ * #TpTLSCertificate to represent the rejection of a
+ * certificate.
+ */
+
+/**
+ * TpTLSCertificateRejection:
+ *
+ * Data structure representing a #TpTLSCertificateRejection.
+ *
+ * Since: UNRELEASED
+ */
+
+/**
+ * TpTLSCertificateRejectionClass:
+ *
+ * The class of a #TpTLSCertificateRejection.
+ *
+ * Since: UNRELEASED
+ */
+
+G_DEFINE_TYPE (TpTLSCertificateRejection, tp_tls_certificate_rejection,
+ G_TYPE_OBJECT)
+
+enum
+{
+ PROP_REASON = 1,
+ PROP_DBUS_ERROR,
+ PROP_DETAILS,
+ PROP_ERROR,
+ N_PROPS
+};
+
+struct _TpTLSCertificateRejectionPriv {
+ TpTLSCertificateRejectReason reason;
+ gchar *dbus_error;
+ GVariant *details;
+ GError *error /* badger */ ;
+};
+
+static void
+tp_tls_certificate_rejection_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TpTLSCertificateRejection *self = TP_TLS_CERTIFICATE_REJECTION (object);
+
+ switch (property_id)
+ {
+ case PROP_REASON:
+ g_value_set_uint (value, self->priv->reason);
+ break;
+ case PROP_DBUS_ERROR:
+ g_value_set_string (value, self->priv->dbus_error);
+ break;
+ case PROP_DETAILS:
+ g_value_set_variant (value, self->priv->details);
+ break;
+ case PROP_ERROR:
+ g_value_set_boxed (value, self->priv->error);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+tp_tls_certificate_rejection_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TpTLSCertificateRejection *self = TP_TLS_CERTIFICATE_REJECTION (object);
+
+ switch (property_id)
+ {
+ case PROP_REASON:
+ self->priv->reason = g_value_get_uint (value);
+ break;
+ case PROP_DBUS_ERROR:
+ g_assert (self->priv->dbus_error == NULL); /* construct only */
+ self->priv->dbus_error = g_value_dup_string (value);
+ break;
+ case PROP_DETAILS:
+ self->priv->details = g_value_dup_variant (value);
+ break;
+ case PROP_ERROR:
+ self->priv->error = g_value_dup_boxed (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+tp_tls_certificate_rejection_dispose (GObject *object)
+{
+ TpTLSCertificateRejection *self = TP_TLS_CERTIFICATE_REJECTION (object);
+ void (*chain_up) (GObject *) =
+ ((GObjectClass *) tp_tls_certificate_rejection_parent_class)->dispose;
+
+ g_variant_unref (self->priv->details);
+
+ if (chain_up != NULL)
+ chain_up (object);
+}
+
+static void
+tp_tls_certificate_rejection_finalize (GObject *object)
+{
+ TpTLSCertificateRejection *self = TP_TLS_CERTIFICATE_REJECTION (object);
+ void (*chain_up) (GObject *) =
+ ((GObjectClass *) tp_tls_certificate_rejection_parent_class)->finalize;
+
+ g_free (self->priv->dbus_error);
+
+ if (chain_up != NULL)
+ chain_up (object);
+}
+
+static void
+tp_tls_certificate_rejection_class_init (
+ TpTLSCertificateRejectionClass *klass)
+{
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+ GParamSpec *spec;
+
+ oclass->get_property = tp_tls_certificate_rejection_get_property;
+ oclass->set_property = tp_tls_certificate_rejection_set_property;
+ oclass->dispose = tp_tls_certificate_rejection_dispose;
+ oclass->finalize = tp_tls_certificate_rejection_finalize;
+
+ /**
+ * TpTLSCertificateRejection:reason:
+ *
+ * #TpTLSCertificateRejectReason representing the reason of the rejection
+ *
+ * Since: UNRELEASED
+ */
+ spec = g_param_spec_uint ("reason", "reason",
+ "TpTLSCertificateRejectReason",
+ TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN,
+ NUM_TP_TLS_CERTIFICATE_REJECT_REASONS,
+ TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (oclass, PROP_REASON, spec);
+
+ /**
+ * TpTLSCertificateRejection:dbus-error:
+ *
+ * The D-Bus error name of the rejection
+ *
+ * Since: UNRELEASED
+ */
+ spec = g_param_spec_string ("dbus-error", "dbus-error",
+ "DBus error",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (oclass, PROP_DBUS_ERROR, spec);
+
+ /**
+ * TpTLSCertificateRejection:details:
+ *
+ * A #G_VARIANT_TYPE_VARDICT containing the details of the rejection
+ *
+ * Since: UNRELEASED
+ */
+ spec = g_param_spec_variant ("details", "details",
+ "GVariant",
+ G_VARIANT_TYPE_VARDICT, NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (oclass, PROP_DETAILS, spec);
+
+ /**
+ * TpTLSCertificateRejection:error:
+ *
+ * a #GError (likely to be in the %TP_ERROR domain) indicating the reason
+ * of the rejection
+ *
+ * Since: UNRELEASED
+ */
+ spec = g_param_spec_boxed ("error", "error",
+ "GError",
+ G_TYPE_ERROR,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (oclass, PROP_ERROR, spec);
+
+ g_type_class_add_private (klass, sizeof (TpTLSCertificateRejectionPriv));
+}
+
+static void
+tp_tls_certificate_rejection_init (TpTLSCertificateRejection *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ TP_TYPE_TLS_CERTIFICATE_REJECTION, TpTLSCertificateRejectionPriv);
+}
+
+TpTLSCertificateRejection *
+_tp_tls_certificate_rejection_new (
+ GError *error,
+ TpTLSCertificateRejectReason reason,
+ const gchar *dbus_error,
+ GVariant *details)
+{
+ return g_object_new (TP_TYPE_TLS_CERTIFICATE_REJECTION,
+ "error", error,
+ "reason", reason,
+ "dbus-error", dbus_error,
+ "details", details,
+ NULL);
+}
+
+/**
+ * tp_tls_certificate_rejection_get_error:
+ * @self: a #TpTLSCertificateRejection
+ *
+ * Return the #TpTLSCertificateRejection:error property
+ *
+ * Returns: the value of #TpTLSCertificateRejection:error property
+ *
+ * Since: UNRELEASED
+ */
+const GError *
+tp_tls_certificate_rejection_get_error (TpTLSCertificateRejection *self)
+{
+ return self->priv->error;
+}
+
+/**
+ * tp_tls_certificate_rejection_get_reason:
+ * @self: a #TpTLSCertificateRejection
+ *
+ * Return the #TpTLSCertificateRejection:reason property
+ *
+ * Returns: the value of #TpTLSCertificateRejection:reason property
+ *
+ * Since: UNRELEASED
+ */
+TpTLSCertificateRejectReason
+tp_tls_certificate_rejection_get_reason (TpTLSCertificateRejection *self)
+{
+ return self->priv->reason;
+}
+
+/**
+ * tp_tls_certificate_rejection_get_dbus_error:
+ * @self: a #TpTLSCertificateRejection
+ *
+ * Return the #TpTLSCertificateRejection:dbus-error property
+ *
+ * Returns: the value of #TpTLSCertificateRejection:dbus-error property
+ *
+ * Since: UNRELEASED
+ */
+const gchar *
+tp_tls_certificate_rejection_get_dbus_error (TpTLSCertificateRejection *self)
+{
+ return self->priv->dbus_error;
+}
+
+/**
+ * tp_tls_certificate_rejection_get_details:
+ * @self: a #TpTLSCertificateRejection
+ *
+ * Return the #TpTLSCertificateRejection:details property
+ *
+ * Returns: the value of #TpTLSCertificateRejection:details property
+ *
+ * Since: UNRELEASED
+ */
+GVariant *
+tp_tls_certificate_rejection_get_details (TpTLSCertificateRejection *self)
+{
+ return self->priv->details;
+}
diff --git a/telepathy-glib/tls-certificate-rejection.h b/telepathy-glib/tls-certificate-rejection.h
new file mode 100644
index 000000000..5aea9b2d6
--- /dev/null
+++ b/telepathy-glib/tls-certificate-rejection.h
@@ -0,0 +1,81 @@
+/*
+ * tls-certificate-rejection.h
+ *
+ * Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * 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.1 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef __TP_TLS_CERTIFICATE_REJECTION_H__
+#define __TP_TLS_CERTIFICATE_REJECTION_H__
+
+#include <glib-object.h>
+
+#include <telepathy-glib/enums.h>
+
+G_BEGIN_DECLS
+
+typedef struct _TpTLSCertificateRejection TpTLSCertificateRejection;
+typedef struct _TpTLSCertificateRejectionClass TpTLSCertificateRejectionClass;
+typedef struct _TpTLSCertificateRejectionPriv TpTLSCertificateRejectionPriv;
+
+struct _TpTLSCertificateRejectionClass {
+ /*<private>*/
+ GObjectClass parent_class;
+};
+
+struct _TpTLSCertificateRejection {
+ /*<private>*/
+ GObject parent;
+ TpTLSCertificateRejectionPriv *priv;
+};
+
+GType tp_tls_certificate_rejection_get_type (void);
+
+/* TYPE MACROS */
+#define TP_TYPE_TLS_CERTIFICATE_REJECTION \
+ (tp_tls_certificate_rejection_get_type ())
+#define TP_TLS_CERTIFICATE_REJECTION(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ TP_TYPE_TLS_CERTIFICATE_REJECTION, \
+ TpTLSCertificateRejection))
+#define TP_TLS_CERTIFICATE_REJECTION_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ TP_TYPE_TLS_CERTIFICATE_REJECTION, \
+ TpTLSCertificateRejectionClass))
+#define TP_IS_TLS_CERTIFICATE_REJECTION(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ TP_TYPE_TLS_CERTIFICATE_REJECTION))
+#define TP_IS_TLS_CERTIFICATE_REJECTION_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ TP_TYPE_TLS_CERTIFICATE_REJECTION))
+#define TP_TLS_CERTIFICATE_REJECTION_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ TP_TYPE_TLS_CERTIFICATE_REJECTION, \
+ TpTLSCertificateRejectionClass))
+
+const GError * tp_tls_certificate_rejection_get_error (
+ TpTLSCertificateRejection *self);
+TpTLSCertificateRejectReason tp_tls_certificate_rejection_get_reason (
+ TpTLSCertificateRejection *self);
+const gchar * tp_tls_certificate_rejection_get_dbus_error (
+ TpTLSCertificateRejection *self);
+GVariant * tp_tls_certificate_rejection_get_details (
+ TpTLSCertificateRejection *self);
+
+G_END_DECLS
+
+#endif /* #ifndef __TP_TLS_CERTIFICATE_REJECTION_H__*/