1 /* |
|
2 * Copyright (c) 2010 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 the License "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 package com.nokia.carbide.internal.discovery.ui.wizard; |
|
18 |
|
19 import java.io.OutputStream; |
|
20 import java.net.URI; |
|
21 import java.util.Arrays; |
|
22 import java.util.Collection; |
|
23 import java.util.HashSet; |
|
24 import java.util.Iterator; |
|
25 import java.util.Set; |
|
26 |
|
27 import org.eclipse.core.runtime.IProgressMonitor; |
|
28 import org.eclipse.equinox.p2.core.IProvisioningAgent; |
|
29 import org.eclipse.equinox.p2.engine.IProfile; |
|
30 import org.eclipse.equinox.p2.engine.IProfileRegistry; |
|
31 import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
|
32 import org.eclipse.equinox.p2.operations.ProvisioningSession; |
|
33 import org.eclipse.equinox.p2.query.IQueryResult; |
|
34 import org.eclipse.equinox.p2.query.QueryUtil; |
|
35 import org.eclipse.equinox.p2.ui.ProvisioningUI; |
|
36 |
|
37 class FeatureUtils { |
|
38 |
|
39 public static Collection<URI> getKnownRepositories() { |
|
40 ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI(); |
|
41 ProvisioningSession session = provisioningUI.getSession(); |
|
42 URI[] uris = provisioningUI.getRepositoryTracker().getKnownRepositories(session); |
|
43 return Arrays.asList(uris); |
|
44 } |
|
45 |
|
46 public static Collection<FeatureInfo> getInstalledFeatures(IProgressMonitor monitor) { |
|
47 Set<FeatureInfo> infos = new HashSet<FeatureInfo>(); |
|
48 ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI(); |
|
49 ProvisioningSession session = provisioningUI.getSession(); |
|
50 IProvisioningAgent agent = session.getProvisioningAgent(); |
|
51 IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); |
|
52 IProfile profile = null; |
|
53 if (profileRegistry != null) { |
|
54 profile = profileRegistry.getProfile(provisioningUI.getProfileId()); |
|
55 if (profile != null) { |
|
56 IQueryResult<IInstallableUnit> result = |
|
57 profile.query(QueryUtil.createIUGroupQuery(), monitor); |
|
58 for (Iterator<IInstallableUnit> iterator = result.iterator(); iterator.hasNext();) { |
|
59 infos.add(new FeatureInfo((IInstallableUnit) iterator.next())); |
|
60 } |
|
61 } |
|
62 } |
|
63 return infos; |
|
64 } |
|
65 |
|
66 public static void writeInfosToStream(Collection<FeatureInfo> featureInfos, OutputStream os) { |
|
67 // TODO Auto-generated method stub |
|
68 |
|
69 } |
|
70 } |
|