/* 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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#define WANTSOCKET
#include "inet.h"
#ifdef WIN32
#include <windows.h>
#else
#include <sys/wait.h>
#include <signal.h>
#include <unistd.h>
#endif
#include "hexchat.h"
#include "fe.h"
#include "util.h"
#include "cfgfiles.h"
#include "chanopt.h"
#include "ignore.h"
#include "hexchat-plugin.h"
#include "inbound.h"
#include "plugin.h"
#include "plugin-identd.h"
#include "plugin-timer.h"
#include "notify.h"
#include "server.h"
#include "servlist.h"
#include "outbound.h"
#include "text.h"
#include "url.h"
#include "hexchatc.h"
#if ! GLIB_CHECK_VERSION (2, 36, 0)
#include <glib-object.h> /* for g_type_init() */
#endif
#ifdef USE_LIBPROXY
#include <proxy.h>
#endif
GSList *popup_list = 0;
GSList *button_list = 0;
GSList *dlgbutton_list = 0;
GSList *command_list = 0;
GSList *ctcp_list = 0;
GSList *replace_list = 0;
GSList *sess_list = 0;
GSList *dcc_list = 0;
GSList *ignore_list = 0;
GSList *usermenu_list = 0;
GSList *urlhandler_list = 0;
GSList *tabmenu_list = 0;
/*
* This array contains 5 double linked lists, one for each priority in the
* "interesting session" queue ("channel" stands for everything but
* SESS_DIALOG):
*
* [0] queries with hilight
* [1] queries
* [2] channels with hilight
* [3] channels with dialogue
* [4] channels with other data
*
* Each time activity happens the corresponding session is put at the
* beginning of one of the lists. The aim is to be able to switch to the
* session with the most important/recent activity.
*/
GList *sess_list_by_lastact[5] = {NULL, NULL, NULL, NULL, NULL};
static int in_hexchat_exit = FALSE;
int hexchat_is_quitting = FALSE;
/* command-line args */
int arg_dont_autoconnect = FALSE;
int arg_skip_plugins = FALSE;
char *arg_url = NULL;
char **arg_urls = NULL;
char *arg_command = NULL;
gint arg_existing = FALSE;
#ifdef USE_DBUS
#include "dbus/dbus-client.h"
#include "dbus/dbus-plugin.h"
#endif /* USE_DBUS */
struct session *current_tab;
struct session *current_sess = 0;
struct hexchatprefs prefs;
#ifdef USE_LIBPROXY
pxProxyFactory *libproxy_factory;
#endif
/*
* Update the priority queue of the "interesting sessions"
* (sess_list_by_lastact).
*/
void
lastact_update(session *sess)
{
int oldidx = sess->lastact_idx;
int newidx = LACT_NONE;
int dia = (sess->type == SESS_DIALOG);
if (sess->tab_state & TAB_STATE_NEW_HILIGHT)
newidx = dia? LACT_QUERY_HI: LACT_CHAN_HI;
else if (sess->tab_state & TAB_STATE_NEW_MSG)
newidx = dia? LACT_QUERY: LACT_CHAN;
else if (sess->tab_state & TAB_STATE_NEW_DATA)
newidx = dia? LACT_QUERY: LACT_CHAN_DATA;
/* If already first at the right position, just return */
if (oldidx == newidx &&
(newidx == LACT_NONE || g_list_index(sess_list_by_lastact[newidx], sess) == 0))
return;
<