Exemple #1
0
/* call whenever timeout intervals change */
void
hexchat_reinit_timers (void)
{
	static int lag_check_update_tag = 0;
	static int lag_check_tag = 0;
	static int away_tag = 0;

	/* notify timeout */
	if (prefs.hex_notify_timeout && notify_tag == 0)
	{
		notify_tag = fe_timeout_add_seconds (prefs.hex_notify_timeout,
						     notify_checklist, NULL);
	}
	else if (notify_tag != 0)
	{
		fe_timeout_remove (notify_tag);
		notify_tag = 0;
	}

	/* away status tracking */
	if (prefs.hex_away_track && away_tag == 0)
	{
		away_tag = fe_timeout_add_seconds (prefs.hex_away_timeout, away_check, NULL);
	}
	else if (away_tag != 0)
	{
		fe_timeout_remove (away_tag);
		away_tag = 0;
	}

	/* lag-o-meter */
	if (prefs.hex_gui_lagometer && lag_check_update_tag == 0)
	{
		lag_check_update_tag = fe_timeout_add (500, hexchat_lag_check_update, NULL);
	}
	else if (lag_check_update_tag != 0)
	{
		fe_timeout_remove (lag_check_update_tag);
		lag_check_update_tag = 0;
	}

	/* network timeouts and lag-o-meter */
	if ((prefs.hex_net_ping_timeout != 0 || prefs.hex_gui_lagometer)
	    && lag_check_tag == 0)
	{
		lag_check_tag = fe_timeout_add_seconds (30, hexchat_lag_check, NULL);
	}
	else if (lag_check_tag != 0)
	{
		fe_timeout_remove (lag_check_tag);
		lag_check_tag = 0;
	}
}
Exemple #2
0
void
clear_channel (session *sess)
{
	if (sess->channel[0])
		strcpy (sess->waitchannel, sess->channel);
	sess->channel[0] = 0;
	sess->doing_who = FALSE;
	sess->done_away_check = FALSE;

	log_close (sess);

	if (sess->current_modes)
	{
		free (sess->current_modes);
		sess->current_modes = NULL;
	}

	if (sess->mode_timeout_tag)
	{
		fe_timeout_remove (sess->mode_timeout_tag);
		sess->mode_timeout_tag = 0;
	}

	fe_clear_channel (sess);
	userlist_clear (sess);
	fe_set_nonchannel (sess, FALSE);
	fe_set_title (sess);
}
Exemple #3
0
void
inbound_identified (server *serv)	/* 'MODE +e MYSELF' on freenode */
{
	if (serv->joindelay_tag)
	{
		/* stop waiting, just auto JOIN now */
		fe_timeout_remove (serv->joindelay_tag);
		serv->joindelay_tag = 0;
		check_autojoin_channels (serv);
	}
}
Exemple #4
0
void *
hexchat_unhook (hexchat_plugin *ph, hexchat_hook *hook)
{
	/* perl.c trips this */
	if (!g_slist_find (hook_list, hook) || hook->type == HOOK_DELETED)
		return NULL;

	if (hook->type == HOOK_TIMER && hook->tag != 0)
		fe_timeout_remove (hook->tag);

	if (hook->type == HOOK_FD && hook->tag != 0)
		fe_input_remove (hook->tag);

	hook->type = HOOK_DELETED;	/* expunge later */

	g_free (hook->name);	/* NULL for timers & fds */
	g_free (hook->help_text);	/* NULL for non-commands */

	return hook->userdata;
}
Exemple #5
0
void* xchat_unhook(xchat_plugin *ph, xchat_hook *hook)
{
	// perl.c trips this
	if (!g_slist_find(hook_list, hook) || hook->type == HOOK_DELETED)
		return nullptr;

	if (hook->type == HOOK_TIMER && hook->tag != 0)
		fe_timeout_remove(hook->tag);

	if (hook->type == HOOK_FD && hook->tag != 0)
		fe_input_remove(hook->tag);

	hook->type = HOOK_DELETED;	// expunge later

	if (hook->name)
		free(hook->name);	// nullptr for timers & fds
	if (hook->help_text)
		free(hook->help_text);	// nullptr for non-commands

	return hook->userdata;
}
Exemple #6
0
void
fe_progressbar_end (struct session *sess)
{
    struct server *serv;
    GSList *list = sess_list;

    if (sess)
    {
        serv = sess->server;
        while (list)				  /* check all windows that use this server and  *
										   * remove the connecting graph, if it has one. */
        {
            sess = (struct session *) list->data;
            if (sess->server == serv && sess->gui->bar)
            {
                if (GTK_IS_WIDGET (sess->gui->bar))
                    gtk_widget_destroy (sess->gui->bar);
                sess->gui->bar = 0;
                fe_timeout_remove (sess->server->bartag);
            }
            list = list->next;
        }
    }
}
Exemple #7
0
void
fe_main (void)
{
    struct timeval timeout, now;
    socketevent *se;
    timerevent *te;
    fd_set rd, wd, ex;
    GSList *list;
    guint64 shortest, delay;

    if (!sess_list)
        new_ircwindow (NULL, NULL, SESS_SERVER, 0);

    while (!done)
    {
        FD_ZERO (&rd);
        FD_ZERO (&wd);
        FD_ZERO (&ex);

        list = se_list;
        while (list)
        {
            se = (socketevent *) list->data;
            if (se->rread)
                FD_SET (se->sok, &rd);
            if (se->wwrite)
                FD_SET (se->sok, &wd);
            if (se->eexcept)
                FD_SET (se->sok, &ex);
            list = list->next;
        }

        FD_SET (STDIN_FILENO, &rd);   /* for reading keyboard */

        /* find the shortest timeout event */
        shortest = 0;
        list = tmr_list;
        while (list)
        {
            te = (timerevent *) list->data;
            if (te->next_call < shortest || shortest == 0)
                shortest = te->next_call;
            list = list->next;
        }
        gettimeofday (&now, NULL);
        delay = shortest - ((now.tv_sec * 1000) + (now.tv_usec / 1000));
        timeout.tv_sec = delay / 1000;
        timeout.tv_usec = (delay % 1000) * 1000;

        select (FD_SETSIZE, &rd, &wd, &ex, &timeout);

        if (FD_ISSET (STDIN_FILENO, &rd))
            read_stdin ();

        /* set all checked flags to false */
        list = se_list;
        while (list)
        {
            se = (socketevent *) list->data;
            se->checked = 0;
            list = list->next;
        }

        /* check all the socket callbacks */
        list = se_list;
        while (list)
        {
            se = (socketevent *) list->data;
            se->checked = 1;
            if (se->rread && FD_ISSET (se->sok, &rd))
            {
                se->callback (NULL, 1, se->userdata);
            }
            else if (se->wwrite && FD_ISSET (se->sok, &wd))
            {
                se->callback (NULL, 2, se->userdata);
            }
            else if (se->eexcept && FD_ISSET (se->sok, &ex))
            {
                se->callback (NULL, 4, se->userdata);
            }
            list = se_list;
            if (list)
            {
                se = (socketevent *) list->data;
                while (se->checked)
                {
                    list = list->next;
                    if (!list)
                        break;
                    se = (socketevent *) list->data;
                }
            }
        }

        /* now check our list of timeout events, some might need to be called! */
        gettimeofday (&now, NULL);
        list = tmr_list;
        while (list)
        {
            te = (timerevent *) list->data;
            list = list->next;
            if (now.tv_sec * 1000 + (now.tv_usec / 1000) >= te->next_call)
            {
                /* if the callback returns 0, it must be removed */
                if (te->callback (te->userdata) == 0)
                {
                    fe_timeout_remove (te->tag);
                }
                else
                {
                    te->next_call =
                        now.tv_sec * 1000 + (now.tv_usec / 1000) +
                        te->interval;
                }
            }
        }

    }
}