1128 TRAP(err,iNpdDb->GetNoteL(aUid, *note)); |
1128 TRAP(err,iNpdDb->GetNoteL(aUid, *note)); |
1129 if(err == KErrNone) |
1129 if(err == KErrNone) |
1130 { |
1130 { |
1131 _NOTEPAD_DBG_FILE("CNSmlNotepadDataStore:: FetchItemL(): begin"); |
1131 _NOTEPAD_DBG_FILE("CNSmlNotepadDataStore:: FetchItemL(): begin"); |
1132 |
1132 |
1133 HBufC8* buf = ConvertNoteToSyncItemL(*note); |
1133 HBufC8* buf = NULL; |
1134 CleanupStack::PushL(buf); |
1134 TRAP(err, buf = ConvertNoteToSyncItemL(*note)); |
1135 aItem.Reset(); |
1135 if(err == KErrNone) |
1136 // Write the buffer to the passed writeStream (aItem) |
1136 { |
1137 TBufBuf bufBuf; |
1137 CleanupStack::PushL(buf); |
1138 bufBuf.Set(aItem, 0, TBufBuf::EWrite); |
1138 aItem.Reset(); |
1139 RWriteStream writeStream( &bufBuf); |
1139 // Write the buffer to the passed writeStream (aItem) |
1140 writeStream.PushL(); |
1140 TBufBuf bufBuf; |
1141 writeStream.WriteL(buf->Des().Ptr(), buf->Des().Length()); |
1141 bufBuf.Set(aItem, 0, TBufBuf::EWrite); |
1142 writeStream.CommitL(); |
1142 RWriteStream writeStream( &bufBuf); |
1143 CleanupStack::PopAndDestroy(1);//writeStream |
1143 writeStream.PushL(); |
1144 CleanupStack::PopAndDestroy(buf);//buf |
1144 writeStream.WriteL(buf->Des().Ptr(), buf->Des().Length()); |
1145 _NOTEPAD_DBG_FILE("CNSmlNotepadDataStore::FetchItemL(): end"); |
1145 writeStream.CommitL(); |
1146 } |
1146 CleanupStack::PopAndDestroy(1);//writeStream |
|
1147 CleanupStack::PopAndDestroy(buf);//buf |
|
1148 _NOTEPAD_DBG_FILE("CNSmlNotepadDataStore::FetchItemL(): end"); |
|
1149 } |
|
1150 } |
1147 CleanupStack::PopAndDestroy(note); // note |
1151 CleanupStack::PopAndDestroy(note); // note |
1148 } |
1152 } |
1149 else |
1153 else |
1150 { |
1154 { |
1151 err = KErrNotReady; |
1155 err = KErrNotReady; |
1196 // ---------------------------------------------------------------------------- |
1200 // ---------------------------------------------------------------------------- |
1197 HBufC8* CNSmlNotepadDataStore::ConvertNoteToSyncItemL(CNpdItem& aNote) |
1201 HBufC8* CNSmlNotepadDataStore::ConvertNoteToSyncItemL(CNpdItem& aNote) |
1198 { |
1202 { |
1199 if (!aNote.Content()) |
1203 if (!aNote.Content()) |
1200 { |
1204 { |
1201 HBufC8* tempHBuf = HBufC8::NewL(KNullCharLen);//room for null character |
1205 User::Leave(KErrGeneral); |
1202 return tempHBuf; |
|
1203 } |
1206 } |
1204 // Note: a single unicode character can be 4 bytes long in UTF8 format, |
1207 // Note: a single unicode character can be 4 bytes long in UTF8 format, |
1205 // hence the long length for 8-bit buffer. |
1208 // hence the long length for 8-bit buffer. |
1206 TInt length = (aNote.Content()->Length()) * KUTF8Lenght; |
1209 TInt length = (aNote.Content()->Length()) * KUTF8Lenght; |
1207 HBufC8* tempHBuf = HBufC8::NewLC(length + KNullCharLen); |
1210 HBufC8* tempHBuf = HBufC8::NewLC(length + KNullCharLen); |