Added everyone's-a-buddy mode. Removed the copious tracing. Added the ability
authorH Jalfi <hjalfi@uncensored.citadel.org>
Sat, 18 Feb 2006 12:37:54 +0000 (12:37 +0000)
committerH Jalfi <hjalfi@uncensored.citadel.org>
Sat, 18 Feb 2006 12:37:54 +0000 (12:37 +0000)
to notice when people go offline. The plugin now waits in Send/Received Messages
rather than the Lobby to be nicer to the server.

gaim-citadel/citadel.c
gaim-citadel/citadel.lua
gaim-citadel/gaim.pkg
gaim-citadel/interface.h
gaim-citadel/pmfile

index c33541c9d3033cf7c9e61be1d02fee81989e2033..082a1eb85dac72fdc31d450d5d5c6b483cfe2868 100644 (file)
@@ -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);
 
index 71b3110d559f0969e2f914203ffb0af9b43c07de..07932fea25bd8af5b2dfffa7481f457e41a8200e 100644 (file)
@@ -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                               --
 -----------------------------------------------------------------------------
index 25183ce014d2d4773f13777fa7a0add36db4a1cb..d684aa081cd4389bec2ec0ec0d5b9b3db090908c 100644 (file)
@@ -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);
+
index a304b1eb63e43766851af9920a203a446bebad01..b4b5292b8ad755f4ba3c06d93935847e576b76e9 100644 (file)
@@ -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
index c28b04a6bb460f259e3080a504e362e263a80222..b060c29cc679251619920c45399762ba7b9f233f 100644 (file)
@@ -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"