The MinGW.org Installation Manager Tool
リビジョン | 5ee508f122d2b81d929326cd8e960b4b1ce5dfac (tree) |
---|---|
日時 | 2012-12-11 00:41:21 |
作者 | Keith Marshall <keithmarshall@user...> |
コミッター | Keith Marshall |
Implement GUI bindings for package download agent.
@@ -1,3 +1,52 @@ | ||
1 | +2012-12-10 Keith Marshall <keithmarshall@users.sourceforge.net> | |
2 | + | |
3 | + Implement GUI bindings for package download agent. | |
4 | + | |
5 | + * src/guimain.h (IDD_PROGRESS_VAL, IDD_PROGRESS_MAX): | |
6 | + (IDD_PROGRESS_PCT): New manifest resource IDs; define them. They will | |
7 | + be used to identify dialogue controls, to be associated with... | |
8 | + (IDD_APPLY_DOWNLOAD): ...this new dialogue template ID; define it. | |
9 | + (AppWindowMaker::DownloadArchiveFiles): New inline method; declare it. | |
10 | + | |
11 | + * src/guidata.rc (IDD_APPLY_DOWNLOAD): Implement dialogue template. | |
12 | + | |
13 | + * src/pkgbase.h (pkgActionItem::DownloadArchiveFiles): New public | |
14 | + inline method; declare it. It overloads an existing private method of | |
15 | + the same name, which it subsequently invokes. | |
16 | + | |
17 | + * src/pkginet.h: New header file; it declares... | |
18 | + (pkgInvokeDownload): ...this new extern "C" function prototype, and... | |
19 | + (pkgDownloadMeter): ...this abstract class; it is factored from its | |
20 | + original implementation in pkginet.cpp, augmented by addition of... | |
21 | + (pkgDownloadMeter::primary): New static member variable; declare it. | |
22 | + (pkgDownloadMeter::UseGUI): New public method; implement it inline. | |
23 | + (pkgDownloadMeter::ResetGUI): New public method; declare it, providing | |
24 | + a do-nothing inline default implementation. Any derived class, which | |
25 | + supports GUI capability, should override this. | |
26 | + | |
27 | + * src/pkgnget.cpp: New file; it implements... | |
28 | + (pkgDownloadMeterGUI): New class, derived from pkgDownloadMeter. | |
29 | + (pkgActionItem::DownloadArchiveFiles): New overloaded inline method. | |
30 | + (AppWindowMaker::DownloadArchiveFiles): New inline method. | |
31 | + (pkgInvokeDownload): New dialogue box worker thread handler. | |
32 | + | |
33 | + * src/pkginet.cpp: Include pkginet.h; hence... | |
34 | + (pkgDownloadMeter): ...remove redundant class declaration. | |
35 | + (pkgDownloadMeter::primary): Define and initialise it. | |
36 | + (pkgInternetStreamingAgent::Get) [pkgDownloadMeter::UseGUI]: Delegate | |
37 | + progress metering to referenced pkgDownloadMeterGUI class instance. | |
38 | + [! pkgDownloadMeter::UseGUI]: Continue to use the existing built-in | |
39 | + pkgDownloadMeterTTY mechanism. | |
40 | + (pkgActionItem::DownloadSingleArchive) [ACTION_DOWLOAD_FAILED]: Assert | |
41 | + this initially; subsequently clear it on successful completion. | |
42 | + (pkgActionItem::DownloadArchiveFiles): Collect diagnostic messages | |
43 | + into a single DMH_BEGIN_DIGEST ... DMH_END_DIGEST group. | |
44 | + | |
45 | + * src/guixmld.cpp: Include pkginet.h; it is required by... | |
46 | + (AppWindowMaker::OnCommand) [IDD_REPO_APPLY]: Use pkgInvokeDownload. | |
47 | + | |
48 | + * Makefile.in (GUIMAIN_OBJECTS): Include pkgnget.$OBJEXT | |
49 | + | |
1 | 50 | 2012-12-08 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 51 | |
3 | 52 | Implement "Discard" handler for GUI "Apply Changes" dialogue. |
@@ -91,7 +91,8 @@ CLI_EXE_OBJECTS = \ | ||
91 | 91 | |
92 | 92 | GUIMAIN_OBJECTS = \ |
93 | 93 | guimain.$(OBJEXT) guidata.$(OBJEXT) guixmld.$(OBJEXT) guidmh.$(OBJEXT) \ |
94 | - approot.$(OBJEXT) pkgview.$(OBJEXT) pkglist.$(OBJEXT) pkgdata.$(OBJEXT) | |
94 | + approot.$(OBJEXT) pkgview.$(OBJEXT) pkglist.$(OBJEXT) pkgdata.$(OBJEXT) \ | |
95 | + pkgnget.$(OBJEXT) | |
95 | 96 | |
96 | 97 | GUIMAIN_LIBS = -lwtklite -lcomctl32 |
97 | 98 |
@@ -4,7 +4,7 @@ | ||
4 | 4 | * $Id$ |
5 | 5 | * |
6 | 6 | * Written by Keith Marshall <keithmarshall@users.sourceforge.net> |
7 | - * Copyright (C) 2012, MinGW Project | |
7 | + * Copyright (C) 2012, MinGW.org Project | |
8 | 8 | * |
9 | 9 | * |
10 | 10 | * Resource definitions for the mingw-get GUI implementation. |
@@ -173,4 +173,21 @@ BEGIN | ||
173 | 173 | EDITTEXT IDD_APPLY_INSTALLS_PACKAGES, 7, 148, 292, 36, WS_VSCROLL | ES_VT100 |
174 | 174 | END |
175 | 175 | |
176 | +/* Template for GUI styled package download monitoring dialogue box. | |
177 | + */ | |
178 | +IDD_APPLY_DOWNLOAD DIALOG DISCARDABLE 10, 20, 280, 52 | |
179 | +CAPTION "Download Package" | |
180 | +STYLE DS_MODALFRAME | DS_SETFONT | WS_POPUP | WS_CAPTION | WS_DLGFRAME | |
181 | +FONT 10, "Verdana" | |
182 | +BEGIN | |
183 | + LTEXT "Connecting...", IDD_PROGRESS_MSG, 7, 6, 266, 10 | |
184 | + CONTROL "", IDD_PROGRESS_VAL, "STATIC", SS_CTEXTBOX, 6, 20, 100, 10 | |
185 | + CTEXT "of", IDD_PROGRESS_TXT, 106, 20, 18, 10 | |
186 | + CONTROL "", IDD_PROGRESS_MAX, "STATIC", SS_CTEXTBOX, 124, 20, 100, 10 | |
187 | + CTEXT ":", IDD_PROGRESS_TXT, 224, 20, 10, 10 | |
188 | + CONTROL "", IDD_PROGRESS_PCT, "STATIC", SS_CTEXTBOX, 234, 20, 40, 10 | |
189 | + CONTROL "", IDD_PROGRESS_BAR, PROGRESS_CLASS, WS_CHILD \ | |
190 | + | PBS_SMOOTH, 6, 35, 268, 10 | |
191 | +END | |
192 | + | |
176 | 193 | /* $RCSfile$: end of file */ |
@@ -5,7 +5,7 @@ | ||
5 | 5 | * $Id$ |
6 | 6 | * |
7 | 7 | * Written by Keith Marshall <keithmarshall@users.sourceforge.net> |
8 | - * Copyright (C) 2012, MinGW Project | |
8 | + * Copyright (C) 2012, MinGW.org Project | |
9 | 9 | * |
10 | 10 | * |
11 | 11 | * Resource definitions and window management class declarations for |
@@ -86,9 +86,13 @@ | ||
86 | 86 | #define IDD_AUTO_CLOSE_OPTION 612 |
87 | 87 | #define IDD_PROGRESS_BAR 613 |
88 | 88 | #define IDD_PROGRESS_MSG 614 |
89 | +#define IDD_PROGRESS_VAL 615 | |
90 | +#define IDD_PROGRESS_MAX 616 | |
91 | +#define IDD_PROGRESS_PCT 617 | |
89 | 92 | #define IDD_PROGRESS_TXT 618 |
90 | 93 | |
91 | 94 | #define IDD_APPLY_APPROVE 630 |
95 | +#define IDD_APPLY_DOWNLOAD 631 | |
92 | 96 | |
93 | 97 | #define IDD_APPLY_REMOVES_PACKAGES 633 |
94 | 98 | #define IDD_APPLY_REMOVES_SUMMARY 634 |
@@ -173,6 +177,7 @@ class AppWindowMaker: public WTK::MainWindowMaker | ||
173 | 177 | inline void DetachProgressMeter( pkgProgressMeter * ); |
174 | 178 | |
175 | 179 | inline unsigned long EnumerateActions( int = 0 ); |
180 | + inline void DownloadArchiveFiles( void ); | |
176 | 181 | |
177 | 182 | private: |
178 | 183 | virtual long OnCreate(); |
@@ -26,6 +26,7 @@ | ||
26 | 26 | */ |
27 | 27 | #include "guimain.h" |
28 | 28 | #include "pkgbase.h" |
29 | +#include "pkginet.h" | |
29 | 30 | #include "pkgkeys.h" |
30 | 31 | #include "pkglist.h" |
31 | 32 | #include "pkgtask.h" |
@@ -621,10 +622,10 @@ long AppWindowMaker::OnCommand( WPARAM cmd ) | ||
621 | 622 | * download any required packages, and invoke the scheduled |
622 | 623 | * remove, upgrade, or install actions. |
623 | 624 | * |
624 | - * FIXME: the pkgInvokeDownload() and pkgApplyChanges() thread | |
625 | - * handlers have yet to be implemented. | |
625 | + * FIXME: the pkgInvokeDownload() thread handler has yet to | |
626 | + * be implemented. | |
626 | 627 | */ |
627 | -// DispatchDialogueThread( IDD_APPLY_DOWNLOAD, pkgInvokeDownload ); | |
628 | + DispatchDialogueThread( IDD_APPLY_DOWNLOAD, pkgInvokeDownload ); | |
628 | 629 | // DispatchDialogueThread( IDD_APPLY_MONITORED, pkgApplyChanges ); |
629 | 630 | |
630 | 631 | /* After applying changes, we fall through... |
@@ -5,7 +5,7 @@ | ||
5 | 5 | * $Id$ |
6 | 6 | * |
7 | 7 | * Written by Keith Marshall <keithmarshall@users.sourceforge.net> |
8 | - * Copyright (C) 2009, 2010, 2011, 2012, MinGW Project | |
8 | + * Copyright (C) 2009, 2010, 2011, 2012, MinGW.org Project | |
9 | 9 | * |
10 | 10 | * |
11 | 11 | * Public interface for the package directory management routines; |
@@ -336,9 +336,10 @@ class pkgActionItem | ||
336 | 336 | void GetSourceArchive( pkgXmlNode*, unsigned long ); |
337 | 337 | void GetScheduledSourceArchives( unsigned long ); |
338 | 338 | |
339 | - /* Method for processing all scheduled actions. | |
339 | + /* Methods for processing all scheduled actions. | |
340 | 340 | */ |
341 | 341 | void Execute(); |
342 | + inline void DownloadArchiveFiles( void ); | |
342 | 343 | |
343 | 344 | /* Method to manipulate error trapping, control, and state |
344 | 345 | * flags for the schedule of actions. |
@@ -4,7 +4,7 @@ | ||
4 | 4 | * $Id$ |
5 | 5 | * |
6 | 6 | * Written by Keith Marshall <keithmarshall@users.sourceforge.net> |
7 | - * Copyright (C) 2009, 2010, 2011, 2012, MinGW Project | |
7 | + * Copyright (C) 2009, 2010, 2011, 2012, MinGW.org Project | |
8 | 8 | * |
9 | 9 | * |
10 | 10 | * Implementation of the package download machinery for mingw-get. |
@@ -50,29 +50,20 @@ | ||
50 | 50 | #include "debug.h" |
51 | 51 | |
52 | 52 | #include "pkgbase.h" |
53 | +#include "pkginet.h" | |
53 | 54 | #include "pkgkeys.h" |
54 | 55 | #include "pkgtask.h" |
55 | 56 | |
56 | -class pkgDownloadMeter | |
57 | -{ | |
58 | - /* Abstract base class, from which facilities for monitoring the | |
59 | - * progress of file downloads may be derived. | |
60 | - */ | |
61 | - public: | |
62 | - /* The working method to refresh the download progress display; | |
63 | - * each derived class MUST furnish an implementation for this. | |
64 | - */ | |
65 | - virtual int Update( unsigned long length ) = 0; | |
66 | - | |
67 | - protected: | |
68 | - /* Storage for the expected size of the active download... | |
69 | - */ | |
70 | - unsigned long content_length; | |
71 | - | |
72 | - /* ...and a method to format it for human readable display. | |
73 | - */ | |
74 | - int SizeFormat( char*, unsigned long ); | |
75 | -}; | |
57 | +/* This static member variable of the pkgDownloadMeter class | |
58 | + * provides a mechanism for communicating with a pre-existing | |
59 | + * download monitoring dialogue, such as is employed in the GUI. | |
60 | + * We MUST define it, and we also initialise it to NULL. While | |
61 | + * it remains thus, (as it always does in the CLI), no attempt | |
62 | + * will be made to access any pre-existing dialogue, and local | |
63 | + * monitoring objects will be employed; the GUI sets this to | |
64 | + * refer to its dialogue, when this is activated. | |
65 | + */ | |
66 | +pkgDownloadMeter *pkgDownloadMeter::primary = NULL; | |
76 | 67 | |
77 | 68 | class pkgDownloadMeterTTY : public pkgDownloadMeter |
78 | 69 | { |
@@ -602,12 +593,33 @@ int pkgInternetStreamingAgent::Get( const char *from_url ) | ||
602 | 593 | /* With the download transaction fully specified, we may |
603 | 594 | * request processing of the file transfer... |
604 | 595 | */ |
605 | - pkgDownloadMeterTTY download_meter | |
606 | - ( | |
607 | - from_url, pkgDownloadAgent.QueryContentLength( dl_host ) | |
608 | - ); | |
609 | - dl_meter = &download_meter; | |
610 | - dl_status = TransferData( fd ); | |
596 | + if( (dl_meter = pkgDownloadMeter::UseGUI()) != NULL ) | |
597 | + { | |
598 | + /* ...with progress monitoring delegated to the GUI's | |
599 | + * dialogue box, when running under its auspices... | |
600 | + */ | |
601 | + dl_meter->ResetGUI( | |
602 | + filename, pkgDownloadAgent.QueryContentLength( dl_host ) | |
603 | + ); | |
604 | + dl_status = TransferData( fd ); | |
605 | + } | |
606 | + else | |
607 | + { /* ...otherwise creating our own TTY progress monitor, | |
608 | + * when running under the auspices of the CLI. | |
609 | + */ | |
610 | + pkgDownloadMeterTTY download_meter( | |
611 | + from_url, pkgDownloadAgent.QueryContentLength( dl_host ) | |
612 | + ); | |
613 | + dl_meter = &download_meter; | |
614 | + | |
615 | + /* Note that the following call MUST be kept within the | |
616 | + * scope in which the progress monitor was created; thus, | |
617 | + * it CANNOT be factored out of this "else" block scope, | |
618 | + * even though it also appears at the end of the scope | |
619 | + * of the preceding "if" block. | |
620 | + */ | |
621 | + dl_status = TransferData( fd ); | |
622 | + } | |
611 | 623 | } |
612 | 624 | else DEBUG_INVOKE_IF( DEBUG_REQUEST( DEBUG_TRACE_INTERNET_REQUESTS ), |
613 | 625 | dmh_printf( "OpenURL:error:%d\n", GetLastError() ) |
@@ -682,8 +694,10 @@ void pkgActionItem::DownloadSingleArchive | ||
682 | 694 | if( ((flags & ACTION_DOWNLOAD) == ACTION_DOWNLOAD) |
683 | 695 | && ((access( download.DestFile(), R_OK ) != 0) && (errno == ENOENT)) ) |
684 | 696 | { |
685 | - /* ...if not, ask the download agent to fetch it... | |
697 | + /* ...if not, ask the download agent to fetch it, | |
698 | + * anticipating that this may fail... | |
686 | 699 | */ |
700 | + flags |= ACTION_DOWNLOAD_FAILED; | |
687 | 701 | const char *url_template = get_host_info( Selection(), uri_key ); |
688 | 702 | if( url_template != NULL ) |
689 | 703 | { |
@@ -695,9 +709,9 @@ void pkgActionItem::DownloadSingleArchive | ||
695 | 709 | mkpath( package_url, url_template, package_name, mirror ); |
696 | 710 | if( download.Get( package_url ) > 0 ) |
697 | 711 | /* |
698 | - * Download was successful; clear the pending flag. | |
712 | + * Download was successful; clear the pending and failure flags. | |
699 | 713 | */ |
700 | - flags &= ~(ACTION_DOWNLOAD); | |
714 | + flags &= ~(ACTION_DOWNLOAD | ACTION_DOWNLOAD_FAILED); | |
701 | 715 | else |
702 | 716 | /* Diagnose failure; leave pending flag set. |
703 | 717 | */ |
@@ -728,8 +742,10 @@ void pkgActionItem::DownloadArchiveFiles( pkgActionItem *current ) | ||
728 | 742 | */ |
729 | 743 | while( current != NULL ) |
730 | 744 | { |
731 | - /* ...while we haven't run off the end... | |
745 | + /* ...while we haven't run off the end, and collecting any diagnositic | |
746 | + * messages relating to any one package into a common digest... | |
732 | 747 | */ |
748 | + dmh_control( DMH_BEGIN_DIGEST ); | |
733 | 749 | if( (current->flags & ACTION_INSTALL) == ACTION_INSTALL ) |
734 | 750 | { |
735 | 751 | /* For all packages specified in the current action list, |
@@ -755,9 +771,11 @@ void pkgActionItem::DownloadArchiveFiles( pkgActionItem *current ) | ||
755 | 771 | */ |
756 | 772 | current->DownloadSingleArchive( package_name, pkgArchivePath() ); |
757 | 773 | } |
758 | - /* Repeat download action, for any additional packages specified | |
774 | + /* Flush out any diagnostics relating to the current package, then | |
775 | + * repeat the download action, for any additional packages specified | |
759 | 776 | * in the current "actions" list. |
760 | 777 | */ |
778 | + dmh_control( DMH_END_DIGEST ); | |
761 | 779 | current = current->next; |
762 | 780 | } |
763 | 781 | } |
@@ -0,0 +1,69 @@ | ||
1 | +#ifndef PKGINET_H | |
2 | +/* | |
3 | + * pkginet.h | |
4 | + * | |
5 | + * $Id$ | |
6 | + * | |
7 | + * Written by Keith Marshall <keithmarshall@users.sourceforge.net> | |
8 | + * Copyright (C) 2009, 2010, 2011, 2012, MinGW.org Project | |
9 | + * | |
10 | + * | |
11 | + * Public declaration of the download metering class, and support | |
12 | + * functions provided by the internet download agent. | |
13 | + * | |
14 | + * | |
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. | |
20 | + * | |
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. | |
27 | + * | |
28 | + */ | |
29 | +#define PKGINET_H 1 | |
30 | + | |
31 | +class pkgDownloadMeter | |
32 | +{ | |
33 | + /* Abstract base class, from which facilities for monitoring the | |
34 | + * progress of file downloads may be derived. | |
35 | + */ | |
36 | + public: | |
37 | + /* Hooks for use in the implementation of the GUI download | |
38 | + * monitoring dialogue; in a CLI context, these effectively | |
39 | + * become no-ops. | |
40 | + */ | |
41 | + static pkgDownloadMeter *UseGUI(){ return primary; } | |
42 | + virtual void ResetGUI( const char *, unsigned long ){} | |
43 | + | |
44 | + /* The working method to refresh the download progress display; | |
45 | + * each derived class MUST furnish an implementation for this. | |
46 | + */ | |
47 | + virtual int Update( unsigned long ) = 0; | |
48 | + | |
49 | + protected: | |
50 | + /* Reference pointer to the primary instance of the download | |
51 | + * meter in the GUI; always set to NULL, in a CLI context. | |
52 | + */ | |
53 | + static pkgDownloadMeter *primary; | |
54 | + | |
55 | + /* Storage for the expected size of the active download... | |
56 | + */ | |
57 | + unsigned long content_length; | |
58 | + | |
59 | + /* ...and a method to format it for human readable display. | |
60 | + */ | |
61 | + int SizeFormat( char *, unsigned long ); | |
62 | +}; | |
63 | + | |
64 | +/* Entry point for the worker thread associated with the download | |
65 | + * monitoring dialogue, in the GUI context. | |
66 | + */ | |
67 | +EXTERN_C void pkgInvokeDownload( void * ); | |
68 | + | |
69 | +#endif /* PKGINET_H: $RCSfile$: end of file */ |
@@ -0,0 +1,161 @@ | ||
1 | +/* | |
2 | + * pkgnget.cpp | |
3 | + * | |
4 | + * $Id$ | |
5 | + * | |
6 | + * Written by Keith Marshall <keithmarshall@users.sourceforge.net> | |
7 | + * Copyright (C) 2012, MinGW.org Project | |
8 | + * | |
9 | + * | |
10 | + * Implementation of the network download agent interface, through | |
11 | + * which the mingw-get GUI requests the services of the mingw-get DLL | |
12 | + * to get (download) package archives from internet repositories. | |
13 | + * | |
14 | + * | |
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. | |
20 | + * | |
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. | |
27 | + * | |
28 | + */ | |
29 | +#include "guimain.h" | |
30 | +#include "pkgbase.h" | |
31 | +#include "pkginet.h" | |
32 | + | |
33 | +class pkgDownloadMeterGUI: public pkgDownloadMeter | |
34 | +{ | |
35 | + /* A locally defined class, through which the download agent | |
36 | + * may transmit progress monitoring data to the designated GUI | |
37 | + * download monitoring dialogue box. | |
38 | + */ | |
39 | + public: | |
40 | + pkgDownloadMeterGUI( HWND ); | |
41 | + | |
42 | + virtual void ResetGUI( const char *, unsigned long ); | |
43 | + virtual int Update( unsigned long ); | |
44 | + | |
45 | + inline ~pkgDownloadMeterGUI(); | |
46 | + | |
47 | + private: | |
48 | + HWND file_name, file_size, copy_size, copy_frac, progress_bar; | |
49 | +}; | |
50 | + | |
51 | +/* Constructor... | |
52 | + */ | |
53 | +pkgDownloadMeterGUI::pkgDownloadMeterGUI( HWND dialogue ) | |
54 | +{ | |
55 | + /* Establish the global reference, through which the download | |
56 | + * agent will obtain access to the GUI dialogue... | |
57 | + */ | |
58 | + primary = this; | |
59 | + | |
60 | + /* ...and store references to its data controls. | |
61 | + */ | |
62 | + file_name = GetDlgItem( dialogue, IDD_PROGRESS_MSG ); | |
63 | + file_size = GetDlgItem( dialogue, IDD_PROGRESS_MAX ); | |
64 | + copy_size = GetDlgItem( dialogue, IDD_PROGRESS_VAL ); | |
65 | + copy_frac = GetDlgItem( dialogue, IDD_PROGRESS_PCT ); | |
66 | + progress_bar = GetDlgItem( dialogue, IDD_PROGRESS_BAR ); | |
67 | +} | |
68 | + | |
69 | +void pkgDownloadMeterGUI::ResetGUI( const char *filename, unsigned long size ) | |
70 | +{ | |
71 | + /* Method to reset the displayed content of the dialogue box to | |
72 | + * an appropriate initial state, in preparation for monitoring the | |
73 | + * download of a new archive file; the name of this file, and its | |
74 | + * anticipated size are preset, as specified by the arguments. | |
75 | + */ | |
76 | + char size_buf[12]; SizeFormat( size_buf, 0 ); | |
77 | + SendMessage( file_name, WM_SETTEXT, 0, (LPARAM)(filename) ); | |
78 | + SendMessage( copy_size, WM_SETTEXT, 0, (LPARAM)(size_buf) ); | |
79 | + SizeFormat( size_buf, content_length = size ); | |
80 | + SendMessage( file_size, WM_SETTEXT, 0, (LPARAM)(size_buf) ); | |
81 | + SendMessage( copy_frac, WM_SETTEXT, 0, (LPARAM)("0 %") ); | |
82 | + SendMessage( progress_bar, PBM_SETRANGE, 0, MAKELPARAM( 0, 100 ) ); | |
83 | + SendMessage( progress_bar, PBM_SETPOS, 0, 0 ); | |
84 | +} | |
85 | + | |
86 | +int pkgDownloadMeterGUI::Update( unsigned long count ) | |
87 | +{ | |
88 | + /* Method to update the download progress report; the download | |
89 | + * agent invokes this after each block of archive data has been | |
90 | + * received from the repository host, so that this method may | |
91 | + * refresh the progress counters in the dialogue box. | |
92 | + */ | |
93 | + char size_buf[12]; | |
94 | + | |
95 | + /* First, we update the display of the actual byte count... | |
96 | + */ | |
97 | + SizeFormat( size_buf, count ); | |
98 | + SendMessage( copy_size, WM_SETTEXT, 0, (LPARAM)(size_buf) ); | |
99 | + | |
100 | + /* ...then we convert that byte count to a percentage of | |
101 | + * the anticipated file size, using the result to update | |
102 | + * the percentage completed, and the progress bar. | |
103 | + */ | |
104 | + count = (count * 100) / content_length; | |
105 | + if( snprintf( size_buf, sizeof( size_buf ), "%d %", count ) >= sizeof( size_buf ) ) | |
106 | + strcpy( size_buf, "*** %" ); | |
107 | + SendMessage( copy_frac, WM_SETTEXT, 0, (LPARAM)(size_buf) ); | |
108 | + SendMessage( progress_bar, PBM_SETPOS, count, 0 ); | |
109 | +} | |
110 | + | |
111 | +/* Destructor... | |
112 | + */ | |
113 | +inline pkgDownloadMeterGUI::~pkgDownloadMeterGUI() | |
114 | +{ | |
115 | + /* This must reset the global reference pointer, so the download | |
116 | + * agent will not attempt to access a dialogue box which has been | |
117 | + * closed by the GUI application. | |
118 | + */ | |
119 | + primary = NULL; | |
120 | +} | |
121 | + | |
122 | +inline void pkgActionItem::DownloadArchiveFiles( void ) | |
123 | +{ | |
124 | + /* Helper method, invoked by the GUI application, to initiate | |
125 | + * an in-order traversal of the schedule of actions... | |
126 | + */ | |
127 | + pkgActionItem *current; | |
128 | + if( (current = this) != NULL ) | |
129 | + { | |
130 | + /* ...ensuring that the traversal commences at the first of | |
131 | + * the scheduled actions... | |
132 | + */ | |
133 | + while( current->prev != NULL ) current = current->prev; | |
134 | + | |
135 | + /* ...to download all requisite archive files. | |
136 | + */ | |
137 | + DownloadArchiveFiles( current ); | |
138 | + } | |
139 | +} | |
140 | + | |
141 | +inline void AppWindowMaker::DownloadArchiveFiles( void ) | |
142 | +{ | |
143 | + /* Helper method to redirect a request to initiate package | |
144 | + * download, from the controlling application window object | |
145 | + * to its associated schedule of actions object. | |
146 | + */ | |
147 | + pkgData->Schedule()->DownloadArchiveFiles(); | |
148 | +} | |
149 | + | |
150 | +EXTERN_C void pkgInvokeDownload( void *window ) | |
151 | +{ | |
152 | + /* Worker thread procedure, invoked by the OnCommand() method | |
153 | + * of the application window object, when initiating the archive | |
154 | + * download process via the appropriate monitoring dialogue. | |
155 | + */ | |
156 | + pkgDownloadMeterGUI metered( (HWND)(window) ); | |
157 | + GetAppWindow( GetParent( (HWND)(window) ))->DownloadArchiveFiles(); | |
158 | + SendMessage( (HWND)(window), WM_COMMAND, (WPARAM)(IDOK), 0 ); | |
159 | +} | |
160 | + | |
161 | +/* $RCSfile$: end of file */ |