Made HANDLEs more generic. They all are derived from one type in APIs. Added opening/closing of UPAPI.
authorChad Peckham <chad.peckham@nokia.com>
Mon, 01 Feb 2010 18:25:22 -0600
changeset 870 cdb6d745cb05
parent 868 089762ea5b6d
child 871 009f5d356768
Made HANDLEs more generic. They all are derived from one type in APIs. Added opening/closing of UPAPI.
connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/APIHANDLE.java
connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/ConnAPILibrary.java
connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/IConnAPILibrary.java
connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/LPAPIHANDLE.java
connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/PCCSConnection.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/APIHANDLE.java	Mon Feb 01 18:25:22 2010 -0600
@@ -0,0 +1,61 @@
+/**
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+package com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative;
+
+import com.sun.jna.FromNativeContext;
+import com.sun.jna.Pointer;
+import com.sun.jna.PointerType;
+
+/**
+ *  Opaque API Handle used in most native APIs
+ *
+ */
+public class APIHANDLE extends PointerType {
+	// Constant value representing an invalid HANDLE.
+    public static APIHANDLE INVALID_HANDLE_VALUE = new APIHANDLE(Pointer.createConstant(-1));
+	private boolean immutable;
+
+	public APIHANDLE() {
+	}
+
+	/**
+	 * @param p
+	 */
+	public APIHANDLE(Pointer p) {
+		setPointer(p); 
+		immutable = true;	
+	}
+
+	/**
+	 * Override to the appropriate object for INVALID_HANDLE_VALUE.
+	 */
+	@Override
+	public Object fromNative(Object nativeValue, FromNativeContext context) {
+        Object o = super.fromNative(nativeValue, context);
+        if (INVALID_HANDLE_VALUE.equals(o))
+            return INVALID_HANDLE_VALUE;
+        return o;
+	}
+
+	@Override
+	public void setPointer(Pointer p) {
+        if (immutable)
+            throw new UnsupportedOperationException("immutable reference"); //$NON-NLS-1$
+		super.setPointer(p);
+	}
+
+}
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/ConnAPILibrary.java	Mon Feb 01 15:42:48 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/ConnAPILibrary.java	Mon Feb 01 18:25:22 2010 -0600
@@ -66,6 +66,8 @@
 		}
 	}
 
+	// these calls are here just to satisfy the interface
+	//   the real calls are marshalled through jna to the native library
 	public int CFAPI_Initialize(int dwAPIVersion, IntByReference pdwParam) {
 		// TODO Auto-generated method stub
 		return 0;
@@ -76,7 +78,7 @@
 		return 0;
 	}
 
-	public int CONACloseDM(DMHANDLE mHDMHandle) {
+	public int CONACloseDM(APIHANDLE mHDMHandle) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
@@ -86,23 +88,23 @@
 		return 0;
 	}
 
