pimappservices/calendar/shared/src/agmfilechangenotification.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <s32strm.h>
       
    17 
       
    18 #include "agmcalendarinfo.h"
       
    19 #include "agmfilechangenotification.h"
       
    20 
       
    21 /* Allocates and constructs a CAgnFileChangeInfo.
       
    22  * It takes the ownership of aFileName 
       
    23  */
       
    24 EXPORT_C CAgnFileChangeInfo* CAgnFileChangeInfo::NewL(HBufC* aFileName, MCalFileChangeObserver::TChangeType aChangeType)
       
    25     {
       
    26     CAgnFileChangeInfo* self = new (ELeave) CAgnFileChangeInfo(aFileName, aChangeType);
       
    27     return self;    
       
    28     }
       
    29 
       
    30 EXPORT_C CAgnFileChangeInfo* CAgnFileChangeInfo::NewL(RReadStream& aReadStream)
       
    31     {
       
    32     CAgnFileChangeInfo* self = new(ELeave) CAgnFileChangeInfo();
       
    33     CleanupStack::PushL(self);
       
    34     self->InternalizeL(aReadStream);
       
    35     CleanupStack::Pop(self);
       
    36     return self;   
       
    37     }
       
    38 
       
    39 EXPORT_C CAgnFileChangeInfo::~CAgnFileChangeInfo()
       
    40     {
       
    41     delete iCalendarFileName;
       
    42     }
       
    43  
       
    44  /** Get the file name of the file that has changed */
       
    45 EXPORT_C const TDesC& CAgnFileChangeInfo::FileNameL() const
       
    46     {
       
    47     if(!iCalendarFileName)
       
    48         {
       
    49         return KNullDesC;
       
    50         }
       
    51     return *iCalendarFileName;
       
    52     }
       
    53  
       
    54  /** Get the type of change that happened to the file */
       
    55 EXPORT_C MCalFileChangeObserver::TChangeType CAgnFileChangeInfo::ChangeType() const
       
    56     {
       
    57     return iChangeType;
       
    58     }
       
    59 
       
    60 EXPORT_C void CAgnFileChangeInfo::InternalizeL(RReadStream& aReadStream)
       
    61     {
       
    62     iChangeType = static_cast<MCalFileChangeObserver::TChangeType>(aReadStream.ReadInt32L());
       
    63     iCalendarFileName = HBufC::NewL(aReadStream, KMaxTInt);
       
    64     }
       
    65 
       
    66 EXPORT_C void CAgnFileChangeInfo::ExternalizeL(RWriteStream& aWriteStream) const
       
    67     {
       
    68     aWriteStream.WriteInt32L(iChangeType);
       
    69     aWriteStream << *iCalendarFileName;
       
    70     }
       
    71 
       
    72 CAgnFileChangeInfo::CAgnFileChangeInfo(HBufC* aFileName, MCalFileChangeObserver::TChangeType aChangeType)
       
    73     :iCalendarFileName(aFileName),
       
    74     iChangeType(aChangeType)
       
    75     {   
       
    76     }
       
    77 
       
    78 CAgnFileChangeInfo::CAgnFileChangeInfo()
       
    79     {
       
    80     }
       
    81