Mercurial > pidgin
comparison libpurple/protocols/myspace/myspace.c @ 17293:bfda36bd957a
Add incomplete msim_add_buddy() implementation.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sun, 03 Jun 2007 02:14:03 +0000 |
parents | d8903e1320a9 |
children | 1905859d7a3b |
comparison
equal
deleted
inserted
replaced
17292:2d9d53b509fd | 17293:bfda36bd957a |
---|---|
989 if (msim_msg_get(msg, "fatal")) | 989 if (msim_msg_get(msg, "fatal")) |
990 { | 990 { |
991 purple_debug_info("msim", "fatal error, destroy session\n"); | 991 purple_debug_info("msim", "fatal error, destroy session\n"); |
992 purple_connection_error(session->gc, full_errmsg); | 992 purple_connection_error(session->gc, full_errmsg); |
993 close(session->fd); | 993 close(session->fd); |
994 //msim_session_destroy(session); | 994 msim_session_destroy(session); |
995 } | 995 } |
996 | 996 |
997 return TRUE; | 997 return TRUE; |
998 } | 998 } |
999 | 999 |
1165 msim_lookup_user(session, userid, msim_status_cb, status_str); | 1165 msim_lookup_user(session, userid, msim_status_cb, status_str); |
1166 | 1166 |
1167 return TRUE; | 1167 return TRUE; |
1168 } | 1168 } |
1169 | 1169 |
1170 /** Allow user to add a buddy to their buddy list. TODO: make work. Should receive statuses from added buddy. */ | |
1171 void msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | |
1172 { | |
1173 MsimSession *session; | |
1174 | |
1175 session = (MsimSession *)gc->proto_data; | |
1176 purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", buddy->name, | |
1177 group ? group->name : "(no group)"); | |
1178 | |
1179 if (!msim_send(session, | |
1180 "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, | |
1181 "sesskey", MSIM_TYPE_STRING, g_strdup(session->sesskey), | |
1182 /* Currently only allow numeric ID. TODO: Lookup screen name/email to uid. */ | |
1183 "newprofileid", MSIM_TYPE_STRING, g_strdup(buddy->name), | |
1184 "reason", MSIM_TYPE_STRING, g_strdup(""), | |
1185 NULL)) | |
1186 { | |
1187 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); | |
1188 } | |
1189 | |
1190 /* TODO: update blocklist */ | |
1191 | |
1192 if (!msim_send(session, | |
1193 "persist", MSIM_TYPE_INTEGER, 1, | |
1194 "sesskey", MSIM_TYPE_STRING, g_strdup(session->sesskey), | |
1195 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_PUT, | |
1196 "dsn", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_DSN, | |
1197 "lid", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_LID, | |
1198 /* TODO: msim_send_persist, to handle all this rid business */ | |
1199 "rid", MSIM_TYPE_INTEGER, session->next_rid++, | |
1200 "body", MSIM_TYPE_STRING, | |
1201 g_strdup_printf("ContactID=%s\034" | |
1202 "GroupName=%s\034" | |
1203 "Position=1000\034" | |
1204 "Visibility=1\034" | |
1205 "NickName=\034" | |
1206 "NameSelect=0", | |
1207 buddy->name, group->name))) | |
1208 { | |
1209 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); | |
1210 } | |
1211 } | |
1212 | |
1170 | 1213 |
1171 | 1214 |
1172 /** | 1215 /** |
1173 * Callback when input available. | 1216 * Callback when input available. |
1174 * | 1217 * |
1175 * @param gc_uncasted A PurpleConnection pointer. | 1218 * @param gc_uncasted A PurpleConnection pointer. |
1176 * @param source File descriptor. | 1219 * @param source File descriptor. |
1177 * @param cond PURPLE_INPUT_READ | 1220 * @param cond PURPLE_INPUT_READ |
1178 * | 1221 * |
1179 * Reads the input, and dispatches calls msim_process to handle it. | 1222 * Reads the input, and dispatches msim_process() to handle it. |
1180 */ | 1223 */ |
1181 void msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond) | 1224 void msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond) |
1182 { | 1225 { |
1183 PurpleConnection *gc; | 1226 PurpleConnection *gc; |
1184 PurpleAccount *account; | 1227 PurpleAccount *account; |
1395 * @param gc The connection. | 1438 * @param gc The connection. |
1396 */ | 1439 */ |
1397 void msim_close(PurpleConnection *gc) | 1440 void msim_close(PurpleConnection *gc) |
1398 { | 1441 { |
1399 g_return_if_fail(gc != NULL); | 1442 g_return_if_fail(gc != NULL); |
1443 | |
1444 purple_debug_info("msim", "msim_close: destroying session\n"); | |
1400 | 1445 |
1401 msim_session_destroy(gc->proto_data); | 1446 msim_session_destroy(gc->proto_data); |
1402 } | 1447 } |
1403 | 1448 |
1404 | 1449 |
1601 msim_send_typing, /* send_typing */ | 1646 msim_send_typing, /* send_typing */ |
1602 NULL, /* get_info */ | 1647 NULL, /* get_info */ |
1603 NULL, /* set_away */ | 1648 NULL, /* set_away */ |
1604 NULL, /* set_idle */ | 1649 NULL, /* set_idle */ |
1605 NULL, /* change_passwd */ | 1650 NULL, /* change_passwd */ |
1606 NULL, /* add_buddy TODO */ | 1651 msim_add_buddy, /* add_buddy TODO */ |
1607 NULL, /* add_buddies */ | 1652 NULL, /* add_buddies */ |
1608 NULL, /* remove_buddy TODO */ | 1653 NULL, /* remove_buddy TODO */ |
1609 NULL, /* remove_buddies */ | 1654 NULL, /* remove_buddies */ |
1610 NULL, /* add_permit */ | 1655 NULL, /* add_permit */ |
1611 NULL, /* add_deny */ | 1656 NULL, /* add_deny */ |
1688 NULL, /**< reserved2 */ | 1733 NULL, /**< reserved2 */ |
1689 NULL, /**< reserved3 */ | 1734 NULL, /**< reserved3 */ |
1690 NULL /**< reserved4 */ | 1735 NULL /**< reserved4 */ |
1691 }; | 1736 }; |
1692 | 1737 |
1693 #include "message.h" | |
1694 | |
1695 void init_plugin(PurplePlugin *plugin) | 1738 void init_plugin(PurplePlugin *plugin) |
1696 { | 1739 { |
1697 PurpleAccountOption *option; | 1740 PurpleAccountOption *option; |
1698 #ifdef _TEST_MSIM_MSG | 1741 #ifdef _TEST_MSIM_MSG |
1699 { | 1742 { |