calendarui/inc/calendarui_debug.h
branchRCL_3
changeset 65 12af337248b1
parent 0 f979ecb2b13e
child 66 bd7edf625bdd
equal deleted inserted replaced
60:96907930389d 65:12af337248b1
     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: Calendar debug file.
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
       
    18 /**
    17 /**
    19 *
    18 *
    20 **/
    19 **/
    21 
    20 
    22 #include "debug.h"
    21 #include "debug.h"
    24 #define RD_CALENDAR_PREVIEW
    23 #define RD_CALENDAR_PREVIEW
    25 
    24 
    26 #ifndef PIM_TRACE_H
    25 #ifndef PIM_TRACE_H
    27 #define PIM_TRACE_H
    26 #define PIM_TRACE_H
    28 
    27 
    29 #if defined (_DEBUG) || defined (_PIM_FILE_LOG) || defined (_DISPLAY_WARNINGS) 
    28 #if defined (_DEBUG) || defined (_PIM_FILE_LOG) 
    30     //Includes
    29     //Includes
    31     #include <e32base.h>
    30     #include <e32base.h>
    32     #include <e32std.h>
    31     #include <e32std.h>
    33     #include <flogger.h>
    32     #include <flogger.h>
    34     #include <e32svr.h>
    33     #include <e32svr.h>
    35     #include <f32file.h>
    34     #include <f32file.h>
    36     #include <AknGlobalConfirmationQuery.h>
    35 	
    37     const TInt KMaxLogLineLength = 512;
    36     const TInt KMaxLogLineLength = 512;
    38 #endif
    37 #endif
    39 
    38 #if defined( _DEBUG ) 
    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 ) 
       
    98     #define PIM_TRAP_HANDLE( _err, _s ) \
    39     #define PIM_TRAP_HANDLE( _err, _s ) \
    99     { \
    40     { \
   100         TRAP( _err, _s; ); \
    41         TRAP( _err, _s; ); \
   101         ASSERT( !_err ); \
    42         ASSERT( !_err ); \
   102     }
    43     }
   104     { \
    45     { \
   105         TRAPD( _err, _s; ); \
    46         TRAPD( _err, _s; ); \
   106         ASSERT( !_err ); \
    47         ASSERT( !_err ); \
   107     }
    48     }
   108     #define WARNING_NOTE( _s )
    49     #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     }
       
   115 #else 
    50 #else 
   116 // urel
    51 // urel
   117     #define PIM_TRAP_HANDLE( _err, _s )   TRAP_IGNORE( _s; );
    52     #define PIM_TRAP_HANDLE( _err, _s )   TRAP_IGNORE( _s; );
   118     #define PIM_TRAPD_HANDLE( _s )  TRAP_IGNORE( _s; );
    53     #define PIM_TRAPD_HANDLE( _s )  TRAP_IGNORE( _s; );
   119     #define WARNING_NOTE( _s )
    54     #define WARNING_NOTE( _s )
   120     #define PIM_ASSERT( _s )  _s;
       
   121 #endif // _DEBUG
    55 #endif // _DEBUG
   122 
    56 
   123 #if defined (_DEBUG) || defined (_PIM_FILE_LOG) 
    57 #if defined (_DEBUG) || defined (_PIM_FILE_LOG) 
   124     
    58     
   125    
    59    
   181         TBuf16<KMaxLogLineLength> buf16( buf8.Length() );
   115         TBuf16<KMaxLogLineLength> buf16( buf8.Length() );
   182         buf16.Copy( buf8 );
   116         buf16.Copy( buf8 );
   183         TRefByValue<const TDesC> tmpFmt( _L("%S") );
   117         TRefByValue<const TDesC> tmpFmt( _L("%S") );
   184  #if defined (_PIM_FILE_LOG)  
   118  #if defined (_PIM_FILE_LOG)  
   185         _LIT( KLogDir, "CalenUi");
   119         _LIT( KLogDir, "CalenUi");
   186         _LIT( KLogDir2, "c://CalenUi");
   120         _LIT( KLogDir2, "c:\\CalenUi");
   187         _LIT( KLogFile, "log.txt");
   121         _LIT( KLogFile, "log.txt");
   188         _LIT( KDir, "c://logs//CalenUi" );
   122         _LIT( KDir, "c:\\logs\\CalenUi" );
   189         _LIT( KDir2, "c://logs//CalenUi" );
   123         _LIT( KDir2, "c:\\logs\\CalenUi" );
   190         
   124         
   191         RFs fs;
   125         RFs fs;
   192         fs.Connect();
   126         fs.Connect();
   193         fs.MkDirAll( KDir );
   127         fs.MkDirAll( KDir );
   194         
   128