|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 #include <comms-infras/metatype.h> |
|
22 #include <comms-infras/es_commsdataobject.h> |
|
23 |
|
24 |
|
25 #ifdef _DEBUG |
|
26 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
27 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
28 _LIT(KSpecAssert_ESockCSockcscmsd, "ESockCSockcscmsd"); |
|
29 #endif |
|
30 |
|
31 using namespace ESock; |
|
32 |
|
33 // No type Id since this class must be derived from. |
|
34 // We deliberately do not register the attributes of this base class for |
|
35 // serialization (with the exception of the iOperationMode member). |
|
36 // They will be provided by the the c'tor of the deriving class. |
|
37 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(XCommsDataObject, 0, 0) |
|
38 REGISTER_ATTRIBUTE(XCommsDataObject, iOperationMode, TMeta<TUint>) |
|
39 END_ATTRIBUTE_TABLE() |
|
40 |
|
41 |
|
42 |
|
43 EXPORT_C CCommsDataObjectBase* CCommsDataObjectBase::NewL(XCommsDataObject* aDataObject) |
|
44 { |
|
45 if (!aDataObject) |
|
46 { |
|
47 User::Leave(KErrArgument); |
|
48 } |
|
49 return new (ELeave)CCommsDataObjectBase(aDataObject); |
|
50 } |
|
51 |
|
52 |
|
53 EXPORT_C CCommsDataObjectBase* CCommsDataObjectBase::LoadL(TPtrC8& aBuffer) |
|
54 { |
|
55 CCommsDataObjectBase* self = new (ELeave)CCommsDataObjectBase(NULL); |
|
56 CleanupStack::PushL(self); |
|
57 User::LeaveIfError(self->Load(aBuffer)); |
|
58 CleanupStack::Pop(); |
|
59 return self; |
|
60 } |
|
61 |
|
62 |
|
63 EXPORT_C CCommsDataObjectBase::CCommsDataObjectBase(XCommsDataObject* aDataObject) |
|
64 : iDataObject(aDataObject) |
|
65 { |
|
66 } |
|
67 |
|
68 |
|
69 EXPORT_C CCommsDataObjectBase::~CCommsDataObjectBase() |
|
70 { |
|
71 delete iDataObject; |
|
72 } |
|
73 |
|
74 |
|
75 EXPORT_C TInt CCommsDataObjectBase::Load(TPtrC8& aBuffer) |
|
76 { |
|
77 XCommsDataObject* newDataObject = NULL; |
|
78 TRAPD(err, newDataObject = static_cast<XCommsDataObject*>(XCommsDataObject::LoadL(aBuffer))); |
|
79 if (err == KErrNone) |
|
80 { |
|
81 delete iDataObject; |
|
82 iDataObject = newDataObject; |
|
83 } |
|
84 return err; |
|
85 } |
|
86 |
|
87 |
|
88 EXPORT_C TInt CCommsDataObjectBase::Store(TDes8& aBuffer) const |
|
89 { |
|
90 return iDataObject->Store(aBuffer); |
|
91 } |
|
92 |
|
93 |
|
94 EXPORT_C void CCommsDataObjectBase::Copy(const TAny* aData) |
|
95 { |
|
96 __ASSERT_DEBUG(aData, User::Panic(KSpecAssert_ESockCSockcscmsd, 1)); |
|
97 const CCommsDataObjectBase* srcData = reinterpret_cast<const CCommsDataObjectBase*>(aData); |
|
98 iDataObject->Copy(*srcData->iDataObject); |
|
99 } |
|
100 |
|
101 |
|
102 EXPORT_C TInt CCommsDataObjectBase::Length() const |
|
103 { |
|
104 return iDataObject->Length(); |
|
105 } |
|
106 |