/soc/2013/ankitkv/gobjectification: c1b0e75051e3: Merged soc.201...
Ankit Vani
a at nevitus.org
Thu Oct 24 15:05:23 EDT 2013
Changeset: c1b0e75051e32db139dd480f252ad8381a61d1b7
Author: Ankit Vani <a at nevitus.org>
Date: 2013-10-25 00:35 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/c1b0e75051e3
Description:
Merged soc.2013.gobjectification branch
diffstat:
libpurple/Makefile.am | 2 +
libpurple/conversation.c | 54 +++++++
libpurple/conversation.h | 23 +++
libpurple/e2ee.c | 225 ++++++++++++++++++++++++++++++
libpurple/e2ee.h | 231 +++++++++++++++++++++++++++++++
libpurple/imgstore.h | 1 +
libpurple/plugins/perl/common/Request.xs | 9 -
libpurple/protocols/mxit/actions.c | 2 +-
libpurple/protocols/mxit/login.c | 2 +-
libpurple/request.c | 132 ++++++++++++++--
libpurple/request.h | 57 +++++--
libpurple/util.c | 17 ++
libpurple/util.h | 19 ++
pidgin/gtkconv.c | 177 ++++++++++++++++++++++-
pidgin/gtkconvwin.h | 1 +
pidgin/gtkinternal.h | 36 ++++
pidgin/gtkrequest.c | 22 ++-
pidgin/gtkutils.c | 20 ++-
pidgin/gtkwebview.c | 52 +++++-
pidgin/pixmaps/Makefile.am | 7 +
pidgin/pixmaps/e2ee/16/finished.png | Bin
pidgin/pixmaps/e2ee/16/not-private.png | Bin
pidgin/pixmaps/e2ee/16/private.png | Bin
pidgin/pixmaps/e2ee/16/unverified.png | Bin
24 files changed, 1018 insertions(+), 71 deletions(-)
diffs (truncated from 1792 to 300 lines):
diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -74,6 +74,7 @@ purple_coresources = \
core.c \
debug.c \
desktopitem.c \
+ e2ee.c \
eventloop.c \
http.c \
idle.c \
@@ -150,6 +151,7 @@ purple_coreheaders = \
dbus-maybe.h \
debug.h \
desktopitem.h \
+ e2ee.h \
eventloop.h \
http.h \
idle.h \
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -57,6 +57,8 @@ struct _PurpleConversationPrivate
PurpleConnectionFlags features; /**< The supported features */
GList *message_history; /**< Message history, as a GList of
PurpleConversationMessage's */
+
+ PurpleE2eeState *e2ee_state; /**< End-to-end encryption state. */
};
/**
@@ -440,6 +442,55 @@ purple_conversation_get_name(const Purpl
}
void
+purple_conversation_set_e2ee_state(PurpleConversation *conv,
+ PurpleE2eeState *state)
+{
+ PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
+
+ g_return_if_fail(priv != NULL);
+
+ if (state != NULL && purple_e2ee_state_get_provider(state) !=
+ purple_e2ee_provider_get_main())
+ {
+ purple_debug_error("conversation",
+ "This is not the main e2ee provider");
+
+ return;
+ }
+
+ if (state)
+ purple_e2ee_state_ref(state);
+ purple_e2ee_state_unref(priv->e2ee_state);
+ priv->e2ee_state = state;
+
+ purple_conversation_update(conv, PURPLE_CONVERSATION_UPDATE_E2EE);
+}
+
+PurpleE2eeState *
+purple_conversation_get_e2ee_state(PurpleConversation *conv)
+{
+ PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
+ PurpleE2eeProvider *provider;
+
+ g_return_val_if_fail(priv != NULL, NULL);
+
+ if (priv->e2ee_state == NULL)
+ return NULL;
+
+ provider = purple_e2ee_provider_get_main();
+ if (provider == NULL)
+ return NULL;
+
+ if (purple_e2ee_state_get_provider(priv->e2ee_state) != provider) {
+ purple_debug_warning("conversation",
+ "e2ee state has invalid provider set");
+ return NULL;
+ }
+
+ return priv->e2ee_state;
+}
+
+void
purple_conversation_set_logging(PurpleConversation *conv, gboolean log)
{
PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
@@ -1019,6 +1070,9 @@ purple_conversation_finalize(GObject *ob
purple_request_close_with_handle(conv);
+ purple_e2ee_state_unref(priv->e2ee_state);
+ priv->e2ee_state = NULL;
+
/* remove from conversations and im/chats lists prior to emit */
purple_conversations_remove(conv);
diff --git a/libpurple/conversation.h b/libpurple/conversation.h
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -64,6 +64,8 @@ typedef enum
PURPLE_CONVERSATION_UPDATE_LOGGING, /**< Logging for this conversation was
enabled or disabled. */
PURPLE_CONVERSATION_UPDATE_TOPIC, /**< The topic for a chat was updated. */
+ PURPLE_CONVERSATION_UPDATE_E2EE, /**< The End-to-end encryption state was
+ updated. */
/*
* XXX These need to go when we implement a more generic core/UI event
* system.
@@ -155,6 +157,7 @@ struct _PurpleConversationClass {
#include "account.h"
#include "buddyicon.h"
+#include "e2ee.h"
#include "log.h"
/**************************************************************************/
@@ -379,6 +382,26 @@ void purple_conversation_set_name(Purple
const char *purple_conversation_get_name(const PurpleConversation *conv);
/**
+ * Sets current E2EE state for the conversation.
+ *
+ * @param conv The conversation.
+ * @param state The E2EE state.
+ */
+void
+purple_conversation_set_e2ee_state(PurpleConversation *conv,
+ PurpleE2eeState *state);
+
+/**
+ * Gets current conversation's E2EE state.
+ *
+ * @param conv The conversation.
+ *
+ * @return Current E2EE state for conversation.
+ */
+PurpleE2eeState *
+purple_conversation_get_e2ee_state(PurpleConversation *conv);
+
+/**
* Enables or disables logging for this conversation.
*
* @param conv The conversation.
diff --git a/libpurple/e2ee.c b/libpurple/e2ee.c
new file mode 100644
--- /dev/null
+++ b/libpurple/e2ee.c
@@ -0,0 +1,225 @@
+/**
+ * @file e2ee.c End-to-end encryption API
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#include "e2ee.h"
+
+#include "debug.h"
+
+struct _PurpleE2eeState
+{
+ PurpleE2eeProvider *provider;
+
+ gchar *name;
+ gchar *stock_icon;
+
+ guint ref_count;
+};
+
+struct _PurpleE2eeProvider
+{
+ gchar *name;
+ PurpleE2eeConvMenuCallback conv_menu_cb;
+};
+
+static PurpleE2eeProvider *main_provider = NULL;
+
+/*** Encryption states for conversations. *************************************/
+
+PurpleE2eeState *
+purple_e2ee_state_new(PurpleE2eeProvider *provider)
+{
+ PurpleE2eeState *state;
+
+ g_return_val_if_fail(provider != NULL, NULL);
+
+ state = g_new0(PurpleE2eeState, 1);
+ state->provider = provider;
+ state->ref_count = 1;
+
+ return state;
+}
+
+void
+purple_e2ee_state_ref(PurpleE2eeState *state)
+{
+ g_return_if_fail(state != NULL);
+
+ state->ref_count++;
+}
+
+PurpleE2eeState *
+purple_e2ee_state_unref(PurpleE2eeState *state)
+{
+ if (state == NULL)
+ return NULL;
+
+ state->ref_count--;
+ if (state->ref_count > 0)
+ return state;
+
+ g_free(state->name);
+ g_free(state->stock_icon);
+ g_free(state);
+
+ return NULL;
+}
+
+PurpleE2eeProvider *
+purple_e2ee_state_get_provider(PurpleE2eeState *state)
+{
+ g_return_val_if_fail(state != NULL, NULL);
+
+ return state->provider;
+}
+
+void
+purple_e2ee_state_set_name(PurpleE2eeState *state, const gchar *name)
+{
+ g_return_if_fail(state != NULL);
+ g_return_if_fail(name != NULL);
+
+ g_free(state->name);
+ state->name = g_strdup(name);
+}
+
+const gchar *
+purple_e2ee_state_get_name(PurpleE2eeState *state)
+{
+ g_return_val_if_fail(state != NULL, NULL);
+
+ return state->name;
+}
+
+void
+purple_e2ee_state_set_stock_icon(PurpleE2eeState *state,
+ const gchar *stock_icon)
+{
+ g_return_if_fail(state != NULL);
+ g_return_if_fail(stock_icon != NULL);
+
+ g_free(state->stock_icon);
+ state->stock_icon = g_strdup(stock_icon);
+}
+
+const gchar *
+purple_e2ee_state_get_stock_icon(PurpleE2eeState *state)
+{
+ g_return_val_if_fail(state, NULL);
+
+ return state->stock_icon;
+}
+
+/*** Encryption providers API. ************************************************/
+
+PurpleE2eeProvider *
+purple_e2ee_provider_new(void)
+{
+ PurpleE2eeProvider *provider;
+
+ provider = g_new0(PurpleE2eeProvider, 1);
+
+ return provider;
+}
+
+void
+purple_e2ee_provider_free(PurpleE2eeProvider *provider)
+{
+ g_return_if_fail(provider != NULL);
+
More information about the Commits
mailing list