コード例 #1
0
ファイル: nicklist.c プロジェクト: svn2github/irssi
static void nicklist_update_flags(IRC_SERVER_REC *server, const char *nick, int gone, int ircop)
{
	GSList *nicks, *tmp;
	CHANNEL_REC *channel;
	NICK_REC *rec;

	g_return_if_fail(server != NULL);
	g_return_if_fail(nick != NULL);

	nicks = nicklist_get_same(server, nick);
	for (tmp = nicks; tmp != NULL; tmp = tmp->next->next) {
		channel = tmp->data;
		rec = tmp->next->data;

		rec->last_check = time(NULL);

		if (gone != -1 && rec->gone != gone) {
			rec->gone = gone;
			signal_emit("nick gone changed", 2, channel, rec);
		}

		if (ircop != -1 && rec->ircop != ircop) {
			rec->ircop = ircop;
			signal_emit("nick ircop changed", 2, channel, rec);
		}
	}
	g_slist_free(nicks);
}
コード例 #2
0
ファイル: irc-nicklist.c プロジェクト: svn2github/irssi
static void event_whois(const char *data, IRC_SERVER_REC *server)
{
	char *params, *nick, *realname;
	GSList *nicks, *tmp;
	NICK_REC *rec;

	g_return_if_fail(data != NULL);

	server->whois_coming = TRUE;

	/* first remove the gone-flag, if user is gone
	   it will be set later.. */
	params = event_get_params(data, 6, NULL, &nick, NULL,
				  NULL, NULL, &realname);

	nicks = nicklist_get_same(SERVER(server), nick);
	for (tmp = nicks; tmp != NULL; tmp = tmp->next->next) {
		rec = tmp->next->data;

		if (rec->realname == NULL)
			rec->realname = g_strdup(realname);
	}
	g_slist_free(nicks);

	/* reset gone and ircop status, we'll handle them in the following
	   WHOIS replies */
	nicklist_update_flags(SERVER(server), nick, FALSE, FALSE);
	g_free(params);
}
コード例 #3
0
ファイル: massjoin.c プロジェクト: svn2github/irssi
static void event_quit(IRC_SERVER_REC *server, const char *data,
		       const char *nick)
{
        IRC_CHANNEL_REC *channel;
	NICK_REC *nickrec;
	GSList *nicks, *tmp;

	g_return_if_fail(data != NULL);

	if (g_strcasecmp(nick, server->nick) == 0) {
		/* you quit, don't do anything here */
		return;
	}

	/* Remove nick from all channels */
	nicks = nicklist_get_same(SERVER(server), nick);
	for (tmp = nicks; tmp != NULL; tmp = tmp->next->next) {
                channel = tmp->data;
		nickrec = tmp->next->data;

		if (nickrec->send_massjoin) {
			/* quick join/quit after which it's useless to
			   send nick in massjoin */
			channel->massjoins--;
		}
		nicklist_remove(CHANNEL(channel), nickrec);
	}
	g_slist_free(nicks);
}
コード例 #4
0
static PyObject *PyServer_nicks_get_same(PyServer *self, PyObject *args, PyObject *kwds)
{
    static char *kwlist[] = {"nick", NULL};
    char *nick = "";
    GSList *list, *node;
    PyObject *pylist = NULL;

    RET_NULL_IF_INVALID(self->data);

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, 
           &nick))
        return NULL;
    
    pylist = PyList_New(0);
    if (!pylist)
        return NULL;

    list = nicklist_get_same(self->data, nick);
    for (node = list; node != NULL; node = node->next->next)
    {
        int ret;
        PyObject *tup;

        tup = Py_BuildValue("(NN)", 
                py_irssi_chat_new(node->data, 1), 
                py_irssi_chat_new(node->next->data, 1));
        if (!tup)
        {
            Py_XDECREF(pylist);
            return NULL;
        }
        
        ret = PyList_Append(pylist, tup);
        Py_DECREF(tup);
        if (ret != 0)
        {
            Py_XDECREF(pylist);
            return NULL;
        }
    }

    return pylist;
}
コード例 #5
0
ファイル: irc-nicklist.c プロジェクト: svn2github/irssi
static void event_nick(const char *data, SERVER_REC *server,
		       const char *orignick)
{
	IRC_CHANNEL_REC *channel;
	NICK_REC *nickrec;
	GSList *nicks, *tmp;
	char *params, *nick;

	g_return_if_fail(data != NULL);

	params = event_get_params(data, 1, &nick);

	if (g_strcasecmp(orignick, server->nick) == 0) {
		/* You changed your nick */
		g_free(server->connrec->nick);
		g_free(server->nick);
		server->connrec->nick = g_strdup(nick);
		server->nick = g_strdup(nick);
		signal_emit("server nick changed", 1, server);
	}

	nicks = nicklist_get_same(server, orignick);
	for (tmp = nicks; tmp != NULL; tmp = tmp->next->next) {
		channel = tmp->data;
		nickrec = tmp->next->data;

		/* remove old nick from hash table */
		g_hash_table_remove(channel->nicks, nickrec->nick);

		g_free(nickrec->nick);
		nickrec->nick = g_strdup(nick);

		/* add new nick to hash table */
		g_hash_table_insert(channel->nicks, nickrec->nick, nickrec);

		signal_emit("nicklist changed", 3, channel, nickrec, orignick);
	}
	g_slist_free(nicks);

	g_free(params);
}
コード例 #6
0
ファイル: nicklist.c プロジェクト: GPF/irssi
void nicklist_update_flags(SERVER_REC *server, const char *nick,
			   int gone, int serverop)
{
	nicklist_update_flags_list(server, gone, serverop,
				   nicklist_get_same(server, nick));
}
コード例 #7
0
ファイル: nicklist.c プロジェクト: GPF/irssi
void nicklist_rename(SERVER_REC *server, const char *old_nick,
		     const char *new_nick)
{
	nicklist_rename_list(server, NULL, old_nick, new_nick,
			     nicklist_get_same(server, old_nick));
}
コード例 #8
0
ファイル: massjoin.c プロジェクト: svn2github/irssi
/* Massjoin support - really useful when trying to do things (like op/deop)
   to people after netjoins. It sends
   "massjoin #channel nick!user@host nick2!user@host ..." signals */
