hexchat/src/fe-text/fe-text.c

914 lines
17 KiB
C
Raw Permalink Normal View History

2011-02-23 22:14:30 -05:00
/* X-Chat
* Copyright (C) 1998 Peter Zelezny.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2012-12-23 14:36:54 -05:00
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
2011-02-23 22:14:30 -05:00
*/
2014-12-28 12:38:19 -05:00
#include "config.h"
2011-02-23 22:14:30 -05:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
2011-02-28 12:59:32 -05:00
#ifdef WIN32
#include <io.h>
2011-02-28 12:59:32 -05:00
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#else
#include <unistd.h>
2011-02-23 22:14:30 -05:00
#include <sys/time.h>
2011-02-28 12:59:32 -05:00
#endif
2011-02-23 22:14:30 -05:00
#include <sys/types.h>
#include <ctype.h>
2013-03-16 19:17:21 -04:00
#include <glib-object.h>
2012-10-24 15:33:02 -04:00
#include "../common/hexchat.h"
#include "../common/hexchatc.h"
2011-02-28 12:59:32 -05:00
#include "../common/cfgfiles.h"
2011-02-23 22:14:30 -05:00
#include "../common/outbound.h"
#include "../common/util.h"
#include "../common/fe.h"
#include "fe-text.h"
static int done = FALSE; /* finished ? */
static void
send_command (char *cmd)
{
2011-02-28 12:59:32 -05:00
handle_multiline (current_tab, cmd, TRUE, FALSE);
2011-02-23 22:14:30 -05:00
}
2011-02-28 12:59:32 -05:00
static gboolean
handle_line (GIOChannel *channel, GIOCondition cond, gpointer data)
2011-02-23 22:14:30 -05:00
{
2011-02-28 12:59:32 -05:00
gchar *str_return;
gsize length, terminator_pos;
GError *error = NULL;
GIOStatus result;
2011-02-23 22:14:30 -05:00
2011-02-28 12:59:32 -05:00
result = g_io_channel_read_line(channel, &str_return, &length, &terminator_pos, &error);
2013-03-16 21:57:34 -04:00
if (result == G_IO_STATUS_ERROR || result == G_IO_STATUS_EOF) {
2011-02-28 12:59:32 -05:00
return FALSE;
}
else {
send_command(str_return);
g_free(str_return);
return TRUE;
2011-02-23 22:14:30 -05:00
}
}
static int done_intro = 0;
void
fe_new_window (struct session *sess, int focus)
{
char buf[512];
2011-02-28 12:59:32 -05:00
current_sess = sess;
2011-02-23 22:14:30 -05:00
if (!sess->server->front_session)
sess->server->front_session = sess;
if (!sess->server->server_session)
sess->server->server_session = sess;
2011-02-28 12:59:32 -05:00
if (!current_tab || focus)
2011-02-23 22:14:30 -05:00
current_tab = sess;
if (done_intro)
return;
done_intro = 1;
2014-12-17 18:49:59 -05:00
g_snprintf (buf, sizeof (buf),
2011-02-23 22:14:30 -05:00
"\n"
2012-10-13 07:05:01 -04:00
" \017HexChat-Text \00310"PACKAGE_VERSION"\n"
" \017Running on \00310%s\n",
get_sys_str (1));
fe_print_text (sess, buf, 0, FALSE);
2011-02-23 22:14:30 -05:00
fe_print_text (sess, "\n\nCompiled in Features\0032:\017 "
#ifdef USE_PLUGIN
"Plugin "
#endif
#ifdef ENABLE_NLS
"NLS "
#endif
#ifdef USE_OPENSSL
"OpenSSL "
#endif
"\n\n", 0, FALSE);
2011-02-23 22:14:30 -05:00
fflush (stdout);
}
static int
get_stamp_str (time_t tim, char *dest, int size)
{
return strftime_validated (dest, size, prefs.hex_stamp_text_format, localtime (&tim));
2011-02-23 22:14:30 -05:00
}
static int
2011-02-28 12:59:32 -05:00
timecat (char *buf, time_t stamp)
2011-02-23 22:14:30 -05:00
{
char stampbuf[64];
2011-02-28 12:59:32 -05:00
/* set the stamp to the current time if not provided */
if (!stamp)
stamp = time (0);
get_stamp_str (stamp, stampbuf, sizeof (stampbuf));
2011-02-23 22:14:30 -05:00
strcat (buf, stampbuf);
return strlen (stampbuf);
}
2011-02-28 12:59:32 -05:00
/* Windows doesn't handle ANSI codes in cmd.exe, need to not display them */
#ifndef WIN32
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
2011-02-23 22:14:30 -05:00
static const short colconv[] = { 0, 7, 4, 2, 1, 3, 5, 11, 13, 12, 6, 16, 14, 15, 10, 7 };
void
fe_print_text (struct session *sess, char *text, time_t stamp,
gboolean no_activity)
2011-02-23 22:14:30 -05:00
{
int dotime = FALSE;
char num[8];
int reverse = 0, under = 0, bold = 0,
comma, k, i = 0, j = 0, len = strlen (text);
unsigned char *newtext = g_malloc (len + 1024);
2011-02-23 22:14:30 -05:00
2012-10-22 09:55:43 -04:00
if (prefs.hex_stamp_text)
2011-02-23 22:14:30 -05:00
{
newtext[0] = 0;
2011-02-28 12:59:32 -05:00
j += timecat (newtext, stamp);
2011-02-23 22:14:30 -05:00
}
while (i < len)
{
if (dotime && text[i] != 0)
{
dotime = FALSE;
newtext[j] = 0;
2011-02-28 12:59:32 -05:00
j += timecat (newtext, stamp);
2011-02-23 22:14:30 -05:00
}
switch (text[i])
{
case 3:
i++;
if (!isdigit (text[i]))
{
newtext[j] = 27;
j++;
newtext[j] = '[';
j++;
newtext[j] = 'm';
j++;
2011-02-28 12:59:32 -05:00
goto endloop;
2011-02-23 22:14:30 -05:00
}
k = 0;
comma = FALSE;
while (i < len)
{
if (text[i] >= '0' && text[i] <= '9' && k < 2)
{
num[k] = text[i];
k++;
} else
{
int col, mirc;
num[k] = 0;
newtext[j] = 27;
j++;
newtext[j] = '[';
j++;
if (k == 0)
{
newtext[j] = 'm';
j++;
} else
{
if (comma)
col = 40;
else
col = 30;
mirc = atoi (num);
2014-12-28 12:43:53 -05:00
mirc = colconv[mirc % G_N_ELEMENTS(colconv)];
2011-02-23 22:14:30 -05:00
if (mirc > 9)
{
mirc += 50;
sprintf ((char *) &newtext[j], "%dm", mirc + col);
} else
{
sprintf ((char *) &newtext[j], "%dm", mirc + col);
}
j = strlen (newtext);
}
switch (text[i])
{
case ',':
comma = TRUE;
break;
default:
2011-02-28 12:59:32 -05:00
goto endloop;
2011-02-23 22:14:30 -05:00
}
k = 0;
}
i++;
}
break;
2011-02-28 12:59:32 -05:00
/* don't actually want hidden text */
case '\010': /* hidden */
break;
2011-02-23 22:14:30 -05:00
case '\026': /* REVERSE */
if (reverse)
{
reverse = FALSE;
strcpy (&newtext[j], "\033[27m");
} else
{
reverse = TRUE;
strcpy (&newtext[j], "\033[7m");
}
j = strlen (newtext);
break;
case '\037': /* underline */
if (under)
{
under = FALSE;
strcpy (&newtext[j], "\033[24m");
} else
{
under = TRUE;
strcpy (&newtext[j], "\033[4m");
}
j = strlen (newtext);
break;
case '\002': /* bold */
if (bold)
{
bold = FALSE;
strcpy (&newtext[j], "\033[22m");
} else
{
bold = TRUE;
strcpy (&newtext[j], "\033[1m");
}
j = strlen (newtext);
break;
case '\007':
2012-10-22 08:18:20 -04:00
if (!prefs.hex_input_filter_beep)
2011-02-23 22:14:30 -05:00
{
newtext[j] = text[i];
j++;
}
break;
case '\017': /* reset all */
strcpy (&newtext[j], "\033[m");
j += 3;
reverse = FALSE;
bold = FALSE;
under = FALSE;
break;
case '\t':
newtext[j] = ' ';
j++;
break;
case '\n':
newtext[j] = '\r';
j++;
2012-10-22 09:55:43 -04:00
if (prefs.hex_stamp_text)
2011-02-23 22:14:30 -05:00
dotime = TRUE;
default:
newtext[j] = text[i];
j++;
}
i++;
2011-02-28 12:59:32 -05:00
endloop:
;
2011-02-23 22:14:30 -05:00
}
2011-02-28 12:59:32 -05:00
/* make sure last character is a new line */
if (text[i-1] != '\n')
newtext[j++] = '\n';
2011-02-23 22:14:30 -05:00
newtext[j] = 0;
write (STDOUT_FILENO, newtext, j);
g_free (newtext);
2011-02-23 22:14:30 -05:00
}
2011-02-28 12:59:32 -05:00
#else
/* The win32 version for cmd.exe */
2011-02-23 22:14:30 -05:00
void
fe_print_text (struct session *sess, char *text, time_t stamp,
gboolean no_activity)
2011-02-23 22:14:30 -05:00
{
2011-02-28 12:59:32 -05:00
int dotime = FALSE;
int comma, k, i = 0, j = 0, len = strlen (text);
unsigned char *newtext = g_malloc (len + 1024);
2011-02-23 22:14:30 -05:00
2012-10-22 09:55:43 -04:00
if (prefs.hex_stamp_text)
2011-02-23 22:14:30 -05:00
{
2011-02-28 12:59:32 -05:00
newtext[0] = 0;
j += timecat (newtext, stamp);
}
while (i < len)
{
if (dotime && text[i] != 0)
2011-02-23 22:14:30 -05:00
{
2011-02-28 12:59:32 -05:00
dotime = FALSE;
newtext[j] = 0;
j += timecat (newtext, stamp);
2011-02-23 22:14:30 -05:00
}
2011-02-28 12:59:32 -05:00
switch (text[i])
{
case 3:
i++;
if (!isdigit (text[i]))
{
goto endloop;
}
k = 0;
comma = FALSE;
while (i < len)
{
if (text[i] >= '0' && text[i] <= '9' && k < 2)
{
k++;
} else
{
switch (text[i])
{
case ',':
comma = TRUE;
break;
default:
goto endloop;
}
k = 0;
}
i++;
}
break;
/* don't actually want hidden text */
case '\010': /* hidden */
case '\026': /* REVERSE */
case '\037': /* underline */
case '\002': /* bold */
case '\017': /* reset all */
break;
case '\007':
2012-10-22 08:18:20 -04:00
if (!prefs.hex_input_filter_beep)
2011-02-28 12:59:32 -05:00
{
newtext[j] = text[i];
j++;
}
break;
case '\t':
newtext[j] = ' ';
j++;
break;
case '\n':
newtext[j] = '\r';
j++;
2012-10-22 09:55:43 -04:00
if (prefs.hex_stamp_text)
2011-02-28 12:59:32 -05:00
dotime = TRUE;
default:
newtext[j] = text[i];
j++;
}
i++;
endloop:
;
2011-02-23 22:14:30 -05:00
}
2011-02-28 12:59:32 -05:00
/* make sure last character is a new line */
if (text[i-1] != '\n')
newtext[j++] = '\n';
newtext[j] = 0;
write (STDOUT_FILENO, newtext, j);
g_free (newtext);
2011-02-28 12:59:32 -05:00
}
#endif
void
fe_timeout_remove (int tag)
{
g_source_remove (tag);
2011-02-23 22:14:30 -05:00
}
int
fe_timeout_add (int interval, void *callback, void *userdata)
{
2011-02-28 12:59:32 -05:00
return g_timeout_add (interval, (GSourceFunc) callback, userdata);
2011-02-23 22:14:30 -05:00
}
void
fe_input_remove (int tag)
{
2011-02-28 12:59:32 -05:00
g_source_remove (tag);
2011-02-23 22:14:30 -05:00
}
int
fe_input_add (int sok, int flags, void *func, void *data)
{
2011-02-28 12:59:32 -05:00
int tag, type = 0;
GIOChannel *channel;
2011-02-23 22:14:30 -05:00
#ifdef G_OS_WIN32
if (flags & FIA_FD)
channel = g_io_channel_win32_new_fd (sok);
else
channel = g_io_channel_win32_new_socket (sok);
#else
2011-02-28 12:59:32 -05:00
channel = g_io_channel_unix_new (sok);
#endif
2011-02-23 22:14:30 -05:00
2011-02-28 12:59:32 -05:00
if (flags & FIA_READ)
type |= G_IO_IN | G_IO_HUP | G_IO_ERR;
if (flags & FIA_WRITE)
type |= G_IO_OUT | G_IO_ERR;
if (flags & FIA_EX)
type |= G_IO_PRI;
2011-02-23 22:14:30 -05:00
2011-02-28 12:59:32 -05:00
tag = g_io_add_watch (channel, type, (GIOFunc) func, data);
g_io_channel_unref (channel);
return tag;
2011-02-23 22:14:30 -05:00
}
2011-02-28 12:59:32 -05:00
/* === command-line parameter parsing : requires glib 2.6 === */
static char *arg_cfgdir = NULL;
static gint arg_show_autoload = 0;
static gint arg_show_config = 0;
static gint arg_show_version = 0;
static const GOptionEntry gopt_entries[] =
{
{"no-auto", 'a', 0, G_OPTION_ARG_NONE, &arg_dont_autoconnect, N_("Don't auto connect to servers"), NULL},
{"cfgdir", 'd', 0, G_OPTION_ARG_STRING, &arg_cfgdir, N_("Use a different config directory"), "PATH"},
{"no-plugins", 'n', 0, G_OPTION_ARG_NONE, &arg_skip_plugins, N_("Don't auto load any plugins"), NULL},
2012-11-04 15:40:59 -05:00
{"plugindir", 'p', 0, G_OPTION_ARG_NONE, &arg_show_autoload, N_("Show plugin/script auto-load directory"), NULL},
2011-02-28 12:59:32 -05:00
{"configdir", 'u', 0, G_OPTION_ARG_NONE, &arg_show_config, N_("Show user config directory"), NULL},
2013-07-01 14:36:15 -04:00
{"url", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &arg_url, N_("Open an irc://server:port/channel URL"), "URL"},
2011-02-28 12:59:32 -05:00
{"version", 'v', 0, G_OPTION_ARG_NONE, &arg_show_version, N_("Show version information"), NULL},
2013-07-01 14:36:15 -04:00
{G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &arg_urls, N_("Open an irc://server:port/channel?key URL"), "URL"},
2011-02-28 12:59:32 -05:00
{NULL}
};
2011-02-23 22:14:30 -05:00
int
fe_args (int argc, char *argv[])
{
2011-02-28 12:59:32 -05:00
GError *error = NULL;
GOptionContext *context;
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, gopt_entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
2011-02-28 12:59:32 -05:00
if (error)
{
if (error->message)
printf ("%s\n", error->message);
return 1;
}
g_option_context_free (context);
if (arg_show_version)
{
printf (PACKAGE_TARNAME" "PACKAGE_VERSION"\n");
return 0;
}
if (arg_show_autoload)
2011-02-23 22:14:30 -05:00
{
2011-02-28 12:59:32 -05:00
#ifdef WIN32
/* see the chdir() below */
char *sl, *exe = g_strdup (argv[0]);
2011-02-28 12:59:32 -05:00
sl = strrchr (exe, '\\');
if (sl)
2011-02-23 22:14:30 -05:00
{
2011-02-28 12:59:32 -05:00
*sl = 0;
printf ("%s\\plugins\n", exe);
2011-02-23 22:14:30 -05:00
}
g_free (exe);
2011-02-28 12:59:32 -05:00
#else
printf ("%s\n", HEXCHATLIBDIR);
2011-02-28 12:59:32 -05:00
#endif
return 0;
2011-02-23 22:14:30 -05:00
}
2011-02-28 12:59:32 -05:00
if (arg_show_config)
{
2012-11-03 13:24:25 -04:00
printf ("%s\n", get_xdir ());
2011-02-28 12:59:32 -05:00
return 0;
}
if (arg_cfgdir) /* we want filesystem encoding */
{
g_free (xdir);
2012-11-03 13:24:25 -04:00
xdir = strdup (arg_cfgdir);
if (xdir[strlen (xdir) - 1] == '/')
xdir[strlen (xdir) - 1] = 0;
2011-02-28 12:59:32 -05:00
g_free (arg_cfgdir);
}
2011-02-23 22:14:30 -05:00
return -1;
}
void
fe_init (void)
{
2011-02-28 12:59:32 -05:00
/* the following should be default generated, not enfoced in binary */
2012-10-22 07:49:28 -04:00
prefs.hex_gui_tab_server = 0;
prefs.hex_gui_autoopen_dialog = 0;
2011-02-28 12:59:32 -05:00
/* except for these, there is no lag meter, there is no server list */
2012-10-22 07:49:28 -04:00
prefs.hex_gui_lagometer = 0;
prefs.hex_gui_slist_skip = 1;
2011-02-23 22:14:30 -05:00
}
void
fe_main (void)
{
2011-02-28 12:59:32 -05:00
GIOChannel *keyboard_input;
2011-02-23 22:14:30 -05:00
2011-02-28 12:59:32 -05:00
main_loop = g_main_loop_new(NULL, FALSE);
2011-02-23 22:14:30 -05:00
2011-02-28 12:59:32 -05:00
/* Keyboard Entry Setup */
#ifdef G_OS_WIN32
keyboard_input = g_io_channel_win32_new_fd(STDIN_FILENO);
#else
keyboard_input = g_io_channel_unix_new(STDIN_FILENO);
2011-02-23 22:14:30 -05:00
#endif
2011-02-28 12:59:32 -05:00
g_io_add_watch(keyboard_input, G_IO_IN, handle_line, NULL);
2011-02-23 22:14:30 -05:00
2011-02-28 12:59:32 -05:00
g_main_loop_run(main_loop);
2011-02-23 22:14:30 -05:00
2011-02-28 12:59:32 -05:00
return;
2011-02-23 22:14:30 -05:00
}
void
fe_exit (void)
{
done = TRUE;
2011-02-28 12:59:32 -05:00
g_main_loop_quit(main_loop);
2011-02-23 22:14:30 -05:00
}
void
fe_new_server (struct server *serv)
{
}
void
fe_message (char *msg, int flags)
{
puts (msg);
}
void
fe_close_window (struct session *sess)
{
session_free (sess);
done = TRUE;
}
void
2013-01-17 18:52:06 -05:00
fe_beep (session *sess)
2011-02-23 22:14:30 -05:00
{
putchar (7);
}
void
fe_add_rawlog (struct server *serv, char *text, int len, int outbound)
{
}
void
fe_set_topic (struct session *sess, char *topic, char *stripped_topic)
{
}
void
fe_cleanup (void)
{
}
void
fe_set_hilight (struct session *sess)
{
}
void
fe_set_tab_color (struct session *sess, int col)
{
}
void
fe_update_mode_buttons (struct session *sess, char mode, char sign)
{
}
void
fe_update_channel_key (struct session *sess)
{
}
void
fe_update_channel_limit (struct session *sess)
{
}
int
fe_is_chanwindow (struct server *serv)
{
return 0;
}
void
fe_add_chan_list (struct server *serv, char *chan, char *users, char *topic)
{
}
void
fe_chan_list_end (struct server *serv)
{
}
Redesign the Ban List window. Closes Issues #303, #342, #427 This is a combination of 18 commits. The first commit's message is: Here is the initial banlist branch of RichardHitt/hexchat. Changed files are only src/fe-gtk/{banlist.c,fe-gtk.h}. This version works and contains my first efforts at selective sensitization of radio buttons and control buttons. From this point I intend to undertake a stepwise redesign. Step 1 will be to make the existing banlist code work for multiple simultaneous banlist windows (for different channels, obviously). It will be a hackathon with the only goal of getting it working. Step 2 will be the objectization and alpha-stage tidying-up of all the terrible looking stuff I will have done in Step 1. This is the 2nd commit message: Here's the post-Step-1 commit. It works for multiple banlist windows. Note particularly what I've done to banlist.h. Note that for many functions in banlist.c the argument is now a banlist_info *, rather than a session *. Note in banlist.c the initialization of array modes[] which contains driving information for the checkboxes. Of course those checkboxes aren't yet implemented. Maybe in Step 2 I will change to checkboxes from radio buttons; but definitely I will change to letting modes[] drive processing. This is the 3rd commit message: Converted to checkboxes. Much additional work. Note that the infrastructure for Auto-invite is not yet present in the hexchat tree. I'm nearly done with banlist, I think! This is the 4th commit message: Fleshed out 'invite'. Tagged masks uniformly, e.g. (b) (e) (I). General cleanup, nearly at the point of beta quality. This is the 5th commit message: Added fourth mode type: quiet. Did lots and lots of cleanup. Beta-ready? This is the 6th commit message: Get the banlist timestamps properly sortable. This is the 7th commit message: Redesign the supports_foo() routines. Now they're responsible for setting the flags in ->capable, ->readable, ->writeable. This is the 8th commit message: Deleted a couple of RBH comments. This is the 9th commit message: Now the ESC key will close the banlist window. This is the 10th commit message: Fix the fe-text occurrence of fe_add_ban_list(). This is the 11th commit message: Fixed also fe_ban_list_end() and removed fe_is_banwindow(). This is the 12th commit message: Use old-style initialization for array of structures modes[] This is the 13th commit message: Oops, incomplete regression of modes[] initialization. This fixes. This is the 14th commit message: Fixed strptime buy implementing a special version here. Fixed column width concerns by setting resizable and autosize. This is the 15th commit message: Get rid of testing line. This is the 16th commit message: Changed to gtkutil_destroy_on_esc () This is the 17th commit message: Remove no-longer-used functnion This is the 18th commit message: Minor cleanups to banlist.c, banlist.h Please enter the commit message for your changes. Lines starting with '#' will be ignored, and an empty message aborts the commit. Author: RichardHitt <rbh00@netcom.com> Committer: Richard Hitt <rbh00@f17.rbh00.pacbell.net> Not currently on any branch. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: src/common/fe.h modified: src/common/hexchat.h modified: src/common/inbound.c modified: src/common/modes.c modified: src/common/proto-irc.c modified: src/common/server.c modified: src/fe-gtk/banlist.c modified: src/fe-gtk/banlist.h modified: src/fe-gtk/fe-gtk.c modified: src/fe-gtk/fe-gtk.h modified: src/fe-gtk/maingui.c modified: src/fe-text/fe-text.c
2013-03-05 03:13:51 -05:00
gboolean
fe_add_ban_list (struct session *sess, char *mask, char *who, char *when, int rplcode)
2011-02-23 22:14:30 -05:00
{
2013-03-27 03:05:38 -04:00
return 0;
2011-02-23 22:14:30 -05:00
}
Redesign the Ban List window. Closes Issues #303, #342, #427 This is a combination of 18 commits. The first commit's message is: Here is the initial banlist branch of RichardHitt/hexchat. Changed files are only src/fe-gtk/{banlist.c,fe-gtk.h}. This version works and contains my first efforts at selective sensitization of radio buttons and control buttons. From this point I intend to undertake a stepwise redesign. Step 1 will be to make the existing banlist code work for multiple simultaneous banlist windows (for different channels, obviously). It will be a hackathon with the only goal of getting it working. Step 2 will be the objectization and alpha-stage tidying-up of all the terrible looking stuff I will have done in Step 1. This is the 2nd commit message: Here's the post-Step-1 commit. It works for multiple banlist windows. Note particularly what I've done to banlist.h. Note that for many functions in banlist.c the argument is now a banlist_info *, rather than a session *. Note in banlist.c the initialization of array modes[] which contains driving information for the checkboxes. Of course those checkboxes aren't yet implemented. Maybe in Step 2 I will change to checkboxes from radio buttons; but definitely I will change to letting modes[] drive processing. This is the 3rd commit message: Converted to checkboxes. Much additional work. Note that the infrastructure for Auto-invite is not yet present in the hexchat tree. I'm nearly done with banlist, I think! This is the 4th commit message: Fleshed out 'invite'. Tagged masks uniformly, e.g. (b) (e) (I). General cleanup, nearly at the point of beta quality. This is the 5th commit message: Added fourth mode type: quiet. Did lots and lots of cleanup. Beta-ready? This is the 6th commit message: Get the banlist timestamps properly sortable. This is the 7th commit message: Redesign the supports_foo() routines. Now they're responsible for setting the flags in ->capable, ->readable, ->writeable. This is the 8th commit message: Deleted a couple of RBH comments. This is the 9th commit message: Now the ESC key will close the banlist window. This is the 10th commit message: Fix the fe-text occurrence of fe_add_ban_list(). This is the 11th commit message: Fixed also fe_ban_list_end() and removed fe_is_banwindow(). This is the 12th commit message: Use old-style initialization for array of structures modes[] This is the 13th commit message: Oops, incomplete regression of modes[] initialization. This fixes. This is the 14th commit message: Fixed strptime buy implementing a special version here. Fixed column width concerns by setting resizable and autosize. This is the 15th commit message: Get rid of testing line. This is the 16th commit message: Changed to gtkutil_destroy_on_esc () This is the 17th commit message: Remove no-longer-used functnion This is the 18th commit message: Minor cleanups to banlist.c, banlist.h Please enter the commit message for your changes. Lines starting with '#' will be ignored, and an empty message aborts the commit. Author: RichardHitt <rbh00@netcom.com> Committer: Richard Hitt <rbh00@f17.rbh00.pacbell.net> Not currently on any branch. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: src/common/fe.h modified: src/common/hexchat.h modified: src/common/inbound.c modified: src/common/modes.c modified: src/common/proto-irc.c modified: src/common/server.c modified: src/fe-gtk/banlist.c modified: src/fe-gtk/banlist.h modified: src/fe-gtk/fe-gtk.c modified: src/fe-gtk/fe-gtk.h modified: src/fe-gtk/maingui.c modified: src/fe-text/fe-text.c
2013-03-05 03:13:51 -05:00
gboolean
fe_ban_list_end (struct session *sess, int rplcode)
2011-02-23 22:14:30 -05:00
{
2013-03-27 03:05:38 -04:00
return 0;
2011-02-23 22:14:30 -05:00
}
void
fe_notify_update (char *name)
{
}
void
fe_notify_ask (char *name, char *networks)
{
}
void
fe_text_clear (struct session *sess, int lines)
{
}
void
fe_progressbar_start (struct session *sess)
{
}
void
fe_progressbar_end (struct server *serv)
{
}
void
fe_userlist_insert (struct session *sess, struct User *newuser, gboolean sel)
2011-02-23 22:14:30 -05:00
{
}
int
fe_userlist_remove (struct session *sess, struct User *user)
{
return 0;
}
void
fe_userlist_rehash (struct session *sess, struct User *user)
{
}
void
fe_userlist_numbers (struct session *sess)
{
}
void
fe_userlist_clear (struct session *sess)
{
}
void
fe_userlist_set_selected (struct session *sess)
{
}
void
fe_dcc_add (struct DCC *dcc)
{
}
void
fe_dcc_update (struct DCC *dcc)
{
}
void
fe_dcc_remove (struct DCC *dcc)
{
}
void
fe_clear_channel (struct session *sess)
{
}
void
fe_session_callback (struct session *sess)
{
}
void
fe_server_callback (struct server *serv)
{
}
void
fe_url_add (const char *text)
{
}
void
fe_pluginlist_update (void)
{
}
void
fe_buttons_update (struct session *sess)
{
}
void
fe_dlgbuttons_update (struct session *sess)
{
}
void
fe_dcc_send_filereq (struct session *sess, char *nick, int maxcps, int passive)
{
}
void
fe_set_channel (struct session *sess)
{
}
void
fe_set_title (struct session *sess)
{
}
void
fe_set_nonchannel (struct session *sess, int state)
{
}
void
fe_set_nick (struct server *serv, char *newnick)
{
}
void
fe_change_nick (struct server *serv, char *nick, char *newnick)
{
}
void
fe_ignore_update (int level)
{
}
int
fe_dcc_open_recv_win (int passive)
{
return FALSE;
}
int
fe_dcc_open_send_win (int passive)
{
return FALSE;
}
int
fe_dcc_open_chat_win (int passive)
{
return FALSE;
}
void
fe_userlist_hide (session * sess)
{
}
void
fe_lastlog (session *sess, session *lastlog_sess, char *sstr, gtk_xtext_search_flags flags)
2011-02-23 22:14:30 -05:00
{
}
void
fe_set_lag (server * serv, long lag)
2011-02-23 22:14:30 -05:00
{
}
void
fe_set_throttle (server * serv)
{
}
void
fe_set_away (server *serv)
{
}
void
fe_serverlist_open (session *sess)
{
}
void
2013-12-31 17:06:58 -05:00
fe_get_bool (char *title, char *prompt, void *callback, void *userdata)
{
}
void
2011-02-23 22:14:30 -05:00
fe_get_str (char *prompt, char *def, void *callback, void *ud)
{
}
void
fe_get_int (char *prompt, int def, void *callback, void *ud)
{
}
void
fe_idle_add (void *func, void *data)
{
2011-02-28 12:59:32 -05:00
g_idle_add (func, data);
2011-02-23 22:14:30 -05:00
}
void
fe_ctrl_gui (session *sess, fe_gui_action action, int arg)
{
2011-02-28 12:59:32 -05:00
/* only one action type handled for now, but could add more */
switch (action)
{
2012-10-13 07:05:01 -04:00
/* gui focus is really the only case hexchat-text needs to wory about */
2011-02-28 12:59:32 -05:00
case FE_GUI_FOCUS:
current_sess = sess;
current_tab = sess;
sess->server->front_session = sess;
break;
default:
break;
}
2011-02-23 22:14:30 -05:00
}
int
fe_gui_info (session *sess, int info_type)
{
return -1;
}
void *
fe_gui_info_ptr (session *sess, int info_type)
{
return NULL;
}
void fe_confirm (const char *message, void (*yesproc)(void *), void (*noproc)(void *), void *ud)
{
}
char *fe_get_inputbox_contents (struct session *sess)
{
return NULL;
}
void fe_set_inputbox_contents (struct session *sess, char *text)
{
}
int fe_get_inputbox_cursor (struct session *sess)
{
return 0;
}
void fe_set_inputbox_cursor (struct session *sess, int delta, int pos)
{
}
void fe_open_url (const char *url)
{
}
void fe_menu_del (menu_entry *me)
{
}
char *fe_menu_add (menu_entry *me)
{
return NULL;
}
void fe_menu_update (menu_entry *me)
{
}
void fe_uselect (struct session *sess, char *word[], int do_clear, int scroll_to)
{
}
void
fe_server_event (server *serv, int type, int arg)
{
}
void
fe_flash_window (struct session *sess)
{
}
void fe_get_file (const char *title, char *initial,
void (*callback) (void *userdata, char *file), void *userdata,
int flags)
{
}
void fe_tray_set_flash (const char *filename1, const char *filename2, int timeout){}
void fe_tray_set_file (const char *filename){}
void fe_tray_set_icon (feicon icon){}
void fe_tray_set_tooltip (const char *text){}
void fe_userlist_update (session *sess, struct User *user){}
2013-10-13 15:39:17 -04:00
void
fe_open_chan_list (server *serv, char *filter, int do_refresh)
{
serv->p_list_channels (serv, filter, 1);
}
const char *
fe_get_default_font (void)
{
return NULL;
}