X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=WHOHandler.c;h=f924e463f7bf1c44eb826a7133f9669e932751bd;hb=795115bf680185ae01043bd1222b78bfed8c1d87;hp=f3da915702ead4f66634790982391896eab614d9;hpb=ba6862f5ec0d37fa2f3bde08e21fa7c4b00a9c4f;p=NeonServV5.git diff --git a/WHOHandler.c b/WHOHandler.c index f3da915..f924e46 100644 --- a/WHOHandler.c +++ b/WHOHandler.c @@ -32,12 +32,13 @@ static struct WHOQueueEntry* addWHOQueueEntry(struct ClientSocket *client) { } entry->next = NULL; entry->client = client; - if(last_entry) + if(last_entry) { last_entry->next = entry; - else last_entry = entry; - if(!first_entry) + } else { + last_entry = entry; first_entry = entry; + } return entry; } @@ -78,6 +79,22 @@ void get_userlist(struct ChanNode *chan, userlist_callback_t callback, void *dat putsock(bot, "WHO %s,%d %%tuhnaf,%d", chan->name, entry->type, entry->type); } +void get_userlist_with_invisible(struct ChanNode *chan, 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)) + break; + } + if(bot == NULL) return; + struct WHOQueueEntry* entry = addWHOQueueEntry(bot); + entry->type = WHOQUEUETYPE_ISONQUEUE | WHOQUEUETYPE_USERLIST; + entry->chan = chan; + entry->callback = callback; + entry->data = data; + //WHO ".$channel->getName().",".$id." d%tuhnaf,".$id + putsock(bot, "WHO %s,%d d%%tuhnaf,%d", chan->name, entry->type, entry->type); +} + void get_userauth(struct UserNode *user, userauth_callback_t callback, void *data) { struct ClientSocket *bot; for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) { @@ -106,10 +123,6 @@ void recv_whohandler_354(struct ClientSocket *client, char **argv, unsigned int //:OGN2.OnlineGamesNet.net 354 skynet 1 pk910 2001:41d0:2:1d3b::babe skynet H@ pk910 struct ChanNode *chan = entry->chan; //add the user toe the channel if he isn't added, yet and update its user data - struct UserNode *user = getUserByNick(argv[4]); - if(user == NULL) { - user = addUser(argv[4]); - } //parse flags int userflags = 0; int chanuserflags = 0; @@ -124,15 +137,32 @@ void recv_whohandler_354(struct ClientSocket *client, char **argv, unsigned int case '*': userflags |= USERFLAG_ISIRCOP; break; + case '<': + chanuserflags |= CHANUSERFLAG_INVISIBLE; + break; default: break; } } - user->flags = (user->flags & ~USERFLAG_ISIRCOP) | userflags; - if(!isUserOnChan(user, chan)) { - struct ChanUser *chanuser = addChanUser(chan, user); + + struct UserNode *user; + if(chanuserflags & CHANUSERFLAG_INVISIBLE) { + user = createTempUser(argv[4]); + user->flags |= USERFLAG_ISTMPUSER; + chan->flags |= CHANFLAG_HAVE_INVISIBLES; + struct ChanUser *chanuser = addInvisibleChanUser(chan, user); chanuser->flags = (chanuser->flags & ~CHANUSERFLAG_OPPED_OR_VOICED) | chanuserflags; + } else { + user = getUserByNick(argv[4]); + if(user == NULL) { + user = addUser(argv[4]); + } + if(!isUserOnChan(user, chan)) { + struct ChanUser *chanuser = addChanUser(chan, user); + chanuser->flags = (chanuser->flags & ~CHANUSERFLAG_OPPED_OR_VOICED) | chanuserflags; + } } + user->flags = (user->flags & ~USERFLAG_ISIRCOP) | userflags; if(!*user->ident) strcpy(user->ident, argv[2]); if(!*user->host) @@ -143,13 +173,13 @@ void recv_whohandler_354(struct ClientSocket *client, char **argv, unsigned int } } else if(type & WHOQUEUETYPE_USERAUTH) { //:OGN2.OnlineGamesNet.net 354 Skynet 1 pk910 2001:41d0:2:1d3b::babe Skynet pk910 - entry->flags |= WHOQUEUETYPE_FOUND; - if(!strcmp(argv[5], "0") && !(entry->user->flags & USERFLAG_ISAUTHED)) { + entry->type |= WHOQUEUETYPE_FOUND; + if(strcmp(argv[5], "0") && !(entry->user->flags & USERFLAG_ISAUTHED)) { strcpy(entry->user->auth, argv[5]); entry->user->flags |= USERFLAG_ISAUTHED; } userauth_callback_t *callback = entry->callback; - callback(client, entry->user, entry->data); + callback(client, entry->user->nick, entry->user, entry->data); } } @@ -165,10 +195,20 @@ void recv_whohandler_315(struct ClientSocket *client, char **argv, unsigned int entry->chan->flags |= CHANFLAG_RECEIVED_USERLIST; userlist_callback_t *callback = entry->callback; callback(client, entry->chan, entry->data); + if(entry->chan->flags & CHANFLAG_HAVE_INVISIBLES) { + //remove all invisible users again + struct ChanUser *chanuser, *next; + for(chanuser = getChannelUsers(entry->chan, NULL); chanuser; chanuser = next) { + next = getChannelUsers(entry->chan, chanuser); + if(chanuser->flags & CHANUSERFLAG_INVISIBLE) { + delChanUser(chanuser, 1); + } + } + } } else if(type & WHOQUEUETYPE_USERAUTH) { - if(!(entry->flags & WHOQUEUETYPE_FOUND)) { + if(!(entry->type & WHOQUEUETYPE_FOUND)) { userauth_callback_t *callback = entry->callback; - callback(client, NULL, entry->data); + callback(client, entry->user->nick, NULL, entry->data); } } free(entry);