Mercurial > pidgin.yaz
comparison libpurple/protocols/myspace/myspace.c @ 17353:1905859d7a3b
Add (incomplete) msim_remove_buddy().
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sun, 03 Jun 2007 04:50:35 +0000 |
parents | bfda36bd957a |
children | c2208b64bffb |
comparison
equal
deleted
inserted
replaced
17352:86b4862b7a02 | 17353:1905859d7a3b |
---|---|
986 full_errmsg, NULL); | 986 full_errmsg, NULL); |
987 | 987 |
988 /* Destroy session if fatal. */ | 988 /* Destroy session if fatal. */ |
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, closing\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 /* Do not call msim_session_destroy(session) - called in msim_close(). */ |
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. */ | 1170 /** Add a buddy to user's buddy list. TODO: make work. Should receive statuses from added buddy. */ |
1171 void msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | 1171 void msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
1172 { | 1172 { |
1173 MsimSession *session; | 1173 MsimSession *session; |
1174 | 1174 |
1175 session = (MsimSession *)gc->proto_data; | 1175 session = (MsimSession *)gc->proto_data; |
1177 group ? group->name : "(no group)"); | 1177 group ? group->name : "(no group)"); |
1178 | 1178 |
1179 if (!msim_send(session, | 1179 if (!msim_send(session, |
1180 "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, | 1180 "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
1181 "sesskey", MSIM_TYPE_STRING, g_strdup(session->sesskey), | 1181 "sesskey", MSIM_TYPE_STRING, g_strdup(session->sesskey), |
1182 /* Currently only allow numeric ID. TODO: Lookup screen name/email to uid. */ | 1182 /* Currently only allow numeric ID. TODO: Lookup username/email to uid. */ |
1183 "newprofileid", MSIM_TYPE_STRING, g_strdup(buddy->name), | 1183 "newprofileid", MSIM_TYPE_STRING, g_strdup(buddy->name), |
1184 "reason", MSIM_TYPE_STRING, g_strdup(""), | 1184 "reason", MSIM_TYPE_STRING, g_strdup(""), |
1185 NULL)) | 1185 NULL)) |
1186 { | 1186 { |
1187 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); | 1187 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); |
1188 return; | |
1188 } | 1189 } |
1189 | 1190 |
1190 /* TODO: update blocklist */ | 1191 /* TODO: update blocklist */ |
1191 | 1192 |
1192 if (!msim_send(session, | 1193 if (!msim_send(session, |
1202 "GroupName=%s\034" | 1203 "GroupName=%s\034" |
1203 "Position=1000\034" | 1204 "Position=1000\034" |
1204 "Visibility=1\034" | 1205 "Visibility=1\034" |
1205 "NickName=\034" | 1206 "NickName=\034" |
1206 "NameSelect=0", | 1207 "NameSelect=0", |
1207 buddy->name, group->name))) | 1208 buddy->name, group->name), |
1209 NULL)) | |
1208 { | 1210 { |
1209 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); | 1211 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); |
1212 return; | |
1210 } | 1213 } |
1214 } | |
1215 | |
1216 /** Remove a buddy from the user's buddy list. */ | |
1217 void msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | |
1218 { | |
1219 MsimSession *session; | |
1220 | |
1221 session = (MsimSession *)gc->proto_data; | |
1222 | |
1223 if (!msim_send(session, | |
1224 "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, | |
1225 "sesskey", MSIM_TYPE_STRING, g_strdup(session->sesskey), | |
1226 /* TODO: Lookup username/email to uid, currently on userid. */ | |
1227 "delprofileid", MSIM_TYPE_STRING, g_strdup(buddy->name), | |
1228 NULL)) | |
1229 { | |
1230 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); | |
1231 return; | |
1232 } | |
1233 | |
1234 if (!msim_send(session, | |
1235 "persist", MSIM_TYPE_INTEGER, 1, | |
1236 "sesskey", MSIM_TYPE_STRING, g_strdup(session->sesskey), | |
1237 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, | |
1238 "dsn", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_DSN, | |
1239 "lid", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_LID, | |
1240 "uid", MSIM_TYPE_INTEGER, 42, /* TODO: put YOUR userid here */ | |
1241 "rid", MSIM_TYPE_INTEGER, session->next_rid++, | |
1242 "body", MSIM_TYPE_STRING, g_strdup_printf("ContactID=%s", buddy->name), | |
1243 NULL)) | |
1244 { | |
1245 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); | |
1246 return; | |
1247 } | |
1248 | |
1249 /* TODO: update blocklist */ | |
1211 } | 1250 } |
1212 | 1251 |
1213 | 1252 |
1214 | 1253 |
1215 /** | 1254 /** |
1646 msim_send_typing, /* send_typing */ | 1685 msim_send_typing, /* send_typing */ |
1647 NULL, /* get_info */ | 1686 NULL, /* get_info */ |
1648 NULL, /* set_away */ | 1687 NULL, /* set_away */ |
1649 NULL, /* set_idle */ | 1688 NULL, /* set_idle */ |
1650 NULL, /* change_passwd */ | 1689 NULL, /* change_passwd */ |
1651 msim_add_buddy, /* add_buddy TODO */ | 1690 msim_add_buddy, /* add_buddy */ |
1652 NULL, /* add_buddies */ | 1691 NULL, /* add_buddies */ |
1653 NULL, /* remove_buddy TODO */ | 1692 msim_remove_buddy, /* remove_buddy */ |
1654 NULL, /* remove_buddies */ | 1693 NULL, /* remove_buddies */ |
1655 NULL, /* add_permit */ | 1694 NULL, /* add_permit */ |
1656 NULL, /* add_deny */ | 1695 NULL, /* add_deny */ |
1657 NULL, /* rem_permit */ | 1696 NULL, /* rem_permit */ |
1658 NULL, /* rem_deny */ | 1697 NULL, /* rem_deny */ |