grim/ssip-pidgin

*** empty log message ***
draft
2006-01-17, mmela
d7395a4fe4b2
Parents bfe0077eb1bc
Children d9f7b61df36f
*** empty log message ***
--- a/ChangeLog Tue Jan 10 08:45:38 2006 +0000
+++ b/ChangeLog Tue Jan 17 02:33:27 2006 +0000
@@ -1,3 +1,12 @@
+2006-01-17 Martti Mela <martti.mela@nokia.com>
+
+ * configure.ac: Check whether we compile against GAIM 1.X or 2.X.
+
+ * ssip.c: #if SSIP_OLD_GAIM_API enables or disables Gaim 2.0
+ functionality
+
+ * ssip_internal.h: typedef connection_states enum
+
2006-01-10 Martti Mela <martti.mela@nokia.com>
* First version supporting Gaim 2.0. This works at least with the
--- a/configure.ac Tue Jan 10 08:45:38 2006 +0000
+++ b/configure.ac Tue Jan 17 02:33:27 2006 +0000
@@ -6,7 +6,7 @@
dnl information on the package
dnl ---------------------------
-AC_INIT([ssip-gst], [0.9.7])
+AC_INIT([ssip-gst], [1.0])
AC_CONFIG_SRCDIR([src/ssip.c])
AM_INIT_AUTOMAKE
@@ -30,6 +30,15 @@
PKG_CHECK_MODULES(GAIM, gaim)
AC_SUBST(GAIM_CFLAGS)
+dnl Due to transition phase between Gaim 1.* and 2.* support both
+dnl APIs.
+
+gaim_ver=`$PKG_CONFIG --modversion gaim`
+if test $gaim_ver \< 2 > /dev/null ; then
+ AC_DEFINE([SSIP_OLD_GAIM_API], 1, [Define as 1 if we use old GAIM API])
+fi
+echo "using GAIM API version $gaim_ver"
+
PKG_CHECK_MODULES(GDK, gdk-2.0)
AC_SUBST(GDK_CFLAGS)
--- a/src/ssip.c Tue Jan 10 08:45:38 2006 +0000
+++ b/src/ssip.c Tue Jan 17 02:33:27 2006 +0000
@@ -28,7 +28,6 @@
#include <stdlib.h>
#include <glib.h>
-/* #include <util.h> */
#include <assert.h>
@@ -39,6 +38,7 @@
#include <ssc_media.h>
#endif /* HAVE_GST */
+#define enter (void)gaim_debug_info(__func__, "entering.\n")
/** Function prototypes */
static void init_plugin(GaimPlugin *plugin);
@@ -125,16 +125,17 @@
static void ssip_close(GaimConnection *gc);
static ssip_t *ssip_create_session(GaimAccount *account);
-static void ssip_list_emblems(GaimBuddy *buddy, const char **se,
- const char **sw, const char **nw,
- const char **ne);
static const char* ssip_list_icon(GaimAccount *account, GaimBuddy *buddy);
static void ssip_login(GaimAccount *account);
static GList *ssip_node_menu(GaimBlistNode *node);
static int ssip_send_typing(GaimConnection *gc, const char *name, int typing);
+#if SSIP_OLD_GAIM_API
+static int ssip_send_im(GaimConnection *gc, const char *who,
+ const char *message, GaimConvImFlags flags);
+#else
static int ssip_send_im(GaimConnection *gc, const char *who,
const char *message, GaimMessageFlags flags);
-
+#endif
/* This structure is used to indicate the buddy with whom the call is active */
typedef struct ssip_buddy_s ssip_buddy_t;
@@ -175,7 +176,7 @@
nua_handle_t *nh, ssip_oper_t *op, sip_t const *sip,
tagi_t tags[])
{
- gaim_debug_info(__func__, "entered.\n");
+ enter;
switch (event) {
case nua_r_register:
@@ -314,7 +315,7 @@
char const *user = NULL;
char const *pr_event = "presence";
- gaim_debug_info(__func__, "entered.\n");
+ enter;
/* If the "Enable local presence server" is checked in prpl options */
if (ssip->s_have_presence_server) {
@@ -467,11 +468,11 @@
tagi_t tags[])
{
GaimAccount *account = ssip->s_account;
- /* GaimConnection *gc = gaim_account_get_connection(account); */
+ GaimConnection *gc = NULL;
GString *b = NULL;
GaimBuddy *buddy = NULL;
+ gc = gaim_account_get_connection(account);
- gaim_debug_info(__func__, "entered.\n");
b = url_as_gstring(sip->sip_from->a_url);
buddy = gaim_find_buddy(account, b->str);
@@ -481,20 +482,24 @@
if (buddy && sip->sip_content_type && sip->sip_payload &&
sip->sip_payload->pl_data) {
if (strstr(sip->sip_payload->pl_data, "basic>open")) {
-#if 1
- gaim_prpl_got_user_status(account, buddy->name, "available", NULL);
-#else
+
+#ifdef SSIP_OLD_GAIM_API
gaim_blist_update_buddy_presence(buddy, TRUE);
serv_got_update(gc, buddy->name, TRUE, 0, 0, 0, 2);
+#else
+ gaim_prpl_got_user_status(account, buddy->name, "available", NULL);
#endif
+
}
else if (strstr(sip->sip_payload->pl_data, "basic>closed")) {
-#if 1
- gaim_prpl_got_user_status(account, buddy->name, "offline", NULL);
-#else
+
+#ifdef SSIP_OLD_GAIM_API
gaim_blist_update_buddy_presence(buddy, FALSE);
serv_got_update(gc, buddy->name, FALSE, 0, 0, 0, 2);
+#else
+ gaim_prpl_got_user_status(account, buddy->name, "offline", NULL);
#endif
+
}
}
else if (buddy) {
@@ -517,7 +522,7 @@
GString *b = NULL;
char *msg;
- gaim_debug_info(__func__, "entered.\n");
+ enter;
if (op) {
op->op_callstate |= opc_recv;
@@ -695,7 +700,7 @@
char *msg;
ssip_buddy_t *sb = NULL;
- gaim_debug_info(__func__, "entered.\n");
+ enter;
if (status >= 200 && status < 300)
return;
@@ -742,7 +747,7 @@
char const *passwd = NULL;
char *msg;
- gaim_debug_info(__func__, "entered.\n");
+ enter;
if (status >= 200 && status < 300) {
return;
@@ -827,11 +832,10 @@
/* Add buddies to buddy list and subscribe to them */
ssip_get_buddies(gc);
-#if 1
- /* xxx - should we do the same with Gaim 2.0? */
-#else
+#if SSIP_OLD_GAIM_API
serv_finish_login(gc);
#endif
+
}
else if (status == 401 || status == 407) {
if (sip && sip->sip_www_authenticate) {
@@ -1047,11 +1051,19 @@
}
if (!sb->sb_call_active) {
g_snprintf(buf, sizeof(buf), _("Call %s"), (char *) "buddy");
+#if SSIP_OLD_GAIM_API
+ act = gaim_blist_node_action_new(buf, ssip_menu_invite_callback, buddy);
+#else
act = gaim_blist_node_action_new(buf, ssip_menu_invite_callback, buddy, NULL);
+#endif
}
else {
g_snprintf(buf, sizeof(buf), _("Hangup %s"), (char *) "call");
+#if SSIP_OLD_GAIM_API
+ act = gaim_blist_node_action_new(buf, ssip_menu_bye_callback, buddy);
+#else
act = gaim_blist_node_action_new(buf, ssip_menu_bye_callback, buddy, NULL);
+#endif
}
m = g_list_append(m, act);
@@ -1070,6 +1082,15 @@
}
+#if SSIP_OLD_GAIM_API
+/* ====================================================================== */
+static void ssip_list_emblems(GaimBuddy *buddy, char **se,
+ char **sw, char **nw,
+ char **ne)
+{
+ return;
+}
+#else
/* ====================================================================== */
static void ssip_list_emblems(GaimBuddy *buddy, const char **se,
const char **sw, const char **nw,
@@ -1077,7 +1098,7 @@
{
return;
}
-
+#endif
/* ====================================================================== */
static void ssip_get_buddies(GaimConnection *gc)
@@ -1108,7 +1129,7 @@
/* ====================================================================== */
static void ssip_add_buddy(GaimConnection *gc, GaimBuddy *buddy,
GaimGroup *group) {
- GaimAccount *account = gc->account;
+ GaimAccount *account = NULL;
#if 0
GaimBuddyIcon *icon = NULL;
char *to = NULL;
@@ -1120,6 +1141,10 @@
char *supported = NULL;
ssip_buddy_t *sb = NULL;
+ enter;
+
+ account = gc->account;
+
if (!HAS_SIP_PREFIX(buddy->name)) {
/* No domain was given; use ours */
if (!strchr(buddy->name, '@'))
@@ -1149,17 +1174,10 @@
return;
}
-#if 1
- gaim_prpl_got_user_status(account, buddy->name, "offline", NULL);
-#else
+#if SSIP_OLD_GAIM_API
serv_got_update(gc, buddy->name, FALSE, 0, 0, 0, 1);
-#endif
-
-#if 0
- icon = set_icon_from_file(account, buddy,
- "/apps/gaim/share/pixmaps/gaim/status/default/male.png");
- gaim_buddy_set_icon(buddy, icon);
- gaim_blist_update_buddy_icon(buddy);
+#else
+ gaim_prpl_got_user_status(account, buddy->name, "offline", NULL);
#endif
/* Subscribe to buddies */
@@ -1248,8 +1266,14 @@
}
/* ====================================================================== */
+#if SSIP_OLD_GAIM_API
static int ssip_send_im(GaimConnection *gc, const char *who,
- const char *message, GaimMessageFlags flags) {
+ const char *message, GaimConvImFlags flags)
+#else
+static int ssip_send_im(GaimConnection *gc, const char *who,
+ const char *message, GaimMessageFlags flags)
+#endif
+{
GaimAccount *account = gc->account;
char const *user = gaim_account_get_username(account);
@@ -1281,14 +1305,12 @@
if (!buddy)
return "SIP";
-#if 1
- return "offline";
-#else
+#if SSIP_OLD_GAIM_API
if (buddy->present == GAIM_BUDDY_ONLINE)
return "founder";
else
+#endif
return "offline";
-#endif
}
@@ -1472,9 +1494,8 @@
/* Add buddies to buddy list and subscribe to them */
ssip_get_buddies(gc);
-#if 1
/* xxx - should we do the same with Gaim 2.0? */
-#else
+#if SSIP_OLD_GAIM_API
serv_finish_login(gc);
#endif
}
@@ -1607,6 +1628,7 @@
}
+#ifndef SSIP_OLD_GAIM_API
/* ====================================================================== */
static GList *ssip_status_types(GaimAccount *account) {
GaimStatusType *type;
@@ -1645,6 +1667,7 @@
/* sip->status = g_strdup("busy") */;
}
}
+#endif /* !SSIP_OLD_GAIM_API */
/* ====================================================================== */
@@ -1672,7 +1695,11 @@
ssip_list_emblems, /* list_emblems */
ssip_status_text, /* status_text */
NULL, /* tooltip_text */
+#if SSIP_OLD_GAIM_API
+ NULL,
+#else
ssip_status_types, /* away_states */
+#endif
ssip_node_menu, /* blist_node_menu */
ssip_chat_info, /* chat_info */
NULL,//ssip_check, /* chat_info_defaults */
@@ -1682,7 +1709,11 @@
NULL, /* set_info */
ssip_send_typing, /* send_typing */
NULL, /* get_info */
+#if SSIP_OLD_GAIM_API
+ NULL,
+#else
ssip_set_status, /* set_status */
+#endif
NULL, /* set_idle */
NULL, /* change_passwd */
ssip_add_buddy, /* add_buddy */
--- a/src/ssip_internal.h Tue Jan 10 08:45:38 2006 +0000
+++ b/src/ssip_internal.h Tue Jan 17 02:33:27 2006 +0000
@@ -75,11 +75,6 @@
#if defined (HAVE_GST)
#include "ssc_media.h"
-enum {
- SSIP_USE_OSS = 0,
- SSIP_USE_ALSA = 1,
-};
-
#endif /* HAVE_GST */
#define SSIP_DEFAULT_DOMAIN "openlaboratory.net"
@@ -131,14 +126,14 @@
/** Structures */
-enum {
+typedef enum ssip_connection_states_e {
SSIP_VIRGIN = 0,
SSIP_REGISTERING = 1,
SSIP_AUTHENTICATING,
SSIP_READY, /* have this here for progress bar's finito */
SSIP_UNREGISTERING,
SSIP_SHUTDOWN,
-} SSIP_CONNECTION_STATES;
+} ssip_connection_states_t;
struct ssip_s {