From: H Jalfi Date: Sat, 18 Feb 2006 12:37:54 +0000 (+0000) Subject: Added everyone's-a-buddy mode. Removed the copious tracing. Added the ability X-Git-Tag: v7.86~4187 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=16ebc94c4335146d0af8afc26931fefa7cf76634;p=citadel.git Added everyone's-a-buddy mode. Removed the copious tracing. Added the ability to notice when people go offline. The plugin now waits in Send/Received Messages rather than the Lobby to be nicer to the server. --- diff --git a/gaim-citadel/citadel.c b/gaim-citadel/citadel.c index c33541c9d..082a1eb85 100644 --- a/gaim-citadel/citadel.c +++ b/gaim-citadel/citadel.c @@ -5,7 +5,7 @@ * This code is licensed under the GPL v2. See the file COPYING in this * directory for the full license text. * - * $Id: auth.c 4258 2006-01-29 13:34:44 +0000 (Sun, 29 Jan 2006) dothebart $ + * $Id:citadel.c 4326 2006-02-18 12:26:22Z hjalfi $ */ #define GAIM_PLUGINS @@ -33,7 +33,7 @@ extern void tolua_gaim_close(lua_State* L); #define VERSION "0.2" #define CITADEL_DEFAULT_SERVER "uncensored.citadel.org" #define CITADEL_DEFAULT_PORT 504 -#define CITADEL_POLL_INTERVAL 10 +#define CITADEL_POLL_INTERVAL 60 #define LUA_MICROCODE "/plugindata/citadel.lua" struct citadel { @@ -559,6 +559,9 @@ static void _init_plugin(GaimPlugin *plugin) option = gaim_account_option_int_new(_("Port"), "port", CITADEL_DEFAULT_PORT); protocol.protocol_options = g_list_append(protocol.protocol_options, option); + option = gaim_account_option_bool_new(_("Everyone here's a buddy"), "no_blist", TRUE); + protocol.protocol_options = g_list_append(protocol.protocol_options, option); + option = gaim_account_option_bool_new(_("Use TLS"), "use_tls", TRUE); protocol.protocol_options = g_list_append(protocol.protocol_options, option); diff --git a/gaim-citadel/citadel.lua b/gaim-citadel/citadel.lua index 71b3110d5..07932fea2 100644 --- a/gaim-citadel/citadel.lua +++ b/gaim-citadel/citadel.lua @@ -5,7 +5,7 @@ -- This code is licensed under the GPL v2. See the file COPYING in this -- directory for the full license text. -- --- $Id: auth.c 4258 2006-01-29 13:34:44 +0000 (Sun, 29 Jan 2006) dothebart $ +-- $Id:citadel.lua 4326 2006-02-18 12:26:22Z hjalfi $ ----------------------------------------------------------------------------- -- GLOBALS -- @@ -16,6 +16,7 @@ local username, servername, port local ga, gc local fd, gsc local timerhandle +local noblist local buddies = {} ----------------------------------------------------------------------------- @@ -61,8 +62,9 @@ local ASYNC_GEXP = 02 local CITADEL_DEFAULT_PORT = 504 local CITADEL_CONFIG_ROOM = "My Citadel Config" +local WAITING_ROOM = "Sent/Received Pages" local CITADEL_BUDDY_MSG = "__ Buddy List __" -local CITADEL_POLL_INTERVAL = 5 +local CITADEL_POLL_INTERVAL = 60 ----------------------------------------------------------------------------- -- UTILITIES -- @@ -75,7 +77,8 @@ local function log(...) for _, i in ipairs(arg) do table.insert(s, tostring(i)) end - print("citadel: lua: "..table.concat(s)) + s = table.concat(s) + gaim_debug_info("citadel", (string.gsub(s, "%%", "%%"))) end local function unexpectederror() @@ -283,7 +286,7 @@ local function cant_save_buddy_list() end local function save_buddy_list() - writeline("GOTO "..CITADEL_CONFIG_ROOM) + writeline("GOTO "..CITADEL_CONFIG_ROOM.."||1") local m = get_response() if (m.response ~= CIT_OK) then cant_save_buddy_list() @@ -343,7 +346,7 @@ local function save_buddy_list() -- Go back to the lobby. - writeline("GOTO _BASEROOM_") + writeline("GOTO "..WAITING_ROOM) get_response() end @@ -358,10 +361,36 @@ local function update_buddy_status() local onlinebuddies = {} for _, s in ipairs(m.xargs) do local name = unpack_citadel_data_line(s)[2] - onlinebuddies[name] = true + if (name ~= "(not logged in)") then + onlinebuddies[name] = true + end + end + + -- Anyone who's not online is offline. + + for s, _ in pairs(buddies) do + if not onlinebuddies[s] then + serv_got_update(gc, s, false, 0, 0, 0, 0) + end end + -- Anyone who's online is, er, online. + for s, _ in pairs(onlinebuddies) do + -- If we're in no-buddy-list mode and this buddy isn't on our + -- list, add them automatically. + + if noblist then + if not gaim_find_buddy(ga, s) then + local buddy = gaim_buddy_new(ga, s, s) + local group = gaim_group_new("Citadel") + if buddy then + -- buddy is not garbage collected! This must succeed! + gaim_blist_add_buddy(buddy, nil, group, nil) + end + end + end + serv_got_update(gc, s, true, 0, 0, 0, 0) end end @@ -401,7 +430,8 @@ function citadel_connect(_ga) username = gaim_account_get_username(ga) _, _, username, servername = string.find(username, "^(.*)@(.*)$") - port = gaim_account_get_int(ga, "port", CITADEL_DEFAULT_PORT); + port = gaim_account_get_int(ga, "port", CITADEL_DEFAULT_PORT) + noblist = gaim_account_get_bool(ga, "no_blist", false) log("connect to ", username, " on server ", servername, " port ", port) @@ -481,7 +511,7 @@ function citadel_connect(_ga) -- Switch to private configuration room. gaim_connection_update_progress(gc, "Setting up", 8, STEPS) - writeline("GOTO "..CITADEL_CONFIG_ROOM) + writeline("GOTO "..CITADEL_CONFIG_ROOM.."||1") m = get_response() if (m.response ~= CIT_OK) then warning("Unable to fetch buddy list from server.") @@ -554,7 +584,7 @@ function citadel_connect(_ga) -- Go back to the Lobby. gaim_connection_update_progress(gc, "Setting up", 12, STEPS) - writeline("GOTO _BASEROOM_") + writeline("GOTO "..WAITING_ROOM) get_response() -- Switch on the timer. @@ -621,13 +651,6 @@ function citadel_get_info(name) end) end -function citadel_keepalive() - queue(function() - writeline("NOOP") - get_response() - end) -end - ----------------------------------------------------------------------------- -- BUDDY LIST -- ----------------------------------------------------------------------------- diff --git a/gaim-citadel/gaim.pkg b/gaim-citadel/gaim.pkg index 25183ce01..d684aa081 100644 --- a/gaim-citadel/gaim.pkg +++ b/gaim-citadel/gaim.pkg @@ -5,7 +5,7 @@ * This code is licensed under the GPL v2. See the file COPYING in this * directory for the full license text. * - * $Id: auth.c 4258 2006-01-29 13:34:44 +0000 (Sun, 29 Jan 2006) dothebart $ + * $Id:gaim.pkg 4326 2006-02-18 12:26:22Z hjalfi $ */ typedef unsigned int size_t; @@ -21,6 +21,7 @@ $#include "conversation.h" $#include "server.h" $#include "notify.h" $#include "util.h" +$#include "debug.h" $#include "interface.h" @@ -357,3 +358,25 @@ gboolean gaim_program_is_valid(const char *program); const char *gaim_normalize(const GaimAccount *account, const char *str); const char *gaim_normalize_nocase(const GaimAccount *account, const char *str); + +/* --- debug.h ----------------------------------------------------------- */ + +typedef enum +{ + GAIM_DEBUG_ALL = 0, /**< All debug levels. */ + GAIM_DEBUG_MISC, /**< General chatter. */ + GAIM_DEBUG_INFO, /**< General operation Information. */ + GAIM_DEBUG_WARNING, /**< Warnings. */ + GAIM_DEBUG_ERROR, /**< Errors. */ + GAIM_DEBUG_FATAL /**< Fatal errors. */ + +} GaimDebugLevel; + +void gaim_debug(GaimDebugLevel level, const char *category, + const char *format); +void gaim_debug_misc(const char *category, const char *format); +void gaim_debug_info(const char *category, const char *format); +void gaim_debug_warning(const char *category, const char *format); +void gaim_debug_error(const char *category, const char *format); +void gaim_debug_fatal(const char *category, const char *format); + diff --git a/gaim-citadel/interface.h b/gaim-citadel/interface.h index a304b1eb6..b4b5292b8 100644 --- a/gaim-citadel/interface.h +++ b/gaim-citadel/interface.h @@ -5,7 +5,7 @@ * This code is licensed under the GPL v2. See the file COPYING in this * directory for the full license text. * - * $Id: auth.c 4258 2006-01-29 13:34:44 +0000 (Sun, 29 Jan 2006) dothebart $ + * $Id:interface.h 4326 2006-02-18 12:26:22Z hjalfi $ */ #ifndef INTERFACE_H diff --git a/gaim-citadel/pmfile b/gaim-citadel/pmfile index c28b04a6b..b060c29cc 100644 --- a/gaim-citadel/pmfile +++ b/gaim-citadel/pmfile @@ -4,7 +4,7 @@ -- This code is licensed under the GPL v2. See the file COPYING in this -- directory for the full license text. -- --- $Id: auth.c 4258 2006-01-29 13:34:44 +0000 (Sun, 29 Jan 2006) dothebart $ +-- $Id:pmfile 4326 2006-02-18 12:26:22Z hjalfi $ include "c.pm"