javaextensions/iapinfo/javasrc.s60/com/nokia/mid/iapinfo/CommsTable.java
branchRCL_3
changeset 66 2455ef1f5bbc
parent 65 ae942d28ec0e
child 71 d5e927d5853b
--- a/javaextensions/iapinfo/javasrc.s60/com/nokia/mid/iapinfo/CommsTable.java	Tue Aug 31 15:09:22 2010 +0300
+++ b/javaextensions/iapinfo/javasrc.s60/com/nokia/mid/iapinfo/CommsTable.java	Wed Sep 01 12:33:18 2010 +0100
@@ -19,7 +19,6 @@
 
 import com.nokia.mj.impl.rt.support.Finalizer;
 import com.nokia.mj.impl.gcf.utils.NativeError;
-import com.nokia.mj.impl.utils.Logger;
 
 //import com.nokia.mj.impl.vmport.VmPort;
 
@@ -132,6 +131,13 @@
 
         iTableName = tableName;
 
+        // create native peer
+        iHandle = _construct();
+        if (iHandle < NativeError.KErrNone)
+        {
+            throw new CommDBException("Native constructor failed!", ERROR_NONE,
+                                      iHandle);
+        }
         // we need this so we can do some cleanup when we are garbage collected
         iFinalizer = createFinalizer();
         state = CREATED;
@@ -140,20 +146,18 @@
     /**
      * Opens the corresponding CommDB table.
      */
-    public void open(int aNativeSessionHandle) throws CommDBException
+    public void open() throws CommDBException
     {
 
-        iHandle = _open(aNativeSessionHandle, iTableName);
-        Logger.LOG(Logger.EJavaIapInfo,Logger.EInfo, "iHandle ="+iHandle);
-
-        if (iHandle > 0)
+        int err = _open(iHandle, iTableName);
+        if (NativeError.KErrNone == err)
         {
             state = OPENED;
             readFieldValues();
         }
         else
         {
-            throw new CommDBException("Open failed!", ERROR_OPEN_FAILED, iHandle);
+            throw new CommDBException("Open failed!", ERROR_OPEN_FAILED, err);
         }
 
     }
@@ -181,7 +185,6 @@
     {
 
         int rec = 0;
-
         rec = _findByName(iHandle, recordName);
         if (rec >= 0)
         {
@@ -227,7 +230,6 @@
      */
     public int getRecordCount() throws CommDBException
     {
-        Logger.LOG(Logger.EJavaIapInfo,Logger.EInfo,"+getRecordCount()");
         return _getRecordCount(iHandle);
     }
 
@@ -324,6 +326,13 @@
     /* Native funcions */
     /*----------------------------------------------------------------*/
     /*
+     * Creates native peer.
+     *
+     * @return handle for native peer
+     */
+    private static native int _construct();
+
+    /*
      * Destructs native peer.
      *
      * @param aHandle - handle for native peer
@@ -337,7 +346,7 @@
      *
      * @return - error code
      */
-    private static native int _open(int aSessionHandle, String tableName);
+    private static native int _open(int aHandle, String tableName);
 
     /*
      * Close the actual CommDB table.