Merge branch 'master' into wdk
This commit is contained in:
commit
0452f9582e
|
@ -16,6 +16,13 @@ highlights. The full CVS log is available at www.xchat.org/cvslog/
|
|||
------------------------------------------------------------------------------
|
||||
- Emit the Topic Change event before setting the topic internally so plugins
|
||||
can access the old topic inside the callback.
|
||||
- Add two options url_grabber and url_grabber_limit.
|
||||
* url_grabber is a boolean for enabling/disabling the url grabber
|
||||
* url_grabber_limit is an integer controlling the number of URLs the
|
||||
URL Grabber will keep around. Setting it to 0 leaves it unlimited as in
|
||||
previous versions.
|
||||
- Fixed a bug with the URL Grabber where it fails to grab a URL if the URL
|
||||
is the first thing in the message.
|
||||
- Perl (Lian Wan Situ)
|
||||
* Added two new options to hook_print, run_after_event and filter. See
|
||||
documentation for details.
|
||||
|
|
|
@ -600,6 +600,8 @@ const struct prefs vars[] = {
|
|||
{"text_transparent", P_OFFINT (transparent), TYPE_BOOL},
|
||||
{"text_wordwrap", P_OFFINT (wordwrap), TYPE_BOOL},
|
||||
|
||||
{"url_grabber", P_OFFINT (url_grabber), TYPE_BOOL},
|
||||
{"url_grabber_limit", P_OFFINT (url_grabber_limit), TYPE_INT},
|
||||
{0, 0, 0},
|
||||
};
|
||||
|
||||
|
@ -719,6 +721,8 @@ load_config (void)
|
|||
prefs.input_flash_priv = prefs.input_flash_hilight = 1;
|
||||
prefs.input_tray_priv = prefs.input_tray_hilight = 1;
|
||||
prefs.autodccsend = 2; /* browse mode */
|
||||
prefs.url_grabber = 1;
|
||||
prefs.url_grabber_limit = 0; /* 0 means unlimited for backcompat */
|
||||
#ifdef WIN32
|
||||
prefs.identd = 1;
|
||||
#endif
|
||||
|
|
|
@ -1159,6 +1159,8 @@ irc_inline (server *serv, char *buf, int len)
|
|||
char pdibuf_static[522]; /* 1 line can potentially be 512*6 in utf8 */
|
||||
char *pdibuf = pdibuf_static;
|
||||
|
||||
url_check_line (buf, len);
|
||||
|
||||
/* need more than 522? fall back to malloc */
|
||||
if (len >= sizeof (pdibuf_static))
|
||||
pdibuf = malloc (len + 1);
|
||||
|
|
|
@ -410,7 +410,6 @@ server_inline (server *serv, char *line, int len)
|
|||
#endif
|
||||
|
||||
fe_add_rawlog (serv, line, len, FALSE);
|
||||
url_check_line (line, len);
|
||||
|
||||
/* let proto-irc.c handle it */
|
||||
serv->p_inline (serv, line, len);
|
||||
|
|
|
@ -150,7 +150,7 @@ tree_find (tree *t, void *key, tree_cmp_func *cmp, void *data, int *pos)
|
|||
return mybsearch (key, &t->array[0], t->elements, cmp, data, pos);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
tree_remove_at_pos (tree *t, int pos)
|
||||
{
|
||||
int post_bytes;
|
||||
|
@ -191,14 +191,9 @@ tree_foreach (tree *t, tree_traverse_func *func, void *data)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
tree_insert (tree *t, void *key)
|
||||
static void
|
||||
tree_grow (tree *t)
|
||||
{
|
||||
int pos, done;
|
||||
|
||||
if (!t)
|
||||
return -1;
|
||||
|
||||
if (t->array_size < t->elements + 1)
|
||||
{
|
||||
int new_size = t->array_size + ARRAY_GROW;
|
||||
|
@ -207,9 +202,33 @@ tree_insert (tree *t, void *key)
|
|||
t->array_size = new_size;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
tree_insert (tree *t, void *key)
|
||||
{
|
||||
int pos, done;
|
||||
|
||||
if (!t)
|
||||
return -1;
|
||||
|
||||
tree_grow (t);
|
||||
pos = tree_find_insertion_pos (t, key, &done);
|
||||
if (!done && pos != -1)
|
||||
tree_insert_at_pos (t, key, pos);
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
void
|
||||
tree_append (tree *t, void *key)
|
||||
{
|
||||
tree_grow (t);
|
||||
tree_insert_at_pos (t, key, t->elements);
|
||||
}
|
||||
|
||||
int tree_size (tree *t)
|
||||
{
|
||||
return t->elements;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,10 @@ tree *tree_new (tree_cmp_func *cmp, void *data);
|
|||
void tree_destroy (tree *t);
|
||||
void *tree_find (tree *t, void *key, tree_cmp_func *cmp, void *data, int *pos);
|
||||
int tree_remove (tree *t, void *key, int *pos);
|
||||
void tree_remove_at_pos (tree *t, int pos);
|
||||
void tree_foreach (tree *t, tree_traverse_func *func, void *data);
|
||||
int tree_insert (tree *t, void *key);
|
||||
void tree_append (tree* t, void *key);
|
||||
int tree_size (tree *t);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "xchat.h"
|
||||
#include "xchatc.h"
|
||||
#include "cfgfiles.h"
|
||||
#include "fe.h"
|
||||
#include "tree.h"
|
||||
|
@ -89,7 +90,13 @@ url_find (char *urltext)
|
|||
static void
|
||||
url_add (char *urltext, int len)
|
||||
{
|
||||
char *data = malloc (len + 1);
|
||||
char *data;
|
||||
int size;
|
||||
|
||||
if (!prefs.url_grabber)
|
||||
return;
|
||||
|
||||
data = malloc (len + 1);
|
||||
if (!data)
|
||||
return;
|
||||
memcpy (data, urltext, len);
|
||||
|
@ -112,7 +119,18 @@ url_add (char *urltext, int len)
|
|||
if (!url_tree)
|
||||
url_tree = tree_new ((tree_cmp_func *)strcasecmp, NULL);
|
||||
|
||||
tree_insert (url_tree, data);
|
||||
size = tree_size (url_tree);
|
||||
/* 0 is unlimited */
|
||||
if (prefs.url_grabber_limit > 0 && size >= prefs.url_grabber_limit)
|
||||
{
|
||||
/* the loop is necessary to handle having the limit lowered while
|
||||
xchat is running */
|
||||
size -= prefs.url_grabber_limit;
|
||||
for(; size > 0; size--)
|
||||
tree_remove_at_pos (url_tree, 0);
|
||||
}
|
||||
|
||||
tree_append (url_tree, data);
|
||||
fe_url_add (data);
|
||||
}
|
||||
|
||||
|
@ -259,10 +277,25 @@ url_check_line (char *buf, int len)
|
|||
{
|
||||
case 0:
|
||||
case ' ':
|
||||
|
||||
wlen = po - start;
|
||||
if (wlen > 2)
|
||||
{
|
||||
if (url_check_word (start, wlen) == WORD_URL)
|
||||
/* HACK! :( */
|
||||
/* This is to work around not being able to detect URLs that are at
|
||||
the start of messages. */
|
||||
if (start[0] == ':')
|
||||
{
|
||||
start++;
|
||||
wlen--;
|
||||
}
|
||||
if (start[0] == '+' || start[0] == '-')
|
||||
{
|
||||
start++;
|
||||
wlen--;
|
||||
}
|
||||
|
||||
if (wlen > 2 && url_check_word (start, wlen) == WORD_URL)
|
||||
{
|
||||
url_add (start, wlen);
|
||||
}
|
||||
|
|
|
@ -321,6 +321,8 @@ struct xchatprefs
|
|||
unsigned int msg_number_limit; /*same deal */
|
||||
unsigned int msg_time_limit;
|
||||
|
||||
unsigned int url_grabber;
|
||||
unsigned int url_grabber_limit;
|
||||
/* Tells us if we need to save, only when they've been edited.
|
||||
This is so that we continue using internal defaults (which can
|
||||
change in the next release) until the user edits them. */
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <gtk/gtkcellrenderertext.h>
|
||||
|
||||
#include "../common/xchat.h"
|
||||
#include "../common/xchatc.h"
|
||||
#include "../common/cfgfiles.h"
|
||||
#include "../common/fe.h"
|
||||
#include "../common/url.h"
|
||||
|
@ -152,6 +153,7 @@ fe_url_add (const char *urltext)
|
|||
{
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
gboolean valid;
|
||||
|
||||
if (urlgrabberwindow)
|
||||
{
|
||||
|
@ -161,6 +163,15 @@ fe_url_add (const char *urltext)
|
|||
gtk_list_store_set (store, &iter,
|
||||
URL_COLUMN, urltext,
|
||||
-1);
|
||||
|
||||
/* remove any overflow */
|
||||
if (prefs.url_grabber_limit > 0)
|
||||
{
|
||||
valid = gtk_tree_model_iter_nth_child (
|
||||
GTK_TREE_MODEL (store), &iter, NULL, prefs.url_grabber_limit);
|
||||
while (valid)
|
||||
valid = gtk_list_store_remove (store, &iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,5 +215,11 @@ url_opengui ()
|
|||
|
||||
gtk_widget_show (urlgrabberwindow);
|
||||
|
||||
if (prefs.url_grabber)
|
||||
tree_foreach (url_tree, (tree_traverse_func *)populate_cb, NULL);
|
||||
else
|
||||
{
|
||||
gtk_list_store_clear (GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (view))));
|
||||
fe_url_add ("URL Grabber is disabled.");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue