changeset 335:34ecd09ce4f8

properly set msgid to the posted message.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 13 Oct 2009 14:07:55 +0900
parents 2dec3eb6e770
children 8de140bc8d13
files twitter_api.c
diffstat 1 files changed, 25 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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, "<?xml");
 
@@ -442,11 +442,12 @@
         if(doc == NULL)
             return;
 
+
         /* enqueue posted message to postedlist */
         for(nptr = doc->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<BR>%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);
     }