meetingrequest/mrcalremoteattachment/remoteattachment/src/ccalremoteattachmentinfo.cpp
branchRCL_3
changeset 12 4ce476e64c59
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
       
     1 /*
       
     2 * Copyright (c) 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "ccalremoteattachmentinfo.h"
       
    19 #include "ccalremoteattachment.h"
       
    20 
       
    21 // ======== MEMBER FUNCTIONS ========
       
    22 // ---------------------------------------------------------------------------
       
    23 // CCalRemoteAttachmentInfo::CCalRemoteAttachmentInfo
       
    24 // ---------------------------------------------------------------------------
       
    25 //
       
    26 CCalRemoteAttachmentInfo::CCalRemoteAttachmentInfo()
       
    27     {
       
    28     
       
    29     }
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // CCalRemoteAttachmentInfo::~CCalRemoteAttachmentInfo
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 EXPORT_C CCalRemoteAttachmentInfo::~CCalRemoteAttachmentInfo()
       
    36     {
       
    37     iAttachments.ResetAndDestroy();
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CCalRemoteAttachmentInfo::NewL
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 EXPORT_C CCalRemoteAttachmentInfo* CCalRemoteAttachmentInfo::NewL()
       
    45     {
       
    46     CCalRemoteAttachmentInfo* self = new (ELeave) CCalRemoteAttachmentInfo;
       
    47     CleanupStack::PushL( self );
       
    48     self->ConstructL();
       
    49     CleanupStack::Pop( self );
       
    50     return self;
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CCalRemoteAttachmentInfo::ConstructL
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 void CCalRemoteAttachmentInfo::ConstructL()
       
    58     {
       
    59     
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CCalRemoteAttachmentInfo::AddAttachmentInfoL
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 void CCalRemoteAttachmentInfo::AddAttachmentInfoL(
       
    67         const TDesC& aAttachmentIdentifier,
       
    68         const TDesC& aAttachmentLabel,
       
    69         TInt aAttachmentSizeInBytes,
       
    70         MCalRemoteAttachment::TCalRemoteAttachmentState aState )
       
    71     {
       
    72     CCalRemoteAttachment* attachment = 
       
    73             CCalRemoteAttachment::NewL(
       
    74                 aAttachmentIdentifier,
       
    75                 aAttachmentLabel,
       
    76                 aAttachmentSizeInBytes,
       
    77                 aState );
       
    78     
       
    79     CleanupStack::PushL( attachment );
       
    80     
       
    81     // Ownership is transferred
       
    82     iAttachments.AppendL( attachment );
       
    83     
       
    84     CleanupStack::Pop( attachment );
       
    85     }
       
    86  
       
    87 // ---------------------------------------------------------------------------
       
    88 // CCalRemoteAttachmentInfo::AddAttachmentInfoL
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void CCalRemoteAttachmentInfo::AddAttachmentInfoL(
       
    92          MCalRemoteAttachment* aAttachment )
       
    93     {
       
    94     // Ownership is transferred
       
    95     iAttachments.AppendL( aAttachment );    
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CCalRemoteAttachmentInfo::AttachmentCount
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 TInt CCalRemoteAttachmentInfo::AttachmentCount() const
       
   103     {
       
   104     return iAttachments.Count();
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CCalRemoteAttachmentInfo::AttachmentL
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 const MCalRemoteAttachment& CCalRemoteAttachmentInfo::AttachmentL(
       
   112          TInt aIndex ) const
       
   113      {
       
   114      return *iAttachments[ aIndex ];
       
   115      }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // CCalRemoteAttachmentInfo::RemoveAttachmentAtL
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 void CCalRemoteAttachmentInfo::RemoveAttachmentAtL(
       
   122          TInt aIndex )
       
   123     {
       
   124     if ( aIndex < iAttachments.Count() && aIndex >= 0 )
       
   125         {
       
   126         MCalRemoteAttachment* attachment = iAttachments[ aIndex ];
       
   127         iAttachments.Remove( aIndex );
       
   128         delete attachment;
       
   129         }
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // CCalRemoteAttachmentInfo::RemoveAttachmentL
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 void CCalRemoteAttachmentInfo::RemoveAttachmentL(
       
   137          MCalRemoteAttachment& aAttachment )
       
   138     {
       
   139     TInt pos( iAttachments.Find( &aAttachment ) );
       
   140     if ( KErrNotFound == pos )
       
   141         {
       
   142         User::Leave( KErrNotFound );
       
   143         }
       
   144     
       
   145     RemoveAttachmentAtL( pos );
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CCalRemoteAttachmentInfo::Attachments
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 const RPointerArray<MCalRemoteAttachment>& 
       
   153         CCalRemoteAttachmentInfo::Attachments() const
       
   154     {
       
   155     return iAttachments;
       
   156     }
       
   157 
       
   158 // EOF