7 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
8 * Copyright (C) 2009, 2010, 2011, 2012, MinGW.org Project
11 * Public declaration of the download metering class, and support
12 * functions provided by the internet download agent.
15 * This is free software. Permission is granted to copy, modify and
16 * redistribute this software, under the provisions of the GNU General
17 * Public License, Version 3, (or, at your option, any later version),
18 * as published by the Free Software Foundation; see the file COPYING
19 * for licensing details.
21 * Note, in particular, that this software is provided "as is", in the
22 * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
23 * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
24 * PARTICULAR PURPOSE. Under no circumstances will the author, or the
25 * MinGW Project, accept liability for any damages, however caused,
26 * arising from the use of this software.
31 class pkgDownloadMeter
33 /* Abstract base class, from which facilities for monitoring the
34 * progress of file downloads may be derived.
37 /* Hooks for use in the implementation of the GUI download
38 * monitoring dialogue; in a CLI context, these effectively
41 static pkgDownloadMeter *UseGUI(){ return primary; }
42 static inline void SpinWait( int, const char * = NULL );
43 virtual void ResetGUI( const char *, unsigned long ){}
45 /* The working method to refresh the download progress display;
46 * each derived class MUST furnish an implementation for this.
48 virtual int Update( unsigned long ) = 0;
51 /* Reference pointer to the primary instance of the download
52 * meter in the GUI; always set to NULL, in a CLI context.
54 static pkgDownloadMeter *primary;
56 /* Handler which may be invoked by the SpinWait() hook.
58 virtual void SpinWaitAction( int, const char * ){}
60 /* Storage for the expected size of the active download...
62 unsigned long content_length;
64 /* ...and a method to format it for human readable display.
66 int SizeFormat( char *, unsigned long );
69 /* Entry point for the worker thread associated with the download
70 * monitoring dialogue, in the GUI context.
72 EXTERN_C void pkgInvokeDownload( void * );
74 #endif /* PKGINET_H: $RCSfile$: end of file */