home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 53 / IOPROG_53.ISO / soft / c++ / xceedbkp.exe / Samples / Vc6 / AddIn / BackupEvents.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-09-02  |  3.8 KB  |  130 lines

  1. #include "stdafx.h"
  2.  
  3. /*
  4.  * Xceed Backup Library - AddIn Sample: Event Sink
  5.  * Copyright 1999, Xceed Software Inc.
  6.  *
  7.  * Description:
  8.  *    The class CBackupEvents implements the event sink for Xceed Backup Library.
  9.  *    It derives from ATL template IDispEventSimpleImpl, which provides the dispatch
  10.  *    interface to the connection point container and calls the proper methods for
  11.  *    incoming events based on the SINK_MAP.
  12.  *
  13.  */
  14.  
  15. void _stdcall CBackupEvents::BackupFileExpired( BSTR sBackupFilename, BSTR sBackupSetName, 
  16.                                                 enum bkpBackupType xBackupType, 
  17.                                                 DATE dtBackupDate, DATE dtExpirationDate, 
  18.                                                 VARIANT_BOOL bLatestOfThisType, 
  19.                                                 VARIANT_BOOL * bKeepBackup )
  20. {
  21.   *bKeepBackup = bLatestOfThisType;
  22. }
  23.  
  24. void _stdcall CBackupEvents::BeforeBackingUpFile( BSTR sFilename, long lSize, 
  25.                                                   enum bkpFileAttributes xAttributes, 
  26.                                                   DATE dtLastModified, DATE dtLastAccessed,
  27.                                                   DATE dtCreated, long lDiskNumber )
  28. {
  29.   if( m_spApplication )
  30.   {
  31.     try
  32.     {
  33.       CComBSTR bstrOutputString( "  Backing up file " );
  34.       bstrOutputString += sFilename;
  35.  
  36.       m_spApplication->PrintToOutputWindow( bstrOutputString );
  37.     }
  38.     catch( ... )
  39.     {
  40.     }
  41.   }
  42. }
  43.  
  44. void _stdcall CBackupEvents::ProcessCompleted( long lFilesTotal, long lFilesProcessed, 
  45.                                                long lFilesSkipped, long lBytesTotal, 
  46.                                                long lBytesProcessed, long lBytesSkipped, 
  47.                                                enum bkpError xResult )
  48. {
  49.   if( m_spApplication )
  50.   {
  51.     try
  52.     {
  53.       CComBSTR bstrOutputString( "Backup completed." );
  54.  
  55.       if( m_piXceedBackup )
  56.       {
  57.         CComBSTR bstrResult;
  58.  
  59.         bstrResult = m_piXceedBackup->GetErrorDescription( bvtError, xResult );
  60.  
  61.         bstrOutputString += " Result: ";
  62.         bstrOutputString += bstrResult;
  63.       }
  64.  
  65.       m_spApplication->PrintToOutputWindow( bstrOutputString );
  66.     }
  67.     catch( ... )
  68.     {
  69.     }
  70.   }
  71. }
  72.  
  73. void _stdcall CBackupEvents::SkippingFile( BSTR sFilename, long lSize, 
  74.                                            enum bkpFileAttributes xAttributes, 
  75.                                            DATE dtLastModified, DATE dtLastAccessed, 
  76.                                            DATE dtCreated,  enum bkpSkippingReason xSkippingReason )
  77. {
  78.   if( m_spApplication )
  79.   {
  80.     try
  81.     {
  82.       CComBSTR bstrOutputString( "  Skipping file " );
  83.       bstrOutputString += sFilename;
  84.  
  85.       if( m_piXceedBackup )
  86.       {
  87.         CComBSTR bstrReason;
  88.  
  89.         bstrReason = m_piXceedBackup->GetErrorDescription( bvtSkippingReason, xSkippingReason );
  90.  
  91.         bstrOutputString += " Reason: ";
  92.         bstrOutputString += bstrReason;
  93.       }
  94.  
  95.       m_spApplication->PrintToOutputWindow( bstrOutputString );
  96.     }
  97.     catch( ... )
  98.     {
  99.     }
  100.   }
  101. }
  102.  
  103. void _stdcall CBackupEvents::StartingBackup( struct IXceedBackupJob * xBackupJob, 
  104.                                              DATE dtBackupDate, BSTR * sMediaLabelPattern, 
  105.                                              VARIANT_BOOL * bPreventLaunch )
  106. {
  107.   if( m_spApplication )
  108.   {
  109.     try
  110.     {
  111.       CComBSTR bstrProjectName;
  112.  
  113.       if( SUCCEEDED( xBackupJob->get_BackupSetName( &bstrProjectName ) ) )
  114.       {
  115.         CComBSTR bstrOutputString( "\nStarting backup of the files for the project " );
  116.         bstrOutputString += bstrProjectName;
  117.  
  118.         m_spApplication->PrintToOutputWindow( bstrOutputString );
  119.       }
  120.     }
  121.     catch( ... )
  122.     {
  123.     }
  124.   }
  125. }
  126.  
  127. //
  128. // END_OF_FILE
  129. //
  130.