ximpfw/presence/srcpresencedatamodel/presencepublishing/documentutils.cpp
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     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:  Document utils
       
    15 *
       
    16 */
       
    17 
       
    18 #include "documentutils.h"
       
    19 #include "presenceinfoimp.h"
       
    20 #include "presenceinfofilterimp.h"
       
    21 #include "ximpobjecthelpers.h"
       
    22 
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS =============================
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // DocumentUtils::InfoFilterUnionL()
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 EXPORT_C CPresenceInfoFilterImp* DocumentUtils::InfoFilterUnionL(
       
    31         CPresenceInfoFilterImp& aSource1,
       
    32         CPresenceInfoFilterImp& aSource2 )
       
    33     {
       
    34     RPointerArray< CPresenceInfoFilterImp > array;
       
    35     CleanupClosePushL( array );
       
    36     array.AppendL( &aSource1 );
       
    37     array.AppendL( &aSource2 );
       
    38     CPresenceInfoFilterImp* retVal = InfoFilterUnionL( array );
       
    39     CleanupStack::PopAndDestroy(); // array
       
    40     return retVal;
       
    41     }
       
    42 
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // DocumentUtils::DocumentUnionL()
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C CPresenceInfoFilterImp* DocumentUtils::InfoFilterUnionL(
       
    49         const RPointerArray< CPresenceInfoFilterImp >& aSources )
       
    50     {
       
    51     CPresenceInfoFilterImp* target = NULL;
       
    52     TInt countOfSources = aSources.Count();
       
    53     if( countOfSources == 0 ) // No sources to combine.
       
    54         {
       
    55         target = CPresenceInfoFilterImp::NewLC();
       
    56         CleanupStack::Pop(); // target
       
    57         return target;
       
    58         }
       
    59 
       
    60     // Create a new one instead of cloning the first to avoid possible duplicates.
       
    61     // Algorithm is: given filters a,b,c: 
       
    62     //   new = empty. 
       
    63     //   new = union(new,a)
       
    64     //   new = union(new,b)
       
    65     //   new = union(new,c)
       
    66     // result in new.
       
    67    
       
    68     target = CPresenceInfoFilterImp::NewL();
       
    69 
       
    70     for ( TInt i = 0; i < aSources.Count(); i++ )
       
    71         {
       
    72         CleanupStack::PushL( target );
       
    73 
       
    74         CPresenceInfoFilterImp* filter = aSources[ i ];
       
    75         CPresenceInfoFilterImp* tmp = CPresenceInfoFilterImp::UnionL( *target, *filter );
       
    76 
       
    77         CleanupStack::PopAndDestroy( target );
       
    78 
       
    79         target = tmp;
       
    80         }
       
    81 
       
    82     return target;
       
    83     }
       
    84 
       
    85 
       
    86 EXPORT_C CPresenceInfoImp* DocumentUtils::CollectFilteredPresenceInfoLC(
       
    87         const CPresenceInfoFilterImp& aPif,
       
    88         const CPresenceInfoImp& aSource )
       
    89     {
       
    90     CPresenceInfoImp* newInfo = aSource.FilteredInfoLC( aPif );
       
    91     return newInfo;
       
    92     }
       
    93 
       
    94 // End of file