Back to index

avfs  1.0.1
Classes | Typedefs | Functions
dav_props.h File Reference
#include "http_request.h"
#include "dav_207.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dav_proppatch_operation

Typedefs

typedef
typedefBEGIN_NEON_DECLS struct 
dav_prop_result_set_s
typedef int(* dav_propset_iterator )(void *userdata, const dav_propname *pname, const char *value, const http_status *status)
typedef void(* dav_props_result )(void *userdata, const char *href, const dav_prop_result_set *results)
typedef struct dav_propfind_handler_s
typedef void *(* dav_props_create_complex )(void *userdata, const char *uri)

Functions

const char * dav_propset_value (const dav_prop_result_set *set, const dav_propname *propname)
const http_statusdav_propset_status (const dav_prop_result_set *set, const dav_propname *propname)
void * dav_propset_private (const dav_prop_result_set *set)
int dav_propset_iterate (const dav_prop_result_set *set, dav_propset_iterator iterator, void *userdata)
int dav_simple_propfind (http_session *sess, const char *uri, int depth, const dav_propname *props, dav_props_result results, void *userdata)
int dav_proppatch (http_session *sess, const char *uri, const dav_proppatch_operation *items)
void * dav_propfind_current_private (dav_propfind_handler *handler)
dav_propfind_handler * dav_propfind_create (http_session *sess, const char *uri, int depth)
hip_xml_parser * dav_propfind_get_parser (dav_propfind_handler *handler)
void dav_propfind_set_complex (dav_propfind_handler *handler, const dav_propname *proplist, dav_props_create_complex creator, void *userdata)
void dav_propfind_set_flat (dav_propfind_handler *handler, const dav_propname *prop)
int dav_propfind_allprop (dav_propfind_handler *handler, dav_props_result result, void *userdata)
int dav_propfind_named (dav_propfind_handler *handler, dav_props_result result, void *userdata)
void dav_propfind_destroy (dav_propfind_handler *handler)

Typedef Documentation

typedef typedefBEGIN_NEON_DECLS struct dav_prop_result_set_s

Definition at line 56 of file dav_props.h.

typedef struct dav_propfind_handler_s

Definition at line 138 of file dav_props.h.

typedef void*(* dav_props_create_complex)(void *userdata, const char *uri)

Definition at line 181 of file dav_props.h.

typedef void(* dav_props_result)(void *userdata, const char *href, const dav_prop_result_set *results)

Definition at line 96 of file dav_props.h.

typedef int(* dav_propset_iterator)(void *userdata, const dav_propname *pname, const char *value, const http_status *status)

Definition at line 82 of file dav_props.h.


Function Documentation

int dav_propfind_allprop ( dav_propfind_handler *  handler,
dav_props_result  result,
void *  userdata 
)

Definition at line 160 of file dav_props.c.

{
    sbuffer_zappend(handler->body, "<allprop/></propfind>" EOL);
    return propfind(handler, results, userdata);
}

Here is the call graph for this function:

dav_propfind_handler* dav_propfind_create ( http_session *  sess,
const char *  uri,
int  depth 
)

Definition at line 483 of file dav_props.c.

{
    dav_propfind_handler *ret = ne_calloc(sizeof(dav_propfind_handler));

    ret->parser = hip_xml_create();
    ret->parser207 = dav_207_create(ret->parser, ret);
    ret->uri = uri;
    ret->depth = depth;
    ret->sess = sess;
    ret->body = sbuffer_create();

    dav_207_set_response_handlers(ret->parser207, 
                              start_response, end_response);

    dav_207_set_propstat_handlers(ret->parser207, start_propstat,
                              end_propstat);

    /* The start of the request body is fixed: */
    sbuffer_concat(ret->body, 
                  "<?xml version=\"1.0\" encoding=\"utf-8\"?>" EOL 
                  "<propfind xmlns=\"DAV:\">", NULL);

    return ret;
}

Here is the call graph for this function:

void* dav_propfind_current_private ( dav_propfind_handler *  handler)

Definition at line 269 of file dav_props.c.

{
    return handler->current->private;
}
void dav_propfind_destroy ( dav_propfind_handler *  handler)

Definition at line 553 of file dav_props.c.

{
    dav_207_destroy(handler->parser207);
    hip_xml_destroy(handler->parser);
    if (handler->elms != NULL)
       free_elms(handler->elms);
    sbuffer_destroy(handler->body);
    free(handler);    
}

Here is the call graph for this function:

hip_xml_parser* dav_propfind_get_parser ( dav_propfind_handler *  handler)

Definition at line 84 of file dav_props.c.

{
    return handler->parser;
}
int dav_propfind_named ( dav_propfind_handler *  handler,
dav_props_result  result,
void *  userdata 
)

Definition at line 167 of file dav_props.c.

{
    sbuffer_zappend(handler->body, "</prop></propfind>" EOL);
    return propfind(handler, results, userdata);
}

