Don't overwrite existing ignores when flooded

Closes #792
This commit is contained in:
TingPing 2013-10-14 17:25:21 -04:00
parent 80cbc74b2b
commit 490b9a91e4
4 changed files with 13 additions and 14 deletions

View File

@ -77,7 +77,7 @@ ignore_exists (char *mask)
*/ */
int int
ignore_add (char *mask, int type) ignore_add (char *mask, int type, gboolean overwrite)
{ {
struct ignore *ig = 0; struct ignore *ig = 0;
int change_only = FALSE; int change_only = FALSE;
@ -94,7 +94,11 @@ ignore_add (char *mask, int type)
return 0; return 0;
ig->mask = strdup (mask); ig->mask = strdup (mask);
ig->type = type;
if (!overwrite && change_only)
ig->type |= type;
else
ig->type = type;
if (!change_only) if (!change_only)
ignore_list = g_slist_prepend (ignore_list, ig); ignore_list = g_slist_prepend (ignore_list, ig);
@ -376,16 +380,14 @@ flood_check (char *nick, char *ip, server *serv, session *sess, int what) /*0=ct
if (ip[i] == '@') if (ip[i] == '@')
break; break;
snprintf (real_ip, sizeof (real_ip), "*!*%s", &ip[i]); snprintf (real_ip, sizeof (real_ip), "*!*%s", &ip[i]);
/*ignore_add (char *mask, int priv, int noti, int chan,
int ctcp, int invi, int unignore, int no_save) */
snprintf (buf, sizeof (buf), snprintf (buf, sizeof (buf),
_("You are being CTCP flooded from %s, ignoring %s\n"), _("You are being CTCP flooded from %s, ignoring %s\n"),
nick, real_ip); nick, real_ip);
PrintText (sess, buf); PrintText (sess, buf);
/*FIXME: only ignore ctcp or all?, its ignoring ctcps for now */ /* ignore CTCP */
ignore_add (real_ip, IG_CTCP); ignore_add (real_ip, IG_CTCP, FALSE);
return 0; return 0;
} }
} }
@ -410,12 +412,9 @@ flood_check (char *nick, char *ip, server *serv, session *sess, int what) /*0=ct
PrintText (sess, buf); PrintText (sess, buf);
serv->msg_last_time = current_time; /*we got the flood, restore all the vars for next one */ serv->msg_last_time = current_time; /*we got the flood, restore all the vars for next one */
serv->msg_counter = 0; serv->msg_counter = 0;
/*ignore_add (char *mask, int priv, int noti, int chan,
int ctcp, int invi, int unignore, int no_save) */
if (prefs.hex_gui_autoopen_dialog) if (prefs.hex_gui_autoopen_dialog)
{ {
/*FIXME: only ignore ctcp or all?, its ignoring ctcps for now */
prefs.hex_gui_autoopen_dialog = 0; prefs.hex_gui_autoopen_dialog = 0;
/* turn it back on in 30 secs */ /* turn it back on in 30 secs */
fe_timeout_add (30000, flood_autodialog_timeout, NULL); fe_timeout_add (30000, flood_autodialog_timeout, NULL);

View File

@ -44,7 +44,7 @@ struct ignore
}; };
struct ignore *ignore_exists (char *mask); struct ignore *ignore_exists (char *mask);
int ignore_add (char *mask, int type); int ignore_add (char *mask, int type, gboolean overwrite);
void ignore_showlist (session *sess); void ignore_showlist (session *sess);
int ignore_del (char *mask, struct ignore *ig); int ignore_del (char *mask, struct ignore *ig);
int ignore_check (char *mask, int type); int ignore_check (char *mask, int type);

View File

@ -2278,7 +2278,7 @@ cmd_ignore (struct session *sess, char *tbuf, char *word[], char *word_eol[])
snprintf (tbuf, TBUFSIZE, "%s!*@*", word[2]); snprintf (tbuf, TBUFSIZE, "%s!*@*", word[2]);
} }
i = ignore_add (mask, type); i = ignore_add (mask, type, TRUE);
if (quiet) if (quiet)
return TRUE; return TRUE;
switch (i) switch (i)

View File

@ -103,7 +103,7 @@ mask_edited (GtkCellRendererText *render, gchar *path, gchar *new, gpointer dat)
/* delete old mask, and add new one with original flags */ /* delete old mask, and add new one with original flags */
ignore_del (old, NULL); ignore_del (old, NULL);
flags = ignore_get_flags (GTK_TREE_MODEL (store), &iter); flags = ignore_get_flags (GTK_TREE_MODEL (store), &iter);
ignore_add (new, flags); ignore_add (new, flags, TRUE);
/* update tree */ /* update tree */
gtk_list_store_set (store, &iter, MASK_COLUMN, new, -1); gtk_list_store_set (store, &iter, MASK_COLUMN, new, -1);
@ -131,7 +131,7 @@ option_toggled (GtkCellRendererToggle *render, gchar *path, gpointer data)
/* update ignore list */ /* update ignore list */
gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, 0, &mask, -1); gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, 0, &mask, -1);
flags = ignore_get_flags (GTK_TREE_MODEL (store), &iter); flags = ignore_get_flags (GTK_TREE_MODEL (store), &iter);
if (ignore_add (mask, flags) != 2) if (ignore_add (mask, flags, TRUE) != 2)
g_warning ("ignore treeview is out of sync!\n"); g_warning ("ignore treeview is out of sync!\n");
g_free (mask); g_free (mask);
@ -244,7 +244,7 @@ ignore_store_new (int cancel, char *mask, gpointer data)
return; return;
} }
ignore_add (mask, flags); ignore_add (mask, flags, TRUE);
gtk_list_store_append (store, &iter); gtk_list_store_append (store, &iter);
/* ignore everything by default */ /* ignore everything by default */