--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/.classpath Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/.classpath Thu Feb 11 16:46:41 2010 -0600
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/win32-x86.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/jna.jar" sourcepath="/jna/src"/>
+ <classpathentry exported="true" kind="lib" path="lib/jna.jar" sourcepath="jna/src/src-full.zip"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/.settings/.api_filters Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/.settings/.api_filters Thu Feb 11 16:46:41 2010 -0600
@@ -1,5 +1,75 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="com.nokia.carbide.remoteConnections.discovery.pccs" version="2">
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/APIHANDLE.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.APIHANDLE">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="PointerType"/>
+ <message_argument value="APIHANDLE"/>
+ </message_arguments>
+ </filter>
+ <filter id="643846161">
+ <message_arguments>
+ <message_argument value="FromNativeContext"/>
+ <message_argument value="APIHANDLE"/>
+ <message_argument value="fromNative(Object, FromNativeContext)"/>
+ </message_arguments>
+ </filter>
+ <filter id="643850349">
+ <message_arguments>
+ <message_argument value="Pointer"/>
+ <message_argument value="APIHANDLE"/>
+ <message_argument value="APIHANDLE(Pointer)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_CONNECTION_INFO.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_CONNECTION_INFO">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="Structure"/>
+ <message_argument value="CONAPI_CONNECTION_INFO"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_CONNECTION_INFO.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_CONNECTION_INFO$ByReference">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="ByReference"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_CONNECTION_INFO.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_CONNECTION_INFO$ByValue">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByValue"/>
+ <message_argument value="ByValue"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_DEVICE.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_DEVICE">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="Structure"/>
+ <message_argument value="CONAPI_DEVICE"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_DEVICE.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_DEVICE$ByReference">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="ByReference"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_DEVICE.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_DEVICE$ByValue">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByValue"/>
+ <message_argument value="ByValue"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_MEDIA.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_MEDIA">
<filter id="576720909">
<message_arguments>
@@ -8,6 +78,22 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_MEDIA.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_MEDIA$ByReference">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="ByReference"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_MEDIA.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_MEDIA$ByValue">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByValue"/>
+ <message_argument value="ByValue"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_MEDIA_INFO.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_MEDIA_INFO">
<filter id="576720909">
<message_arguments>
@@ -16,4 +102,277 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_MEDIA_INFO.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_MEDIA_INFO$ByReference">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="ByReference"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_MEDIA_INFO.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_MEDIA_INFO$ByValue">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByValue"/>
+ <message_argument value="ByValue"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/ConnAPILibrary.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.ConnAPILibrary">
+ <filter id="643846161">
+ <message_arguments>
+ <message_argument value="IntByReference"/>
+ <message_argument value="ConnAPILibrary"/>
+ <message_argument value="CFAPI_Initialize(int, IntByReference)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/DMHANDLE.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.DMHANDLE">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="PointerType"/>
+ <message_argument value="DMHANDLE"/>
+ </message_arguments>
+ </filter>
+ <filter id="643846161">
+ <message_arguments>
+ <message_argument value="FromNativeContext"/>
+ <message_argument value="DMHANDLE"/>
+ <message_argument value="fromNative(Object, FromNativeContext)"/>
+ </message_arguments>
+ </filter>
+ <filter id="643846161">
+ <message_arguments>
+ <message_argument value="Pointer"/>
+ <message_argument value="DMHANDLE"/>
+ <message_argument value="setPointer(Pointer)"/>
+ </message_arguments>
+ </filter>
+ <filter id="643850349">
+ <message_arguments>
+ <message_argument value="Pointer"/>
+ <message_argument value="DMHANDLE"/>
+ <message_argument value="DMHANDLE(Pointer)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/GUID.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.GUID">
+ <filter id="643850349">
+ <message_arguments>
+ <message_argument value="NativeLong"/>
+ <message_argument value="GUID"/>
+ <message_argument value="GUID(NativeLong, short, short, byte[])"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/GUID.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.GUID$ByReference">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="ByReference"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/GUID.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.GUID$ByValue">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByValue"/>
+ <message_argument value="ByValue"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/IConnAPILibrary.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.IConnAPILibrary">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="StdCallLibrary"/>
+ <message_argument value="IConnAPILibrary"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/IConnAPILibrary.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.IConnAPILibrary$IConnAPIDeviceCallback">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="StdCallCallback"/>
+ <message_argument value="IConnAPIDeviceCallback"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/LPAPIHANDLE.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.LPAPIHANDLE">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="LPAPIHANDLE"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/LPDMHANDLE.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.LPDMHANDLE">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="LPDMHANDLE"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/MCHANDLE.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.MCHANDLE">
+ <filter id="643850349">
+ <message_arguments>
+ <message_argument value="Pointer"/>
+ <message_argument value="MCHANDLE"/>
+ <message_argument value="MCHANDLE(Pointer)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/PCCSConnection.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.PCCSConnection$DeviceNotificationCallback">
+ <filter id="643846161">
+ <message_arguments>
+ <message_argument value="ShortByReference"/>
+ <message_argument value="DeviceNotificationCallback"/>
+ <message_argument value="invoke(int, ShortByReference)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_CONFIGURATION_DESCRIPTOR.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_CONFIGURATION_DESCRIPTOR">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="Structure"/>
+ <message_argument value="UP_CONFIGURATION_DESCRIPTOR"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_CONFIGURATION_DESCRIPTOR.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_CONFIGURATION_DESCRIPTOR$ByReference">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="ByReference"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_CONFIGURATION_DESCRIPTOR.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_CONFIGURATION_DESCRIPTOR$ByValue">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByValue"/>
+ <message_argument value="ByValue"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_DATA_BUFFER.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_DATA_BUFFER">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="Structure"/>
+ <message_argument value="UP_DATA_BUFFER"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_DATA_BUFFER.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_DATA_BUFFER$ByReference">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="ByReference"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_DATA_BUFFER.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_DATA_BUFFER$ByValue">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByValue"/>
+ <message_argument value="ByValue"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_DEVICE_DESCRIPTOR.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_DEVICE_DESCRIPTOR">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="Structure"/>
+ <message_argument value="UP_DEVICE_DESCRIPTOR"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_DEVICE_DESCRIPTOR.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_DEVICE_DESCRIPTOR$ByReference">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="ByReference"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_DEVICE_DESCRIPTOR.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_DEVICE_DESCRIPTOR$ByValue">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByValue"/>
+ <message_argument value="ByValue"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_PERSONALITY.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_PERSONALITY">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="Structure"/>
+ <message_argument value="UP_PERSONALITY"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_PERSONALITY.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_PERSONALITY$ByReference">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="ByReference"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_PERSONALITY.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_PERSONALITY$ByValue">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByValue"/>
+ <message_argument value="ByValue"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_PERSONALITY_DESCRIPTORS.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_PERSONALITY_DESCRIPTORS">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="Structure"/>
+ <message_argument value="UP_PERSONALITY_DESCRIPTORS"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_PERSONALITY_DESCRIPTORS.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_PERSONALITY_DESCRIPTORS$ByReference">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="ByReference"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_PERSONALITY_DESCRIPTORS.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_PERSONALITY_DESCRIPTORS$ByValue">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByValue"/>
+ <message_argument value="ByValue"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_STRING_DESCRIPTOR.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_STRING_DESCRIPTOR">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="Structure"/>
+ <message_argument value="UP_STRING_DESCRIPTOR"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_STRING_DESCRIPTOR.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_STRING_DESCRIPTOR$ByReference">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByReference"/>
+ <message_argument value="ByReference"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UP_STRING_DESCRIPTOR.java" type="com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.UP_STRING_DESCRIPTOR$ByValue">
+ <filter id="576725006">
+ <message_arguments>
+ <message_argument value="ByValue"/>
+ <message_argument value="ByValue"/>
+ </message_arguments>
+ </filter>
+ </resource>
</component>
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/META-INF/MANIFEST.MF Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/META-INF/MANIFEST.MF Thu Feb 11 16:46:41 2010 -0600
@@ -18,3 +18,5 @@
pccsPlugin.jar
Export-Package: com.nokia.carbide.remoteconnections.discovery.pccs.agent,
com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative
+Import-Package: com.nokia.cpp.internal.api.utils.core,
+ com.nokia.cpp.internal.api.utils.ui
Binary file connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/jna/src/src-full.zip has changed
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/Activator.java Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/Activator.java Thu Feb 11 16:46:41 2010 -0600
@@ -17,13 +17,17 @@
package com.nokia.carbide.remoteconnections.discovery.pccs;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
+import com.nokia.cpp.internal.api.utils.core.Logging;
+
/**
* The activator class controls the plug-in life cycle
*/
-public class Activator extends Plugin {
+public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "com.nokia.carbide.remoteConnections.discovery.pccs"; //$NON-NLS-1$
@@ -85,4 +89,15 @@
return PCSuiteWikiLocation;
}
}
+ public static void logError(Throwable t) {
+ Logging.log(plugin, Logging.newSimpleStatus(0, t));
+ }
+
+ public static void logMessage(String message, int type) {
+ Logging.log(plugin, Logging.newStatus(plugin, type, message));
+ }
+
+ public static void setHelp(Control control, String id) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(control, PLUGIN_ID + id); //$NON-NLS-1$
+ }
}
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/Messages.java Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/Messages.java Thu Feb 11 16:46:41 2010 -0600
@@ -25,12 +25,23 @@
public static String Activator_PCSuite_Location;
public static String ConnAPILibrary_PCCS_Not_Found_Error;
public static String ConnAPILibrary_PCSuite_Not_Found_Error;
+ public static String GUID_0;
+ public static String PCCSConnection_Bad_Personality_DontSwitch_Warning1;
+ public static String PCCSConnection_Bad_Personality_DontSwitch_Warning2;
+ public static String PCCSConnection_DontAsk_CheckText;
+ public static String PCCSConnection_Generic_Personality_Description;
public static String PCCSConnection_PCCS_CONAOpenDM_Error;
public static String PCCSConnection_PCCS_CONARegisterNotifyCallback_Error;
public static String PCCSConnection_PCCS_CONARegisterNotifyCallback_Pointer_Error;
public static String PCCSConnection_PCCS_Not_Enough_Memory_Error;
public static String PCCSConnection_PCCS_Version_Error;
public static String PCCSConnection_PCSuite_Version_Error;
+ public static String PCCSConnection_Personality_Switch_Error;
+ public static String PCCSConnection_Switch_Message_Title;
+ public static String PCCSConnection_Switch_Message1;
+ public static String PCCSConnection_Switch_Message3;
+ public static String PCCSConnection_Switch_Message4;
+ public static String PCCSConnection_Swtich_Message2;
public static String PCCSDiscoveryAgent_PCCS_Not_Found_Error;
public static String PCCSDiscoveryAgent_PCCS_Version_Error;
public static String PCCSDiscoveryAgent_PCSuite_Not_Found_Error;
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/agent/PCCSDiscoveryAgent.java Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/agent/PCCSDiscoveryAgent.java Thu Feb 11 16:46:41 2010 -0600
@@ -18,6 +18,7 @@
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -26,8 +27,7 @@
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
import com.nokia.carbide.remoteconnections.discovery.pccs.Activator;
import com.nokia.carbide.remoteconnections.discovery.pccs.Messages;
-import com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.DeviceConnectionInfo;
-import com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.DeviceInfo;
+import com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.DeviceConnection;
import com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.PCCSConnection;
import com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.PCCSConnection.DeviceEventListener;
import com.nokia.carbide.remoteconnections.interfaces.IConnection;
@@ -123,7 +123,7 @@
case DEVICE_REMOVED:
case DEVICE_UPDATED_ADDEDCONNECTION:
case DEVICE_UPDATED_REMOVEDCONNECTION:
- updateConnections(pccsConnection.getDeviceList());
+ updateConnections(pccsConnection.getGoodConnectionList());
break;
case DEVICE_UPDATED_RENAMED:
// TODO what to do when device is renamed?
@@ -145,7 +145,7 @@
saveLoadStatus(ce);
throw ce; // rethrow
}
- updateConnections(pccsConnection.getDeviceList());
+ updateConnections(pccsConnection.getGoodConnectionList());
pccsConnection.addEventListenter(this);
}
@@ -186,86 +186,83 @@
}
/**
- * Creates a new PCCS USB connection
- * @param deviceInfo - device information of the PCCS USB connection
+ * Creates a new PCCS connection
+ * @param deviceConn - device/connection information from PCCS
*/
- protected void createConnection(DeviceInfo deviceInfo, DeviceConnectionInfo connectionInfo) {
- if (connections.get(deviceInfo) == null) {
- // TODO: currently only handles USB
- if (connectionInfo.media.equals("usb")) { //$NON-NLS-1$
- IConnectionType connectionType =
- RemoteConnectionsActivator.getConnectionTypeProvider().getConnectionType(USB_CONNECTION_TYPE);
- if (connectionType != null) {
- IConnectionFactory factory = connectionType.getConnectionFactory();
- Map<String, String> settings = factory.getSettingsFromUI();
- settings.put(PORT_SETTING, connectionInfo.comPort);
- IConnection connection = factory.createConnection(settings);
- if (connection instanceof IConnection2) {
- IConnection2 connection2 = (IConnection2) connection;
- connection2.setIdentifier(createUniqueId(deviceInfo));
- connection2.setDisplayName(deviceInfo.friendlyName);
- connection2.setDynamic(true);
- String key = getKey(deviceInfo, connectionInfo);
- connections.put(key, connection2);
- manager.addConnection(connection2);
+ protected void createConnection(DeviceConnection deviceConn) {
+ if (connections.get(getKey(deviceConn)) == null) {
+ // TODO: currently only handles USB & Serial
+ if (deviceConn.media.equals("usb")) { //$NON-NLS-1$
+ if (deviceConn.mode.equals("serial")) { //$NON-NLS-1$
+ IConnectionType connectionType =
+ RemoteConnectionsActivator.getConnectionTypeProvider().getConnectionType(USB_CONNECTION_TYPE);
+ if (connectionType != null) {
+ IConnectionFactory factory = connectionType.getConnectionFactory();
+ Map<String, String> settings = factory.getSettingsFromUI();
+ settings.put(PORT_SETTING, deviceConn.port);
+ IConnection connection = factory.createConnection(settings);
+ if (connection instanceof IConnection2) {
+ IConnection2 connection2 = (IConnection2) connection;
+ connection2.setIdentifier(createUniqueId(deviceConn));
+ connection2.setDisplayName(deviceConn.friendlyName);
+ connection2.setDynamic(true);
+ String key = getKey(deviceConn);
+ connections.put(key, connection2);
+ manager.addConnection(connection2);
+ }
+ else {
+ RemoteConnectionsActivator.log("Could not create dynamic serial connection", null);
+ }
}
else {
- RemoteConnectionsActivator.log("Could not create dynamic serial connection", null);
+ RemoteConnectionsActivator.log("USB connection type extension not found", null);
}
}
- else {
- RemoteConnectionsActivator.log("USB connection type extension not found", null);
- }
}
}
}
- private String createUniqueId(DeviceInfo deviceInfo) {
- return getClass().getSimpleName() + ": " + deviceInfo.friendlyName; //$NON-NLS-1$
- }
-
/**
- * Return a string key based on the device and connection information
- * @param deviceInfo - device information
- * @param connectionInfo - device connection information
+ * Create a unique ID based on this device/connection
+ * @param conn - device/connection information from PCCS
* @return
*/
- protected String getKey(DeviceInfo deviceInfo, DeviceConnectionInfo connectionInfo) {
- String key = deviceInfo.friendlyName + deviceInfo.serialNumber + connectionInfo.address;
- return key;
+ private String createUniqueId(DeviceConnection conn) {
+ return getClass().getSimpleName() + ": " + conn.friendlyName; //$NON-NLS-1$
}
/**
- * Update existing PCCS USB connections
- * @param deviceInfoList - list of device information for current PCCS USB connections
+ * Return a string key based on the device and connection information
+ * @param conn - device/connection information
+ * @return
*/
- protected void updateConnections(DeviceInfo[] deviceInfoList) {
+ protected String getKey(DeviceConnection conn) {
+ String key = conn.friendlyName + conn.serialNumber + conn.address;
+ return key;
+ }
+ /**
+ * Update existing PCCS connections
+ * @param connList - the Device/Connection list from PCCS
+ */
+ protected void updateConnections(Collection<DeviceConnection> connList) {
disconnectAll();
- if (deviceInfoList != null) {
+ if (connList != null && !connList.isEmpty()) {
if (connections.isEmpty()) {
// no existing connections, so create new ones
- for (DeviceInfo deviceInfo : deviceInfoList) {
- for (DeviceConnectionInfo connectionInfo : deviceInfo.connections) {
- createConnection(deviceInfo, connectionInfo);
- }
+ for (DeviceConnection deviceConn : connList) {
+ createConnection(deviceConn);
}
}
else {
- for (DeviceInfo deviceInfo : deviceInfoList) {
- for (DeviceConnectionInfo connectionInfo : deviceInfo.connections) {
- String key = getKey(deviceInfo, connectionInfo);
- IConnection2 connection = connections.get(key);
- if (connection == null) {
- // no existing connection for the device found, must be new connection
- createConnection(deviceInfo, connectionInfo);
- }
- else {
- // existing connection for the device found, try to reconnect
- if (!manager.reconnect(connection)) {
- // reconnect failed, probably because the connection is not in use
- // so just create a new one
- manager.addConnection(connection);
- }
+ for (DeviceConnection deviceConn : connList) {
+ String key = getKey(deviceConn);
+ IConnection2 connection = connections.get(key);
+ if (connection == null) {
+ // no existing connection for the device found, must be new connection
+ createConnection(deviceConn);
+ } else {
+ if (!manager.reconnect(connection)) {
+ manager.addConnection(connection);
}
}
}
@@ -296,5 +293,4 @@
return loadStatus;
}
-
}
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/messages.properties Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/messages.properties Thu Feb 11 16:46:41 2010 -0600
@@ -3,12 +3,23 @@
Activator_PCSuite_Location=http://s60wiki.nokia.com/S60Wiki/Device_Discovery
ConnAPILibrary_PCCS_Not_Found_Error=Agent could not find a PC Connectivity Solution (PCCS) installation. For more information go to:
ConnAPILibrary_PCSuite_Not_Found_Error=Agent could not find a PC Suite installation. To install PC Suite, go to:
+GUID_0=Wrong array size \!
+PCCSConnection_Bad_Personality_DontSwitch_Warning1=The "{0}" device is currently in "{1}" USB personality, which is not compatible with on-device debugging.
+PCCSConnection_Bad_Personality_DontSwitch_Warning2=Switch to "{2}" personality in order to do debugging.
+PCCSConnection_DontAsk_CheckText=Don't ask again
+PCCSConnection_Generic_Personality_Description=Personality \#{0}
PCCSConnection_PCCS_CONAOpenDM_Error=PCCS CONAOpenDM API returned error on initialization %x
PCCSConnection_PCCS_CONARegisterNotifyCallback_Error=PCCS CONARegisterNotifyCallback API returned error %x
PCCSConnection_PCCS_CONARegisterNotifyCallback_Pointer_Error=PCCS CONARegisterNotifyCallback API contained an invalid function pointer
PCCSConnection_PCCS_Not_Enough_Memory_Error=Not enough memory to open the PCCS Device Management connection
PCCSConnection_PCCS_Version_Error=The requested PC Connectivity Solution DMAPI version (3.4) is not installed on this machine. To install a later version go to:
PCCSConnection_PCSuite_Version_Error=The current PC Suite intallation does not support the required level of API for this agent. To install a later version go to:
+PCCSConnection_Personality_Switch_Error=Connected device "{0}" does not support getting/setting the USB personality from the current personality.
+PCCSConnection_Switch_Message_Title=Switch Device USB Personality
+PCCSConnection_Switch_Message1=The "{0}" device is currently in "{1}" USB personality, which is not compatible with on-device debugging.
+PCCSConnection_Switch_Message3=Click Yes to switch to the latter personality and create a remote connection.\nClick No to leave the device in the current personality and
+PCCSConnection_Switch_Message4=not create a connection.\n\nTo not see this reminder again, check the "Don''t ask again" box.
+PCCSConnection_Swtich_Message2=This device supports the "{2}" debugging compatible personality.\n\n
PCCSDiscoveryAgent_PCCS_Not_Found_Error=Agent could not find the PC Connectivity Solution (PCCS) installation.
PCCSDiscoveryAgent_PCCS_Version_Error=Agent requires a later version of the PC Connectivity Solution (PCCS) installed.
PCCSDiscoveryAgent_PCSuite_Not_Found_Error=Agent could not find a PC Suite installation.
--- /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 Thu Feb 11 16:46:41 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((long)-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/CONAPI_MEDIA.java Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_MEDIA.java Thu Feb 11 16:46:41 2010 -0600
@@ -16,6 +16,7 @@
*/
package com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative;
+import com.sun.jna.Pointer;
import com.sun.jna.Structure;
/**
@@ -46,6 +47,9 @@
public CONAPI_MEDIA() {
super();
}
+ public CONAPI_MEDIA(Pointer p) {
+ super(p);
+ }
/**
* @param dwSize Must be sizeof(CONAPI_MEDIA)<br>
* @param dwMedia Media type<br>
@@ -67,12 +71,29 @@
this.dwMediaData = dwMediaData;
this.pstrID = pstrID;
}
- protected ByReference newByReference() { return new ByReference(); }
- protected ByValue newByValue() { return new ByValue(); }
- protected CONAPI_MEDIA newInstance() { return new CONAPI_MEDIA(); }
+ protected ByReference newByReference() {
+ ByReference s = new ByReference();
+ s.useMemory(getPointer());
+ write();
+ s.read();
+ return s;
+ }
+ protected ByValue newByValue() {
+ ByValue s = new ByValue();
+ s.useMemory(getPointer());
+ write();
+ s.read();
+ return s;
+ }
+ protected CONAPI_MEDIA newInstance() {
+ CONAPI_MEDIA s = new CONAPI_MEDIA();
+ s.useMemory(getPointer());
+ write();
+ s.read();
+ return s;
+ }
public static CONAPI_MEDIA[] newArray(int arrayLength) {
- return null;
-// return com.ochafik.lang.jnaerator.runtime.Structure.newArray(CONAPI_MEDIA.class, arrayLength);
+ return (CONAPI_MEDIA[]) new CONAPI_MEDIA().toArray(arrayLength);
}
public static class ByReference extends CONAPI_MEDIA implements com.sun.jna.Structure.ByReference {}
public static class ByValue extends CONAPI_MEDIA implements com.sun.jna.Structure.ByValue {}
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_MEDIA_INFO.java Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/CONAPI_MEDIA_INFO.java Thu Feb 11 16:46:41 2010 -0600
@@ -16,10 +16,7 @@
*/
package com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative;
-import com.sun.jna.NativeLong;
-import com.sun.jna.Pointer;
import com.sun.jna.Structure;
-import com.sun.jna.TypeMapper;
import com.sun.jna.ptr.ShortByReference;
/**
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/ConnAPILibrary.java Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/ConnAPILibrary.java Thu Feb 11 16:46:41 2010 -0600
@@ -25,9 +25,9 @@
import com.nokia.carbide.remoteconnections.discovery.pccs.Activator;
import com.nokia.carbide.remoteconnections.discovery.pccs.Messages;
-import com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_MEDIA.ByReference;
+//import com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.CONAPI_MEDIA.ByReference;
import com.sun.jna.Native;
-import com.sun.jna.Pointer;
+import com.sun.jna.WString;
import com.sun.jna.ptr.IntByReference;
public class ConnAPILibrary implements IConnAPILibrary {
@@ -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,34 +125,33 @@
return 0;
}
- public int CONACloseMM(MCHANDLE hMCHandle) {
+ public int CONACloseMM(APIHANDLE hMCHandle) {
// TODO Auto-generated method stub
return 0;
}
- public int CONAMMFreeMediaStructures(int dwCountOfMedia,
- CONAPI_MEDIA[] pMedia) {
+ public int CONAMMFreeMediaStructures(int dwCountOfMedia, CONAPI_MEDIA[] pMedia) {
// TODO Auto-generated method stub
return 0;
}
- public int CONAMMGetMedia(MCHANDLE hMCHandle, IntBuffer pdwCountOfMedia,
- ByReference[] ppMedia) {
+ public int CONAMMGetMedia(APIHANDLE hMCHandle, IntBuffer pdwCountOfMedia,
+ CONAPI_MEDIA.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 +167,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 +183,7 @@
return 0;
}
- public int UPAPI_CloseUSBPersonality(UPHANDLE hUPHandle) {
+ public int UPAPI_CloseUSBPersonality(APIHANDLE hUPHandle) {
// TODO Auto-generated method stub
return 0;
}
@@ -200,7 +201,7 @@
}
public int UPAPI_FreeStringDescriptor(
- UP_STRING_DESCRIPTOR[] pStringDescriptor) {
+ UP_STRING_DESCRIPTOR pStringDescriptor) {
// TODO Auto-generated method stub
return 0;
}
@@ -210,23 +211,23 @@
return 0;
}
- public int UPAPI_GetConfigurationDescriptor(UPHANDLE hUPHandle,
- ShortBuffer pstrDeviceId,
+ public int UPAPI_GetConfigurationDescriptor(APIHANDLE hUPHandle,
+ WString pstrDeviceId,
UP_CONFIGURATION_DESCRIPTOR[] pConfigurationDescriptor) {
// TODO Auto-generated method stub
return 0;
}
- public int UPAPI_GetPersonalityDescriptors(UPHANDLE hUPHandle,
- ShortBuffer pstrDeviceId,
+ public int UPAPI_GetPersonalityDescriptors(APIHANDLE hUPHandle,
+ WString pstrDeviceId,
UP_PERSONALITY_DESCRIPTORS[] pPersonalityDescriptors) {
// TODO Auto-generated method stub
return 0;
}
- public int UPAPI_GetStringDescriptor(UPHANDLE hUPHandle,
- ShortBuffer pstrDeviceId, int dwDescriptorIndex, int dwLanguageID,
- UP_STRING_DESCRIPTOR[] pStringDescriptor) {
+ public int UPAPI_GetStringDescriptor(APIHANDLE hUPHandle,
+ WString pstrDeviceId, int dwDescriptorIndex, int dwLanguageID,
+ UP_STRING_DESCRIPTOR pStringDescriptor) {
// TODO Auto-generated method stub
return 0;
}
@@ -236,32 +237,32 @@
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,
- ShortBuffer pstrDeviceId, int dwDataDirection,
+ public int UPAPI_SendCommandToDevice(APIHANDLE hUPHandle,
+ WString pstrDeviceId, int dwDataDirection,
UP_DATA_BUFFER[] pDataBuffer) {
// TODO Auto-generated method stub
return 0;
}
- public int UPAPI_SetPersonality(UPHANDLE hUPHandle,
- ShortBuffer pstrDeviceId, int dwPersonalityCode) {
+ public int UPAPI_SetPersonality(APIHANDLE hUPHandle,
+ WString pstrDeviceId, int dwPersonalityCode) {
// TODO Auto-generated method stub
return 0;
}
--- /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/DeviceConnection.java Thu Feb 11 16:46:41 2010 -0600
@@ -0,0 +1,31 @@
+/*
+* 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;
+
+/**
+ * Connection information for a device used by agent to create connections
+ */
+public class DeviceConnection {
+
+ public String media; // "usb", "bluetooth", etc.
+ public String mode; // "serial", "rndis", etc.
+ public String friendlyName;
+ public String serialNumber;
+ public String port; // COM port, IP address
+ public String address; // from DMAPI
+}
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/DeviceConnectionInfo.java Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/DeviceConnectionInfo.java Thu Feb 11 16:46:41 2010 -0600
@@ -23,7 +23,8 @@
public String deviceName;
public String address;
public int state;
- public String comPort;
+ public String port; // may be serial port or IP address
+ public String mode; // "serial" or "rndis" or etc.
/**
*
*/
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/GUID.java Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/GUID.java Thu Feb 11 16:46:41 2010 -0600
@@ -16,6 +16,7 @@
*/
package com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative;
+import com.nokia.carbide.remoteconnections.discovery.pccs.Messages;
import com.sun.jna.NativeLong;
import com.sun.jna.Structure;
@@ -39,7 +40,7 @@
this.Data2 = Data2;
this.Data3 = Data3;
if (Data4.length != this.Data4.length)
- throw new java.lang.IllegalArgumentException("Wrong array size !");
+ throw new java.lang.IllegalArgumentException(Messages.GUID_0);
this.Data4 = Data4;
}
protected ByReference newByReference() { return new ByReference(); }
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/IConnAPILibrary.java Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/IConnAPILibrary.java Thu Feb 11 16:46:41 2010 -0600
@@ -19,10 +19,7 @@
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
-import org.eclipse.core.runtime.CoreException;
-
-import com.sun.jna.Callback;
-import com.sun.jna.Native;
+import com.sun.jna.WString;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.ShortByReference;
import com.sun.jna.win32.StdCallLibrary;
@@ -39,12 +36,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 +56,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 +71,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_FreeStringDescriptor(UP_STRING_DESCRIPTOR[] pStringDescriptor);
- int UPAPI_GetPersonalityDescriptors(UPHANDLE hUPHandle, ShortBuffer pstrDeviceId, UP_PERSONALITY_DESCRIPTORS[] pPersonalityDescriptors);
+ int UPAPI_GetConfigurationDescriptor(APIHANDLE hUPHandle, WString pstrDeviceId, UP_CONFIGURATION_DESCRIPTOR[] pConfigurationDescriptor);
+ int UPAPI_GetStringDescriptor(APIHANDLE hUPHandle, WString pstrDeviceId, int dwDescriptorIndex, int dwLanguageID, UP_STRING_DESCRIPTOR pStringDescriptor);
+ int UPAPI_FreeStringDescriptor(UP_STRING_DESCRIPTOR pStringDescriptor);
+ int UPAPI_GetPersonalityDescriptors(APIHANDLE hUPHandle, WString 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, WString pstrDeviceId, int dwPersonalityCode);
+ int UPAPI_SendCommandToDevice(APIHANDLE hUPHandle, WString 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 Thu Feb 11 16:46:41 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/MCAPIDefinitions.java Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/MCAPIDefinitions.java Thu Feb 11 16:46:41 2010 -0600
@@ -16,8 +16,6 @@
*/
package com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative;
-import com.sun.jna.Structure;
-
public class MCAPIDefinitions {
//=========================================================
// Media Control API versions
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/PCCSConnection.java Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/PCCSConnection.java Thu Feb 11 16:46:41 2010 -0600
@@ -16,28 +16,42 @@
*/
package com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative;
+import java.nio.IntBuffer;
+import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
+import java.util.Map;
import org.eclipse.cdt.utils.WindowsRegistry;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.swt.widgets.Display;
+import org.osgi.service.prefs.BackingStoreException;
import com.nokia.carbide.remoteconnections.discovery.pccs.Activator;
import com.nokia.carbide.remoteconnections.discovery.pccs.Messages;
import com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.IConnAPILibrary.IConnAPIDeviceCallback;
+import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
+import com.sun.jna.Pointer;
+import com.sun.jna.WString;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.ShortByReference;
public class PCCSConnection {
+ private static final String NOT_KNOWN = "not known"; //$NON-NLS-1$ // used for all string structure elements that come back from PCCS as null
private boolean DEBUG = false;
+ private boolean SWITCH_TO_RNDIS = false; // false for 2.x, true for 3.x
+ private String DONT_ASK_AGAIN_KEY = "DontAskAgain"; //$NON-NLS-1$
/**
- * @author chpeckha
*
*/
public class DeviceNotificationCallback implements IConnAPIDeviceCallback {
@@ -54,11 +68,10 @@
// everything else will be null (according to the PCCS docs)
// TODO: bug in PCCS API:
if (DEBUG) System.out.printf("DeviceNotificationCallback %x %s\n", dwStatus, (pstrSerialNumber == null ? "serNum: null" : pstrSerialNumber.getPointer().getString(0, true))); //$NON-NLS-1$ //$NON-NLS-2$
- String serialNumber = "unknown device"; //$NON-NLS-1$
+ String serialNumber = NOT_KNOWN;
if (pstrSerialNumber != null) {
serialNumber = pstrSerialNumber.getPointer().getString(0, true);
}
- if (DEBUG) System.out.printf("DeviceNotificationCallback %x %s\n", dwStatus, serialNumber); //$NON-NLS-1$
DeviceEventListener.DeviceEvent eventType = DeviceEventListener.DeviceEvent.DEVICE_LIST_UPDATED;
// decode dwStatus per PCCS docs
@@ -99,13 +112,25 @@
private static final Collection<DeviceEventListener> listeners = new LinkedList<DeviceEventListener>();
private IConnAPILibrary library;
- private LPDMHANDLE dmHandle = new LPDMHANDLE();
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 APIHANDLE dmHandle = APIHANDLE.INVALID_HANDLE_VALUE;
+ private APIHANDLE mcHandle = APIHANDLE.INVALID_HANDLE_VALUE;
+ private APIHANDLE upHandle = APIHANDLE.INVALID_HANDLE_VALUE;
+ private void storeDontAskAgain() {
+ Activator.getDefault().getPreferenceStore().setValue(DONT_ASK_AGAIN_KEY, true);
+ try {
+ new InstanceScope().getNode(Activator.PLUGIN_ID).flush();
+ } catch (BackingStoreException e) {
+ Activator.logError(e);
+ }
+ }
+ private boolean dontAskAgain() {
+ return Activator.getDefault().getPreferenceStore().getBoolean(DONT_ASK_AGAIN_KEY);
+ }
/**
*
*/
@@ -116,10 +141,23 @@
if (library == null) {
library = ConnAPILibrary.getInstance();
}
+ // this uses the MCAPI only to enable required media
+ ensureMediaEnabled();
+
+ // load DMAPI
loadDMAPI();
-// loadMCAPI(); TODO: not tested yet
}
+ private void ensureMediaEnabled() throws CoreException {
+ // open the MCAPI
+ loadMCAPI();
+ // TODO:
+ // get media
+ // enable media
+ // close MCAPI
+ closeMCAPI();
+ }
+
/**
* Initializes the Device Management API (DMAPI) for use.
*
@@ -151,8 +189,10 @@
// }
// open a DM handle
- dmHandle.setValue(DMHANDLE.INVALID_HANDLE_VALUE);
- dwResult = library.CONAOpenDM(dmHandle);
+ dmHandle = APIHANDLE.INVALID_HANDLE_VALUE;
+ LPAPIHANDLE pHandle = new LPAPIHANDLE();
+ dwResult = library.CONAOpenDM(pHandle);
+
if (dwResult != PCCSErrors.CONA_OK) {
library.DMAPI_Terminate(null);
String msg = String.format(Messages.PCCSConnection_PCCS_CONAOpenDM_Error, dwResult);
@@ -160,15 +200,17 @@
msg = Messages.PCCSConnection_PCCS_Not_Enough_Memory_Error;
}
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, dwResult, msg, null));
+ } else {
+ dmHandle = pHandle.getValue();
}
// register a call back
- dwResult = library.CONARegisterNotifyCallback(dmHandle.getValue(), PCCSTypeDefinitions.API_REGISTER, pfnCallback);
+ dwResult = library.CONARegisterNotifyCallback(dmHandle, PCCSTypeDefinitions.API_REGISTER, pfnCallback);
if (dwResult != PCCSErrors.CONA_OK) {
// System.out.printf("CONAOpenDM returned: %x\n", dwResult);
library.DMAPI_Terminate(null);
- library.CONACloseDM(dmHandle.getValue());
- dmHandle.setValue(DMHANDLE.INVALID_HANDLE_VALUE);
+ library.CONACloseDM(dmHandle);
+ dmHandle = APIHANDLE.INVALID_HANDLE_VALUE;
String msg = String.format(Messages.PCCSConnection_PCCS_CONARegisterNotifyCallback_Error, dwResult);
if (dwResult == PCCSErrors.ECONA_INVALID_POINTER) {
@@ -194,24 +236,60 @@
}
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, PCCS_WRONG_VERSION, msg, null));
}
- dwResult = library.CONAOpenMM(mcHandle, 0);
+ LPAPIHANDLE pHandle = new LPAPIHANDLE();
+ dwResult = library.CONAOpenMM(pHandle, 0);
if (dwResult != PCCSErrors.CONA_OK) {
library.MCAPI_Terminate(null);
- String msg = String.format("PCCS CONAOpenMM API returned error on initialization %x", dwResult);
+ String msg = String.format("PCCS CONAOpenMM API returned error on initialization %x", dwResult); //$NON-NLS-1$
if (dwResult == PCCSErrors.ECONA_NOT_ENOUGH_MEMORY) {
msg = Messages.PCCSConnection_PCCS_Not_Enough_Memory_Error;
}
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, dwResult, msg, null));
+ } else {
+ mcHandle = pHandle.getValue();
}
}
+ private void loadUPAPI() throws CoreException {
+ int dwResult = PCCSErrors.CONA_OK;
+ dwResult = library.UPAPI_Initialize(UPAPIDefinitions.UPAPI_VERSION_10, null);
+ if (dwResult != PCCSErrors.CONA_OK) {
+ library.UPAPI_Terminate(null);
+ String msg;
+ msg = String.format("PCCS UPAPI_Initialize API returned error on initialization %x", dwResult); //$NON-NLS-1$
+ if (DEBUG) System.out.println(msg);
+ if (Activator.isSymSEELayout()) {
+ if (dwResult == PCCSErrors.ECONA_UNSUPPORTED_API_VERSION) {
+ msg = Messages.PCCSConnection_PCCS_Version_Error + Activator.getLoadErrorURL();
+ }
+ } else {
+ msg = Messages.PCCSConnection_PCSuite_Version_Error + Activator.getLoadErrorURL();
+ }
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, PCCS_WRONG_VERSION, msg, null));
+ }
+ LPAPIHANDLE pHandle = new LPAPIHANDLE();
+ dwResult = library.UPAPI_OpenUSBPersonality(0, pHandle);
+ if (dwResult != PCCSErrors.CONA_OK) {
+ library.UPAPI_Terminate(null);
+ String msg = String.format("PCCS OpenUSBPersonality API returned error on initialization %x", dwResult); //$NON-NLS-1$
+ if (DEBUG) System.out.println(msg);
+ if (dwResult == PCCSErrors.ECONA_NOT_ENOUGH_MEMORY) {
+ msg = Messages.PCCSConnection_PCCS_Not_Enough_Memory_Error;
+ }
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, dwResult, msg, null));
+ } else {
+ upHandle = pHandle.getValue();
+ }
+ if (DEBUG) System.out.println("\n-----loadUPAPI"); //$NON-NLS-1$
+
+ }
public void close() throws CoreException {
if (library == null)
return;
-
-// closeMCAPI(); TODO: not tested yet
- closeDMAPI();
+
+ // DMAPI should only one be open
+ closeDMAPI();
}
/**
@@ -220,12 +298,12 @@
*/
private void closeDMAPI() throws CoreException {
int dwResult = PCCSErrors.CONA_OK;
- if (dmHandle.getValue() != DMHANDLE.INVALID_HANDLE_VALUE) {
+ if (!APIHANDLE.INVALID_HANDLE_VALUE.equals(dmHandle)) {
// unregister callback
- dwResult = library.CONARegisterNotifyCallback(dmHandle.getValue(), PCCSTypeDefinitions.API_UNREGISTER, pfnCallback);
+ dwResult = library.CONARegisterNotifyCallback(dmHandle, PCCSTypeDefinitions.API_UNREGISTER, pfnCallback);
// close DM connection
- dwResult = library.CONACloseDM(dmHandle.getValue());
- dmHandle.setValue(DMHANDLE.INVALID_HANDLE_VALUE);
+ dwResult = library.CONACloseDM(dmHandle);
+ dmHandle = APIHANDLE.INVALID_HANDLE_VALUE;
// Terminate Common Functions API
// dwResult = library.CFAPI_Terminate(null); unnecessary
// Terminate Device management API
@@ -235,17 +313,543 @@
private void closeMCAPI() {
int dwResult = PCCSErrors.CONA_OK;
- if (mcHandle.getValue() != MCHANDLE.INVALID_HANDLE_VALUE) {
+ if (!APIHANDLE.INVALID_HANDLE_VALUE.equals(mcHandle)) {
// close DM connection
- dwResult = library.CONACloseDM(mcHandle.getValue());
- mcHandle.setValue(MCHANDLE.INVALID_HANDLE_VALUE);
+ dwResult = library.CONACloseDM(mcHandle);
+ mcHandle = APIHANDLE.INVALID_HANDLE_VALUE;
// Terminate Device management API
dwResult = library.MCAPI_Terminate(null);
}
}
+
+ private void closeUPAPI() {
+ int dwResult = PCCSErrors.CONA_OK;
+ if (!APIHANDLE.INVALID_HANDLE_VALUE.equals(upHandle)) {
+// if (upHandle.getValue() != APIHANDLE.INVALID_HANDLE_VALUE) {
+ // close DM connection
+ dwResult = library.UPAPI_CloseUSBPersonality(upHandle);
+ if (dwResult != PCCSErrors.CONA_OK) {
+ if (DEBUG) System.out.printf("UPAPI_CloseUSBPersonality dwResult = %x\n", dwResult); //$NON-NLS-1$
+ }
+ upHandle = APIHANDLE.INVALID_HANDLE_VALUE;
+ // Terminate Device management API
+ dwResult = library.UPAPI_Terminate(null);
+ if (dwResult != PCCSErrors.CONA_OK) {
+ if (DEBUG) System.out.printf("UPAPI_Terminate dwResult = %x\n", dwResult); //$NON-NLS-1$
+ }
+ }
+ if (DEBUG) System.out.println("closeUPAPI----\n"); //$NON-NLS-1$
+ }
+
+ public void getMediaList() {
+ if (!APIHANDLE.INVALID_HANDLE_VALUE.equals(mcHandle)) {
+ IntBuffer pdwCount = IntBuffer.allocate(1);
+
+ CONAPI_MEDIA.ByReference[] ppMedia = (CONAPI_MEDIA.ByReference[])new CONAPI_MEDIA.ByReference().toArray(10);
+
+ int dwResult = library.CONAMMGetMedia(mcHandle, pdwCount, ppMedia);
+ if (DEBUG) System.out.printf("dwResult = %x\tpdwCount = %d\n", dwResult, pdwCount.get(0)); //$NON-NLS-1$
+ int size = pdwCount.get(0);
+ CONAPI_MEDIA[] pMedia = CONAPI_MEDIA.newArray(10);
+ Pointer p0 = ppMedia[0].getPointer().getPointer(0);
+ Pointer p1 = ppMedia[1].getPointer().getPointer(0);
+ CONAPI_MEDIA media0 = ppMedia[0].newInstance();
+ CONAPI_MEDIA media1 = ppMedia[1].newInstance();
+ if (dwResult == PCCSErrors.CONA_OK) {
+ for (int i = 0; i < size; i++) {
+ // if (DEBUG) {
+ // System.out.printf("dwSize=%d\tdwMedia=%x\tpstrDescription=%s\n",
+ // media.dwMedia,
+ // media.dwMedia,
+ // (media.pstrDescription == null) ? "null" : media.pstrDescription.getPointer().getString(0, true));
+ // System.out.printf("dwState=%d\tdwOptions=%x\tdwMediaData=%d\tpstrID=%s\n",
+ // media.dwState,
+ // media.dwOptions,
+ // media.dwMediaData,
+ // (media.pstrID == null) ? "null" : media.pstrID.getPointer().getString(0, true));
+ // }
+ //
+ }
+ dwResult = library.CONAMMFreeMediaStructures(size, pMedia);
+ if (dwResult != PCCSErrors.CONA_OK) {
+ if (DEBUG) System.out.printf("CONAMMFreeMediaStructures = %x\n", dwResult); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ /**
+ * All devices detected are gotten here - BT, USB, etc.
+ * No checking of a valid connection is done here
+ *
+ * @return DeviceInfo[] - null if no devices connected
+ */
+ private DeviceInfo[] getCompleteDeviceList() {
+ DeviceInfo[] deviceInfo = null;
+
+ IntByReference pdwCount = new IntByReference(0);
+ int dwResult = library.CONAGetDeviceCount(dmHandle, pdwCount);
+ if (DEBUG) System.out.printf("CONAGetDeviceCount: %x number of devices: %d\n", dwResult, pdwCount.getValue()); //$NON-NLS-1$
+ if (dwResult != PCCSErrors.CONA_OK)
+ return deviceInfo;
+
+ int deviceCount = pdwCount.getValue();
+ if (deviceCount > 0) {
+
+ CONAPI_DEVICE[] pDevices = (CONAPI_DEVICE[])new CONAPI_DEVICE().toArray(deviceCount);
+ dwResult = library.CONAGetDevices(dmHandle, pdwCount, pDevices);
+ if (DEBUG) System.out.printf("CONAGetDevices: %x number of devices: %d\n", dwResult, deviceCount); //$NON-NLS-1$
+ if (dwResult != PCCSErrors.CONA_OK) {
+ return deviceInfo;
+ }
+
+ // Extract device information and connection info
+ deviceInfo = new DeviceInfo[deviceCount];
+ CONAPI_DEVICE[] devices = pDevices;
+ for (int i = 0; i < deviceCount; i++) {
+ deviceInfo[i] = new DeviceInfo();
+ if (devices[i].pstrSerialNumber != null) {
+ deviceInfo[i].serialNumber = devices[i].pstrSerialNumber.getPointer().getString(0, true);
+ } else {
+ // TODO: docs say if ser num == null --> device unsupported, but this is a bug in PCCS
+ deviceInfo[i].serialNumber = NOT_KNOWN; //$NON-NLS-1$
+ }
+ if (devices[i].pstrFriendlyName != null) {
+ deviceInfo[i].friendlyName = devices[i].pstrFriendlyName.getPointer().getString(0, true);
+ } else {
+ deviceInfo[i].friendlyName = NOT_KNOWN; //$NON-NLS-1$
+ }
+ if (devices[i].pstrModel != null) {
+ deviceInfo[i].model = devices[i].pstrModel.getPointer().getString(0, true);
+ } else {
+ deviceInfo[i].model = NOT_KNOWN; //$NON-NLS-1$
+ }
+ if (devices[i].pstrManufacturer != null) {
+ deviceInfo[i].mfr = devices[i].pstrManufacturer.getPointer().getString(0, true);
+ } else {
+ deviceInfo[i].mfr = NOT_KNOWN; //$NON-NLS-1$
+ }
+ int numConnections = deviceInfo[i].numberOfConnections = devices[i].dwNumberOfItems;
+
+ CONAPI_CONNECTION_INFO[] conn = null;
+ if (numConnections > 0)
+ conn = (CONAPI_CONNECTION_INFO[])devices[i].pItems.toArray(numConnections);
+
+ for (int j = 0; j < numConnections; j++) {
+
+ DeviceConnectionInfo connInfo = new DeviceConnectionInfo();
+ connInfo.deviceID = conn[j].dwDeviceID;
+ switch(conn[j].dwMedia){
+ case PCCSTypeDefinitions.API_MEDIA_BLUETOOTH:
+ connInfo.media = "bluetooth"; //$NON-NLS-1$
+ break;
+ case PCCSTypeDefinitions.API_MEDIA_IRDA:
+ connInfo.media = "irda"; //$NON-NLS-1$
+ break;
+ case PCCSTypeDefinitions.API_MEDIA_SERIAL:
+ connInfo.media = "serial-ca42"; //$NON-NLS-1$
+ break;
+ default:
+ case PCCSTypeDefinitions.API_MEDIA_USB:
+ connInfo.media = "usb"; //$NON-NLS-1$
+ break;
+ }
+ // fill-in friendly name with device name if the former was null
+ if (conn[j].pstrDeviceName != null) {
+ connInfo.deviceName = conn[j].pstrDeviceName.getPointer().getString(0,true);
+ if (deviceInfo[i].friendlyName.equals(NOT_KNOWN)) { //$NON-NLS-1$
+ deviceInfo[i].friendlyName = connInfo.deviceName;
+ }
+ } else {
+ connInfo.deviceName = NOT_KNOWN; //$NON-NLS-1$
+ }
+
+ // if the address is not known, this is serious - we may weed out this connection later
+ if (conn[j].pstrAddress != null) {
+ connInfo.address = conn[j].pstrAddress.getPointer().getString(0, true);
+ } else {
+ connInfo.address = NOT_KNOWN; // $NON-NLS-1$
+ }
+ connInfo.state = conn[j].dwState;
+ deviceInfo[i].connections.add(connInfo);
+ }
+ }
+ dwResult = library.CONAFreeDeviceStructure(deviceCount, pDevices);
+ }
+
+ return deviceInfo;
+ }
+
+ public synchronized Collection<DeviceConnection> getGoodConnectionList() throws CoreException {
+ DeviceInfo[] deviceList = getCompleteDeviceList();
+ Collection<DeviceConnection> goodConnections = new ArrayList<DeviceConnection>();
+
+ if (deviceList == null)
+ return goodConnections;
+
+ try {
+ loadUPAPI();
+ } catch (CoreException e) {
+ Activator.logError(e);
+ return goodConnections;
+ }
+ boolean upapiOpen = true;
+ Collection<DeviceUSBPersonalityInfo> personalityList = getAllDeviceUSBPersonalities();
+ // sometimes on a phone connected to USB, this is failing at least a couple of times
+ // so retry a number of times
+ // if there are no USB connections, this failure is expected
+ if (personalityList == null || personalityList.size() == 0) {
+ if (DEBUG) System.out.printf("Error 1 getting USB personalities\n"); //$NON-NLS-1$
+ closeUPAPI();
+ upapiOpen = false;
+ for (int i = 2; i < 6; i++) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ try {
+ loadUPAPI();
+ upapiOpen = true;
+ } catch (CoreException e) {
+ Activator.logError(e);
+ }
+ if (upapiOpen)
+ personalityList = getAllDeviceUSBPersonalities();
+ if (personalityList == null || personalityList.size() == 0) {
+ if (DEBUG) System.out.printf("Error %d getting USB personalities\n", i); //$NON-NLS-1$
+ closeUPAPI();
+ upapiOpen = false;
+ } else {
+ break;
+ }
+ }
+ }
+ // if we failed getting the USB personalities above - UPAPI will be closed
+ // so reopen it
+ // else we finally got the USB personalities, UPAPI is still open
+ if (!upapiOpen) {
+ loadUPAPI();
+ upapiOpen = true;
+ }
+
+ // go through each connected device and check for good connection modes (e.g. USB in debuggable mode)
+ if (DEBUG) System.out.printf("getGoodConnectionList: sizeof deviceList: %d\n", deviceList.length); //$NON-NLS-1$
+ for (DeviceInfo device : deviceList) {
+ Collection<DeviceConnectionInfo> connectionList = device.connections;
+ if (DEBUG) System.out.printf("getGoodConnectionList: sizeof connectionList: %d\n", connectionList.size()); //$NON-NLS-1$
+ for (DeviceConnectionInfo connInfo : connectionList) {
+ if (DEBUG) {
+ System.out.printf("getGoodConnectionList: name: %s media: %s\n", device.friendlyName, connInfo.media); //$NON-NLS-1$
+ }
+ if (connInfo.media.equals("usb")) { //$NON-NLS-1$
+ DeviceUSBPersonalityInfo personality = findPersonality(device.serialNumber, connInfo.address, personalityList);
+ if (personality == null) {
+ if (DEBUG) System.out.println("getGoodConnectionList: personality not found, continue"); //$NON-NLS-1$
+ String msg = MessageFormat.format(Messages.PCCSConnection_Personality_Switch_Error,
+ device.friendlyName);
+ Activator.logMessage(msg, IStatus.ERROR);
+ continue;
+ }
+ if (isGoodUSBPersonality(device, connInfo, personality)) {
+ // if current mode was bad, and we switched, then we'll pick it up at next notification
+ // if current mode is still bad, don't put into good list
+ // if current mode is good, store it to good list
+ DeviceConnection newConnection = new DeviceConnection();
+ newConnection.friendlyName = device.friendlyName;
+ if (!device.serialNumber.equals(NOT_KNOWN))
+ newConnection.serialNumber = device.serialNumber;
+ else if (!personality.serialNumber.equals(NOT_KNOWN))
+ newConnection.serialNumber = personality.serialNumber;
+ else
+ newConnection.serialNumber = NOT_KNOWN;
+
+ newConnection.media = connInfo.media;
+ newConnection.port = connInfo.port; // port may be IP address or COM Port depending on personality
+ newConnection.mode = connInfo.mode;
+ newConnection.address = connInfo.address;
+ if (!newConnection.friendlyName.equals(NOT_KNOWN) && !newConnection.address.equals(NOT_KNOWN))
+ goodConnections.add(newConnection);
+ }
+ } else if (connInfo.media.equals("bluetooth")) { //$NON-NLS-1$
+ // TODO: Bluetooth - not supported yet
+ } else {
+ // TODO: what else?
+ }
+ }
+ }
+ if (upapiOpen)
+ closeUPAPI();
+
+ return goodConnections;
+ }
+ /**
+ * Find a matching device in the personality list (all USB devices).<p>
+ * Might have to use a combination of the serial number and device ID to match with ID's from personality.
+ *
+ * @param serialNumber - serial number from connectivity API
+ * @param address - this contains the device ID from the connectivity API
+ * @param personalityList - all USB-connected devices
+ * @return - null if no personality found
+ */
+ private DeviceUSBPersonalityInfo findPersonality(String serialNumber, String address, Collection<DeviceUSBPersonalityInfo> personalityList) {
+
+ if (DEBUG) System.out.println("findPersonality: start"); //$NON-NLS-1$
+ if (personalityList == null || personalityList.isEmpty())
+ return null;
+
+ for (DeviceUSBPersonalityInfo personality : personalityList) {
+ if (DEBUG) {
+ System.out.printf("findPersonality: serialNums: %s\t%s\n", serialNumber, personality.serialNumber); //$NON-NLS-1$
+ System.out.printf("findPersonality: address: %s\tdeviceID: %s\n", address, personality.deviceID); //$NON-NLS-1$
+ }
+ if (!serialNumber.equals(NOT_KNOWN) && !personality.serialNumber.equals(NOT_KNOWN)) {
+ // serial number not null from both DMAPI and UPAPI
+ if (serialNumber.equals(personality.serialNumber)) {
+ if (DEBUG) System.out.println("findPersonality: serialNums match"); //$NON-NLS-1$
+ return personality;
+ } else if (new String(serialNumber+"0").equals(personality.serialNumber)) { //$NON-NLS-1$
+ if (DEBUG) System.out.println("findPersonality: serialNums match (by appending '0' to DMAPI)"); //$NON-NLS-1$
+ return personality;
+ }
+ }
+ // cannot use serial numbers! try using device IDs
+ if (!address.equals(NOT_KNOWN) && !personality.deviceID.equals(NOT_KNOWN)) {
+ // compare Device IDs
+ String id = address.substring(address.indexOf('\\'), address.lastIndexOf('\\'));
+ if (personality.deviceID.contains(id)) {
+ if (DEBUG) System.out.println("findPersonality: address matches deviceID"); //$NON-NLS-1$
+ return personality;
+ }
+ }
+ }
+ if (DEBUG) System.out.println("findPersonality end return null"); //$NON-NLS-1$
+ return null;
+ }
+
+ /**
+ * This will do a switch if the user wants us to.
+ *
+ * @param device - USB-connected device
+ * @param connInfo - connection information for this USB-connected device
+ * @param personalities - USB personalities of all devices (not just this one)
+ * @return true - iff we're in a 'good' USB personality already
+ * if we have to switch, the device will disconnect and reconnect in the other personality
+ *
+ * Only 'good' personalities are:
+ * PC Suite - Serial
+ * OVI Suite - Serial
+ * RNDIS - TCP/IP - currently unsupported
+ */
+ private boolean isGoodUSBPersonality(DeviceInfo device,
+ DeviceConnectionInfo connInfo,
+ DeviceUSBPersonalityInfo personality) {
+
+ if (DEBUG) System.out.printf("isGoodUSBPersonality: current personality: %d %s\n", personality.currentPersonalityCode, personality.currentPersonalityDescription); //$NON-NLS-1$
+ // currently assume that mode is always 'serial'
+ if (personality.currentPersonalityCode == UPAPIDefinitions.UPAPI_PERSONALITY_CODE_PC_SUITE ||
+ personality.currentPersonalityCode == UPAPIDefinitions.UPAPI_PERSONALITY_CODE_OVI_SUITE) {
+ connInfo.mode = "serial"; //$NON-NLS-1$
+ connInfo.port = getUSBComPort(connInfo.address);
+ // good personality
+ return true;
+ }
+
+ // bad personality - switch? if dontAskAgain is true - return bad personality
+ int goodCode = UPAPIDefinitions.UPAPI_PERSONALITY_CODE_PC_SUITE;
+ if (personality.supportedPersonalities.containsKey(new Integer(UPAPIDefinitions.UPAPI_PERSONALITY_CODE_OVI_SUITE))) {
+ goodCode = UPAPIDefinitions.UPAPI_PERSONALITY_CODE_OVI_SUITE;
+ }
+ String goodDesc = personality.supportedPersonalities.get(new Integer(goodCode));
+
+ if (dontAskAgain()) {
+ if (DEBUG) System.out.println("isGoodUSBPersonality: dont ask = true, return false"); //$NON-NLS-1$
+ String fmt = Messages.PCCSConnection_Bad_Personality_DontSwitch_Warning1 +
+ Messages.PCCSConnection_Bad_Personality_DontSwitch_Warning2;
+ String message = MessageFormat.format(fmt, device.friendlyName, personality.currentPersonalityDescription, goodDesc);
+ Activator.logMessage(message, IStatus.WARNING);
+ return false;
+ }
+
+ // ask to switch
+ askToSwitchPersonality(device, personality, goodCode, goodDesc);
+
+ // was bad personality - if we switched, it will be good next notification
+ if (DEBUG) System.out.println("isGoodUSBPersonality: return false"); //$NON-NLS-1$
+ return false;
+ }
+ private void askToSwitchPersonality(DeviceInfo device,
+ DeviceUSBPersonalityInfo personality, int goodCode, String goodDesc) {
+
+ // ask the user and switch
+ String fmt = Messages.PCCSConnection_Switch_Message1 +
+ Messages.PCCSConnection_Swtich_Message2 +
+ Messages.PCCSConnection_Switch_Message3 +
+ Messages.PCCSConnection_Switch_Message4;
+ String message = MessageFormat.format(fmt,
+ device.friendlyName,
+ personality.currentPersonalityDescription,
+ goodDesc);
+
+ MessageDialogWithToggle dlg = MessageDialogWithToggle.openYesNoQuestion(
+ WorkbenchUtils.getSafeShell(),
+ Messages.PCCSConnection_Switch_Message_Title,
+ message,
+ Messages.PCCSConnection_DontAsk_CheckText,
+ false,
+ null,
+ null);
+ boolean dontAskAgain = dlg.getToggleState();
+ boolean doSwitch = (dlg.getReturnCode() == IDialogConstants.YES_ID);
+
+ if (doSwitch) {
+ WString pstrDeviceId = new WString(personality.deviceID);
+ int dwResult = library.UPAPI_SetPersonality(upHandle, pstrDeviceId, goodCode);
+ if (dwResult != PCCSErrors.CONA_OK) {
+ if (DEBUG)
+ System.out.printf("UPAPI_SetPersonality failed: %x\n", dwResult); //$NON-NLS-1$
+ }
+ }
+ // store don't ask again only if selected
+ if (dontAskAgain)
+ storeDontAskAgain();
+ }
+
+ /**
+ * This function assumes the UPAPI has already been loaded by the caller
+ * @return - list of personalities
+ */
+ private Collection<DeviceUSBPersonalityInfo> getAllDeviceUSBPersonalities() {
+ Collection<DeviceUSBPersonalityInfo> p = new ArrayList<DeviceUSBPersonalityInfo>();
+ boolean apiError = false;
+ // how many USB devices are connected
+ IntBuffer pdwDeviceCount = IntBuffer.allocate(1);
+ int dwResult = library.UPAPI_QueryDeviceCount(upHandle, pdwDeviceCount);
+ if (dwResult == PCCSErrors.CONA_OK) {
+ int dwDeviceCount = pdwDeviceCount.get(0);
+ if (DEBUG) System.out.printf("UPAPI_QueryDeviceCount: dwDeviceCount: %d\n", dwDeviceCount); //$NON-NLS-1$
+ if (dwDeviceCount > 0) {
+ UP_DEVICE_DESCRIPTOR[] pDeviceDescriptor = (UP_DEVICE_DESCRIPTOR[])new UP_DEVICE_DESCRIPTOR().toArray(dwDeviceCount);
+
+ // get the descriptor for all USB device
+ dwResult = library.UPAPI_QueryDevices(upHandle, pdwDeviceCount, pDeviceDescriptor);
+ if (dwResult == PCCSErrors.CONA_OK) {
+ if (DEBUG) System.out.printf("UPAPI_QueryDevices dwDeviceCount: %d\n", dwDeviceCount); //$NON-NLS-1$
+
+ UP_DEVICE_DESCRIPTOR[] devices = pDeviceDescriptor;
+ //
+ for (int i = 0; i < dwDeviceCount; i++) {
+ // save important device descriptor information for each device
+ DeviceUSBPersonalityInfo deviceInfo = new DeviceUSBPersonalityInfo();
+
+ // device ID is very important to get personalities and for matching with
+ // the connectivity API
+ if (devices[i].pstrDeviceID != null) {
+ deviceInfo.deviceID = devices[i].pstrDeviceID.getPointer().getString(0, true);
+ } else {
+ deviceInfo.deviceID = NOT_KNOWN;
+ }
+ // nice to have, but maybe null on some devices
+ if (devices[i].pstrSerialNumber != null) {
+ deviceInfo.serialNumber = devices[i].pstrSerialNumber.getPointer().getString(0, true);
+ } else {
+ deviceInfo.serialNumber = NOT_KNOWN;
+ }
+ // now get the personality descriptor for this device
+ apiError = getPersonalityDescriptors(p, apiError, deviceInfo);
+ }
+ if (DEBUG) System.out.println("getAllDeviceUSBPersonalities all devices read"); //$NON-NLS-1$
+ } else {
+ apiError = true;
+ if (DEBUG)
+ System.out.printf("UPAPI_QueryDevices dwResult = %x\n", dwResult); //$NON-NLS-1$
+ }
+ dwResult = library.UPAPI_FreeDeviceDescriptor(dwDeviceCount, pDeviceDescriptor);
+ } else {
+ if (DEBUG) System.out.println("getAllDeviceUSBPersonalities no devices"); //$NON-NLS-1$
+ }
+ } else {
+ apiError = true;
+ if (DEBUG)
+ System.out.printf("UPAPI_QueryDeviceCount dwResult = %x\n", dwResult); //$NON-NLS-1$
+ }
+ if (DEBUG) System.out.printf("getAllDeviceUSBPersonalities return p size : %s\n", p.size()); //$NON-NLS-1$
+ return p;
+ }
+ private boolean getPersonalityDescriptors(
+ Collection<DeviceUSBPersonalityInfo> p, boolean apiError,
+ DeviceUSBPersonalityInfo deviceInfo) {
+ int dwResult;
+
+ // make device ID a wide string so JNA marshals it appropriately
+ WString pid = new WString(deviceInfo.deviceID);
+ UP_PERSONALITY_DESCRIPTORS[] persDesc = (UP_PERSONALITY_DESCRIPTORS[])new UP_PERSONALITY_DESCRIPTORS().toArray(1);
+ persDesc[0].dwSize = 12; // important - won't work without this
+ dwResult = library.UPAPI_GetPersonalityDescriptors(upHandle, pid, persDesc);
+ if (dwResult == PCCSErrors.CONA_OK) {
+ // store personality information
+ deviceInfo.currentPersonalityCode = (persDesc[0].bCurrentPersonality & 0xff);
+
+ // get num of supported personalities
+ int numPers = (persDesc[0].bNumOfPersonalities & 0xff);
+ if (DEBUG) System.out.printf("UPAPI_GetPersonalityDescriptors numPers = %d\n", numPers); //$NON-NLS-1$
+
+ // get all the supported personalities for this device
+ apiError = getSupportedPersonalities(apiError, deviceInfo, pid, persDesc, numPers);
+ } else {
+ apiError = true;
+ if (DEBUG)
+ System.out.printf("UPAPI_GetPersonalityDescriptors dwResult = %x\n", dwResult); //$NON-NLS-1$
+ }
+ dwResult = library.UPAPI_FreePersonalityDescriptors(persDesc);
+ if (apiError == false) {
+ if (DEBUG) System.out.println("getAllDeviceUSBPersonalities deviceInfo added"); //$NON-NLS-1$
+ p.add(deviceInfo);
+ }
+ return apiError;
+ }
+ private boolean getSupportedPersonalities(boolean apiError,
+ DeviceUSBPersonalityInfo deviceInfo, WString pid,
+ UP_PERSONALITY_DESCRIPTORS[] persDesc, int numPers) {
+ int dwResult;
+ UP_PERSONALITY[] pSupportedPersonality = null;
+ if (numPers > 0) {
+ pSupportedPersonality = (UP_PERSONALITY[])persDesc[0].pPersonalities.toArray(numPers);
+ deviceInfo.supportedPersonalities = new HashMap<Integer, String>();
+ }
+ // now get the string descriptor for each supported personality
+ for (int j = 0; j < numPers; j++) {
+ Integer code = new Integer(pSupportedPersonality[j].bPersonalityCode);
+ int stringIndex = (pSupportedPersonality[j].bPersonalityIndex & 0xff);
+ UP_STRING_DESCRIPTOR pStringDescriptor = new UP_STRING_DESCRIPTOR();
+ String desc = NOT_KNOWN;
+ pStringDescriptor.dwSize = 12; // this is important
+ dwResult = library.UPAPI_GetStringDescriptor(upHandle, pid, stringIndex, 0, pStringDescriptor);
+ if (dwResult == PCCSErrors.CONA_OK) {
+ if (pStringDescriptor.pstrDescription != null) {
+ desc = pStringDescriptor.pstrDescription.getPointer().getString(0, true);
+ }
+ if (DEBUG) System.out.printf("UPAPI_GetStringDescriptor code: %d, desc: %s\n", code.intValue(), desc); //$NON-NLS-1$
+ dwResult = library.UPAPI_FreeStringDescriptor(pStringDescriptor);
+ } else {
+ apiError = true;
+ if (DEBUG)
+ System.out.printf("UPAPI_GetStringDescriptor dwResult = %x\n", dwResult); //$NON-NLS-1$
+ }
+ if (apiError == false)
+ deviceInfo.supportedPersonalities.put(code, desc);
+ }
+ if (deviceInfo.supportedPersonalities.isEmpty()) {
+ deviceInfo.currentPersonalityDescription = MessageFormat.format(Messages.PCCSConnection_Generic_Personality_Description, Integer.toString(deviceInfo.currentPersonalityCode));
+ } else {
+ deviceInfo.currentPersonalityDescription = deviceInfo.supportedPersonalities.get(new Integer(deviceInfo.currentPersonalityCode));
+ }
+ if (DEBUG) System.out.printf("current Desc found: %s\n", deviceInfo.currentPersonalityDescription); //$NON-NLS-1$
+ return apiError;
+ }
+
/**
* @return null if no device found.
* @throws CoreException
+ * @deprecated Use {@link #getGoodConnectionList()} instead.
*/
public DeviceInfo[] getDeviceList() throws CoreException {
@@ -253,7 +857,7 @@
int dwResult = PCCSErrors.CONA_OK;
IntByReference pdwCount = new IntByReference(0);
- dwResult = library.CONAGetDeviceCount(dmHandle.getValue(), pdwCount);
+ dwResult = library.CONAGetDeviceCount(dmHandle, pdwCount);
if (DEBUG) System.out.printf("CONAGetDeviceCount: %x number of devices: %d\n", dwResult, pdwCount.getValue()); //$NON-NLS-1$
int deviceCnt = pdwCount.getValue();
@@ -262,7 +866,7 @@
// array of structs in contiguous memory required !
CONAPI_DEVICE[] pDevices = (CONAPI_DEVICE[])new CONAPI_DEVICE().toArray(deviceCnt);
- dwResult = library.CONAGetDevices(dmHandle.getValue(), pdwCount, pDevices);
+ dwResult = library.CONAGetDevices(dmHandle, pdwCount, pDevices);
if (DEBUG) System.out.printf("CONAGetDevices: %x number of devices: %d\n", dwResult, deviceCnt); //$NON-NLS-1$
if (dwResult == PCCSErrors.CONA_OK) {
@@ -276,22 +880,22 @@
deviceInfo[i].serialNumber = devices[i].pstrSerialNumber.getPointer().getString(0, true);
} else {
// TODO: docs say if ser num == null --> device unsupported, but this is a bug in PCCS
- deviceInfo[i].serialNumber = "not known"; //$NON-NLS-1$
+ deviceInfo[i].serialNumber = NOT_KNOWN; //$NON-NLS-1$
}
if (devices[i].pstrFriendlyName != null) {
deviceInfo[i].friendlyName = devices[i].pstrFriendlyName.getPointer().getString(0, true);
} else {
- deviceInfo[i].friendlyName = "not known"; //$NON-NLS-1$
+ deviceInfo[i].friendlyName = NOT_KNOWN; //$NON-NLS-1$
}
if (devices[i].pstrModel != null) {
deviceInfo[i].model = devices[i].pstrModel.getPointer().getString(0, true);
} else {
- deviceInfo[i].model = "not known"; //$NON-NLS-1$
+ deviceInfo[i].model = NOT_KNOWN; //$NON-NLS-1$
}
if (devices[i].pstrManufacturer != null) {
deviceInfo[i].mfr = devices[i].pstrManufacturer.getPointer().getString(0, true);
} else {
- deviceInfo[i].mfr = "not known"; //$NON-NLS-1$
+ deviceInfo[i].mfr = NOT_KNOWN; //$NON-NLS-1$
}
int numItems = deviceInfo[i].numberOfConnections = devices[i].dwNumberOfItems;
@@ -318,36 +922,36 @@
}
if (conn[j].pstrDeviceName != null) {
connInfo.deviceName = conn[j].pstrDeviceName.getPointer().getString(0,true);
- if (deviceInfo[i].friendlyName.equals("not known")) { //$NON-NLS-1$
+ if (deviceInfo[i].friendlyName.equals(NOT_KNOWN)) { //$NON-NLS-1$
// use device name as friendly name (latter was null)
deviceInfo[i].friendlyName = connInfo.deviceName;
}
} else {
- connInfo.deviceName = "not known"; //$NON-NLS-1$
+ connInfo.deviceName = NOT_KNOWN; //$NON-NLS-1$
}
// Bomb if friendly name is not known or address is not known
// since these are essential to a connection
- if (conn[j].pstrAddress == null || deviceInfo[i].friendlyName.equals("not known")) //$NON-NLS-1$
+ if (conn[j].pstrAddress == null || deviceInfo[i].friendlyName.equals(NOT_KNOWN)) //$NON-NLS-1$
continue;
connInfo.address = conn[j].pstrAddress.getPointer().getString(0, true);
connInfo.state = conn[j].dwState;
if (connInfo.media.equals("usb")) { //$NON-NLS-1$
- if (isGoodUSBState(connInfo.state)){
- connInfo.comPort = getUSBComPort(connInfo.address);
+ if (checkUSBMode(deviceInfo[i], connInfo)){
+ connInfo.port = getUSBComPort(connInfo.address);
} else {
// don't store - not in good USB personality mode
continue;
}
} else if (connInfo.media.equals("bluetooth")) { //$NON-NLS-1$
// TODO: implement BT
- connInfo.comPort = getBTComPort(connInfo.address);
+ connInfo.port = getBTComPort(connInfo.address);
} else {
// IRDA and Serial(CA42) probably will not come here anyway
- connInfo.comPort = null;
+ connInfo.port = null;
}
- if (connInfo.comPort != null)
+ if (connInfo.port != null)
deviceInfo[i].connections.add(connInfo);
}
}
@@ -358,22 +962,17 @@
return deviceInfo;
}
- private boolean isGoodUSBState(int state) {
- // This test is necessary since we're seeing
- // on some devices PCSuite mode not set BUT PCSuite trusted flag is set
- // OR PCSuite mode on device is selected BUT only Paired flag is set
- // good if:
- // in PCSuite mode
- // OR is Paired
- // OR is PCSuite trusted
- // TODO: use UPAPI here instead
- if (DMAPIDefinitions.CONAPI_IS_IN_PCSUITE_MODE(state))
- return true;
- else if (DMAPIDefinitions.CONAPI_IS_DEVICE_PAIRED(state))
- return true;
- else if (DMAPIDefinitions.CONAPI_IS_PCSUITE_TRUSTED(state))
- return true;
- return false;
+ /**
+ *
+ * @param deviceInfo
+ * @param connInfo
+ * @return
+ *
+ * @deprecated not used anymore
+ */
+ private boolean checkUSBMode(DeviceInfo deviceInfo,
+ DeviceConnectionInfo connInfo) {
+ return true;
}
private String getBTComPort(String address) {
@@ -441,4 +1040,17 @@
}
public void onDeviceEvent(DeviceEvent eventType, String serialNumber);
}
+ /**
+ * Class to hold USB personality information from UPAPI per Device
+ */
+ private class DeviceUSBPersonalityInfo {
+ String deviceID; // from device descriptor
+ String serialNumber; // from device descriptor
+ int currentPersonalityCode; // from personality descriptor
+ String currentPersonalityDescription; // from list of supported personalities
+ // list of supported personalities
+ // int = personality code
+ // string = personality description for code from device
+ Map<Integer, String> supportedPersonalities;
+ }
}
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UPAPIDefinitions.java Thu Feb 11 16:45:33 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/UPAPIDefinitions.java Thu Feb 11 16:46:41 2010 -0600
@@ -31,6 +31,7 @@
public static final int UPAPI_PERSONALITY_CODE_PICTURE_TRANSFER =0x03;
public static final int UPAPI_PERSONALITY_CODE_MEDIA_TRANSFER =0x04;
public static final int UPAPI_PERSONALITY_CODE_COMBINED =0x05;
+ public static final int UPAPI_PERSONALITY_CODE_OVI_SUITE =UPAPI_PERSONALITY_CODE_COMBINED;
public static final int UPAPI_PERSONALITY_CODE_PC_TO_WEB =0x06;
// not from documentation - from email only