calendarui/inc/calendarui_debug.h
changeset 89 b57382753122
parent 55 2c54b51f39c4
equal deleted inserted replaced
83:5aadd1120515 89:b57382753122
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description: Calendar debug file.
    15 *
    15 *
    16 */
    16 */
       
    17 
    17 /**
    18 /**
    18 *
    19 *
    19 **/
    20 **/
    20 
    21 
    21 #include "debug.h"
    22 #include "debug.h"
    23 #define RD_CALENDAR_PREVIEW
    24 #define RD_CALENDAR_PREVIEW
    24 
    25 
    25 #ifndef PIM_TRACE_H
    26 #ifndef PIM_TRACE_H
    26 #define PIM_TRACE_H
    27 #define PIM_TRACE_H
    27 
    28 
    28 #if defined (_DEBUG) || defined (_PIM_FILE_LOG) 
    29 #if defined (_DEBUG) || defined (_PIM_FILE_LOG) || defined (_DISPLAY_WARNINGS) 
    29     //Includes
    30     //Includes
    30     #include <e32base.h>
    31     #include <e32base.h>
    31     #include <e32std.h>
    32     #include <e32std.h>
    32     #include <flogger.h>
    33     #include <flogger.h>
    33     #include <e32svr.h>
    34     #include <e32svr.h>
    34     #include <f32file.h>
    35     #include <f32file.h>
    35 	
    36     #include <AknGlobalConfirmationQuery.h>
    36     const TInt KMaxLogLineLength = 512;
    37     const TInt KMaxLogLineLength = 512;
    37 #endif
    38 #endif
    38 #if defined( _DEBUG ) 
    39 
       
    40 /**
       
    41 * Define our own trap and assert macros to prevent compiler warnings.
       
    42 */
       
    43 #if defined (_DISPLAY_WARNINGS)
       
    44     _LIT( KWarningFormat, " error %d trapped %S line %d");
       
    45     inline void DisplayWarningNote( TInt aError, const TDesC8& aFile, TInt aWarningNote )
       
    46         {
       
    47         if ( aError )
       
    48             {
       
    49             TRAP_IGNORE(
       
    50             CAknGlobalConfirmationQuery* cq = CAknGlobalConfirmationQuery::NewL();
       
    51             CleanupStack::PushL( cq );
       
    52             
       
    53             TBuf<KMaxLogLineLength> text;
       
    54             TBuf<128> fileName;
       
    55             fileName.Copy( aFile );
       
    56             text.Format( KWarningFormat, aError, &fileName, aWarningNote );
       
    57             
       
    58             TRequestStatus stat = KRequestPending;
       
    59             cq->ShowConfirmationQueryL( stat, text, R_AVKON_SOFTKEYS_YES_NO );
       
    60             User::WaitForRequest( stat );
       
    61             
       
    62             CleanupStack::PopAndDestroy( cq );
       
    63             );
       
    64             }       
       
    65         }
       
    66 
       
    67     inline void DisplayWarningNote( const TDesC& aNote )
       
    68         {
       
    69         TRAP_IGNORE(
       
    70             CAknGlobalConfirmationQuery* cq = CAknGlobalConfirmationQuery::NewL();
       
    71             CleanupStack::PushL( cq );
       
    72            
       
    73             
       
    74             TRequestStatus stat = KRequestPending;
       
    75             cq->ShowConfirmationQueryL( stat, aNote, R_AVKON_SOFTKEYS_YES_NO );
       
    76             User::WaitForRequest( stat );
       
    77             
       
    78             CleanupStack::PopAndDestroy( cq );
       
    79             );
       
    80         }
       
    81         
       
    82     #undef TRAP_INSTRUMENTATION_LEAVE
       
    83     #define TRAP_INSTRUMENTATION_LEAVE(aResult) DisplayWarningNote( aResult,TPtrC8( ( TText8* )__FILE__), __LINE__);
       
    84 
       
    85     #define PIM_TRAP_HANDLE( _err, _s ) \
       
    86     { \
       
    87         TRAP( _err, _s; ); \
       
    88         DisplayWarningNote( _err,TPtrC8( ( TText8* )__FILE__),__LINE__ ); \
       
    89     }
       
    90     #define PIM_TRAPD_HANDLE( _s ) \
       
    91     { \
       
    92         TRAPD( _err, _s; ); \
       
    93         DisplayWarningNote( _err, TPtrC8( ( TText8* )__FILE__), __LINE__ ); \
       
    94     }
       
    95     #define WARNING_NOTE( _s ) DisplayWarningNote( _s );
       
    96     
       
    97 #elif defined( _DEBUG ) 
    39     #define PIM_TRAP_HANDLE( _err, _s ) \
    98     #define PIM_TRAP_HANDLE( _err, _s ) \
    40     { \
    99     { \
    41         TRAP( _err, _s; ); \
   100         TRAP( _err, _s; ); \
    42         ASSERT( !_err ); \
   101         ASSERT( !_err ); \
    43     }
   102     }
    45     { \
   104     { \
    46         TRAPD( _err, _s; ); \
   105         TRAPD( _err, _s; ); \
    47         ASSERT( !_err ); \
   106         ASSERT( !_err ); \
    48     }
   107     }
    49     #define WARNING_NOTE( _s )
   108     #define WARNING_NOTE( _s )
       
   109     #define PIM_ASSERT( _s ) \
       
   110     { \
       
   111         const TInt _err = _s; \
       
   112         if( _err ) RDebug::Print( _L("### PIM_ASSERT: %d"), _err ); \
       
   113         ASSERT( !_err ); \
       
   114     }
    50 #else 
   115 #else 
    51 // urel
   116 // urel
    52     #define PIM_TRAP_HANDLE( _err, _s )   TRAP_IGNORE( _s; );
   117     #define PIM_TRAP_HANDLE( _err, _s )   TRAP_IGNORE( _s; );
    53     #define PIM_TRAPD_HANDLE( _s )  TRAP_IGNORE( _s; );
   118     #define PIM_TRAPD_HANDLE( _s )  TRAP_IGNORE( _s; );
    54     #define WARNING_NOTE( _s )
   119     #define WARNING_NOTE( _s )
       
   120     #define PIM_ASSERT( _s )  _s;
    55 #endif // _DEBUG
   121 #endif // _DEBUG
    56 
   122 
    57 #if defined (_DEBUG) || defined (_PIM_FILE_LOG) 
   123 #if defined (_DEBUG) || defined (_PIM_FILE_LOG) 
    58     
   124     
    59    
   125    
   115         TBuf16<KMaxLogLineLength> buf16( buf8.Length() );
   181         TBuf16<KMaxLogLineLength> buf16( buf8.Length() );
   116         buf16.Copy( buf8 );
   182         buf16.Copy( buf8 );
   117         TRefByValue<const TDesC> tmpFmt( _L("%S") );
   183         TRefByValue<const TDesC> tmpFmt( _L("%S") );
   118  #if defined (_PIM_FILE_LOG)  
   184  #if defined (_PIM_FILE_LOG)  
   119         _LIT( KLogDir, "CalenUi");
   185         _LIT( KLogDir, "CalenUi");
   120         _LIT( KLogDir2, "c:\\CalenUi");
   186         _LIT( KLogDir2, "c://CalenUi");
   121         _LIT( KLogFile, "log.txt");
   187         _LIT( KLogFile, "log.txt");
   122         _LIT( KDir, "c:\\logs\\CalenUi" );
   188         _LIT( KDir, "c://logs//CalenUi" );
   123         _LIT( KDir2, "c:\\logs\\CalenUi" );
   189         _LIT( KDir2, "c://logs//CalenUi" );
   124         
   190         
   125         RFs fs;
   191         RFs fs;
   126         fs.Connect();
   192         fs.Connect();
   127         fs.MkDirAll( KDir );
   193         fs.MkDirAll( KDir );
   128         
   194