Mercurial > pidgin
annotate src/protocols/gg/libgg.h @ 2475:ba7ee4c1908c
[gaim-migrate @ 2488]
BMiller's fixes so gg compiles on solaris
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Wed, 10 Oct 2001 20:03:17 +0000 |
| parents | b2926d21f067 |
| children | 1950afffd107 |
| rev | line source |
|---|---|
|
2475
ba7ee4c1908c
[gaim-migrate @ 2488]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2399
diff
changeset
|
1 /* $Id: libgg.h 2488 2001-10-10 20:03:17Z warmenhoven $ */ |
| 2393 | 2 |
| 3 /* | |
| 4 * (C) Copyright 2001 Wojtek Kaniewski <wojtekka@irc.pl> | |
| 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 Version 2 as | |
| 8 * published by the Free Software Foundation. | |
| 9 * | |
| 10 * This program is distributed in the hope that it will be useful, | |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 * GNU General Public License for more details. | |
| 14 * | |
| 15 * You should have received a copy of the GNU General Public License | |
| 16 * along with this program; if not, write to the Free Software | |
| 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 18 */ | |
| 19 | |
| 20 #ifndef __LIBGG_H | |
| 21 #define __LIBGG_H | |
| 22 | |
| 23 #ifdef __cplusplus | |
| 24 extern "C" { | |
| 25 #endif | |
| 26 | |
| 27 #define GG_DEBUG 1 | |
| 28 | |
|
2475
ba7ee4c1908c
[gaim-migrate @ 2488]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2399
diff
changeset
|
29 #ifndef INADDR_NONE |
|
ba7ee4c1908c
[gaim-migrate @ 2488]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2399
diff
changeset
|
30 #define INADDR_NONE 0xffffffff |
|
ba7ee4c1908c
[gaim-migrate @ 2488]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2399
diff
changeset
|
31 #endif |
|
ba7ee4c1908c
[gaim-migrate @ 2488]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2399
diff
changeset
|
32 |
| 2393 | 33 /* |
| 34 * typ zmiennej określającej numerek danej osoby. | |
| 35 */ | |
| 36 typedef unsigned int uin_t; | |
| 37 | |
| 38 /* | |
| 39 * cośtam. | |
| 40 */ | |
| 41 struct gg_session { | |
| 42 int state, check; | |
| 43 int fd, pid; | |
| 44 int port; | |
| 45 int seq, async; | |
| 46 | |
| 47 uin_t uin; | |
| 48 char *password; | |
| 49 | |
| 50 char *recv_buf; | |
| 51 int recv_done, recv_left; | |
| 52 }; | |
| 53 | |
| 54 /* | |
| 55 * różne stany asynchronicznej maszynki. | |
| 56 */ | |
| 57 enum { | |
| 58 GG_STATE_IDLE = 0, /* wspólne */ | |
| 59 GG_STATE_RESOLVING, | |
| 60 GG_STATE_CONNECTING_HTTP, | |
| 61 | |
| 62 GG_STATE_WRITING_HTTP, /* gg_login */ | |
| 63 GG_STATE_CONNECTING_GG, | |
| 64 GG_STATE_WAITING_FOR_KEY, | |
| 65 GG_STATE_SENDING_KEY, | |
| 66 GG_STATE_CONNECTED, | |
| 67 | |
| 68 GG_STATE_READING_HEADER, /* gg_search */ | |
| 69 GG_STATE_READING_DATA, | |
| 70 GG_STATE_PARSING, | |
| 71 GG_STATE_FINISHED, | |
| 72 }; | |
| 73 | |
| 74 /* | |
| 75 * co proces klienta powinien sprawdzać w deskryptorach? | |
| 76 */ | |
| 77 enum { | |
| 78 GG_CHECK_NONE = 0, | |
| 79 GG_CHECK_WRITE = 1, | |
| 80 GG_CHECK_READ = 2, | |
| 81 }; | |
| 82 | |
| 83 struct gg_session *gg_login(uin_t uin, char *password, int async); | |
| 84 void gg_free_session(struct gg_session *sess); | |
| 85 void gg_logoff(struct gg_session *sess); | |
| 86 int gg_change_status(struct gg_session *sess, int status); | |
| 87 int gg_send_message(struct gg_session *sess, int msgclass, uin_t recipient, unsigned char *message); | |
| 88 int gg_ping(struct gg_session *sess); | |
| 89 | |
| 90 struct gg_notify_reply { | |
| 91 uin_t uin; /* numerek */ | |
| 92 int status; /* status danej osoby */ | |
| 93 int remote_ip; /* adres ip delikwenta */ | |
| 94 short remote_port; /* port, na którym słucha klient */ | |
| 95 int dunno1; /* == 0x0b */ | |
| 96 short dunno2; /* znowu port? */ | |
| 97 } __attribute__ ((packed)); | |
| 98 | |
| 99 struct gg_status { | |
| 100 uin_t uin; /* numerek */ | |
| 101 int status; /* nowy stan */ | |
| 102 } __attribute__ ((packed)); | |
| 103 | |
| 104 enum { | |
| 105 GG_EVENT_NONE = 0, | |
| 106 GG_EVENT_MSG, | |
| 107 GG_EVENT_NOTIFY, | |
| 108 GG_EVENT_STATUS, | |
| 109 GG_EVENT_ACK, | |
| 110 GG_EVENT_CONN_FAILED, | |
| 111 GG_EVENT_CONN_SUCCESS, | |
| 112 }; | |
| 113 | |
| 114 enum { | |
| 115 GG_FAILURE_RESOLVING = 1, | |
| 116 GG_FAILURE_CONNECTING, | |
| 117 GG_FAILURE_INVALID, | |
| 118 GG_FAILURE_READING, | |
| 119 GG_FAILURE_WRITING, | |
| 120 GG_FAILURE_PASSWORD, | |
| 121 }; | |
| 122 | |
| 123 struct gg_event { | |
| 124 int type; | |
| 125 union { | |
| 126 struct { | |
| 127 uin_t sender; | |
| 128 int msgclass; | |
| 129 unsigned char *message; | |
| 130 } msg; | |
| 131 struct gg_notify_reply *notify; | |
| 132 struct gg_status status; | |
| 133 struct { | |
| 134 uin_t recipient; | |
| 135 int status; | |
| 136 int seq; | |
| 137 } ack; | |
| 138 int failure; | |
| 139 } event; | |
| 140 }; | |
| 141 | |
| 142 struct gg_event *gg_watch_fd(struct gg_session *sess); | |
| 143 void gg_free_event(struct gg_event *e); | |
| 144 | |
| 145 int gg_notify(struct gg_session *sess, uin_t *userlist, int count); | |
| 146 int gg_add_notify(struct gg_session *sess, uin_t uin); | |
| 147 int gg_remove_notify(struct gg_session *sess, uin_t uin); | |
| 148 | |
| 149 /* | |
| 150 * jakieśtam bzdurki dotyczące szukania userów. | |
| 151 */ | |
| 152 | |
| 153 struct gg_search_result { | |
| 154 uin_t uin; | |
| 155 char *first_name; | |
| 156 char *last_name; | |
| 157 char *nickname; | |
| 158 int born; | |
| 159 int gender; | |
| 160 char *city; | |
| 161 int active; | |
| 162 }; | |
| 163 | |
| 164 struct gg_search_request { | |
| 165 /* czy ma szukać tylko aktywnych? */ | |
| 166 int active; | |
| 167 /* mode 0 */ | |
| 168 char *nickname, *first_name, *last_name, *city; | |
| 169 int gender, min_birth, max_birth; | |
| 170 /* mode 1 */ | |
| 171 char *email; | |
| 172 /* mode 2 */ | |
| 173 char *phone; | |
| 174 /* mode 3 */ | |
| 175 uin_t uin; | |
| 176 }; | |
| 177 | |
| 178 struct gg_search { | |
| 179 struct gg_search_request request; | |
| 180 | |
| 181 /* bzdurki */ | |
| 182 int mode, fd, async, state, check, error, pid; | |
| 183 char *header_buf, *data_buf; | |
| 184 int header_size, data_size; | |
| 185 | |
| 186 /* wyniki */ | |
| 187 int count; | |
| 188 struct gg_search_result *results; | |
| 189 }; | |
| 190 | |
| 191 #define GG_GENDER_NONE 0 | |
| 192 #define GG_GENDER_FEMALE 1 | |
| 193 #define GG_GENDER_MALE 2 | |
| 194 | |
| 195 struct gg_search *gg_search(struct gg_search_request *r, int async); | |
| 196 int gg_search_watch_fd(struct gg_search *f); | |
| 197 void gg_free_search(struct gg_search *f); | |
| 198 void gg_search_cancel(struct gg_search *f); | |
| 199 | |
| 200 /* | |
| 201 * jeśli chcemy sobie podebugować, wystarczy zdefiniować GG_DEBUG. | |
| 202 */ | |
| 203 | |
| 204 int gg_debug_level; | |
| 205 | |
| 206 #ifdef GG_DEBUG | |
| 207 | |
| 208 # define GG_DEBUG_NET 1 | |
| 209 # define GG_DEBUG_TRAFFIC 2 | |
| 210 # define GG_DEBUG_DUMP 4 | |
| 211 # define GG_DEBUG_FUNCTION 8 | |
| 212 # define GG_DEBUG_MISC 16 | |
| 213 | |
| 214 void gg_debug_real(int level, char *format, ...); | |
| 215 # define gg_debug(x, y...) gg_debug_real(x, y) | |
| 216 | |
| 217 #else | |
| 218 | |
| 219 # define gg_debug(x, y...) while(0) { }; | |
| 220 | |
| 221 #endif /* GG_DEBUG */ | |
| 222 | |
| 223 /* | |
| 224 * ------------------------------------------------------------------------- | |
| 225 * poniżej znajdują się wewnętrzne sprawy biblioteki. zwykły klient nie | |
| 226 * powinien ich w ogóle ruszać, bo i nie ma po co. wszystko można załatwić | |
| 227 * procedurami wyższego poziomu, których definicje znajdują się na początku | |
| 228 * tego pliku. | |
| 229 * ------------------------------------------------------------------------- | |
| 230 */ | |
| 231 | |
| 232 int gg_resolve(int *fd, int *pid, char *hostname); | |
| 233 int gg_connect(void *addr, int port, int async); | |
| 234 char *gg_alloc_sprintf(char *format, ...); | |
| 235 | |
| 236 #define GG_APPMSG_HOST "appmsg.gadu-gadu.pl" | |
| 237 #define GG_APPMSG_PORT 80 | |
| 238 #define GG_PUBDIR_HOST "pubdir.gadu-gadu.pl" | |
| 239 #define GG_PUBDIR_PORT 80 | |
| 240 #define GG_DEFAULT_PORT 8074 | |
| 241 | |
| 242 struct gg_header { | |
| 243 int type; /* typ pakietu */ | |
| 244 int length; /* długość reszty pakietu */ | |
| 245 } __attribute__ ((packed)); | |
| 246 | |
| 247 #define GG_WELCOME 0x0001 | |
| 248 | |
| 249 struct gg_welcome { | |
| 250 int key; /* klucz szyfrowania hasła */ | |
| 251 } __attribute__ ((packed)); | |
| 252 | |
| 253 #define GG_LOGIN 0x000c | |
| 254 | |
| 255 struct gg_login { | |
| 256 uin_t uin; /* twój numerek */ | |
| 257 int hash; /* hash hasła */ | |
| 258 int status; /* status na dzień dobry */ | |
| 259 int dunno; /* == 0x0b */ | |
| 260 int local_ip; /* mój adres ip */ | |
| 261 short local_port; /* port, na którym słucham */ | |
| 262 } __attribute__ ((packed)); | |
| 263 | |
| 264 #define GG_LOGIN_OK 0x0003 | |
| 265 | |
| 266 #define GG_LOGIN_FAILED 0x0009 | |
| 267 | |
| 268 #define GG_NEW_STATUS 0x0002 | |
| 269 | |
| 270 #define GG_STATUS_NOT_AVAIL 0x0001 /* rozłączony */ | |
| 271 #define GG_STATUS_AVAIL 0x0002 /* dostępny */ | |
| 272 #define GG_STATUS_BUSY 0x0003 /* zajęty */ | |
| 273 #define GG_STATUS_INVISIBLE 0x0014 /* niewidoczny (GG 4.6) */ | |
| 274 | |
| 275 #define GG_STATUS_FRIENDS_MASK 0x8000 /* tylko dla znajomych (GG 4.6) */ | |
| 276 | |
| 277 struct gg_new_status { | |
| 278 int status; /* na jaki zmienić? */ | |
| 279 } __attribute__ ((packed)); | |
| 280 | |
| 281 #define GG_NOTIFY 0x0010 | |
| 282 | |
| 283 struct gg_notify { | |
| 284 uin_t uin; /* numerek danej osoby */ | |
| 285 char dunno1; /* == 3 */ | |
| 286 } __attribute__ ((packed)); | |
| 287 | |
| 288 #define GG_NOTIFY_REPLY 0x000c /* tak, to samo co GG_LOGIN */ | |
| 289 | |
| 290 /* struct gg_notify_reply zadeklarowane wyżej */ | |
| 291 | |
| 292 #define GG_ADD_NOTIFY 0x000d | |
| 293 #define GG_REMOVE_NOTIFY 0x000e | |
| 294 | |
| 295 struct gg_add_remove { | |
| 296 uin_t uin; /* numerek */ | |
| 297 char dunno1; /* == 3 */ | |
| 298 } __attribute__ ((packed)); | |
| 299 | |
| 300 #define GG_STATUS 0x0002 | |
| 301 | |
| 302 /* struct gg_status zadeklarowane wcześniej */ | |
| 303 | |
| 304 #define GG_SEND_MSG 0x000b | |
| 305 | |
| 306 #define GG_CLASS_MSG 0x0004 | |
| 307 #define GG_CLASS_CHAT 0x0008 | |
| 308 | |
| 309 struct gg_send_msg { | |
| 310 int recipient; | |
| 311 int seq; | |
| 312 int msgclass; | |
| 313 } __attribute__ ((packed)); | |
| 314 | |
| 315 #define GG_SEND_MSG_ACK 0x0005 | |
| 316 | |
| 317 #define GG_ACK_DELIVERED 0x0002 | |
| 318 #define GG_ACK_QUEUED 0x0003 | |
| 319 | |
| 320 struct gg_send_msg_ack { | |
| 321 int status; | |
| 322 int recipient; | |
| 323 int seq; | |
| 324 } __attribute__ ((packed)); | |
| 325 | |
| 326 #define GG_RECV_MSG 0x000a | |
| 327 | |
| 328 struct gg_recv_msg { | |
| 329 int sender; | |
| 330 int dunno1; | |
| 331 int dunno2; | |
| 332 int msgclass; | |
| 333 } __attribute__ ((packed)); | |
| 334 | |
| 335 #define GG_PING 0x0008 | |
| 336 | |
| 337 #define GG_PONG 0x0007 | |
| 338 | |
| 339 #ifdef __cplusplus | |
| 340 } | |
| 341 #endif | |
| 342 | |
| 343 #endif |
