1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <com/sun/star/uno/XComponentContext.hpp>
32 #include <rtl/ref.hxx>
33 #include <rtl/ustring.hxx>
34 #include <osl/conditn.hxx>
37 struct DownloadInteractionHandler
: public rtl::IReference
39 virtual bool checkDownloadDestination(const rtl::OUString
& rFileName
) = 0;
41 // called if the destination file already exists, but resume is false
42 virtual bool downloadTargetExists(const rtl::OUString
& rFileName
) = 0;
44 // called when curl reports an error
45 virtual void downloadStalled(const rtl::OUString
& rErrorMessage
) = 0;
48 virtual void downloadProgressAt(sal_Int8 nPercent
) = 0;
50 // called on first progress notification
51 virtual void downloadStarted(const rtl::OUString
& rFileName
, sal_Int64 nFileSize
) = 0;
53 // called when download has been finished
54 virtual void downloadFinished(const rtl::OUString
& rFileName
) = 0;
57 ~DownloadInteractionHandler() {}
64 Download(const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>& xContext
,
65 const rtl::Reference
< DownloadInteractionHandler
>& rHandler
) : m_xContext(xContext
), m_aHandler(rHandler
) {};
67 // returns true when the content of rURL was successfully written to rLocalFile
68 bool start(const rtl::OUString
& rURL
, const rtl::OUString
& rFile
, const rtl::OUString
& rDestinationDir
);
70 // stops the download after the next write operation
73 // returns true if the stop condition is set
74 bool isStopped() const
75 { return sal_True
== const_cast <Download
*> (this)->m_aCondition
.check(); };
79 // Determines the appropriate proxy settings for the given URL. Returns true if a proxy should be used
80 void getProxyForURL(const rtl::OUString
& rURL
, rtl::OString
& rHost
, sal_Int32
& rPort
) const;
83 osl::Condition m_aCondition
;
84 const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>& m_xContext
;
85 const rtl::Reference
< DownloadInteractionHandler
> m_aHandler
;
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */