Mercurial > pidgin
comparison libpurple/protocols/myspace/myspace.c @ 16723:3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Change msim_send to msim_send_raw and add an empty msim_send for later.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Fri, 04 May 2007 04:49:01 +0000 |
parents | 1aa62f7368ca |
children | 58cd11fcd84f |
comparison
equal
deleted
inserted
replaced
16722:ba7d6317da76 | 16723:3b5037a93807 |
---|---|
349 purple_debug_info("msim", "%s=%s\n", (char*)key, (char*)value); | 349 purple_debug_info("msim", "%s=%s\n", (char*)key, (char*)value); |
350 } | 350 } |
351 #endif | 351 #endif |
352 | 352 |
353 /** | 353 /** |
354 * Send an arbitrary protocol message. | 354 * Send raw data to the server. |
355 * | 355 * |
356 * @param session | 356 * @param session |
357 * @param msg The textual, packed message to send. | 357 * @param msg The raw data to send. |
358 * | 358 * |
359 * @return TRUE if succeeded, FALSE if not. | 359 * @return TRUE if succeeded, FALSE if not. |
360 * | 360 * |
361 * Note: this does not send instant messages. For that, see msim_send_im. | 361 */ |
362 */ | 362 static gboolean msim_send_raw(MsimSession *session, const gchar *msg) |
363 static gboolean msim_send(MsimSession *session, const gchar *msg) | |
364 { | 363 { |
365 int total_bytes_sent, total_bytes; | 364 int total_bytes_sent, total_bytes; |
366 | 365 |
367 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); | 366 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
368 g_return_val_if_fail(msg != NULL, FALSE); | 367 g_return_val_if_fail(msg != NULL, FALSE); |
379 bytes_sent = send(session->fd, msg + total_bytes_sent, | 378 bytes_sent = send(session->fd, msg + total_bytes_sent, |
380 total_bytes - total_bytes_sent, 0); | 379 total_bytes - total_bytes_sent, 0); |
381 | 380 |
382 if (bytes_sent < 0) | 381 if (bytes_sent < 0) |
383 { | 382 { |
384 purple_debug_info("msim", "msim_send(%s): send() failed: %s\n", | 383 purple_debug_info("msim", "msim_send_raw(%s): send() failed: %s\n", |
385 msg, g_strerror(errno)); | 384 msg, g_strerror(errno)); |
386 return FALSE; | 385 return FALSE; |
387 } | 386 } |
388 total_bytes_sent += bytes_sent; | 387 total_bytes_sent += bytes_sent; |
389 | 388 |
390 } while(total_bytes_sent < total_bytes); | 389 } while(total_bytes_sent < total_bytes); |
391 return TRUE; | 390 return TRUE; |
391 } | |
392 | |
393 /** | |
394 * Send a message to the server. | |
395 * | |
396 * @param session | |
397 * @param ... A sequence of gchar* key/value pairs, terminated with NULL | |
398 */ | |
399 static gboolean msim_send(MsimSession *session, ...) | |
400 { | |
401 /* TODO: implement this */ | |
392 } | 402 } |
393 | 403 |
394 /** | 404 /** |
395 * Start logging in to the MSIM servers. | 405 * Start logging in to the MSIM servers. |
396 * | 406 * |
485 | 495 |
486 g_free(response_str); | 496 g_free(response_str); |
487 | 497 |
488 purple_debug_info("msim", "response=<%s>\n", buf); | 498 purple_debug_info("msim", "response=<%s>\n", buf); |
489 | 499 |
490 msim_send(session, buf); | 500 msim_send_raw(session, buf); |
491 | 501 |
492 g_free(buf); | 502 g_free(buf); |
493 | 503 |
494 return 0; | 504 return 0; |
495 } | 505 } |
711 /* TODO: escape values */ | 721 /* TODO: escape values */ |
712 msg_string = g_strdup_printf("\\bm\\121\\sesskey\\%s\\t\\%s\\cv\\%d\\msg\\%s\\final\\", | 722 msg_string = g_strdup_printf("\\bm\\121\\sesskey\\%s\\t\\%s\\cv\\%d\\msg\\%s\\final\\", |
713 session->sesskey, userid, MSIM_CLIENT_VERSION, message); | 723 session->sesskey, userid, MSIM_CLIENT_VERSION, message); |
714 | 724 |
715 /* XXX: delete after escape each value */ | 725 /* XXX: delete after escape each value */ |
716 g_free(message); | 726 g_free((char*)message); |
717 | 727 |
718 purple_debug_info("msim", "going to write: %s\n", msg_string); | 728 purple_debug_info("msim", "going to write: %s\n", msg_string); |
719 | 729 |
720 msim_send(session, msg_string); | 730 msim_send_raw(session, msg_string); |
721 | 731 |
722 /* TODO: notify Purple that we sent the IM. */ | 732 /* TODO: notify Purple that we sent the IM. */ |
723 | 733 |
724 /* Not needed since sending messages to yourself is allowed by MSIM! */ | 734 /* Not needed since sending messages to yourself is allowed by MSIM! */ |
725 /*if (strcmp(from_username, who) == 0) | 735 /*if (strcmp(from_username, who) == 0) |
1463 | 1473 |
1464 /* TODO: escape values */ | 1474 /* TODO: escape values */ |
1465 msg_string = g_strdup_printf("\\persist\\1\\sesskey\\%s\\cmd\\1\\dsn\\%d\\uid\\%s\\lid\\%d\\rid\\%d\\body\\%s=%s\\final\\", | 1475 msg_string = g_strdup_printf("\\persist\\1\\sesskey\\%s\\cmd\\1\\dsn\\%d\\uid\\%s\\lid\\%d\\rid\\%d\\body\\%s=%s\\final\\", |
1466 session->sesskey, dsn, session->userid, lid, rid, field_name, user); | 1476 session->sesskey, dsn, session->userid, lid, rid, field_name, user); |
1467 | 1477 |
1468 msim_send(session, msg_string); | 1478 msim_send_raw(session, msg_string); |
1469 } | 1479 } |
1470 | 1480 |
1471 | 1481 |
1472 /** | 1482 /** |
1473 * Obtain the status text for a buddy. | 1483 * Obtain the status text for a buddy. |
1603 NULL, /* send_file */ | 1613 NULL, /* send_file */ |
1604 NULL, /* new_xfer */ | 1614 NULL, /* new_xfer */ |
1605 NULL, /* offline_message */ | 1615 NULL, /* offline_message */ |
1606 NULL, /* whiteboard_prpl_ops */ | 1616 NULL, /* whiteboard_prpl_ops */ |
1607 NULL, /* send_raw */ | 1617 NULL, /* send_raw */ |
1608 NULL /* roomlist_room_serialize */ | 1618 NULL, /* roomlist_room_serialize */ |
1619 NULL, /* _purple_reserved1 */ | |
1620 NULL, /* _purple_reserved2 */ | |
1621 NULL, /* _purple_reserved3 */ | |
1622 NULL /* _purple_reserved4 */ | |
1609 }; | 1623 }; |
1610 | 1624 |
1611 | 1625 |
1612 | 1626 |
1613 /** Based on MSN's plugin info comments. */ | 1627 /** Based on MSN's plugin info comments. */ |
1638 NULL, /**< ui_info */ | 1652 NULL, /**< ui_info */ |
1639 &prpl_info, /**< extra_info */ | 1653 &prpl_info, /**< extra_info */ |
1640 NULL, /**< prefs_info */ | 1654 NULL, /**< prefs_info */ |
1641 | 1655 |
1642 /* msim_actions */ | 1656 /* msim_actions */ |
1643 NULL | 1657 NULL, |
1658 | |
1659 NULL, /**< reserved1 */ | |
1660 NULL, /**< reserved2 */ | |
1661 NULL, /**< reserved3 */ | |
1662 NULL /**< reserved4 */ | |
1644 }; | 1663 }; |
1645 | 1664 |
1646 | 1665 |
1647 PURPLE_INIT_PLUGIN(myspace, init_plugin, info); | 1666 PURPLE_INIT_PLUGIN(myspace, init_plugin, info); |