--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/agent/PCCSDiscoveryAgent.java Tue Mar 02 08:17:46 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/agent/PCCSDiscoveryAgent.java Tue Mar 02 08:24:40 2010 -0600
@@ -119,6 +119,7 @@
* @see com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.PCCSConnection.DeviceEventListener#onDeviceEvent(com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.PCCSConnection.DeviceEventListener.DeviceEvent, java.lang.String)
*/
public void onDeviceEvent(DeviceEvent eventType, String serialNumber) {
+ if (DEBUG) System.out.println("onDeviceEvent");
try {
switch (eventType) {
case DEVICE_LIST_UPDATED:
@@ -139,7 +140,10 @@
// updateConnections(pccsConnection.getGoodConnectionList());
break;
case DEVICE_UPDATED_RENAMED:
- // TODO what to do when device is renamed?
+ if (DEBUG) System.out.println("onDeviceEvent: updated renamed");
+ break;
+ default:
+ if (DEBUG) System.out.println("onDeviceEvent: default");
break;
}
} catch (Exception e) {
@@ -158,7 +162,7 @@
public void run() {
try {
do {
- if (DEBUG) System.out.println("updateThread updating");
+ if (DEBUG) System.out.println("updateThread updating: " + numPendingUpdates);
updateConnections2(pccs.getGoodConnectionList());
numPendingUpdates--;
} while (numPendingUpdates > 0);
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/PCCSConnection.java Tue Mar 02 08:17:46 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/pccsnative/PCCSConnection.java Tue Mar 02 08:24:40 2010 -0600
@@ -86,6 +86,7 @@
}
}
// fire events
+ if (DEBUG) System.out.println("DeviceNotificationCallback: fire events");
Iterator<DeviceEventListener> iter = listeners.iterator();
while (iter.hasNext()) {
iter.next().onDeviceEvent(eventType, serialNumber);
@@ -514,8 +515,11 @@
DeviceInfo[] deviceList = getCompleteDeviceList();
Collection<DeviceConnection> goodConnections = new ArrayList<DeviceConnection>();
- if (deviceList == null)
+ if (deviceList == null) {
+ // forget all non switched devices
+ forgetAllNoSwitchConnectionsNotInCurrentList(null);
return goodConnections;
+ }
try {
loadUPAPI();
@@ -524,50 +528,49 @@
return goodConnections;
}
boolean upapiOpen = true;
- int numUSBPersonalities = 0;
+ int numUSBDevicesExpected = 0;
for (DeviceInfo device : deviceList) {
Collection<DeviceConnectionInfo> connectionList = device.connections;
for (DeviceConnectionInfo connInfo : connectionList) {
if (connInfo.media.equals("usb")) {
- numUSBPersonalities++;
+ numUSBDevicesExpected++;
}
}
}
- if (DEBUG)
- System.out.println("numUSBPersonalities: " + numUSBPersonalities);
+ if (DEBUG) System.out.println("numDevices: "+ deviceList.length + " numUSBDevicesExpected: " + numUSBDevicesExpected);
+ if (deviceList.length < numUSBDevicesExpected) {
+ // error - number of total devices should be equal to or more than number of USB devices
+ // i.e., only 1 USB connection is permitted per device
+ String message = MessageFormat.format(
+ "PCSuite is reporting more USB connections ({0}) than the number of connected devices ({1}). Carbide cannot match devices to USB connections.",
+ numUSBDevicesExpected, deviceList.length);
+ Activator.logMessage(message, IStatus.ERROR);
+ closeUPAPI();
+ return goodConnections;
+ }
Collection<DeviceUSBPersonalityInfo> personalityList = null;
- if (numUSBPersonalities > 0) {
- 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() < numUSBPersonalities) {
- if (DEBUG) System.out.printf("Error 1 getting USB personalities: %d of %d total\n", (personalityList != null) ? personalityList.size() : 0, numUSBPersonalities); //$NON-NLS-1$
- closeUPAPI();
- upapiOpen = false;
- for (int i = 2; i < 6; i++) {
+ if (numUSBDevicesExpected > 0) {
+ int attempt = 1;
+ do {
+ personalityList = getAllDeviceUSBPersonalities();
+ if (personalityList == null || personalityList.size() < numUSBDevicesExpected) {
+ if (DEBUG) System.out.printf("Error %d getting USB personalities: %d of %d total\n", attempt, (personalityList != null) ? personalityList.size() : 0, numUSBDevicesExpected); //$NON-NLS-1$
+ if (attempt > 5) {
+ break; // bomb - leave UPAPI open, we need it later
+ }
+ attempt++;
+ // UPAPI seems to need a reload
+ closeUPAPI();
+ upapiOpen = false;
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() < numUSBPersonalities) {
- if (DEBUG) System.out.printf("Error %d getting USB personalities: %d of %d total\n", (personalityList != null) ? personalityList.size() : 0, numUSBPersonalities); //$NON-NLS-1$
- closeUPAPI();
- upapiOpen = false;
- } else {
- break;
- }
+ loadUPAPI();
+ upapiOpen = true;
}
- }
+ } while (personalityList == null || personalityList.size() < numUSBDevicesExpected);
}
// if we failed getting the USB personalities above - UPAPI will be closed
// so reopen it
@@ -589,9 +592,9 @@
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);
+ DeviceUSBPersonalityInfo personality = findPersonality(numUSBDevicesExpected, device.serialNumber, connInfo.address, personalityList);
if (personality == null) {
- if (DEBUG) System.out.println("getGoodConnectionList: personality not found, continue"); //$NON-NLS-1$
+ if (DEBUG) System.out.println("getGoodConnectionList: personality not found for device: " + device.friendlyName + "-- continue"); //$NON-NLS-1$
String msg = MessageFormat.format(Messages.PCCSConnection_Personality_Switch_Error,
device.friendlyName);
Activator.logMessage(msg, IStatus.ERROR);
@@ -660,23 +663,27 @@
/**
* 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 numUSBPersonalities
*
* @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) {
+ private DeviceUSBPersonalityInfo findPersonality(int numUSBPersonalities, String serialNumber, String address, Collection<DeviceUSBPersonalityInfo> personalityList) {
if (DEBUG) System.out.println("findPersonality: start"); //$NON-NLS-1$
- if (personalityList == null || personalityList.isEmpty())
+ if (personalityList == null || personalityList.isEmpty()) {
+ if (DEBUG) System.out.println("findPersonality: list is empty");
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$
}
+ // sometimes the serial numbers match except the personality one has an added 0
if (!serialNumber.equals(NOT_KNOWN) && !personality.serialNumber.equals(NOT_KNOWN)) {
// serial number not null from both DMAPI and UPAPI
if (serialNumber.equals(personality.serialNumber)) {
@@ -685,15 +692,29 @@
} 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;
+ } else {
+ if (DEBUG) System.out.println("findPersonality: both serialNums != null && serialNums do not match"); //$NON-NLS-1$
}
}
// cannot use serial numbers! try using device IDs
if (!address.equals(NOT_KNOWN) && !personality.deviceID.equals(NOT_KNOWN)) {
+ // example device ids:
+ // 0\VID_0421&PID_00AB\0 (no serial number as part of id)
+ // 004401011418023\VID_0421&PID_0500\0 (serial number comes at front)
// 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$
+ if (personality.deviceID.contains(id) && personality.deviceID.contains(serialNumber)) {
+ if (DEBUG) System.out.println("findPersonality: address matches deviceID with serial number"); //$NON-NLS-1$
return personality;
+ } else {
+ String begin = personality.deviceID.substring(0, personality.deviceID.indexOf('\\'));
+ if (begin.equals("0")) {
+ // no serial number at beginning
+ if (personality.deviceID.contains(id)) {
+ if (DEBUG) System.out.println("findPersonality: address matches deviceID without serial number"); //$NON-NLS-1$
+ return personality;
+ }
+ }
}
}
// sometimes the serial number is part of the address!
@@ -794,7 +815,7 @@
device.friendlyName,
personality.currentPersonalityDescription,
goodDesc);
- IStatus status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, message);
+ final IStatus status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, message);
String prompt = MessageFormat.format("Switch to {0} mode now.", goodDesc);
@@ -804,8 +825,9 @@
int dwResult = library.UPAPI_SetPersonality(upHandle, pstrDeviceId, goodCode);
if (dwResult != PCCSErrors.CONA_OK) {
forgetNoSwitchConnections(personality.deviceID);
- if (DEBUG)
- System.out.printf("UPAPI_SetPersonality failed: %x\n", dwResult); //$NON-NLS-1$
+ String message = status.getMessage() + "\nThe device returned an error when trying to switch. Disconnect and reconnect in the proper mode.";
+ Activator.logMessage(message, IStatus.ERROR);
+ if (DEBUG) System.out.printf("UPAPI_SetPersonality failed: %x\n", dwResult); //$NON-NLS-1$
}
}
});
@@ -856,6 +878,7 @@
} else {
deviceInfo.deviceID = NOT_KNOWN;
}
+ if (DEBUG) System.out.println("UPAPI_QueryDevices: ID found: " + deviceInfo.deviceID);
// nice to have, but maybe null on some devices
if (devices[i].pstrSerialNumber != null) {
deviceInfo.serialNumber = devices[i].pstrSerialNumber.getPointer().getString(0, true);
@@ -863,7 +886,7 @@
deviceInfo.serialNumber = NOT_KNOWN;
}
// now get the personality descriptor for this device
- apiError = getPersonalityDescriptors(p, apiError, deviceInfo);
+ apiError = getPersonalityDescriptors(p, deviceInfo);
}
if (DEBUG) System.out.println("getAllDeviceUSBPersonalities all devices read"); //$NON-NLS-1$
} else {
@@ -884,10 +907,11 @@
return p;
}
private boolean getPersonalityDescriptors(
- Collection<DeviceUSBPersonalityInfo> p, boolean apiError,
+ Collection<DeviceUSBPersonalityInfo> p,
DeviceUSBPersonalityInfo deviceInfo) {
int dwResult;
+ boolean apiError = false;
// 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);
@@ -902,7 +926,7 @@
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);
+ apiError = getSupportedPersonalities(deviceInfo, pid, persDesc, numPers);
} else {
apiError = true;
if (DEBUG)
@@ -915,8 +939,7 @@
}
return apiError;
}
- private boolean getSupportedPersonalities(boolean apiError,
- DeviceUSBPersonalityInfo deviceInfo, WString pid,
+ private boolean getSupportedPersonalities(DeviceUSBPersonalityInfo deviceInfo, WString pid,
UP_PERSONALITY_DESCRIPTORS[] persDesc, int numPers) {
int dwResult;
UP_PERSONALITY[] pSupportedPersonality = null;
@@ -924,6 +947,7 @@
pSupportedPersonality = (UP_PERSONALITY[])persDesc[0].pPersonalities.toArray(numPers);
deviceInfo.supportedPersonalities = new HashMap<Integer, String>();
}
+ boolean apiError = false;
// now get the string descriptor for each supported personality
for (int j = 0; j < numPers; j++) {
Integer code = new Integer(pSupportedPersonality[j].bPersonalityCode);
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/StatusDisplay.java Tue Mar 02 08:17:46 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/StatusDisplay.java Tue Mar 02 08:24:40 2010 -0600
@@ -35,6 +35,8 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
import com.nokia.carbide.remoteconnections.internal.api.IStatusDisplay;
import com.nokia.cpp.internal.api.utils.core.Check;
@@ -75,18 +77,9 @@
@Override
protected String getPopupShellTitle() {
- switch (status.getSeverity()) {
- case IStatus.INFO:
- return "Information";
- case IStatus.WARNING:
- return "Warning";
- case IStatus.ERROR:
- return "Error";
- };
- Check.checkState(false);
- return null;
+ return getTitleString(status);
}
-
+
@Override
protected Image getPopupShellImage(int maximumHeight) {
switch (status.getSeverity()) {
@@ -102,6 +95,8 @@
}
}
+ private static final int MODAL_MASK = SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL | SWT.SYSTEM_MODAL;
+
private boolean clicked;
private boolean closed;
@@ -134,14 +129,68 @@
action.run();
}
- protected void doDisplayStatus(Display display, String prompt, IStatus status) {
- NotificationPopup popup = new NotificationPopup(display, status, prompt);
- popup.open();
- popup.getShell().addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- StatusDisplay.this.closed = true;
+ private Shell getModalShell(Display display) {
+ Shell[] shells = display.getShells();
+ for (int i = shells.length - 1; i >= 0; i--) {
+ Shell shell = shells[i];
+ if ((shell.getStyle() & MODAL_MASK) != 0) {
+ return shell;
}
- });
+ }
+ return null;
}
+ protected void doDisplayStatus(Display display, String prompt, IStatus status) {
+ Shell modalShell = getModalShell(display);
+ if (modalShell == null) {
+ NotificationPopup popup = new NotificationPopup(display, status, prompt);
+ popup.open();
+ popup.getShell().addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ StatusDisplay.this.closed = true;
+ }
+ });
+ }
+ else {
+ int style = SWT.YES | SWT.NO;
+ switch (status.getSeverity()) {
+ case IStatus.INFO:
+ style |= SWT.ICON_INFORMATION;
+ break;
+ case IStatus.WARNING:
+ style |= SWT.ICON_WARNING;
+ break;
+ case IStatus.ERROR:
+ style |= SWT.ICON_ERROR;
+ break;
+ default:
+ Check.checkState(false);
+ };
+
+ MessageBox messageBox = new MessageBox(modalShell, style);
+ messageBox.setText(getTitleString(status));
+ StringBuilder sb = new StringBuilder();
+ sb.append(status.getMessage());
+ sb.append("\n");
+ sb.append(prompt);
+ messageBox.setMessage(sb.toString());
+ int open = messageBox.open();
+ closed = true;
+ clicked = open == SWT.YES;
+ }
+ }
+
+ private String getTitleString(IStatus status) {
+ switch (status.getSeverity()) {
+ case IStatus.INFO:
+ return "Information";
+ case IStatus.WARNING:
+ return "Warning";
+ case IStatus.ERROR:
+ return "Error";
+ };
+ Check.checkState(false);
+ return null;
+ }
+
}
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessDialog.java Tue Mar 02 08:17:46 2010 -0600
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessDialog.java Tue Mar 02 08:24:40 2010 -0600
@@ -216,9 +216,8 @@
sisLabel.setData(UID, "DebugRunProcessDialog.sisLabel"); //$NON-NLS-1$
sisFile = new Combo(composite, SWT.READ_ONLY);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false).applyTo(sisLabel);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false).applyTo(sisFile);
sisFile.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip")); //$NON-NLS-1$
- sisFile.add("None"); //$NON-NLS-1$
sisFile.setData(UID, "DebugRunProcessDialog.sisFile"); //$NON-NLS-1$
sisFile.addSelectionListener(new SelectionAdapter() {
@@ -228,18 +227,7 @@
}
});
- ICarbideBuildConfiguration config = cpi.getDefaultConfiguration();
- for (ISISBuilderInfo info : config.getSISBuilderInfoList()) {
- IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath();
- sisFile.add(sisPath.toOSString());
- }
-
- // select the first sis file if any, otherwise select none
- if (sisFile.getItemCount() > 1) {
- sisFile.select(1);
- } else {
- sisFile.select(0);
- }
+ updateSisFileCombo(cpi);
// listen for events so we can detect if they click on the link below and add new sis info.
CoreModel.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED);
@@ -278,6 +266,9 @@
validate();
}
});
+ String sisPath = data.getSisPath();
+ if (sisPath != null)
+ sisEdit.setText(sisPath);
sisEdit.setData(UID, "DebugRunProcessDialog.sisEdit"); //$NON-NLS-1$
sisBrowse = new Button(composite, SWT.NONE);
@@ -304,6 +295,25 @@
sisBrowse.setData(UID, "DebugRunProcessDialog.sisBrowse"); //$NON-NLS-1$
}
}
+
+
+ private void updateSisFileCombo(ICarbideProjectInfo cpi) {
+ sisFile.add(Messages.getString("DebugRunProcessDialog.NoneItem")); //$NON-NLS-1$
+
+ ICarbideBuildConfiguration config = cpi.getDefaultConfiguration();
+ for (ISISBuilderInfo info : config.getSISBuilderInfoList()) {
+ IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath();
+ sisFile.add(sisPath.toOSString());
+ }
+
+ // select the first sis file if any, otherwise select none
+ if (sisFile.getItemCount() > 1) {
+ sisFile.select(1);
+ } else {
+ sisFile.select(0);
+ }
+ updateSisFile();
+ }
/**
@@ -345,20 +355,7 @@
if (cpi != null) {
sisFile.removeAll();
- sisFile.add(Messages.getString("DebugRunProcessDialog.NoneItem")); //$NON-NLS-1$
-
- ICarbideBuildConfiguration config = cpi.getDefaultConfiguration();
- for (ISISBuilderInfo info : config.getSISBuilderInfoList()) {
- IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath();
- sisFile.add(sisPath.toOSString());
- }
-
- // select the first sis file if any, otherwise select none
- if (sisFile.getItemCount() > 1) {
- sisFile.select(1);
- } else {
- sisFile.select(0);
- }
+ updateSisFileCombo(cpi);
}
}
}
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessSection.java Tue Mar 02 08:17:46 2010 -0600
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessSection.java Tue Mar 02 08:24:40 2010 -0600
@@ -58,8 +58,8 @@
else if (data.getDefaultExecutable() != null)
data.setExeSelectionPath(data.getDefaultExecutable());
ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(data.getProject());
+ data.setInstallPackage(!data.isSysTRKConnection());
if (cpi != null) {
- data.setInstallPackage(!data.isSysTRKConnection());
ICarbideBuildConfiguration config = cpi.getDefaultConfiguration();
for (ISISBuilderInfo info : config.getSISBuilderInfoList()) {
IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath();