metadataengine/server/src/mdsimportexport.cpp
changeset 2 b73a2e62868f
parent 1 acef663c1218
child 6 646a02f170b9
equal deleted inserted replaced
1:acef663c1218 2:b73a2e62868f
    49 #include "mdscommoninternal.h"
    49 #include "mdscommoninternal.h"
    50 
    50 
    51 const TInt KMdsMaxUriLenght = KMaxFileName;
    51 const TInt KMdsMaxUriLenght = KMaxFileName;
    52 const TChar KMdsLineFeed = '\n';
    52 const TChar KMdsLineFeed = '\n';
    53 
    53 
       
    54 #ifdef _DEBUG
    54 const TInt KMdsMaxLogLineLenght( 2056 );
    55 const TInt KMdsMaxLogLineLenght( 2056 );
    55 
    56 
    56 _LIT( KMdsErrorLogDirectory, "Metadata" );
    57 _LIT( KMdsErrorLogDirectory, "Metadata" );
    57 _LIT( KMdsErrorLogFilename, "importerror.log" );
    58 _LIT( KMdsErrorLogFilename, "importerror.log" );
       
    59 #endif
    58 
    60 
    59 // keyword definitions in import file
    61 // keyword definitions in import file
    60 _LIT8( KMdsKeywordComment,     "//" );
    62 _LIT8( KMdsKeywordComment,     "//" );
    61 _LIT8( KMdsKeywordNamespace,   "namespace" );
    63 _LIT8( KMdsKeywordNamespace,   "namespace" );
    62 _LIT8( KMdsKeywordObjectDef,   "object" );
    64 _LIT8( KMdsKeywordObjectDef,   "object" );
   115  */
   117  */
   116 CMdsImportExport::~CMdsImportExport()
   118 CMdsImportExport::~CMdsImportExport()
   117 	{
   119 	{
   118    	delete iConverter;
   120    	delete iConverter;
   119 
   121 
   120     iLog.CloseLog(); 
   122 #ifdef _DEBUG
   121     iLog.Close();
   123    	if( iLogEnabled )
       
   124    	    {
       
   125         iLog.CloseLog(); 
       
   126         iLog.Close();
       
   127    	    }
       
   128 #endif
   122     iFs.Close();
   129     iFs.Close();
   123 
   130 
   124    	delete iBuffer;
   131    	delete iBuffer;
   125 
   132 
   126    	delete iSchema;
   133    	delete iSchema;
   134 	iSchema = CMdsSchema::NewL();
   141 	iSchema = CMdsSchema::NewL();
   135     iConverter = CCnvCharacterSetConverter::NewL();
   142     iConverter = CCnvCharacterSetConverter::NewL();
   136 
   143 
   137     User::LeaveIfError( iFs.Connect() );
   144     User::LeaveIfError( iFs.Connect() );
   138     iConverter->PrepareToConvertToOrFromL( KCharacterSetIdentifierUtf8, iFs );
   145     iConverter->PrepareToConvertToOrFromL( KCharacterSetIdentifierUtf8, iFs );
   139     
   146 
   140     User::LeaveIfError( iLog.Connect( ) );
   147 #ifdef _DEBUG
   141     iLog.CreateLog( KMdsErrorLogDirectory, KMdsErrorLogFilename, EFileLoggingModeOverwrite );
   148     const TInt logError( iLog.Connect( ) );
   142     iLog.SetDateAndTime(EFalse, ETrue);
   149     if( logError == KErrNone )
       
   150         {
       
   151         iLogEnabled = ETrue;
       
   152         iLog.CreateLog( KMdsErrorLogDirectory, KMdsErrorLogFilename, EFileLoggingModeOverwrite );
       
   153         iLog.SetDateAndTime(EFalse, ETrue);
       
   154         }
       
   155 #endif
   143 
   156 
   144 	iBuffer = NULL;
   157 	iBuffer = NULL;
   145     iLastObjectDef = NULL;
   158     iLastObjectDef = NULL;
   146 	}
   159 	}
   147 
   160 
  2472 
  2485 
  2473 // ------------------------------------------------
  2486 // ------------------------------------------------
  2474 // LogError
  2487 // LogError
  2475 // ------------------------------------------------
  2488 // ------------------------------------------------
  2476 //
  2489 //
       
  2490 #ifdef _DEBUG
  2477 void CMdsImportExport::LogError( const TDesC& aMessage )
  2491 void CMdsImportExport::LogError( const TDesC& aMessage )
  2478     {
  2492     {
  2479     _LIT( KParseError, "Parse error: %S" );
  2493     if( iLogEnabled )
  2480     _LIT( KCurrentFile, "Current file: %S" );
  2494         {
  2481     _LIT( KCurrentLineNum, "Current line number: %d" );
  2495         _LIT( KParseError, "Parse error: %S" );
  2482     _LIT( KCurrentLine, "Current line: %S" );
  2496         _LIT( KCurrentFile, "Current file: %S" );
  2483     iLog.WriteFormat( KParseError, &aMessage );
  2497         _LIT( KCurrentLineNum, "Current line number: %d" );
  2484     iLog.WriteFormat( KCurrentFile, &iFileName );
  2498         _LIT( KCurrentLine, "Current line: %S" );
  2485     iLog.WriteFormat( KCurrentLineNum, iLineNumber );
  2499         iLog.WriteFormat( KParseError, &aMessage );
  2486     TBuf16<KMdsMaxLogLineLenght> line16;
  2500         iLog.WriteFormat( KCurrentFile, &iFileName );
  2487     Conv8To16( iLine, line16 );
  2501         iLog.WriteFormat( KCurrentLineNum, iLineNumber );
  2488     iLog.WriteFormat( KCurrentLine, &line16 );
  2502         TBuf16<KMdsMaxLogLineLenght> line16;
       
  2503         Conv8To16( iLine, line16 );
       
  2504         iLog.WriteFormat( KCurrentLine, &line16 );
       
  2505         }
  2489     }
  2506     }
       
  2507 #else
       
  2508 void CMdsImportExport::LogError( const TDesC& /*aMessage*/ )
       
  2509     {
       
  2510     }
       
  2511 #endif
  2490 
  2512 
  2491 
  2513 
  2492 // ------------------------------------------------
  2514 // ------------------------------------------------
  2493 // CheckForConstant
  2515 // CheckForConstant
  2494 // ------------------------------------------------
  2516 // ------------------------------------------------