Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsWebDAVUtils.cpp File Reference
#include "nsWebDAVInternal.h"
#include "nsComponentManagerUtils.h"
#include "nsIDOMElement.h"
#include "nsIDOMNode.h"
#include "nsIDOM3Node.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMDocument.h"
#include "nsIDOMParser.h"
#include "nsContentErrors.h"

Go to the source code of this file.

Functions

nsresult NS_WD_GetElementByTagName (nsIDOMElement *parentElt, const nsAString &tagName, nsIDOMElement **elt)
nsresult NS_WD_ElementTextChildValue (nsIDOMElement *elt, const nsAString &tagName, nsAString &value)
nsresult NS_WD_AppendElementWithNS (nsIDOMDocument *doc, nsIDOMNode *parent, const nsAString &ns, const nsAString &tagName, nsIDOMElement **child)
nsresult NS_WD_GetDocAndResponseListFromBuffer (const nsACString &buffer, nsIDOMDocument **xmldoc, nsIDOMNodeList **responseList, PRUint32 *length)

Function Documentation

nsresult NS_WD_AppendElementWithNS ( nsIDOMDocument doc,
nsIDOMNode parent,
const nsAString &  ns,
const nsAString &  tagName,
nsIDOMElement **  child 
)

Definition at line 93 of file nsWebDAVUtils.cpp.

{
    nsresult rv;
    nsCOMPtr<nsIDOMElement> childElt;
    nsCOMPtr<nsIDOMNode> junk;

    rv = doc->CreateElementNS(ns, tagName, getter_AddRefs(childElt));
    NS_ENSURE_SUCCESS(rv, rv);
    
    rv = parent->AppendChild(childElt, getter_AddRefs(junk));
    NS_ENSURE_SUCCESS(rv, rv);
    
    *child = childElt.get();
    NS_ADDREF(*child);
    
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_WD_ElementTextChildValue ( nsIDOMElement elt,
const nsAString &  tagName,
nsAString &  value 
)

Definition at line 78 of file nsWebDAVUtils.cpp.

{
    nsCOMPtr<nsIDOMElement> childElt;
    nsresult rv = NS_WD_GetElementByTagName(elt, tagName,
                                            getter_AddRefs(childElt));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIDOM3Node> node3 = do_QueryInterface(childElt, &rv);
    NS_ENSURE_SUCCESS(rv, rv);

    return node3->GetTextContent(value);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_WD_GetDocAndResponseListFromBuffer ( const nsACString &  buffer,
nsIDOMDocument **  xmldoc,
nsIDOMNodeList **  responseList,
PRUint32 length 
)

Definition at line 114 of file nsWebDAVUtils.cpp.

{
    nsresult rv;

    nsCOMPtr<nsIDOMParser>
        parser(do_CreateInstance("@mozilla.org/xmlextras/domparser;1", &rv));
    NS_ENSURE_SUCCESS(rv, rv);

    nsPromiseFlatCString flat(buffer);

    PR_LOG(gDAVLog, 5, ("XML:\n\n%*s\n\n", flat.Length(), flat.get()));

    nsCOMPtr<nsIDOMDocument> doc;
    rv = parser->ParseFromBuffer(NS_REINTERPRET_CAST(const PRUint8 *,
                                                     flat.get()),
                                 flat.Length(), "text/xml",
                                 getter_AddRefs(doc));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIDOMNodeList> list;
    rv = doc->GetElementsByTagNameNS(NS_LITERAL_STRING("DAV:"),
                                     NS_LITERAL_STRING("response"),
                                     getter_AddRefs(list));
    NS_ENSURE_SUCCESS(rv, rv);

    rv = list->GetLength(length);
    NS_ENSURE_SUCCESS(rv, rv);
    NS_ENSURE_TRUE(length, NS_ERROR_UNEXPECTED);

    NS_ADDREF(*xmldoc = doc.get());
    NS_ADDREF(*responseList = list.get());
    return NS_OK;
}

Here is the call graph for this function:

nsresult NS_WD_GetElementByTagName ( nsIDOMElement parentElt,
const nsAString &  tagName,
nsIDOMElement **  elt 
)

Definition at line 57 of file nsWebDAVUtils.cpp.

{
    nsresult rv;

    nsCOMPtr<nsIDOMNodeList> list;
    rv = parentElt->GetElementsByTagNameNS(NS_LITERAL_STRING("DAV:"), tagName, getter_AddRefs(list));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIDOMNode> node;
    rv = list->Item(0, getter_AddRefs(node));
    NS_ENSURE_SUCCESS(rv, rv);

    if (!node) {
        return NS_OK;
    }

    return CallQueryInterface(node, elt);
}

Here is the call graph for this function:

Here is the caller graph for this function: