home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / layout / fsfile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.0 KB  |  203 lines

  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19.  
  20. #ifndef FSFILE_H
  21. #define FSFILE_H
  22.  
  23. #ifdef EDITOR
  24.  
  25. #include "xp.h"
  26. #include "xp_file.h"
  27. #include "streams.h"
  28. #include "bits.h"  // mac seems to need it for garray.h to work. hardts
  29. #include "garray.h"
  30.  
  31. // Same as TXP_GrowableArray_pChar 
  32. Declare_GrowableArray(char,char*)    // TXP_GrowableArray_char
  33.  
  34. Declare_GrowableArray(CStreamOutFile,CStreamOutFile *) // TXP_GrowableArray_CStreamOutFile
  35.  
  36. class CFileBackup;
  37. Declare_GrowableArray(CFileBackup,CFileBackup *) // TXP_GrowableArray_CFileBackup
  38.  
  39. //-----------------------------------------------------------------------
  40. // File based version of ITapeFileSystem
  41. //-----------------------------------------------------------------------
  42.  
  43.  
  44. class CTapeFSFile: public ITapeFileSystem {
  45. public:
  46.     // Give the directory where everything will be saved.
  47.     CTapeFSFile(char *pDestPathURL,char *pDestURL);
  48.     virtual ~CTapeFSFile();
  49.  
  50.     virtual intn GetType();
  51.  
  52.     virtual void SetSourceBaseURL( char* pURL );
  53.  
  54.     // See ITapeFileSystem::AddFile().
  55.     virtual intn AddFile( char* pURL, char *pMIMEType, int16 iDocCharSetID );
  56.     
  57.     virtual intn GetNumFiles() {return m_srcURLs.Size();}    
  58.  
  59.     // Simply returns the URL given in AddFile().  Allocated with XP_STRDUP().
  60.     virtual char* GetSourceURL(intn iFileIndex);
  61.  
  62.     virtual char* GetDestAbsURL();
  63.  
  64.     // iFileIndex must be in {0...GetNumFiles()-1}
  65.     // Returns URL relative to document, i.e. just the stripped local file name.
  66.     virtual char* GetDestURL( intn iFileIndex );
  67.     virtual char* GetHumanName( intn iFileIndex ) {return GetDestURL(iFileIndex);}
  68.  
  69.     virtual char* GetDestPathURL();
  70.  
  71.     virtual XP_Bool IsLocalPersistentFile(intn iFileIndex);
  72.  
  73.     virtual XP_Bool FileExists(intn iFileIndex);
  74.  
  75.     // Save old file first.
  76.     virtual IStreamOut *OpenStream( intn iFileIndex );
  77.  
  78.     virtual void CloseStream( intn iFileIndex );
  79.     
  80.     virtual void Complete( XP_Bool bSuccess,
  81.                                     EDT_ITapeFileSystemComplete *complete, void *pArg  );
  82.  
  83.     void CopyURLInfo(intn iFileIndex, const URL_Struct *pURL);
  84.     
  85. protected:
  86.     // Can be NULL.    
  87.     char *m_pSrcBaseURL;
  88.     // These are absolute URLs.
  89.     TXP_GrowableArray_char m_srcURLs;
  90.      // All dest filenames relative to pDestPathURL, which is a directory.
  91.     char *m_pDestPathURL;       
  92.     // The destination filename for the root HTML document.  Should be file:// url.
  93.     char *m_pDestURL;    
  94.     // relative filenames   
  95.     TXP_GrowableArray_char m_destFilenames;
  96.     
  97.     TXP_GrowableArray_CStreamOutFile m_streamOuts;
  98.     TXP_GrowableArray_CFileBackup m_fileBackups;
  99. };
  100.  
  101. //-----------------------------------------------------------------------
  102. // HTTP/FTP publish based version of ITapeFileSystem
  103. // Similar to CTapeFSFile because it writes to temporary files,
  104. // then publishes.
  105. //-----------------------------------------------------------------------
  106. class CTapeFSPublish: public ITapeFileSystem {
  107. public:
  108.     // Important: If pRemoteURL is a directory, it must end with a slash.
  109.     // pUsername and pPassword may be NULL.
  110.     CTapeFSPublish(MWContext *, char *pRemoteURL, char *pUsername, char *pPassword, 
  111.                     char *pTempDir); // where to put temp files, in xpURL format, ends in slash.
  112.     virtual ~CTapeFSPublish();
  113.  
  114.     virtual intn GetType();
  115.  
  116.     virtual void SetSourceBaseURL( char* pURL );
  117.  
  118.     // See ITapeFileSystem::AddFile().
  119.     virtual intn AddFile( char* pURL, char *pMIMEType, int16 iDocCharSetID );
  120.     
  121.     virtual intn GetNumFiles() {return m_srcURLs.Size();}    
  122.  
  123.     // Simply returns the URL given in AddFile().  Allocated with XP_STRDUP().
  124.     virtual char* GetSourceURL(intn iFileIndex);
  125.  
  126.     virtual char* GetDestAbsURL();
  127.  
  128.     char *GetUsername();
  129.     char *GetPassword();
  130.  
  131.     // iFileIndex must be in {0...GetNumFiles()-1}
  132.     // Returns URL relative to document, i.e. just the stripped local file name.
  133.     virtual char* GetDestURL( intn iFileIndex );
  134.     virtual char* GetHumanName( intn iFileIndex ) {return GetDestURL(iFileIndex);}
  135.  
  136.     // Returns the directory on the remote server (with trailing slash) where the document will
  137.     // be published.  Does not contain username or password info.  
  138.     // E.g. http://the_machine/the_directory/  not http://username:password@the_machine/the_directory/
  139.     virtual char* GetDestPathURL();
  140.  
  141.     virtual XP_Bool IsLocalPersistentFile(intn iFileIndex);
  142.  
  143.     virtual XP_Bool FileExists(intn /* iFileIndex */ ) {return FALSE;}
  144.     
  145.     // Save old file first.
  146.     virtual IStreamOut *OpenStream( intn iFileIndex );
  147.  
  148.     virtual void CloseStream( intn iFileIndex );
  149.     
  150.     // Calls Net_PublishFiles().
  151.     virtual void Complete( XP_Bool bSuccess,
  152.                                      EDT_ITapeFileSystemComplete *pfComplete, void *pArg  );
  153.     
  154.     XP_Bool Verify() {return m_iVerifier == iVerifierKey;}
  155.  
  156.     void CopyURLInfo(intn iFileIndex, const URL_Struct *pURL);
  157.  
  158. public:
  159.     // These are just here to pass data to edt_CTapeFSExit().
  160.     EDT_ITapeFileSystemComplete *m_pfComplete;
  161.     void *m_pArg;
  162.     
  163. private:
  164.     int32 m_iVerifier;
  165.     static int32 iVerifierKey;
  166.     
  167.     // Makes a new url pointing to a file in the same directory as baseURL, baseURL may also be a 
  168.     // directory, e.g. http://home.netscape.com/     
  169.     // Uses srcURL to choose the name and returns an absolute URL.
  170.     char *makeLocal(char *baseURL, char *srcURL);
  171.  
  172.     // For call to NET_PublishFiles.
  173.     MWContext *m_pMWContext;
  174.     
  175.     // Can be NULL.    
  176.     char *m_pSrcBaseURL;
  177.  
  178.     // These are absolute URLs.
  179.     TXP_GrowableArray_char m_srcURLs;
  180.  
  181.     // final location of the HTML file
  182.     char *m_pRemoteURL;    // {http,ftp}://location
  183.     char *m_pUsername;
  184.     char *m_pPassword;
  185.  
  186.     // final locations of all the files.  Note that element 0 will be a copy of m_pRemoteURL.
  187.     // These contain username:password information.
  188.     TXP_GrowableArray_char m_remoteURLs;
  189.  
  190.     char *m_pTempDir;  // xpURL format.
  191.     // Absolute platform specific filenames.  The temp files.
  192.     TXP_GrowableArray_char m_tempFilenames;
  193.  
  194.     // Streams to write to temp files.
  195.     TXP_GrowableArray_CStreamOutFile m_streamOuts;
  196.  
  197.     // TRUE if http, FALSE if ftp
  198.     XP_Bool m_bIsHTTP;
  199. };
  200.  
  201. #endif // EDITOR
  202. #endif
  203.