Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
GetToStringStreamListener Class Reference
Inheritance diagram for GetToStringStreamListener:
Inheritance graph
[legend]
Collaboration diagram for GetToStringStreamListener:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS_INHERITED GetToStringStreamListener (nsIWebDAVResource *resource, nsIWebDAVOperationListener *listener, nsISupports *closure)
virtual ~GetToStringStreamListener ()
void onDataAvailable (in nsIRequest aRequest, in nsISupports aContext, in nsIInputStream aInputStream, in unsigned long aOffset, in unsigned long aCount)
 Called when the next chunk of data (corresponding to the request) may be read without blocking the calling thread.
void onStartRequest (in nsIRequest aRequest, in nsISupports aContext)
 Called to signify the beginning of an asynchronous request.
void onStopRequest (in nsIRequest aRequest, in nsISupports aContext, in nsresult aStatusCode)
 Called to signify the end of an asynchronous request.

Static Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
static
NS_DECL_NSISTREAMLISTENER
NS_METHOD 
StreamReaderCallback (nsIInputStream *in, void *closure, const char *fromRawSegment, PRUint32 toOffset, PRUint32 count, PRUint32 *writeCount)

Protected Member Functions

NS_IMETHOD OnStopRequest (nsIRequest *aRequest, nsISupports *aContext, nsresult aStatusCode)
virtual nsresult SignalCompletion (PRUint32 status)
virtual void SignalDetail (PRUint32 statusCode, const nsACString &resource, nsISupports *detail)
virtual nsresult ProcessResponse (nsIDOMElement *responseElt)
nsresult StatusAndHrefFromResponse (nsIDOMElement *responseElt, nsACString &href, PRUint32 *statusCode)

Protected Attributes

nsCOMPtr< nsIWebDAVResourcemResource
nsCOMPtr
< nsIWebDAVOperationListener
mListener
nsCOMPtr< nsISupports > mClosure
nsCOMPtr< nsIOutputStreammOutputStream
PRUint32 mOperation
nsCString mBody
nsCOMPtr< nsIDOMDocumentmXMLDoc

Detailed Description

Definition at line 482 of file nsOperationStreamListeners.cpp.


Constructor & Destructor Documentation

Definition at line 494 of file nsOperationStreamListeners.cpp.

{ }

Member Function Documentation

void nsIStreamListener::onDataAvailable ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsIInputStream  aInputStream,
in unsigned long  aOffset,
in unsigned long  aCount 
) [inherited]

Called when the next chunk of data (corresponding to the request) may be read without blocking the calling thread.

The onDataAvailable impl must read exactly |aCount| bytes of data before returning.

Parameters:
aRequestrequest corresponding to the source of the data
aContextuser defined context
aInputStreaminput stream containing the data chunk
aOffsetNumber of bytes that were sent in previous onDataAvailable calls for this request. In other words, the sum of all previous count parameters. If that number is greater than or equal to 2^32, this parameter will be PR_UINT32_MAX (2^32 - 1).
aCountnumber of bytes available in the stream

NOTE: The aInputStream parameter must implement readSegments.

An exception thrown from onDataAvailable has the side-effect of causing the request to be canceled.

void nsIRequestObserver::onStartRequest ( in nsIRequest  aRequest,
in nsISupports  aContext 
) [inherited]

Called to signify the beginning of an asynchronous request.

Parameters:
aRequestrequest being observed
aContextuser defined context

An exception thrown from onStartRequest has the side-effect of causing the request to be canceled.

Here is the caller graph for this function:

void nsIRequestObserver::onStopRequest ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsresult  aStatusCode 
) [inherited]

Called to signify the end of an asynchronous request.

This call is always preceded by a call to onStartRequest.

Parameters:
aRequestrequest being observed
aContextuser defined context
aStatusCodereason for stopping (NS_OK if completed successfully)

An exception thrown from onStopRequest is generally ignored.

Here is the caller graph for this function:

NS_IMETHODIMP GetToStringStreamListener::OnStopRequest ( nsIRequest aRequest,
nsISupports *  aContext,
nsresult  aStatusCode 
) [protected]

Definition at line 504 of file nsOperationStreamListeners.cpp.

{
    PRUint32 status, rv;
    nsCOMPtr<nsIHttpChannel> channel = do_QueryInterface(aContext);

    LOG(("OperationStreamListener::OnStopRequest() entered"));

    rv = channel ? channel->GetResponseStatus(&status) : NS_ERROR_UNEXPECTED;

    if (NS_FAILED(rv))
        return SignalCompletion(rv);

    if (status != 200)
        return SignalCompletion(status);

    nsCOMPtr<nsISupportsCString>
        suppString(do_CreateInstance("@mozilla.org/supports-cstring;1",
                                     &rv));
    NS_ENSURE_SUCCESS(rv, rv);
    suppString->SetData(mBody);

    SignalDetail(status, nsCAutoString(""), suppString);
    SignalCompletion(status);
    return NS_OK;
}

