Mercurial > pidgin
comparison src/server.c @ 423:0d4e80bdb96b
[gaim-migrate @ 433]
No more --enable-oscar option. From now on, it's a toggle in the preferences.
PLEASE DO NOT USE OSCAR, even though it's very easy to.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Wed, 21 Jun 2000 19:33:58 +0000 |
| parents | f9dc74875833 |
| children | 5db3734a1fe6 |
comparison
equal
deleted
inserted
replaced
| 422:7cd05539952d | 423:0d4e80bdb96b |
|---|---|
| 28 #include <sys/types.h> | 28 #include <sys/types.h> |
| 29 #include <sys/stat.h> | 29 #include <sys/stat.h> |
| 30 #include <sys/time.h> | 30 #include <sys/time.h> |
| 31 #include <unistd.h> | 31 #include <unistd.h> |
| 32 #include <gtk/gtk.h> | 32 #include <gtk/gtk.h> |
| 33 #ifdef USE_OSCAR | |
| 34 #include <aim.h> | 33 #include <aim.h> |
| 35 extern int gaim_caps; | 34 extern int gaim_caps; |
| 36 #endif | |
| 37 #include "gaim.h" | 35 #include "gaim.h" |
| 38 | 36 |
| 39 static int idle_timer = -1; | 37 static int idle_timer = -1; |
| 40 static time_t lastsent = 0; | 38 static time_t lastsent = 0; |
| 41 static time_t login_time = 0; | 39 static time_t login_time = 0; |
| 44 | 42 |
| 45 int correction_time = 0; | 43 int correction_time = 0; |
| 46 | 44 |
| 47 int serv_login(char *username, char *password) | 45 int serv_login(char *username, char *password) |
| 48 { | 46 { |
| 49 #ifndef USE_OSCAR | 47 if (!(general_options & OPT_GEN_USE_OSCAR)) { |
| 50 return toc_login(username, password); | 48 USE_OSCAR = 0; |
| 51 #else | 49 return toc_login(username, password); |
| 52 return oscar_login(username, password); | 50 } else { |
| 53 #endif | 51 USE_OSCAR = 1; |
| 52 debug_print("Logging in using Oscar. Expect problems.\n"); | |
| 53 return oscar_login(username, password); | |
| 54 } | |
| 54 } | 55 } |
| 55 | 56 |
| 56 void serv_close() | 57 void serv_close() |
| 57 { | 58 { |
| 58 #ifndef USE_OSCAR | 59 if (!USE_OSCAR) |
| 59 toc_close(); | 60 toc_close(); |
| 60 #else | 61 else |
| 61 oscar_close(); | 62 oscar_close(); |
| 62 #endif | 63 |
| 63 gtk_timeout_remove(idle_timer); | 64 gtk_timeout_remove(idle_timer); |
| 64 idle_timer = -1; | 65 idle_timer = -1; |
| 65 } | 66 } |
| 66 | 67 |
| 67 | 68 |
| 154 | 155 |
| 155 | 156 |
| 156 | 157 |
| 157 void serv_send_im(char *name, char *message, int away) | 158 void serv_send_im(char *name, char *message, int away) |
| 158 { | 159 { |
| 159 #ifndef USE_OSCAR | 160 if (!USE_OSCAR) { |
| 160 char buf[MSG_LEN - 7]; | 161 char buf[MSG_LEN - 7]; |
| 161 | 162 |
| 162 g_snprintf(buf, MSG_LEN - 8, "toc_send_im %s \"%s\"%s", normalize(name), | 163 g_snprintf(buf, MSG_LEN - 8, "toc_send_im %s \"%s\"%s", normalize(name), |
| 163 message, ((away) ? " auto" : "")); | 164 message, ((away) ? " auto" : "")); |
| 164 sflap_send(buf, strlen(buf), TYPE_DATA); | 165 sflap_send(buf, strlen(buf), TYPE_DATA); |
| 165 #else | 166 } else { |
| 166 if (away) | 167 if (away) |
| 167 aim_send_im(gaim_sess, gaim_conn, name, AIM_IMFLAGS_AWAY, message); | 168 aim_send_im(gaim_sess, gaim_conn, name, AIM_IMFLAGS_AWAY, message); |
| 168 else | 169 else |
| 169 aim_send_im(gaim_sess, gaim_conn, name, 0, message); | 170 aim_send_im(gaim_sess, gaim_conn, name, 0, message); |
| 170 #endif | 171 } |
| 171 if (!away) | 172 if (!away) |
| 172 serv_touch_idle(); | 173 serv_touch_idle(); |
| 173 } | 174 } |
| 174 | 175 |
| 175 void serv_get_info(char *name) | 176 void serv_get_info(char *name) |
| 176 { | 177 { |
| 177 #ifndef USE_OSCAR | 178 if (!USE_OSCAR) { |
| 178 char buf[MSG_LEN]; | 179 char buf[MSG_LEN]; |
| 179 g_snprintf(buf, MSG_LEN, "toc_get_info %s", normalize(name)); | 180 g_snprintf(buf, MSG_LEN, "toc_get_info %s", normalize(name)); |
| 180 sflap_send(buf, -1, TYPE_DATA); | 181 sflap_send(buf, -1, TYPE_DATA); |
| 181 #else | 182 } else { |
| 182 aim_getinfo(gaim_sess, gaim_conn, name, AIM_GETINFO_GENERALINFO); | 183 aim_getinfo(gaim_sess, gaim_conn, name, AIM_GETINFO_GENERALINFO); |
| 183 #endif | 184 } |
| 184 } | 185 } |
| 185 | 186 |
| 186 void serv_get_away_msg(char *name) | 187 void serv_get_away_msg(char *name) |
| 187 { | 188 { |
| 188 #ifndef USE_OSCAR | 189 if (!USE_OSCAR) { |
| 189 /* HAHA! TOC doesn't have this yet */ | 190 /* HAHA! TOC doesn't have this yet */ |
| 190 #else | 191 } else { |
| 191 aim_getinfo(gaim_sess, gaim_conn, name, AIM_GETINFO_AWAYMESSAGE); | 192 aim_getinfo(gaim_sess, gaim_conn, name, AIM_GETINFO_AWAYMESSAGE); |
| 192 #endif | 193 } |
| 193 } | 194 } |
| 194 | 195 |
| 195 void serv_get_dir(char *name) | 196 void serv_get_dir(char *name) |
| 196 { | 197 { |
| 197 #ifndef USE_OSCAR | 198 if (!USE_OSCAR) { |
| 198 char buf[MSG_LEN]; | 199 char buf[MSG_LEN]; |
| 199 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", normalize(name)); | 200 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", normalize(name)); |
| 200 sflap_send(buf, -1, TYPE_DATA); | 201 sflap_send(buf, -1, TYPE_DATA); |
| 201 #endif | 202 } |
| 202 } | 203 } |
| 203 | 204 |
| 204 void serv_set_dir(char *first, char *middle, char *last, char *maiden, | 205 void serv_set_dir(char *first, char *middle, char *last, char *maiden, |
| 205 char *city, char *state, char *country, int web) | 206 char *city, char *state, char *country, int web) |
| 206 { | 207 { |
| 207 #ifndef USE_OSCAR | 208 if (!USE_OSCAR) { |
| 208 char buf2[BUF_LEN*4], buf[BUF_LEN]; | 209 char buf2[BUF_LEN*4], buf[BUF_LEN]; |
| 209 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, | 210 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, |
| 210 middle, last, maiden, city, state, country, | 211 middle, last, maiden, city, state, country, |
| 211 (web == 1) ? "Y" : ""); | 212 (web == 1) ? "Y" : ""); |
| 212 escape_text(buf2); | 213 escape_text(buf2); |
| 213 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf2); | 214 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf2); |
| 214 sflap_send(buf, -1, TYPE_DATA); | 215 sflap_send(buf, -1, TYPE_DATA); |
| 215 #endif | 216 } |
| 216 } | 217 } |
| 217 | 218 |
| 218 void serv_dir_search(char *first, char *middle, char *last, char *maiden, | 219 void serv_dir_search(char *first, char *middle, char *last, char *maiden, |
| 219 char *city, char *state, char *country, char *email) | 220 char *city, char *state, char *country, char *email) |
| 220 { | 221 { |
| 221 #ifndef USE_OSCAR | 222 if (!USE_OSCAR) { |
| 222 char buf[BUF_LONG]; | 223 char buf[BUF_LONG]; |
| 223 g_snprintf(buf, sizeof(buf)/2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, last, maiden, city, state, country, email); | 224 g_snprintf(buf, sizeof(buf)/2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, last, maiden, city, state, country, email); |
| 224 sprintf(debug_buff,"Searching for: %s,%s,%s,%s,%s,%s,%s\n", first, middle, last, maiden, city, state, country); | 225 sprintf(debug_buff,"Searching for: %s,%s,%s,%s,%s,%s,%s\n", first, middle, last, maiden, city, state, country); |
| 225 debug_print(debug_buff); | 226 debug_print(debug_buff); |
| 226 sflap_send(buf, -1, TYPE_DATA); | 227 sflap_send(buf, -1, TYPE_DATA); |
| 227 #else | 228 } else { |
| 228 if (strlen(email)) | 229 if (strlen(email)) |
| 229 aim_usersearch_address(gaim_sess, gaim_conn, email); | 230 aim_usersearch_address(gaim_sess, gaim_conn, email); |
| 230 #endif | 231 } |
| 231 } | 232 } |
| 232 | 233 |
| 233 | 234 |
| 234 void serv_set_away(char *message) | 235 void serv_set_away(char *message) |
| 235 { | 236 { |
| 236 #ifndef USE_OSCAR | 237 if (!USE_OSCAR) { |
| 237 char buf[MSG_LEN]; | 238 char buf[MSG_LEN]; |
| 238 if (message) | 239 if (message) |
| 239 g_snprintf(buf, MSG_LEN, "toc_set_away \"%s\"", message); | 240 g_snprintf(buf, MSG_LEN, "toc_set_away \"%s\"", message); |
| 240 else | 241 else |
| 241 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); | 242 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); |
| 242 sflap_send(buf, -1, TYPE_DATA); | 243 sflap_send(buf, -1, TYPE_DATA); |
| 243 #else | 244 } else { |
| 244 aim_bos_setprofile(gaim_sess, gaim_conn, current_user->user_info, | 245 aim_bos_setprofile(gaim_sess, gaim_conn, current_user->user_info, |
| 245 message, gaim_caps); | 246 message, gaim_caps); |
| 246 #endif | 247 } |
| 247 } | 248 } |
| 248 | 249 |
| 249 void serv_set_info(char *info) | 250 void serv_set_info(char *info) |
| 250 { | 251 { |
| 251 #ifndef USE_OSCAR | 252 if (!USE_OSCAR) { |
| 252 char buf[MSG_LEN]; | 253 char buf[MSG_LEN]; |
| 253 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", info); | 254 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", info); |
| 254 sflap_send(buf, -1, TYPE_DATA); | 255 sflap_send(buf, -1, TYPE_DATA); |
| 255 #else | 256 } else { |
| 256 if (awaymessage) | 257 if (awaymessage) |
| 257 aim_bos_setprofile(gaim_sess, gaim_conn, info, | 258 aim_bos_setprofile(gaim_sess, gaim_conn, info, |
| 258 awaymessage->message, gaim_caps); | 259 awaymessage->message, gaim_caps); |
| 259 else | 260 else |
| 260 aim_bos_setprofile(gaim_sess, gaim_conn, info, | 261 aim_bos_setprofile(gaim_sess, gaim_conn, info, |
| 261 NULL, gaim_caps); | 262 NULL, gaim_caps); |
| 262 #endif | 263 } |
| 263 } | 264 } |
| 264 | 265 |
| 265 extern gboolean change_password; | 266 extern gboolean change_password; |
| 266 extern char *old_password; | 267 extern char *old_password; |
| 267 extern char *new_password; | 268 extern char *new_password; |
| 268 | 269 |
| 269 void serv_change_passwd(char *orig, char *new) { | 270 void serv_change_passwd(char *orig, char *new) { |
| 270 #ifndef USE_OSCAR | 271 if (!USE_OSCAR) { |
| 271 char *buf = g_malloc(BUF_LONG); | 272 char *buf = g_malloc(BUF_LONG); |
| 272 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); | 273 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); |
| 273 sflap_send(buf, strlen(buf), TYPE_DATA); | 274 sflap_send(buf, strlen(buf), TYPE_DATA); |
| 274 g_free(buf); | 275 g_free(buf); |
| 275 #else | 276 } else { |
| 276 if (change_password) return; | 277 if (change_password) return; |
| 277 change_password = TRUE; | 278 change_password = TRUE; |
| 278 old_password = g_strdup(orig); | 279 old_password = g_strdup(orig); |
| 279 new_password = g_strdup(new); | 280 new_password = g_strdup(new); |
| 280 aim_bos_reqservice(gaim_sess, gaim_conn, AIM_CONN_TYPE_AUTH); | 281 aim_bos_reqservice(gaim_sess, gaim_conn, AIM_CONN_TYPE_AUTH); |
| 281 #endif | 282 } |
| 282 } | 283 } |
| 283 | 284 |
| 284 void serv_add_buddy(char *name) | 285 void serv_add_buddy(char *name) |
| 285 { | 286 { |
| 286 #ifndef USE_OSCAR | 287 if (!USE_OSCAR) { |
| 287 char buf[1024]; | 288 char buf[1024]; |
| 288 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name)); | 289 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name)); |
| 289 sflap_send(buf, -1, TYPE_DATA); | 290 sflap_send(buf, -1, TYPE_DATA); |
| 290 #else | 291 } else { |
| 291 aim_add_buddy(gaim_sess, gaim_conn, name); | 292 aim_add_buddy(gaim_sess, gaim_conn, name); |
| 292 #endif | 293 } |
| 293 } | 294 } |
| 294 | 295 |
| 295 void serv_add_buddies(GList *buddies) | 296 void serv_add_buddies(GList *buddies) |
| 296 { | 297 { |
| 297 #ifndef USE_OSCAR | 298 if (!USE_OSCAR) { |
| 298 char buf[MSG_LEN]; | 299 char buf[MSG_LEN]; |
| 299 int n, num = 0; | 300 int n, num = 0; |
| 300 | 301 |
| 301 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | 302 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); |
| 302 while(buddies) { | 303 while(buddies) { |
| 308 ++num; | 309 ++num; |
| 309 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", normalize(buddies->data)); | 310 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", normalize(buddies->data)); |
| 310 buddies = buddies->next; | 311 buddies = buddies->next; |
| 311 } | 312 } |
| 312 sflap_send(buf, -1, TYPE_DATA); | 313 sflap_send(buf, -1, TYPE_DATA); |
| 313 #else | 314 } else { |
| 314 char buf[MSG_LEN]; | 315 char buf[MSG_LEN]; |
| 315 int n = 0; | 316 int n = 0; |
| 316 while(buddies) { | 317 while(buddies) { |
| 317 if (n > MSG_LEN - 18) { | 318 if (n > MSG_LEN - 18) { |
| 318 aim_bos_setbuddylist(gaim_sess, gaim_conn, buf); | 319 aim_bos_setbuddylist(gaim_sess, gaim_conn, buf); |
| 321 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", | 322 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", |
| 322 (char *)buddies->data); | 323 (char *)buddies->data); |
| 323 buddies = buddies->next; | 324 buddies = buddies->next; |
| 324 } | 325 } |
| 325 aim_bos_setbuddylist(gaim_sess, gaim_conn, buf); | 326 aim_bos_setbuddylist(gaim_sess, gaim_conn, buf); |
| 326 #endif | 327 } |
| 327 } | 328 } |
| 328 | 329 |
| 329 | 330 |
| 330 void serv_remove_buddy(char *name) | 331 void serv_remove_buddy(char *name) |
| 331 { | 332 { |
| 332 #ifndef USE_OSCAR | 333 if (!USE_OSCAR) { |
| 333 char buf[1024]; | 334 char buf[1024]; |
| 334 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name)); | 335 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name)); |
| 335 sflap_send(buf, -1, TYPE_DATA); | 336 sflap_send(buf, -1, TYPE_DATA); |
| 336 #else | 337 } else { |
| 337 aim_remove_buddy(gaim_sess, gaim_conn, name); | 338 aim_remove_buddy(gaim_sess, gaim_conn, name); |
| 338 #endif | 339 } |
| 339 } | 340 } |
| 340 | 341 |
| 341 void serv_add_permit(char *name) | 342 void serv_add_permit(char *name) |
| 342 { | 343 { |
| 343 #ifndef USE_OSCAR | 344 if (!USE_OSCAR) { |
| 344 char buf[1024]; | 345 char buf[1024]; |
| 345 g_snprintf(buf, sizeof(buf), "toc_add_permit %s", normalize(name)); | 346 g_snprintf(buf, sizeof(buf), "toc_add_permit %s", normalize(name)); |
| 346 sflap_send(buf, -1, TYPE_DATA); | 347 sflap_send(buf, -1, TYPE_DATA); |
| 347 #else | 348 } else { |
| 348 serv_set_permit_deny(); | 349 serv_set_permit_deny(); |
| 349 #endif | 350 } |
| 350 } | 351 } |
| 351 | 352 |
| 352 | 353 |
| 353 | 354 |
| 354 void serv_add_deny(char *name) | 355 void serv_add_deny(char *name) |
| 355 { | 356 { |
| 356 #ifndef USE_OSCAR | 357 if (!USE_OSCAR) { |
| 357 char buf[1024]; | 358 char buf[1024]; |
| 358 g_snprintf(buf, sizeof(buf), "toc_add_deny %s", normalize(name)); | 359 g_snprintf(buf, sizeof(buf), "toc_add_deny %s", normalize(name)); |
| 359 sflap_send(buf, -1, TYPE_DATA); | 360 sflap_send(buf, -1, TYPE_DATA); |
| 360 #else | 361 } else { |
| 361 serv_set_permit_deny(); | 362 serv_set_permit_deny(); |
| 362 #endif | 363 } |
| 363 } | 364 } |
| 364 | 365 |
| 365 | 366 |
| 366 | 367 |
| 367 void serv_set_permit_deny() | 368 void serv_set_permit_deny() |
| 368 { | 369 { |
| 369 #ifndef USE_OSCAR | 370 if (!USE_OSCAR) { |
| 370 char buf[MSG_LEN]; | 371 char buf[MSG_LEN]; |
| 371 int at; | 372 int at; |
| 372 GList *list; | 373 GList *list; |
| 373 | 374 |
| 374 if (permdeny == 1 || permdeny == 4) { | 375 if (permdeny == 1 || permdeny == 4) { |
| 399 list = list->next; | 400 list = list->next; |
| 400 } | 401 } |
| 401 buf[at] = 0; | 402 buf[at] = 0; |
| 402 sflap_send(buf, -1, TYPE_DATA); | 403 sflap_send(buf, -1, TYPE_DATA); |
| 403 } | 404 } |
| 404 #else | 405 } else { |
| 405 /* oscar requires us to do everyone at once (?) */ | 406 /* oscar requires us to do everyone at once (?) */ |
| 406 /* I think this code is OK now. */ | 407 /* I think this code is OK now. */ |
| 407 char buf[BUF_LONG]; int at; GList *list, *grp, *bud; | 408 char buf[BUF_LONG]; int at; GList *list, *grp, *bud; |
| 408 if (permdeny == 3) { /* Permit Some : Only people on buddy list and | 409 if (permdeny == 3) { /* Permit Some : Only people on buddy list and |
| 409 on permit list */ | 410 on permit list */ |
| 437 list = list->next; | 438 list = list->next; |
| 438 } | 439 } |
| 439 aim_bos_changevisibility(gaim_sess, gaim_conn, | 440 aim_bos_changevisibility(gaim_sess, gaim_conn, |
| 440 AIM_VISIBILITYCHANGE_DENYADD, buf); | 441 AIM_VISIBILITYCHANGE_DENYADD, buf); |
| 441 } | 442 } |
| 442 #endif | 443 } |
| 443 } | 444 } |
| 444 | 445 |
| 445 void serv_set_idle(int time) | 446 void serv_set_idle(int time) |
| 446 { | 447 { |
| 447 #ifndef USE_OSCAR | 448 if (!USE_OSCAR) { |
| 448 char buf[256]; | 449 char buf[256]; |
| 449 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); | 450 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); |
| 450 sflap_send(buf, -1, TYPE_DATA); | 451 sflap_send(buf, -1, TYPE_DATA); |
| 451 #else | 452 } else { |
| 452 aim_bos_setidle(gaim_sess, gaim_conn, time); | 453 aim_bos_setidle(gaim_sess, gaim_conn, time); |
| 453 #endif | 454 } |
| 454 } | 455 } |
| 455 | 456 |
| 456 | 457 |
| 457 void serv_warn(char *name, int anon) | 458 void serv_warn(char *name, int anon) |
| 458 { | 459 { |
| 459 #ifndef USE_OSCAR | 460 if (!USE_OSCAR) { |
| 460 char *send = g_malloc(256); | 461 char *send = g_malloc(256); |
| 461 g_snprintf(send, 255, "toc_evil %s %s", name, | 462 g_snprintf(send, 255, "toc_evil %s %s", name, |
| 462 ((anon) ? "anon" : "norm")); | 463 ((anon) ? "anon" : "norm")); |
| 463 sflap_send(send, -1, TYPE_DATA); | 464 sflap_send(send, -1, TYPE_DATA); |
| 464 g_free(send); | 465 g_free(send); |
| 465 #endif | 466 } |
| 466 } | 467 } |
| 467 | 468 |
| 468 void serv_build_config(char *buf, int len) { | 469 void serv_build_config(char *buf, int len) { |
| 469 toc_build_config(buf, len); | 470 toc_build_config(buf, len); |
| 470 } | 471 } |
| 471 | 472 |
| 472 | 473 |
| 473 void serv_save_config() | 474 void serv_save_config() |
| 474 { | 475 { |
| 475 #ifndef USE_OSCAR | 476 if (!USE_OSCAR) { |
| 476 char *buf = g_malloc(BUF_LONG); | 477 char *buf = g_malloc(BUF_LONG); |
| 477 char *buf2 = g_malloc(MSG_LEN); | 478 char *buf2 = g_malloc(MSG_LEN); |
| 478 serv_build_config(buf, BUF_LONG / 2); | 479 serv_build_config(buf, BUF_LONG / 2); |
| 479 g_snprintf(buf2, MSG_LEN, "toc_set_config {%s}", buf); | 480 g_snprintf(buf2, MSG_LEN, "toc_set_config {%s}", buf); |
| 480 sflap_send(buf2, -1, TYPE_DATA); | 481 sflap_send(buf2, -1, TYPE_DATA); |
| 481 g_free(buf2); | 482 g_free(buf2); |
| 482 g_free(buf); | 483 g_free(buf); |
| 483 #endif | 484 } |
| 484 } | 485 } |
| 485 | 486 |
| 486 | 487 |
| 487 void serv_accept_chat(int i) | 488 void serv_accept_chat(int i) |
| 488 { | 489 { |
| 489 #ifndef USE_OSCAR | 490 if (!USE_OSCAR) { |
| 490 char *buf = g_malloc(256); | 491 char *buf = g_malloc(256); |
| 491 g_snprintf(buf, 255, "toc_chat_accept %d", i); | 492 g_snprintf(buf, 255, "toc_chat_accept %d", i); |
| 492 sflap_send(buf, -1, TYPE_DATA); | 493 sflap_send(buf, -1, TYPE_DATA); |
| 493 g_free(buf); | 494 g_free(buf); |
| 494 #else | 495 } else { |
| 495 /* this should never get called because libfaim doesn't use the id | 496 /* this should never get called because libfaim doesn't use the id |
| 496 * (i'm not even sure Oscar does). go through serv_join_chat instead */ | 497 * (i'm not even sure Oscar does). go through serv_join_chat instead */ |
| 497 #endif | 498 } |
| 498 } | 499 } |
| 499 | 500 |
| 500 void serv_join_chat(int exchange, char *name) | 501 void serv_join_chat(int exchange, char *name) |
| 501 { | 502 { |
| 502 #ifndef USE_OSCAR | 503 if (!USE_OSCAR) { |
| 503 char buf[BUF_LONG]; | 504 char buf[BUF_LONG]; |
| 504 g_snprintf(buf, sizeof(buf)/2, "toc_chat_join %d \"%s\"", exchange, name); | 505 g_snprintf(buf, sizeof(buf)/2, "toc_chat_join %d \"%s\"", exchange, name); |
| 505 sflap_send(buf, -1, TYPE_DATA); | 506 sflap_send(buf, -1, TYPE_DATA); |
| 506 #else | 507 } else { |
| 507 sprintf(debug_buff, "Attempting to join chat room %s.\n", name); | 508 sprintf(debug_buff, "Attempting to join chat room %s.\n", name); |
| 508 debug_print(debug_buff); | 509 debug_print(debug_buff); |
| 509 /* aim_bos_reqservice(gaim_sess, gaim_conn, AIM_CONN_TYPE_CHATNAV); */ | 510 aim_chat_join(gaim_sess, gaim_conn, 0x0004, name); |
| 510 /* aim_chatnav_createroom(gaim_sess, aim_getconn_type(gaim_sess, AIM_CONN_TYPE_CHATNAV), name, 0x0004); */ | 511 } |
| 511 aim_chat_join(gaim_sess, gaim_conn, 0x0004, name); | |
| 512 #endif | |
| 513 } | 512 } |
| 514 | 513 |
| 515 void serv_chat_invite(int id, char *message, char *name) | 514 void serv_chat_invite(int id, char *message, char *name) |
| 516 { | 515 { |
| 517 #ifndef USE_OSCAR | 516 if (!USE_OSCAR) { |
| 518 char buf[BUF_LONG]; | 517 char buf[BUF_LONG]; |
| 519 g_snprintf(buf, sizeof(buf)/2, "toc_chat_invite %d \"%s\" %s", id, message, normalize(name)); | 518 g_snprintf(buf, sizeof(buf)/2, "toc_chat_invite %d \"%s\" %s", id, message, normalize(name)); |
| 520 sflap_send(buf, -1, TYPE_DATA); | 519 sflap_send(buf, -1, TYPE_DATA); |
| 521 #else | 520 } else { |
| 522 GList *bcs = buddy_chats; | 521 GList *bcs = buddy_chats; |
| 523 struct buddy_chat *b = NULL; | 522 struct buddy_chat *b = NULL; |
| 524 | 523 |
| 525 while (bcs) { | 524 while (bcs) { |
| 526 b = (struct buddy_chat *)bcs->data; | 525 b = (struct buddy_chat *)bcs->data; |
| 527 if (id == b->id) | 526 if (id == b->id) |
| 528 break; | 527 break; |
| 529 bcs = bcs->next; | 528 bcs = bcs->next; |
| 530 b = NULL; | 529 b = NULL; |
| 531 } | 530 } |
| 532 | 531 |
| 533 if (!b) | 532 if (!b) |
| 534 return; | 533 return; |
| 535 | 534 |
| 536 aim_chat_invite(gaim_sess, gaim_conn, name, message, 0x4, b->name, 0x1); | 535 aim_chat_invite(gaim_sess, gaim_conn, name, message, 0x4, b->name, 0x1); |
| 537 #endif | 536 } |
| 538 } | 537 } |
| 539 | 538 |
| 540 void serv_chat_leave(int id) | 539 void serv_chat_leave(int id) |
| 541 { | 540 { |
| 542 #ifndef USE_OSCAR | 541 if (!USE_OSCAR) { |
| 543 char *buf = g_malloc(256); | 542 char *buf = g_malloc(256); |
| 544 g_snprintf(buf, 255, "toc_chat_leave %d", id); | 543 g_snprintf(buf, 255, "toc_chat_leave %d", id); |
| 545 sflap_send(buf, -1, TYPE_DATA); | 544 sflap_send(buf, -1, TYPE_DATA); |
| 546 g_free(buf); | 545 g_free(buf); |
| 547 #else | 546 } else { |
| 548 GList *bcs = buddy_chats; | 547 GList *bcs = buddy_chats; |
| 549 struct buddy_chat *b = NULL; | 548 struct buddy_chat *b = NULL; |
| 550 struct chat_connection *c = NULL; | 549 struct chat_connection *c = NULL; |
| 551 int count = 0; | 550 int count = 0; |
| 552 | 551 |
| 574 g_free(c->name); | 573 g_free(c->name); |
| 575 g_free(c); | 574 g_free(c); |
| 576 } | 575 } |
| 577 /* we do this because with Oscar it doesn't tell us we left */ | 576 /* we do this because with Oscar it doesn't tell us we left */ |
| 578 serv_got_chat_left(b->id); | 577 serv_got_chat_left(b->id); |
| 579 #endif | 578 } |
| 580 } | 579 } |
| 581 | 580 |
| 582 void serv_chat_whisper(int id, char *who, char *message) | 581 void serv_chat_whisper(int id, char *who, char *message) |
| 583 { | 582 { |
| 584 #ifndef USE_OSCAR | 583 if (!USE_OSCAR) { |
| 585 char buf2[MSG_LEN]; | 584 char buf2[MSG_LEN]; |
| 586 g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, who, message); | 585 g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, who, message); |
| 587 sflap_send(buf2, -1, TYPE_DATA); | 586 sflap_send(buf2, -1, TYPE_DATA); |
| 588 #else | 587 } else { |
| 589 do_error_dialog("Sorry, Oscar doesn't whisper. Send an IM. (The last message was not received.)", | 588 do_error_dialog("Sorry, Oscar doesn't whisper. Send an IM. (The last message was not received.)", |
| 590 "Gaim - Chat"); | 589 "Gaim - Chat"); |
| 591 #endif | 590 } |
| 592 } | 591 } |
| 593 | 592 |
| 594 void serv_chat_send(int id, char *message) | 593 void serv_chat_send(int id, char *message) |
| 595 { | 594 { |
| 596 #ifndef USE_OSCAR | 595 if (!USE_OSCAR) { |
| 597 char buf[MSG_LEN]; | 596 char buf[MSG_LEN]; |
| 598 g_snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"",id, message); | 597 g_snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"",id, message); |
| 599 sflap_send(buf, -1, TYPE_DATA); | 598 sflap_send(buf, -1, TYPE_DATA); |
| 600 #else | 599 } else { |
| 601 struct aim_conn_t *cn; | 600 struct aim_conn_t *cn; |
| 602 GList *bcs = buddy_chats; | 601 GList *bcs = buddy_chats; |
| 603 struct buddy_chat *b = NULL; | 602 struct buddy_chat *b = NULL; |
| 604 | 603 |
| 605 while (bcs) { | 604 while (bcs) { |
| 606 b = (struct buddy_chat *)bcs->data; | 605 b = (struct buddy_chat *)bcs->data; |
| 607 if (id == b->id) | 606 if (id == b->id) |
| 608 break; | 607 break; |
| 609 bcs = bcs->next; | 608 bcs = bcs->next; |
| 610 b = NULL; | 609 b = NULL; |
| 611 } | 610 } |
| 612 if (!b) | 611 if (!b) |
| 613 return; | 612 return; |
| 614 | 613 |
| 615 cn = aim_chat_getconn(gaim_sess, b->name); | 614 cn = aim_chat_getconn(gaim_sess, b->name); |
| 616 aim_chat_send_im(gaim_sess, cn, message); | 615 aim_chat_send_im(gaim_sess, cn, message); |
| 617 #endif | 616 } |
| 618 } | 617 } |
| 619 | 618 |
| 620 | 619 |
| 621 | 620 |
| 622 | 621 |
| 881 gtk_widget_destroy(w2); | 880 gtk_widget_destroy(w2); |
| 882 } | 881 } |
| 883 | 882 |
| 884 static void chat_invite_callback(GtkWidget *w, GtkWidget *w2) | 883 static void chat_invite_callback(GtkWidget *w, GtkWidget *w2) |
| 885 { | 884 { |
| 886 #ifndef USE_OSCAR | 885 if (!USE_OSCAR) { |
| 887 int i = (int)gtk_object_get_user_data(GTK_OBJECT(w2)); | 886 int i = (int)gtk_object_get_user_data(GTK_OBJECT(w2)); |
| 888 serv_accept_chat(i); | 887 serv_accept_chat(i); |
| 889 gtk_widget_destroy(w2); | 888 gtk_widget_destroy(w2); |
| 890 #else | 889 } else { |
| 891 char *i = (char *)gtk_object_get_user_data(GTK_OBJECT(w2)); | 890 char *i = (char *)gtk_object_get_user_data(GTK_OBJECT(w2)); |
| 892 serv_join_chat(0, i); /* for oscar, it doesn't use the id anyway */ | 891 serv_join_chat(0, i); /* for oscar, it doesn't use the id anyway */ |
| 893 g_free(i); | 892 g_free(i); |
| 894 gtk_widget_destroy(w2); | 893 gtk_widget_destroy(w2); |
| 895 #endif | 894 } |
| 896 } | 895 } |
| 897 | 896 |
| 898 | 897 |
| 899 | 898 |
| 900 void serv_got_chat_invite(char *name, int id, char *who, char *message) | 899 void serv_got_chat_invite(char *name, int id, char *who, char *message) |
| 944 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), | 943 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), |
| 945 nobtn, FALSE, FALSE, 5); | 944 nobtn, FALSE, FALSE, 5); |
| 946 | 945 |
| 947 | 946 |
| 948 /* gtk_widget_set_usize(d, 200, 110); */ | 947 /* gtk_widget_set_usize(d, 200, 110); */ |
| 949 #ifndef USE_OSCAR | 948 |
| 950 gtk_object_set_user_data(GTK_OBJECT(d), (void *)id); | 949 if (!USE_OSCAR) |
| 951 #else | 950 gtk_object_set_user_data(GTK_OBJECT(d), (void *)id); |
| 952 gtk_object_set_user_data(GTK_OBJECT(d), (void *)g_strdup(name)); | 951 else |
| 953 #endif | 952 gtk_object_set_user_data(GTK_OBJECT(d), (void *)g_strdup(name)); |
| 954 | 953 |
| 955 | 954 |
| 956 gtk_window_set_title(GTK_WINDOW(d), "Buddy chat invite"); | 955 gtk_window_set_title(GTK_WINDOW(d), "Buddy chat invite"); |
| 957 gtk_signal_connect(GTK_OBJECT(nobtn), "clicked", GTK_SIGNAL_FUNC(close_invite), d); | 956 gtk_signal_connect(GTK_OBJECT(nobtn), "clicked", GTK_SIGNAL_FUNC(close_invite), d); |
| 958 gtk_signal_connect(GTK_OBJECT(yesbtn), "clicked", GTK_SIGNAL_FUNC(chat_invite_callback), d); | 957 gtk_signal_connect(GTK_OBJECT(yesbtn), "clicked", GTK_SIGNAL_FUNC(chat_invite_callback), d); |
| 1072 chat_write(b, who, w, message); | 1071 chat_write(b, who, w, message); |
| 1073 } | 1072 } |
| 1074 | 1073 |
| 1075 void serv_rvous_accept(char *name, char *cookie, char *uid) | 1074 void serv_rvous_accept(char *name, char *cookie, char *uid) |
| 1076 { | 1075 { |
| 1077 #ifndef USE_OSCAR | 1076 /* Oscar doesn't matter here because this won't ever be called for it */ |
| 1078 char buf[MSG_LEN]; | 1077 char buf[MSG_LEN]; |
| 1079 g_snprintf(buf, MSG_LEN, "toc_rvous_accept %s %s %s", normalize(name), | 1078 g_snprintf(buf, MSG_LEN, "toc_rvous_accept %s %s %s", normalize(name), |
| 1080 cookie, uid); | 1079 cookie, uid); |
| 1081 sflap_send(buf, strlen(buf), TYPE_DATA); | 1080 sflap_send(buf, strlen(buf), TYPE_DATA); |
| 1082 #endif | |
| 1083 } | 1081 } |
| 1084 | 1082 |
| 1085 void serv_rvous_cancel(char *name, char *cookie, char *uid) | 1083 void serv_rvous_cancel(char *name, char *cookie, char *uid) |
| 1086 { | 1084 { |
| 1087 #ifndef USE_OSCAR | |
| 1088 char buf[MSG_LEN]; | 1085 char buf[MSG_LEN]; |
| 1089 g_snprintf(buf, MSG_LEN, "toc_rvous_cancel %s %s %s", normalize(name), | 1086 g_snprintf(buf, MSG_LEN, "toc_rvous_cancel %s %s %s", normalize(name), |
| 1090 cookie, uid); | 1087 cookie, uid); |
| 1091 sflap_send(buf, strlen(buf), TYPE_DATA); | 1088 sflap_send(buf, strlen(buf), TYPE_DATA); |
| 1092 #endif | 1089 } |
| 1093 } |
