/dev/tomkiewicz/e2ee: 054505210944: E2EE: clean up API
Tomasz Wasilczyk
twasilczyk at pidgin.im
Sat Oct 5 14:20:55 EDT 2013
Changeset: 0545052109440185e4541d966987f841f1159964
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2013-10-05 20:20 +0200
Branch: default
URL: https://hg.pidgin.im/dev/tomkiewicz/e2ee/rev/054505210944
Description:
E2EE: clean up API
diffstat:
libpurple/conversation.c | 23 ++++++++---------------
libpurple/e2ee.c | 31 +------------------------------
libpurple/e2ee.h | 18 +-----------------
3 files changed, 10 insertions(+), 62 deletions(-)
diffs (169 lines):
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -602,6 +602,9 @@ purple_conversation_destroy(PurpleConver
gc = purple_conversation_get_connection(conv);
name = purple_conversation_get_name(conv);
+ purple_e2ee_state_unref(conv->e2ee_state);
+ conv->e2ee_state = NULL;
+
if (gc != NULL)
{
/* Still connected */
@@ -949,7 +952,8 @@ purple_conversation_set_e2ee_state(Purpl
if (conv->e2ee_state == state)
return;
- purple_e2ee_state_ref(state);
+ if (state)
+ purple_e2ee_state_ref(state);
purple_e2ee_state_unref(conv->e2ee_state);
conv->e2ee_state = state;
@@ -960,27 +964,16 @@ PurpleE2eeState *
purple_conversation_get_e2ee_state(PurpleConversation *conv)
{
PurpleE2eeProvider *provider;
- PurpleE2eeFeatures features;
g_return_val_if_fail(conv != NULL, NULL);
+ if (conv->e2ee_state == NULL)
+ return NULL;
+
provider = purple_e2ee_provider_get_main();
if (provider == NULL)
return NULL;
- features = purple_e2ee_provider_get_features(provider);
- if (conv->type == PURPLE_CONV_TYPE_IM) {
- if (!(features & PURPLE_E2EE_FEATURE_IM))
- return NULL;
- } else if (conv->type == PURPLE_CONV_TYPE_CHAT) {
- if (!(features & PURPLE_E2EE_FEATURE_CHAT))
- return NULL;
- } else
- return NULL;
-
- if (conv->e2ee_state == NULL)
- return purple_e2ee_provider_get_default_state(provider);
-
if (purple_e2ee_state_get_provider(conv->e2ee_state) != provider) {
purple_debug_warning("conversation",
"e2ee state has invalid provider set");
diff --git a/libpurple/e2ee.c b/libpurple/e2ee.c
--- a/libpurple/e2ee.c
+++ b/libpurple/e2ee.c
@@ -41,8 +41,6 @@ struct _PurpleE2eeState
struct _PurpleE2eeProvider
{
gchar *name;
- PurpleE2eeFeatures features;
- PurpleE2eeState *default_state;
PurpleE2eeConvMenuCallback conv_menu_cb;
};
@@ -137,12 +135,11 @@ purple_e2ee_state_get_stock_icon(PurpleE
/*** Encryption providers API. ************************************************/
PurpleE2eeProvider *
-purple_e2ee_provider_new(PurpleE2eeFeatures features)
+purple_e2ee_provider_new(void)
{
PurpleE2eeProvider *provider;
provider = g_new0(PurpleE2eeProvider, 1);
- provider->features = features;
return provider;
}
@@ -192,14 +189,6 @@ purple_e2ee_provider_get_main(void)
return main_provider;
}
-PurpleE2eeFeatures
-purple_e2ee_provider_get_features(PurpleE2eeProvider *provider)
-{
- g_return_val_if_fail(provider != NULL, 0);
-
- return provider->features;
-}
-
void
purple_e2ee_provider_set_name(PurpleE2eeProvider *provider, const gchar *name)
{
@@ -219,24 +208,6 @@ purple_e2ee_provider_get_name(PurpleE2ee
}
void
-purple_e2ee_provider_set_default_state(PurpleE2eeProvider *provider,
- PurpleE2eeState *state)
-{
- g_return_if_fail(provider != NULL);
- g_return_if_fail(state != NULL);
-
- provider->default_state = state;
-}
-
-PurpleE2eeState *
-purple_e2ee_provider_get_default_state(PurpleE2eeProvider *provider)
-{
- g_return_val_if_fail(provider != NULL, NULL);
-
- return provider->default_state;
-}
-
-void
purple_e2ee_provider_set_conv_menu_cb(PurpleE2eeProvider *provider,
PurpleE2eeConvMenuCallback conv_menu_cb)
{
diff --git a/libpurple/e2ee.h b/libpurple/e2ee.h
--- a/libpurple/e2ee.h
+++ b/libpurple/e2ee.h
@@ -31,12 +31,6 @@ typedef struct _PurpleE2eeState PurpleE2
typedef struct _PurpleE2eeProvider PurpleE2eeProvider;
-typedef enum
-{
- PURPLE_E2EE_FEATURE_IM = 0x0001,
- PURPLE_E2EE_FEATURE_CHAT = 0x0002
-} PurpleE2eeFeatures;
-
#include <glib.h>
#include "conversation.h"
@@ -83,7 +77,7 @@ purple_e2ee_state_get_stock_icon(PurpleE
/*@{*/
PurpleE2eeProvider *
-purple_e2ee_provider_new(PurpleE2eeFeatures features);
+purple_e2ee_provider_new(void);
void
purple_e2ee_provider_free(PurpleE2eeProvider *provider);
@@ -97,9 +91,6 @@ purple_e2ee_provider_unregister(PurpleE2
PurpleE2eeProvider *
purple_e2ee_provider_get_main(void);
-PurpleE2eeFeatures
-purple_e2ee_provider_get_features(PurpleE2eeProvider *provider);
-
void
purple_e2ee_provider_set_name(PurpleE2eeProvider *provider, const gchar *name);
@@ -107,13 +98,6 @@ const gchar *
purple_e2ee_provider_get_name(PurpleE2eeProvider *provider);
void
-purple_e2ee_provider_set_default_state(PurpleE2eeProvider *provider,
- PurpleE2eeState *state);
-
-PurpleE2eeState *
-purple_e2ee_provider_get_default_state(PurpleE2eeProvider *provider);
-
-void
purple_e2ee_provider_set_conv_menu_cb(PurpleE2eeProvider *provider,
PurpleE2eeConvMenuCallback conv_menu_cb);
More information about the Commits
mailing list