propagate from branch 'im.pidgin.pidgin' (head 1d77c730a1160c77d14354d4ce61455e59c94fbc)
[pidgin-git:pidgin-git.git] / libpurple / protocols / yahoo / yahoo.h
1 /**
2  * @file yahoo.h The Yahoo! protocol plugin
3  *
4  * purple
5  *
6  * Purple is the legal property of its developers, whose names are too numerous
7  * to list here.  Please refer to the COPYRIGHT file distributed with this
8  * source distribution.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
23  */
24
25 #ifndef _YAHOO_H_
26 #define _YAHOO_H_
27
28 #include "circbuffer.h"
29 #include "prpl.h"
30
31 #define YAHOO_PAGER_HOST "scs.msg.yahoo.com"
32 #define YAHOO_PAGER_PORT 5050
33 #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/"
34 #define YAHOO_MAIL_URL "https://login.yahoo.com/config/login?.src=ym"
35 #define YAHOO_XFER_HOST "filetransfer.msg.yahoo.com"
36 #define YAHOO_XFER_PORT 80
37 #define YAHOO_ROOMLIST_URL "http://insider.msg.yahoo.com/ycontent/"
38 #define YAHOO_ROOMLIST_LOCALE "us"
39 /* really we should get the list of servers from
40  http://update.messenger.yahoo.co.jp/servers.html */
41 #define YAHOOJP_PAGER_HOST "cs.yahoo.co.jp"
42 #define YAHOOJP_PROFILE_URL "http://profiles.yahoo.co.jp/"
43 #define YAHOOJP_MAIL_URL "http://mail.yahoo.co.jp/"
44 #define YAHOOJP_XFER_HOST "filetransfer.msg.yahoo.co.jp"
45 #define YAHOOJP_WEBCAM_HOST "wc.yahoo.co.jp"
46
47 #define YAHOO_AUDIBLE_URL "http://us.dl1.yimg.com/download.yahoo.com/dl/aud"
48
49 #define WEBMESSENGER_URL "http://login.yahoo.com/config/login?.src=pg"
50
51 #define YAHOO_PICURL_SETTING "picture_url"
52 #define YAHOO_PICCKSUM_SETTING "picture_checksum"
53 #define YAHOO_PICEXPIRE_SETTING "picture_expire"
54
55 #define YAHOO_STATUS_TYPE_OFFLINE "offline"
56 #define YAHOO_STATUS_TYPE_AVAILABLE "available"
57 #define YAHOO_STATUS_TYPE_BRB "brb"
58 #define YAHOO_STATUS_TYPE_BUSY "busy"
59 #define YAHOO_STATUS_TYPE_NOTATHOME "notathome"
60 #define YAHOO_STATUS_TYPE_NOTATDESK "notatdesk"
61 #define YAHOO_STATUS_TYPE_NOTINOFFICE "notinoffice"
62 #define YAHOO_STATUS_TYPE_ONPHONE "onphone"
63 #define YAHOO_STATUS_TYPE_ONVACATION "onvacation"
64 #define YAHOO_STATUS_TYPE_OUTTOLUNCH "outtolunch"
65 #define YAHOO_STATUS_TYPE_STEPPEDOUT "steppedout"
66 #define YAHOO_STATUS_TYPE_AWAY "away"
67 #define YAHOO_STATUS_TYPE_INVISIBLE "invisible"
68 #define YAHOO_STATUS_TYPE_MOBILE "mobile"
69
70 /* Index into attention types list. */
71 #define YAHOO_BUZZ 0
72
73 enum yahoo_status {
74         YAHOO_STATUS_AVAILABLE = 0,
75         YAHOO_STATUS_BRB,
76         YAHOO_STATUS_BUSY,
77         YAHOO_STATUS_NOTATHOME,
78         YAHOO_STATUS_NOTATDESK,
79         YAHOO_STATUS_NOTINOFFICE,
80         YAHOO_STATUS_ONPHONE,
81         YAHOO_STATUS_ONVACATION,
82         YAHOO_STATUS_OUTTOLUNCH,
83         YAHOO_STATUS_STEPPEDOUT,
84         YAHOO_STATUS_INVISIBLE = 12,
85         YAHOO_STATUS_CUSTOM = 99,
86         YAHOO_STATUS_IDLE = 999,
87         YAHOO_STATUS_WEBLOGIN = 0x5a55aa55,
88         YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */
89         YAHOO_STATUS_TYPING = 0x16
90 };
91
92 struct yahoo_buddy_icon_upload_data {
93         PurpleConnection *gc;
94         GString *str;
95         char *filename;
96         int pos;
97         int fd;
98         guint watcher;
99 };
100
101 struct _YchtConn;
102
103 struct yahoo_data {
104         PurpleConnection *gc;
105         int fd;
106         guchar *rxqueue;
107         int rxlen;
108         PurpleCircBuffer *txbuf;
109         guint txhandler;
110         GHashTable *friends;
111
112         /**
113          * This is used to keep track of the IMVironment chosen
114          * by people you talk to.  We don't do very much with
115          * this right now... but at least now if the remote user
116          * selects an IMVironment we won't reset it back to the
117          * default of nothing.
118          */
119         GHashTable *imvironments;
120
121         int current_status;
122         gboolean logged_in;
123         GString *tmp_serv_blist, *tmp_serv_ilist, *tmp_serv_plist;
124         GSList *confs;
125         unsigned int conf_id; /* just a counter */
126         gboolean chat_online;
127         gboolean in_chat;
128         char *chat_name;
129         char *pending_chat_room;
130         char *pending_chat_id;
131         char *pending_chat_topic;
132         char *pending_chat_goto;
133         char *auth;
134         gsize auth_written;
135         char *cookie_y;
136         char *cookie_t;
137         char *cookie_c;
138         int session_id;
139         gboolean jp;
140         gboolean wm; /* connected w/ web messenger method */
141         /* picture aka buddy icon stuff */
142         char *picture_url;
143         int picture_checksum;
144
145         /* ew. we have to check the icon before we connect,
146          * but can't upload it til we're connected. */
147         struct yahoo_buddy_icon_upload_data *picture_upload_todo;
148         PurpleProxyConnectData *buddy_icon_connect_data;
149
150         struct _YchtConn *ycht;
151
152         /**
153          * This linked list contains PurpleUtilFetchUrlData structs
154          * for when we lookup people profile or photo information.
155          */
156         GSList *url_datas;
157 };
158
159 #define YAHOO_MAX_STATUS_MESSAGE_LENGTH (255)
160
161 /* sometimes i wish prpls could #include things from other prpls. then i could just
162  * use the routines from libfaim and not have to admit to knowing how they work. */
163 #define yahoo_put16(buf, data) ( \
164                 (*(buf) = (unsigned char)((data)>>8)&0xff), \
165                 (*((buf)+1) = (unsigned char)(data)&0xff),  \
166                 2)
167 #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
168 #define yahoo_put32(buf, data) ( \
169                 (*((buf)) = (unsigned char)((data)>>24)&0xff), \
170                 (*((buf)+1) = (unsigned char)((data)>>16)&0xff), \
171                 (*((buf)+2) = (unsigned char)((data)>>8)&0xff), \
172                 (*((buf)+3) = (unsigned char)(data)&0xff), \
173                 4)
174 #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \
175                 (((*((buf)+1))<<16)&0x00ff0000) + \
176                 (((*((buf)+2))<< 8)&0x0000ff00) + \
177                 (((*((buf)+3)    )&0x000000ff)))
178
179 /* util.c */
180 void yahoo_init_colorht(void);
181 void yahoo_dest_colorht(void);
182 char *yahoo_codes_to_html(const char *x);
183 char *yahoo_html_to_codes(const char *src);
184
185 /**
186  * Encode some text to send to the yahoo server.
187  *
188  * @param gc The connection handle.
189  * @param str The null terminated utf8 string to encode.
190  * @param utf8 If not @c NULL, whether utf8 is okay or not.
191  *             Even if it is okay, we may not use it. If we
192  *             used it, we set this to @c TRUE, else to
193  *             @c FALSE. If @c NULL, false is assumed, and
194  *             it is not dereferenced.
195  * @return The g_malloced string in the appropriate encoding.
196  */
197 char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8);
198
199 /**
200  * Decode some text received from the server.
201  *
202  * @param gc The gc handle.
203  * @param str The null terminated string to decode.
204  * @param utf8 Did the server tell us it was supposed to be utf8?
205  * @return The decoded, utf-8 string, which must be g_free()'d.
206  */
207 char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8);
208
209 /* previously-static functions, now needed for yahoo_profile.c */
210 void yahoo_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full);
211
212 /* yahoo_profile.c */
213 void yahoo_get_info(PurpleConnection *gc, const char *name);
214
215 /**
216  * Check to see whether the sender is permitted to send
217  *
218  * @param gc The gc handle.
219  * @param who The sender of the packet to check
220 */
221 gboolean yahoo_privacy_check
222         (PurpleConnection *gc, const char *who);
223
224 gboolean yahoo_send_attention(PurpleConnection *gc, const char *username, guint type);
225 GList *yahoo_attention_types(PurpleAccount *account);
226
227 #endif /* _YAHOO_H_ */