|
1 /* |
|
2 * Copyright (c) 2002 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: History entry |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <s32mem.h> |
|
20 #include <SyncMLHistory.h> |
|
21 #include <SyncMLAlertInfo.h> |
|
22 |
|
23 // --------------------------------------------------------- |
|
24 // CSyncMLHistoryEntry::CSyncMLHistoryEntry(TUid aUid) |
|
25 // Constructor |
|
26 // --------------------------------------------------------- |
|
27 CSyncMLHistoryEntry::CSyncMLHistoryEntry(TUid aUid) |
|
28 : iEntryType(aUid), iEntryId(0), iSpare(0) |
|
29 { |
|
30 } |
|
31 |
|
32 // --------------------------------------------------------- |
|
33 // CSyncMLHistoryEntry::NewL(TUid aEntryType) |
|
34 // Two phase constructor |
|
35 // --------------------------------------------------------- |
|
36 EXPORT_C CSyncMLHistoryEntry* CSyncMLHistoryEntry::NewL(TUid aEntryType) |
|
37 { |
|
38 if (aEntryType == KUidSmlHistoryEntryJob) |
|
39 { |
|
40 CSyncMLHistoryJob* self =CSyncMLHistoryJob::NewL(); |
|
41 return self; |
|
42 } |
|
43 else |
|
44 if (aEntryType == KUidSmlHistoryEntryPushMsg) |
|
45 { |
|
46 CSyncMLHistoryPushMsg* self = CSyncMLHistoryPushMsg::NewL(); |
|
47 return self; |
|
48 } |
|
49 |
|
50 return NULL; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // CSyncMLHistoryEntry::NewL(RReadStream& aStream) |
|
55 // Two phase constructor |
|
56 // --------------------------------------------------------- |
|
57 EXPORT_C CSyncMLHistoryEntry* CSyncMLHistoryEntry::NewL(RReadStream& aStream) |
|
58 { |
|
59 const TInt entryType = aStream.ReadInt32L(); |
|
60 |
|
61 TUid entryUid; |
|
62 entryUid.iUid = entryType; |
|
63 |
|
64 CSyncMLHistoryEntry* self = CSyncMLHistoryEntry::NewL(entryUid); |
|
65 CleanupStack::PushL(self); |
|
66 self->InternalizeL(aStream); |
|
67 CleanupStack::Pop(); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------- |
|
72 // CSyncMLHistoryEntry::NewL(const CSyncMLHistoryEntry& aEntry) |
|
73 // Two phase constructor |
|
74 // --------------------------------------------------------- |
|
75 EXPORT_C CSyncMLHistoryEntry* CSyncMLHistoryEntry::NewL(const CSyncMLHistoryEntry& aEntry) |
|
76 { |
|
77 TUid entryType = aEntry.EntryType(); |
|
78 |
|
79 CSyncMLHistoryEntry* entry = CSyncMLHistoryEntry::NewL(aEntry.iEntryType); |
|
80 CleanupStack::PushL(entry); |
|
81 |
|
82 CBufBase* buffer = CBufFlat::NewL(1024); |
|
83 CleanupStack::PushL(buffer); |
|
84 |
|
85 RBufWriteStream writeStream(*buffer); |
|
86 writeStream.PushL(); |
|
87 aEntry.ExternalizeL(writeStream); |
|
88 writeStream.CommitL(); |
|
89 |
|
90 CleanupStack::PopAndDestroy(); //writeStream |
|
91 |
|
92 RBufReadStream readStream(*buffer); |
|
93 readStream.PushL(); |
|
94 entry->InternalizeL(readStream); |
|
95 |
|
96 CleanupStack::PopAndDestroy(2); //readStream, buffer |
|
97 CleanupStack::Pop(); //entry |
|
98 |
|
99 return entry; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------- |
|
103 // CSyncMLHistoryEntry::~CSyncMLHistoryEntry() |
|
104 // Destructor |
|
105 // --------------------------------------------------------- |
|
106 EXPORT_C CSyncMLHistoryEntry::~CSyncMLHistoryEntry() |
|
107 { |
|
108 |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------- |
|
112 // CSyncMLHistoryEntry::ExternalizeL(RWriteStream& aStream) const |
|
113 // Writes entry to given stream |
|
114 // --------------------------------------------------------- |
|
115 EXPORT_C void CSyncMLHistoryEntry::ExternalizeL(RWriteStream& aStream) const |
|
116 { |
|
117 aStream.WriteInt32L( iEntryType.iUid ); |
|
118 aStream.WriteInt32L( iEntryId ); |
|
119 aStream.WriteInt32L( iSpare ); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // CSyncMLHistoryEntry::EntryType() const |
|
124 // Returns entry type identifier |
|
125 // --------------------------------------------------------- |
|
126 EXPORT_C TUid CSyncMLHistoryEntry::EntryType() const |
|
127 { |
|
128 return iEntryType; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------- |
|
132 // CSyncMLHistoryEntry::EntryId() const |
|
133 // Returns entry identifier |
|
134 // --------------------------------------------------------- |
|
135 EXPORT_C TInt CSyncMLHistoryEntry::EntryId() const |
|
136 { |
|
137 return iEntryId; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------- |
|
141 // CSyncMLHistoryEntry::DoDynamicCast(TUid aEntryType, CSyncMLHistoryEntry* aEntry) |
|
142 // Checks is entry is valid. |
|
143 // --------------------------------------------------------- |
|
144 EXPORT_C CSyncMLHistoryEntry* CSyncMLHistoryEntry::DoDynamicCast(TUid aEntryType, CSyncMLHistoryEntry* aEntry) |
|
145 { |
|
146 if (aEntryType != aEntry->EntryType()) |
|
147 { |
|
148 return NULL; |
|
149 } |
|
150 |
|
151 return aEntry; |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------- |
|
155 // CSyncMLHistoryEntry::DoDynamicCast(TUid aEntryType, const CSyncMLHistoryEntry* aEntry) |
|
156 // Checks is entry is valid. |
|
157 // --------------------------------------------------------- |
|
158 EXPORT_C const CSyncMLHistoryEntry* CSyncMLHistoryEntry::DoDynamicCast(TUid aEntryType, const CSyncMLHistoryEntry* aEntry) |
|
159 { |
|
160 if (aEntryType != aEntry->EntryType()) |
|
161 { |
|
162 return NULL; |
|
163 } |
|
164 |
|
165 return aEntry; |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------- |
|
169 // CSyncMLHistoryEntry::SetEntryId(TInt aEntryId) |
|
170 // Sets entry identifier |
|
171 // --------------------------------------------------------- |
|
172 EXPORT_C void CSyncMLHistoryEntry::SetEntryId(TInt aEntryId) |
|
173 { |
|
174 iEntryId = aEntryId; |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------- |
|
178 // CSyncMLHistoryEntry::Reserved(TUid) |
|
179 // Reserved for future use |
|
180 // --------------------------------------------------------- |
|
181 EXPORT_C TAny* CSyncMLHistoryEntry::Reserved(TUid) |
|
182 { |
|
183 return 0; |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------- |
|
187 // CSyncMLHistoryEntry::InternalizeL(RReadStream& aStream) |
|
188 // Reads item from stream |
|
189 // --------------------------------------------------------- |
|
190 void CSyncMLHistoryEntry::InternalizeL(RReadStream& aStream) |
|
191 { |
|
192 iEntryId = aStream.ReadInt32L(); |
|
193 iSpare = aStream.ReadInt32L(); |
|
194 } |