author | Chad Peckham <chad.peckham@nokia.com> |
Thu, 11 Mar 2010 12:12:22 -0600 | |
branch | RCL_2_4 |
changeset 1092 | cfabdba53722 |
parent 1080 | 43348591c4a0 |
child 1124 | f68b7751b408 |
permissions | -rw-r--r-- |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1 |
/* |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
3 |
* All rights reserved. |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
8 |
* |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
9 |
* Initial Contributors: |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
11 |
* |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
12 |
* Contributors: |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
13 |
* |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
14 |
* Description: |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
15 |
* |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
16 |
*/ |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
17 |
package com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
18 |
|
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
19 |
import java.nio.IntBuffer; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
20 |
import java.text.MessageFormat; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
21 |
import java.util.ArrayList; |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
22 |
import java.util.Collection; |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
23 |
import java.util.HashMap; |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
24 |
import java.util.Iterator; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
25 |
import java.util.LinkedList; |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
26 |
import java.util.Map; |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
27 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
28 |
import org.eclipse.cdt.utils.WindowsRegistry; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
29 |
import org.eclipse.core.runtime.CoreException; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
30 |
import org.eclipse.core.runtime.IStatus; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
31 |
import org.eclipse.core.runtime.Status; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
32 |
|
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
33 |
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
34 |
import com.nokia.carbide.remoteconnections.discovery.pccs.Activator; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
35 |
import com.nokia.carbide.remoteconnections.discovery.pccs.Messages; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
36 |
import com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.IConnAPILibrary.IConnAPIDeviceCallback; |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
37 |
import com.sun.jna.Pointer; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
38 |
import com.sun.jna.WString; |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
39 |
import com.sun.jna.ptr.IntByReference; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
40 |
import com.sun.jna.ptr.ShortByReference; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
41 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
42 |
public class PCCSConnection { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
43 |
|
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
44 |
private static final String NOT_KNOWN = "not known"; //$NON-NLS-1$ // used for all string structure elements that come back from PCCS as null |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
45 |
private boolean DEBUG = false; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
46 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
47 |
public class DeviceNotificationCallback implements IConnAPIDeviceCallback { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
48 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
49 |
/* (non-Javadoc) |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
50 |
* @see com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.IConnAPILibrary.IConnAPIDeviceCallback#invoke(int, com.sun.jna.ptr.ShortByReference) |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
51 |
*/ |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
52 |
public int invoke(final int dwStatus, final ShortByReference pstrSerialNumber) { |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
53 |
// check for NULL, since I am seeing bogus events coming from PCCS before the real one |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
54 |
// and the serial number is not filled in. If the serial number is null, |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
55 |
// everything else will be null (according to the PCCS docs) |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
56 |
// TODO: bug in PCCS API: |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
57 |
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$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
58 |
String serialNumber = NOT_KNOWN; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
59 |
if (pstrSerialNumber != null) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
60 |
serialNumber = pstrSerialNumber.getPointer().getString(0, true); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
61 |
} |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
62 |
|
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
63 |
DeviceEventListener.DeviceEvent eventType = DeviceEventListener.DeviceEvent.DEVICE_LIST_UPDATED; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
64 |
// decode dwStatus per PCCS docs |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
65 |
switch(DMAPIDefinitions.GET_CONAPI_CB_STATUS(dwStatus)) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
66 |
case DMAPIDefinitions.CONAPI_DEVICE_LIST_UPDATED: |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
67 |
eventType = DeviceEventListener.DeviceEvent.DEVICE_LIST_UPDATED; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
68 |
break; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
69 |
case DMAPIDefinitions.CONAPI_DEVICE_ADDED: |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
70 |
eventType = DeviceEventListener.DeviceEvent.DEVICE_ADDED; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
71 |
break; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
72 |
case DMAPIDefinitions.CONAPI_DEVICE_REMOVED: |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
73 |
eventType = DeviceEventListener.DeviceEvent.DEVICE_REMOVED; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
74 |
break; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
75 |
case DMAPIDefinitions.CONAPI_DEVICE_UPDATED: |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
76 |
switch(DMAPIDefinitions.GET_CONAPI_CB_INFO(dwStatus)) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
77 |
case DMAPIDefinitions.CONAPI_CONNECTION_ADDED: |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
78 |
eventType = DeviceEventListener.DeviceEvent.DEVICE_UPDATED_ADDEDCONNECTION; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
79 |
break; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
80 |
case DMAPIDefinitions.CONAPI_CONNECTION_REMOVED: |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
81 |
eventType = DeviceEventListener.DeviceEvent.DEVICE_UPDATED_REMOVEDCONNECTION; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
82 |
break; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
83 |
case DMAPIDefinitions.CONAPI_DEVICE_RENAMED: |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
84 |
eventType = DeviceEventListener.DeviceEvent.DEVICE_UPDATED_RENAMED; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
85 |
break; |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
86 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
87 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
88 |
// fire events |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
89 |
if (DEBUG) System.out.println("DeviceNotificationCallback: fire events"); |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
90 |
Iterator<DeviceEventListener> iter = listeners.iterator(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
91 |
while (iter.hasNext()) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
92 |
iter.next().onDeviceEvent(eventType, serialNumber); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
93 |
} |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
94 |
return PCCSErrors.CONA_OK; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
95 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
96 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
97 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
98 |
private static final Collection<DeviceEventListener> listeners = new LinkedList<DeviceEventListener>(); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
99 |
private IConnAPILibrary library; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
100 |
private DeviceNotificationCallback pfnCallback = new DeviceNotificationCallback(); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
101 |
public static final int PCCS_NOT_FOUND = 1; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
102 |
public static final int PCCS_WRONG_VERSION = 2; |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
103 |
private static final int DMAPI_VERSION = DMAPIDefinitions.DMAPI_VERSION_34; |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
104 |
|
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
105 |
private APIHANDLE dmHandle = APIHANDLE.INVALID_HANDLE_VALUE; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
106 |
private APIHANDLE mcHandle = APIHANDLE.INVALID_HANDLE_VALUE; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
107 |
private APIHANDLE upHandle = APIHANDLE.INVALID_HANDLE_VALUE; |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
108 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
109 |
private Collection<String> noSwitchConnections = new ArrayList<String>(); |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
110 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
111 |
public PCCSConnection() { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
112 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
113 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
114 |
public void open() throws CoreException { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
115 |
if (library == null) { |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
116 |
try { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
117 |
library = IConnAPILibrary.INSTANCE; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
118 |
} catch (UnsatisfiedLinkError e) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
119 |
String msg; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
120 |
if (Activator.isSymSEELayout()) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
121 |
msg = Messages.ConnAPILibrary_PCCS_Not_Found_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
122 |
} else { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
123 |
msg = Messages.ConnAPILibrary_PCSuite_Not_Found_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
124 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
125 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, PCCSConnection.PCCS_NOT_FOUND, msg, e)); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
126 |
} catch (NoClassDefFoundError e) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
127 |
String msg; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
128 |
if (Activator.isSymSEELayout()) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
129 |
msg = Messages.ConnAPILibrary_PCCS_Not_Found_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
130 |
} else { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
131 |
msg = Messages.ConnAPILibrary_PCSuite_Not_Found_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
132 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
133 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, PCCSConnection.PCCS_NOT_FOUND, msg, e)); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
134 |
} |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
135 |
} |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
136 |
// this uses the MCAPI only to enable required media |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
137 |
ensureMediaEnabled(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
138 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
139 |
// load DMAPI |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
140 |
initDMAPI(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
141 |
dmHandle = loadDMAPI(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
142 |
if (!APIHANDLE.INVALID_HANDLE_VALUE.equals(dmHandle)) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
143 |
startDMNotifications(dmHandle); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
144 |
} |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
145 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
146 |
|
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
147 |
private void initDMAPI() throws CoreException { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
148 |
int dwResult = library.DMAPI_Initialize(DMAPI_VERSION, null); |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
149 |
if (dwResult != PCCSErrors.CONA_OK) { |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
150 |
terminateDMAPI(); |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
151 |
String msg; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
152 |
if (Activator.isSymSEELayout()) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
153 |
msg = String.format("PCCS DMAPI_Initialize API returned error on initialization %x", dwResult); //$NON-NLS-1$ |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
154 |
if (dwResult == PCCSErrors.ECONA_UNSUPPORTED_API_VERSION) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
155 |
msg = Messages.PCCSConnection_PCCS_Version_Error + Activator.getLoadErrorURL(); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
156 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
157 |
} else { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
158 |
msg = Messages.PCCSConnection_PCSuite_Version_Error + Activator.getLoadErrorURL(); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
159 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
160 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, PCCS_WRONG_VERSION, msg, null)); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
161 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
162 |
if (DEBUG) System.out.println("initDMAPI"); //$NON-NLS-1$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
163 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
164 |
private void startDMNotifications(APIHANDLE handle) throws CoreException { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
165 |
// register a call back |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
166 |
int dwResult = library.CONARegisterNotifyCallback(handle, PCCSTypeDefinitions.API_REGISTER, pfnCallback); |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
167 |
if (dwResult != PCCSErrors.CONA_OK) { |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
168 |
library.CONACloseDM(handle); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
169 |
handle = APIHANDLE.INVALID_HANDLE_VALUE; |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
170 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
171 |
String msg = String.format(Messages.PCCSConnection_PCCS_CONARegisterNotifyCallback_Error, dwResult); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
172 |
if (dwResult == PCCSErrors.ECONA_INVALID_POINTER) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
173 |
msg = Messages.PCCSConnection_PCCS_CONARegisterNotifyCallback_Pointer_Error; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
174 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
175 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, dwResult, msg, null)); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
176 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
177 |
if (DEBUG) System.out.println("startDMNotifications"); //$NON-NLS-1$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
178 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
179 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
180 |
private void ensureMediaEnabled() throws CoreException { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
181 |
// open the MCAPI |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
182 |
loadMCAPI(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
183 |
// get media list |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
184 |
IntBuffer pdwCount = IntBuffer.allocate(1); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
185 |
CONAPI_MEDIA.ByReference ppMedia = new CONAPI_MEDIA.ByReference(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
186 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
187 |
int dwResult = library.CONAMMGetMedia(mcHandle, pdwCount, ppMedia); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
188 |
if (DEBUG) |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
189 |
System.out.printf("CONAMMGetMedia dwResult = %x\tpdwCount = %d\n", dwResult, pdwCount.get(0)); //$NON-NLS-1$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
190 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
191 |
int count = pdwCount.get(0); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
192 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
193 |
Pointer pMedia = ppMedia.getPointer(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
194 |
Pointer nativePointer = pMedia.getPointer(0); // save this for freeing media |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
195 |
int size = ppMedia.size(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
196 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
197 |
if (count > 0) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
198 |
CONAPI_MEDIA media[] = new CONAPI_MEDIA[count]; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
199 |
for (int i = 0; i < count; i++) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
200 |
// get pointer from offset of native pointer |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
201 |
Pointer sharedP = nativePointer.share(0 + i*size); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
202 |
media[i] = new CONAPI_MEDIA(sharedP); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
203 |
// and read the data from native memory |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
204 |
media[i].read(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
205 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
206 |
for (int i = 0; i < count; i++) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
207 |
if (MCAPIDefinitions.CONAPI_GET_MEDIA_TYPE(media[i].dwMedia) == MCAPIDefinitions.CONAPI_MEDIA_USB) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
208 |
if (MCAPIDefinitions.CONAPI_IS_MEDIA_UNACTIVE(media[i].dwState)) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
209 |
media[i].dwState = MCAPIDefinitions.CONAPI_MEDIA_ACTIVE; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
210 |
dwResult = library.CONAMMSetMedia(mcHandle, media); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
211 |
if (DEBUG) |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
212 |
System.out.printf("CONAMMSetMedia dwResult = %x\n", dwResult); //$NON-NLS-1$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
213 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
214 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
215 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
216 |
dwResult = library.CONAMMFreeMediaStructures(count, nativePointer); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
217 |
if (DEBUG) |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
218 |
System.out.printf("CONAMMFreeMediaStructures dwResult = %x\n", dwResult); //$NON-NLS-1$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
219 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
220 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
221 |
// close MCAPI |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
222 |
closeMCAPI(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
223 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
224 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
225 |
/** |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
226 |
* Opens Device Management API (DMAPI) for use. Note: initDMAPI must be called prior to this.<br> |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
227 |
* initDMAPI need be called only once, but this can be called whenever we need a handle to |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
228 |
* the DMAPI. |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
229 |
* |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
230 |
* @throws CoreException |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
231 |
*/ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
232 |
private APIHANDLE loadDMAPI() throws CoreException { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
233 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
234 |
// open a DM handle |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
235 |
APIHANDLE handle = APIHANDLE.INVALID_HANDLE_VALUE; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
236 |
LPAPIHANDLE pHandle = new LPAPIHANDLE(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
237 |
int dwResult = library.CONAOpenDM(pHandle); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
238 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
239 |
if (dwResult != PCCSErrors.CONA_OK) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
240 |
String msg = String.format(Messages.PCCSConnection_PCCS_CONAOpenDM_Error, dwResult); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
241 |
if (dwResult == PCCSErrors.ECONA_NOT_ENOUGH_MEMORY) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
242 |
msg = Messages.PCCSConnection_PCCS_Not_Enough_Memory_Error; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
243 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
244 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, dwResult, msg, null)); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
245 |
} else { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
246 |
handle = pHandle.getValue(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
247 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
248 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
249 |
if (DEBUG) System.out.printf("loadDMAPI handle=%s\n", handle.toString()); //$NON-NLS-1$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
250 |
return handle; |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
251 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
252 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
253 |
private void loadMCAPI() throws CoreException { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
254 |
int dwResult = PCCSErrors.CONA_OK; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
255 |
dwResult = library.MCAPI_Initialize(MCAPIDefinitions.MCAPI_VERSION_32, null); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
256 |
if (dwResult != PCCSErrors.CONA_OK) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
257 |
library.MCAPI_Terminate(null); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
258 |
String msg; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
259 |
if (Activator.isSymSEELayout()) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
260 |
msg = String.format("PCCS MCAPI_Initialize API returned error on initialization %x", dwResult); //$NON-NLS-1$ |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
261 |
if (dwResult == PCCSErrors.ECONA_UNSUPPORTED_API_VERSION) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
262 |
msg = Messages.PCCSConnection_PCCS_Version_Error + Activator.getLoadErrorURL(); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
263 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
264 |
} else { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
265 |
msg = Messages.PCCSConnection_PCSuite_Version_Error + Activator.getLoadErrorURL(); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
266 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
267 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, PCCS_WRONG_VERSION, msg, null)); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
268 |
} |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
269 |
LPAPIHANDLE pHandle = new LPAPIHANDLE(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
270 |
dwResult = library.CONAOpenMM(pHandle, 0); |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
271 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
272 |
if (dwResult != PCCSErrors.CONA_OK) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
273 |
library.MCAPI_Terminate(null); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
274 |
String msg = String.format("PCCS CONAOpenMM API returned error on initialization %x", dwResult); //$NON-NLS-1$ |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
275 |
if (dwResult == PCCSErrors.ECONA_NOT_ENOUGH_MEMORY) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
276 |
msg = Messages.PCCSConnection_PCCS_Not_Enough_Memory_Error; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
277 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
278 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, dwResult, msg, null)); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
279 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
280 |
mcHandle = pHandle.getValue(); |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
281 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
282 |
if (DEBUG) System.out.println("\n-----loadMCAPI"); //$NON-NLS-1$ |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
283 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
284 |
|
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
285 |
private void loadUPAPI() throws CoreException { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
286 |
int dwResult = PCCSErrors.CONA_OK; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
287 |
dwResult = library.UPAPI_Initialize(UPAPIDefinitions.UPAPI_VERSION_10, null); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
288 |
if (dwResult != PCCSErrors.CONA_OK) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
289 |
library.UPAPI_Terminate(null); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
290 |
String msg; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
291 |
msg = String.format("PCCS UPAPI_Initialize API returned error on initialization %x", dwResult); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
292 |
if (DEBUG) System.out.println(msg); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
293 |
if (Activator.isSymSEELayout()) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
294 |
if (dwResult == PCCSErrors.ECONA_UNSUPPORTED_API_VERSION) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
295 |
msg = Messages.PCCSConnection_PCCS_Version_Error + Activator.getLoadErrorURL(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
296 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
297 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
298 |
msg = Messages.PCCSConnection_PCSuite_Version_Error + Activator.getLoadErrorURL(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
299 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
300 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, PCCS_WRONG_VERSION, msg, null)); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
301 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
302 |
LPAPIHANDLE pHandle = new LPAPIHANDLE(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
303 |
dwResult = library.UPAPI_OpenUSBPersonality(0, pHandle); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
304 |
if (dwResult != PCCSErrors.CONA_OK) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
305 |
library.UPAPI_Terminate(null); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
306 |
String msg = String.format("PCCS OpenUSBPersonality API returned error on initialization %x", dwResult); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
307 |
if (DEBUG) System.out.println(msg); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
308 |
if (dwResult == PCCSErrors.ECONA_NOT_ENOUGH_MEMORY) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
309 |
msg = Messages.PCCSConnection_PCCS_Not_Enough_Memory_Error; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
310 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
311 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, dwResult, msg, null)); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
312 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
313 |
upHandle = pHandle.getValue(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
314 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
315 |
if (DEBUG) System.out.println("\n-----loadUPAPI"); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
316 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
317 |
} |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
318 |
public void close() throws CoreException { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
319 |
if (library == null) |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
320 |
return; |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
321 |
|
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
322 |
stopDMNotifications(dmHandle); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
323 |
|
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
324 |
// DMAPI should only one be open |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
325 |
dmHandle = closeDMAPI(dmHandle); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
326 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
327 |
terminateDMAPI(); |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
328 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
329 |
|
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
330 |
private void terminateDMAPI() { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
331 |
// Terminate Device management API |
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
332 |
/*int dwResult =*/ library.DMAPI_Terminate(null); |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
333 |
if (DEBUG) System.out.println("terminateDMAPI"); //$NON-NLS-1$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
334 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
335 |
private void stopDMNotifications(APIHANDLE handle) { |
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
336 |
// int dwResult = PCCSErrors.CONA_OK; |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
337 |
if (!APIHANDLE.INVALID_HANDLE_VALUE.equals(handle)) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
338 |
// unregister callback |
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
339 |
/*dwResult =*/ library.CONARegisterNotifyCallback(handle, PCCSTypeDefinitions.API_UNREGISTER, pfnCallback); |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
340 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
341 |
if (DEBUG) System.out.println("stopDMNotifications"); //$NON-NLS-1$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
342 |
} |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
343 |
/** |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
344 |
* Closes the DMAPI. |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
345 |
* @throws CoreException |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
346 |
*/ |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
347 |
private APIHANDLE closeDMAPI(APIHANDLE handle) throws CoreException { |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
348 |
int dwResult = PCCSErrors.CONA_OK; |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
349 |
if (!APIHANDLE.INVALID_HANDLE_VALUE.equals(handle)) { |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
350 |
// close DM connection |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
351 |
dwResult = library.CONACloseDM(handle); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
352 |
if (DEBUG) System.out.printf("closeDMAPI ret=%x handle=%s\n", dwResult, handle.toString()); //$NON-NLS-1$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
353 |
handle = APIHANDLE.INVALID_HANDLE_VALUE; |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
354 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
355 |
return handle; |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
356 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
357 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
358 |
private void closeMCAPI() { |
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
359 |
// int dwResult = PCCSErrors.CONA_OK; |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
360 |
if (!APIHANDLE.INVALID_HANDLE_VALUE.equals(mcHandle)) { |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
361 |
// close DM connection |
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
362 |
/*dwResult =*/ library.CONACloseDM(mcHandle); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
363 |
mcHandle = APIHANDLE.INVALID_HANDLE_VALUE; |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
364 |
// Terminate Device management API |
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
365 |
/*dwResult =*/ library.MCAPI_Terminate(null); |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
366 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
367 |
if (DEBUG) System.out.println("closeMCAPI----\n"); //$NON-NLS-1$ |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
368 |
} |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
369 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
370 |
private void closeUPAPI() { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
371 |
int dwResult = PCCSErrors.CONA_OK; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
372 |
if (!APIHANDLE.INVALID_HANDLE_VALUE.equals(upHandle)) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
373 |
// close DM connection |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
374 |
dwResult = library.UPAPI_CloseUSBPersonality(upHandle); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
375 |
if (dwResult != PCCSErrors.CONA_OK) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
376 |
if (DEBUG) System.out.printf("UPAPI_CloseUSBPersonality dwResult = %x\n", dwResult); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
377 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
378 |
upHandle = APIHANDLE.INVALID_HANDLE_VALUE; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
379 |
// Terminate Device management API |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
380 |
dwResult = library.UPAPI_Terminate(null); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
381 |
if (dwResult != PCCSErrors.CONA_OK) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
382 |
if (DEBUG) System.out.printf("UPAPI_Terminate dwResult = %x\n", dwResult); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
383 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
384 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
385 |
if (DEBUG) System.out.println("closeUPAPI----\n"); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
386 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
387 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
388 |
/** |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
389 |
* All devices detected are gotten here - BT, USB, etc. |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
390 |
* No checking of a valid connection is done here |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
391 |
* |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
392 |
* @return DeviceInfo[] - null if no devices connected |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
393 |
*/ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
394 |
private DeviceInfo[] getCompleteDeviceList() { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
395 |
DeviceInfo[] deviceInfo = null; |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
396 |
APIHANDLE handle = APIHANDLE.INVALID_HANDLE_VALUE; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
397 |
try { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
398 |
handle = loadDMAPI(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
399 |
} catch (CoreException e) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
400 |
return deviceInfo; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
401 |
} |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
402 |
IntByReference pdwCount = new IntByReference(0); |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
403 |
int dwResult = library.CONAGetDeviceCount(handle, pdwCount); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
404 |
if (DEBUG) System.out.printf("CONAGetDeviceCount: %x number of devices: %d\n", dwResult, pdwCount.getValue()); //$NON-NLS-1$ |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
405 |
if (dwResult != PCCSErrors.CONA_OK) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
406 |
try { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
407 |
closeDMAPI(handle); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
408 |
} catch (CoreException e) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
409 |
} |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
410 |
return deviceInfo; |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
411 |
} |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
412 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
413 |
int deviceCount = pdwCount.getValue(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
414 |
if (deviceCount > 0) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
415 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
416 |
CONAPI_DEVICE[] pDevices = (CONAPI_DEVICE[])new CONAPI_DEVICE().toArray(deviceCount); |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
417 |
dwResult = library.CONAGetDevices(handle, pdwCount, pDevices); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
418 |
if (DEBUG) System.out.printf("CONAGetDevices: %x number of devices: %d\n", dwResult, deviceCount); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
419 |
if (dwResult != PCCSErrors.CONA_OK) { |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
420 |
try { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
421 |
closeDMAPI(handle); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
422 |
} catch (CoreException e) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
423 |
} |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
424 |
return deviceInfo; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
425 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
426 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
427 |
// Extract device information and connection info |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
428 |
deviceInfo = new DeviceInfo[deviceCount]; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
429 |
CONAPI_DEVICE[] devices = pDevices; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
430 |
for (int i = 0; i < deviceCount; i++) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
431 |
deviceInfo[i] = new DeviceInfo(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
432 |
if (devices[i].pstrSerialNumber != null) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
433 |
deviceInfo[i].serialNumber = devices[i].pstrSerialNumber.getPointer().getString(0, true); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
434 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
435 |
// TODO: docs say if ser num == null --> device unsupported, but this is a bug in PCCS |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
436 |
deviceInfo[i].serialNumber = NOT_KNOWN; //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
437 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
438 |
if (devices[i].pstrFriendlyName != null) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
439 |
deviceInfo[i].friendlyName = devices[i].pstrFriendlyName.getPointer().getString(0, true); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
440 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
441 |
deviceInfo[i].friendlyName = NOT_KNOWN; //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
442 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
443 |
if (devices[i].pstrModel != null) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
444 |
deviceInfo[i].model = devices[i].pstrModel.getPointer().getString(0, true); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
445 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
446 |
deviceInfo[i].model = NOT_KNOWN; //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
447 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
448 |
if (devices[i].pstrManufacturer != null) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
449 |
deviceInfo[i].mfr = devices[i].pstrManufacturer.getPointer().getString(0, true); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
450 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
451 |
deviceInfo[i].mfr = NOT_KNOWN; //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
452 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
453 |
int numConnections = deviceInfo[i].numberOfConnections = devices[i].dwNumberOfItems; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
454 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
455 |
CONAPI_CONNECTION_INFO[] conn = null; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
456 |
if (numConnections > 0) |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
457 |
conn = (CONAPI_CONNECTION_INFO[])devices[i].pItems.toArray(numConnections); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
458 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
459 |
for (int j = 0; j < numConnections; j++) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
460 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
461 |
DeviceConnectionInfo connInfo = new DeviceConnectionInfo(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
462 |
connInfo.deviceID = conn[j].dwDeviceID; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
463 |
switch(conn[j].dwMedia){ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
464 |
case PCCSTypeDefinitions.API_MEDIA_BLUETOOTH: |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
465 |
connInfo.media = "bluetooth"; //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
466 |
break; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
467 |
case PCCSTypeDefinitions.API_MEDIA_IRDA: |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
468 |
connInfo.media = "irda"; //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
469 |
break; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
470 |
case PCCSTypeDefinitions.API_MEDIA_SERIAL: |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
471 |
connInfo.media = "serial-ca42"; //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
472 |
break; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
473 |
default: |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
474 |
case PCCSTypeDefinitions.API_MEDIA_USB: |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
475 |
connInfo.media = "usb"; //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
476 |
break; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
477 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
478 |
// fill-in friendly name with device name if the former was null |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
479 |
if (conn[j].pstrDeviceName != null) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
480 |
connInfo.deviceName = conn[j].pstrDeviceName.getPointer().getString(0,true); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
481 |
if (deviceInfo[i].friendlyName.equals(NOT_KNOWN)) { //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
482 |
deviceInfo[i].friendlyName = connInfo.deviceName; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
483 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
484 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
485 |
connInfo.deviceName = NOT_KNOWN; //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
486 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
487 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
488 |
// if the address is not known, this is serious - we may weed out this connection later |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
489 |
if (conn[j].pstrAddress != null) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
490 |
connInfo.address = conn[j].pstrAddress.getPointer().getString(0, true); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
491 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
492 |
connInfo.address = NOT_KNOWN; // $NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
493 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
494 |
connInfo.state = conn[j].dwState; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
495 |
deviceInfo[i].connections.add(connInfo); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
496 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
497 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
498 |
dwResult = library.CONAFreeDeviceStructure(deviceCount, pDevices); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
499 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
500 |
try { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
501 |
closeDMAPI(handle); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
502 |
} catch (CoreException e) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
503 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
504 |
|
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
505 |
return deviceInfo; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
506 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
507 |
|
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
508 |
/** |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
509 |
* Gets the complete list of connections and weeds out "good" connections (i.e., non-debuggable) |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
510 |
* |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
511 |
* @return |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
512 |
* @throws CoreException |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
513 |
*/ |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
514 |
public synchronized Collection<DeviceConnection> getGoodConnectionList() throws CoreException { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
515 |
DeviceInfo[] deviceList = getCompleteDeviceList(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
516 |
Collection<DeviceConnection> goodConnections = new ArrayList<DeviceConnection>(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
517 |
|
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
518 |
if (deviceList == null) { |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
519 |
// forget all non switched devices |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
520 |
forgetAllNoSwitchConnectionsNotInCurrentList(null); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
521 |
return goodConnections; |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
522 |
} |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
523 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
524 |
try { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
525 |
loadUPAPI(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
526 |
} catch (CoreException e) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
527 |
Activator.logError(e); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
528 |
return goodConnections; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
529 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
530 |
boolean upapiOpen = true; |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
531 |
int numUSBDevicesExpected = 0; |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
532 |
for (DeviceInfo device : deviceList) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
533 |
Collection<DeviceConnectionInfo> connectionList = device.connections; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
534 |
for (DeviceConnectionInfo connInfo : connectionList) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
535 |
if (connInfo.media.equals("usb")) { |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
536 |
numUSBDevicesExpected++; |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
537 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
538 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
539 |
} |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
540 |
if (DEBUG) System.out.println("numDevices: "+ deviceList.length + " numUSBDevicesExpected: " + numUSBDevicesExpected); |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
541 |
if (deviceList.length < numUSBDevicesExpected) { |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
542 |
// error - number of total devices should be equal to or more than number of USB devices |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
543 |
// i.e., only 1 USB connection is permitted per device |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
544 |
String message = MessageFormat.format( |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
545 |
"PCSuite is reporting more USB connections ({0}) than the number of connected devices ({1}). Carbide cannot match devices to USB connections.", |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
546 |
numUSBDevicesExpected, deviceList.length); |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
547 |
Activator.logMessage(message, IStatus.ERROR); |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
548 |
closeUPAPI(); |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
549 |
return goodConnections; |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
550 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
551 |
|
1080
43348591c4a0
Make sure we don't remember non-switch status if only one device is connected. Also increase the timeout to get USB personalities seen on some devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1040
diff
changeset
|
552 |
if (deviceList.length == 1) { |
43348591c4a0
Make sure we don't remember non-switch status if only one device is connected. Also increase the timeout to get USB personalities seen on some devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1040
diff
changeset
|
553 |
// forget all non switched devices |
43348591c4a0
Make sure we don't remember non-switch status if only one device is connected. Also increase the timeout to get USB personalities seen on some devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1040
diff
changeset
|
554 |
forgetAllNoSwitchConnectionsNotInCurrentList(null); |
43348591c4a0
Make sure we don't remember non-switch status if only one device is connected. Also increase the timeout to get USB personalities seen on some devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1040
diff
changeset
|
555 |
} |
43348591c4a0
Make sure we don't remember non-switch status if only one device is connected. Also increase the timeout to get USB personalities seen on some devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1040
diff
changeset
|
556 |
|
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
557 |
Collection<DeviceUSBPersonalityInfo> personalityList = null; |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
558 |
if (numUSBDevicesExpected > 0) { |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
559 |
int attempt = 1; |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
560 |
do { |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
561 |
personalityList = getAllDeviceUSBPersonalities(); |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
562 |
if (personalityList == null || personalityList.size() < numUSBDevicesExpected) { |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
563 |
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$ |
1080
43348591c4a0
Make sure we don't remember non-switch status if only one device is connected. Also increase the timeout to get USB personalities seen on some devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1040
diff
changeset
|
564 |
if (attempt > 10) { |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
565 |
break; // bomb - leave UPAPI open, we need it later |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
566 |
} |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
567 |
attempt++; |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
568 |
// UPAPI seems to need a reload |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
569 |
closeUPAPI(); |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
570 |
upapiOpen = false; |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
571 |
try { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
572 |
Thread.sleep(1000); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
573 |
} catch (InterruptedException e) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
574 |
} |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
575 |
loadUPAPI(); |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
576 |
upapiOpen = true; |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
577 |
} |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
578 |
} while (personalityList == null || personalityList.size() < numUSBDevicesExpected); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
579 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
580 |
// if we failed getting the USB personalities above - UPAPI will be closed |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
581 |
// so reopen it |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
582 |
// else we finally got the USB personalities, UPAPI is still open |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
583 |
if (!upapiOpen) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
584 |
loadUPAPI(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
585 |
upapiOpen = true; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
586 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
587 |
|
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
588 |
forgetAllNoSwitchConnectionsNotInCurrentList(personalityList); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
589 |
|
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
590 |
// go through each connected device and check for good connection modes (e.g. USB in debuggable mode) |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
591 |
if (DEBUG) System.out.printf("getGoodConnectionList: sizeof deviceList: %d\n", deviceList.length); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
592 |
for (DeviceInfo device : deviceList) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
593 |
Collection<DeviceConnectionInfo> connectionList = device.connections; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
594 |
if (DEBUG) System.out.printf("getGoodConnectionList: sizeof connectionList: %d\n", connectionList.size()); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
595 |
for (DeviceConnectionInfo connInfo : connectionList) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
596 |
if (DEBUG) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
597 |
System.out.printf("getGoodConnectionList: name: %s media: %s\n", device.friendlyName, connInfo.media); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
598 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
599 |
if (connInfo.media.equals("usb")) { //$NON-NLS-1$ |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
600 |
DeviceUSBPersonalityInfo personality = findPersonality(numUSBDevicesExpected, device.serialNumber, connInfo.address, personalityList); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
601 |
if (personality == null) { |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
602 |
if (DEBUG) System.out.println("getGoodConnectionList: personality not found for device: " + device.friendlyName + "-- continue"); //$NON-NLS-1$ |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
603 |
String msg = MessageFormat.format(Messages.PCCSConnection_Personality_Switch_Error, |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
604 |
device.friendlyName); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
605 |
Activator.logMessage(msg, IStatus.ERROR); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
606 |
continue; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
607 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
608 |
if (isGoodUSBPersonality(device, connInfo, personality)) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
609 |
// if current mode was bad, and we switched, then we'll pick it up at next notification |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
610 |
// if current mode is still bad, don't put into good list |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
611 |
// if current mode is good, store it to good list |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
612 |
DeviceConnection newConnection = new DeviceConnection(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
613 |
newConnection.friendlyName = device.friendlyName; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
614 |
if (!device.serialNumber.equals(NOT_KNOWN)) |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
615 |
newConnection.serialNumber = device.serialNumber; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
616 |
else if (!personality.serialNumber.equals(NOT_KNOWN)) |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
617 |
newConnection.serialNumber = personality.serialNumber; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
618 |
else |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
619 |
newConnection.serialNumber = NOT_KNOWN; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
620 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
621 |
newConnection.media = connInfo.media; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
622 |
newConnection.port = connInfo.port; // port may be IP address or COM Port depending on personality |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
623 |
newConnection.mode = connInfo.mode; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
624 |
newConnection.address = connInfo.address; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
625 |
if (!newConnection.friendlyName.equals(NOT_KNOWN) && !newConnection.address.equals(NOT_KNOWN)) |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
626 |
goodConnections.add(newConnection); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
627 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
628 |
} else if (connInfo.media.equals("bluetooth")) { //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
629 |
// TODO: Bluetooth - not supported yet |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
630 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
631 |
// TODO: what else? |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
632 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
633 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
634 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
635 |
if (upapiOpen) |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
636 |
closeUPAPI(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
637 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
638 |
return goodConnections; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
639 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
640 |
/** |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
641 |
* Forget all previous "no-switch-personality" devices that are not in current list (e.g., device is now disconnected) |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
642 |
* |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
643 |
* @param personalityList |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
644 |
*/ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
645 |
private void forgetAllNoSwitchConnectionsNotInCurrentList( |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
646 |
Collection<DeviceUSBPersonalityInfo> personalityList) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
647 |
if (personalityList == null || personalityList.isEmpty()) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
648 |
if (DEBUG) System.out.println("forgetAllNoSwitchConnectionsNotInCurrentList: all"); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
649 |
noSwitchConnections.clear(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
650 |
} else if (noSwitchConnections == null || noSwitchConnections.isEmpty()) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
651 |
if (DEBUG) System.out.println("forgetAllNoSwitchConnectionsNotInCurrentList: noSwitchConnections already empty"); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
652 |
return; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
653 |
} else { |
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
654 |
for (String id : new ArrayList<String>(noSwitchConnections)) { |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
655 |
boolean found = false; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
656 |
for (DeviceUSBPersonalityInfo personality : personalityList) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
657 |
if (id.equals(personality.deviceID)) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
658 |
found = true; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
659 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
660 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
661 |
if (!found) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
662 |
if (DEBUG) System.out.println("forgetAllNoSwitchConnectionsNotInCurrentList: " + id); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
663 |
noSwitchConnections.remove(id); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
664 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
665 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
666 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
667 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
668 |
/** |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
669 |
* Find a matching device in the personality list (all USB devices).<p> |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
670 |
* Might have to use a combination of the serial number and device ID to match with ID's from personality. |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
671 |
* @param numUSBPersonalities |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
672 |
* |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
673 |
* @param serialNumber - serial number from connectivity API |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
674 |
* @param address - this contains the device ID from the connectivity API |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
675 |
* @param personalityList - all USB-connected devices |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
676 |
* @return - null if no personality found |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
677 |
*/ |
1092
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
678 |
private DeviceUSBPersonalityInfo findPersonality(int numUSBDevicesExpected, String serialNumber, String address, Collection<DeviceUSBPersonalityInfo> personalityList) { |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
679 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
680 |
if (DEBUG) System.out.println("findPersonality: start"); //$NON-NLS-1$ |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
681 |
if (personalityList == null || personalityList.isEmpty()) { |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
682 |
if (DEBUG) System.out.println("findPersonality: list is empty"); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
683 |
return null; |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
684 |
} |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
685 |
|
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
686 |
for (DeviceUSBPersonalityInfo personality : personalityList) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
687 |
if (DEBUG) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
688 |
System.out.printf("findPersonality: serialNums: %s\t%s\n", serialNumber, personality.serialNumber); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
689 |
System.out.printf("findPersonality: address: %s\tdeviceID: %s\n", address, personality.deviceID); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
690 |
} |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
691 |
// sometimes the serial numbers match except the personality one has an added 0 |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
692 |
if (!serialNumber.equals(NOT_KNOWN) && !personality.serialNumber.equals(NOT_KNOWN)) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
693 |
// serial number not null from both DMAPI and UPAPI |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
694 |
if (serialNumber.equals(personality.serialNumber)) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
695 |
if (DEBUG) System.out.println("findPersonality: serialNums match"); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
696 |
return personality; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
697 |
} else if (new String(serialNumber+"0").equals(personality.serialNumber)) { //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
698 |
if (DEBUG) System.out.println("findPersonality: serialNums match (by appending '0' to DMAPI)"); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
699 |
return personality; |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
700 |
} else { |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
701 |
if (DEBUG) System.out.println("findPersonality: both serialNums != null && serialNums do not match"); //$NON-NLS-1$ |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
702 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
703 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
704 |
// cannot use serial numbers! try using device IDs |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
705 |
if (!address.equals(NOT_KNOWN) && !personality.deviceID.equals(NOT_KNOWN)) { |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
706 |
// example device ids: |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
707 |
// 0\VID_0421&PID_00AB\0 (no serial number as part of id) |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
708 |
// 004401011418023\VID_0421&PID_0500\0 (serial number comes at front) |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
709 |
// compare Device IDs |
1092
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
710 |
String vidpid = address.substring(address.indexOf('\\'), address.lastIndexOf('\\')); |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
711 |
String endid = address.substring(address.lastIndexOf('\\')+1); |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
712 |
if (personality.deviceID.contains(vidpid) && personality.deviceID.contains(endid)) { |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
713 |
if (DEBUG) System.out.println("findPersonality: address matches deviceID with end number\n"); //$NON-NLS-1$ |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
714 |
return personality; |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
715 |
} |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
716 |
else if (personality.deviceID.contains(vidpid) && personality.deviceID.contains(serialNumber)) { |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
717 |
if (DEBUG) System.out.println("findPersonality: address matches deviceID with serial number\n"); //$NON-NLS-1$ |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
718 |
return personality; |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
719 |
} else { |
1092
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
720 |
if (serialNumber.equals(NOT_KNOWN)) { |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
721 |
if (personality.deviceID.contains(vidpid) && numUSBDevicesExpected == 1) { |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
722 |
if (DEBUG) System.out.println("findPersonality: serial number not known, but VID/PID match\n"); //$NON-NLS-1$ |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
723 |
return personality; |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
724 |
} |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
725 |
} |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
726 |
String begin = personality.deviceID.substring(0, personality.deviceID.indexOf('\\')); |
1092
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
727 |
if (begin.equals("0") || numUSBDevicesExpected == 1) { |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
728 |
// no serial number at beginning |
1092
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
729 |
if (personality.deviceID.contains(vidpid)) { |
cfabdba53722
Fix for 1 device and 1 personality not matching. Bug 10843. Should also improve bug 10805, but not in the case of multiple devices.
Chad Peckham <chad.peckham@nokia.com>
parents:
1080
diff
changeset
|
730 |
if (DEBUG) System.out.println("findPersonality: address matches deviceID without serial number\n"); //$NON-NLS-1$ |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
731 |
return personality; |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
732 |
} |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
733 |
} |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
734 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
735 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
736 |
// sometimes the serial number is part of the address! |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
737 |
if (!address.equals(NOT_KNOWN) && !personality.serialNumber.equals(NOT_KNOWN)) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
738 |
if (address.endsWith(personality.serialNumber)) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
739 |
if (DEBUG) System.out.println("findPersonality: address contains serialNumber"); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
740 |
return personality; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
741 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
742 |
} |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
743 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
744 |
if (DEBUG) System.out.println("findPersonality end return null"); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
745 |
return null; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
746 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
747 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
748 |
/** |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
749 |
* This will do a switch if the user wants us to. |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
750 |
* |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
751 |
* @param device - USB-connected device |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
752 |
* @param connInfo - connection information for this USB-connected device |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
753 |
* @param personalities - USB personalities of all devices (not just this one) |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
754 |
* @return true - iff we're in a 'good' USB personality already |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
755 |
* if we have to switch, the device will disconnect and reconnect in the other personality |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
756 |
* |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
757 |
* Only 'good' personalities are: |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
758 |
* PC Suite - Serial |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
759 |
* OVI Suite - Serial |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
760 |
* RNDIS - TCP/IP - currently unsupported |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
761 |
*/ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
762 |
private boolean isGoodUSBPersonality(DeviceInfo device, |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
763 |
DeviceConnectionInfo connInfo, |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
764 |
DeviceUSBPersonalityInfo personality) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
765 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
766 |
if (DEBUG) System.out.printf("isGoodUSBPersonality: current personality: %d %s\n", personality.currentPersonalityCode, personality.currentPersonalityDescription); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
767 |
// currently assume that mode is always 'serial' |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
768 |
if (personality.currentPersonalityCode == UPAPIDefinitions.UPAPI_PERSONALITY_CODE_PC_SUITE || |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
769 |
personality.currentPersonalityCode == UPAPIDefinitions.UPAPI_PERSONALITY_CODE_OVI_SUITE) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
770 |
connInfo.mode = "serial"; //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
771 |
connInfo.port = getUSBComPort(connInfo.address); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
772 |
// good personality |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
773 |
forgetNoSwitchConnections(personality.deviceID); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
774 |
return true; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
775 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
776 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
777 |
// bad personality - switch? if dontAskAgain is true - return bad personality |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
778 |
int goodCode = UPAPIDefinitions.UPAPI_PERSONALITY_CODE_PC_SUITE; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
779 |
if (personality.supportedPersonalities.containsKey(new Integer(UPAPIDefinitions.UPAPI_PERSONALITY_CODE_OVI_SUITE))) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
780 |
goodCode = UPAPIDefinitions.UPAPI_PERSONALITY_CODE_OVI_SUITE; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
781 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
782 |
String goodDesc = personality.supportedPersonalities.get(new Integer(goodCode)); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
783 |
|
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
784 |
if (!noSwitchConnectionsContains(personality.deviceID)) |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
785 |
// ask to switch |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
786 |
askToSwitchPersonality(device, personality, goodCode, goodDesc); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
787 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
788 |
// was bad personality - if we switched, it will be good next notification |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
789 |
if (DEBUG) System.out.println("isGoodUSBPersonality: return false"); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
790 |
return false; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
791 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
792 |
|
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
793 |
/** |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
794 |
* Search previous "no-switch-personality" list for a new device (e.g., user already said no before - don't ask again unless he reconnects) |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
795 |
* |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
796 |
* @param deviceID |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
797 |
* @return |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
798 |
*/ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
799 |
private boolean noSwitchConnectionsContains(String deviceID) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
800 |
if (!noSwitchConnections.isEmpty()) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
801 |
for (String id : noSwitchConnections) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
802 |
if (id.equals(deviceID)) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
803 |
return true; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
804 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
805 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
806 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
807 |
return false; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
808 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
809 |
/** |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
810 |
* Forget one device in previous "no-switch-personality" list (e.g., device is now in a good personality and doesn't need switching) |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
811 |
* |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
812 |
* @param deviceID |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
813 |
*/ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
814 |
private void forgetNoSwitchConnections(String deviceID) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
815 |
if (noSwitchConnections.isEmpty()) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
816 |
if (DEBUG) System.out.println("forgetNoSwitchConnections empty"); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
817 |
return; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
818 |
} |
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
819 |
if (DEBUG) System.out.println("forgetNoSwitchConnections: " + deviceID); |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
820 |
noSwitchConnections.remove(deviceID); |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
821 |
} |
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
822 |
|
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
823 |
private void askToSwitchPersonality(final DeviceInfo device, |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
824 |
final DeviceUSBPersonalityInfo personality, final int goodCode, final String goodDesc) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
825 |
|
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
826 |
// remember this device so we don't ask again unless it changes personality or is reconnected |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
827 |
rememberNoSwitchConnections(personality.deviceID); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
828 |
|
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
829 |
String message = MessageFormat.format( |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
830 |
"''{0}'' is currently in {1} mode\nand must be in {2} mode to be usable in Carbide.", |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
831 |
device.friendlyName, |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
832 |
personality.currentPersonalityDescription, |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
833 |
goodDesc); |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
834 |
final IStatus status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, message); |
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
835 |
|
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
836 |
String prompt = MessageFormat.format("Switch to {0} mode now.", goodDesc); |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
837 |
|
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
838 |
RemoteConnectionsActivator.getStatusDisplay().displayStatusWithAction(status, prompt, new Runnable() { |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
839 |
public void run() { |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
840 |
WString pstrDeviceId = new WString(personality.deviceID); |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
841 |
int dwResult = library.UPAPI_SetPersonality(upHandle, pstrDeviceId, goodCode); |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
842 |
if (dwResult != PCCSErrors.CONA_OK) { |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
843 |
forgetNoSwitchConnections(personality.deviceID); |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
844 |
String message = status.getMessage() + "\nThe device returned an error when trying to switch. Disconnect and reconnect in the proper mode."; |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
845 |
Activator.logMessage(message, IStatus.ERROR); |
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
846 |
if (DEBUG) System.out.printf("UPAPI_SetPersonality failed: %x\n", dwResult); //$NON-NLS-1$ |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
847 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
848 |
} |
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
849 |
}); |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
850 |
|
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
851 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
852 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
853 |
/** |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
854 |
* Device is bad personality and user said 'no' to switch (we won't ask again for this device unless it is reconnected or now in a good mode) |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
855 |
* |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
856 |
* @param deviceID |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
857 |
*/ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
858 |
private void rememberNoSwitchConnections(String deviceID) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
859 |
if (DEBUG) System.out.println("rememberNoSwitchConnections: " + deviceID); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
860 |
noSwitchConnections.add(deviceID); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
861 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
862 |
/** |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
863 |
* This function assumes the UPAPI has already been loaded by the caller |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
864 |
* @return - list of personalities |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
865 |
*/ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
866 |
private Collection<DeviceUSBPersonalityInfo> getAllDeviceUSBPersonalities() { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
867 |
Collection<DeviceUSBPersonalityInfo> p = new ArrayList<DeviceUSBPersonalityInfo>(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
868 |
boolean apiError = false; |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
869 |
|
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
870 |
// how many USB devices are connected |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
871 |
IntBuffer pdwDeviceCount = IntBuffer.allocate(1); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
872 |
int dwResult = library.UPAPI_QueryDeviceCount(upHandle, pdwDeviceCount); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
873 |
if (dwResult == PCCSErrors.CONA_OK) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
874 |
int dwDeviceCount = pdwDeviceCount.get(0); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
875 |
if (DEBUG) System.out.printf("UPAPI_QueryDeviceCount: dwDeviceCount: %d\n", dwDeviceCount); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
876 |
if (dwDeviceCount > 0) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
877 |
UP_DEVICE_DESCRIPTOR[] pDeviceDescriptor = (UP_DEVICE_DESCRIPTOR[])new UP_DEVICE_DESCRIPTOR().toArray(dwDeviceCount); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
878 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
879 |
// get the descriptor for all USB device |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
880 |
dwResult = library.UPAPI_QueryDevices(upHandle, pdwDeviceCount, pDeviceDescriptor); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
881 |
if (dwResult == PCCSErrors.CONA_OK) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
882 |
if (DEBUG) System.out.printf("UPAPI_QueryDevices dwDeviceCount: %d\n", dwDeviceCount); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
883 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
884 |
UP_DEVICE_DESCRIPTOR[] devices = pDeviceDescriptor; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
885 |
// |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
886 |
for (int i = 0; i < dwDeviceCount; i++) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
887 |
// save important device descriptor information for each device |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
888 |
DeviceUSBPersonalityInfo deviceInfo = new DeviceUSBPersonalityInfo(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
889 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
890 |
// device ID is very important to get personalities and for matching with |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
891 |
// the connectivity API |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
892 |
if (devices[i].pstrDeviceID != null) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
893 |
deviceInfo.deviceID = devices[i].pstrDeviceID.getPointer().getString(0, true); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
894 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
895 |
deviceInfo.deviceID = NOT_KNOWN; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
896 |
} |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
897 |
if (DEBUG) System.out.println("UPAPI_QueryDevices: ID found: " + deviceInfo.deviceID); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
898 |
// nice to have, but maybe null on some devices |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
899 |
if (devices[i].pstrSerialNumber != null) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
900 |
deviceInfo.serialNumber = devices[i].pstrSerialNumber.getPointer().getString(0, true); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
901 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
902 |
deviceInfo.serialNumber = NOT_KNOWN; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
903 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
904 |
// now get the personality descriptor for this device |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
905 |
apiError = getPersonalityDescriptors(p, deviceInfo); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
906 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
907 |
if (DEBUG) System.out.println("getAllDeviceUSBPersonalities all devices read"); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
908 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
909 |
apiError = true; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
910 |
if (DEBUG) |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
911 |
System.out.printf("UPAPI_QueryDevices dwResult = %x\n", dwResult); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
912 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
913 |
dwResult = library.UPAPI_FreeDeviceDescriptor(dwDeviceCount, pDeviceDescriptor); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
914 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
915 |
if (DEBUG) System.out.println("getAllDeviceUSBPersonalities no devices"); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
916 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
917 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
918 |
apiError = true; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
919 |
if (DEBUG) |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
920 |
System.out.printf("UPAPI_QueryDeviceCount dwResult = %x\n", dwResult); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
921 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
922 |
if (DEBUG) System.out.printf("getAllDeviceUSBPersonalities return size : %s\n", p.size()); //$NON-NLS-1$ |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
923 |
return p; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
924 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
925 |
private boolean getPersonalityDescriptors( |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
926 |
Collection<DeviceUSBPersonalityInfo> p, |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
927 |
DeviceUSBPersonalityInfo deviceInfo) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
928 |
int dwResult; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
929 |
|
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
930 |
boolean apiError = false; |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
931 |
// make device ID a wide string so JNA marshals it appropriately |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
932 |
WString pid = new WString(deviceInfo.deviceID); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
933 |
UP_PERSONALITY_DESCRIPTORS[] persDesc = (UP_PERSONALITY_DESCRIPTORS[])new UP_PERSONALITY_DESCRIPTORS().toArray(1); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
934 |
persDesc[0].dwSize = 12; // important - won't work without this |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
935 |
dwResult = library.UPAPI_GetPersonalityDescriptors(upHandle, pid, persDesc); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
936 |
if (dwResult == PCCSErrors.CONA_OK) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
937 |
// store personality information |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
938 |
deviceInfo.currentPersonalityCode = (persDesc[0].bCurrentPersonality & 0xff); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
939 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
940 |
// get num of supported personalities |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
941 |
int numPers = (persDesc[0].bNumOfPersonalities & 0xff); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
942 |
if (DEBUG) System.out.printf("UPAPI_GetPersonalityDescriptors numPers = %d\n", numPers); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
943 |
|
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
944 |
// get all the supported personalities for this device |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
945 |
apiError = getSupportedPersonalities(deviceInfo, pid, persDesc, numPers); |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
946 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
947 |
apiError = true; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
948 |
if (DEBUG) |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
949 |
System.out.printf("UPAPI_GetPersonalityDescriptors dwResult = %x\n", dwResult); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
950 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
951 |
dwResult = library.UPAPI_FreePersonalityDescriptors(persDesc); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
952 |
if (apiError == false) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
953 |
if (DEBUG) System.out.println("getAllDeviceUSBPersonalities deviceInfo added"); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
954 |
p.add(deviceInfo); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
955 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
956 |
return apiError; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
957 |
} |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
958 |
private boolean getSupportedPersonalities(DeviceUSBPersonalityInfo deviceInfo, WString pid, |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
959 |
UP_PERSONALITY_DESCRIPTORS[] persDesc, int numPers) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
960 |
int dwResult; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
961 |
UP_PERSONALITY[] pSupportedPersonality = null; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
962 |
if (numPers > 0) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
963 |
pSupportedPersonality = (UP_PERSONALITY[])persDesc[0].pPersonalities.toArray(numPers); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
964 |
deviceInfo.supportedPersonalities = new HashMap<Integer, String>(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
965 |
} |
1040
6028c6c9c6ad
more work on multiple phone connections
Chad Peckham <chad.peckham@nokia.com>
parents:
1035
diff
changeset
|
966 |
boolean apiError = false; |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
967 |
// now get the string descriptor for each supported personality |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
968 |
for (int j = 0; j < numPers; j++) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
969 |
Integer code = new Integer(pSupportedPersonality[j].bPersonalityCode); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
970 |
int stringIndex = (pSupportedPersonality[j].bPersonalityIndex & 0xff); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
971 |
UP_STRING_DESCRIPTOR pStringDescriptor = new UP_STRING_DESCRIPTOR(); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
972 |
String desc = NOT_KNOWN; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
973 |
pStringDescriptor.dwSize = 12; // this is important |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
974 |
dwResult = library.UPAPI_GetStringDescriptor(upHandle, pid, stringIndex, 0, pStringDescriptor); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
975 |
if (dwResult == PCCSErrors.CONA_OK) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
976 |
if (pStringDescriptor.pstrDescription != null) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
977 |
desc = pStringDescriptor.pstrDescription.getPointer().getString(0, true); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
978 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
979 |
if (DEBUG) System.out.printf("UPAPI_GetStringDescriptor code: %d, desc: %s\n", code.intValue(), desc); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
980 |
dwResult = library.UPAPI_FreeStringDescriptor(pStringDescriptor); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
981 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
982 |
apiError = true; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
983 |
if (DEBUG) |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
984 |
System.out.printf("UPAPI_GetStringDescriptor dwResult = %x\n", dwResult); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
985 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
986 |
if (apiError == false) |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
987 |
deviceInfo.supportedPersonalities.put(code, desc); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
988 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
989 |
if (deviceInfo.supportedPersonalities.isEmpty()) { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
990 |
deviceInfo.currentPersonalityDescription = MessageFormat.format(Messages.PCCSConnection_Generic_Personality_Description, Integer.toString(deviceInfo.currentPersonalityCode)); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
991 |
} else { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
992 |
deviceInfo.currentPersonalityDescription = deviceInfo.supportedPersonalities.get(new Integer(deviceInfo.currentPersonalityCode)); |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
993 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
994 |
if (DEBUG) System.out.printf("current Desc found: %s\n", deviceInfo.currentPersonalityDescription); //$NON-NLS-1$ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
995 |
return apiError; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
996 |
} |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
997 |
|
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
998 |
|
1035
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
999 |
// private String getBTComPort(String address) { |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
1000 |
// // TODO Auto-generated method stub |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
1001 |
// return null; |
a50c0b5d243e
remove ui dependency + use new notification to switch mode
dadubrow
parents:
1014
diff
changeset
|
1002 |
// } |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1003 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1004 |
public String getUSBComPort(String address) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1005 |
if (address != null && address.length() > 0) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1006 |
String id, key, subKey, parentIdPrefix = null, portName; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1007 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1008 |
WindowsRegistry wr = WindowsRegistry.getRegistry(); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1009 |
key = "SYSTEM\\ControlSet001\\Enum\\USB" + address.substring(address.indexOf('\\'), address.lastIndexOf('\\')); //$NON-NLS-1$ |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1010 |
id = address.substring(address.lastIndexOf('\\') + 1); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1011 |
int i = 0; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1012 |
do { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1013 |
subKey = wr.getLocalMachineKeyName(key, i); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1014 |
if (subKey != null && subKey.equalsIgnoreCase(id)) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1015 |
key += "\\" + subKey; //$NON-NLS-1$ |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1016 |
parentIdPrefix = wr.getLocalMachineValue(key, "ParentIdPrefix"); //$NON-NLS-1$ |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1017 |
break; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1018 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1019 |
i++; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1020 |
} while (subKey != null); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1021 |
if (parentIdPrefix != null) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1022 |
key = "SYSTEM\\ControlSet001\\Enum\\NMWCD"; //$NON-NLS-1$ |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1023 |
subKey = address.substring(address.indexOf('\\'), address.lastIndexOf('\\')); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1024 |
key += subKey + "&IF_JAVACOMM"; //$NON-NLS-1$ |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1025 |
i = 0; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1026 |
do { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1027 |
subKey = wr.getLocalMachineKeyName(key, i); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1028 |
if (subKey != null && subKey.contains(parentIdPrefix)) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1029 |
key += "\\" + subKey + "\\Device Parameters"; //$NON-NLS-1$ //$NON-NLS-2$ |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1030 |
portName = wr.getLocalMachineValue(key, "PortName"); //$NON-NLS-1$ |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1031 |
if (portName != null) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1032 |
portName = portName.substring(portName.indexOf('M') + 1); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1033 |
return portName; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1034 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1035 |
break; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1036 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1037 |
i++; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1038 |
} while (subKey != null); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1039 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1040 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1041 |
return null; |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1042 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1043 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1044 |
public void addEventListenter(DeviceEventListener listener) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1045 |
listeners.add(listener); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1046 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1047 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1048 |
public void removeEventListener(DeviceEventListener listener) { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1049 |
listeners.remove(listener); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1050 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1051 |
|
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1052 |
public interface DeviceEventListener { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1053 |
public enum DeviceEvent { |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1054 |
DEVICE_LIST_UPDATED, // not any specific information |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1055 |
DEVICE_ADDED, |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1056 |
DEVICE_REMOVED, |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1057 |
DEVICE_UPDATED_ADDEDCONNECTION, |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1058 |
DEVICE_UPDATED_REMOVEDCONNECTION, |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1059 |
DEVICE_UPDATED_RENAMED, |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1060 |
DEVICE_UPDATED_UNKNOWN, |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1061 |
} |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1062 |
public void onDeviceEvent(DeviceEvent eventType, String serialNumber); |
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1063 |
} |
941
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1064 |
/** |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1065 |
* Class to hold USB personality information from UPAPI per Device |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1066 |
*/ |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1067 |
private class DeviceUSBPersonalityInfo { |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1068 |
String deviceID; // from device descriptor |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1069 |
String serialNumber; // from device descriptor |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1070 |
int currentPersonalityCode; // from personality descriptor |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1071 |
String currentPersonalityDescription; // from list of supported personalities |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1072 |
// list of supported personalities |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1073 |
// int = personality code |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1074 |
// string = personality description for code from device |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1075 |
Map<Integer, String> supportedPersonalities; |
e90e6ea44529
PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents:
869
diff
changeset
|
1076 |
} |
1014
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1077 |
public void testPrerequisites() throws CoreException { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1078 |
try { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1079 |
if (library == null) |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1080 |
library = IConnAPILibrary.INSTANCE; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1081 |
} catch (UnsatisfiedLinkError e) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1082 |
String msg; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1083 |
if (Activator.isSymSEELayout()) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1084 |
msg = Messages.ConnAPILibrary_PCCS_Not_Found_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1085 |
} else { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1086 |
msg = Messages.ConnAPILibrary_PCSuite_Not_Found_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1087 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1088 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, PCCSConnection.PCCS_NOT_FOUND, msg, e)); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1089 |
} catch (NoClassDefFoundError e) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1090 |
String msg; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1091 |
if (Activator.isSymSEELayout()) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1092 |
msg = Messages.ConnAPILibrary_PCCS_Not_Found_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1093 |
} else { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1094 |
msg = Messages.ConnAPILibrary_PCSuite_Not_Found_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1095 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1096 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, PCCSConnection.PCCS_NOT_FOUND, msg, e)); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1097 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1098 |
testDMAPI(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1099 |
testUPAPI(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1100 |
testMCAPI(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1101 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1102 |
/* |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1103 |
* Tests version of DMAPI and leaves it closed |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1104 |
*/ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1105 |
private void testDMAPI() throws CoreException { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1106 |
int dwResult = library.DMAPI_Initialize(DMAPI_VERSION, null); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1107 |
library.DMAPI_Terminate(null); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1108 |
if (dwResult != PCCSErrors.CONA_OK) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1109 |
String msg; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1110 |
if (Activator.isSymSEELayout()) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1111 |
msg = String.format("PCCS DMAPI_Initialize API returned error on initialization %x", dwResult); //$NON-NLS-1$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1112 |
if (dwResult == PCCSErrors.ECONA_UNSUPPORTED_API_VERSION) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1113 |
msg = Messages.PCCSConnection_PCCS_Version_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1114 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1115 |
} else { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1116 |
msg = Messages.PCCSConnection_PCSuite_Version_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1117 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1118 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, PCCS_WRONG_VERSION, msg, null)); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1119 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1120 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1121 |
/* |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1122 |
* Test version of UPAPI and leaves it closed |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1123 |
*/ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1124 |
private void testUPAPI() throws CoreException { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1125 |
int dwResult = PCCSErrors.CONA_OK; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1126 |
dwResult = library.UPAPI_Initialize(UPAPIDefinitions.UPAPI_VERSION_10, null); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1127 |
library.UPAPI_Terminate(null); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1128 |
if (dwResult != PCCSErrors.CONA_OK) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1129 |
String msg; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1130 |
msg = String.format("PCCS UPAPI_Initialize API returned error on initialization %x", dwResult); //$NON-NLS-1$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1131 |
if (DEBUG) System.out.println(msg); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1132 |
if (Activator.isSymSEELayout()) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1133 |
if (dwResult == PCCSErrors.ECONA_UNSUPPORTED_API_VERSION) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1134 |
msg = Messages.PCCSConnection_PCCS_Version_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1135 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1136 |
} else { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1137 |
msg = Messages.PCCSConnection_PCSuite_Version_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1138 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1139 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, PCCS_WRONG_VERSION, msg, null)); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1140 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1141 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1142 |
/* |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1143 |
* Test version of MCAPI and leaves it closed |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1144 |
*/ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1145 |
private void testMCAPI() throws CoreException { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1146 |
int dwResult = PCCSErrors.CONA_OK; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1147 |
dwResult = library.MCAPI_Initialize(MCAPIDefinitions.MCAPI_VERSION_32, null); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1148 |
library.MCAPI_Terminate(null); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1149 |
if (dwResult != PCCSErrors.CONA_OK) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1150 |
String msg; |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1151 |
if (Activator.isSymSEELayout()) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1152 |
msg = String.format("PCCS MCAPI_Initialize API returned error on initialization %x", dwResult); //$NON-NLS-1$ |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1153 |
if (dwResult == PCCSErrors.ECONA_UNSUPPORTED_API_VERSION) { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1154 |
msg = Messages.PCCSConnection_PCCS_Version_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1155 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1156 |
} else { |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1157 |
msg = Messages.PCCSConnection_PCSuite_Version_Error + Activator.getLoadErrorURL(); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1158 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1159 |
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, PCCS_WRONG_VERSION, msg, null)); |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1160 |
} |
e3fac3e42c4a
Changes to fix bugs 10618 10714 10731 10759 10580
Chad Peckham <chad.peckham@nokia.com>
parents:
941
diff
changeset
|
1161 |
} |
869
cb5e1f0959c9
move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff
changeset
|
1162 |
} |