uifw/AvKon/notifsrc/AknSDData.cpp
changeset 0 2f259fa3e83a
child 6 9f56a4e1b8ab
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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 <SecondaryDisplay/AknSecondaryDisplayDefs.h>
       
    19 #include <s32mem.h>
       
    20 #include "aknSDData.h"
       
    21 
       
    22 EXPORT_C void CAknSDData::ExternalizeL(RWriteStream& aStream) const
       
    23     {
       
    24     aStream.WriteInt32L(iCategory.iUid);
       
    25     aStream.WriteInt32L(iDialogIdx);
       
    26     if (iAdditionalData)
       
    27         {
       
    28         aStream.WriteInt32L(iAdditionalData->Length());
       
    29         aStream << *iAdditionalData;            
       
    30         }
       
    31     else 
       
    32         {
       
    33         aStream.WriteInt32L(KErrNotFound);              
       
    34         }    
       
    35     }
       
    36         
       
    37 EXPORT_C void CAknSDData::InternalizeL(RReadStream& aStream)
       
    38     {
       
    39     delete iAdditionalData;
       
    40     iAdditionalData = 0;
       
    41 
       
    42     iCategory.iUid = aStream.ReadInt32L();
       
    43     iDialogIdx = aStream.ReadInt32L();
       
    44     TInt size = aStream.ReadInt32L();
       
    45     if (size != KErrNotFound )
       
    46         {
       
    47         iAdditionalData = HBufC8::NewL(size);
       
    48         TPtr8 ptr (iAdditionalData->Des());
       
    49         aStream >> ptr;
       
    50         }
       
    51     }
       
    52 
       
    53 EXPORT_C void CAknSDData::InsertGlobalListQueryItemIdsL(RArray<TInt>& aIdArray)
       
    54     {
       
    55     TInt count = aIdArray.Count();
       
    56     if (count == 0)
       
    57         {
       
    58         return; // no use to waste mem and time to post nothing
       
    59         }
       
    60     
       
    61     TInt previousLength = iAdditionalData?iAdditionalData->Length():0;
       
    62         
       
    63     HBufC8* newBuf = HBufC8::NewLC((count+2)*4+previousLength);
       
    64     TPtr8 ptr = newBuf->Des();
       
    65     RDesWriteStream strm(ptr);
       
    66     CleanupClosePushL(strm);
       
    67     strm.WriteInt32L(EAknListQueryItemsInfo);
       
    68     strm.WriteInt32L(count);
       
    69     for(TInt i = 0;i < count; i++)
       
    70         {
       
    71         strm.WriteInt32L(aIdArray[i]);
       
    72         }
       
    73 
       
    74     if (previousLength)
       
    75         {
       
    76         strm << *iAdditionalData;        
       
    77         }
       
    78         
       
    79     strm.CommitL();
       
    80     CleanupStack::PopAndDestroy(); // close stream
       
    81     
       
    82     CleanupStack::Pop(); // new buf
       
    83     delete iAdditionalData;
       
    84     iAdditionalData = newBuf;    
       
    85     }
       
    86     
       
    87 // End of file