/* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #include #include #include #include #include #include #include #ifdef WIN32 #include #else #include #endif #include "hexchat.h" #include "notify.h" #include "cfgfiles.h" #include "fe.h" #include "server.h" #include "text.h" #include "util.h" #include "hexchatc.h" GSList *notify_list = 0; int notify_tag = 0; static char * despacify_dup (char *str) { char *p, *res = malloc (strlen (str) + 1); p = res; while (1) { if (*str != ' ') { *p = *str; if (*p == 0) return res; p++; } str++; } } static int notify_netcmp (char *str, void *serv) { char *net = despacify_dup (server_get_network (serv, TRUE)); if (rfc_casecmp (str, net) == 0) { free (net); return 0; /* finish & return FALSE from token_foreach() */ } free (net); return 1; /* keep going... */ } /* monitor this nick on this particular network? */ static gboolean notify_do_network (struct notify *notify, server *serv) { if (!notify->networks) /* ALL networks for this nick */ return TRUE; if (token_foreach (notify->networks, ',', notify_netcmp, serv)) return FALSE; /* network list doesn't contain this one */ return TRUE; } struct notify_per_server * notify_find_server_entry (struct notify *notify, struct server *serv) { GSList *list = notify->server_list; struct notify_per_server *servnot; while (list) { servnot = (struct notify_per_server *) list->data; if (servnot->server == serv) return servnot; list = list->next; } /* not found, should we add it, or is this not a network where we're monitoring this nick? */ if (!notify_do_network (notify, serv)) return NULL; servnot = malloc (sizeof (struct notify_per_server)); if (servnot) { memset (servnot, 0, sizeof (struct notify_per_server)); servnot->server = serv; servnot->notify = notify; notify->server_list = g_slist_prepend (notify->server_list, servnot); } return servnot; } void notify_save (void) { int fh; struct notify *notify; GSList *list = notify_list; fh = hexchat_open_file ("notify.conf", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE); if (fh != -1) { while (list) { notify = (struct notify *) list->data; write (fh, notify->name, strlen (notify->name)); if (notify->networks) { write (fh, " ", 1); write (fh, notify->networks, strlen (notify->networks)); } write (fh, "\n", 1); list = list->next; } close (fh); } } void notify_load (void) { int fh; char buf[256]; char *sep; fh = hexchat_open_file ("notify.conf", O_RDONLY, 0, 0); if (fh != -1) { while (waitline (fh, buf, sizeof buf, FALSE) != -1) { if (buf[0] != '#' && buf[0] != 0) { sep = strchr (buf, ' '); if (sep) { sep[0] = 0; notify_adduser (buf, sep + 1); } else notify_adduser (buf, NULL); } } close (fh); } } static struct notify_per_server * notify_find (server *serv, char *nick) { GSList *list = notify_list; struct notify_per_server *servnot; struct notify *notify; while (list) { notify = (struct notify *) list->data; servnot = notify_find_server_entry (notify, serv); if (!servnot) { list = list->next; continue; } if (!serv->p_cmp (notify->name, nick)) return servnot; list = list->next; } return 0; } static void notify_announce_offline (server * serv, struct notify_per_server *servnot, char *nick, int quiet) { session *sess; sess = serv->front_session; servnot->ison = FALSE; servnot->lastoff = time (0); if (!quiet) EMIT_SIGNAL (XP_TE_NOTIFYOFFLINE, sess, nick, serv->servername, server_get_network (serv, TRUE), NULL, 0); fe_notify_update (nick); fe_notify_update (0); } static void noti
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    name="HexChat"
    processorArchitecture="*"
    version="1.0.0.0"
    type="win32"
  />
  <description>HexChat IRC Client</description>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="*"
        publicKeyToken="6595b64144ccf1df"
        language="*"
      />
    </dependentAssembly>
  </dependency>
</assembly>
notify->name = strdup (name); } if (networks) notify->networks = despacify_dup (networks); notify->server_list = 0; notify_list = g_slist_prepend (notify_list, notify); notify_checklist (); fe_notify_update (notify->name); fe_notify_update (0); notify_watch_all (notify, TRUE); } } gboolean notify_is_in_list (server *serv, char *name) { struct notify *notify; GSList *list = notify_list; while (list) { notify = (struct notify *) list->data; if (!serv->p_cmp (notify->name, name)) return TRUE; list = list->next; } return FALSE; } int notify_isnotify (struct session *sess, char *name) { struct notify *notify; struct notify_per_server *servnot; GSList *list = notify_list; while (list) { notify = (struct notify *) list->data; if (!sess->server->p_cmp (notify->name, name)) { servnot = notify_find_server_entry (notify, sess->server); if (servnot && servnot->ison) return TRUE; } list = list->next; } return FALSE; } void notify_cleanup () { GSList *list = notify_list; GSList *nslist, *srvlist; struct notify *notify; struct notify_per_server *servnot; struct server *serv; int valid; while (list) { /* Traverse the list of notify structures */ notify = (struct notify *) list->data; nslist = notify->server_list; while (nslist) { /* Look at each per-server structure */ servnot = (struct notify_per_server *) nslist->data; /* Check the server is valid */ valid = FALSE; srvlist = serv_list; while (srvlist) { serv = (struct server *) srvlist->data; if (servnot->server == serv) { valid = serv->connected; /* Only valid if server is too */ break; } srvlist = srvlist->next; } if (!valid) { notify->server_list = g_slist_remove (notify->server_list, servnot); free (servnot); nslist = notify->server_list; } else { nslist = nslist->next; } } list = list->next; } fe_notify_update (0); }