Changeset 9e8c945 for protocols


Ignore:
Timestamp:
2012-11-10T12:31:33Z (11 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
8bd866f
Parents:
24132ec
Message:

Removed xmltree dependency entirely.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter_lib.c

    r24132ec r9e8c945  
    3535#include "misc.h"
    3636#include "base64.h"
    37 #include "xmltree.h"
    3837#include "twitter_lib.h"
    3938#include "json_util.h"
     
    257256 * Fill a list of ids.
    258257 */
    259 static xt_status twitter_xt_get_friends_id_list(json_value *node, struct twitter_xml_list *txl)
     258static gboolean twitter_xt_get_friends_id_list(json_value *node, struct twitter_xml_list *txl)
    260259{
    261260        json_value *c;
     
    267266        c = json_o_get(node, "ids");
    268267        if (!c || c->type != json_array)
    269                 return XT_ABORT;
     268                return FALSE;
    270269
    271270        for (i = 0; i < c->u.array.length; i ++) {
     
    284283                txl->next_cursor = -1;
    285284       
    286         return XT_HANDLED;
     285        return TRUE;
    287286}
    288287
     
    334333}
    335334
    336 static xt_status twitter_xt_get_users(json_value *node, struct twitter_xml_list *txl);
     335static gboolean twitter_xt_get_users(json_value *node, struct twitter_xml_list *txl);
    337336static void twitter_http_get_users_lookup(struct http_request *req);
    338337
     
    421420 *  - all <user>s from the <users> element.
    422421 */
    423 static xt_status twitter_xt_get_users(json_value *node, struct twitter_xml_list *txl)
     422static gboolean twitter_xt_get_users(json_value *node, struct twitter_xml_list *txl)
    424423{
    425424        struct twitter_xml_user *txu;
     
    430429
    431430        if (!node || node->type != json_array)
    432                 return XT_ABORT;
     431                return FALSE;
    433432
    434433        // The root <users> node should hold the list of users <user>
     
    440439        }
    441440
    442         return XT_HANDLED;
     441        return TRUE;
    443442}
    444443
     
    457456 *  - the user in a twitter_xml_user struct.
    458457 */
    459 static xt_status twitter_xt_get_status(const json_value *node, struct twitter_xml_status *txs)
     458static gboolean twitter_xt_get_status(const json_value *node, struct twitter_xml_status *txs)
    460459{
    461460        const json_value *rt = NULL, *entities = NULL;
    462         int i;
    463461       
    464462        if (node->type != json_object)
    465                 return XT_ABORT;
    466 
    467         for (i = 0; i < node->u.object.length; i ++) {
    468                 const char *k = node->u.object.values[i].name;
    469                 const json_value *v = node->u.object.values[i].value;
    470                
     463                return FALSE;
     464
     465        JSON_O_FOREACH (node, k, v) {
    471466                if (strcmp("text", k) == 0 && v->type == json_string) {
    472467                        txs->text = g_memdup(v->u.string.ptr, v->u.string.length + 1);
     
    496491        if (rt) {
    497492                struct twitter_xml_status *rtxs = g_new0(struct twitter_xml_status, 1);
    498                 if (twitter_xt_get_status(rt, rtxs) != XT_HANDLED) {
     493                if (!twitter_xt_get_status(rt, rtxs)) {
    499494                        txs_free(rtxs);
    500                         return XT_HANDLED;
     495                        return TRUE;
    501496                }
    502497
     
    534529        }
    535530
    536         return XT_HANDLED;
     531        return TRUE;
    537532}
    538533
     
    543538 *  - the next_cursor.
    544539 */
    545 static xt_status twitter_xt_get_status_list(struct im_connection *ic, const json_value *node,
    546                                             struct twitter_xml_list *txl)
     540static gboolean twitter_xt_get_status_list(struct im_connection *ic, const json_value *node,
     541                                           struct twitter_xml_list *txl)
    547542{
    548543        struct twitter_xml_status *txs;
     
    554549       
    555550        if (node->type != json_array)
    556                 return XT_ABORT;
     551                return FALSE;
    557552
    558553        // The root <statuses> node should hold the list of statuses <status>
     
    575570        }
    576571
    577         return XT_HANDLED;
     572        return TRUE;
    578573}
    579574
Note: See TracChangeset for help on using the changeset viewer.