calendarui/controller/src/calendebug.cpp
branchRCL_3
changeset 66 bd7edf625bdd
parent 0 f979ecb2b13e
equal deleted inserted replaced
65:12af337248b1 66:bd7edf625bdd
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Debug tools for Calendar 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //debug
       
    21 #include "calendarui_debug.h"
       
    22 
       
    23 #include "calendebug.h"
       
    24 
       
    25 #ifdef _DEBUG
       
    26 
       
    27 #include <calalarm.h>
       
    28 #include <calentry.h>
       
    29 #include <calinstance.h>
       
    30 #include <calrrule.h>
       
    31 #include <e32debug.h>
       
    32 #include <utf.h> 
       
    33 
       
    34 namespace CalenDebug 
       
    35     {
       
    36     void LogTimeL(const TDesC& aMsg, const TTime& aTime)
       
    37         {
       
    38         TBuf<30> tmp;
       
    39         if ( aTime == Time::NullTTime() )
       
    40             {
       
    41             tmp = _L("null time");
       
    42             }
       
    43         else 
       
    44             {
       
    45             _LIT(KDtFmt, "%F%H:%T %D.%M.%Y");
       
    46             aTime.FormatL( tmp, KDtFmt ); 
       
    47             }
       
    48         RDebug::Print(aMsg, &tmp);
       
    49         }
       
    50 
       
    51     void LogRRuleL(const TCalRRule& aRule)
       
    52         {
       
    53         _LIT(KYearly,  "Yearly");
       
    54         _LIT(KMonthly, "Monthly");
       
    55         _LIT(KWeekly,  "Weekly");
       
    56         _LIT(KDaily,   "Daily");
       
    57         _LIT(KInvalid, "Invalid");
       
    58 
       
    59         TBuf<20> typeStr;
       
    60         switch ( aRule.Type() )
       
    61             {
       
    62             case TCalRRule::EInvalid:
       
    63                 typeStr = KInvalid;
       
    64                 break;
       
    65             case TCalRRule::EDaily:
       
    66                 typeStr = KDaily;
       
    67                 break;
       
    68             case TCalRRule::EWeekly:
       
    69                 typeStr = KWeekly;
       
    70                 break;
       
    71             case TCalRRule::EMonthly:
       
    72                 typeStr = KMonthly;
       
    73                 break;
       
    74             case TCalRRule::EYearly:
       
    75                 typeStr = KYearly;
       
    76                 break;
       
    77             }
       
    78         RDebug::RawPrint( typeStr );
       
    79         RDebug::Print( _L("Count   %d"), aRule.Count() );
       
    80         RDebug::Print( _L("Interv. %d"), aRule.Interval() );
       
    81 
       
    82         RDebug::RawPrint( _L("UTC:") );
       
    83         LOGTIME(       _L("DtStart %S"), aRule.DtStart().TimeUtcL() );
       
    84         LOGTIME(       _L("Until   %S"), aRule.Until().TimeUtcL() );
       
    85 
       
    86         RDebug::RawPrint( _L("Local:") );
       
    87         LOGTIME(       _L("DtStart %S"), aRule.DtStart().TimeLocalL() );
       
    88         LOGTIME(       _L("Until   %S"), aRule.Until().TimeLocalL() );
       
    89         }
       
    90 
       
    91     void LogGuidL( const TDesC8& aGuid )
       
    92         {
       
    93         HBufC16* guid = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aGuid );
       
    94         CleanupStack::PushL( guid );
       
    95         RDebug::Print( _L("Guid:\"%S\""), guid );
       
    96         CleanupStack::PopAndDestroy( guid );
       
    97         }
       
    98 
       
    99     void LogCalTimeL( TCalTime& aCalTime )
       
   100         {
       
   101         LOGTIME(_L("UTC   %S"), aCalTime.TimeUtcL());
       
   102         LOGTIME(_L("Local %S"), aCalTime.TimeLocalL());
       
   103         }
       
   104 
       
   105     void LogEntryRecurrenceIdL( CCalEntry& aEntry )
       
   106         {
       
   107         TCalTime recurrenceId;
       
   108         TRAPD( err, recurrenceId = aEntry.RecurrenceIdL() );
       
   109         if ( err == KErrNone )
       
   110             {
       
   111             if ( recurrenceId.TimeUtcL() == Time::NullTTime() )
       
   112                 {
       
   113                 RDebug::RawPrint( _L("No recurrence id") );
       
   114                 }
       
   115             else
       
   116                 {
       
   117                 RDebug::RawPrint( _L("Recurrence id:") );
       
   118                 LogCalTimeL( recurrenceId );
       
   119                 }
       
   120             }
       
   121         else
       
   122             {
       
   123             RDebug::Print( _L("Recurrence id: reading leaved with %d"), err );
       
   124             }
       
   125         }
       
   126 
       
   127     void LogRecurrenceRangeL( CalCommon::TRecurrenceRange aRange )
       
   128         {
       
   129         switch ( aRange )
       
   130             {
       
   131             case CalCommon::EThisOnly:
       
   132                 RDebug::RawPrint( _L("ThisOnly") );
       
   133                 break;
       
   134             case CalCommon::EThisAndAll:
       
   135                 RDebug::RawPrint( _L("ThisAndAll") );
       
   136                 break;
       
   137             case CalCommon::EThisAndFuture:
       
   138                 RDebug::RawPrint( _L("ThisAndFuture") );
       
   139                 break;
       
   140             case CalCommon::EThisAndPrior:
       
   141                 RDebug::RawPrint( _L("ThisAndPrior") );
       
   142                 break;
       
   143             }
       
   144         }
       
   145 
       
   146     void LogDatesL( RArray<TCalTime>& aExDateList )
       
   147         {
       
   148 
       
   149         if ( aExDateList.Count() > 0 )
       
   150             {
       
   151             RDebug::RawPrint( _L("START                    ***") );
       
   152             for (TInt i=0; i < aExDateList.Count(); i++) 
       
   153                 {
       
   154                 LogCalTimeL( aExDateList[i] );
       
   155                 }
       
   156             RDebug::RawPrint( _L("END                      ***") );
       
   157             }
       
   158         }
       
   159 
       
   160     void LogEntryDetailsL(CCalEntry& aEntry)
       
   161         {
       
   162         RDebug::RawPrint( aEntry.SummaryL() );
       
   163         RDebug::RawPrint( aEntry.LocationL() );
       
   164 
       
   165         LogGuidL( aEntry.UidL() );
       
   166         LogEntryRecurrenceIdL( aEntry );
       
   167         LogRecurrenceRangeL( aEntry.RecurrenceRangeL() );
       
   168 
       
   169         RArray< TCalTime > exceptionDates;
       
   170         CleanupClosePushL( exceptionDates );
       
   171         aEntry.GetExceptionDatesL( exceptionDates );
       
   172         RDebug::Print( _L("Exception dates %d"), exceptionDates.Count() );
       
   173         LogDatesL( exceptionDates );
       
   174         CleanupStack::PopAndDestroy( & exceptionDates );
       
   175 
       
   176         // Guid
       
   177         //     HBufC* guid = HBufC16::NewLC(500);
       
   178         //     guid->Copy( aEntry.UidL() );
       
   179         //     RDebug::Print( *guid );
       
   180         //     CleanupStack::PopAndDestroy( guid );
       
   181 
       
   182         // Entry Start and end times
       
   183         // Note %S modifier is very important!
       
   184         // UTC
       
   185         RDebug::RawPrint( _L("Entry UTC:" ) );
       
   186         LOGTIME(_L("Start %S"), aEntry.StartTimeL().TimeUtcL());
       
   187         LOGTIME(_L("End   %S"), aEntry.EndTimeL().TimeUtcL());
       
   188 
       
   189         // Local 
       
   190         RDebug::RawPrint( _L("Entry Local:" ) );
       
   191         LOGTIME(_L("Start %S"), aEntry.StartTimeL().TimeLocalL());
       
   192         LOGTIME(_L("End   %S"), aEntry.EndTimeL().TimeLocalL());
       
   193 
       
   194         // Alarm 
       
   195         CCalAlarm* alarm = aEntry.AlarmL();
       
   196         CleanupStack::PushL( alarm );
       
   197         if ( alarm )
       
   198             {
       
   199             RDebug::RawPrint( _L("Has alarm" ) );
       
   200             RDebug::Print( _L(" offset: %d"), alarm->TimeOffset().Int() );
       
   201             }
       
   202         else
       
   203             {
       
   204             RDebug::RawPrint( _L("No alarm") );
       
   205             }
       
   206         CleanupStack::PopAndDestroy(alarm);
       
   207 
       
   208         // Repeat rule 
       
   209         TCalRRule rrule;
       
   210         if ( aEntry.GetRRuleL(rrule) )
       
   211             {
       
   212             RDebug::RawPrint( _L("Has rrule" ) );
       
   213             LOGRRULE( rrule );
       
   214             }
       
   215         else
       
   216             {
       
   217             RDebug::RawPrint( _L("No rrule" ) );
       
   218             }
       
   219         }
       
   220 
       
   221     void LogInstanceDetailsL(CCalInstance& aInstance)
       
   222         {
       
   223         // Instance times
       
   224         // UTC
       
   225         RDebug::RawPrint( _L("Instance UTC:") );
       
   226         LOGTIME(_L("time  %S"), aInstance.Time().TimeUtcL());
       
   227         LOGTIME(_L("start %S"), aInstance.StartTimeL().TimeUtcL());
       
   228         LOGTIME(_L("end   %S"), aInstance.EndTimeL().TimeUtcL());
       
   229 
       
   230         // Local 
       
   231         RDebug::RawPrint( _L("Instance Local:") );
       
   232         LOGTIME(_L("time  %S"), aInstance.Time().TimeLocalL());
       
   233         LOGTIME(_L("start %S"), aInstance.StartTimeL().TimeLocalL());
       
   234         LOGTIME(_L("end   %S"), aInstance.EndTimeL().TimeLocalL());
       
   235         }
       
   236 
       
   237     void LogEntryL(CCalEntry& aEntry)
       
   238         {
       
   239         RDebug::RawPrint( _L("----- ENTRY -----") );
       
   240         LogEntryDetailsL( aEntry );
       
   241         }
       
   242 
       
   243     void LogInstanceL(CCalInstance& aInstance)
       
   244         {
       
   245         RDebug::RawPrint( _L("----- INSTANCE -----") );
       
   246         LogEntryDetailsL( aInstance.Entry() );
       
   247         LogInstanceDetailsL( aInstance );
       
   248         }
       
   249     }
       
   250 
       
   251 #endif // _DEBUG
       
   252