]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_icq.c
* Get/save arbitrary configs
[citadel.git] / citadel / serv_icq.c
index 74c8fbe04ae8eaf14c3dfcafd517f4aa66c1e485..0af084e111e5f597f10964e651e1c25737e4fb30 100644 (file)
@@ -24,6 +24,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <arpa/inet.h>
 
 #include <time.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <limits.h>
 #include "sysdep.h"
-#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
-#endif
 #include "citadel.h"
 #include "server.h"
 #include "dynloader.h"
 #include "tools.h"
 #include "citserver.h"
+#include "locate_host.h"
 #include "msgbase.h"
 #include "sysdep_decls.h"
 #include "support.h"
@@ -53,16 +52,12 @@ struct CtdlICQ_CL {
        DWORD uin;
        char name[32];
        DWORD status;
+       char host[26];
 };
 
 
 /* <ig> */
 
-/* ICQROOM is the name of the room in which each user's ICQ configuration
- * and contact lists will be stored.  (It's a personal room.)
- */
-#define ICQROOM                "My ICQ Config"
-
 /* MIME types to use for storing ICQ stuff */
 #define ICQMIME                "application/x-citadel-icq"     /* configuration */
 #define ICQCLMIME      "application/x-citadel-icq-cl"  /* contact list */
@@ -1793,7 +1788,7 @@ void CtdlICQ_Read_Config(void) {
        char icq_rm[ROOMNAMELEN];
        
        strcpy(hold_rm, CC->quickroom.QRname);
-       MailboxName(icq_rm, &CC->usersupp, ICQROOM);
+       MailboxName(icq_rm, &CC->usersupp, USERCONFIGROOM);
        strcpy(ThisICQ->icq_config, "");
 
        if (getroom(&CC->quickroom, icq_rm) != 0) {
@@ -1804,7 +1799,8 @@ void CtdlICQ_Read_Config(void) {
        /* We want the last (and probably only) config in this room */
        lprintf(9, "We're in <%s> looking for config\n", 
                CC->quickroom.QRname);
-       CtdlForEachMessage(MSGS_LAST, 1, ICQMIME, CtdlICQ_Read_Config_Backend);
+       CtdlForEachMessage(MSGS_LAST, 1, ICQMIME, NULL,
+               CtdlICQ_Read_Config_Backend);
        getroom(&CC->quickroom, hold_rm);
        return;
 }
@@ -1826,7 +1822,7 @@ void CtdlICQ_Write_Config(void) {
        fclose(fp);
 
        /* this handy API function does all the work for us */
-       CtdlWriteObject(ICQROOM, ICQMIME, temp, 1, 0, 1);
+       CtdlWriteObject(USERCONFIGROOM, ICQMIME, temp, &CC->usersupp, 0, 1, 0);
 
        unlink(temp);
 }
@@ -1856,7 +1852,7 @@ void CtdlICQ_Write_CL(void) {
        fclose(fp);
 
        /* this handy API function does all the work for us */
-       CtdlWriteObject(ICQROOM, ICQCLMIME, temp, 1, 0, 1);
+       CtdlWriteObject(USERCONFIGROOM, ICQCLMIME, temp, &CC->usersupp, 0, 1, 0);
 
        unlink(temp);
 }
@@ -1917,7 +1913,7 @@ void CtdlICQ_Read_CL(void) {
        char icq_rm[ROOMNAMELEN];
        
        strcpy(hold_rm, CC->quickroom.QRname);
-       MailboxName(icq_rm, &CC->usersupp, ICQROOM);
+       MailboxName(icq_rm, &CC->usersupp, USERCONFIGROOM);
        strcpy(ThisICQ->icq_config, "");
 
        if (getroom(&CC->quickroom, icq_rm) != 0) {
@@ -1932,7 +1928,8 @@ void CtdlICQ_Read_CL(void) {
        }
 
        /* We want the last (and probably only) list in this room */
-       CtdlForEachMessage(MSGS_LAST, 1, ICQCLMIME, CtdlICQ_Read_CL_Backend);
+       CtdlForEachMessage(MSGS_LAST, 1, ICQCLMIME, NULL,
+               CtdlICQ_Read_CL_Backend);
        getroom(&CC->quickroom, hold_rm);
 }
 
@@ -2277,7 +2274,7 @@ void CtdlICQ_rwho(void) {
                        0,      /* no session ID */
                        ThisICQ->icq_cl[i].name,
                        icq_ConvertStatus2Str(ThisICQ->icq_cl[i].status),
-                       " ",    /* FIX add host */
+                       ThisICQ->icq_cl[i].host,
                        " ",    /* no client */
                        time(NULL),     /* now? */
                        " ",    /* no last command */
@@ -2303,7 +2300,11 @@ void CtdlICQ_Logged(void) {
 void CtdlICQ_UserOnline(DWORD uin, DWORD status, DWORD ip,
                        DWORD port, DWORD realip) {
 
+       DWORD decoded_ip;
+       
        CtdlICQ_Status_Update(uin, status);
+       decoded_ip = ntohl(ip);
+       locate_host(CtdlICQ_CLent(uin)->host, (struct in_addr *)&decoded_ip);
 }