OSDN Git Service

Implement GUI bindings for processing a schedule of actions.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Tue, 11 Dec 2012 23:03:44 +0000 (23:03 +0000)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Tue, 11 Dec 2012 23:03:44 +0000 (23:03 +0000)
ChangeLog
src/guidata.rc
src/guimain.h
src/guixmld.cpp
src/pkgbase.h
src/pkgexec.cpp

index def75ce..c2182e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
 2012-12-11  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
+       Implement GUI bindings for processing a schedule of actions.
+
+       * src/guimain.h (IDD_DMH_CONSOLE): New resource ID; define it.
+       (IDD_APPLY_EXECUTE): New dialogue template resource ID; define it.
+       (AppWindowMaker::ExecuteScheduledActions): New method; declare it.
+
+       * src/guidata.rc (IDD_APPLY_EXECUTE): Implement dialogue template.
+
+       * src/guixmld.cpp (pkgApplyChanges): New thread function; implement it.
+       (AppWindowMaker::OnCommand) [IDD_REPO_APPLY]: Use it; it is invoked...
+       (IDD_APPLY_EXECUTE): ...via this dialogue box, subsequently calling...
+       (AppWindowMaker::ExecuteScheduledActions): ...this; implement it.
+
+       * src/pkgexec.cpp (pkgActionItem::Execute): Add argument; use it.
+       (pkgActionItem::~pkgActionItem): Unlink chained references.
+
+       * src/pkgbase.h (pkgActionItem::Execute): Adjust prototype.
+
+2012-12-11  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
        Do not preserve unnecessary download requests.
 
        * src/pkginet.cpp (pkgActionItem::DownloadArchiveFiles):
index 5956998..00a1e36 100644 (file)
@@ -173,7 +173,7 @@ BEGIN
   EDITTEXT                             IDD_APPLY_INSTALLS_PACKAGES, 7, 148, 292, 36, WS_VSCROLL | ES_VT100
 END
 
-/* Template for GUI styled package download monitoring dialogue box.
+/* Template for GUI styled package download monitoring dialogue box.
  */
 IDD_APPLY_DOWNLOAD DIALOG DISCARDABLE  10, 20, 280, 52
 CAPTION                                        "Download Package"
@@ -190,4 +190,17 @@ BEGIN
                                        | PBS_SMOOTH, 6, 35, 268, 10
 END
 
+IDD_APPLY_EXECUTE DIALOG DISCARDABLE   10, 10, 306, 193
+CAPTION                                        "Applying Scheduled Changes"
+STYLE                                  DS_MODALFRAME | DS_SETFONT | WS_POPUP | WS_CAPTION | WS_DLGFRAME
+FONT                                   10, "Verdana"
+BEGIN
+  LTEXT                                "", IDD_PROGRESS_MSG, 7, 6, 294, 10
+  AUTOCHECKBOX                         "Close dialogue automatically, when activity is complete.", \
+                                       IDD_AUTO_CLOSE_OPTION, 8, 19, 240, 11
+  DEFPUSHBUTTON                        "Close", IDOK, 258, 18, 40, 12, WS_GROUP | WS_DISABLED
+  GROUPBOX                             "Details", IDD_PROGRESS_TXT, 6, 35, 294, 152
+  EDITTEXT                             IDD_DMH_CONSOLE, 7, 45, 292, 141, WS_BORDER | WS_VSCROLL | ES_VT100
+END
+
 /* $RCSfile$: end of file */
index f326a14..44301c7 100644 (file)
@@ -93,6 +93,7 @@
 
 #define IDD_APPLY_APPROVE               630
 #define IDD_APPLY_DOWNLOAD              631
+#define IDD_APPLY_EXECUTE               632
 
 #define IDD_APPLY_REMOVES_PACKAGES      633
 #define IDD_APPLY_REMOVES_SUMMARY       634
 #define IDD_APPLY_INSTALLS_PACKAGES     637
 #define IDD_APPLY_INSTALLS_SUMMARY      638
 
+#define IDD_DMH_CONSOLE                 650
+
 #define ID_PKGLIST_TABLE_HEADINGS      1024
 #define ID_PKGNAME_COLUMN_HEADING      1025
 #define ID_PKGTYPE_COLUMN_HEADING      1026
@@ -178,6 +181,7 @@ class AppWindowMaker: public WTK::MainWindowMaker
 
     inline unsigned long EnumerateActions( int = 0 );
     inline void DownloadArchiveFiles( void );
+    inline void ExecuteScheduledActions( void );
 
   private:
     virtual long OnCreate();
index 9c3a7df..ce1130b 100644 (file)
@@ -295,6 +295,52 @@ static void pkgInvokeUpdate( void *window )
   }
 }
 
+inline void AppWindowMaker::ExecuteScheduledActions( void )
+{
+  /* Helper method to delegate execution of a schedule of actions from
+   * the application window to its associated action item controller.
+   */
+  pkgData->Schedule()->Execute( false );
+  pkgData->UpdateSystemMap();
+}
+
+static void pkgApplyChanges( void *window )
+{
+  /* Worker thread processing function, run while displaying the
+   * IDD_APPLY_EXECUTE dialogue box, to apply scheduled changes.
+   */
+  dmh_setpty( GetDlgItem( (HWND)(window), IDD_DMH_CONSOLE ) );
+  GetAppWindow( GetParent( (HWND)(window) ))->ExecuteScheduledActions();
+  dmh_setpty( NULL );
+
+  /* During processing, the user may have selected the option for
+   * automatic dismissal of the dialogue box on completion...
+   *
+   * FIXME: We need to adapt this, so that auto-close is ignored
+   * when any scheduled action fails to complete successfully.
+   */
+  if( IsDlgButtonChecked( (HWND)(window), IDD_AUTO_CLOSE_OPTION ) )
+    /*
+     * ...in which case, we dismiss it without further ado...
+     */
+    SendMessage( (HWND)(window), WM_COMMAND, (WPARAM)(IDOK), 0 );
+
+  else
+  { /* ...otherwise, we activate the manual dismissal button...
+     */
+    HWND dlg;
+    if( (dlg = GetDlgItem( (HWND)(window), IDOK )) != NULL )
+      EnableWindow( dlg, TRUE );
+
+    /* ...and notify the user that it must be clicked to continue.
+     */
+    if( (dlg = GetDlgItem( (HWND)(window), IDD_PROGRESS_MSG )) != NULL )
+      SendMessage( dlg, WM_SETTEXT, 0,
+         (LPARAM)("All changes have been successfully applied; you may close this dialogue.")
+       );
+  }
+}
+
 static int CALLBACK pkgDialogue
 ( HWND window, unsigned int msg, WPARAM wParam, LPARAM lParam )
 {
@@ -353,8 +399,9 @@ inline unsigned long AppWindowMaker::EnumerateActions( int classified )
   return pkgData->Schedule()->EnumeratePendingActions( classified );
 }
 
-pkgActionItem *pkgActionItem::Clear( pkgActionItem *schedule, unsigned long mask )
-# define ACTION_PRESERVE_FAILED  (ACTION_DOWNLOAD_FAILED | ACTION_APPLY_FAILED)
+pkgActionItem
+*pkgActionItem::Clear( pkgActionItem *schedule, unsigned long mask )
+#define ACTION_PRESERVE_FAILED (ACTION_DOWNLOAD_FAILED | ACTION_APPLY_FAILED)
 {
   /* Method to remove those action items which have no attribute flags in common
    * with the specified mask, from the schedule; return the residual schedule of
@@ -621,12 +668,9 @@ long AppWindowMaker::OnCommand( WPARAM cmd )
          /* When "Apply" confirmation is forthcoming, we proceed to
           * download any required packages, and invoke the scheduled
           * remove, upgrade, or install actions.
-          *
-          * FIXME: the pkgInvokeDownload() thread handler has yet to
-          * be implemented.
           */
          DispatchDialogueThread( IDD_APPLY_DOWNLOAD, pkgInvokeDownload );
-//       DispatchDialogueThread( IDD_APPLY_MONITORED, pkgApplyChanges );
+         DispatchDialogueThread( IDD_APPLY_EXECUTE, pkgApplyChanges );
 
          /* After applying changes, we fall through...
           */
index 7d2618c..d8eae27 100644 (file)
@@ -338,7 +338,7 @@ class pkgActionItem
 
     /* Methods for processing all scheduled actions.
      */
-    void Execute();
+    void Execute( bool = true );
     inline void DownloadArchiveFiles( void );
 
     /* Method to manipulate error trapping, control, and state
index b1d0bf2..c32d5f8 100644 (file)
@@ -429,7 +429,7 @@ int reinstall_action_scheduled( pkgActionItem *package )
     );
 }
 
-void pkgActionItem::Execute()
+void pkgActionItem::Execute( bool with_download )
 {
   if( this != NULL )
   {
@@ -447,7 +447,8 @@ void pkgActionItem::Execute()
            * be necessary to fetch all required archives into
            * the local package cache.
            */
-          DownloadArchiveFiles( current );
+          if( with_download )
+            DownloadArchiveFiles( current );
         } while( SetAuthorities( current ) > 0 );
 
     else while( current != NULL )
@@ -597,6 +598,13 @@ pkgActionItem::~pkgActionItem()
      * the same memory referenced by "max_wanted".
      */
     free( (void *)(min_wanted) );
+
+  /* Also ensure that we preserve the integrity of any linked list of
+   * action items in which this item participates, by detaching this
+   * item from the pointer chain.
+   */
+  if( prev != NULL ) prev->next = next;
+  if( next != NULL ) next->prev = prev;
 }
 
 /*