comparison src/server.c @ 6621:42fdf16f1dad

[gaim-migrate @ 7145] Individual accounts remember the "No Proxy" setting instead of reverting back to "Use Global Proxy Settings" Proxy settings for individual accounts do not revert to "No Proxy" if you open an account, don't change the proxy drop down, then save the account. Those two sound like the same thing, but they're different. I think. Added the "use environmental variables" setting in a way that isn't horrible. We're not using that thing that splits the proxy variable into host:port yet. I'll do that later. I would have done that earlier, but I had to go buy a bike. Also, I'd like to show what the environmental variables are set to somewhere. That'll come later. Also a patch from Robot101: (22:10:25) Bzubhipheron: I have a patch that replaces #define WFLAG_* with GaimMessageFlags GAIM_MESSAGE_* (22:10:30) Bzubhipheron: (an enum in disguise) (22:14:18) Bzubhipheron: GaimMessageFlags protrays much better typing information than "int". most of the other #defines are gone, and glib standardises on enums for its flags too. (22:14:27) Bzubhipheron: (gone or going) (22:14:45) Bzubhipheron: and it makes the prototype of my message queueing stuff prettier. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 25 Aug 2003 02:49:42 +0000
parents 9714538226f0
children a4622f1fb5a1
comparison
equal deleted inserted replaced
6620:7230e5920911 6621:42fdf16f1dad
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 flags) 261 int len, int 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
268 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); 268 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
269 269
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, flags); 273 val = prpl_info->send_im(gc, name, message, len, imflags);
274 274
275 if (!(flags & IM_FLAG_AWAY)) 275 if (!(imflags & IM_FLAG_AWAY))
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 & OPT_CONN_AUTO_RESP) &&
280 gaim_prefs_get_bool("/core/away/auto_response/enabled") && 280 gaim_prefs_get_bool("/core/away/auto_response/enabled") &&
797 797
798 templist = message_queue; 798 templist = message_queue;
799 799
800 while (templist) { 800 while (templist) {
801 struct queued_message *qm = (struct queued_message *)templist->data; 801 struct queued_message *qm = (struct queued_message *)templist->data;
802 if ((qm->flags & WFLAG_RECV) && !strcmp(name, qm->name)) 802 if ((qm->flags & GAIM_MESSAGE_RECV) && !strcmp(name, qm->name))
803 i++; 803 i++;
804 804
805 templist = templist->next; 805 templist = templist->next;
806 } 806 }
807 807
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 flags, time_t mtime, gint len) 816 guint32 imflags, time_t mtime, gint len)
817 { 817 {
818 char *buffy; 818 char *buffy;
819 char *angel; 819 char *angel;
820 int plugin_return; 820 int plugin_return;
821 int away = 0; 821 GaimMessageFlags away = 0;
822 822
823 GaimConversation *cnv; 823 GaimConversation *cnv;
824 824
825 char *message, *name; 825 char *message, *name;
826 826
833 * Also with some it's easy to have false positives as well. So if you're 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. 834 * a plugin author, don't rely on this, still do your own checks. But uh.
835 * It's a start. 835 * It's a start.
836 */ 836 */
837 837
838 if (flags & IM_FLAG_GAIMUSER) 838 if (imflags & IM_FLAG_GAIMUSER)
839 gaim_debug(GAIM_DEBUG_MISC, "server", "%s is a gaim user.\n", who); 839 gaim_debug(GAIM_DEBUG_MISC, "server", "%s is a gaim user.\n", who);
840 840
841 /* 841 /*
842 * We should update the conversation window buttons and menu, 842 * We should update the conversation window buttons and menu,
843 * if it exists. 843 * if it exists.
857 angel = g_strdup(who); 857 angel = g_strdup(who);
858 858
859 plugin_return = GPOINTER_TO_INT( 859 plugin_return = GPOINTER_TO_INT(
860 gaim_signal_emit_return_1(gaim_conversations_get_handle(), 860 gaim_signal_emit_return_1(gaim_conversations_get_handle(),
861 "received-im-msg", gc->account, 861 "received-im-msg", gc->account,
862 &angel, &buffy, &flags)); 862 &angel, &buffy, &imflags));
863 863
864 if (!buffy || !angel || plugin_return) { 864 if (!buffy || !angel || plugin_return) {
865 if (buffy) 865 if (buffy)
866 g_free(buffy); 866 g_free(buffy);
867 if (angel) 867 if (angel)
889 889
890 /* 890 /*
891 * Um. When we call gaim_conversation_write with the message we received, 891 * 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 892 * 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 893 * was an auto-response, we set the appropriate flag. This is just so
894 * prpls don't have to know about WFLAG_* (though some do anyway) 894 * prpls don't have to know about GAIM_MESSAGE_* (though some do anyway)
895 */ 895 */
896 if (flags & IM_FLAG_AWAY) 896 if (imflags & IM_FLAG_AWAY)
897 away = WFLAG_AUTO; 897 away = GAIM_MESSAGE_AUTO_RESP;
898 898
899 /* 899 /*
900 * Alright. Two cases for how to handle this. Either we're away or 900 * 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 901 * 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 902 * are three or four different ways of handling it and different
934 qm = g_new0(struct queued_message, 1); 934 qm = g_new0(struct queued_message, 1);
935 g_snprintf(qm->name, sizeof(qm->name), "%s", name); 935 g_snprintf(qm->name, sizeof(qm->name), "%s", name);
936 qm->message = g_memdup(message, len == -1 ? strlen(message) + 1 : len); 936 qm->message = g_memdup(message, len == -1 ? strlen(message) + 1 : len);
937 qm->account = gc->account; 937 qm->account = gc->account;
938 qm->tm = mtime; 938 qm->tm = mtime;
939 qm->flags = WFLAG_RECV | away; 939 qm->flags = GAIM_MESSAGE_RECV | away;
940 qm->len = len; 940 qm->len = len;
941 message_queue = g_slist_append(message_queue, qm); 941 message_queue = g_slist_append(message_queue, qm);
942 942
943 row = find_queue_row_by_name(qm->name); 943 row = find_queue_row_by_name(qm->name);
944 if (row >= 0) { 944 if (row >= 0) {
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, len, 975 gaim_im_write(GAIM_IM(cnv), NULL, message, len,
976 away | WFLAG_RECV, mtime); 976 away | GAIM_MESSAGE_RECV, mtime);
977 } 977 }
978 978
979 /* 979 /*
980 * Regardless of whether we queue it or not, we should send an 980 * Regardless of whether we queue it or not, we should send an
981 * auto-response. That is, of course, unless the horse.... no wait. 981 * auto-response. That is, of course, unless the horse.... no wait.
1028 qm = g_new0(struct queued_message, 1); 1028 qm = g_new0(struct queued_message, 1);
1029 g_snprintf(qm->name, sizeof(qm->name), "%s", name); 1029 g_snprintf(qm->name, sizeof(qm->name), "%s", name);
1030 qm->message = g_strdup(away_subs(tmpmsg, alias)); 1030 qm->message = g_strdup(away_subs(tmpmsg, alias));
1031 qm->account = gc->account; 1031 qm->account = gc->account;
1032 qm->tm = mtime; 1032 qm->tm = mtime;
1033 qm->flags = WFLAG_SEND | WFLAG_AUTO; 1033 qm->flags = GAIM_MESSAGE_SEND | GAIM_MESSAGE_AUTO_RESP;
1034 qm->len = -1; 1034 qm->len = -1;
1035 message_queue = g_slist_append(message_queue, qm); 1035 message_queue = g_slist_append(message_queue, qm);
1036 } else if (cnv != NULL) 1036 } else if (cnv != NULL)
1037 gaim_im_write(GAIM_IM(cnv), NULL, away_subs(tmpmsg, alias), 1037 gaim_im_write(GAIM_IM(cnv), NULL, away_subs(tmpmsg, alias),
1038 len, WFLAG_SEND | WFLAG_AUTO, mtime); 1038 len, GAIM_MESSAGE_SEND | GAIM_MESSAGE_AUTO_RESP, mtime);
1039 1039
1040 g_free(tmpmsg); 1040 g_free(tmpmsg);
1041 } else { 1041 } else {
1042 /* 1042 /*
1043 * We're not away. This is easy. If the convo window doesn't 1043 * We're not away. This is easy. If the convo window doesn't
1061 qm = g_new0(struct queued_message, 1); 1061 qm = g_new0(struct queued_message, 1);
1062 g_snprintf(qm->name, sizeof(qm->name), "%s", name); 1062 g_snprintf(qm->name, sizeof(qm->name), "%s", name);
1063 qm->message = g_strdup(message); 1063 qm->message = g_strdup(message);
1064 qm->account = gc->account; 1064 qm->account = gc->account;
1065 qm->tm = mtime; 1065 qm->tm = mtime;
1066 qm->flags = away | WFLAG_RECV; 1066 qm->flags = away | GAIM_MESSAGE_RECV;
1067 qm->len = len; 1067 qm->len = len;
1068 unread_message_queue = g_slist_append(unread_message_queue, qm); 1068 unread_message_queue = g_slist_append(unread_message_queue, qm);
1069 } 1069 }
1070 else { 1070 else {
1071 if (cnv == NULL) 1071 if (cnv == NULL)
1072 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name); 1072 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name);
1073 1073
1074 gaim_im_write(GAIM_IM(cnv), NULL, message, len, 1074 gaim_im_write(GAIM_IM(cnv), NULL, message, len,
1075 away | WFLAG_RECV, mtime); 1075 away | GAIM_MESSAGE_RECV, mtime);
1076 gaim_window_flash(gaim_conversation_get_window(cnv)); 1076 gaim_window_flash(gaim_conversation_get_window(cnv));
1077 } 1077 }
1078 } 1078 }
1079 1079
1080 g_free(name); 1080 g_free(name);
1111 if (!b) { 1111 if (!b) {
1112 gaim_debug(GAIM_DEBUG_ERROR, "server", "No such buddy: %s\n", name); 1112 gaim_debug(GAIM_DEBUG_ERROR, "server", "No such buddy: %s\n", name);
1113 return; 1113 return;
1114 } 1114 }
1115 1115
1116 c = gaim_find_conversation(b->name); 1116 c = gaim_find_conversation_with_account(b->name, account);
1117 1117
1118 /* This code will 'align' the name from the TOC */ 1118 /* This code will 'align' the name from the TOC */
1119 /* server with what's in our record. We want to */ 1119 /* server with what's in our record. We want to */
1120 /* store things how THEY want it... */ 1120 /* store things how THEY want it... */
1121 if (strcmp(name, b->name)) { 1121 if (strcmp(name, b->name)) {
1152 if (c != NULL) { 1152 if (c != NULL) {
1153 1153
1154 char *tmp = g_strdup_printf(_("%s logged in."), 1154 char *tmp = g_strdup_printf(_("%s logged in."),
1155 gaim_get_buddy_alias(b)); 1155 gaim_get_buddy_alias(b));
1156 1156
1157 gaim_conversation_write(c, NULL, tmp, -1, WFLAG_SYSTEM, 1157 gaim_conversation_write(c, NULL, tmp, -1, GAIM_MESSAGE_SYSTEM,
1158 time(NULL)); 1158 time(NULL));
1159 g_free(tmp); 1159 g_free(tmp);
1160 } 1160 }
1161 else if (awayqueue && find_queue_total_by_name(b->name)) { 1161 else if (awayqueue && find_queue_total_by_name(b->name)) {
1162 struct queued_message *qm = g_new0(struct queued_message, 1); 1162 struct queued_message *qm = g_new0(struct queued_message, 1);
1163 g_snprintf(qm->name, sizeof(qm->name), "%s", b->name); 1163 g_snprintf(qm->name, sizeof(qm->name), "%s", b->name);
1164 qm->message = g_strdup_printf(_("%s logged in."), 1164 qm->message = g_strdup_printf(_("%s logged in."),
1165 gaim_get_buddy_alias(b)); 1165 gaim_get_buddy_alias(b));
1166 qm->account = gc->account; 1166 qm->account = gc->account;
1167 qm->tm = time(NULL); 1167 qm->tm = time(NULL);
1168 qm->flags = WFLAG_SYSTEM; 1168 qm->flags = GAIM_MESSAGE_SYSTEM;
1169 qm->len = -1; 1169 qm->len = -1;
1170 message_queue = g_slist_append(message_queue, qm); 1170 message_queue = g_slist_append(message_queue, qm);
1171 } 1171 }
1172 } 1172 }
1173 gaim_sound_play_event(GAIM_SOUND_BUDDY_ARRIVE); 1173 gaim_sound_play_event(GAIM_SOUND_BUDDY_ARRIVE);
1181 if (c != NULL) { 1181 if (c != NULL) {
1182 1182
1183 char *tmp = g_strdup_printf(_("%s logged out."), 1183 char *tmp = g_strdup_printf(_("%s logged out."),
1184 gaim_get_buddy_alias(b)); 1184 gaim_get_buddy_alias(b));
1185 gaim_conversation_write(c, NULL, tmp, -1, 1185 gaim_conversation_write(c, NULL, tmp, -1,
1186 WFLAG_SYSTEM, time(NULL)); 1186 GAIM_MESSAGE_SYSTEM, time(NULL));
1187 g_free(tmp); 1187 g_free(tmp);
1188 } else if (awayqueue && find_queue_total_by_name(b->name)) { 1188 } else if (awayqueue && find_queue_total_by_name(b->name)) {
1189 struct queued_message *qm = g_new0(struct queued_message, 1); 1189 struct queued_message *qm = g_new0(struct queued_message, 1);
1190 g_snprintf(qm->name, sizeof(qm->name), "%s", b->name); 1190 g_snprintf(qm->name, sizeof(qm->name), "%s", b->name);
1191 qm->message = g_strdup_printf(_("%s logged out."), 1191 qm->message = g_strdup_printf(_("%s logged out."),
1192 gaim_get_buddy_alias(b)); 1192 gaim_get_buddy_alias(b));
1193 qm->account = gc->account; 1193 qm->account = gc->account;
1194 qm->tm = time(NULL); 1194 qm->tm = time(NULL);
1195 qm->flags = WFLAG_SYSTEM; 1195 qm->flags = GAIM_MESSAGE_SYSTEM;
1196 qm->len = -1; 1196 qm->len = -1;
1197 message_queue = g_slist_append(message_queue, qm); 1197 message_queue = g_slist_append(message_queue, qm);
1198 } 1198 }
1199 } 1199 }
1200 serv_got_typing_stopped(gc, name); /* obviously not typing */ 1200 serv_got_typing_stopped(gc, name); /* obviously not typing */
1435 } 1435 }
1436 1436
1437 void serv_got_chat_in(GaimConnection *g, int id, const char *who, 1437 void serv_got_chat_in(GaimConnection *g, int id, const char *who,
1438 int whisper, const char *message, time_t mtime) 1438 int whisper, const char *message, time_t mtime)
1439 { 1439 {
1440 int w; 1440 GaimMessageFlags w;
1441 GSList *bcs; 1441 GSList *bcs;
1442 GaimConversation *conv = NULL; 1442 GaimConversation *conv = NULL;
1443 GaimChat *chat = NULL; 1443 GaimChat *chat = NULL;
1444 char *buf; 1444 char *buf;
1445 char *buffy, *angel; 1445 char *buffy, *angel;
1493 buf = linkify_text(message); 1493 buf = linkify_text(message);
1494 else 1494 else
1495 buf = g_strdup(message); 1495 buf = g_strdup(message);
1496 1496
1497 if (whisper) 1497 if (whisper)
1498 w = WFLAG_WHISPER; 1498 w = GAIM_MESSAGE_WHISPER;
1499 else 1499 else
1500 w = 0; 1500 w = 0;
1501 1501
1502 gaim_chat_write(chat, who, buf, w, mtime); 1502 gaim_chat_write(chat, who, buf, w, mtime);
1503 1503