Mercurial > pidgin.yaz
comparison src/server.c @ 6622:a4622f1fb5a1
[gaim-migrate @ 7146]
(10:10:23) Robot101: kills off OPT_CONN_* in favour of an enum, and deprecates all
the IM_FLAGS_* except IM_FLAG_AWAY which is made into GAIM_IM_AUTO_RESP in a
GaimImFlags enum.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 25 Aug 2003 14:12:28 +0000 |
parents | 42fdf16f1dad |
children | 22346bcb50c2 |
comparison
equal
deleted
inserted
replaced
6621:42fdf16f1dad | 6622:a4622f1fb5a1 |
---|---|
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 int len, int imflags) | 261 int len, GaimImFlags 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(name); | 270 c = gaim_find_conversation(name); |
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, len, imflags); | 273 val = prpl_info->send_im(gc, name, message, len, imflags); |
274 | 274 |
275 if (!(imflags & IM_FLAG_AWAY)) | 275 if (!(imflags & GAIM_MESSAGE_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 & OPT_CONN_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") && |
281 !gaim_prefs_get_bool("/core/away/auto_response/in_active_conv")) { | 281 !gaim_prefs_get_bool("/core/away/auto_response/in_active_conv")) { |
282 | 282 |
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); |
811 /* | 811 /* |
812 * woo. i'm actually going to comment this function. isn't that fun. make | 812 * woo. i'm actually going to comment this function. isn't that fun. make |
813 * sure to follow along, kids | 813 * sure to follow along, kids |
814 */ | 814 */ |
815 void serv_got_im(GaimConnection *gc, const char *who, const char *msg, | 815 void serv_got_im(GaimConnection *gc, const char *who, const char *msg, |
816 guint32 imflags, time_t mtime, gint len) | 816 GaimImFlags imflags, time_t mtime, gint len) |
817 { | 817 { |
818 char *buffy; | 818 GaimConversation *cnv; |
819 char *angel; | 819 GaimMessageFlags auto_resp; |
820 char *message, *name; | |
821 char *angel, *buffy; | |
820 int plugin_return; | 822 int plugin_return; |
821 GaimMessageFlags away = 0; | |
822 | |
823 GaimConversation *cnv; | |
824 | |
825 char *message, *name; | |
826 | |
827 /* | |
828 * Pay no attention to the man behind the curtain. | |
829 * | |
830 * The reason i feel okay with this is because it's useful to some | |
831 * plugins. Gaim doesn't ever use it itself. Besides, it's not entirely | |
832 * accurate; it's possible to have false negatives with most protocols. | |
833 * Also with some it's easy to have false positives as well. So if you're | |
834 * a plugin author, don't rely on this, still do your own checks. But uh. | |
835 * It's a start. | |
836 */ | |
837 | |
838 if (imflags & IM_FLAG_GAIMUSER) | |
839 gaim_debug(GAIM_DEBUG_MISC, "server", "%s is a gaim user.\n", who); | |
840 | 823 |
841 /* | 824 /* |
842 * We should update the conversation window buttons and menu, | 825 * We should update the conversation window buttons and menu, |
843 * if it exists. | 826 * if it exists. |
844 */ | 827 */ |
891 * Um. When we call gaim_conversation_write with the message we received, | 874 * Um. When we call gaim_conversation_write with the message we received, |
892 * it's nice to pass whether or not it was an auto-response. So if it | 875 * it's nice to pass whether or not it was an auto-response. So if it |
893 * was an auto-response, we set the appropriate flag. This is just so | 876 * was an auto-response, we set the appropriate flag. This is just so |
894 * prpls don't have to know about GAIM_MESSAGE_* (though some do anyway) | 877 * prpls don't have to know about GAIM_MESSAGE_* (though some do anyway) |
895 */ | 878 */ |
896 if (imflags & IM_FLAG_AWAY) | 879 if (imflags & GAIM_IM_AUTO_RESP) |
897 away = GAIM_MESSAGE_AUTO_RESP; | 880 auto_resp = GAIM_MESSAGE_AUTO_RESP; |
881 else | |
882 auto_resp = 0; | |
898 | 883 |
899 /* | 884 /* |
900 * Alright. Two cases for how to handle this. Either we're away or | 885 * Alright. Two cases for how to handle this. Either we're away or |
901 * we're not. If we're not, then it's easy. If we are, then there | 886 * we're not. If we're not, then it's easy. If we are, then there |
902 * are three or four different ways of handling it and different | 887 * are three or four different ways of handling it and different |
934 qm = g_new0(struct queued_message, 1); | 919 qm = g_new0(struct queued_message, 1); |
935 g_snprintf(qm->name, sizeof(qm->name), "%s", name); | 920 g_snprintf(qm->name, sizeof(qm->name), "%s", name); |
936 qm->message = g_memdup(message, len == -1 ? strlen(message) + 1 : len); | 921 qm->message = g_memdup(message, len == -1 ? strlen(message) + 1 : len); |
937 qm->account = gc->account; | 922 qm->account = gc->account; |
938 qm->tm = mtime; | 923 qm->tm = mtime; |
939 qm->flags = GAIM_MESSAGE_RECV | away; | 924 qm->flags = GAIM_MESSAGE_RECV | auto_resp; |
940 qm->len = len; | 925 qm->len = len; |
941 message_queue = g_slist_append(message_queue, qm); | 926 message_queue = g_slist_append(message_queue, qm); |
942 | 927 |
943 row = find_queue_row_by_name(qm->name); | 928 row = find_queue_row_by_name(qm->name); |
944 if (row >= 0) { | 929 if (row >= 0) { |
971 */ | 956 */ |
972 if (cnv == NULL) | 957 if (cnv == NULL) |
973 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name); | 958 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name); |
974 | 959 |
975 gaim_im_write(GAIM_IM(cnv), NULL, message, len, | 960 gaim_im_write(GAIM_IM(cnv), NULL, message, len, |
976 away | GAIM_MESSAGE_RECV, mtime); | 961 GAIM_MESSAGE_RECV | auto_resp, mtime); |
977 } | 962 } |
978 | 963 |
979 /* | 964 /* |
980 * Regardless of whether we queue it or not, we should send an | 965 * Regardless of whether we queue it or not, we should send an |
981 * auto-response. That is, of course, unless the horse.... no wait. | 966 * auto-response. That is, of course, unless the horse.... no wait. |
985 * - or it's disabled | 970 * - or it's disabled |
986 * - or the away message is empty | 971 * - or the away message is empty |
987 * - or we're not idle and the 'only auto respond if idle' pref | 972 * - or we're not idle and the 'only auto respond if idle' pref |
988 * is set | 973 * is set |
989 */ | 974 */ |
990 if (!(gc->flags & OPT_CONN_AUTO_RESP) || | 975 if (!(gc->flags & GAIM_CONNECTION_AUTO_RESP) || |
991 !gaim_prefs_get_bool("/core/away/auto_response/enabled") || | 976 !gaim_prefs_get_bool("/core/away/auto_response/enabled") || |
992 *gc->away == '\0' || | 977 *gc->away == '\0' || |
993 (!gc->is_idle && | 978 (!gc->is_idle && |
994 gaim_prefs_get_bool("/core/away/auto_response/idle_only"))) { | 979 gaim_prefs_get_bool("/core/away/auto_response/idle_only"))) { |
995 | 980 |
1017 } | 1002 } |
1018 lar->sent = t; | 1003 lar->sent = t; |
1019 | 1004 |
1020 /* apply default fonts and colors */ | 1005 /* apply default fonts and colors */ |
1021 tmpmsg = stylize(gc->away, MSG_LEN); | 1006 tmpmsg = stylize(gc->away, MSG_LEN); |
1022 serv_send_im(gc, name, away_subs(tmpmsg, alias), -1, IM_FLAG_AWAY); | 1007 serv_send_im(gc, name, away_subs(tmpmsg, alias), -1, GAIM_IM_AUTO_RESP); |
1023 if (!cnv && awayqueue && | 1008 if (!cnv && awayqueue && |
1024 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { | 1009 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
1025 | 1010 |
1026 struct queued_message *qm; | 1011 struct queued_message *qm; |
1027 | 1012 |
1061 qm = g_new0(struct queued_message, 1); | 1046 qm = g_new0(struct queued_message, 1); |
1062 g_snprintf(qm->name, sizeof(qm->name), "%s", name); | 1047 g_snprintf(qm->name, sizeof(qm->name), "%s", name); |
1063 qm->message = g_strdup(message); | 1048 qm->message = g_strdup(message); |
1064 qm->account = gc->account; | 1049 qm->account = gc->account; |
1065 qm->tm = mtime; | 1050 qm->tm = mtime; |
1066 qm->flags = away | GAIM_MESSAGE_RECV; | 1051 qm->flags = GAIM_MESSAGE_RECV | auto_resp; |
1067 qm->len = len; | 1052 qm->len = len; |
1068 unread_message_queue = g_slist_append(unread_message_queue, qm); | 1053 unread_message_queue = g_slist_append(unread_message_queue, qm); |
1069 } | 1054 } |
1070 else { | 1055 else { |
1071 if (cnv == NULL) | 1056 if (cnv == NULL) |
1072 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name); | 1057 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name); |
1073 | 1058 |
1074 gaim_im_write(GAIM_IM(cnv), NULL, message, len, | 1059 gaim_im_write(GAIM_IM(cnv), NULL, message, len, |
1075 away | GAIM_MESSAGE_RECV, mtime); | 1060 GAIM_MESSAGE_RECV | auto_resp, mtime); |
1076 gaim_window_flash(gaim_conversation_get_window(cnv)); | 1061 gaim_window_flash(gaim_conversation_get_window(cnv)); |
1077 } | 1062 } |
1078 } | 1063 } |
1079 | 1064 |
1080 g_free(name); | 1065 g_free(name); |