Updating ChangeLog for 4.22.10
[centerim.git] / src / hooks / yahoohook.h
blob8e6e3b9c042a051029b38ad057f759b29023b415
1 #ifndef __YAHOOHOOK_H__
2 #define __YAHOOHOOK_H__
4 #include "abstracthook.h"
6 #ifdef BUILD_YAHOO
8 #include "icqconf.h"
10 #define USE_STRUCT_CALLBACKS
11 #include "yahoo2_callbacks.h"
13 class yahoohook: public abstracthook {
14 protected:
15 enum Action {
16 tbdConfLogon
19 struct connect_callback_data {
20 yahoo_connect_callback callback;
21 void *callback_data;
22 int id, tag;
25 struct y_c {
26 int fd;
27 bool ssl;
28 int state;
29 y_c(int afd, bool assl, int astate) : fd(afd), ssl(assl), state(astate) { }
32 struct yfd {
33 struct y_c con;
34 int tag;
35 void *data;
36 bool isconnect;
37 yahoo_input_condition cond;
39 static int connection_tags;
41 yfd(int afd, void *adata, bool assl, yahoo_input_condition acond, bool aisconnect = false)
42 : con(afd, assl, 0), tag(connection_tags++), data(adata), isconnect(aisconnect), cond(acond) {}
44 bool operator == (int atag) const { return tag == atag; }
45 bool operator != (int atag) const { return tag != atag; }
48 vector<yfd> fds;
49 vector<pair<Action, string> > tobedone;
51 vector<char *> sfiles;
52 map<const char *, imfile> srfiles;
54 map<imfile, string> fvalid;
55 map<string, string> awaymessages;
57 bool fonline, flogged, searchonlineonly;
58 map<string, vector<string> > confmembers;
59 imstatus ourstatus;
60 int cid;
62 time_t timer_refresh, timer_close;
64 static void login_response(int id, int succ, const char *url);
65 static void got_buddies(int id, YList *buds);
66 static void got_identities(int id, YList *ids);
67 static void status_changed(int id, const char *who, int stat, const char *msg, int away, int idle, int mobile);
68 static void got_im(int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8);
69 static void got_conf_invite(int id, const char *me, const char *who, const char *room, const char *msg, YList *members);
70 static void conf_userdecline(int id, const char *me, const char *who, const char *room, const char *msg);
71 static void conf_userjoin(int id, const char *me, const char *who, const char *room);
72 static void conf_userleave(int id, const char *me, const char *who, const char *room);
73 static void conf_message(int id, const char *me, const char *who, const char *room, const char *msg, int utf8);
74 static void got_file(int id, const char *me, const char *who, const char *msg, const char *fname, unsigned long fesize, char *trid);
75 static void contact_added(int id, const char *myid, const char *who, const char *msg);
76 static void typing_notify(int id, const char *me, const char *who, int stat);
77 static void game_notify(int id, const char *me, const char *who, int stat, const char *msg);
78 static void mail_notify(int id, const char *from, const char *subj, int cnt);
79 static void system_message(int id, const char *me, const char *who, const char *msg);
80 static void got_ping(int id, const char *msg);
81 static void error(int id, const char *err, int fatal, int num);
82 static void got_ignore(int id, YList * igns);
83 static void got_cookies(int id);
84 static void got_search_result(int id, int found, int start, int total, YList *contacts);
85 static void chat_cat_xml(int id, const char *xml);
86 static void chat_join(int id, const char *me, const char *room, const char *topic, YList *members, void *fd);
87 static void chat_userjoin(int id, const char *me, const char *room, struct yahoo_chat_member *who);
88 static void chat_userleave(int id, const char *me, const char *room, const char *who);
89 static void chat_message(int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8);
90 static void rejected(int id, const char *who, const char *msg);
91 static void got_webcam_image(int id, const char * who, const unsigned char *image, unsigned int image_size, unsigned int real_size, unsigned int timestamp);
92 static void webcam_invite(int id, const char *me, const char *from);
93 static void webcam_invite_reply(int id, const char *me, const char *from, int accept);
94 static void webcam_closed(int id, const char *who, int reason);
95 static void webcam_viewer(int id, const char *who, int connect);
96 static void webcam_data_request(int id, int send);
97 static void got_buddyicon_request(int id, const char *me, const char *who);
98 static void got_buddyicon(int id, const char *me, const char *who, const char *url, int checksum);
99 static void auth_request(int id, const char *who, const char *msg);
100 static void auth_response(int id, const char *who, char granted, const char *msg);
101 static void buddyicon_uploaded(int id, const char *url);
102 static void chat_yahooerror(int id, const char *me);
103 static void chat_yahoologout(int id, const char *me);
104 static int yahoo_connect(const char *host, int port);
105 static void file_transfer_done(int id, int result, void *data);
106 static char *get_ip_addr(const char *domain);
107 static void got_buddy_change_group(int id, const char *me, const char *who, const char *old_group, const char *new_group);
108 static void got_buddyicon_checksum(int id, char const *me, const char *who, int checksum);
109 static void got_buzz(int id, const char *me, const char *who, long tm);
110 static void got_ft_data(int id, const unsigned char *in, int len, void *data);
112 static int ylog(const char *fmt, ...);
114 static int add_handler(int id, void *fd, yahoo_input_condition cond, void *data);
115 static void remove_handler(int id, int tag);
116 static int connect_async(int id, const char *host, int port, yahoo_connect_callback callback, void *data, int use_ssl);
117 static int y_write(void *fd, char *buf, int len);
118 static int y_read(void *fd, char *buf, int len);
119 static void y_close(void *fd);
121 static void get_fd(int id, void *fd, int error, void *data);
122 static void get_url(int id, int fd, int error, const char *filename,
123 unsigned long size, void *data);
125 static struct tm *timestamp();
126 static imstatus yahoo2imstatus(int status);
128 string decode(string text, bool utf);
130 YList *getmembers(const string &room);
131 void userstatus(const string &nick, int st, const string &message, bool away);
132 void disconnected();
134 void checkinlist(imcontact ic);
135 void sendnewuser(const imcontact &ic, bool report);
136 void removeuser(const imcontact &ic, bool report);
138 void connect_complete(void *data, struct y_c *con);
140 public:
141 yahoohook();
142 ~yahoohook();
144 void init();
146 void connect();
147 void main();
148 void exectimers();
149 void disconnect();
151 void getsockets(fd_set &rs, fd_set &ws, fd_set &es, int &hsocket) const;
152 bool isoursocket(fd_set &rs, fd_set &ws, fd_set &es) const;
154 bool online() const;
155 bool logged() const;
156 bool isconnecting() const;
157 bool enabled() const;
159 void sendnewuser(const imcontact &ic);
160 void removeuser(const imcontact &ic);
161 void requestinfo(const imcontact &ic);
163 bool send(const imevent &ev);
165 void setautostatus(imstatus st);
166 imstatus getstatus() const;
168 void lookup(const imsearchparams &params, verticalmenu &dest);
170 bool knowntransfer(const imfile &fr) const;
171 void replytransfer(const imfile &fr, bool accept, const string &localpath = string());
172 void aborttransfer(const imfile &fr);
174 void requestawaymsg(const imcontact &ic);
175 void conferencecreate(const imcontact &confid, const vector<imcontact> &lst);
177 void updatecontact(icqcontact *c);
178 void renamegroup(const string &oldname, const string &newname);
181 extern yahoohook yhook;
183 #endif
185 #endif