meetingrequest/mrcommon/src/esmrentryhelper.cpp
changeset 0 8466d47a6819
child 16 4ce476e64c59
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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:  Static helper methods for analyzing entries
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "emailtrace.h"
       
    22 #include "esmrentryhelper.h"
       
    23 #include "esmrhelper.h"
       
    24 
       
    25 // From System
       
    26 #include <calentry.h>
       
    27 #include <caltime.h>
       
    28 #include <calrrule.h>
       
    29 #include <caluser.h>
       
    30 #include <msvids.h>
       
    31 #include <MsgMailUIDs.h>
       
    32 #include <cmrmailboxutils.h>
       
    33 
       
    34 
       
    35 // ======== MEMBER FUNCTIONS ========
       
    36 
       
    37 // ----------------------------------------------------------------------------
       
    38 // ESMREntryHelper::SendingMailBoxL
       
    39 // ----------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C TMsvId ESMREntryHelper::SendingMailBoxL(
       
    42     const MAgnEntryUi::TAgnEntryUiInParams& aInParams,
       
    43     CMRMailboxUtils& aUtils )
       
    44     {
       
    45     FUNC_LOG;
       
    46     TMsvId result(0); 
       
    47     if ( aInParams.iCallingApp.iUid == KUidMsgMailViewer )
       
    48         {
       
    49         result = aInParams.iMailBoxId;
       
    50         }
       
    51     else
       
    52         {
       
    53         CMRMailboxUtils::TMailboxInfo info;
       
    54         // returns KMsvNullIndexEntryId if default box cannot be resolved:
       
    55         aUtils.GetDefaultMRMailBoxL( info );
       
    56         result = info.iEntryId;
       
    57         }
       
    58     return result;
       
    59     }
       
    60 
       
    61 // ----------------------------------------------------------------------------
       
    62 // ESMREntryHelper::IsRepeatingMeetingL
       
    63 // ----------------------------------------------------------------------------
       
    64 //
       
    65 EXPORT_C TBool ESMREntryHelper::IsRepeatingMeetingL(
       
    66         const CCalEntry& aEntry )
       
    67     {
       
    68     FUNC_LOG;
       
    69 
       
    70     TBool retVal( EFalse );
       
    71 
       
    72     if ( IsModifyingEntryL( aEntry ) )
       
    73         {
       
    74 
       
    75         retVal = ETrue;
       
    76         }
       
    77     else
       
    78         {
       
    79         TCalRRule dummyRule;
       
    80         if ( aEntry.GetRRuleL( dummyRule ) )
       
    81             {
       
    82 
       
    83             retVal = ETrue;
       
    84             }
       
    85         else
       
    86             {
       
    87             RArray<TCalTime> dummyRDateList;
       
    88             CleanupClosePushL( dummyRDateList );
       
    89             aEntry.GetRDatesL( dummyRDateList );
       
    90             if ( dummyRDateList.Count() > 0 )
       
    91                 {
       
    92 
       
    93                 retVal = ETrue;
       
    94                 }
       
    95             CleanupStack::PopAndDestroy( &dummyRDateList );
       
    96             }
       
    97         }
       
    98 
       
    99 
       
   100     return retVal;
       
   101     }
       
   102 
       
   103 // ----------------------------------------------------------------------------
       
   104 // ESMREntryHelper::IsModifyingEntryL
       
   105 // ----------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C TBool ESMREntryHelper::IsModifyingEntryL( const CCalEntry& aEntry )
       
   108     {
       
   109     FUNC_LOG;
       
   110     return ( aEntry.RecurrenceIdL().TimeUtcL() !=
       
   111              Time::NullTTime() ) ? ETrue : EFalse;
       
   112     }
       
   113 
       
   114 // ----------------------------------------------------------------------------
       
   115 // ESMREntryHelper::IsLatestSavedSentL
       
   116 // ----------------------------------------------------------------------------
       
   117 //
       
   118 EXPORT_C TBool ESMREntryHelper::IsLatestSavedSentL(
       
   119     const CCalEntry& aEntry )
       
   120     {
       
   121     FUNC_LOG;
       
   122     TBool retVal( EFalse );
       
   123     if ( aEntry.DTStampL().TimeUtcL() == Time::NullTTime() )
       
   124         {
       
   125         // If entries are synchronized to phone we must always assume that
       
   126         // they have been sent already. In case of our own requests we keep the
       
   127         // DTSTAMP as null until sending.
       
   128 
       
   129         retVal = ETrue;
       
   130         }
       
   131     return retVal;
       
   132     }
       
   133 
       
   134 // ----------------------------------------------------------------------------
       
   135 // ESMREntryHelper::IsCancelledL
       
   136 // ----------------------------------------------------------------------------
       
   137 //
       
   138 EXPORT_C TBool ESMREntryHelper::IsCancelledL(
       
   139     const CCalEntry& aEntry,
       
   140     CMRMailboxUtils& aUtils )
       
   141     {
       
   142     FUNC_LOG;
       
   143     TBool retVal( EFalse );
       
   144     // Check if either entire meeting is cancelled, or this attendee
       
   145     // has been removed from the participant list. According to RFC2446
       
   146     // in that case entry doesn't have status field set.
       
   147     if ( aEntry.StatusL() == CCalEntry::ECancelled ||
       
   148          ( aEntry.MethodL() == CCalEntry::EMethodCancel &&
       
   149          !aUtils.ThisAttendeeL( aEntry ) ) )
       
   150         {
       
   151         retVal = ETrue;
       
   152         }
       
   153     return retVal;
       
   154     }
       
   155 
       
   156 // ----------------------------------------------------------------------------
       
   157 // ESMREntryHelper::OccursInPastL
       
   158 // ----------------------------------------------------------------------------
       
   159 //
       
   160 EXPORT_C TBool ESMREntryHelper::OccursInPastL( const CCalEntry& aEntry )
       
   161     {
       
   162     FUNC_LOG;
       
   163     TBool retVal( EFalse );
       
   164     TTime universalTime;
       
   165     universalTime.UniversalTime();
       
   166     TTime meetingUniversalTime = aEntry.StartTimeL().TimeUtcL();
       
   167     if ( universalTime  > meetingUniversalTime )
       
   168         {
       
   169         retVal = ETrue;
       
   170         }
       
   171     return retVal;
       
   172     }
       
   173 
       
   174 // ----------------------------------------------------------------------------
       
   175 // ESMREntryHelper::PhoneOwnerAddrL
       
   176 // ----------------------------------------------------------------------------
       
   177 //
       
   178 EXPORT_C const TDesC& ESMREntryHelper::PhoneOwnerAddrL(
       
   179     const CCalEntry& aEntry,
       
   180     CMRMailboxUtils& aUtils )
       
   181     {
       
   182     FUNC_LOG;
       
   183     if ( aUtils.IsOrganizerL( aEntry ) )
       
   184         {
       
   185         return aEntry.OrganizerL()->Address();
       
   186         }
       
   187     else
       
   188         {
       
   189         CCalAttendee* thisAttendee = aUtils.ThisAttendeeL( aEntry  );
       
   190         if ( thisAttendee )
       
   191             {
       
   192             return thisAttendee->Address();
       
   193             }
       
   194         else
       
   195             {
       
   196             return KNullDesC;
       
   197             }
       
   198         }
       
   199     }
       
   200 
       
   201 // ----------------------------------------------------------------------------
       
   202 // ESMREntryHelper::EqualAttendeeL
       
   203 // ----------------------------------------------------------------------------
       
   204 //
       
   205 EXPORT_C CCalAttendee* ESMREntryHelper::EqualAttendeeL(
       
   206     const CCalAttendee& aAttendee,
       
   207     const CCalEntry& aEntry )
       
   208     {
       
   209     FUNC_LOG;
       
   210     TPtrC addr = ESMRHelper::AddressWithoutMailtoPrefix(
       
   211                     aAttendee.Address() );
       
   212 
       
   213     RPointerArray<CCalAttendee>& attendees = aEntry.AttendeesL();
       
   214     TInt count( attendees.Count() );
       
   215     for ( TInt i ( 0 ); i < count; ++i )
       
   216         {
       
   217         TPtrC testAddr =
       
   218             ESMRHelper::AddressWithoutMailtoPrefix(
       
   219                     attendees[i]->Address() );
       
   220 
       
   221         if ( addr.CompareF( testAddr ) == 0 )
       
   222             {
       
   223             return attendees[i];
       
   224             }
       
   225         }
       
   226     return NULL;
       
   227     }
       
   228 
       
   229 // ----------------------------------------------------------------------------
       
   230 // ESMREntryHelper::SpansManyDaysL
       
   231 // ----------------------------------------------------------------------------
       
   232 //
       
   233 EXPORT_C TBool ESMREntryHelper::SpansManyDaysL(
       
   234     const TCalTime& aStartTime,
       
   235     const TCalTime& aEndTime )
       
   236     {
       
   237     FUNC_LOG;
       
   238     TBool retVal( EFalse );
       
   239 
       
   240     // mustn't use UTC time here, local time specifies if the midnight
       
   241     // is crossed
       
   242     TTime localStartTime = aStartTime.TimeLocalL();
       
   243     TTime localEndTime = aEndTime.TimeLocalL();
       
   244 
       
   245     TTimeIntervalDays days = localEndTime.DaysFrom( localStartTime );
       
   246 
       
   247     if ( days.Int() > 0 )
       
   248         {
       
   249         retVal = ETrue;
       
   250         }
       
   251     return retVal;
       
   252     }
       
   253 
       
   254 //  End of File
       
   255