1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
109 @leave if non memory or StartL leaves |
106 @leave if non memory or StartL leaves |
110 */ |
107 */ |
111 void CSqlBackupClient::ConstructL() |
108 void CSqlBackupClient::ConstructL() |
112 { |
109 { |
113 // attach to backup/restore publish/subscribe property |
110 // attach to backup/restore publish/subscribe property |
114 __SQLLEAVE_IF_ERROR(iProperty.Attach(KUidSystemCategory,KUidBackupRestoreKey)); |
111 __SQLLEAVE_IF_ERROR(iBurProperty.Attach(KUidSystemCategory,KUidBackupRestoreKey)); |
115 |
112 |
116 // add us to the scheduler |
113 // add us to the scheduler |
117 CActiveScheduler::Add(this); |
114 CActiveScheduler::Add(this); |
118 |
115 |
119 // set active and request notification of changes to backup |
116 // set active and request notification of changes to backup |
120 // and restore publish/subscribe property |
117 // and restore publish/subscribe property |
121 StartL(); |
118 StartL(); |
122 } |
119 } |
123 |
120 |
124 /** Nuke outstanding requests |
121 /** |
|
122 Cancel the outstanding B&R request |
125 */ |
123 */ |
126 void CSqlBackupClient::DoCancel() |
124 void CSqlBackupClient::DoCancel() |
127 { |
125 { |
128 // lose any oustanding reqs |
126 iBurProperty.Cancel(); |
129 iProperty.Cancel(); |
|
130 } |
127 } |
131 |
128 |
132 /** Not implemented |
129 /** Not implemented |
133 @return a flag indicating whether we actioned the error |
130 @return a flag indicating whether we actioned the error |
134 @param the error unused |
131 @param the error unused |
150 |
147 |
151 /** Resubscribe and wait for events |
148 /** Resubscribe and wait for events |
152 */ |
149 */ |
153 void CSqlBackupClient::NotifyChange() |
150 void CSqlBackupClient::NotifyChange() |
154 { |
151 { |
155 iProperty.Subscribe(iStatus); |
152 iBurProperty.Subscribe(iStatus); |
156 SetActive(); |
153 SetActive(); |
157 } |
154 } |
158 |
155 |
159 /** Something happened. Find out what. |
156 /** Something happened. Find out what. |
160 Create an instance of BUR client if required |
157 Create an instance of BUR client if required |
163 @leave if ConfirmReadyForBURL leaves |
160 @leave if ConfirmReadyForBURL leaves |
164 */ |
161 */ |
165 void CSqlBackupClient::TestBurStatusL() |
162 void CSqlBackupClient::TestBurStatusL() |
166 { |
163 { |
167 TInt status; |
164 TInt status; |
168 if(iProperty.Get(status)!=KErrNotFound) |
165 if(iBurProperty.Get(status)!=KErrNotFound) |
169 { |
166 { |
170 status&=KBURPartTypeMask; |
167 status&=KBURPartTypeMask; |
171 switch(status) |
168 switch(status) |
172 { |
169 { |
173 case EBURUnset: // same as EBURNormal |
170 case EBURUnset: // same as EBURNormal |
833 //available data will be copied to the output buffer. |
824 //available data will be copied to the output buffer. |
834 // |
825 // |
835 //Attention!!! This function won't work properly if aInBuf parameter contains odd number of bytes!!! |
826 //Attention!!! This function won't work properly if aInBuf parameter contains odd number of bytes!!! |
836 //(a legacy problem, if it is a problem at all, because the B&R engine probably sends the data in chunks with even size) |
827 //(a legacy problem, if it is a problem at all, because the B&R engine probably sends the data in chunks with even size) |
837 // |
828 // |
|
829 //How the function works. It is called during the restore process and aInBuf parameter contains a block of raw |
|
830 //data sent by the B&R server. The calling function, RestoreBaseDataSectionL(), uses a state |
|
831 //machine to processes the incoming data. At particular moment RestoreBaseDataSectionL() will process the data header |
|
832 //and will have to read "aDataLen" 16-bit characters at position "aInBufReadPos". If there are "aDataLen" characters |
|
833 //at position "aInBufReadPos" and enough free space in "aOutBuf", CopyBufData() will copy all of them, |
|
834 //otherwise CopyBufData() will copy as much characters as possible (in which case RestoreBaseDataSectionL() will |
|
835 //stay in the same state, waiting for more data from the B&R server). |
|
836 // |
838 void CSqlBackupClient::CopyBufData(const TDesC8& aInBuf, TInt& aInBufReadPos, TDes& aOutBuf, TInt aDataLen) |
837 void CSqlBackupClient::CopyBufData(const TDesC8& aInBuf, TInt& aInBufReadPos, TDes& aOutBuf, TInt aDataLen) |
839 { |
838 { |
840 __SQLASSERT(aInBufReadPos >= 0, ESqlPanicBadArgument); |
839 __SQLASSERT(aInBufReadPos >= 0, ESqlPanicBadArgument); |
841 __SQLASSERT(aDataLen > 0, ESqlPanicBadArgument); |
840 __SQLASSERT(aDataLen > 0, ESqlPanicBadArgument); |
|
841 __SQLASSERT(!(aInBuf.Length() & 0x01), ESqlPanicInternalError); |
842 |
842 |
843 TInt needed = (aDataLen - aOutBuf.Length()) << K8to16bitShift; |
843 TInt needed = (aDataLen - aOutBuf.Length()) << K8to16bitShift; |
844 TInt available = aInBuf.Size() - aInBufReadPos; |
844 TInt available = aInBuf.Size() - aInBufReadPos; |
845 TInt len = Min(needed, available); |
845 TInt len = Min(needed, available); |
846 TPtrC8 ptr8 = aInBuf.Mid(aInBufReadPos, len); |
846 TPtrC8 ptr8 = aInBuf.Mid(aInBufReadPos, len); |