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