-	public int CONAGetDeviceCount(DMHANDLE hDMHandle, IntByReference pdwCount) {
+	public int CONAGetDeviceCount(APIHANDLE hDMHandle, IntByReference pdwCount) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	public int CONAGetDevices(DMHANDLE hDMHandle, IntByReference pdwCount,
+	public int CONAGetDevices(APIHANDLE hDMHandle, IntByReference pdwCount,
 			CONAPI_DEVICE[] pDevices) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	public int CONAOpenDM(LPDMHANDLE mHDMHandle) {
+	public int CONAOpenDM(LPAPIHANDLE mHDMHandle) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	public int CONARegisterNotifyCallback(DMHANDLE hDMHandle, int dwState,
+	public int CONARegisterNotifyCallback(APIHANDLE hDMHandle, int dwState,
 			IConnAPIDeviceCallback pfnNotify) {
 		// TODO Auto-generated method stub
 		return 0;
@@ -123,7 +125,7 @@
 		return 0;
 	}
 
-	public int CONACloseMM(MCHANDLE hMCHandle) {
+	public int CONACloseMM(APIHANDLE hMCHandle) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
@@ -134,23 +136,23 @@
 		return 0;
 	}
 
-	public int CONAMMGetMedia(MCHANDLE hMCHandle, IntBuffer pdwCountOfMedia,
+	public int CONAMMGetMedia(APIHANDLE hMCHandle, IntBuffer pdwCountOfMedia,
 			ByReference[] ppMedia) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	public int CONAMMSetMedia(MCHANDLE hMCHandle, CONAPI_MEDIA[] pMedia) {
+	public int CONAMMSetMedia(APIHANDLE hMCHandle, CONAPI_MEDIA[] pMedia) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	public int CONAOpenMM(LPMCHANDLE phMCHandle, int dwValue) {
+	public int CONAOpenMM(LPAPIHANDLE phMCHandle, int dwValue) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	public int CONARegisterMMNotifyCallback(MCHANDLE hMCHandle, int dwState,
+	public int CONARegisterMMNotifyCallback(APIHANDLE hMCHandle, int dwState,
 			IConnAPIMediaCallback pfnNotify) {
 		// TODO Auto-generated method stub
 		return 0;
@@ -166,7 +168,7 @@
 		return 0;
 	}
 
-	public int MCAPI_GetMediaInfo(MCHANDLE hMCHandle, ShortBuffer pstrMediaID,
+	public int MCAPI_GetMediaInfo(APIHANDLE hMCHandle, ShortBuffer pstrMediaID,
 			CONAPI_MEDIA_INFO[] pMediaInfo) {
 		// TODO Auto-generated method stub
 		return 0;
@@ -182,7 +184,7 @@
 		return 0;
 	}
 
-	public int UPAPI_CloseUSBPersonality(UPHANDLE hUPHandle) {
+	public int UPAPI_CloseUSBPersonality(APIHANDLE hUPHandle) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
@@ -210,21 +212,21 @@
 		return 0;
 	}
 
-	public int UPAPI_GetConfigurationDescriptor(UPHANDLE hUPHandle,
+	public int UPAPI_GetConfigurationDescriptor(APIHANDLE hUPHandle,
 			ShortBuffer pstrDeviceId,
 			UP_CONFIGURATION_DESCRIPTOR[] pConfigurationDescriptor) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	public int UPAPI_GetPersonalityDescriptors(UPHANDLE hUPHandle,
+	public int UPAPI_GetPersonalityDescriptors(APIHANDLE hUPHandle,
 			ShortBuffer pstrDeviceId,
 			UP_PERSONALITY_DESCRIPTORS[] pPersonalityDescriptors) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	public int UPAPI_GetStringDescriptor(UPHANDLE hUPHandle,
+	public int UPAPI_GetStringDescriptor(APIHANDLE hUPHandle,
 			ShortBuffer pstrDeviceId, int dwDescriptorIndex, int dwLanguageID,
 			UP_STRING_DESCRIPTOR[] pStringDescriptor) {
 		// TODO Auto-generated method stub
@@ -236,31 +238,31 @@
 		return 0;
 	}
 
-	public int UPAPI_OpenUSBPersonality(int dwVendorId, LPUPHANDLE phUPHandle) {
+	public int UPAPI_OpenUSBPersonality(int dwVendorId, LPAPIHANDLE phUPHandle) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	public int UPAPI_QueryDeviceCount(UPHANDLE hUPHandle,
+	public int UPAPI_QueryDeviceCount(APIHANDLE hUPHandle,
 			IntBuffer pdwDeviceCount) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	public int UPAPI_QueryDevices(Pointer hUPHandle, IntBuffer pdwDeviceCount,
+	public int UPAPI_QueryDevices(APIHANDLE hUPHandle, IntBuffer pdwDeviceCount,
 			UP_DEVICE_DESCRIPTOR[] pDeviceDescriptor) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	public int UPAPI_SendCommandToDevice(UPHANDLE hUPHandle,
+	public int UPAPI_SendCommandToDevice(APIHANDLE hUPHandle,
 			ShortBuffer pstrDeviceId, int dwDataDirection,
 			UP_DATA_BUFFER[] pDataBuffer) {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	public int UPAPI_SetPersonality(UPHANDLE hUPHandle,
+	public int UPAPI_SetPersonality(APIHANDLE hUPHandle,
 			ShortBuffer pstrDeviceId, int dwPersonalityCode) {
 		// TODO Auto-generated method stub
 		return 0;
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/IConnAPILibrary.java	Mon Feb 01 15:42:48 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/IConnAPILibrary.java	Mon Feb 01 18:25:22 2010 -0600
@@ -39,12 +39,12 @@
 	int DMAPI_Initialize(int dwAPIVersion, IntByReference pdwParam);
 	int DMAPI_Terminate(IntByReference pdwParam);
 	int DMAPI_GetAPIVersion();
-	int CONAOpenDM(LPDMHANDLE mHDMHandle);
-	int CONACloseDM(DMHANDLE mHDMHandle);
-	int CONAGetDeviceCount(DMHANDLE hDMHandle, IntByReference pdwCount);
-	int CONAGetDevices(DMHANDLE hDMHandle, IntByReference pdwCount, CONAPI_DEVICE[] pDevices );
+	int CONAOpenDM(LPAPIHANDLE mHDMHandle);
+	int CONACloseDM(APIHANDLE mHDMHandle);
+	int CONAGetDeviceCount(APIHANDLE hDMHandle, IntByReference pdwCount);
+	int CONAGetDevices(APIHANDLE hDMHandle, IntByReference pdwCount, CONAPI_DEVICE[] pDevices );
 	int CONAFreeDeviceStructure( int dwCount, CONAPI_DEVICE[] pDevices );
-	int CONARegisterNotifyCallback(DMHANDLE hDMHandle, int dwState, IConnAPIDeviceCallback pfnNotify);
+	int CONARegisterNotifyCallback(APIHANDLE hDMHandle, int dwState, IConnAPIDeviceCallback pfnNotify);
 
 	// CFAPI Common APIs
 	int CFAPI_Initialize(int dwAPIVersion, IntByReference pdwParam);
@@ -59,14 +59,14 @@
 	int MCAPI_Initialize(int dwAPIVersion, IntBuffer pdwParam);
 	int MCAPI_Terminate(IntBuffer pdwParam);
 	int MCAPI_GetAPIVersion();
-	int CONAOpenMM(LPMCHANDLE phMCHandle, int dwValue);
-	int CONACloseMM(MCHANDLE hMCHandle);
-	int CONAMMGetMedia(MCHANDLE hMCHandle, IntBuffer pdwCountOfMedia, CONAPI_MEDIA.ByReference ppMedia[]); //TODO: c++ - CONAPI_MEDIA**	ppMedia
-	int CONAMMSetMedia(MCHANDLE hMCHandle, CONAPI_MEDIA[] pMedia);
+	int CONAOpenMM(LPAPIHANDLE phMCHandle, int dwValue);
+	int CONACloseMM(APIHANDLE hMCHandle);
+	int CONAMMGetMedia(APIHANDLE hMCHandle, IntBuffer pdwCountOfMedia, CONAPI_MEDIA.ByReference[] ppMedia); //TODO: c++ - CONAPI_MEDIA**	ppMedia
+	int CONAMMSetMedia(APIHANDLE hMCHandle, CONAPI_MEDIA[] pMedia);
 	int CONAMMFreeMediaStructures(int dwCountOfMedia, CONAPI_MEDIA[] pMedia);
-	int MCAPI_GetMediaInfo(MCHANDLE hMCHandle, ShortBuffer pstrMediaID, CONAPI_MEDIA_INFO[] pMediaInfo);
+	int MCAPI_GetMediaInfo(APIHANDLE hMCHandle, ShortBuffer pstrMediaID, CONAPI_MEDIA_INFO[] pMediaInfo);
 	int MCAPI_FreeMediaInfo(CONAPI_MEDIA_INFO[] pMediaInfo);
-	int CONARegisterMMNotifyCallback(MCHANDLE hMCHandle, int dwState, IConnAPIMediaCallback pfnNotify);
+	int CONARegisterMMNotifyCallback(APIHANDLE hMCHandle, int dwState, IConnAPIMediaCallback pfnNotify);
 
 	
 	// UPAPI USB Personality
@@ -74,18 +74,18 @@
 	int UPAPI_Initialize(int dwAPIVersion, IntBuffer pdwParam);
 	int UPAPI_Terminate(IntBuffer pdwParam);
 	int UPAPI_GetAPIVersion();
-	int UPAPI_OpenUSBPersonality(int dwVendorId, LPUPHANDLE phUPHandle);
-	int UPAPI_CloseUSBPersonality(UPHANDLE hUPHandle);
-	int UPAPI_QueryDeviceCount(UPHANDLE hUPHandle, IntBuffer pdwDeviceCount);
-	int UPAPI_QueryDevices(com.sun.jna.Pointer hUPHandle, IntBuffer pdwDeviceCount, UP_DEVICE_DESCRIPTOR[] pDeviceDescriptor);
+	int UPAPI_OpenUSBPersonality(int dwVendorId, LPAPIHANDLE phUPHandle);
+	int UPAPI_CloseUSBPersonality(APIHANDLE hUPHandle);
+	int UPAPI_QueryDeviceCount(APIHANDLE hUPHandle, IntBuffer pdwDeviceCount);
+	int UPAPI_QueryDevices(APIHANDLE hUPHandle, IntBuffer pdwDeviceCount, UP_DEVICE_DESCRIPTOR[] pDeviceDescriptor);
 	int UPAPI_FreeDeviceDescriptor(int dwDeviceCount, UP_DEVICE_DESCRIPTOR[] pDeviceDescriptor);
-	int UPAPI_GetConfigurationDescriptor(UPHANDLE hUPHandle, ShortBuffer pstrDeviceId, UP_CONFIGURATION_DESCRIPTOR[] pConfigurationDescriptor);
-	int UPAPI_GetStringDescriptor(UPHANDLE hUPHandle, ShortBuffer pstrDeviceId, int dwDescriptorIndex, int dwLanguageID, UP_STRING_DESCRIPTOR[] pStringDescriptor);
+	int UPAPI_GetConfigurationDescriptor(APIHANDLE hUPHandle, ShortBuffer pstrDeviceId, UP_CONFIGURATION_DESCRIPTOR[] pConfigurationDescriptor);
+	int UPAPI_GetStringDescriptor(APIHANDLE hUPHandle, ShortBuffer pstrDeviceId, int dwDescriptorIndex, int dwLanguageID, UP_STRING_DESCRIPTOR[] pStringDescriptor);
 	int UPAPI_FreeStringDescriptor(UP_STRING_DESCRIPTOR[] pStringDescriptor);
-	int UPAPI_GetPersonalityDescriptors(UPHANDLE hUPHandle, ShortBuffer pstrDeviceId, UP_PERSONALITY_DESCRIPTORS[] pPersonalityDescriptors);
+	int UPAPI_GetPersonalityDescriptors(APIHANDLE hUPHandle, ShortBuffer pstrDeviceId, UP_PERSONALITY_DESCRIPTORS[] pPersonalityDescriptors);
 	int UPAPI_FreePersonalityDescriptors(UP_PERSONALITY_DESCRIPTORS[] pPersonalityDescriptors);
-	int UPAPI_SetPersonality(UPHANDLE hUPHandle, ShortBuffer pstrDeviceId, int dwPersonalityCode);
-	int UPAPI_SendCommandToDevice(UPHANDLE hUPHandle, ShortBuffer pstrDeviceId, int dwDataDirection, UP_DATA_BUFFER[] pDataBuffer);
+	int UPAPI_SetPersonality(APIHANDLE hUPHandle, ShortBuffer pstrDeviceId, int dwPersonalityCode);
+	int UPAPI_SendCommandToDevice(APIHANDLE hUPHandle, ShortBuffer pstrDeviceId, int dwDataDirection, UP_DATA_BUFFER[] pDataBuffer);
 	
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/LPAPIHANDLE.java	Mon Feb 01 18:25:22 2010 -0600
@@ -0,0 +1,56 @@
+/**
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+package com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative;
+
+import com.sun.jna.Pointer;
+import com.sun.jna.ptr.ByReference;
+
+/**
+ * Opaque Pointer to API Handle used in some native APIs
+ *
+ */
+public class LPAPIHANDLE extends ByReference {
+
+	public LPAPIHANDLE() {
+		this(null);
+	}
+	public LPAPIHANDLE(APIHANDLE h) {
+		super(Pointer.SIZE);
+		setValue(h);
+	}
+	public void setValue(APIHANDLE h) {
+		getPointer().setPointer(0, h != null ? h.getPointer() : null);
+	}
+	public APIHANDLE getValue() {
+        Pointer p = getPointer().getPointer(0);
+        if (p == null)
+            return null;
+        if (APIHANDLE.INVALID_HANDLE_VALUE.getPointer().equals(p)) 
+            return APIHANDLE.INVALID_HANDLE_VALUE;
+        APIHANDLE h = new APIHANDLE();
+        h.setPointer(p);
+        return h;
+	}
+	/**
+	 * @param dataSize
+	 */
+	public LPAPIHANDLE(int dataSize) {
+		super(dataSize);
+		// TODO Auto-generated constructor stub
+	}
+
+}
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/PCCSConnection.java	Mon Feb 01 15:42:48 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/PCCSConnection.java	Mon Feb 01 18:25:22 2010 -0600
@@ -16,6 +16,7 @@
 */
 package com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative;
 
+import java.nio.IntBuffer;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -99,12 +100,12 @@
 
 	private static final Collection<DeviceEventListener> listeners = new LinkedList<DeviceEventListener>();
 	private IConnAPILibrary library;
-	private LPDMHANDLE dmHandle = new LPDMHANDLE();
+	private LPAPIHANDLE dmHandle = new LPAPIHANDLE();
 	private DeviceNotificationCallback pfnCallback = new DeviceNotificationCallback();
 	public static final int PCCS_NOT_FOUND = 1;
 	public static final int PCCS_WRONG_VERSION = 2;
 	
-	private LPMCHANDLE mcHandle = new LPMCHANDLE();
+	private LPAPIHANDLE mcHandle = new LPAPIHANDLE();
 	
 	/**
 	 * 
@@ -117,7 +118,7 @@
 			library = ConnAPILibrary.getInstance();
 		}
 		loadDMAPI();
-//		loadMCAPI(); TODO: not tested yet
+		loadMCAPI(); //TODO: not tested yet
 	}
 	
 	/**
@@ -151,7 +152,7 @@
 //    	}
     	
     	// open a DM handle
-    	dmHandle.setValue(DMHANDLE.INVALID_HANDLE_VALUE);
+    	dmHandle.setValue(APIHANDLE.INVALID_HANDLE_VALUE);
     	dwResult = library.CONAOpenDM(dmHandle);
     	if (dwResult != PCCSErrors.CONA_OK) {
     		library.DMAPI_Terminate(null);
@@ -168,7 +169,7 @@
 //    		System.out.printf("CONAOpenDM returned: %x\n", dwResult);
     		library.DMAPI_Terminate(null);
     		library.CONACloseDM(dmHandle.getValue());
-        	dmHandle.setValue(DMHANDLE.INVALID_HANDLE_VALUE);
+        	dmHandle.setValue(APIHANDLE.INVALID_HANDLE_VALUE);
 
         	String msg = String.format(Messages.PCCSConnection_PCCS_CONARegisterNotifyCallback_Error, dwResult);
     		if (dwResult == PCCSErrors.ECONA_INVALID_POINTER) {
@@ -210,7 +211,7 @@
 		if (library == null)
 			return;
 		
-//		closeMCAPI(); TODO: not tested yet
+		closeMCAPI(); //TODO: not tested yet
 		closeDMAPI();
 	}
 	
@@ -220,12 +221,12 @@
 	 */
 	private void closeDMAPI() throws CoreException {
 		int dwResult = PCCSErrors.CONA_OK;
-		if (dmHandle.getValue() != DMHANDLE.INVALID_HANDLE_VALUE) {
+		if (dmHandle.getValue() != APIHANDLE.INVALID_HANDLE_VALUE) {
 			// unregister callback
 			dwResult = library.CONARegisterNotifyCallback(dmHandle.getValue(), PCCSTypeDefinitions.API_UNREGISTER, pfnCallback);
 			// close DM connection
 			dwResult = library.CONACloseDM(dmHandle.getValue());
-        	dmHandle.setValue(DMHANDLE.INVALID_HANDLE_VALUE);
+        	dmHandle.setValue(APIHANDLE.INVALID_HANDLE_VALUE);
         	// Terminate Common Functions API
 //        	dwResult = library.CFAPI_Terminate(null); unnecessary
         	// Terminate Device management API
@@ -235,12 +236,23 @@
 
 	private void closeMCAPI() {
 		int dwResult = PCCSErrors.CONA_OK;
-		if (mcHandle.getValue() != MCHANDLE.INVALID_HANDLE_VALUE) {
+		if (mcHandle.getValue() != APIHANDLE.INVALID_HANDLE_VALUE) {
 			// close DM connection
 			dwResult = library.CONACloseDM(mcHandle.getValue());
-			mcHandle.setValue(MCHANDLE.INVALID_HANDLE_VALUE);
+			mcHandle.setValue(APIHANDLE.INVALID_HANDLE_VALUE);
         	// Terminate Device management API
     		dwResult = library.MCAPI_Terminate(null);
+	}
+	
+	public void getMediaList() {
+		if (mcHandle.getValue() != APIHANDLE.INVALID_HANDLE_VALUE) {
+			IntBuffer pdwCount = IntBuffer.allocate(1);
+			CONAPI_MEDIA pMedia = new CONAPI_MEDIA();
+			
+			CONAPI_MEDIA.ByReference[] ppMedia = null;
+			
+			int dwResult = library.CONAMMGetMedia(mcHandle.getValue(), pdwCount, ppMedia);
+			System.out.printf("dwResult = %x\tpdwCount = %d\n", dwResult, pdwCount.get());
 		}
 	}
 	/**