/* 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 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #include #include #include #include #include #ifndef WIN32 #include #endif #include "fe-gtk.h" #include "../common/hexchat.h" #include "../common/fe.h" #include "../common/modes.h" #include "../common/outbound.h" #include "../common/hexchatc.h" #include "gtkutil.h" #include "maingui.h" #include "banlist.h" /* * These supports_* routines set capable, readable, writable bits */ static void supports_bans (banlist_info *, int); static void supports_exempt (banlist_info *, int); static void supports_invite (banlist_info *, int); static void supports_quiet (banlist_info *, int); static mode_info modes[MODE_CT] = { { N_("Bans"), N_("Ban"), 'b', RPL_BANLIST, RPL_ENDOFBANLIST, 1<res->banlist->treeview); } static GtkListStore * get_store (struct session *sess) { return GTK_LIST_STORE (gtk_tree_view_get_model (get_view (sess))); } static void supports_bans (banlist_info *banl, int i) { int bit = 1<capable |= bit; banl->readable |= bit; banl->writeable |= bit; return; } static void supports_exempt (banlist_info *banl, int i) { server *serv = banl->sess->server; char *cm = serv->chanmodes; int bit = 1<have_except) goto yes; if (!cm) return; while (*cm) { if (*cm == ',') break; if (*cm == 'e') goto yes; cm++; } return; yes: banl->capable |= bit; banl->writeable |= bit; } static void supports_invite (banlist_info *banl, int i) { server *serv = banl->sess->server; char *cm = serv->chanmodes; int bit = 1<have_invite) goto yes; if (!cm) return; while (*cm) { if (*cm == ',') break; if (*cm == 'I') goto yes; cm++; } return; yes: banl->capable |= bit; banl->writeable |= bit; } static void supports_quiet (banlist_info *banl, int i) { server *serv = banl->sess->server; char *cm = serv->chanmodes; int bit = 1<capable |= bit; banl->readable |= bit; banl->writeable |= bit; } /* fe_add_ban_list() and fe_ban_list_end() return TRUE if consumed, FALSE otherwise */ gboolean fe_add_ban_list (struct session *sess, char *mask, char *who, char *when, int rplcode) { banlist_info *banl = sess->res->banlist; int i; GtkListStore *store; GtkTreeIter iter; if (!banl) return FALSE; for (i = 0; i < MODE_CT; i++) if (modes[i].code == rplcode) break; if (i == MODE_CT) { /* printf ("Unexpected value in fe_add_ban_list: %d\n", rplcode); */ return FALSE; } if (banl->pending & 1<line_ct++; return TRUE; } else return FALSE; } /* Sensitize checkboxes and buttons as appropriate for the moment */ static void banlist_sensitize (banlist_info *banl) { int checkable, i; gboolean is_op = FALSE; if (banl->sess->me == NULL) return; /* FIXME: More access levels than these can unban */ if (banl->sess->me->op || banl->sess->me->hop) is_op = TRUE; /* CHECKBOXES -- */ checkable = is_op? banl->writeable: banl->readable; for (i = 0; i < MODE_CT; i++) { if (banl->checkboxes[i] == NULL) continue; if ((checkable & 1<checkboxes[i], FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (banl->checkboxes[i]), FALSE); } else /* Checkbox is checkable. Be sure it's sensitive. */ { gtk_widget_set_sensitive (banl->checkboxes[i], TRUE); } } /* BUTTONS --- */ if (!is_op || banl->line_ct == 0) { /* If user is not op or list is empty, buttons should be all greyed */ gtk_widget_set_sensitive (banl->but_clear, FALSE); gtk_widget_set_sensitive (banl->but_crop, FALSE); gtk_widget_set_sensitive (banl->but_remove, FALSE); } else { /* If no lines are selected, only the CLEAR button should be sensitive */ if (banl->select_ct == 0) { gtk_widget_set_sensitive (banl->but_clear, TRUE); gtk_widget_set_sensitive (banl->but_crop, FALSE); gtk_widget_set_sensitive (banl->but_remove, FALSE); } /* If any lines are selected, only the REMOVE and CROP buttons should be sensitive */ else { gtk_widget_set_sensitive (banl->but_clear, FALSE); gtk_widget_set_sensitive (banl->but_crop, banl->line_ct == banl->select_ct? FALSE: TRUE); gtk_widget_set_sensitive (banl->but_remove, TRUE); } } /* Set "Refresh" sensitvity */ gtk_widget_set_sensitive (banl->but_refresh, banl->pending? FALSE: banl->checked? TRUE: FALSE); } /* fe_ban_list_end() returns TRUE if consumed, FALSE otherwise */ gbool
/* HexChat
 * Copyright (C) 1998-2010 Peter Zelezny.
 * Copyright (C) 2009-2013 Berke Viktor.
 *
 * 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
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include "proto-irc.h"

#ifndef HEXCHAT_NOTIFY_H
#define HEXCHAT_NOTIFY_H

struct notify
{
	char *name;
	char *networks;	/* network names, comma sep */
	GSList *server_list;
};

struct notify_per_server
{
	struct server *server;
	struct notify *notify;
	time_t laston;
	time_t lastseen;
	time_t lastoff;
	unsigned int ison:1;
};

extern GSList *notify_list;
extern int notify_tag;

/* the WATCH stuff */
void notify_set_online (server * serv, char *nick,
								const message_tags_data *tags_data);
void notify_set_offline (server * serv, char *nick, int quiet,
								 const message_tags_data *tags_data);
/* the MONITOR stuff */
void notify_set_online_list (server * serv, char *users,
								const message_tags_data *tags_data);
void notify_set_offline_list (server * serv, char *users, int quiet,
								 const message_tags_data *tags_data);
void notify_send_watches (server * serv);

/* the general stuff */
void notify_adduser (char *name, char *networks);
int notify_deluser (char *name);
void notify_cleanup (void);
void notify_load (void);
void notify_save (void);
void notify_showlist (session *sess, const message_tags_data *tags_data);
gboolean notify_is_in_list (server *serv, char *name);
int notify_isnotify (session *sess, char *name);
struct notify_per_server *notify_find_server_entry (struct notify *