63
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Helpers for handling objects
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <mpresencebuddyinfo2.h>
|
|
20 |
#include "cacheobjecthelpers.h"
|
|
21 |
#include "presenceobjecthelpers.h"
|
|
22 |
#include "presencecachebuddyinfo.h"
|
|
23 |
|
|
24 |
// ==================== TPresenceArrayPacker MEMBER FUNCTIONS ====================
|
|
25 |
|
|
26 |
// -----------------------------------------------------------------------------
|
|
27 |
// TPresenceArrayPacker::PackArrayL()
|
|
28 |
// -----------------------------------------------------------------------------
|
|
29 |
//
|
|
30 |
EXPORT_C HBufC8* TPresenceArrayPacker::PackArrayL( const RPointerArray< MPresenceBuddyInfo2 >& aBufferArray )
|
|
31 |
{
|
|
32 |
CBufFlat* packBuf = CBufFlat::NewL( KObjectBufGranurality );
|
|
33 |
CleanupStack::PushL( packBuf );
|
|
34 |
|
|
35 |
RBufWriteStream ws;
|
|
36 |
ws.Open( *packBuf ); // CSI: 65 #
|
|
37 |
CleanupClosePushL( ws );
|
|
38 |
|
|
39 |
// Get count of objects
|
|
40 |
TInt objCount( aBufferArray.Count() );
|
|
41 |
// write the count
|
|
42 |
ws.WriteInt32L( objCount );
|
|
43 |
// objects
|
|
44 |
MPresenceBuddyInfo2* info = NULL;
|
|
45 |
for ( TInt count(0); count < objCount; count++ )
|
|
46 |
{
|
|
47 |
info = aBufferArray[ count ];
|
|
48 |
info->ExternalizeL( ws );
|
|
49 |
}
|
|
50 |
|
|
51 |
ws.CommitL();
|
|
52 |
CleanupStack::PopAndDestroy(); //ws
|
|
53 |
|
|
54 |
HBufC8* packBufDesc = packBuf->Ptr(0).AllocL();
|
|
55 |
CleanupStack::PopAndDestroy( packBuf );
|
|
56 |
|
|
57 |
return packBufDesc;
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
// TPresenceArrayPacker::UnPackArrayL()
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
//
|
|
65 |
EXPORT_C void TPresenceArrayPacker::UnPackArrayL( RPointerArray< MPresenceBuddyInfo2 >& aBufferArray, const TDesC8& aPack )
|
|
66 |
{
|
|
67 |
CleanupResetAndDestroyPushL( aBufferArray );
|
|
68 |
// No reset
|
|
69 |
if ( ! aPack.Length() )
|
|
70 |
{
|
|
71 |
// empty, don't attempt to unpack
|
|
72 |
return;
|
|
73 |
}
|
|
74 |
|
|
75 |
RDesReadStream rs;
|
|
76 |
CleanupClosePushL( rs );
|
|
77 |
rs.Open( aPack ); // CSI: 65 #
|
|
78 |
|
|
79 |
// read the object count
|
|
80 |
TInt objCount( rs.ReadInt32L() );
|
|
81 |
|
|
82 |
MPresenceBuddyInfo2* info = NULL;
|
|
83 |
|
|
84 |
for ( TInt count = 0; count < objCount; count++ )
|
|
85 |
{
|
|
86 |
info = MPresenceBuddyInfo2::NewLC();
|
|
87 |
info->InternalizeL( rs );
|
|
88 |
aBufferArray.AppendL( info );
|
|
89 |
CleanupStack::Pop();
|
|
90 |
}
|
|
91 |
CleanupStack::PopAndDestroy(); // rs
|
|
92 |
CleanupStack::Pop( &aBufferArray );
|
|
93 |
}
|
|
94 |
|
|
95 |
|
|
96 |
// -----------------------------------------------------------------------------
|
|
97 |
// PresenceCacheBuddyUtils::ResetBuddyInfoTimeStamp()
|
|
98 |
// -----------------------------------------------------------------------------
|
|
99 |
//
|
|
100 |
EXPORT_C void PresenceCacheBuddyUtils::ResetBuddyInfoTimeStamp(
|
|
101 |
MPresenceBuddyInfo2& aBuddy)
|
|
102 |
{
|
|
103 |
static_cast<CPresenceCacheBuddyInfo*>(&aBuddy)->ResetTimeStamp();
|
|
104 |
}
|
|
105 |
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
// PresenceCacheBuddyUtils::IsBuddyInfoExpired()
|
|
108 |
// -----------------------------------------------------------------------------
|
|
109 |
//
|
|
110 |
EXPORT_C TBool PresenceCacheBuddyUtils::IsBuddyInfoExpired(
|
|
111 |
const MPresenceBuddyInfo2& aBuddy)
|
|
112 |
{
|
|
113 |
return static_cast<const CPresenceCacheBuddyInfo*>(&aBuddy)->IsExpired();
|
|
114 |
}
|
|
115 |
|
|
116 |
|
|
117 |
// End of file
|