comparison plugins/yay/yay.c @ 1400:476b24cdfa32

[gaim-migrate @ 1410] README now has docs on how to use Yahoo/IRC/etc, so people aren't so lost. Yahoo can now receive messages and linkify them properly doesn't say "quit" in applet login window committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 10 Jan 2001 19:56:39 +0000
parents 567758889707
children bf041349b11e
comparison
equal deleted inserted replaced
1399:51620cc6ec4b 1400:476b24cdfa32
75 signoff(gc); 75 signoff(gc);
76 return; 76 return;
77 } 77 }
78 78
79 for (i = 0; i < pkt->idstatus_count; i++) { 79 for (i = 0; i < pkt->idstatus_count; i++) {
80 struct group *g;
81 struct buddy *b; 80 struct buddy *b;
82 struct yahoo_idstatus *rec = pkt->idstatus[i]; 81 struct yahoo_idstatus *rec = pkt->idstatus[i];
83 gboolean online = rec->in_pager || rec->in_chat || rec->in_game; 82 gboolean online = rec->in_pager || rec->in_chat || rec->in_game;
84 83
85 b = find_buddy(gc, rec->id); 84 b = find_buddy(gc, rec->id);
87 time(&tmptime); 86 time(&tmptime);
88 if (b->signon == 0) b->signon = tmptime; 87 if (b->signon == 0) b->signon = tmptime;
89 if (!online) 88 if (!online)
90 serv_got_update(gc, b->name, 0, 0, 0, 0, 0, 0); 89 serv_got_update(gc, b->name, 0, 0, 0, 0, 0, 0);
91 else { 90 else {
92 if (rec->status == YAHOO_STATUS_IDLE) 91 if (rec->status == YAHOO_STATUS_AVAILABLE)
92 serv_got_update(gc, b->name, 1, 0, b->signon, 0, UC_NORMAL, 0);
93 else if (rec->status == YAHOO_STATUS_IDLE)
93 serv_got_update(gc, b->name, 1, 0, b->signon, tmptime - 600, 94 serv_got_update(gc, b->name, 1, 0, b->signon, tmptime - 600,
94 (rec->status << 5) | UC_NORMAL, 0); 95 (rec->status << 5) | UC_NORMAL, 0);
95 else if (rec->status == YAHOO_STATUS_AVAILABLE)
96 serv_got_update(gc, b->name, 1, 0, b->signon, 0, UC_NORMAL, 0);
97 else 96 else
98 serv_got_update(gc, b->name, 1, 0, b->signon, 0, 97 serv_got_update(gc, b->name, 1, 0, b->signon, 0,
99 (rec->status << 5) | UC_UNAVAILABLE, 0); 98 (rec->status << 5) | UC_UNAVAILABLE, 0);
100 if (rec->status == YAHOO_STATUS_CUSTOM) { 99 if (rec->status == YAHOO_STATUS_CUSTOM) {
101 gpointer val = g_hash_table_lookup(yd->hash, b->name); 100 gpointer val = g_hash_table_lookup(yd->hash, b->name);
108 } 107 }
109 } 108 }
110 109
111 static void process_packet_message(struct gaim_connection *gc, struct yahoo_packet *pkt) { 110 static void process_packet_message(struct gaim_connection *gc, struct yahoo_packet *pkt) {
112 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 111 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
112 char buf[BUF_LEN * 4];
113 113
114 if (pkt->msg) { 114 if (pkt->msg) {
115 if (pkt->msgtype == YAHOO_MSGTYPE_BOUNCE) 115 if (pkt->msgtype == YAHOO_MSGTYPE_BOUNCE)
116 do_error_dialog("Your message did not get received.", "Error"); 116 do_error_dialog("Your message did not get received.", "Error");
117 else 117 else {
118 serv_got_im(gc, pkt->msg_id, pkt->msg, pkt->msg_timestamp ? 1 : 0); 118 g_snprintf(buf, sizeof(buf), "%s", pkt->msg);
119 serv_got_im(gc, pkt->msg_id, buf, pkt->msg_timestamp ? 1 : 0);
120 }
119 } 121 }
120 } 122 }
121 123
122 static void process_packet_newmail(struct gaim_connection *gc, struct yahoo_packet *pkt) { 124 static void process_packet_newmail(struct gaim_connection *gc, struct yahoo_packet *pkt) {
123 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 125 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
135 do_error_dialog(buf, "New Mail!"); 137 do_error_dialog(buf, "New Mail!");
136 } 138 }
137 } 139 }
138 140
139 static void process_packet_conference(struct gaim_connection *gc, struct yahoo_packet *pkt) { 141 static void process_packet_conference(struct gaim_connection *gc, struct yahoo_packet *pkt) {
140 }
141
142 static void process_packet_ping(struct gaim_connection *gc, struct yahoo_packet *pkt) {
143 } 142 }
144 143
145 static void yahoo_callback(gpointer data, gint source, GdkInputCondition condition) { 144 static void yahoo_callback(gpointer data, gint source, GdkInputCondition condition) {
146 struct gaim_connection *gc = (struct gaim_connection *)data; 145 struct gaim_connection *gc = (struct gaim_connection *)data;
147 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; 146 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
180 if (pkt->msg_id && !find_buddy(gc, pkt->msg_id)) { 179 if (pkt->msg_id && !find_buddy(gc, pkt->msg_id)) {
181 char buf[1024]; 180 char buf[1024];
182 g_snprintf(buf, sizeof buf, "%s on Yahoo has made you " 181 g_snprintf(buf, sizeof buf, "%s on Yahoo has made you "
183 "their friend", pkt->msg_id); 182 "their friend", pkt->msg_id);
184 do_error_dialog(buf, "Yahoo"); 183 do_error_dialog(buf, "Yahoo");
185 show_add_buddy(gc, pkt->msg_id, NULL); 184 if (!find_buddy(gc, pkt->msg_id))
185 show_add_buddy(gc, pkt->msg_id, NULL);
186 } 186 }
187 break; 187 break;
188 case YAHOO_SERVICE_NEWMAIL: 188 case YAHOO_SERVICE_NEWMAIL:
189 case YAHOO_SERVICE_NEWPERSONALMAIL: 189 case YAHOO_SERVICE_NEWPERSONALMAIL:
190 /* do we really want to do this? */ 190 /* do we really want to do this? */
195 case YAHOO_SERVICE_CONFLOGON: 195 case YAHOO_SERVICE_CONFLOGON:
196 case YAHOO_SERVICE_CONFLOGOFF: 196 case YAHOO_SERVICE_CONFLOGOFF:
197 case YAHOO_SERVICE_CONFMSG: 197 case YAHOO_SERVICE_CONFMSG:
198 process_packet_conference(gc, pkt); 198 process_packet_conference(gc, pkt);
199 break; 199 break;
200 case YAHOO_SERVICE_PING:
201 process_packet_ping(gc, pkt);
202 break;
203 case YAHOO_SERVICE_FILETRANSFER: 200 case YAHOO_SERVICE_FILETRANSFER:
204 case YAHOO_SERVICE_CALENDAR: 201 case YAHOO_SERVICE_CALENDAR:
205 case YAHOO_SERVICE_CHATINVITE: 202 case YAHOO_SERVICE_CHATINVITE:
206 default: 203 default:
207 debug_printf("Unhandled packet type %s\n", 204 debug_printf("Unhandled packet type %s\n",
214 } 211 }
215 212
216 static void yahoo_login(struct aim_user *user) { 213 static void yahoo_login(struct aim_user *user) {
217 struct gaim_connection *gc = new_gaim_conn(user); 214 struct gaim_connection *gc = new_gaim_conn(user);
218 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); 215 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1);
219 int i;
220 216
221 struct yahoo_options opt; 217 struct yahoo_options opt;
222 struct yahoo_context *ctxt; 218 struct yahoo_context *ctxt;
223 opt.connect_mode = YAHOO_CONNECT_NORMAL; 219 opt.connect_mode = YAHOO_CONNECT_NORMAL;
224 opt.proxy_host = NULL; 220 opt.proxy_host = NULL;
267 if (ctxt->buddies) { 263 if (ctxt->buddies) {
268 struct yahoo_buddy **buddies; 264 struct yahoo_buddy **buddies;
269 265
270 for (buddies = ctxt->buddies; *buddies; buddies++) { 266 for (buddies = ctxt->buddies; *buddies; buddies++) {
271 struct yahoo_buddy *bud = *buddies; 267 struct yahoo_buddy *bud = *buddies;
272 struct buddy *b; 268
273 struct group *g; 269 if (!find_buddy(gc, bud->id))
274 270 add_buddy(gc, bud->group, bud->id, bud->id);
275 b = find_buddy(gc, bud->id);
276 if (!b) add_buddy(gc, bud->group, bud->id, bud->id);
277 } 271 }
278 } 272 }
279 273
280 gc->inpa = gdk_input_add(ctxt->sockfd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, 274 gc->inpa = gdk_input_add(ctxt->sockfd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
281 yahoo_callback, gc); 275 yahoo_callback, gc);
396 return; 390 return;
397 391
398 if ((b->uc >> 5) != YAHOO_STATUS_CUSTOM) 392 if ((b->uc >> 5) != YAHOO_STATUS_CUSTOM)
399 g_snprintf(buf, sizeof buf, "Status: %s", yahoo_get_status_string(b->uc >> 5)); 393 g_snprintf(buf, sizeof buf, "Status: %s", yahoo_get_status_string(b->uc >> 5));
400 else 394 else
401 g_snprintf(buf, sizeof buf, "Custom Status: %s", g_hash_table_lookup(yd->hash, b->name)); 395 g_snprintf(buf, sizeof buf, "Custom Status: %s",
396 (char *)g_hash_table_lookup(yd->hash, b->name));
402 button = gtk_menu_item_new_with_label(buf); 397 button = gtk_menu_item_new_with_label(buf);
403 gtk_menu_append(GTK_MENU(menu), button); 398 gtk_menu_append(GTK_MENU(menu), button);
404 gtk_widget_show(button); 399 gtk_widget_show(button);
405 } 400 }
406 401