1 | /* |
---|
2 | * libyahoo2: yahoo2.h |
---|
3 | * |
---|
4 | * Copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net> |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; either version 2 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program; if not, write to the Free Software |
---|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
---|
19 | * |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef YAHOO2_H |
---|
23 | #define YAHOO2_H |
---|
24 | |
---|
25 | #ifdef __cplusplus |
---|
26 | extern "C" { |
---|
27 | #endif |
---|
28 | |
---|
29 | /* *** BitlBee: *** */ |
---|
30 | #include "bitlbee.h" |
---|
31 | #undef free |
---|
32 | #define free(x) g_free(x) |
---|
33 | #undef malloc |
---|
34 | #define malloc(x) g_malloc(x) |
---|
35 | #undef realloc |
---|
36 | #define realloc(x, y) g_realloc(x, y) |
---|
37 | #undef strdup |
---|
38 | #define strdup(x) g_strdup(x) |
---|
39 | #undef strndup |
---|
40 | #define strndup(x, y) g_strndup(x, y) |
---|
41 | #undef snprintf |
---|
42 | // #define snprintf( x... ) g_snprintf( x ) |
---|
43 | #undef strcasecmp |
---|
44 | #define strcasecmp(x, y) g_strcasecmp(x, y) |
---|
45 | #undef strncasecmp |
---|
46 | #define strncasecmp(x, y, z) g_strncasecmp(x, y, z) |
---|
47 | |
---|
48 | |
---|
49 | #include "yahoo2_types.h" |
---|
50 | |
---|
51 | /* returns the socket descriptor object for a given pager connection. shouldn't be needed */ |
---|
52 | void *yahoo_get_fd(int id); |
---|
53 | |
---|
54 | /* says how much logging to do */ |
---|
55 | /* see yahoo2_types.h for the different values */ |
---|
56 | int yahoo_set_log_level(enum yahoo_log_level level); |
---|
57 | enum yahoo_log_level yahoo_get_log_level(void); |
---|
58 | |
---|
59 | /* these functions should be self explanatory */ |
---|
60 | /* who always means the buddy you're acting on */ |
---|
61 | /* id is the successful value returned by yahoo_init */ |
---|
62 | |
---|
63 | /* init returns a connection id used to identify the connection hereon */ |
---|
64 | /* or 0 on failure */ |
---|
65 | /* you must call init before calling any other function */ |
---|
66 | /* |
---|
67 | * The optional parameters to init are key/value pairs that specify |
---|
68 | * server settings to use. This list must be NULL terminated - even |
---|
69 | * if the list is empty. If a parameter isn't set, a default value |
---|
70 | * will be used. Parameter keys are strings, parameter values are |
---|
71 | * either strings or ints, depending on the key. Values passed in |
---|
72 | * are copied, so you can use const/auto/static/pointers/whatever |
---|
73 | * you want. Parameters are: |
---|
74 | * NAME TYPE DEFAULT |
---|
75 | * pager_host char * scs.msg.yahoo.com |
---|
76 | * pager_port int 5050 |
---|
77 | * filetransfer_host char * filetransfer.msg.yahoo.com |
---|
78 | * filetransfer_port int 80 |
---|
79 | * webcam_host char * webcam.yahoo.com |
---|
80 | * webcam_port int 5100 |
---|
81 | * webcam_description char * "" |
---|
82 | * local_host char * "" |
---|
83 | * conn_type int Y_WCM_DSL |
---|
84 | * |
---|
85 | * You should set at least local_host if you intend to use webcams |
---|
86 | */ |
---|
87 | int yahoo_init_with_attributes(const char *username, |
---|
88 | const char *password, ...); |
---|
89 | |
---|
90 | /* yahoo_init does the same as yahoo_init_with_attributes, assuming defaults |
---|
91 | * for all attributes */ |
---|
92 | int yahoo_init(const char *username, const char *password); |
---|
93 | |
---|
94 | /* release all resources held by this session */ |
---|
95 | /* you need to call yahoo_close for a session only if |
---|
96 | * yahoo_logoff is never called for it (ie, it was never logged in) */ |
---|
97 | void yahoo_close(int id); |
---|
98 | /* login logs in to the server */ |
---|
99 | /* initial is of type enum yahoo_status. see yahoo2_types.h */ |
---|
100 | void yahoo_login(int id, int initial); |
---|
101 | void yahoo_logoff(int id); |
---|
102 | /* reloads status of all buddies */ |
---|
103 | void yahoo_refresh(int id); |
---|
104 | /* activates/deactivates an identity */ |
---|
105 | void yahoo_set_identity_status(int id, const char *identity, |
---|
106 | int active); |
---|
107 | /* regets the entire buddy list from the server */ |
---|
108 | void yahoo_get_list(int id); |
---|
109 | /* download buddy contact information from your yahoo addressbook */ |
---|
110 | void yahoo_get_yab(int id); |
---|
111 | /* add/modify an address book entry. if yab->dbid is set, it will */ |
---|
112 | /* modify that entry else it creates a new entry */ |
---|
113 | void yahoo_set_yab(int id, struct yab *yab); |
---|
114 | void yahoo_keepalive(int id); |
---|
115 | void yahoo_chat_keepalive(int id); |
---|
116 | |
---|
117 | /* from is the identity you're sending from. if NULL, the default is used */ |
---|
118 | /* utf8 is whether msg is a utf8 string or not. */ |
---|
119 | void yahoo_send_im(int id, const char *from, const char *who, |
---|
120 | const char *msg, int utf8, int picture); |
---|
121 | // void yahoo_send_buzz(int id, const char *from, const char *who); |
---|
122 | /* if type is true, send typing notice, else send stopped typing notice */ |
---|
123 | void yahoo_send_typing(int id, const char *from, const char *who, |
---|
124 | int typ); |
---|
125 | |
---|
126 | /* used to set away/back status. */ |
---|
127 | /* away says whether the custom message is an away message or a sig */ |
---|
128 | void yahoo_set_away(int id, enum yahoo_status state, const char *msg, |
---|
129 | int away); |
---|
130 | |
---|
131 | void yahoo_add_buddy(int id, const char *who, const char *group, |
---|
132 | const char *msg); |
---|
133 | void yahoo_remove_buddy(int id, const char *who, const char *group); |
---|
134 | void yahoo_confirm_buddy(int id, const char *who, int reject, |
---|
135 | const char *msg); |
---|
136 | void yahoo_stealth_buddy(int id, const char *who, int unstealth); |
---|
137 | /* if unignore is true, unignore, else ignore */ |
---|
138 | void yahoo_ignore_buddy(int id, const char *who, int unignore); |
---|
139 | void yahoo_change_buddy_group(int id, const char *who, |
---|
140 | const char *old_group, const char *new_group); |
---|
141 | void yahoo_group_rename(int id, const char *old_group, |
---|
142 | const char *new_group); |
---|
143 | |
---|
144 | void yahoo_conference_invite(int id, const char *from, YList *who, |
---|
145 | const char *room, const char *msg); |
---|
146 | void yahoo_conference_addinvite(int id, const char *from, |
---|
147 | const char *who, const char *room, const YList *members, |
---|
148 | const char *msg); |
---|
149 | void yahoo_conference_decline(int id, const char *from, YList *who, |
---|
150 | const char *room, const char *msg); |
---|
151 | void yahoo_conference_message(int id, const char *from, YList *who, |
---|
152 | const char *room, const char *msg, int utf8); |
---|
153 | void yahoo_conference_logon(int id, const char *from, YList *who, |
---|
154 | const char *room); |
---|
155 | void yahoo_conference_logoff(int id, const char *from, YList *who, |
---|
156 | const char *room); |
---|
157 | |
---|
158 | /* Get a list of chatrooms */ |
---|
159 | void yahoo_get_chatrooms(int id, int chatroomid); |
---|
160 | /* join room with specified roomname and roomid */ |
---|
161 | void yahoo_chat_logon(int id, const char *from, const char *room, |
---|
162 | const char *roomid); |
---|
163 | /* Send message "msg" to room with specified roomname, msgtype is 1-normal message or 2-/me mesage */ |
---|
164 | void yahoo_chat_message(int id, const char *from, const char *room, |
---|
165 | const char *msg, const int msgtype, const int utf8); |
---|
166 | /* Log off chat */ |
---|
167 | void yahoo_chat_logoff(int id, const char *from); |
---|
168 | |
---|
169 | /* requests a webcam feed */ |
---|
170 | /* who is the person who's webcam you would like to view */ |
---|
171 | /* if who is null, then you're the broadcaster */ |
---|
172 | void yahoo_webcam_get_feed(int id, const char *who); |
---|
173 | void yahoo_webcam_close_feed(int id, const char *who); |
---|
174 | |
---|
175 | /* sends an image when uploading */ |
---|
176 | /* image points to a JPEG-2000 image, length is the length of the image */ |
---|
177 | /* in bytes. The timestamp is the time in milliseconds since we started the */ |
---|
178 | /* webcam. */ |
---|
179 | void yahoo_webcam_send_image(int id, unsigned char *image, |
---|
180 | unsigned int length, unsigned int timestamp); |
---|
181 | |
---|
182 | /* this function should be called if we want to allow a user to watch the */ |
---|
183 | /* webcam. Who is the user we want to accept. */ |
---|
184 | /* Accept user (accept = 1), decline user (accept = 0) */ |
---|
185 | void yahoo_webcam_accept_viewer(int id, const char *who, int accept); |
---|
186 | |
---|
187 | /* send an invitation to a user to view your webcam */ |
---|
188 | void yahoo_webcam_invite(int id, const char *who); |
---|
189 | |
---|
190 | /* will set up a connection and initiate file transfer. |
---|
191 | * callback will be called with the fd that you should write |
---|
192 | * the file data to |
---|
193 | */ |
---|
194 | void yahoo_send_file(int id, const char *who, const char *msg, |
---|
195 | const char *name, unsigned long size, |
---|
196 | yahoo_get_fd_callback callback, void *data); |
---|
197 | |
---|
198 | /* |
---|
199 | * Respond to a file transfer request. Be sure to provide the callback data |
---|
200 | * since that is your only chance to recognize future callbacks |
---|
201 | */ |
---|
202 | void yahoo_send_file_transfer_response(int client_id, int response, |
---|
203 | char *id, void *data); |
---|
204 | |
---|
205 | |
---|
206 | /* send a search request |
---|
207 | */ |
---|
208 | void yahoo_search(int id, enum yahoo_search_type t, const char *text, |
---|
209 | enum yahoo_search_gender g, enum yahoo_search_agerange ar, |
---|
210 | int photo, int yahoo_only); |
---|
211 | |
---|
212 | /* continue last search |
---|
213 | * should be called if only (start+found >= total) |
---|
214 | * |
---|
215 | * where the above three are passed to ext_yahoo_got_search_result |
---|
216 | */ |
---|
217 | void yahoo_search_again(int id, int start); |
---|
218 | |
---|
219 | /* these should be called when input is available on a fd */ |
---|
220 | /* registered by ext_yahoo_add_handler */ |
---|
221 | /* if these return negative values, errno may be set */ |
---|
222 | int yahoo_read_ready(int id, void *fd, void *data); |
---|
223 | int yahoo_write_ready(int id, void *fd, void *data); |
---|
224 | |
---|
225 | /* utility functions. these do not hit the server */ |
---|
226 | enum yahoo_status yahoo_current_status(int id); |
---|
227 | const YList *yahoo_get_buddylist(int id); |
---|
228 | const YList *yahoo_get_ignorelist(int id); |
---|
229 | const YList *yahoo_get_identities(int id); |
---|
230 | /* 'which' could be y, t, c or login. This may change in later versions. */ |
---|
231 | const char *yahoo_get_cookie(int id, const char *which); |
---|
232 | |
---|
233 | /* returns the url used to get user profiles - you must append the user id */ |
---|
234 | /* as of now this is http://profiles.yahoo.com/ */ |
---|
235 | /* You'll have to do urlencoding yourself, but see yahoo_httplib.h first */ |
---|
236 | const char *yahoo_get_profile_url(void); |
---|
237 | |
---|
238 | void yahoo_buddyicon_request(int id, const char *who); |
---|
239 | |
---|
240 | #include "yahoo_httplib.h" |
---|
241 | |
---|
242 | #ifdef __cplusplus |
---|
243 | } |
---|
244 | #endif |
---|
245 | #endif |
---|