Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/xmpp_iqrequest.c @ 2003:10cec229b41a
Handle errors of private storage
author | Hermitifier |
---|---|
date | Fri, 21 Oct 2011 08:50:32 +0200 |
parents | 45e0b13a39e2 |
children | aa7e03c35488 |
comparison
equal
deleted
inserted
replaced
2002:a0437e179b35 | 2003:10cec229b41a |
---|---|
648 static LmHandlerResult cb_storage_bookmarks(LmMessageHandler *h, | 648 static LmHandlerResult cb_storage_bookmarks(LmMessageHandler *h, |
649 LmConnection *c, | 649 LmConnection *c, |
650 LmMessage *m, gpointer user_data) | 650 LmMessage *m, gpointer user_data) |
651 { | 651 { |
652 LmMessageNode *x, *ansqry; | 652 LmMessageNode *x, *ansqry; |
653 char *p; | 653 char *p = NULL; |
654 | 654 |
655 if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_ERROR) { | 655 if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_ERROR) { |
656 LmMessageNode *error = lm_message_node_get_child(m->node, "error"); | |
656 // No server support, or no bookmarks? | 657 // No server support, or no bookmarks? |
657 p = m->node->children->name; | 658 if (error && error->children) |
659 p = error->children->name; | |
658 if (p && !strcmp(p, "item-not-found")) { | 660 if (p && !strcmp(p, "item-not-found")) { |
659 // item-no-found means the server has Private Storage, but it's | 661 // item-no-found means the server has Private Storage, but it's |
660 // currently empty. | 662 // currently empty. |
661 if (bookmarks) | 663 if (bookmarks) |
662 lm_message_node_unref(bookmarks); | 664 lm_message_node_unref(bookmarks); |
663 bookmarks = lm_message_node_new("storage", "storage:bookmarks"); | 665 bookmarks = lm_message_node_new("storage", "storage:bookmarks"); |
664 // We return 0 so that the IQ error message be | 666 // We return 0 so that the IQ error message be |
665 // not displayed, as it isn't a real error. | 667 // not displayed, as it isn't a real error. |
666 return LM_HANDLER_RESULT_REMOVE_MESSAGE; | 668 } else |
667 } | 669 scr_LogPrint(LPRINT_LOGNORM, "Server does not support bookmarks storage."); |
668 return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; // Unhandled error | 670 return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
669 } | 671 } |
670 | 672 |
671 ansqry = lm_message_node_get_child(m->node, "query"); | 673 ansqry = lm_message_node_get_child(m->node, "query"); |
672 ansqry = lm_message_node_get_child(ansqry, "storage"); | 674 ansqry = lm_message_node_get_child(ansqry, "storage"); |
673 if (!ansqry) { | 675 if (!ansqry) { |
695 LmMessage *m, gpointer user_data) | 697 LmMessage *m, gpointer user_data) |
696 { | 698 { |
697 LmMessageNode *ansqry; | 699 LmMessageNode *ansqry; |
698 | 700 |
699 if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_ERROR) { | 701 if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_ERROR) { |
700 const char *p; | 702 const char *p = NULL; |
703 LmMessageNode *error = lm_message_node_get_child(m->node, "error"); | |
701 // No server support, or no roster notes? | 704 // No server support, or no roster notes? |
702 p = m->node->children->name; | 705 if (error && error->children) |
706 p = error->children->name; | |
703 if (p && !strcmp(p, "item-not-found")) { | 707 if (p && !strcmp(p, "item-not-found")) { |
704 // item-no-found means the server has Private Storage, but it's | 708 // item-no-found means the server has Private Storage, but it's |
705 // currently empty. | 709 // currently empty. |
706 if (rosternotes) | 710 if (rosternotes) |
707 lm_message_node_unref(rosternotes); | 711 lm_message_node_unref(rosternotes); |
708 rosternotes = lm_message_node_new("storage", "storage:rosternotes"); | 712 rosternotes = lm_message_node_new("storage", "storage:rosternotes"); |
709 // We return 0 so that the IQ error message be | 713 // We return 0 so that the IQ error message be |
710 // not displayed, as it isn't a real error. | 714 // not displayed, as it isn't a real error. |
711 return LM_HANDLER_RESULT_REMOVE_MESSAGE; | 715 } else |
712 } | 716 scr_LogPrint(LPRINT_LOGNORM, "Server does not support roster notes storage."); |
713 return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; // Unhandled error | 717 return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
714 } | 718 } |
715 | 719 |
716 ansqry = lm_message_node_get_child(m->node, "query"); | 720 ansqry = lm_message_node_get_child(m->node, "query"); |
717 ansqry = lm_message_node_get_child(ansqry, "storage"); | 721 ansqry = lm_message_node_get_child(ansqry, "storage"); |
718 if (!ansqry) { | 722 if (!ansqry) { |