X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FWHOHandler.c;h=3294e3802f3a244575dc0a1901795f379138f16e;hb=a40e0df080a82db2b1150492a8952cdfe3559185;hp=28547188eb3f0e0f2e22213a98af3a344ccdf5c5;hpb=2b9e305af713f0960ac0cd7645af3e0ef85a8515;p=NeonServV5.git diff --git a/src/WHOHandler.c b/src/WHOHandler.c index 2854718..3294e38 100644 --- a/src/WHOHandler.c +++ b/src/WHOHandler.c @@ -1,4 +1,4 @@ -/* WHOHandler.c - NeonServ v5.3 +/* WHOHandler.c - NeonServ v5.6 * Copyright (C) 2011-2012 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -22,6 +22,7 @@ #include "ModeNode.h" #include "ClientSocket.h" #include "IPNode.h" +#include "modules.h" #define WHOQUEUETYPE_ISONQUEUE 0x01 #define WHOQUEUETYPE_USERLIST 0x02 @@ -29,7 +30,7 @@ #define WHOQUEUETYPE_CHECKTYPE 0x07 #define WHOQUEUETYPE_FOUND 0x08 -#define MAXCALLBACKS 3 +#define MAXCALLBACKS 10 struct WHOQueueEntry { char type; @@ -38,6 +39,7 @@ struct WHOQueueEntry { struct UserNode *user; struct WHOQueueEntry *next; void *callback[MAXCALLBACKS]; + int module_id[MAXCALLBACKS]; void *data[MAXCALLBACKS]; }; @@ -114,7 +116,7 @@ void clear_whoqueue(struct ClientSocket *client) { DESYNCHRONIZE(whohandler_sync); } -void get_userlist(struct ChanNode *chan, userlist_callback_t callback, void *data) { +void get_userlist(struct ChanNode *chan, int module_id, userlist_callback_t callback, void *data) { struct ClientSocket *bot; for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) { if(isUserOnChan(bot->user, chan)) @@ -137,6 +139,7 @@ void get_userlist(struct ChanNode *chan, userlist_callback_t callback, void *dat entry->type = WHOQUEUETYPE_ISONQUEUE | WHOQUEUETYPE_USERLIST; entry->chan = chan; entry->callback[0] = callback; + entry->module_id[0] = module_id; int i; for(i = 1; i < MAXCALLBACKS; i++) entry->callback[i] = NULL; @@ -148,7 +151,7 @@ void get_userlist(struct ChanNode *chan, userlist_callback_t callback, void *dat callback(bot, chan, data); } -void _get_userlist_with_invisible(struct ChanNode *chan, userlist_callback_t callback, void *data, int force) { +void _get_userlist_with_invisible(struct ChanNode *chan, int module_id, userlist_callback_t callback, void *data, int force) { struct ClientSocket *bot; for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) { if(isUserOnChan(bot->user, chan)) @@ -172,6 +175,7 @@ void _get_userlist_with_invisible(struct ChanNode *chan, userlist_callback_t cal entry->type = WHOQUEUETYPE_ISONQUEUE | WHOQUEUETYPE_USERLIST; entry->chan = chan; entry->callback[0] = callback; + entry->module_id[0] = module_id; int i; for(i = 1; i < MAXCALLBACKS; i++) entry->callback[i] = NULL; @@ -183,7 +187,7 @@ void _get_userlist_with_invisible(struct ChanNode *chan, userlist_callback_t cal callback(bot, chan, data); } -void get_userauth(struct UserNode *user, userauth_callback_t callback, void *data) { +void get_userauth(struct UserNode *user, int module_id, userauth_callback_t callback, void *data) { //check if we have already an active WHO for this user struct ClientSocket *bot, *whobot = NULL; struct WHOQueueEntry *entry; @@ -194,6 +198,7 @@ void get_userauth(struct UserNode *user, userauth_callback_t callback, void *dat for(i = 1; i < MAXCALLBACKS; i++) { if(!entry->callback[i]) { entry->callback[i] = callback; + entry->module_id[i] = module_id; entry->data[i] = data; return; } @@ -210,7 +215,7 @@ void get_userauth(struct UserNode *user, userauth_callback_t callback, void *dat callback(bot, user->nick, NULL, data); return; } - if((user->flags & (USERFLAG_ISAUTHED | USERFLAG_ISIRCOP | USERFLAG_ISBOT | USERFLAG_ISSERVER)) || (time(0) - user->last_who) <= REWHO_TIMEOUT) { + if((user->flags & (USERFLAG_ISAUTHED | USERFLAG_ISSERVER)) || (time(0) - user->last_who) <= REWHO_TIMEOUT) { callback(bot, user->nick, user, data); return; } @@ -219,6 +224,7 @@ void get_userauth(struct UserNode *user, userauth_callback_t callback, void *dat entry->user = user; user->flags |= USERFLAG_IS_ON_WHO_QUEUE; entry->callback[0] = callback; + entry->module_id[0] = module_id; int i; for(i = 1; i < MAXCALLBACKS; i++) entry->callback[i] = NULL; @@ -279,11 +285,9 @@ static void _recv_whohandler_354(struct ClientSocket *client, char **argv, unsig struct UserNode *user = getUserByNick(argv[5]); struct ChanUser *chanuser; - if((chanuserflags & CHANUSERFLAG_INVISIBLE)) { - if(!user) { - user = createTempUser(argv[5]); - user->flags |= USERFLAG_ISTMPUSER; - } + if((chanuserflags & CHANUSERFLAG_INVISIBLE) && (!user || (user && !isBot(user)))) { + user = createTempUser(argv[5]); //always add a temponary user to prevent cache problems when the user joins right now (while it's stored in our cache as being invisible) + user->flags |= USERFLAG_ISTMPUSER; chan->flags |= CHANFLAG_HAVE_INVISIBLES; chanuser = addInvisibleChanUser(chan, user); chanuser->flags = (chanuser->flags & ~CHANUSERFLAG_OPPED_OR_VOICED) | chanuserflags; @@ -319,7 +323,8 @@ static void _recv_whohandler_354(struct ClientSocket *client, char **argv, unsig for(i = 0; i < MAXCALLBACKS; i++) { userauth_callback_t *callback = entry->callback[i]; if(!callback) break; - callback(client, entry->user->nick, entry->user, entry->data[i]); + if(!entry->module_id[i] || module_loaded(entry->module_id[i])) + callback(client, entry->user->nick, entry->user, entry->data[i]); } } } @@ -352,7 +357,8 @@ static void _recv_whohandler_315(struct ClientSocket *client, char **argv, unsig for(i = 0; i < MAXCALLBACKS; i++) { callback = entry->callback[i]; if(!callback) break; - callback(client, entry->chan, entry->data[i]); + if(!entry->module_id[i] || module_loaded(entry->module_id[i])) + callback(client, entry->chan, entry->data[i]); } if(entry->chan->flags & CHANFLAG_HAVE_INVISIBLES) { //remove all invisible users again @@ -371,7 +377,8 @@ static void _recv_whohandler_315(struct ClientSocket *client, char **argv, unsig for(i = 0; i < MAXCALLBACKS; i++) { callback = entry->callback[i]; if(!callback) break; - callback(client, entry->user->nick, NULL, entry->data[i]); + if(!entry->module_id[i] || module_loaded(entry->module_id[i])) + callback(client, entry->user->nick, NULL, entry->data[i]); } } entry->user->flags &= ~USERFLAG_IS_ON_WHO_QUEUE;