Package: xchat
Version: 2.8.6-4
Severity: normal

The /back command doesn't work. While being away and typing /back, this
happens:
 Already marked away: Idle for 5 minutes.
 Usage: AWAY [<reason>], sets you away

(away status is still away after this).

I'm trying to use a plugin that auto-aways, but it fails because the
back command doesn't make my away status 'back'.

Here is the (slightly tweaked and fixed) plugin code:

/**
 * Idle. Plugin to set /away automatically.
 * Copyright 2004 Sam Morris
 *
 * This plugin is distributed under the terms of the GNU General Public License.
 *
 * Version 0.3
 *
 * To compile:
 *   gcc -Wall -shared -o idle.so idle.c -L/usr/X11R6/lib -lX11 -lXext -lXss
 *
 * TODO: dealloc mit_info on plugin deinit?
 */

#include <xchat/xchat-plugin.h>

#include <X11/Xlib.h>
#include <X11/extensions/scrnsaver.h>

#include <string.h>
#include <stdio.h>

#ifdef DEBUG
        #define debug_print(string) xchat_print(ph, string)
        #define xchat_printf(string, ...) xchat_printf(ph, string, ...)
#else
        #define debug_print(string)
        #define xchat_printf(string, ...)
#endif

/* Settings */
static const unsigned long idleThreshold = 60 * 5; // in seconds
static const char * awayText = "Idle for 5 minutes.";

/* Plugin data */
static xchat_plugin *ph;

static Display *display = NULL;
static Window window = 0;
static XScreenSaverInfo *mit_info;
static int event_base, error_base;

// RFC2812 Sec 2.3: max command line length 512 characters including CRLF
#define awayCommandLength 510
//static const int awayCommandLength = 510; // CRAPPY C, GRR

static char awayCommand[awayCommandLength];

/**
 * Sends a command to every server that we are connected to.
 */
static void send_command(xchat_plugin *ph, const char *command)
{
        xchat_command(ph, command);
        debug_print("command sent");
}

/**
 * Called every so often; if idle time > timeout, set /away.
 *
 * NB: assumes the away status is synchronised between different servers.
 */
static int checkTimeout(void *userdata)
{
        const char * awayinfo = xchat_get_info(ph, "away");

        XScreenSaverQueryInfo(display, window, mit_info);

        xchat_printf(ph, "Idle time = %u ms.", mit_info->idle);
        
        if (mit_info->idle > idleThreshold * 1000)
        {
                if (awayinfo == NULL)
                {
                        debug_print("Going away!");
                        send_command(ph, awayCommand);
                }
                else
                {
                        debug_print("already away.");
                }
        }
        else
        {
                if (awayinfo != NULL)
                {
                        // Only set back if we set away in the first place
                        if (strncmp(awayinfo, awayText, strlen(awayText)) == 0)
                        {
                                debug_print("we're back.");
                                send_command(ph, "allserv back");
                        }
                }
                else
                {
                        debug_print("still back.");
                }
        }

        return 1;
}

int xchat_plugin_init(xchat_plugin *plugin_handle,
        char **plugin_name,
        char **plugin_desc,
        char **plugin_version,
        char **arg)
{
        ph = plugin_handle;

        *plugin_name = "idle";
        *plugin_desc = "sets /away automatically";
        *plugin_version = "0.1";

        snprintf(awayCommand, awayCommandLength, "allserv away %s", awayText);

        display = XOpenDisplay(NULL);
        if (display == NULL)
                return 0;
        
        window = DefaultRootWindow(display);
        if (window == 0)
                return 0;

        if (! XScreenSaverQueryExtension(display, &event_base, &error_base))
                return 0;

        mit_info = XScreenSaverAllocInfo();

        xchat_hook_timer(ph, 10 * 1000, checkTimeout, NULL);
        //xchat_hook_command(ph, "CHECKTIMEOUT", XCHAT_PRI_NORM, (void 
*)checkTimeout, "blah", NULL);

        xchat_print(ph, "idle plugin loaded.");

        return 1;
}

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages xchat depends on:
ii  libatk1.0-0            1.26.0-1          The ATK accessibility toolkit
ii  libc6                  2.9-12            GNU C Library: Shared libraries
ii  libcairo2              1.8.6-2+b1        The Cairo 2D vector graphics libra
ii  libdbus-1-3            1.2.12-1          simple interprocess messaging syst
ii  libdbus-glib-1-2       0.80-4            simple interprocess messaging syst
ii  libfontconfig1         2.6.0-3           generic font configuration library
ii  libfreetype6           2.3.9-4.1         FreeType 2 font engine, shared lib
ii  libglib2.0-0           2.20.1-2          The GLib library of C routines
ii  libgtk2.0-0            2.16.1-2          The GTK+ graphical user interface 
ii  libpango1.0-0          1.24.0-3+b1       Layout and rendering of internatio
ii  libperl5.10            5.10.0-23         Shared Perl library
ii  libsexy2               0.1.11-2+b1       collection of additional GTK+ widg
ii  libssl0.9.8            0.9.8k-3          SSL shared libraries
ii  libx11-6               2:1.2.1-1         X11 client-side library
ii  libxml2                2.7.3.dfsg-1      GNOME XML library
ii  xchat-common           2.8.6-4           Common files for X-Chat
ii  zlib1g                 1:1.2.3.3.dfsg-13 compression library - runtime

Versions of packages xchat recommends:
ii  alsa-utils                    1.0.20-1   ALSA utilities
ii  esound-clients                0.2.41-5   Enlightened Sound Daemon - clients
ii  libnotify-bin                 0.4.5-1    sends desktop notifications to a n
ii  libnotify1                    0.4.5-1    sends desktop notifications to a n
ii  python                        2.5.4-2    An interactive high-level object-o
ii  tcl                           8.4.16-2   The Tool Command Language (default
ii  xdg-utils                     1.0.2-6.1  desktop integration utilities from

xchat suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to