rearranged NeonServ code to be modular
[NeonServV5.git] / src / cmd_neonserv_voiceall.c
diff --git a/src/cmd_neonserv_voiceall.c b/src/cmd_neonserv_voiceall.c
deleted file mode 100644 (file)
index 779110c..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/* cmd_neonserv_voiceall.c - NeonServ v5.3
- * Copyright (C) 2011-2012  Philipp Kreil (pk910)
- * 
- * 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 3 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, see <http://www.gnu.org/licenses/>. 
- */
-
-#include "cmd_neonserv.h"
-
-/*
-* argv[0]    (optional) nick mask
-*/
-static USERLIST_CALLBACK(neonserv_cmd_voiceall_userlist_lookup);
-static void neonserv_cmd_voiceall_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nickmask);
-
-struct neonserv_cmd_voiceall_cache {
-    struct ClientSocket *client, *textclient;
-    struct UserNode *user;
-    struct Event *event;
-    char *nickmask;
-};
-
-CMD_BIND(neonserv_cmd_voiceall) {
-    struct neonserv_cmd_voiceall_cache *cache = malloc(sizeof(*cache));
-    if (!cache) {
-        perror("malloc() failed");
-        return;
-    }
-    cache->client = client;
-    cache->textclient = getTextBot();
-    cache->user = user;
-    cache->event = event;
-    if(argc > 0) {
-        cache->nickmask = strdup(argv[0]);
-    } else
-        cache->nickmask = NULL;
-    get_userlist_if_invisible(chan, neonserv_cmd_voiceall_userlist_lookup, cache);
-}
-
-static USERLIST_CALLBACK(neonserv_cmd_voiceall_userlist_lookup) {
-    struct neonserv_cmd_voiceall_cache *cache = data;
-    neonserv_cmd_voiceall_async1(cache->client, cache->textclient, cache->user, chan, cache->event, cache->nickmask);
-    if(cache->nickmask)
-        free(cache->nickmask);
-    free(cache);
-}
-
-static void neonserv_cmd_voiceall_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nickmask) {
-    int done_users = 0;
-    struct ChanUser *chanuser;
-    struct ModeBuffer *modeBuf;
-    modeBuf = initModeBuffer(client, chan);
-    for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) {
-        if(nickmask && match(nickmask, chanuser->user->nick)) continue;
-        if(chanuser->flags & CHANUSERFLAG_VOICED) continue;
-        modeBufferVoice(modeBuf, chanuser->user->nick);
-        done_users++;
-    }
-    freeModeBuffer(modeBuf);
-    reply(textclient, user, "NS_VOICEALL_DONE", done_users, chan->name);
-    if(done_users)
-        logEvent(event);
-}