Here is the call graph for this function:

nsresult OperationStreamListener::ProcessResponse ( nsIDOMElement responseElt) [protected, virtual, inherited]

Reimplemented in ReportStreamListener, and PropfindStreamListener.

Definition at line 248 of file nsOperationStreamListeners.cpp.

{
    nsCAutoString href;
    PRUint32 statusCode;
    nsresult rv = StatusAndHrefFromResponse(responseElt, href, &statusCode);
    NS_ENSURE_SUCCESS(rv, rv);

    SignalDetail(statusCode, href, nsnull);
    return NS_OK;
}

Here is the call graph for this function:

virtual nsresult OperationStreamListener::SignalCompletion ( PRUint32  status) [inline, protected, virtual, inherited]

Definition at line 87 of file nsOperationStreamListeners.cpp.

    {    
        mListener->OnOperationComplete(status, mResource, mOperation,
                                       mClosure);
        if (mOutputStream)
            return mOutputStream->Flush();
        return NS_OK;
    }
void OperationStreamListener::SignalDetail ( PRUint32  statusCode,
const nsACString &  resource,
nsISupports *  detail 
) [protected, virtual, inherited]

Definition at line 218 of file nsOperationStreamListeners.cpp.

{
    nsCOMPtr<nsIURL> resourceURL, detailURL;
    nsCOMPtr<nsIURI> detailURI;
    if (NS_FAILED(mResource->GetResourceURL(getter_AddRefs(resourceURL))))
        return;
    if (resource.IsEmpty()) {
        detailURL = resourceURL;
    } else {
        // if this URL is relative, resolve it.
        nsresult rv;
        nsCAutoString resolvedSpec;
        rv = resourceURL->Resolve(resource, resolvedSpec);

        // XXX better error handling
        NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to resolve remote URL!");

        if (NS_FAILED(resourceURL->Clone(getter_AddRefs(detailURI))) ||
            !(detailURL = do_QueryInterface(detailURI)) ||
            NS_FAILED(detailURI->SetSpec(resolvedSpec))) {
            return;
        }
    }
    mListener->OnOperationDetail(statusCode, detailURL, mOperation, detail,
                                 mClosure);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult OperationStreamListener::StatusAndHrefFromResponse ( nsIDOMElement responseElt,
nsACString &  href,
PRUint32 statusCode 
) [protected, inherited]

Definition at line 260 of file nsOperationStreamListeners.cpp.

{
    nsAutoString hrefString;
    nsresult rv = NS_WD_ElementTextChildValue(responseElt,
                                              NS_LITERAL_STRING("href"),
                                              hrefString);
    NS_ENSURE_SUCCESS(rv, rv);
    href = NS_ConvertUTF16toUTF8(hrefString);
    
    nsAutoString statusString;
    rv = NS_WD_ElementTextChildValue(responseElt, NS_LITERAL_STRING("status"),
                                     statusString);
    // XXX if we don't find a status element (or hit any other parse error,
    // for that matter) we need to signal this back to the caller
    //
    NS_ENSURE_SUCCESS(rv, rv);

    PRInt32 res = 0;
    NS_ConvertUTF16toUTF8 statusUTF8(statusString);
    LOG(("status: %s", statusUTF8.get()));
    PRInt32 statusVal = nsCAutoString(Substring(statusUTF8,
                                                8)).ToInteger(&res, 10);
    NS_ENSURE_SUCCESS(res, (nsresult)res);
    
    *statusCode = (PRUint32)statusVal;
    
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_METHOD OperationStreamListener::StreamReaderCallback ( nsIInputStream in,
void closure,
const char *  fromRawSegment,
PRUint32  toOffset,
PRUint32  count,
PRUint32 writeCount 
) [static, inherited]

Definition at line 179 of file nsOperationStreamListeners.cpp.

{
    OperationStreamListener *osl = NS_STATIC_CAST(OperationStreamListener *,
                                                  aClosure);
    osl->mBody.Append(aRawSegment, aCount);
    *aWriteCount = aCount;
    return NS_OK;
}

Member Data Documentation

nsCString OperationStreamListener::mBody [protected, inherited]

Definition at line 110 of file nsOperationStreamListeners.cpp.

nsCOMPtr<nsISupports> OperationStreamListener::mClosure [protected, inherited]

Definition at line 107 of file nsOperationStreamListeners.cpp.

Definition at line 106 of file nsOperationStreamListeners.cpp.

Definition at line 109 of file nsOperationStreamListeners.cpp.

Definition at line 108 of file nsOperationStreamListeners.cpp.

Definition at line 105 of file nsOperationStreamListeners.cpp.

Definition at line 111 of file nsOperationStreamListeners.cpp.


The documentation for this class was generated from the following file: