OSDN Git Service

Refactor API to facilitate implementation of GUI ListView hooks.
[mingw/mingw-get.git] / src / pkgbase.h
index 900c95e..833a9cc 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2009, 2010, MinGW Project
+ * Copyright (C) 2009, 2010, 2011, 2012, MinGW Project
  *
  *
  * Public interface for the package directory management routines;
 # endif
 #endif
 
+/* Define an API for registering environment variables.
+ */
+EXTERN_C int pkgPutEnv( int, char* );
+
+#define PKG_PUTENV_DIRSEP_MSW          (0x01)
+#define PKG_PUTENV_DIRSEP_POSIX        (0x02)
+#define PKG_PUTENV_SCAN_VARNAME        (0x04)
+#define PKG_PUTENV_NAME_TOUPPER        (0x08)
+
+#define PKG_PUTENV_FLAGS_MASK          (0x0F)
+
+/* Begin class declarations.
+ */
 class pkgSpecs;
+class pkgDirectory;
 
 class pkgXmlNode : public TiXmlElement
 {
@@ -166,15 +180,15 @@ class pkgXmlNode : public TiXmlElement
     /* Methods for retrieving the system root management records
      * for a specified installed subsystem.
      */
-    pkgXmlNode *GetSysRoot( const char *subsystem );
+    pkgXmlNode *GetSysRoot( const char* );
     pkgXmlNode *GetInstallationRecord( const char* );
 
     /* The following pair of methods provide an iterator
      * for enumerating the contained nodes, within the owner,
      * which themselves exhibit a specified tagname.
      */
-    pkgXmlNode* FindFirstAssociate( const char* tagname );
-    pkgXmlNode* FindNextAssociate( const char* tagname );
+    pkgXmlNode* FindFirstAssociate( const char* );
+    pkgXmlNode* FindNextAssociate( const char* );
 
     /* Specific to XML node elements of type "release",
      * the following pair of methods retrieve the actual name of
@@ -182,7 +196,7 @@ class pkgXmlNode : public TiXmlElement
      * as they are named on the project download servers.
      */
     const char* ArchiveName();
-    const char* SourceArchiveName();
+    const char* SourceArchiveName( unsigned long );
 
     /* The following retrieves an attribute which may have been
      * specified on an ancestor (container) node; typically used to
@@ -190,6 +204,23 @@ class pkgXmlNode : public TiXmlElement
      * be associated with a release.
      */
     const char *GetContainerAttribute( const char*, const char* = NULL );
+
+    /* Any package may have associated scripts; the following
+     * method invokes them on demand.
+     */
+    inline int InvokeScript( const char *context )
+    {
+      /* The actual implementation is delegated to the following
+       * (private) overloaded method.
+       */
+      return InvokeScript( 0, context );
+    }
+
+  private:
+    /* Helpers used to implement the preceding InvokeScript() method.
+     */
+    int InvokeScript( int, const char* );
+    int DispatchScript( int, const char*, const char*, pkgXmlNode* );
 };
 
 enum { to_remove = 0, to_install, selection_types };
@@ -223,9 +254,14 @@ class pkgActionItem
      */
     pkgXmlNode* selection[ selection_types ];
 
-    /* Method for retrieving packages from a distribution server.
+    /* Method to display the URI whence a package may be downloaded.
+     */
+    void PrintURI( const char* );
+
+    /* Methods for retrieving packages from a distribution server.
      */
     void DownloadArchiveFiles( pkgActionItem* );
+    void DownloadSingleArchive( const char*, const char* );
 
   public:
     /* Constructor...
@@ -239,12 +275,19 @@ class pkgActionItem
 
     /* Methods for compiling the schedule of actions.
      */
+    unsigned long SetAuthorities( pkgActionItem* );
+    inline unsigned long HasAttribute( unsigned long required )
+    {
+      return flags & required;
+    }
     pkgActionItem* GetReference( pkgActionItem& );
     pkgActionItem* Schedule( unsigned long, pkgActionItem& );
+    inline void SetPrimary( pkgActionItem* );
 
     /* Methods for defining the selection criteria for
      * packages to be processed.
      */
+    void ApplyBounds( pkgXmlNode *, const char * );
     pkgXmlNode* SelectIfMostRecentFit( pkgXmlNode* );
     const char* SetRequirements( pkgXmlNode*, pkgSpecs* );
     inline void SelectPackage( pkgXmlNode *pkg, int opt = to_install )
@@ -259,6 +302,12 @@ class pkgActionItem
        */
       return selection[ mode ];
     }
+    void ConfirmInstallationStatus();
+
+    /* Methods to download and unpack one or more source archives.
+     */
+    void GetSourceArchive( pkgXmlNode*, unsigned long );
+    void GetScheduledSourceArchives( unsigned long );
 
     /* Method for processing all scheduled actions.
      */
@@ -340,6 +389,12 @@ class pkgXmlDocument : public TiXmlDocument
     pkgActionItem* actions;
 
   public:
+    /* Method to interpret user preferences for mingw-get processing
+     * options, which are specified within profile.xml rather than on
+     * the command line.
+     */
+    void EstablishPreferences();
+
     /* Method to synchronise the state of the local package manifest
      * with the master copy held on the distribution server.
      */
@@ -364,6 +419,11 @@ class pkgXmlDocument : public TiXmlDocument
      */
     pkgXmlNode* FindPackageByName( const char*, const char* = NULL );
 
+    /* Methods to retrieve and display information about packages.
+     */
+    pkgDirectory *CatalogueAllPackages();
+    void DisplayPackageInfo( int, char** );
+
     /* Method to resolve the dependencies of a specified package,
      * by walking the chain of references specified by "requires"
      * elements in the respective package database entries.
@@ -374,10 +434,20 @@ class pkgXmlDocument : public TiXmlDocument
      */
     void Schedule( unsigned long, const char* );
     pkgActionItem* Schedule( unsigned long, pkgActionItem&, pkgActionItem* = NULL );
+    void RescheduleInstalledPackages( unsigned long );
 
     /* Method to execute a sequence of scheduled actions.
      */
     inline void ExecuteActions(){ actions->Execute(); }
+
+    /* Methods to retrieve and optionally extract source archives
+     * for a collection of dependent packages.
+     */
+    void GetSourceArchive( const char*, unsigned long );
+    inline void GetScheduledSourceArchives( unsigned long category )
+    {
+      actions->GetScheduledSourceArchives( category );
+    }
 };
 
 EXTERN_C const char *xmlfile( const char*, const char* = NULL );