Mercurial > pidgin
comparison src/server.c @ 7118:bf630f7dfdcd
[gaim-migrate @ 7685]
Here's a commit that I think will make faceprint happy. GaimWindow ->
GaimConvWindow, GaimIm -> GaimConvIm, GaimChat -> GaimConvChat,
GaimBlistChat -> GaimChat, and updated the API functions as well. Plugin
authors are going to hunt me down and murder me. I can feel it..
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 02 Oct 2003 02:54:07 +0000 |
parents | 6faeeecab0dc |
children | 1930e3d00ecd |
comparison
equal
deleted
inserted
replaced
7117:943085b0ff8b | 7118:bf630f7dfdcd |
---|---|
256 } | 256 } |
257 } | 257 } |
258 } | 258 } |
259 | 259 |
260 int serv_send_im(GaimConnection *gc, const char *name, const char *message, | 260 int serv_send_im(GaimConnection *gc, const char *name, const char *message, |
261 GaimImFlags imflags) | 261 GaimConvImFlags imflags) |
262 { | 262 { |
263 GaimConversation *c; | 263 GaimConversation *c; |
264 int val = -EINVAL; | 264 int val = -EINVAL; |
265 GaimPluginProtocolInfo *prpl_info = NULL; | 265 GaimPluginProtocolInfo *prpl_info = NULL; |
266 | 266 |
270 c = gaim_find_conversation_with_account(name, gc->account); | 270 c = gaim_find_conversation_with_account(name, gc->account); |
271 | 271 |
272 if (prpl_info && prpl_info->send_im) | 272 if (prpl_info && prpl_info->send_im) |
273 val = prpl_info->send_im(gc, name, message, imflags); | 273 val = prpl_info->send_im(gc, name, message, imflags); |
274 | 274 |
275 if (!(imflags & GAIM_IM_AUTO_RESP)) | 275 if (!(imflags & GAIM_CONV_IM_AUTO_RESP)) |
276 serv_touch_idle(gc); | 276 serv_touch_idle(gc); |
277 | 277 |
278 if (gc->away && | 278 if (gc->away && |
279 (gc->flags & GAIM_CONNECTION_AUTO_RESP) && | 279 (gc->flags & GAIM_CONNECTION_AUTO_RESP) && |
280 gaim_prefs_get_bool("/core/away/auto_response/enabled") && | 280 gaim_prefs_get_bool("/core/away/auto_response/enabled") && |
283 struct last_auto_response *lar; | 283 struct last_auto_response *lar; |
284 lar = get_last_auto_response(gc, name); | 284 lar = get_last_auto_response(gc, name); |
285 lar->sent = time(NULL); | 285 lar->sent = time(NULL); |
286 } | 286 } |
287 | 287 |
288 if (c && gaim_im_get_type_again_timeout(GAIM_IM(c))) | 288 if (c && gaim_conv_im_get_type_again_timeout(GAIM_CONV_IM(c))) |
289 gaim_im_stop_type_again_timeout(GAIM_IM(c)); | 289 gaim_conv_im_stop_type_again_timeout(GAIM_CONV_IM(c)); |
290 | 290 |
291 return val; | 291 return val; |
292 } | 292 } |
293 | 293 |
294 void serv_get_info(GaimConnection *g, const char *name) | 294 void serv_get_info(GaimConnection *g, const char *name) |
833 /* | 833 /* |
834 * woo. i'm actually going to comment this function. isn't that fun. make | 834 * woo. i'm actually going to comment this function. isn't that fun. make |
835 * sure to follow along, kids | 835 * sure to follow along, kids |
836 */ | 836 */ |
837 void serv_got_im(GaimConnection *gc, const char *who, const char *msg, | 837 void serv_got_im(GaimConnection *gc, const char *who, const char *msg, |
838 GaimImFlags imflags, time_t mtime) | 838 GaimConvImFlags imflags, time_t mtime) |
839 { | 839 { |
840 GaimConversation *cnv; | 840 GaimConversation *cnv; |
841 GaimMessageFlags msgflags; | 841 GaimMessageFlags msgflags; |
842 char *message, *name; | 842 char *message, *name; |
843 char *angel, *buffy; | 843 char *angel, *buffy; |
890 * prpls don't have to know about GAIM_MESSAGE_* (though some do anyway). | 890 * prpls don't have to know about GAIM_MESSAGE_* (though some do anyway). |
891 * We also need to preserve the flag that tells the UI to look for the | 891 * We also need to preserve the flag that tells the UI to look for the |
892 * associated images. | 892 * associated images. |
893 */ | 893 */ |
894 msgflags = GAIM_MESSAGE_RECV; | 894 msgflags = GAIM_MESSAGE_RECV; |
895 if (imflags & GAIM_IM_AUTO_RESP) | 895 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
896 msgflags |= GAIM_MESSAGE_AUTO_RESP; | 896 msgflags |= GAIM_MESSAGE_AUTO_RESP; |
897 if (imflags & GAIM_IM_IMAGES) | 897 if (imflags & GAIM_CONV_IM_IMAGES) |
898 msgflags |= GAIM_MESSAGE_IMAGES; | 898 msgflags |= GAIM_MESSAGE_IMAGES; |
899 | 899 |
900 /* | 900 /* |
901 * Alright. Two cases for how to handle this. Either we're away or | 901 * Alright. Two cases for how to handle this. Either we're away or |
902 * we're not. If we're not, then it's easy. If we are, then there | 902 * we're not. If we're not, then it's easy. If we are, then there |
970 * while away), and then write it to the convo window. | 970 * while away), and then write it to the convo window. |
971 */ | 971 */ |
972 if (cnv == NULL) | 972 if (cnv == NULL) |
973 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name); | 973 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name); |
974 | 974 |
975 gaim_im_write(GAIM_IM(cnv), NULL, message, msgflags, mtime); | 975 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, message, msgflags, mtime); |
976 } | 976 } |
977 | 977 |
978 /* | 978 /* |
979 * Regardless of whether we queue it or not, we should send an | 979 * Regardless of whether we queue it or not, we should send an |
980 * auto-response. That is, of course, unless the horse.... no wait. | 980 * auto-response. That is, of course, unless the horse.... no wait. |
1016 } | 1016 } |
1017 lar->sent = t; | 1017 lar->sent = t; |
1018 | 1018 |
1019 /* apply default fonts and colors */ | 1019 /* apply default fonts and colors */ |
1020 tmpmsg = stylize(gc->away, MSG_LEN); | 1020 tmpmsg = stylize(gc->away, MSG_LEN); |
1021 serv_send_im(gc, name, gaim_str_sub_away_formatters(tmpmsg, alias), GAIM_IM_AUTO_RESP); | 1021 serv_send_im(gc, name, gaim_str_sub_away_formatters(tmpmsg, alias), GAIM_CONV_IM_AUTO_RESP); |
1022 if (!cnv && awayqueue && | 1022 if (!cnv && awayqueue && |
1023 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { | 1023 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
1024 | 1024 |
1025 struct queued_message *qm; | 1025 struct queued_message *qm; |
1026 | 1026 |
1030 qm->account = gc->account; | 1030 qm->account = gc->account; |
1031 qm->tm = mtime; | 1031 qm->tm = mtime; |
1032 qm->flags = GAIM_MESSAGE_SEND | GAIM_MESSAGE_AUTO_RESP; | 1032 qm->flags = GAIM_MESSAGE_SEND | GAIM_MESSAGE_AUTO_RESP; |
1033 message_queue = g_slist_append(message_queue, qm); | 1033 message_queue = g_slist_append(message_queue, qm); |
1034 } else if (cnv != NULL) | 1034 } else if (cnv != NULL) |
1035 gaim_im_write(GAIM_IM(cnv), NULL, gaim_str_sub_away_formatters(tmpmsg, alias), | 1035 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, gaim_str_sub_away_formatters(tmpmsg, alias), |
1036 GAIM_MESSAGE_SEND | GAIM_MESSAGE_AUTO_RESP, mtime); | 1036 GAIM_MESSAGE_SEND | GAIM_MESSAGE_AUTO_RESP, mtime); |
1037 | 1037 |
1038 g_free(tmpmsg); | 1038 g_free(tmpmsg); |
1039 } else { | 1039 } else { |
1040 /* | 1040 /* |
1066 } | 1066 } |
1067 else { | 1067 else { |
1068 if (cnv == NULL) | 1068 if (cnv == NULL) |
1069 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name); | 1069 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name); |
1070 | 1070 |
1071 gaim_im_write(GAIM_IM(cnv), NULL, message, msgflags, mtime); | 1071 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, message, msgflags, mtime); |
1072 gaim_window_flash(gaim_conversation_get_window(cnv)); | 1072 gaim_conv_window_flash(gaim_conversation_get_window(cnv)); |
1073 } | 1073 } |
1074 } | 1074 } |
1075 | 1075 |
1076 g_free(name); | 1076 g_free(name); |
1077 g_free(message); | 1077 g_free(message); |
1235 void serv_got_typing(GaimConnection *gc, const char *name, int timeout, | 1235 void serv_got_typing(GaimConnection *gc, const char *name, int timeout, |
1236 GaimTypingState state) { | 1236 GaimTypingState state) { |
1237 | 1237 |
1238 GaimBuddy *b; | 1238 GaimBuddy *b; |
1239 GaimConversation *cnv = gaim_find_conversation_with_account(name, gc->account); | 1239 GaimConversation *cnv = gaim_find_conversation_with_account(name, gc->account); |
1240 GaimIm *im; | 1240 GaimConvIm *im; |
1241 | 1241 |
1242 if (!cnv) | 1242 if (!cnv) |
1243 return; | 1243 return; |
1244 | 1244 |
1245 im = GAIM_IM(cnv); | 1245 im = GAIM_CONV_IM(cnv); |
1246 | 1246 |
1247 gaim_conversation_set_account(cnv, gc->account); | 1247 gaim_conversation_set_account(cnv, gc->account); |
1248 gaim_im_set_typing_state(im, state); | 1248 gaim_conv_im_set_typing_state(im, state); |
1249 gaim_im_update_typing(im); | 1249 gaim_conv_im_update_typing(im); |
1250 | 1250 |
1251 b = gaim_find_buddy(gc->account, name); | 1251 b = gaim_find_buddy(gc->account, name); |
1252 | 1252 |
1253 if (b != NULL) | 1253 if (b != NULL) |
1254 { | 1254 { |
1263 "buddy-typing-stopped", cnv); | 1263 "buddy-typing-stopped", cnv); |
1264 } | 1264 } |
1265 } | 1265 } |
1266 | 1266 |
1267 if (timeout > 0) | 1267 if (timeout > 0) |
1268 gaim_im_start_typing_timeout(im, timeout); | 1268 gaim_conv_im_start_typing_timeout(im, timeout); |
1269 } | 1269 } |
1270 | 1270 |
1271 void serv_got_typing_stopped(GaimConnection *gc, const char *name) { | 1271 void serv_got_typing_stopped(GaimConnection *gc, const char *name) { |
1272 | 1272 |
1273 GaimConversation *c = gaim_find_conversation_with_account(name, gc->account); | 1273 GaimConversation *c = gaim_find_conversation_with_account(name, gc->account); |
1274 GaimIm *im; | 1274 GaimConvIm *im; |
1275 GaimBuddy *b; | 1275 GaimBuddy *b; |
1276 | 1276 |
1277 if (!c) | 1277 if (!c) |
1278 return; | 1278 return; |
1279 | 1279 |
1280 im = GAIM_IM(c); | 1280 im = GAIM_CONV_IM(c); |
1281 | 1281 |
1282 if (im->typing_state == GAIM_NOT_TYPING) | 1282 if (im->typing_state == GAIM_NOT_TYPING) |
1283 return; | 1283 return; |
1284 | 1284 |
1285 gaim_im_stop_typing_timeout(im); | 1285 gaim_conv_im_stop_typing_timeout(im); |
1286 gaim_im_set_typing_state(im, GAIM_NOT_TYPING); | 1286 gaim_conv_im_set_typing_state(im, GAIM_NOT_TYPING); |
1287 gaim_im_update_typing(im); | 1287 gaim_conv_im_update_typing(im); |
1288 | 1288 |
1289 b = gaim_find_buddy(gc->account, name); | 1289 b = gaim_find_buddy(gc->account, name); |
1290 | 1290 |
1291 if (b != NULL) | 1291 if (b != NULL) |
1292 { | 1292 { |
1348 | 1348 |
1349 GaimConversation *serv_got_joined_chat(GaimConnection *gc, | 1349 GaimConversation *serv_got_joined_chat(GaimConnection *gc, |
1350 int id, const char *name) | 1350 int id, const char *name) |
1351 { | 1351 { |
1352 GaimConversation *conv; | 1352 GaimConversation *conv; |
1353 GaimChat *chat; | 1353 GaimConvChat *chat; |
1354 GaimAccount *account; | 1354 GaimAccount *account; |
1355 | 1355 |
1356 account = gaim_connection_get_account(gc); | 1356 account = gaim_connection_get_account(gc); |
1357 | 1357 |
1358 conv = gaim_conversation_new(GAIM_CONV_CHAT, account, name); | 1358 conv = gaim_conversation_new(GAIM_CONV_CHAT, account, name); |
1359 chat = GAIM_CHAT(conv); | 1359 chat = GAIM_CONV_CHAT(conv); |
1360 | 1360 |
1361 gc->buddy_chats = g_slist_append(gc->buddy_chats, conv); | 1361 gc->buddy_chats = g_slist_append(gc->buddy_chats, conv); |
1362 | 1362 |
1363 gaim_chat_set_id(chat, id); | 1363 gaim_conv_chat_set_id(chat, id); |
1364 | 1364 |
1365 /* TODO Move this to UI logging code! */ | 1365 /* TODO Move this to UI logging code! */ |
1366 if (gaim_prefs_get_bool("/gaim/gtk/logging/log_chats") || | 1366 if (gaim_prefs_get_bool("/gaim/gtk/logging/log_chats") || |
1367 find_log_info(gaim_conversation_get_name(conv))) { | 1367 find_log_info(gaim_conversation_get_name(conv))) { |
1368 | 1368 |
1385 fclose(fd); | 1385 fclose(fd); |
1386 } | 1386 } |
1387 free(filename); | 1387 free(filename); |
1388 } | 1388 } |
1389 | 1389 |
1390 gaim_window_show(gaim_conversation_get_window(conv)); | 1390 gaim_conv_window_show(gaim_conversation_get_window(conv)); |
1391 gaim_window_switch_conversation(gaim_conversation_get_window(conv), | 1391 gaim_conv_window_switch_conversation(gaim_conversation_get_window(conv), |
1392 gaim_conversation_get_index(conv)); | 1392 gaim_conversation_get_index(conv)); |
1393 | 1393 |
1394 gaim_signal_emit(gaim_conversations_get_handle(), "chat-joined", conv); | 1394 gaim_signal_emit(gaim_conversations_get_handle(), "chat-joined", conv); |
1395 | 1395 |
1396 return conv; | 1396 return conv; |
1398 | 1398 |
1399 void serv_got_chat_left(GaimConnection *g, int id) | 1399 void serv_got_chat_left(GaimConnection *g, int id) |
1400 { | 1400 { |
1401 GSList *bcs; | 1401 GSList *bcs; |
1402 GaimConversation *conv = NULL; | 1402 GaimConversation *conv = NULL; |
1403 GaimChat *chat = NULL; | 1403 GaimConvChat *chat = NULL; |
1404 GaimAccount *account; | 1404 GaimAccount *account; |
1405 | 1405 |
1406 account = gaim_connection_get_account(g); | 1406 account = gaim_connection_get_account(g); |
1407 | 1407 |
1408 for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { | 1408 for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { |
1409 conv = (GaimConversation *)bcs->data; | 1409 conv = (GaimConversation *)bcs->data; |
1410 | 1410 |
1411 chat = GAIM_CHAT(conv); | 1411 chat = GAIM_CONV_CHAT(conv); |
1412 | 1412 |
1413 if (gaim_chat_get_id(chat) == id) | 1413 if (gaim_conv_chat_get_id(chat) == id) |
1414 break; | 1414 break; |
1415 | 1415 |
1416 conv = NULL; | 1416 conv = NULL; |
1417 } | 1417 } |
1418 | 1418 |
1433 int whisper, const char *message, time_t mtime) | 1433 int whisper, const char *message, time_t mtime) |
1434 { | 1434 { |
1435 GaimMessageFlags w; | 1435 GaimMessageFlags w; |
1436 GSList *bcs; | 1436 GSList *bcs; |
1437 GaimConversation *conv = NULL; | 1437 GaimConversation *conv = NULL; |
1438 GaimChat *chat = NULL; | 1438 GaimConvChat *chat = NULL; |
1439 char *buf; | 1439 char *buf; |
1440 char *buffy, *angel; | 1440 char *buffy, *angel; |
1441 int plugin_return; | 1441 int plugin_return; |
1442 | 1442 |
1443 for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { | 1443 for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { |
1444 conv = (GaimConversation *)bcs->data; | 1444 conv = (GaimConversation *)bcs->data; |
1445 | 1445 |
1446 chat = GAIM_CHAT(conv); | 1446 chat = GAIM_CONV_CHAT(conv); |
1447 | 1447 |
1448 if (gaim_chat_get_id(chat) == id) | 1448 if (gaim_conv_chat_get_id(chat) == id) |
1449 break; | 1449 break; |
1450 | 1450 |
1451 conv = NULL; | 1451 conv = NULL; |
1452 } | 1452 } |
1453 | 1453 |
1468 | 1468 |
1469 plugin_return = GPOINTER_TO_INT( | 1469 plugin_return = GPOINTER_TO_INT( |
1470 gaim_signal_emit_return_1(gaim_conversations_get_handle(), | 1470 gaim_signal_emit_return_1(gaim_conversations_get_handle(), |
1471 "received-chat-msg", g->account, | 1471 "received-chat-msg", g->account, |
1472 &angel, &buffy, | 1472 &angel, &buffy, |
1473 gaim_chat_get_id(GAIM_CHAT(conv)))); | 1473 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)))); |
1474 | 1474 |
1475 if (!buffy || !angel || plugin_return) { | 1475 if (!buffy || !angel || plugin_return) { |
1476 if (buffy) | 1476 if (buffy) |
1477 g_free(buffy); | 1477 g_free(buffy); |
1478 if (angel) | 1478 if (angel) |
1492 if (whisper) | 1492 if (whisper) |
1493 w = GAIM_MESSAGE_WHISPER; | 1493 w = GAIM_MESSAGE_WHISPER; |
1494 else | 1494 else |
1495 w = 0; | 1495 w = 0; |
1496 | 1496 |
1497 gaim_chat_write(chat, who, buf, w, mtime); | 1497 gaim_conv_chat_write(chat, who, buf, w, mtime); |
1498 | 1498 |
1499 g_free(angel); | 1499 g_free(angel); |
1500 g_free(buf); | 1500 g_free(buf); |
1501 g_free(buffy); | 1501 g_free(buffy); |
1502 } | 1502 } |