Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
BitchX
GitHub Repository: BitchX/BitchX1.3
Path: blob/master/dll/aim/toc.c
1072 views
1
/*
2
* AOL Instant Messanger Module for BitchX
3
*
4
* By Nadeem Riaz ([email protected])
5
*
6
* toc.c
7
*
8
* Interface to libtoc (libtoc -> client)
9
*/
10
11
12
#include <irc.h>
13
#include <struct.h>
14
#include <hook.h>
15
#include <ircaux.h>
16
#include <output.h>
17
#include <lastlog.h>
18
#include <status.h>
19
#include <vars.h>
20
#include <window.h>
21
#include <sys/stat.h>
22
#include <module.h>
23
#include <modval.h>
24
25
#include <string.h>
26
#include <stdlib.h>
27
#include <stdio.h>
28
#include "toc.h"
29
#include "aim.h"
30
31
int sock_read_id;
32
void (*chatprintf)(char *, ...) = statusprintf;
33
34
/* LIBToc Call back functions */
35
36
int toc_add_input_stream(int fd,int (*func)(int)) {
37
sock_read_id = add_socketread(fd, 0, 0, "bleh", func, func);
38
return 1;
39
}
40
41
int toc_remove_input_stream(int fd) {
42
close_socketread(sock_read_id);
43
return 1;
44
}
45
46
int toc_main_interface(int type, char **args) {
47
48
switch (type) {
49
case TOC_IM_IN: {
50
char *msg, *nick;
51
nick = rm_space(args[0]);
52
msg = strip_html(args[1]);
53
RemoveFromLLByKey(msgdus,nick);
54
AddToLL(msgdus,nick,NULL);
55
msgprintf("%s", cparse(fget_string_var(FORMAT_MSG_FSET),
56
"%s %s %s %s",update_clock(GET_TIME),
57
nick, "AIM", msg));
58
if ( is_away )
59
serv_send_im(args[0],away_message);
60
free(nick);
61
break;
62
}
63
case TOC_TRANSLATED_ERROR:
64
case TOC_CONNECT_MSGS:
65
statusprintf(args[0]);
66
break;
67
case TOC_BUDDY_LOGGED_OFF:
68
statusprintf("%s logged off",args[0]);
69
if ( get_dllint_var("aim_window") )
70
build_aim_status(get_window_by_name("AIM"));
71
break;
72
case TOC_BUDDY_LOGGED_ON:
73
statusprintf("%s logged on", args[0]);
74
if ( get_dllint_var("aim_window") )
75
build_aim_status(get_window_by_name("AIM"));
76
break;
77
case TOC_EVILED:
78
statusprintf("You have been warned by %s.", ((args[0] == NULL) ? "an anonymous person" : args[0]));
79
statusprintf("Your new warning level is %s%%" , args[1]);
80
if ( get_dllint_var("aim_window") )
81
build_aim_status(get_window_by_name("AIM"));
82
break;
83
case TOC_CHAT_JOIN:
84
chatprintf("Joined buddy chat %s",args[1]);
85
strncpy(current_chat,args[1],511);
86
break;
87
case TOC_BUDDY_LEFT_CHAT:
88
chatprintf("%s left %s",args[1],args[0]);
89
break;
90
case TOC_BUDDY_JOIN_CHAT:
91
chatprintf("%s joined %s",args[1],args[0]);
92
break;
93
case TOC_CHAT_LEFT:
94
chatprintf("Left chat id: %s",args[0]);
95
break;
96
case TOC_CHAT_IN: {
97
char *e,*name,*chat;
98
/* chatprintf("got msg from chat: <%s@AIM> %s",args[1],args[3]); */
99
/* Need to take better action here */
100
e = strip_html(args[3]);
101
name = rm_space(args[1]);
102
chat = rm_space(args[4]);
103
msgprintf("%s",cparse(fget_string_var(FORMAT_PUBLIC_OTHER_FSET), "%s %s %s %s", update_clock(GET_TIME), name, chat, e));
104
free(name); free(chat);
105
break;
106
}
107
case TOC_GOTO_URL:
108
statusprintf("GOTO_URL: %s",args[0]);
109
break;
110
case TOC_CHAT_INVITE:
111
statusprintf("Invited to %s by %s '%s'",args[0],args[2],args[3]);
112
break;
113
case TOC_LAG_UPDATE:
114
case TOC_WENT_IDLE:
115
if ( get_dllint_var("aim_window") )
116
build_aim_status(get_window_by_name("AIM"));
117
break;
118
case TOC_DIR_STATUS:
119
if ( atoi(args[0]) == 1 )
120
statusprintf("Directory information successfully changed.");
121
else
122
statusprintf("Error altering directory information, error code: %s",args[0]);
123
break;
124
default:
125
statusprintf("INTERNAL ERROR: Unknown toc type: %d",type);
126
}
127
return 1;
128
}
129
130
int toc_timer(int type, char **args) {
131
timer_id = add_timer(0,"aimtime",20000,0,&check_idle,NULL,NULL,0,"aimtime");
132
return 1;
133
}
134
135
/* int toc_buddy_logged_on( */
136
137
void bx_init_toc() {
138
init_toc();
139
strcpy(current_chat,"");
140
/* Setup Hanlders */
141
install_handler(TOC_IM_IN,&toc_main_interface);
142
install_handler(TOC_TRANSLATED_ERROR,&toc_main_interface);
143
install_handler(TOC_CONNECT_MSGS,&toc_main_interface);
144
install_handler(TOC_BUDDY_LOGGED_ON,&toc_main_interface);
145
install_handler(TOC_BUDDY_LOGGED_OFF,&toc_main_interface);
146
install_handler(TOC_EVILED,&toc_main_interface);
147
install_handler(TOC_CHAT_JOIN,&toc_main_interface);
148
install_handler(TOC_BUDDY_LEFT_CHAT,&toc_main_interface);
149
install_handler(TOC_BUDDY_JOIN_CHAT,&toc_main_interface);
150
install_handler(TOC_CHAT_LEFT,&toc_main_interface);
151
install_handler(TOC_CHAT_IN,&toc_main_interface);
152
install_handler(TOC_CHAT_INVITE,&toc_main_interface);
153
install_handler(TOC_GOTO_URL,&toc_main_interface);
154
install_handler(TOC_LAG_UPDATE,&toc_main_interface);
155
install_handler(TOC_WENT_IDLE,&toc_main_interface);
156
install_handler(TOC_DIR_STATUS,&toc_main_interface);
157
install_handler(TOC_REINSTALL_TIMER,&toc_timer);
158
}
159
160