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.services.connectiontestservice;
|
|
19 |
|
|
20 |
import java.util.List;
|
|
21 |
|
|
22 |
import com.nokia.s60tools.hticonnection.core.RequestQueueManager;
|
|
23 |
import com.nokia.s60tools.hticonnection.core.RequestResult;
|
|
24 |
import com.nokia.s60tools.hticonnection.exceptions.ConnectionException;
|
|
25 |
import com.nokia.s60tools.hticonnection.exceptions.HTIException;
|
|
26 |
import com.nokia.s60tools.hticonnection.exceptions.ServiceShutdownException;
|
|
27 |
import com.nokia.s60tools.hticonnection.services.HTIVersion;
|
|
28 |
import com.nokia.s60tools.hticonnection.services.IConnectionTestService;
|
|
29 |
import com.nokia.s60tools.util.console.IConsolePrintUtility;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* Service that contains interface for testing if connection is ready for use.
|
|
33 |
*/
|
|
34 |
public class ConnectionTestService implements IConnectionTestService{
|
|
35 |
|
|
36 |
/**
|
|
37 |
* Print utility used to report errors, warnings, and info messages.
|
|
38 |
*/
|
|
39 |
private final IConsolePrintUtility printUtility;
|
|
40 |
|
|
41 |
/**
|
|
42 |
* Constructor.
|
|
43 |
* @param printUtility Used for printing messages.
|
|
44 |
*/
|
|
45 |
public ConnectionTestService(IConsolePrintUtility printUtility){
|
|
46 |
this.printUtility = printUtility;
|
|
47 |
}
|
|
48 |
|
|
49 |
/* (non-Javadoc)
|
|
50 |
* @see com.nokia.s60tools.hticonnection.services.IConnectionTestService#isReady()
|
|
51 |
*/
|
|
52 |
public boolean isReady(){
|
|
53 |
ConnectionTestRequest request = new ConnectionTestRequest();
|
|
54 |
|
|
55 |
try {
|
|
56 |
// Getting result for connection test.
|
|
57 |
RequestResult result = RequestQueueManager.getInstance().submit(request, printUtility);
|
|
58 |
return result.getBooleanData();
|
|
59 |
} catch (Exception e) {
|
|
60 |
// Request failed.
|
|
61 |
return false;
|
|
62 |
}
|
|
63 |
}
|
|
64 |
|
|
65 |
/* (non-Javadoc)
|
|
66 |
* @see com.nokia.s60tools.hticonnection.services.IConnectionTestService#listServices()
|
|
67 |
*/
|
|
68 |
public List<String> listServices() throws HTIException, ConnectionException, ServiceShutdownException{
|
|
69 |
ListServiceRequest request = new ListServiceRequest();
|
|
70 |
|
|
71 |
// Getting result for connection test.
|
|
72 |
RequestResult result = RequestQueueManager.getInstance().submit(request, printUtility);
|
|
73 |
return result.getListData();
|
|
74 |
}
|
|
75 |
|
|
76 |
/* (non-Javadoc)
|
|
77 |
* @see com.nokia.s60tools.hticonnection.services.IConnectionTestService#getVersion()
|
|
78 |
*/
|
|
79 |
public HTIVersion getVersion() throws HTIException, ConnectionException, ServiceShutdownException{
|
|
80 |
GetVersionRequest request = new GetVersionRequest();
|
|
81 |
|
|
82 |
// Getting result for connection test.
|
|
83 |
RequestResult result = RequestQueueManager.getInstance().submit(request, printUtility);
|
|
84 |
return result.getHTIVersionData();
|
|
85 |
}
|
|
86 |
}
|