1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */
4 * Copyright (C) 2010 Sergey Yanovich <ynvich@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include "aaDBXMLtoXMLConverter.h"
24 #include "nsIChannel.h"
25 #include "nsILoadGroup.h"
27 #include "nsStringAPI.h"
28 #include "nsMimeTypes.h"
30 NS_IMPL_ISUPPORTS3(aaDBXMLtoXMLConverter
,
35 aaDBXMLtoXMLConverter::aaDBXMLtoXMLConverter()
40 aaDBXMLtoXMLConverter::~aaDBXMLtoXMLConverter()
45 aaDBXMLtoXMLConverter::Convert(nsIInputStream
*aFromStream
,
46 const char *aFromType
, const char *aToType
, nsISupports
*aCtxt
,
47 nsIInputStream
**_retval
)
49 return NS_ERROR_NOT_IMPLEMENTED
;
53 aaDBXMLtoXMLConverter::AsyncConvertData(const char *aFromType
,
54 const char *aToType
, nsIStreamListener
*aListener
, nsISupports
*ctxt
)
56 NS_ENSURE_ARG_POINTER(aListener
);
57 mListener
= aListener
;
61 // nsIStreamListener method
62 /* This method handles asyncronous conversion of data. */
64 aaDBXMLtoXMLConverter::OnDataAvailable(nsIRequest
* request
, nsISupports
*aContext
,
65 nsIInputStream
*aInStream
, PRUint32 aSourceOffset
, PRUint32 aCount
)
67 NS_ENSURE_STATE(mListener
);
68 return mListener
->OnDataAvailable(request
, aContext
, aInStream
,
69 aSourceOffset
, aCount
);
72 // nsIRequestObserver methods
73 /* These methods just pass through directly to the mListener */
75 aaDBXMLtoXMLConverter::OnStartRequest(nsIRequest
* request
, nsISupports
*ctxt
)
78 NS_ENSURE_STATE(mListener
);
80 nsCOMPtr
<nsIChannel
> channel
=
81 do_QueryInterface(request
, &rv
);
82 NS_ENSURE_SUCCESS(rv
, rv
);
84 rv
= channel
->SetContentType(NS_LITERAL_CSTRING(TEXT_XML
));
85 NS_ENSURE_SUCCESS(rv
, rv
);
87 return mListener
->OnStartRequest(request
, ctxt
);
91 aaDBXMLtoXMLConverter::OnStopRequest(nsIRequest
* request
, nsISupports
*ctxt
,
94 NS_ENSURE_STATE(mListener
);
95 return mListener
->OnStopRequest(request
, ctxt
, aStatus
);