Mercurial > pidgin.yaz
changeset 31229:64a6ce55aa63
Move more SlpMessage creation to its module.
author | masca@cpw.pidgin.im |
---|---|
date | Sat, 12 Jun 2010 21:22:06 +0000 |
parents | 545fa069c531 |
children | 9192c59f2f84 |
files | libpurple/protocols/msn/slp.c libpurple/protocols/msn/slplink.c libpurple/protocols/msn/slpmsg.c libpurple/protocols/msn/slpmsg.h |
diffstat | 4 files changed, 77 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/slp.c Thu Jun 10 22:40:44 2010 +0000 +++ b/libpurple/protocols/msn/slp.c Sat Jun 12 21:22:06 2010 +0000 @@ -509,19 +509,13 @@ if (img != NULL) { /* DATA PREP */ - slpmsg = msn_slpmsg_new(slplink); - slpmsg->slpcall = slpcall; - slpmsg->session_id = slpcall->session_id; - msn_slpmsg_set_body(slpmsg, NULL, 4); - slpmsg->info = "SLP DATA PREP"; + slpmsg = msn_slpmsg_new_dataprep(slpcall); + msn_slpmsg_set_slplink(slpmsg, slplink); msn_slplink_queue_slpmsg(slplink, slpmsg); /* DATA */ - slpmsg = msn_slpmsg_new(slplink); - slpmsg->slpcall = slpcall; - slpmsg->flags = P2P_MSN_OBJ_DATA; - slpmsg->info = "SLP DATA"; - msn_slpmsg_set_image(slpmsg, img); + slpmsg = msn_slpmsg_new_obj(slpcall, img); + msn_slpmsg_set_slplink(slpmsg, slplink); msn_slplink_queue_slpmsg(slplink, slpmsg); purple_imgstore_unref(img);
--- a/libpurple/protocols/msn/slplink.c Thu Jun 10 22:40:44 2010 +0000 +++ b/libpurple/protocols/msn/slplink.c Sat Jun 12 21:22:06 2010 +0000 @@ -538,11 +538,8 @@ } purple_xfer_unref(xfer); - slpmsg = msn_slpmsg_new(slpcall->slplink); - slpmsg->slpcall = slpcall; - slpmsg->flags = P2P_FILE_DATA; - slpmsg->info = "SLP FILE"; - slpmsg->size = purple_xfer_get_size(xfer); + slpmsg = msn_slpmsg_new_file(slpcall, purple_xfer_get_size(xfer)); + msn_slpmsg_set_slplink(slpmsg, slpcall->slplink); msn_slplink_send_slpmsg(slpcall->slplink, slpmsg); }
--- a/libpurple/protocols/msn/slpmsg.c Thu Jun 10 22:40:44 2010 +0000 +++ b/libpurple/protocols/msn/slpmsg.c Sat Jun 12 21:22:06 2010 +0000 @@ -280,6 +280,48 @@ return slpmsg; } +MsnSlpMessage *msn_slpmsg_new_obj(MsnSlpCall *slpcall,PurpleStoredImage *img) +{ + MsnSlpMessage *slpmsg; + + slpmsg = msn_slpmsg_new(NULL); + slpmsg->slpcall = slpcall; + slpmsg->flags = P2P_MSN_OBJ_DATA; + slpmsg->info = "SLP DATA"; + + msn_slpmsg_set_image(slpmsg, img); + + return slpmsg; +} + +MsnSlpMessage *msn_slpmsg_new_dataprep(MsnSlpCall *slpcall) +{ + MsnSlpMessage *slpmsg; + + slpmsg = msn_slpmsg_new(NULL); + slpmsg->slpcall = slpcall; + slpmsg->session_id = slpcall->session_id; + msn_slpmsg_set_body(slpmsg, NULL, 4); + slpmsg->info = "SLP DATA PREP"; + + return slpmsg; + +} + +MsnSlpMessage *msn_slpmsg_new_file(MsnSlpCall *slpcall, size_t size) +{ + MsnSlpMessage *slpmsg; + + slpmsg = msn_slpmsg_new(NULL); + + slpmsg->slpcall = slpcall; + slpmsg->flags = P2P_FILE_DATA; + slpmsg->info = "SLP FILE"; + slpmsg->size = size; + + return slpmsg; +} + char *msn_slpmsg_serialize(MsnSlpMessage *slpmsg, size_t *ret_size) { MsnP2PHeader *header;
--- a/libpurple/protocols/msn/slpmsg.h Thu Jun 10 22:40:44 2010 +0000 +++ b/libpurple/protocols/msn/slpmsg.h Sat Jun 12 21:22:06 2010 +0000 @@ -138,6 +138,35 @@ */ MsnSlpMessage *msn_slpmsg_new_ack(MsnP2PHeader *header); +/** + * Create a new SLP message for MsnObject data. + * + * @param slpcall The slpcall that manages this message. + * @param img The image to be sent in this message. + * + * @return A new SlpMessage with MsnObject info. + */ +MsnSlpMessage *msn_slpmsg_new_obj(MsnSlpCall *slpcall, PurpleStoredImage *img); + +/** + * Create a new SLP message for data preparation. + * + * @param slpcall The slpcall that manages this message. + * + * @return A new SlpMessage with data preparation info. + */ +MsnSlpMessage *msn_slpmsg_new_dataprep(MsnSlpCall *slpcall); + +/** + * Create a new SLP message for File transfer. + * + * @param slpcall The slpcall that manages this message. + * @param size The size of the file being transsmited. + * + * @return A new SlpMessage with the file transfer info. + */ +MsnSlpMessage *msn_slpmsg_new_file(MsnSlpCall *slpcall, size_t size); + void msn_slpmsg_show(MsnMessage *msg); /**