• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

The MinGW.OSDN Installation Manager Tool


Commit MetaInfo

Revisionf3bf16655b788f987b6ad638a5fc64ee58b5dbcf (tree)
Zeit2012-12-19 20:03:06
AutorKeith Marshall <keithmarshall@user...>
CommiterKeith Marshall

Log Message

Improve progress reporting in "Apply Changes" dialogue.

Ändern Zusammenfassung

Diff

--- a/ChangeLog
+++ b/ChangeLog
@@ -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+
128 2012-12-18 Keith Marshall <keithmarshall@users.sourceforge.net>
229
330 Update tab display on right-click in package list view.
--- a/src/guixmld.cpp
+++ b/src/guixmld.cpp
@@ -29,6 +29,7 @@
2929 #include "pkginet.h"
3030 #include "pkgkeys.h"
3131 #include "pkglist.h"
32+#include "pkgstat.h"
3233 #include "pkgtask.h"
3334
3435 #include <unistd.h>
@@ -304,13 +305,43 @@ inline void AppWindowMaker::ExecuteScheduledActions( void )
304305 pkgData->UpdateSystemMap();
305306 }
306307
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+
307331 static void pkgApplyChanges( void *window )
308332 {
309333 /* Worker thread processing function, run while displaying the
310334 * IDD_APPLY_EXECUTE dialogue box, to apply scheduled changes.
311335 */
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 );
312343 dmh_setpty( GetDlgItem( (HWND)(window), IDD_DMH_CONSOLE ) );
313- GetAppWindow( GetParent( (HWND)(window) ))->ExecuteScheduledActions();
344+ app->ExecuteScheduledActions();
314345 dmh_setpty( NULL );
315346
316347 /* During processing, the user may have selected the option for
@@ -334,10 +365,9 @@ static void pkgApplyChanges( void *window )
334365
335366 /* ...and notify the user that it must be clicked to continue.
336367 */
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+ );
341371 }
342372 }
343373
--- a/src/pkgexec.cpp
+++ b/src/pkgexec.cpp
@@ -4,7 +4,7 @@
44 * $Id$
55 *
66 * 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
88 *
99 *
1010 * Implementation of package management task scheduler and executive.
@@ -31,9 +31,45 @@
3131 #include "pkgkeys.h"
3232 #include "pkginfo.h"
3333 #include "pkgtask.h"
34+#include "pkgstat.h"
3435 #include "pkgopts.h"
3536 #include "pkgproc.h"
3637
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+
3773 EXTERN_C const char *action_name( unsigned long index )
3874 {
3975 /* Define the keywords used on the mingw-get command line,
@@ -432,8 +468,7 @@ int reinstall_action_scheduled( pkgActionItem *package )
432468 void pkgActionItem::Execute( bool with_download )
433469 {
434470 if( this != NULL )
435- {
436- pkgActionItem *current = this;
471+ { pkgActionItem *current = this;
437472 bool init_rites_pending = true;
438473 while( current->prev != NULL ) current = current->prev;
439474
@@ -570,6 +605,7 @@ void pkgActionItem::Execute( bool with_download )
570605 }
571606 /* Proceed to the next package, if any, with scheduled actions.
572607 */
608+ pkgSpinWait::Report( "Processing... (%c)", pkgSpinWait::Indicator() );
573609 current = current->next;
574610 }
575611 }
--- /dev/null
+++ b/src/pkgstat.h
@@ -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 */
--- a/src/pkgunst.cpp
+++ b/src/pkgunst.cpp
@@ -4,7 +4,7 @@
44 * $Id$
55 *
66 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
7- * Copyright (C) 2011, 2012, MinGW Project
7+ * Copyright (C) 2011, 2012, MinGW.org Project
88 *
99 *
1010 * Implementation of the primary package removal methods.
@@ -37,6 +37,7 @@
3737 #include "pkgkeys.h"
3838 #include "pkgproc.h"
3939 #include "pkgtask.h"
40+#include "pkgstat.h"
4041
4142 #include "mkpath.h"
4243
@@ -286,6 +287,7 @@ int pkg_unlink( const char *sysroot, const char *pathname )
286287 char filepath[ mkpath( NULL, sysroot, pathname, NULL ) ];
287288 mkpath( filepath, sysroot, pathname, NULL );
288289
290+ pkgSpinWait::Report( "Deleting %s", pathname );
289291 DEBUG_INVOKE_IF( DEBUG_REQUEST( DEBUG_TRACE_TRANSACTIONS ),
290292 dmh_printf( " %s: unlink file\n", filepath )
291293 );
--- a/src/sysroot.cpp
+++ b/src/sysroot.cpp
@@ -4,7 +4,7 @@
44 * $Id$
55 *
66 * 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
88 *
99 *
1010 * Implementation of the system map loader, sysroot management and
@@ -42,6 +42,7 @@
4242 #include "mkpath.h"
4343
4444 #include "pkgbase.h"
45+#include "pkgstat.h"
4546 #include "pkgkeys.h"
4647
4748 #include "debug.h"
@@ -425,7 +426,9 @@ void pkgXmlDocument::UpdateSystemMap()
425426 pkgXmlNode *entry = GetRoot()->FindFirstAssociate( sysroot_key );
426427
427428 while( entry != NULL )
428- {
429+ { pkgSpinWait::Report( "Updating system map... (%c)",
430+ pkgSpinWait::Indicator()
431+ );
429432 /* We found a sysroot record...
430433 * evaluate and clear its 'modified' attribute...
431434 */
--- a/src/tarproc.cpp
+++ b/src/tarproc.cpp
@@ -4,7 +4,7 @@
44 * $Id$
55 *
66 * 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
88 *
99 *
1010 * Implementation of package archive processing methods, for reading
@@ -43,6 +43,7 @@
4343 #include "pkginfo.h"
4444 #include "pkgkeys.h"
4545 #include "pkgproc.h"
46+#include "pkgstat.h"
4647
4748 /*******************
4849 *
@@ -664,6 +665,7 @@ int pkgTarArchiveInstaller::ProcessDataStream( const char *pathname )
664665 /* Extract file data from the archive, and copy it to the
665666 * associated target file stream, if any.
666667 */
668+ pkgSpinWait::Report( "Extracting %s", pathname + sysroot_len );
667669 if( DEBUG_REQUEST( DEBUG_SUPPRESS_INSTALLATION ) )
668670 {
669671 /* Debugging stub...