The MinGW.OSDN Installation Manager Tool
Revision | f3bf16655b788f987b6ad638a5fc64ee58b5dbcf (tree) |
---|---|
Zeit | 2012-12-19 20:03:06 |
Autor | Keith Marshall <keithmarshall@user...> |
Commiter | Keith Marshall |
Improve progress reporting in "Apply Changes" dialogue.
@@ -1,3 +1,30 @@ | ||
1 | +2012-12-19 Keith Marshall <keithmarshall@users.sourceforge.net> | |
2 | + | |
3 | + Improve progress reporting in "Apply Changes" dialogue. | |
4 | + | |
5 | + * src/pkgstat.h: New header file; it declares... | |
6 | + (pkgSpinWait): ...this new pure abstract base class; it specifies an | |
7 | + infrastructure for posting arbitrary text to dialogue controls. | |
8 | + | |
9 | + * src/pkgexec.cpp (pkgSpinWait): Implement its static elements. | |
10 | + (pkgActionItem::Execute): Dispatch progress reports, handled by... | |
11 | + (pkgSpinWait::Report, pkgSpinWait::Indicator): ...these. | |
12 | + | |
13 | + * src/guixmld.cpp (pkgDialogueSpinWait): New class; declare it and | |
14 | + implement locally. It is derived from, and provides a listener for... | |
15 | + (pkgSpinWait): ...this abstract class. | |
16 | + (pkgApplyChanges): Use it. | |
17 | + | |
18 | + * src/tarproc.cpp (pkgTarArchiveInstaller::ProcessDataStream): Call... | |
19 | + (pkgSpinWait::Report): ...this, to report extracted files. | |
20 | + | |
21 | + * src/pkgunst.cpp (pkg_unst): Call... | |
22 | + (pkgSpinWait::Report): ...this, to report deleted files. | |
23 | + | |
24 | + * src/sysroot.cpp (pkgXmlDocument::UpdateSystemMap): Call... | |
25 | + (pkgSpinWait::Report, pkgSpinWait::Indicator): ...these, to confirm | |
26 | + continuing database update activity. | |
27 | + | |
1 | 28 | 2012-12-18 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 29 | |
3 | 30 | Update tab display on right-click in package list view. |
@@ -29,6 +29,7 @@ | ||
29 | 29 | #include "pkginet.h" |
30 | 30 | #include "pkgkeys.h" |
31 | 31 | #include "pkglist.h" |
32 | +#include "pkgstat.h" | |
32 | 33 | #include "pkgtask.h" |
33 | 34 | |
34 | 35 | #include <unistd.h> |
@@ -304,13 +305,43 @@ inline void AppWindowMaker::ExecuteScheduledActions( void ) | ||
304 | 305 | pkgData->UpdateSystemMap(); |
305 | 306 | } |
306 | 307 | |
308 | +class pkgDialogueSpinWait: public pkgSpinWait | |
309 | +{ | |
310 | + /* Derivative class for redirection of pkgSpinWait::Report() | |
311 | + * messages to a specified dialogue box text control. | |
312 | + */ | |
313 | + public: | |
314 | + pkgDialogueSpinWait( HWND msg ): dlg( msg ){} | |
315 | + | |
316 | + private: | |
317 | + virtual int DispatchReport( const char *, va_list ); | |
318 | + HWND dlg; | |
319 | +}; | |
320 | + | |
321 | +int pkgDialogueSpinWait::DispatchReport( const char *fmt, va_list argv ) | |
322 | +{ | |
323 | + /* Method to handle pkgSpinWait::Report() message redirection. | |
324 | + */ | |
325 | + char buf[ 1 + vsnprintf( NULL, 0, fmt, argv ) ]; | |
326 | + int count = vsnprintf( buf, sizeof( buf ), fmt, argv ); | |
327 | + SendMessage( dlg, WM_SETTEXT, 0, (LPARAM)(buf) ); | |
328 | + return count; | |
329 | +} | |
330 | + | |
307 | 331 | static void pkgApplyChanges( void *window ) |
308 | 332 | { |
309 | 333 | /* Worker thread processing function, run while displaying the |
310 | 334 | * IDD_APPLY_EXECUTE dialogue box, to apply scheduled changes. |
311 | 335 | */ |
336 | + HWND msg = GetDlgItem( (HWND)(window), IDD_PROGRESS_MSG ); | |
337 | + AppWindowMaker *app = GetAppWindow( GetParent( (HWND)(window) ) ); | |
338 | + | |
339 | + /* Set up progess reporting and diagnostic message display | |
340 | + * channels, and execute the scheduled actions. | |
341 | + */ | |
342 | + pkgDialogueSpinWait stat( msg ); | |
312 | 343 | dmh_setpty( GetDlgItem( (HWND)(window), IDD_DMH_CONSOLE ) ); |
313 | - GetAppWindow( GetParent( (HWND)(window) ))->ExecuteScheduledActions(); | |
344 | + app->ExecuteScheduledActions(); | |
314 | 345 | dmh_setpty( NULL ); |
315 | 346 | |
316 | 347 | /* During processing, the user may have selected the option for |
@@ -334,10 +365,9 @@ static void pkgApplyChanges( void *window ) | ||
334 | 365 | |
335 | 366 | /* ...and notify the user that it must be clicked to continue. |
336 | 367 | */ |
337 | - if( (dlg = GetDlgItem( (HWND)(window), IDD_PROGRESS_MSG )) != NULL ) | |
338 | - SendMessage( dlg, WM_SETTEXT, 0, | |
339 | - (LPARAM)("All changes have been successfully applied; you may close this dialogue.") | |
340 | - ); | |
368 | + stat.Report( "All changes have been successfully applied;" | |
369 | + " you may now close this dialogue." | |
370 | + ); | |
341 | 371 | } |
342 | 372 | } |
343 | 373 |
@@ -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 package management task scheduler and executive. |
@@ -31,9 +31,45 @@ | ||
31 | 31 | #include "pkgkeys.h" |
32 | 32 | #include "pkginfo.h" |
33 | 33 | #include "pkgtask.h" |
34 | +#include "pkgstat.h" | |
34 | 35 | #include "pkgopts.h" |
35 | 36 | #include "pkgproc.h" |
36 | 37 | |
38 | +/* The following static member of the pkgSpinWait class provides | |
39 | + * the access hook through which the static core implementation of | |
40 | + * the base class methods may pass reports back to any derivative | |
41 | + * class object, while retaining the capability to issue reports | |
42 | + * even when no such object exists. | |
43 | + */ | |
44 | +pkgSpinWait *pkgSpinWait::referrer = NULL; | |
45 | + | |
46 | +int pkgSpinWait::Report( const char *fmt, ... ) | |
47 | +{ | |
48 | + /* Also declared as static, this directs printf() style reports | |
49 | + * to any existing derivative class object, while behaving as a | |
50 | + * no-op in the absence of any such object. | |
51 | + */ | |
52 | + int count = 0; | |
53 | + if( referrer != NULL ) | |
54 | + { | |
55 | + va_list argv; | |
56 | + va_start( argv, fmt ); | |
57 | + count = referrer->DispatchReport( fmt, argv ); | |
58 | + va_end( argv ); | |
59 | + } | |
60 | + return count; | |
61 | +} | |
62 | + | |
63 | +int pkgSpinWait::Indicator( void ) | |
64 | +{ | |
65 | + /* Once again, declared as static, this method provides a | |
66 | + * mechanism for spin-wait animation of any "%c" formatted | |
67 | + * field within a progress reporting message. | |
68 | + */ | |
69 | + static const char *marker = "|/-\\"; | |
70 | + return marker[ referrer->UpdateIndex() ]; | |
71 | +} | |
72 | + | |
37 | 73 | EXTERN_C const char *action_name( unsigned long index ) |
38 | 74 | { |
39 | 75 | /* Define the keywords used on the mingw-get command line, |
@@ -432,8 +468,7 @@ int reinstall_action_scheduled( pkgActionItem *package ) | ||
432 | 468 | void pkgActionItem::Execute( bool with_download ) |
433 | 469 | { |
434 | 470 | if( this != NULL ) |
435 | - { | |
436 | - pkgActionItem *current = this; | |
471 | + { pkgActionItem *current = this; | |
437 | 472 | bool init_rites_pending = true; |
438 | 473 | while( current->prev != NULL ) current = current->prev; |
439 | 474 |
@@ -570,6 +605,7 @@ void pkgActionItem::Execute( bool with_download ) | ||
570 | 605 | } |
571 | 606 | /* Proceed to the next package, if any, with scheduled actions. |
572 | 607 | */ |
608 | + pkgSpinWait::Report( "Processing... (%c)", pkgSpinWait::Indicator() ); | |
573 | 609 | current = current->next; |
574 | 610 | } |
575 | 611 | } |
@@ -0,0 +1,55 @@ | ||
1 | +#ifndef PKGSTAT_H | |
2 | +/* | |
3 | + * pkgstat.h | |
4 | + * | |
5 | + * $Id$ | |
6 | + * | |
7 | + * Written by Keith Marshall <keithmarshall@users.sourceforge.net> | |
8 | + * Copyright (C) 2012, MinGW.org Project | |
9 | + * | |
10 | + * | |
11 | + * Public declaration of the pkgSpinWait class, which provides an | |
12 | + * infrastructure for reporting status of long-running activities. | |
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 PKGSTAT_H 1 | |
30 | + | |
31 | +# include <stdarg.h> | |
32 | + | |
33 | +class pkgSpinWait | |
34 | +{ | |
35 | + /* An abstract base class, providing a facility for passing | |
36 | + * progress messages from mingw-get worker thread processing | |
37 | + * functions, to the GUI's dialogue boxes; the dialogue box | |
38 | + * initialisation function must create a derivative of this | |
39 | + * object class, providing the DispatchReport() method, to | |
40 | + * update message text within the dialogue box, using a | |
41 | + * vprintf() style of message formatting. | |
42 | + */ | |
43 | + public: | |
44 | + static int Report( const char *, ... ); | |
45 | + static int Indicator( void ); | |
46 | + | |
47 | + protected: | |
48 | + static pkgSpinWait *referrer; int index; | |
49 | + pkgSpinWait( void ): index( 0 ){ referrer = this; } | |
50 | + int UpdateIndex(){ return this ? index = (1 + index) % 4 : 0; } | |
51 | + virtual int DispatchReport( const char *, va_list ) = 0; | |
52 | + ~pkgSpinWait(){ referrer = NULL; } | |
53 | +}; | |
54 | + | |
55 | +#endif /* PKGSTAT_H: $RCSfile$: end of file */ |
@@ -4,7 +4,7 @@ | ||
4 | 4 | * $Id$ |
5 | 5 | * |
6 | 6 | * Written by Keith Marshall <keithmarshall@users.sourceforge.net> |
7 | - * Copyright (C) 2011, 2012, MinGW Project | |
7 | + * Copyright (C) 2011, 2012, MinGW.org Project | |
8 | 8 | * |
9 | 9 | * |
10 | 10 | * Implementation of the primary package removal methods. |
@@ -37,6 +37,7 @@ | ||
37 | 37 | #include "pkgkeys.h" |
38 | 38 | #include "pkgproc.h" |
39 | 39 | #include "pkgtask.h" |
40 | +#include "pkgstat.h" | |
40 | 41 | |
41 | 42 | #include "mkpath.h" |
42 | 43 |
@@ -286,6 +287,7 @@ int pkg_unlink( const char *sysroot, const char *pathname ) | ||
286 | 287 | char filepath[ mkpath( NULL, sysroot, pathname, NULL ) ]; |
287 | 288 | mkpath( filepath, sysroot, pathname, NULL ); |
288 | 289 | |
290 | + pkgSpinWait::Report( "Deleting %s", pathname ); | |
289 | 291 | DEBUG_INVOKE_IF( DEBUG_REQUEST( DEBUG_TRACE_TRANSACTIONS ), |
290 | 292 | dmh_printf( " %s: unlink file\n", filepath ) |
291 | 293 | ); |
@@ -4,7 +4,7 @@ | ||
4 | 4 | * $Id$ |
5 | 5 | * |
6 | 6 | * Written by Keith Marshall <keithmarshall@users.sourceforge.net> |
7 | - * Copyright (C) 2010, 2011, 2012, MinGW Project | |
7 | + * Copyright (C) 2010, 2011, 2012, MinGW.org Project | |
8 | 8 | * |
9 | 9 | * |
10 | 10 | * Implementation of the system map loader, sysroot management and |
@@ -42,6 +42,7 @@ | ||
42 | 42 | #include "mkpath.h" |
43 | 43 | |
44 | 44 | #include "pkgbase.h" |
45 | +#include "pkgstat.h" | |
45 | 46 | #include "pkgkeys.h" |
46 | 47 | |
47 | 48 | #include "debug.h" |
@@ -425,7 +426,9 @@ void pkgXmlDocument::UpdateSystemMap() | ||
425 | 426 | pkgXmlNode *entry = GetRoot()->FindFirstAssociate( sysroot_key ); |
426 | 427 | |
427 | 428 | while( entry != NULL ) |
428 | - { | |
429 | + { pkgSpinWait::Report( "Updating system map... (%c)", | |
430 | + pkgSpinWait::Indicator() | |
431 | + ); | |
429 | 432 | /* We found a sysroot record... |
430 | 433 | * evaluate and clear its 'modified' attribute... |
431 | 434 | */ |
@@ -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, MinGW Project | |
7 | + * Copyright (C) 2009, 2010, 2011, 2012, MinGW.org Project | |
8 | 8 | * |
9 | 9 | * |
10 | 10 | * Implementation of package archive processing methods, for reading |
@@ -43,6 +43,7 @@ | ||
43 | 43 | #include "pkginfo.h" |
44 | 44 | #include "pkgkeys.h" |
45 | 45 | #include "pkgproc.h" |
46 | +#include "pkgstat.h" | |
46 | 47 | |
47 | 48 | /******************* |
48 | 49 | * |
@@ -664,6 +665,7 @@ int pkgTarArchiveInstaller::ProcessDataStream( const char *pathname ) | ||
664 | 665 | /* Extract file data from the archive, and copy it to the |
665 | 666 | * associated target file stream, if any. |
666 | 667 | */ |
668 | + pkgSpinWait::Report( "Extracting %s", pathname + sysroot_len ); | |
667 | 669 | if( DEBUG_REQUEST( DEBUG_SUPPRESS_INSTALLATION ) ) |
668 | 670 | { |
669 | 671 | /* Debugging stub... |