# HG changeset patch # User Yoshiki Yazawa # Date 1255410475 -32400 # Node ID 34ecd09ce4f807ef0e4014a9b712493c9fed8925 # Parent 2dec3eb6e770f8ed64dc4b94f184946cfcaf90cc properly set msgid to the posted message. diff -r 2dec3eb6e770 -r 34ecd09ce4f8 twitter_api.c --- a/twitter_api.c Tue Oct 13 13:39:49 2009 +0900 +++ b/twitter_api.c Tue Oct 13 14:07:55 2009 +0900 @@ -141,7 +141,7 @@ else if(!xmlStrcmp(nptr->name, (xmlChar *)"id")) { gchar *str = (gchar *)xmlNodeGetContent(nptr); st->id = atoll(str); - twitter_debug("id=%llud\n", (long long unsigned int)st->id); + twitter_debug("id=%llu\n", (long long unsigned int)st->id); xmlFree(str); } else if(!xmlStrcmp(nptr->name, (xmlChar *)"text")) { @@ -368,7 +368,8 @@ if (error_message) { /* connection failed or something */ msg = g_strdup_printf("Local error: %s", error_message); - } else { + } + else { int code = -1; if ((strncmp(url_text, "HTTP/1.0", strlen("HTTP/1.0")) == 0 @@ -390,7 +391,8 @@ if (code == 200) { error = 0; - } else { + } + else { switch (code) { case 400: msg = g_strdup("Invalid request. Too many updates?"); @@ -424,14 +426,12 @@ } if (!error) { - purple_conv_im_write(conv->u.im, - purple_account_get_username(tm->account), - tm->status, PURPLE_MESSAGE_SEND, tm->time); - /* cache message ID that posted via API */ gchar *start = NULL; xmlDocPtr doc; xmlNode *nptr; + status_t *st; + gchar *m; start = strstr(url_text, "children; nptr != NULL; nptr = nptr->next) { if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"status")) { - status_t *st = g_new0(status_t, 1); + st = g_new0(status_t, 1); postedlist = g_list_prepend(postedlist, st); parse_status(nptr, st); } @@ -455,14 +456,28 @@ xmlFreeDoc(doc); xmlCleanupParser(); - } else { + m = g_strdup_printf("%s ptmsgid=%llu", + tm->status, + (long long unsigned int)st->id); + + purple_conv_im_write(conv->u.im, + purple_account_get_username(tm->account), + m, + PURPLE_MESSAGE_SEND, + tm->time); + g_free(m); + + } + else { gchar *m; m = g_strdup_printf("%s
%s", msg, tm->status); /* FIXME: too strong. it should be more smart */ purple_conv_im_write(conv->u.im, purple_account_get_username(tm->account), - m, PURPLE_MESSAGE_ERROR, time(NULL)); + m, + PURPLE_MESSAGE_ERROR, + time(NULL)); g_free(m); }