Here is the call graph for this function:

void dav_propfind_set_complex ( dav_propfind_handler *  handler,
const dav_propname proplist,
dav_props_create_complex  creator,
void *  userdata 
)

Definition at line 602 of file dav_props.c.

{
    set_body(hdl, props);
    hdl->private_creator = creator;
    hdl->private_userdata = userdata;
}

Here is the call graph for this function:

void dav_propfind_set_flat ( dav_propfind_handler *  handler,
const dav_propname prop 
)

Definition at line 588 of file dav_props.c.

{
    set_body(hdl, props);

    /* Register our special flat-property handler, which
     * is used for every flat property that they just passed.
     */
    
    hdl->elms = make_elms(props);
    hip_xml_push_handler(hdl->parser, hdl->elms, 
                      check_context, startelm, endelm, hdl);
}

Here is the call graph for this function:

int dav_proppatch ( http_session *  sess,
const char *  uri,
const dav_proppatch_operation items 
)

Definition at line 176 of file dav_props.c.

{
    http_req *req = http_request_create(sess, "PROPPATCH", uri);
    sbuffer body = sbuffer_create();
    char *utf8body;
    int n, ret;
    
    /* Create the request body */
    sbuffer_zappend(body, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" EOL
                   "<propertyupdate xmlns=\"DAV:\">");

    for (n = 0; items[n].name != NULL; n++) {
       switch (items[n].type) {
       case dav_propset:
           /* <set><prop><prop-name>value</prop-name></prop></set> */
           sbuffer_concat(body, "<set><prop>"
                        "<", items[n].name->name, " xmlns=\"",
                        items[n].name->nspace, "\">", items[n].value,
                        "</", items[n].name->name, "></prop></set>" EOL, 
                        NULL);
           break;

       case dav_propremove:
           /* <remove><prop><prop-name/></prop></remove> */
           sbuffer_concat(body, 
                        "<remove><prop><", items[n].name->name, " xmlns=\"",
                        items[n].name->nspace, "\"/></prop></remove>" EOL, 
                        NULL);
           break;
       }
    }  

    sbuffer_zappend(body, "</propertyupdate>" EOL);
    
    utf8body = ne_utf8_encode(sbuffer_data(body));

    http_set_request_body_buffer(req, utf8body);
    http_add_request_header(req, "Content-Type", "text/xml"); /* TODO: UTF-8? */
    
    ret = dav_simple_request(sess, req);
    
    sbuffer_destroy(body);
    free(utf8body);

    return ret;
}
int dav_propset_iterate ( const dav_prop_result_set *  set,
dav_propset_iterator  iterator,
void *  userdata 
)

Definition at line 279 of file dav_props.c.

{
    int ps, p;

    for (ps = 0; ps < set->numpstats; ps++) {
       for (p = 0; p < set->pstats[ps].numprops; p++) {
           struct prop *prop = &set->pstats[ps].props[p];
           int ret = iterator(userdata, &prop->pname, prop->value, 
                            &set->pstats[ps].status);
           if (ret)
              return ret;

       }
    }

    return 0;
}
void* dav_propset_private ( const dav_prop_result_set *  set)

Definition at line 274 of file dav_props.c.

{
    return set->private;
}
const http_status* dav_propset_status ( const dav_prop_result_set *  set,
const dav_propname propname 
)

Definition at line 298 of file dav_props.c.

{
    struct propstat *pstat;
    
    if (findprop(set, pname, &pstat, NULL)) {
       /* TODO: it is tempting to return a dummy status object here
        * rather than NULL, which says "Property result was not given
        * by server."  but I'm not sure if this is best left to the
        * client.  */
       return NULL;
    } else {
       return &pstat->status;
    }
}

Here is the call graph for this function:

const char* dav_propset_value ( const dav_prop_result_set *  set,
const dav_propname propname 
)

Definition at line 257 of file dav_props.c.

{
    struct prop *prop;
    
    if (findprop(set, pname, NULL, &prop)) {
       return NULL;
    } else {
       return prop->value;
    }
}

Here is the call graph for this function:

int dav_simple_propfind ( http_session *  sess,
const char *  uri,
int  depth,
const dav_propname props,
dav_props_result  results,
void *  userdata 
)

Definition at line 563 of file dav_props.c.

{
    dav_propfind_handler *hdl;
    int ret;

    hdl = dav_propfind_create(sess, href, depth);
    if (props != NULL) {
       /* Named. */
       dav_propfind_set_flat(hdl, props);
       ret = dav_propfind_named(hdl, results, userdata);
    } else {
       /* Allprop: register the catch-all-props handler. */
       hdl->elms = make_elms(NULL);
       hip_xml_push_handler(hdl->parser, hdl->elms, 
                          check_context, startelm, endelm, hdl);
       ret = dav_propfind_allprop(hdl, results, userdata);
    }
       
    dav_propfind_destroy(hdl);
    
    return ret;
}

Here is the call graph for this function: