libpurple/protocols/myspace/myspace.c

branch
soc.2007.msimprpl
changeset 18063
619ec16f2e6d
parent 18062
c903259e0c83
child 18064
527bea0f11ab
equal deleted inserted replaced
18062:c903259e0c83 18063:619ec16f2e6d
2282 { 2282 {
2283 purple_debug_info("msim", 2283 purple_debug_info("msim",
2284 "msim_check_inbox_cb: notifying of %d\n", n); 2284 "msim_check_inbox_cb: notifying of %d\n", n);
2285 2285
2286 /* TODO: free strings with callback _if_ change to dynamic (w/ token) */ 2286 /* TODO: free strings with callback _if_ change to dynamic (w/ token) */
2287 purple_notify_emails(session->account, 2287 purple_notify_emails(session->gc, /* handle */
2288 n, TRUE, subjects, froms, tos, urls, NULL, NULL); 2288 n, /* count */
2289 TRUE, /* detailed */
2290 subjects, froms, tos, urls,
2291 NULL, /* PurpleNotifyCloseCallback cb */
2292 NULL); /* gpointer user_data */
2289 2293
2290 } 2294 }
2291 2295
2292 g_hash_table_destroy(body); 2296 g_hash_table_destroy(body);
2293 } 2297 }
2887 */ 2891 */
2888 static MsimMessage * 2892 static MsimMessage *
2889 msim_do_postprocessing(MsimMessage *msg, const gchar *uid_before, 2893 msim_do_postprocessing(MsimMessage *msg, const gchar *uid_before,
2890 const gchar *uid_field_name, guint uid) 2894 const gchar *uid_field_name, guint uid)
2891 { 2895 {
2892 purple_debug_info("msim", "msim_do_postprocessing called with ufn=%s, ub=%s, uid=%d\n",
2893 uid_field_name, uid_before, uid);
2894 msim_msg_dump("msim_do_postprocessing msg: %s\n", msg); 2896 msim_msg_dump("msim_do_postprocessing msg: %s\n", msg);
2895 2897
2896 /* First, check - if the field already exists, treat it as a format string. */ 2898 /* First, check - if the field already exists, treat it as a format string. */
2897 if (msim_msg_get(msg, uid_field_name)) 2899 if (msim_msg_get(msg, uid_field_name))
2898 { 2900 {
2989 * @param msg Message to postprocess. Will NOT be freed. 2991 * @param msg Message to postprocess. Will NOT be freed.
2990 * @param username Username to resolve. Assumed to be a static string (will not be freed or copied). 2992 * @param username Username to resolve. Assumed to be a static string (will not be freed or copied).
2991 * @param uid_field_name Name of new field to add, containing uid of username. Static string. 2993 * @param uid_field_name Name of new field to add, containing uid of username. Static string.
2992 * @param uid_before Name of existing field to insert username field before. Static string. 2994 * @param uid_before Name of existing field to insert username field before. Static string.
2993 * 2995 *
2994 * @return Postprocessed message. 2996 * @return TRUE if successful.
2995 */ 2997 */
2996 gboolean 2998 gboolean
2997 msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg, 2999 msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg,
2998 const gchar *username, const gchar *uid_field_name, 3000 const gchar *username, const gchar *uid_field_name,
2999 const gchar *uid_before) 3001 const gchar *uid_before)
3000 { 3002 {
3001 PurpleBuddy *buddy; 3003 PurpleBuddy *buddy;
3002 guint uid; 3004 guint uid;
3003 gboolean rc; 3005 gboolean rc;
3004 3006
3007 g_return_val_if_fail(msg != NULL, FALSE);
3008
3005 /* Store information for msim_postprocess_outgoing_cb(). */ 3009 /* Store information for msim_postprocess_outgoing_cb(). */
3006 purple_debug_info("msim", "msim_postprocess_outgoing(u=%s,ufn=%s,ub=%s)\n",
3007 username, uid_field_name, uid_before);
3008 msim_msg_dump("msim_postprocess_outgoing: msg before=%s\n", msg); 3010 msim_msg_dump("msim_postprocess_outgoing: msg before=%s\n", msg);
3009 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); 3011 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username));
3010 msg = msim_msg_append(msg, "_uid_field_name", MSIM_TYPE_STRING, g_strdup(uid_field_name)); 3012 msg = msim_msg_append(msg, "_uid_field_name", MSIM_TYPE_STRING, g_strdup(uid_field_name));
3011 msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before)); 3013 msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before));
3012 3014
3065 delbuddy_msg = msim_msg_new(TRUE, 3067 delbuddy_msg = msim_msg_new(TRUE,
3066 "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, 3068 "delbuddy", MSIM_TYPE_BOOLEAN, TRUE,
3067 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, 3069 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
3068 /* 'delprofileid' with uid will be inserted here. */ 3070 /* 'delprofileid' with uid will be inserted here. */
3069 NULL); 3071 NULL);
3070 /* TODO: free msg */ 3072
3071 if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) 3073 if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL))
3072 { 3074 {
3073 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); 3075 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed"));
3076 msim_msg_free(delbuddy_msg);
3074 return; 3077 return;
3075 } 3078 }
3079 msim_msg_free(delbuddy_msg);
3076 3080
3077 persist_msg = msim_msg_new(TRUE, 3081 persist_msg = msim_msg_new(TRUE,
3078 "persist", MSIM_TYPE_INTEGER, 1, 3082 "persist", MSIM_TYPE_INTEGER, 1,
3079 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, 3083 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
3080 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, 3084 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE,
3084 "rid", MSIM_TYPE_INTEGER, session->next_rid++, 3088 "rid", MSIM_TYPE_INTEGER, session->next_rid++,
3085 /* <uid> will be replaced by postprocessing */ 3089 /* <uid> will be replaced by postprocessing */
3086 "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"), 3090 "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"),
3087 NULL); 3091 NULL);
3088 3092
3089 /* TODO: free msg */
3090 if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) 3093 if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL))
3091 { 3094 {
3092 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); 3095 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed"));
3096 msim_msg_free(persist_msg);
3093 return; 3097 return;
3094 } 3098 }
3099 msim_msg_free(persist_msg);
3095 3100
3096 blocklist_msg = msim_msg_new(TRUE, 3101 blocklist_msg = msim_msg_new(TRUE,
3097 "blocklist", MSIM_TYPE_BOOLEAN, TRUE, 3102 "blocklist", MSIM_TYPE_BOOLEAN, TRUE,
3098 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, 3103 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
3099 /* TODO: MsimMessage lists */ 3104 /* TODO: MsimMessage lists */
3101 NULL); 3106 NULL);
3102 3107
3103 if (!msim_postprocess_outgoing(session, blocklist_msg, buddy->name, "idlist", NULL)) 3108 if (!msim_postprocess_outgoing(session, blocklist_msg, buddy->name, "idlist", NULL))
3104 { 3109 {
3105 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("blocklist command failed")); 3110 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("blocklist command failed"));
3111 msim_msg_free(blocklist_msg);
3106 return; 3112 return;
3107 } 3113 }
3114 msim_msg_free(blocklist_msg);
3108 } 3115 }
3109 3116
3110 /** Return whether the buddy can be messaged while offline. 3117 /** Return whether the buddy can be messaged while offline.
3111 * 3118 *
3112 * The protocol supports offline messages in just the same way as online 3119 * The protocol supports offline messages in just the same way as online
3192 3199
3193 if (n + session->rxoff >= MSIM_READ_BUF_SIZE) 3200 if (n + session->rxoff >= MSIM_READ_BUF_SIZE)
3194 { 3201 {
3195 purple_debug_info("msim_input_cb", "received %d bytes, pushing rxoff to %d, over buffer size of %d\n", 3202 purple_debug_info("msim_input_cb", "received %d bytes, pushing rxoff to %d, over buffer size of %d\n",
3196 n, n + session->rxoff, MSIM_READ_BUF_SIZE); 3203 n, n + session->rxoff, MSIM_READ_BUF_SIZE);
3204 /* TODO: g_realloc like msn, yahoo, irc, jabber? */
3197 purple_connection_error(gc, _("Read buffer full")); 3205 purple_connection_error(gc, _("Read buffer full"));
3198 } 3206 }
3199 3207
3200 /* Null terminate */ 3208 /* Null terminate */
3201 purple_debug_info("msim", "msim_input_cb: going to null terminate " 3209 purple_debug_info("msim", "msim_input_cb: going to null terminate "

mercurial