static void event_join(IRC_SERVER_REC *server, const char *data,
		       const char *nick, const char *address)
{
	char *params, *channel, *ptr;
	IRC_CHANNEL_REC *chanrec;
	NICK_REC *nickrec;
	GSList *nicks, *tmp;

	g_return_if_fail(data != NULL);

	if (g_strcasecmp(nick, server->nick) == 0) {
		/* You joined, no need to do anything here */
		return;
	}

	params = event_get_params(data, 1, &channel);
	ptr = strchr(channel, 7); /* ^G does something weird.. */
	if (ptr != NULL) *ptr = '\0';

	/* find channel */
	chanrec = irc_channel_find(server, channel);
	g_free(params);
	if (chanrec == NULL) return;

	/* check that the nick isn't already in nicklist. seems to happen
	   sometimes (server desyncs or something?) */
	nickrec = nicklist_find(CHANNEL(chanrec), nick);
	if (nickrec != NULL) {
		/* destroy the old record */
		nicklist_remove(CHANNEL(chanrec), nickrec);
	}

	/* add user to nicklist */
	nickrec = irc_nicklist_insert(chanrec, nick, FALSE, FALSE, FALSE, TRUE);
        nicklist_set_host(CHANNEL(chanrec), nickrec, address);

	if (chanrec->massjoins == 0) {
		/* no nicks waiting in massjoin queue */
		chanrec->massjoin_start = time(NULL);
		chanrec->last_massjoins = 0;
	}

	if (nickrec->realname == NULL) {
		/* Check if user is already in some other channel,
		   get the realname and other stuff from there */
		nicks = nicklist_get_same(SERVER(server), nick);
		for (tmp = nicks; tmp != NULL; tmp = tmp->next->next) {
			NICK_REC *rec = tmp->next->data;

			if (rec->realname != NULL) {
				nickrec->last_check = rec->last_check;
				nickrec->realname = g_strdup(rec->realname);
				nickrec->gone = rec->gone;
				break;
			}
		}
		g_slist_free(nicks);
	}

	chanrec->massjoins++;
}