meetingui/attendeeview/EngSrc/AttendeeParser.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Provides methods for Attendee View's parser class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "AttendeeParser.h"
       
    22 #include "CAttendeeItemList.h"
       
    23 #include "CAttendeeItem.h"
       
    24 #include <calentry.h>
       
    25 #include <caluser.h>
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ==============================
       
    28 // ---------------------------------------------------------
       
    29 // AttendeeParser::ParseAgnEntryL
       
    30 // ---------------------------------------------------------
       
    31 //
       
    32 void AttendeeParser::ParseAgnEntryL( CCalEntry& aCalEntry,
       
    33 									 CAttendeeItemList& aAttendees )
       
    34 	{
       
    35            
       
    36     //Create internal attendee for organizer
       
    37     CCalAttendee* organizer = CCalAttendee::NewL(
       
    38                                     aCalEntry.OrganizerL()->Address() );       
       
    39     CleanupStack::PushL( organizer );                  
       
    40     organizer->SetCommonNameL( aCalEntry.OrganizerL()->CommonName() );    
       
    41         
       
    42     //Take ownership
       
    43     CAttendeeItem* organizerItem = CAttendeeItem::NewL( organizer );
       
    44     organizerItem->SetOwnership( ETrue );
       
    45     CleanupStack::Pop( organizer );                   
       
    46     CleanupStack::PushL( organizerItem );                        
       
    47     aAttendees.InsertL( organizerItem, 0);        
       
    48     organizerItem->SetOrganizerStatus( ETrue );    
       
    49     CleanupStack::Pop( organizerItem );
       
    50          
       
    51     //This count doesn't include organizer
       
    52     const TInt count( aCalEntry.AttendeesL().Count() );    
       
    53     TInt requiresIndex( 1 );//starts after organizer     
       
    54     for( TInt j( 0 ); j < count; ++j )
       
    55         {
       
    56         CAttendeeItem* item = CAttendeeItem::NewLC(
       
    57                                 (aCalEntry.AttendeesL())[j] );
       
    58      
       
    59         
       
    60          if ( item->AttendanceL() == CAttendeeItem::ERequire )
       
    61             {
       
    62             aAttendees.InsertL( item, requiresIndex );            
       
    63             ++requiresIndex;            
       
    64             }
       
    65          else //Optional
       
    66             {
       
    67             aAttendees.AppendL( item );
       
    68             }
       
    69        
       
    70         CleanupStack::Pop( item ); //item
       
    71         }
       
    72 	}
       
    73 
       
    74 // ---------------------------------------------------------
       
    75 // AttendeeParser::UpdateAgnEntryL
       
    76 // ---------------------------------------------------------
       
    77 //
       
    78 void AttendeeParser::UpdateAgnEntryL( CCalEntry& aCalEntry,
       
    79                               		  CAttendeeItemList& aAttendees,
       
    80                               		  CAttendeeItemList& aDeleted )
       
    81     {
       
    82     //Remove deleted attendees from CCalEntry
       
    83     RemoveDeletedL( aCalEntry, aDeleted );
       
    84 
       
    85     //Insert new attendees to CCalEntry. Organizer that is added to internal
       
    86     //attendee list should not be added because is already in the cal entry.
       
    87     const TInt count( aAttendees.Count() );
       
    88     for ( TInt i( 0 ); i < count; ++i )
       
    89         {
       
    90         CAttendeeItem* item = aAttendees.At( i );
       
    91         if ( item && item->Ownership() && !item->IsOrganizer())
       
    92             {            
       
    93             //change ownership
       
    94             item->SetOwnership( EFalse );
       
    95             //take ownership in the first line                             
       
    96             aCalEntry.AddAttendeeL( item->AgnAttendee() );                            
       
    97             }
       
    98         }                
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // AttendeeParser::RemoveDeletedL
       
   103 // ---------------------------------------------------------
       
   104 //
       
   105 void AttendeeParser::RemoveDeletedL( CCalEntry& aCalEntry,
       
   106                             		 CAttendeeItemList& aDeleted )
       
   107     {
       
   108     const TInt count( aDeleted.Count() );
       
   109     TInt attCount( 0 );
       
   110     for ( TInt i( 0 ); i < count; ++i )
       
   111         {
       
   112         CAttendeeItem* item = aDeleted.At( i );
       
   113         if ( item )
       
   114             {
       
   115             CCalAttendee* attendee = item->AgnAttendee();
       
   116             attCount = aCalEntry.AttendeesL().Count();
       
   117             for ( TInt j( 0 ); j < attCount; ++j )
       
   118                 {
       
   119                 if ( attendee && attendee == (aCalEntry.AttendeesL())[j])
       
   120                     {               
       
   121                     //copy CCalUser to CAttendeeItem and then delete it
       
   122                     CCalAttendee* copy = CCalAttendee::NewL( attendee->Address(),
       
   123                                                              attendee->SentBy());
       
   124                     
       
   125                     CleanupStack::PushL( copy );
       
   126               
       
   127                     copy->SetCommonNameL( attendee->CommonName() );
       
   128                     copy->SetRoleL( attendee->RoleL() );
       
   129                     copy->SetStatusL( attendee->StatusL() );
       
   130                     copy->SetResponseRequested( attendee->ResponseRequested() );
       
   131                                    
       
   132                     item->SetAgnAttendee( copy );
       
   133                     item->SetOwnership( ETrue );
       
   134                     CleanupStack::Pop( copy );
       
   135                     aCalEntry.DeleteAttendeeL( j );
       
   136                     break;
       
   137                     }
       
   138                 }
       
   139             }
       
   140         }
       
   141     }
       
   142 
       
   143 // End of File