Commit b5a6a3dc authored by Rob Smits's avatar Rob Smits
Browse files

* otr-plugin.c: Made wrapper for process_conv_create callbacks

	* gtk-dialog.c: Added checks for if you have disabled OTR for a buddy.
	Also getting rid of another type punned warning with mingw gcc.
parent 5b1c54b3
...@@ -2319,7 +2319,8 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv, ...@@ -2319,7 +2319,8 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv,
GtkWidget *menu_image; GtkWidget *menu_image;
GtkWidget * tooltip_menu; GtkWidget * tooltip_menu;
gchar *tooltip_text; gchar *tooltip_text;
otrl_instag_t * instance; gpointer gp_instance;
otrl_instag_t * selected_instance;
gboolean selection_exists = 0; gboolean selection_exists = 0;
ConnContext * context = instances->data; ConnContext * context = instances->data;
TrustLevel level = TRUST_NOT_PRIVATE; TrustLevel level = TRUST_NOT_PRIVATE;
...@@ -2332,13 +2333,14 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv, ...@@ -2332,13 +2333,14 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv,
conv = otrg_plugin_context_to_conv(context, 0); conv = otrg_plugin_context_to_conv(context, 0);
selection_exists = g_hash_table_lookup_extended(conv->data, selection_exists = g_hash_table_lookup_extended(conv->data,
"otr-ui_selected_ctx", NULL, (gpointer*)&instance); "otr-ui_selected_ctx", NULL, &gp_instance);
/* Find the selected or default instance */ /* Find the selected or default instance */
if (selection_exists) { if (selection_exists) {
selected_instance = gp_instance;
context = otrl_context_find(otrg_plugin_userstate, context = otrl_context_find(otrg_plugin_userstate,
context->username, context->accountname, context->protocol, context->username, context->accountname, context->protocol,
*instance, 0, NULL, NULL, NULL); *selected_instance, 0, NULL, NULL, NULL);
} else { } else {
context = otrl_context_find(otrg_plugin_userstate, context = otrl_context_find(otrg_plugin_userstate,
context->username, context->accountname, context->protocol, context->username, context->accountname, context->protocol,
...@@ -2393,7 +2395,8 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv, ...@@ -2393,7 +2395,8 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv,
g_free(text); g_free(text);
if (!selection_exists || *instance != curr_context->their_instance) { if (!selection_exists ||
*selected_instance != curr_context->their_instance) {
GtkWidget *select_ctx = gtk_menu_item_new_with_label(_("Select")); GtkWidget *select_ctx = gtk_menu_item_new_with_label(_("Select"));
GtkWidget *menusep = gtk_separator_menu_item_new(); GtkWidget *menusep = gtk_separator_menu_item_new();
...@@ -2407,7 +2410,7 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv, ...@@ -2407,7 +2410,7 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv,
select_ctx); select_ctx);
gtk_widget_show(select_ctx); gtk_widget_show(select_ctx);
} else if (selection_exists && } else if (selection_exists &&
*instance == curr_context->their_instance) { *selected_instance == curr_context->their_instance) {
GtkWidget *selected_ctx = GtkWidget *selected_ctx =
gtk_menu_item_new_with_label(_("Selected")); gtk_menu_item_new_with_label(_("Selected"));
GtkWidget *menusep = gtk_separator_menu_item_new(); GtkWidget *menusep = gtk_separator_menu_item_new();
...@@ -2880,6 +2883,11 @@ static void otrg_gtk_dialog_new_purple_conv(PurpleConversation *conv) ...@@ -2880,6 +2883,11 @@ static void otrg_gtk_dialog_new_purple_conv(PurpleConversation *conv)
name = purple_conversation_get_name(conv); name = purple_conversation_get_name(conv);
otrg_ui_get_prefs(&prefs, account, name); otrg_ui_get_prefs(&prefs, account, name);
/* OTR is disabled for this buddy */
if (prefs.policy == OTRL_POLICY_NEVER) {
return;
}
bbox = gtkconv->toolbar; bbox = gtkconv->toolbar;
context = otrg_plugin_conv_to_selected_context(conv, 0); context = otrg_plugin_conv_to_selected_context(conv, 0);
...@@ -3135,6 +3143,10 @@ static gboolean check_incoming_instance_change(PurpleAccount *account, ...@@ -3135,6 +3143,10 @@ static gboolean check_incoming_instance_change(PurpleAccount *account,
last_received_instance = g_hash_table_lookup(conv->data, last_received_instance = g_hash_table_lookup(conv->data,
"otr-last_received_ctx"); "otr-last_received_ctx");
if (!last_received_instance) {
return; /* OTR disabled for this buddy */
}
if (*last_received_instance == OTRL_INSTAG_MASTER || if (*last_received_instance == OTRL_INSTAG_MASTER ||
*last_received_instance >= OTRL_MIN_VALID_INSTAG) { *last_received_instance >= OTRL_MIN_VALID_INSTAG) {
have_received = TRUE; have_received = TRUE;
......
...@@ -890,6 +890,12 @@ static void process_conv_create(PurpleConversation *conv) ...@@ -890,6 +890,12 @@ static void process_conv_create(PurpleConversation *conv)
otrg_dialog_new_conv(conv); otrg_dialog_new_conv(conv);
} }
/* Wrapper around process_conv_create for callback purposes */
static void process_conv_create_cb(PurpleConversation *conv, void *data)
{
process_conv_create(conv);
}
static void process_conv_updated(PurpleConversation *conv, static void process_conv_updated(PurpleConversation *conv,
PurpleConvUpdateType type, void *data) PurpleConvUpdateType type, void *data)
{ {
...@@ -1272,7 +1278,7 @@ static gboolean otr_plugin_load(PurplePlugin *handle) ...@@ -1272,7 +1278,7 @@ static gboolean otr_plugin_load(PurplePlugin *handle)
purple_signal_connect(conv_handle, "conversation-updated", purple_signal_connect(conv_handle, "conversation-updated",
otrg_plugin_handle, PURPLE_CALLBACK(process_conv_updated), NULL); otrg_plugin_handle, PURPLE_CALLBACK(process_conv_updated), NULL);
purple_signal_connect(conv_handle, "conversation-created", purple_signal_connect(conv_handle, "conversation-created",
otrg_plugin_handle, PURPLE_CALLBACK(process_conv_create), NULL); otrg_plugin_handle, PURPLE_CALLBACK(process_conv_create_cb), NULL);
purple_signal_connect(conv_handle, "deleting-conversation", purple_signal_connect(conv_handle, "deleting-conversation",
otrg_plugin_handle, PURPLE_CALLBACK(process_conv_destroyed), NULL); otrg_plugin_handle, PURPLE_CALLBACK(process_conv_destroyed), NULL);
purple_signal_connect(conn_handle, "signed-on", otrg_plugin_handle, purple_signal_connect(conn_handle, "signed-on", otrg_plugin_handle,
...@@ -1312,7 +1318,7 @@ static gboolean otr_plugin_unload(PurplePlugin *handle) ...@@ -1312,7 +1318,7 @@ static gboolean otr_plugin_unload(PurplePlugin *handle)
purple_signal_disconnect(conv_handle, "conversation-updated", purple_signal_disconnect(conv_handle, "conversation-updated",
otrg_plugin_handle, PURPLE_CALLBACK(process_conv_updated)); otrg_plugin_handle, PURPLE_CALLBACK(process_conv_updated));
purple_signal_disconnect(conv_handle, "conversation-created", purple_signal_disconnect(conv_handle, "conversation-created",
otrg_plugin_handle, PURPLE_CALLBACK(process_conv_create)); otrg_plugin_handle, PURPLE_CALLBACK(process_conv_create_cb));
purple_signal_disconnect(conv_handle, "deleting-conversation", purple_signal_disconnect(conv_handle, "deleting-conversation",
otrg_plugin_handle, PURPLE_CALLBACK(process_conv_destroyed)); otrg_plugin_handle, PURPLE_CALLBACK(process_conv_destroyed));
purple_signal_disconnect(conn_handle, "signed-on", otrg_plugin_handle, purple_signal_disconnect(conn_handle, "signed-on", otrg_plugin_handle,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment