equal
deleted
inserted
replaced
17 |
17 |
18 package com.nokia.mid.iapinfo; |
18 package com.nokia.mid.iapinfo; |
19 |
19 |
20 import com.nokia.mj.impl.rt.support.Finalizer; |
20 import com.nokia.mj.impl.rt.support.Finalizer; |
21 import com.nokia.mj.impl.gcf.utils.NativeError; |
21 import com.nokia.mj.impl.gcf.utils.NativeError; |
22 import com.nokia.mj.impl.utils.Logger; |
|
23 |
22 |
24 //import com.nokia.mj.impl.vmport.VmPort; |
23 //import com.nokia.mj.impl.vmport.VmPort; |
25 |
24 |
26 /** |
25 /** |
27 * <p> |
26 * <p> |
130 public CommsTable(String tableName) throws CommDBException |
129 public CommsTable(String tableName) throws CommDBException |
131 { |
130 { |
132 |
131 |
133 iTableName = tableName; |
132 iTableName = tableName; |
134 |
133 |
|
134 // create native peer |
|
135 iHandle = _construct(); |
|
136 if (iHandle < NativeError.KErrNone) |
|
137 { |
|
138 throw new CommDBException("Native constructor failed!", ERROR_NONE, |
|
139 iHandle); |
|
140 } |
135 // we need this so we can do some cleanup when we are garbage collected |
141 // we need this so we can do some cleanup when we are garbage collected |
136 iFinalizer = createFinalizer(); |
142 iFinalizer = createFinalizer(); |
137 state = CREATED; |
143 state = CREATED; |
138 } |
144 } |
139 |
145 |
140 /** |
146 /** |
141 * Opens the corresponding CommDB table. |
147 * Opens the corresponding CommDB table. |
142 */ |
148 */ |
143 public void open(int aNativeSessionHandle) throws CommDBException |
149 public void open() throws CommDBException |
144 { |
150 { |
145 |
151 |
146 iHandle = _open(aNativeSessionHandle, iTableName); |
152 int err = _open(iHandle, iTableName); |
147 Logger.LOG(Logger.EJavaIapInfo,Logger.EInfo, "iHandle ="+iHandle); |
153 if (NativeError.KErrNone == err) |
148 |
|
149 if (iHandle > 0) |
|
150 { |
154 { |
151 state = OPENED; |
155 state = OPENED; |
152 readFieldValues(); |
156 readFieldValues(); |
153 } |
157 } |
154 else |
158 else |
155 { |
159 { |
156 throw new CommDBException("Open failed!", ERROR_OPEN_FAILED, iHandle); |
160 throw new CommDBException("Open failed!", ERROR_OPEN_FAILED, err); |
157 } |
161 } |
158 |
162 |
159 } |
163 } |
160 |
164 |
161 /** |
165 /** |
179 */ |
183 */ |
180 public int findByName(String recordName) throws CommDBException |
184 public int findByName(String recordName) throws CommDBException |
181 { |
185 { |
182 |
186 |
183 int rec = 0; |
187 int rec = 0; |
184 |
|
185 rec = _findByName(iHandle, recordName); |
188 rec = _findByName(iHandle, recordName); |
186 if (rec >= 0) |
189 if (rec >= 0) |
187 { |
190 { |
188 readFieldValues(); |
191 readFieldValues(); |
189 } |
192 } |
225 * |
228 * |
226 * @return with the number of records |
229 * @return with the number of records |
227 */ |
230 */ |
228 public int getRecordCount() throws CommDBException |
231 public int getRecordCount() throws CommDBException |
229 { |
232 { |
230 Logger.LOG(Logger.EJavaIapInfo,Logger.EInfo,"+getRecordCount()"); |
|
231 return _getRecordCount(iHandle); |
233 return _getRecordCount(iHandle); |
232 } |
234 } |
233 |
235 |
234 /** |
236 /** |
235 * Retrieves data from the next record in the database. Throws |
237 * Retrieves data from the next record in the database. Throws |
322 } |
324 } |
323 /*----------------------------------------------------------------*/ |
325 /*----------------------------------------------------------------*/ |
324 /* Native funcions */ |
326 /* Native funcions */ |
325 /*----------------------------------------------------------------*/ |
327 /*----------------------------------------------------------------*/ |
326 /* |
328 /* |
|
329 * Creates native peer. |
|
330 * |
|
331 * @return handle for native peer |
|
332 */ |
|
333 private static native int _construct(); |
|
334 |
|
335 /* |
327 * Destructs native peer. |
336 * Destructs native peer. |
328 * |
337 * |
329 * @param aHandle - handle for native peer |
338 * @param aHandle - handle for native peer |
330 */ |
339 */ |
331 private static native void _destroy(int aHandle); |
340 private static native void _destroy(int aHandle); |
335 * |
344 * |
336 * @param table - the name of the current table. |
345 * @param table - the name of the current table. |
337 * |
346 * |
338 * @return - error code |
347 * @return - error code |
339 */ |
348 */ |
340 private static native int _open(int aSessionHandle, String tableName); |
349 private static native int _open(int aHandle, String tableName); |
341 |
350 |
342 /* |
351 /* |
343 * Close the actual CommDB table. |
352 * Close the actual CommDB table. |
344 * |
353 * |
345 * @param aHandle - handle for native peer |
354 * @param aHandle - handle for native peer |