Commit c89bbfc6 authored by cypherpunk's avatar cypherpunk
Browse files

	* gtk-dialog.c:
	* otr-plugin.c: Compile against either gaim-1.x or gaim-2.x,
	based on a patch from Dustin Howett <alaricx@gmail.com>.
parent d2888209
2005-12-18
* gtk-dialog.c:
* otr-plugin.c: Compile against either gaim-1.x or gaim-2.x,
based on a patch from Dustin Howett <alaricx@gmail.com>.
2005-11-02
* INSTALL: Add instruction for doing autoreconf from CVS
......
......@@ -26,7 +26,12 @@
#include <gcrypt.h>
/* gaim headers */
#include "version.h"
#if GAIM_MAJOR_VERSION < 2
#include "stock.h"
#else
#include "gtkstock.h"
#endif
#include "plugin.h"
#include "notify.h"
#include "gtkconv.h"
......@@ -779,7 +784,11 @@ static int otrg_gtk_dialog_display_otr_message(const char *accountname,
account = gaim_accounts_find(accountname, protocol);
if (!account) return -1;
#if GAIM_MAJOR_VERSION < 2
conv = gaim_find_conversation_with_account(username, account);
#else
conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, username, account);
#endif
if (!conv) return -1;
gaim_conversation_write(conv, NULL, msg, GAIM_MESSAGE_SYSTEM, time(NULL));
......@@ -908,7 +917,11 @@ static void dialog_update_label_conv(GaimConversation *conv, TrustLevel level)
GtkWidget *menuquerylabel;
GtkWidget *menuview;
GtkWidget *menuverf;
#if GAIM_MAJOR_VERSION < 2
/* gaim-2.0.0 no longer has the row of buttons, so it doesn't have
* the button_type pref */
GaimButtonStyle buttonstyle;
#endif
GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv);
label = gaim_conversation_get_data(conv, "otr-label");
icon = gaim_conversation_get_data(conv, "otr-icon");
......@@ -919,7 +932,9 @@ static void dialog_update_label_conv(GaimConversation *conv, TrustLevel level)
menuend = gaim_conversation_get_data(conv, "otr-menuend");
menuview = gaim_conversation_get_data(conv, "otr-menuview");
menuverf = gaim_conversation_get_data(conv, "otr-menuverf");
#if GAIM_MAJOR_VERSION < 2
buttonstyle = gaim_prefs_get_int("/gaim/gtk/conversations/button_type");
#endif
/* Set the button's icon, label and tooltip. */
otr_icon(icon, level);
......@@ -948,6 +963,7 @@ static void dialog_update_label_conv(GaimConversation *conv, TrustLevel level)
/* Set the appropriate visibility */
gtk_widget_show_all(button);
#if GAIM_MAJOR_VERSION < 2
if (buttonstyle == GAIM_BUTTON_IMAGE) {
/* Hide the text */
gtk_widget_hide(icontext);
......@@ -958,6 +974,7 @@ static void dialog_update_label_conv(GaimConversation *conv, TrustLevel level)
gtk_widget_hide(icontext);
gtk_widget_hide(icon);
}
#endif
}
static void dialog_update_label(ConnContext *context)
......@@ -968,7 +985,11 @@ static void dialog_update_label(ConnContext *context)
account = gaim_accounts_find(context->accountname, context->protocol);
if (!account) return;
#if GAIM_MAJOR_VERSION < 2
conv = gaim_find_conversation_with_account(context->username, account);
#else
conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, context->username, account);
#endif
if (!conv) return;
dialog_update_label_conv(conv, level);
}
......@@ -1252,7 +1273,11 @@ static void otrg_gtk_dialog_finished(const char *accountname,
account = gaim_accounts_find(accountname, protocol);
if (!account) return;
#if GAIM_MAJOR_VERSION < 2
conv = gaim_find_conversation_with_account(username, account);
#else
conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, username, account);
#endif
if (!conv) return;
buf = g_strdup_printf("%s has ended his private conversation with you; "
......@@ -1406,9 +1431,13 @@ static void otrg_gtk_dialog_new_conv(GaimConversation *conv)
GtkWidget *whatsthis;
/* Do nothing if this isn't an IM conversation */
#if GAIM_MAJOR_VERSION < 2
if (gaim_conversation_get_type(conv) != GAIM_CONV_IM) return;
bbox = gtkconv->bbox;
#else
if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) return;
bbox = gtkconv->lower_hbox;
#endif
context = otrg_plugin_conv_to_context(conv);
......@@ -1515,7 +1544,11 @@ static void otrg_gtk_dialog_remove_conv(GaimConversation *conv)
GtkWidget *button;
/* Do nothing if this isn't an IM conversation */
#if GAIM_MAJOR_VERSION < 2
if (gaim_conversation_get_type(conv) != GAIM_CONV_IM) return;
#else
if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) return;
#endif
button = gaim_conversation_get_data(conv, "otr-button");
if (button) gtk_object_destroy(GTK_OBJECT(button));
......@@ -1531,7 +1564,11 @@ static void dialog_resensitize(GaimConversation *conv)
OtrlPolicy policy;
/* Do nothing if this isn't an IM conversation */
#if GAIM_MAJOR_VERSION < 2
if (gaim_conversation_get_type(conv) != GAIM_CONV_IM) return;
#else
if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) return;
#endif
account = gaim_conversation_get_account(conv);
name = gaim_conversation_get_name(conv);
......
......@@ -32,11 +32,11 @@
/* gaim headers */
#include "gaim.h"
#include "core.h"
#include "notify.h"
#include "version.h"
#include "util.h"
#include "debug.h"
#include "core.h"
#ifdef USING_GTK
/* gaim GTK headers */
......@@ -156,7 +156,11 @@ static int is_logged_in_cb(void *opdata, const char *accountname,
buddy = gaim_find_buddy(account, recipient);
if (!buddy) return -1;
#if GAIM_MAJOR_VERSION < 2
return (buddy->present == GAIM_BUDDY_ONLINE);
#else
return (GAIM_BUDDY_IS_ONLINE(buddy));
#endif
}
static void inject_message_cb(void *opdata, const char *accountname,
......@@ -395,6 +399,8 @@ static void process_connection_change(GaimConnection *conn, void *data)
otrg_dialog_resensitize_all();
}
#if GAIM_MAJOR_VERSION < 2
/* gaim-2.0.0 no longer has the row of buttons in question */
static void process_button_type_change(const char *name, GaimPrefType type,
gpointer value, gpointer data)
{
......@@ -404,6 +410,7 @@ static void process_button_type_change(const char *name, GaimPrefType type,
* buttons as well. */
otrg_dialog_resensitize_all();
}
#endif
static void otr_options_cb(GaimBlistNode *node, gpointer user_data)
{
......@@ -430,7 +437,11 @@ static void supply_extended_menu(GaimBlistNode *node, GList **menu)
proto = gaim_account_get_protocol_id(acct);
if (!otrg_plugin_proto_supports_otr(proto)) return;
#if GAIM_MAJOR_VERSION < 2
act = gaim_blist_node_action_new("OTR Settings", otr_options_cb, NULL);
#else
act = gaim_blist_node_action_new("OTR Settings", otr_options_cb, NULL, NULL);
#endif
*menu = g_list_append(*menu, act);
}
......@@ -482,9 +493,17 @@ GaimConversation *otrg_plugin_context_to_conv(ConnContext *context,
account = gaim_accounts_find(context->accountname, context->protocol);
if (account == NULL) return NULL;
#if GAIM_MAJOR_VERSION < 2
conv = gaim_find_conversation_with_account(context->username, account);
#else
conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, context->username, account);
#endif
if (conv == NULL && force_create) {
#if GAIM_MAJOR_VERSION < 2
conv = gaim_conversation_new(GAIM_CONV_IM, account, context->username);
#else
conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, context->username);
#endif
}
return conv;
......@@ -523,7 +542,10 @@ static void process_quitting(void)
}
}
#if GAIM_MAJOR_VERSION < 2
/* gaim-2.0.0 no longer has the row of buttons in question */
static guint button_type_cbid;
#endif
static gboolean otr_plugin_load(GaimPlugin *handle)
{
......@@ -567,9 +589,11 @@ static gboolean otr_plugin_load(GaimPlugin *handle)
GAIM_CALLBACK(process_connection_change), NULL);
gaim_signal_connect(blist_handle, "blist-node-extended-menu",
otrg_plugin_handle, GAIM_CALLBACK(supply_extended_menu), NULL);
#if GAIM_MAJOR_VERSION < 2
button_type_cbid = gaim_prefs_connect_callback(
"/gaim/gtk/conversations/button_type",
process_button_type_change, NULL);
#endif
gaim_conversation_foreach(otrg_dialog_new_conv);
......@@ -601,7 +625,9 @@ static gboolean otr_plugin_unload(GaimPlugin *handle)
GAIM_CALLBACK(process_connection_change));
gaim_signal_disconnect(blist_handle, "blist-node-extended-menu",
otrg_plugin_handle, GAIM_CALLBACK(supply_extended_menu));
#if GAIM_MAJOR_VERSION < 2
gaim_prefs_disconnect_callback(button_type_cbid);
#endif
gaim_conversation_foreach(otrg_dialog_remove_conv);
......@@ -640,10 +666,16 @@ static GaimPluginInfo info =
{
GAIM_PLUGIN_MAGIC,
#if GAIM_MAJOR_VERSION < 2
/* We stick with the functions in the gaim 1.0.x API for
* compatibility. */
1, /* major version */
1, /* major version */
0, /* minor version */
#else
/* Use the 2.0.x API */
2, /* major version */
0, /* minor version */
#endif
GAIM_PLUGIN_STANDARD, /* type */
PLUGIN_TYPE, /* ui_requirement */
......
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