author | Matti Laitinen <matti.t.laitinen@nokia.com> |
Thu, 04 Mar 2010 13:38:40 +0200 | |
changeset 7 | 018264c44c89 |
parent 0 | 61163b28edca |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
package com.nokia.s60tools.hticonnection.connection; |
|
19 |
||
20 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
21 |
import org.osgi.framework.Version; |
|
22 |
||
7
018264c44c89
HTI Connection v1.3.1 - Supporting Carbide 2.5
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
0
diff
changeset
|
23 |
import com.nokia.carbide.remoteconnections.interfaces.AbstractConnectedService2; |
0 | 24 |
import com.nokia.carbide.remoteconnections.interfaces.AbstractSynchronizedConnection; |
25 |
import com.nokia.carbide.remoteconnections.interfaces.IService; |
|
26 |
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus; |
|
27 |
import com.nokia.s60tools.hticonnection.core.HtiConnection; |
|
28 |
import com.nokia.s60tools.hticonnection.core.HtiConnection.ConnectionStatus; |
|
29 |
import com.nokia.s60tools.hticonnection.resources.Messages; |
|
30 |
import com.nokia.s60tools.hticonnection.services.HTIVersion; |
|
31 |
||
32 |
/** |
|
33 |
* Connected service for HTI to contain connection information. |
|
34 |
*/ |
|
7
018264c44c89
HTI Connection v1.3.1 - Supporting Carbide 2.5
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
0
diff
changeset
|
35 |
public class HTIConnectedService extends AbstractConnectedService2 { |
018264c44c89
HTI Connection v1.3.1 - Supporting Carbide 2.5
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
0
diff
changeset
|
36 |
|
0 | 37 |
/** |
38 |
* Constructor. |
|
39 |
* @param service Service that is connected. |
|
40 |
* @param connection Connection that is connected. |
|
41 |
*/ |
|
42 |
public HTIConnectedService(IService service, |
|
43 |
AbstractSynchronizedConnection connection) { |
|
44 |
super(service, connection); |
|
45 |
currentStatus = new Status(); |
|
46 |
||
47 |
currentStatus.setEStatus(EStatus.DOWN, Messages.getString("HTIConnectedService.NotConnected_ShortMsg"), ""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
48 |
} |
|
49 |
||
50 |
/* (non-Javadoc) |
|
7
018264c44c89
HTI Connection v1.3.1 - Supporting Carbide 2.5
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
0
diff
changeset
|
51 |
* @see com.nokia.carbide.remoteconnections.interfaces.AbstractConnectedService2#runTestStatus(org.eclipse.core.runtime.IProgressMonitor) |
0 | 52 |
*/ |
53 |
protected TestResult runTestStatus(IProgressMonitor monitor) { |
|
7
018264c44c89
HTI Connection v1.3.1 - Supporting Carbide 2.5
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
0
diff
changeset
|
54 |
if(!externalTesting) { |
0 | 55 |
// Not using automatic testing as it would take too much resources. Returning currently known status. |
56 |
IStatus status = getStatusFromHtiConnection(); |
|
57 |
return new TestResult(status.getEStatus(), status.getShortDescription(), status.getLongDescription()); |
|
58 |
} |
|
7
018264c44c89
HTI Connection v1.3.1 - Supporting Carbide 2.5
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
0
diff
changeset
|
59 |
|
0 | 60 |
// Testing connection when user has ordered testing command from the settings wizard. |
61 |
monitor.beginTask("Testing HTI Service", IProgressMonitor.UNKNOWN); //$NON-NLS-1$ |
|
62 |
IStatus status = HtiConnection.getInstance().testConnection(connection); |
|
63 |
||
64 |
monitor.done(); |
|
65 |
||
66 |
return new TestResult(status.getEStatus(), status.getShortDescription(), status.getLongDescription()); |
|
67 |
} |
|
68 |
||
69 |
/* (non-Javadoc) |
|
70 |
* @see com.nokia.carbide.remoteconnections.interfaces.IConnectedService#getStatus() |
|
71 |
*/ |
|
72 |
public IStatus getStatus() { |
|
73 |
return currentStatus; |
|
74 |
} |
|
75 |
||
76 |
/** |
|
77 |
* Returns status of this connection. |
|
78 |
* @return Status of this connection. |
|
79 |
*/ |
|
80 |
public IStatus getStatusFromHtiConnection() { |
|
81 |
HtiConnection htiConnection = HtiConnection.getInstance(); |
|
82 |
||
83 |
HTIConnectionStatus status = null; |
|
84 |
if(connection.equals(htiConnection.getCurrentConnection())) { |
|
85 |
// This connection is active, getting status. |
|
86 |
ConnectionStatus connStatus = htiConnection.getConnectionStatus(); |
|
87 |
switch (connStatus) { |
|
88 |
case CONNECTED: |
|
89 |
HTIVersion version = HtiConnection.getInstance().getHTIVersion(); |
|
90 |
status = new HTIConnectionStatus(this, |
|
91 |
EStatus.UP, |
|
92 |
Messages.getString("HTIConnectedService.Connected_ShortMsg"), //$NON-NLS-1$ |
|
93 |
Messages.getString("HTIConnectedService.ConnectedToHti_LongMsg") + version.toString()); //$NON-NLS-1$ |
|
94 |
break; |
|
95 |
case CONNECTING: |
|
96 |
status = new HTIConnectionStatus(this, |
|
97 |
EStatus.UP, |
|
98 |
Messages.getString("HTIConnectedService.TryingToConnect_ShortMsg"), //$NON-NLS-1$ |
|
99 |
""); //$NON-NLS-1$ |
|
100 |
break; |
|
101 |
case SHUTDOWN: |
|
102 |
status = new HTIConnectionStatus(this, |
|
103 |
EStatus.DOWN, |
|
104 |
Messages.getString("HTIConnectedService.NotConnected_ShortMsg"), //$NON-NLS-1$ |
|
105 |
""); //$NON-NLS-1$ |
|
106 |
break; |
|
107 |
case TESTING: |
|
108 |
status = new HTIConnectionStatus(this, EStatus.UP, Messages.getString("HTIConnectedService.Testing_ShortMsg"), ""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
109 |
break; |
|
110 |
} |
|
111 |
} |
|
112 |
if(status == null) { |
|
113 |
// This connection is not active. |
|
114 |
status = new HTIConnectionStatus(this, EStatus.DOWN, Messages.getString("HTIConnectedService.NotConnected_ShortMsg"), ""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
115 |
} |
|
116 |
||
117 |
return status; |
|
118 |
} |
|
119 |
||
120 |
/** |
|
121 |
* Refreshes current status. |
|
122 |
*/ |
|
123 |
public void refreshStatus() { |
|
124 |
IStatus status = getStatusFromHtiConnection(); |
|
125 |
||
126 |
currentStatus.setEStatus(status.getEStatus(), status.getShortDescription(), status.getLongDescription()); |
|
127 |
} |
|
128 |
||
129 |
/* (non-Javadoc) |
|
130 |
* @see com.nokia.carbide.remoteconnections.interfaces.IConnectedService#setDeviceOS(java.lang.String, org.osgi.framework.Version) |
|
131 |
*/ |
|
132 |
public void setDeviceOS(String familyName, Version version) { |
|
133 |
// Not implemented. |
|
134 |
} |
|
135 |
} |