changeset 2003:10cec229b41a

Handle errors of private storage
author Hermitifier
date Fri, 21 Oct 2011 08:50:32 +0200
parents a0437e179b35
children aa7e03c35488
files mcabber/mcabber/xmpp_iqrequest.c
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/xmpp_iqrequest.c	Thu Oct 13 15:58:02 2011 +0200
+++ b/mcabber/mcabber/xmpp_iqrequest.c	Fri Oct 21 08:50:32 2011 +0200
@@ -650,11 +650,13 @@
                                             LmMessage *m, gpointer user_data)
 {
   LmMessageNode *x, *ansqry;
-  char *p;
+  char *p = NULL;
 
   if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_ERROR) {
+    LmMessageNode *error = lm_message_node_get_child(m->node, "error");
     // No server support, or no bookmarks?
-    p = m->node->children->name;
+    if (error && error->children)
+      p = error->children->name;
     if (p && !strcmp(p, "item-not-found")) {
       // item-no-found means the server has Private Storage, but it's
       // currently empty.
@@ -663,9 +665,9 @@
       bookmarks = lm_message_node_new("storage", "storage:bookmarks");
       // We return 0 so that the IQ error message be
       // not displayed, as it isn't a real error.
-      return LM_HANDLER_RESULT_REMOVE_MESSAGE;
-    }
-    return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; // Unhandled error
+    } else
+      scr_LogPrint(LPRINT_LOGNORM, "Server does not support bookmarks storage.");
+    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
   }
 
   ansqry = lm_message_node_get_child(m->node, "query");
@@ -697,9 +699,11 @@
   LmMessageNode *ansqry;
 
   if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_ERROR) {
-    const char *p;
+    const char *p = NULL;
+    LmMessageNode *error = lm_message_node_get_child(m->node, "error");
     // No server support, or no roster notes?
-    p = m->node->children->name;
+    if (error && error->children)
+      p = error->children->name;
     if (p && !strcmp(p, "item-not-found")) {
       // item-no-found means the server has Private Storage, but it's
       // currently empty.
@@ -708,9 +712,9 @@
       rosternotes = lm_message_node_new("storage", "storage:rosternotes");
       // We return 0 so that the IQ error message be
       // not displayed, as it isn't a real error.
-      return LM_HANDLER_RESULT_REMOVE_MESSAGE;
-    }
-    return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; // Unhandled error
+    } else
+      scr_LogPrint(LPRINT_LOGNORM, "Server does not support roster notes storage.");
+    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
   }
 
   ansqry = lm_message_node_get_child(m->node, "query");