multiple fixes
[NeonServV5.git] / src / HandleInfoHandler.c
index 6e5415ffe40381af7b894b72cc37f97d512a156a..c6a2efe808d2447330084c5396584613f64c2c9b 100644 (file)
@@ -21,6 +21,7 @@
 #include "ChanNode.h"
 #include "IRCEvents.h"
 #include "tools.h"
+#include "modules.h"
 
 #define AUTHSERV_NICK "AuthServ"
 
@@ -29,6 +30,7 @@
 struct HandleInfoQueueEntry {
     char *auth;
     void *callback[MAXCALLBACKS];
+    int module_id[MAXCALLBACKS];
     void *data[MAXCALLBACKS];
     
     struct HandleInfoQueueEntry *next;
@@ -79,7 +81,7 @@ void clear_handleinfoqueue(struct ClientSocket *client) {
     DESYNCHRONIZE(cache_sync);
 }
 
-void lookup_authname(char *auth, authlookup_callback_t callback, void *data) {
+void lookup_authname(char *auth, int module_id, authlookup_callback_t callback, void *data) {
     struct ClientSocket *bot;
     struct HandleInfoQueueEntry* entry;
     for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
@@ -89,6 +91,7 @@ void lookup_authname(char *auth, authlookup_callback_t callback, void *data) {
                 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;
                     }
@@ -103,6 +106,7 @@ void lookup_authname(char *auth, authlookup_callback_t callback, void *data) {
     int i;
     entry->auth = strdup(auth);
     entry->callback[0] = callback;
+    entry->module_id[0] = module_id;
     for(i = 1; i < MAXCALLBACKS; i++)
         entry->callback[i] = NULL;
     entry->data[0] = data;
@@ -224,7 +228,8 @@ static void recv_notice(struct UserNode *user, struct UserNode *target, char *me
             for(i = 0; i < MAXCALLBACKS; i++) {
                 callback = entry->callback[i];
                 if(!callback) break;
-                callback(entry->auth, exists, registered, entry->data[i]);
+                if(!entry->module_id[i] || module_loaded(entry->module_id[i]))
+                    callback(entry->auth, exists, registered, entry->data[i]);
             }
             free(entry->auth);
             free(entry);
@@ -233,7 +238,7 @@ static void recv_notice(struct UserNode *user, struct UserNode *target, char *me
 }
 
 void init_handleinfohandler() {
-    bind_privnotice(recv_notice);
+    bind_privnotice(recv_notice, 0);
 }
 
 void free_handleinfohandler() {