org.eclipse.cdt.launch.internal.ui,
org.eclipse.cdt.launch.ui,
org.eclipse.core.expressions,
+ org.eclipse.core.net.proxy,
org.eclipse.debug.core,
org.eclipse.debug.core.model,
org.eclipse.debug.ui,
</page>
</extension>
- <extension
- point="org.eclipse.ui.preferencePages">
- <page
- category="org.tizen.nativeplatform.preferences"
- class="org.tizen.nativeplatform.preferences.ui.proxy.HttpProxyPreferencePage"
- id="org.tizen.nativeplatform.gitconfig"
- name="%org.tizen.nativeplatform.proxyconfig.label">
- </page>
- </extension>
<extension
point="org.eclipse.ui.preferencePages">
</context>
</extension>
<!-- package manager end -->
-</plugin>
\ No newline at end of file
+</plugin>
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.tizen.nativecommon.build.CommonProjectDependentPackager;
-import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativecommon.build.exception.SBIException;
import org.tizen.nativeplatform.password.SudoPasswdManager;
import org.tizen.nativeplatform.preferences.PreferencesManager;
-import org.tizen.nativeplatform.preferences.ui.proxy.HttpProxyUtil;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
import org.tizen.nativeplatform.views.model.ICheckTreeItem;
import org.tizen.nativeplatform.views.model.PlatformRootstrap;
String workingDir = getWorkingDir(config);
String passwd = SudoPasswdManager.getSudoPassword();
- String httpAddr = PreferencesManager.getHttpProxy();
- String httpPort = PreferencesManager.getHttpProxyPort();
- String httpProxy = "";
- if (!httpAddr.isEmpty()) {
- httpProxy = HttpProxyUtil.getHttpProxy(httpAddr, httpPort);
- } else {
+ String httpProxy = PreferencesManager.getHttpProxy();
+ if (httpProxy.isEmpty()) {
httpProxy = "noproxy";
}
String name = rootstrap.getName();
import org.tizen.nativeplatform.pkgmgr.model.PackageProvider;
import org.tizen.nativeplatform.pkgmgr.model.RemotePkgProvider;
import org.tizen.nativeplatform.preferences.PreferencesManager;
-import org.tizen.nativeplatform.preferences.ui.proxy.HttpProxyUtil;
import org.tizen.nativeplatform.views.model.PlatformRootstrap;
public class RPMPackageDialog extends Dialog {
x = bounds.x + (bounds.width - width)/2;
y = bounds.y + (bounds.height - height)/2;
- String addr = PreferencesManager.getHttpProxy();
- String port = PreferencesManager.getHttpProxyPort();
- http_proxy = HttpProxyUtil.getHttpProxy(addr, port);
- RPMPackageCommander.setHttpProxy(http_proxy);
+ http_proxy = PreferencesManager.getHttpProxy();
+ RPMPackageCommander.setHttpProxy(PreferencesManager.getHttpProxy());
this.rootstrap = rootstrap;
}
IProject _project = CurrentEnabledProject.getCurrentProject();
IConfiguration config = ManagedBuildManager.getBuildInfo( _project ).getDefaultConfiguration();
configuration = config.getName();
- String addr = PreferencesManager.getHttpProxy();
- String port = PreferencesManager.getHttpProxyPort();
- http_proxy = HttpProxyUtil.getHttpProxy(addr, port);
+ http_proxy = PreferencesManager.getHttpProxy();
RPMPackageCommander.setHttpProxy(http_proxy);
}
if (enableTarget) {
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.core.net.proxy.IProxyData;
+import org.eclipse.core.net.proxy.IProxyService;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.util.tracker.ServiceTracker;
public class PreferencesManager {
private static final String GIT_LIST_CACHE_FILE_FORMAT = ".%s.index.html";
private static IPreferenceStore prefStore = org.tizen.nativecommon.Activator.getDefault().getPreferenceStore();
-
+ private static ServiceTracker<IProxyService,IProxyService> proxyTracker;
public static void setDefaultValues() {
if ( !prefStore.contains(GIT_CONFIG_NAME) ) {
}
- public static void setHttpProxy(String s) {
- prefStore.setValue(HTTPPROXY_KEY, s);
- }
-
- public static void setHttpProxyPort(String s) {
- prefStore.setValue(PROXYPORT_KEY, s);
- }
-
public static void setPassword(String p) {
prefStore.setValue(PASSWORD_KEY, p);
}
+
public static String getHttpProxy() {
- return prefStore.getString(HTTPPROXY_KEY);
+ IProxyData data = getHttpProxyData();
+ if ( data != null ) {
+ if ( data.getUserId() != null && data.getPassword() != null ) {
+ return String.format("http://%s:%s@%s:%d",
+ data.getUserId(), data.getPassword(), data.getHost(), data.getPort());
+ }
+ else if ( data.getUserId() != null && data.getPassword() != null ) {
+ return String.format("http://%s@%s:%d",
+ data.getUserId(), data.getHost(), data.getPort());
+ }
+ else {
+ return String.format("http://%s:%d", data.getHost(), data.getPort());
+ }
+ }
+
+ return "";
}
+
+ public static String getHttpProxyHost() {
+ IProxyData data = getHttpProxyData();
+ if ( data != null ) {
+ return data.getHost();
+ }
+ else {
+ return "";
+ }
+ }
+
+
public static String getHttpProxyPort() {
- return prefStore.getString(PROXYPORT_KEY);
+ IProxyData data = getHttpProxyData();
+ if ( data != null ) {
+ return String.format("%d", data.getPort() );
+ }
+ return "";
}
+
+ private static IProxyData getHttpProxyData() {
+ if ( proxyTracker == null ) {
+ proxyTracker = new ServiceTracker<IProxyService,IProxyService>(FrameworkUtil.getBundle(
+ PreferencesManager.class).getBundleContext(), IProxyService.class
+ .getName(), null);
+ proxyTracker.open();
+ }
+
+ IProxyService service = proxyTracker.getService();
+ if ( service.isProxiesEnabled() ) {
+ IProxyData data = service.getProxyData(IProxyData.HTTP_PROXY_TYPE);
+ if ( data != null && data.getHost() != null ) {
+ return data;
+ }
+ }
+
+ return null;
+ }
+
+
public static String getPassword() {
return prefStore.getString(PASSWORD_KEY);
}
+++ /dev/null
-package org.tizen.nativeplatform.preferences.ui.proxy;
-
-import java.util.ArrayList;
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.tizen.nativeplatform.preferences.PreferencesManager;
-
-
-public class HttpProxyPreferencePage extends PreferencePage implements IWorkbenchPreferencePage{
-
- private String port;
- private String proxy;
- private TableViewer proxyTable;
-
- private final String BUNDLE_NAME = HttpProxyPreferencePage.class.getPackage().getName() + ".ProxyConfUIMessages";//$NON-NLS-1$
- private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
- public HttpProxyPreferencePage() {
- }
-
- @Override
- public void init(IWorkbench workbench) {
- updateData();
- }
-
- @Override
- public void createControl(Composite parent) {
- super.createControl(parent);
- Button defaultButton = getDefaultsButton();
- if (defaultButton != null) {
- defaultButton.setVisible(false);
- }
-
- Button applyButton = getApplyButton();
-
- if(applyButton != null) {
- applyButton.setVisible(false);
- }
- }
-
- @Override
- protected Control createContents(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createGitDetailTableComposite(composite);
-
- return parent;
- }
-
- private void createGitDetailTableComposite(Composite parent) {
-
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout(1, false);
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- composite.setLayout(gridLayout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING));
-
- createDetailTableComposite(composite);
- createGitButtonComposite(composite);
- }
-
- private void createDetailTableComposite(Composite parent) {
-
- proxyTable = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- Table table = proxyTable.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- proxyTable.setLabelProvider(new TableViewerProvider());
- proxyTable.setContentProvider(new ArrayContentProvider());
-
- TableColumn column = new TableColumn(table, SWT.NONE);
- column.setResizable(true);
- column.setText(resources.getString("ConfPref.Column.Type"));
- column.setWidth(100);
-
- column = new TableColumn(table, SWT.NONE);
- column.setResizable(true);
- column.setText(resources.getString("ConfPref.Column.Value"));
- column.setWidth(300);
-
- GridData tableGridData = new GridData(GridData.FILL_HORIZONTAL);
- tableGridData.minimumHeight = 300;
- table.setLayoutData(tableGridData);
-
- setTableData();
- }
-
- private void setTableData() {
- ArrayList<String> datas = new ArrayList<String>();
- datas.add(resources.getString("ConfPref.Text.Addr") + "::" + proxy);
- datas.add(resources.getString("ConfPref.Text.Port") + "::" + port);
-
- proxyTable.setInput(datas);
- }
-
- private void updateData() {
- proxy = PreferencesManager.getHttpProxy();
- port = PreferencesManager.getHttpProxyPort();
-
- if (proxy.isEmpty() && port.isEmpty()) {
- setDefaultProxy();
- }
- }
-
- private void createGitButtonComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout(1, false);
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
-
- composite.setLayout(gridLayout);
- composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_BEGINNING));
-
- Button modifyBt = new Button(composite, SWT.PUSH);
- modifyBt.setText(resources.getString("ConfPref.Button.Modify"));
-
- modifyBt.addMouseListener(new MouseListener(){
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- ModifyProxyDialog dialog = new ModifyProxyDialog(getShell(), proxy, port);
- if (dialog.open() == ModifyProxyDialog.OK) {
- updateData();
- setTableData();
- }
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
- });
-
- }
-
- @Override
- public boolean performOk() {
- return super.performOk();
- }
-
- private class TableViewerProvider extends LabelProvider implements ITableLabelProvider
- {
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
- String[] splitValues = ((String)element).split("::");
- switch(columnIndex) {
- case 0:
- return splitValues[0];
- case 1:
- if (splitValues.length == 2) {
- return splitValues[1];
- } else {
- return "";
- }
- }
- return null;
- }
- }
-
- private void setDefaultProxy() {
- String[] values = HttpProxyUtil.getProxyEnv();
-
- if (values == null) {
- return;
- }
-
- if (values.length == 2) {
- proxy = values[0];
- port = values[1];
- } else if (values.length == 1) {
- proxy = values[0];
- }
-
- return;
- }
-}
+++ /dev/null
-package org.tizen.nativeplatform.preferences.ui.proxy;
-
-import java.util.Map;
-
-public class HttpProxyUtil {
-
- private static final String HTTP_PROXY_KEY = "http_proxy";
- private static final String[] HTTP_PROTOCOL = {"http://", "https://"};
- private static final String DELIMITER_PORT = ":";
-
- public HttpProxyUtil() {
-
- }
-
- public static String removeHttpProtocol(String s) {
- return s.replaceAll(HTTP_PROTOCOL[0], "").replaceAll(HTTP_PROTOCOL[1], "");
- }
-
- public static String[] getProxyEnv() {
- Map<String, String> envMap = System.getenv();
- String value = envMap.get(HTTP_PROXY_KEY);
-
- if (value == null) {
- return null;
- }
- value = removeHttpProtocol(value);
- String[] values = value.split(":");
-
- if (values.length == 2) {
- // filter a port string on just number
- String match = "[^0-9.,]+";
- values[1] = values[1].replaceAll(match, "");
- return values;
- } else if (values.length == 1) {
- return values;
- }
-
- return null;
- }
-
- public static String getHttpProxy(String addr, String port) {
- if (addr.isEmpty()) {
- return "";
- }
-
- if (port.isEmpty()) {
- return HTTP_PROTOCOL[0] + addr;
- } else {
- return HTTP_PROTOCOL[0] + addr + DELIMITER_PORT + port;
- }
- }
-}
+++ /dev/null
-package org.tizen.nativeplatform.preferences.ui.proxy;
-
-import org.eclipse.swt.widgets.Shell;
-
-public class ModifyProxyDialog extends ProxyConfDialog {
-
- public ModifyProxyDialog(Shell parentShell, String proxy, String port) {
- super(parentShell, proxy, port);
- }
-
- @Override
- protected void okPressed() {
- super.okPressed();
- }
-}
+++ /dev/null
-package org.tizen.nativeplatform.preferences.ui.proxy;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.tizen.common.util.DialogUtil;
-import org.tizen.nativeplatform.preferences.PreferencesManager;
-
-public class ProxyConfDialog extends Dialog {
-
- private Text proxyText;
- private Text portText;
- private String port = "";
- private String proxy = "";
-
- private int x = 0;
- private int y = 0;
- private final int width = 500;
- private final int height = 200;
-
- private final String BUNDLE_NAME = ProxyConfDialog.class.getPackage().getName() + ".ProxyConfUIMessages";//$NON-NLS-1$
- private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
- protected ProxyConfDialog(Shell parentShell) {
- super(parentShell);
- }
-
- public ProxyConfDialog(Shell parentShell, String proxy, String port) {
- super(parentShell);
-
- this.port = port;
- this.proxy = proxy;
-
- Rectangle bounds = parentShell.getBounds();
- x = bounds.x + (bounds.width - width)/2;
- y = bounds.y + (bounds.height - height)/2;
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
-
- newShell.setText(resources.getString("ConfDlg.Title"));
- newShell.setLocation(x, y);
- newShell.setSize(width, height);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
-
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new GridLayout(1, false));
-
- //createDescComposite(composite);
- createProxyComposite(composite);
-
- return null;
- }
-
- private void createDescComposite(Composite parent) {
-
- Composite comp_descrip = new Composite(parent, SWT.NONE);
- Color whiteColor = new Color(parent.getDisplay(), 255, 255, 255);
-
- comp_descrip.setLayout(new GridLayout(1, false));
- GridData comp_descrip_gd = new GridData(GridData.FILL_HORIZONTAL);
- comp_descrip_gd.heightHint = height/3;
- comp_descrip.setLayoutData(comp_descrip_gd);
- comp_descrip.setBackground(whiteColor);
-
- Label descLabel = new Label(comp_descrip, SWT.NONE);
- descLabel.setText(resources.getString("ConfDlg.Label.Desc"));
- descLabel.setBackground(whiteColor);
- }
-
- private void createProxyComposite(Composite parent) {
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new GridLayout(2, false));
-
- Label proxyLabel = new Label(composite, SWT.NONE);
- proxyLabel.setText(resources.getString("ConfDlg.Label.Addr"));
- proxyText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
- GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- gridData.minimumHeight = 0;
- proxyText.setLayoutData(gridData);
- proxyText.setText(proxy);
-
- Label portLabel = new Label(composite, SWT.NONE);
- portLabel.setText(resources.getString("ConfDlg.Label.Port"));
- portText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
- gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- gridData.minimumHeight = 0;
- portText.setLayoutData(gridData);
- portText.setText(port);
-
- }
-
- @Override
- protected void okPressed() {
- String newPort = HttpProxyUtil.removeHttpProtocol(portText.getText().trim());
- String newProxy = HttpProxyUtil.removeHttpProtocol(proxyText.getText().trim());
-
- /*
- if (newProxy.isEmpty()) {
- DialogUtil.openMessageDialog(resources.getString("ConfDlg.Info.Input.Addr"));
- return;
- }
- */
-
- // filter a port string on just number
- String match = "[^0-9.,]+";
- newPort = newPort.replaceAll(match, "");
-
- if (newProxy != proxy) {
- PreferencesManager.setHttpProxy(newProxy);
- }
-
- if (newPort != port) {
- PreferencesManager.setHttpProxyPort(newPort);
- }
-
- super.okPressed();
- }
-}
+++ /dev/null
-ConfDlg.Title = Modify HTTP Proxy
-ConfDlg.Label.Port = Port:
-ConfDlg.Label.Addr = HTTP Proxy:
-ConfDlg.Label.Desc = Input http proxy information as below.\n - HTTP Proxy: 172.21.17.105\n - Port: 8080
-
-ConfDlg.Info.Input.Addr = HTTP proxy address should be input for cloning git project
-
-ConfPref.Button.Modify = Modify
-ConfPref.Button.Add = Add
-
-ConfPref.Text.Port = Port
-ConfPref.Text.Addr = HTTP Proxy
-ConfPref.Column.Type = Type
-ConfPref.Column.Value = Value
-
-
-
-FileDlg.Title = File Dialog
-FileDlg.Filter.Ext = txt
\ No newline at end of file
import org.eclipse.core.runtime.Path;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativecommon.build.exception.SBIException;
-import org.tizen.nativecommon.build.model.SBIModel;
import org.tizen.nativeplatform.build.PlatformConfigurationManager;
import org.tizen.nativeplatform.views.model.ICheckTreeItem;
import org.tizen.nativeplatform.views.model.PlatformRootstrap;
proxyText.setEnabled(false);
portText.setEnabled(false);
- String prefProxy = PreferencesManager.getHttpProxy();
+ String prefProxyHost = PreferencesManager.getHttpProxyHost();
String prefProxyPort = PreferencesManager.getHttpProxyPort();
- if (!prefProxy.isEmpty()) {
- proxyText.setText(prefProxy);
+ if (!prefProxyHost.isEmpty()) {
+ proxyText.setText(prefProxyHost);
}
if (!prefProxyPort.isEmpty()) {
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.ui.part.ViewPart;
import org.tizen.common.TizenHelpContextIds;
import org.tizen.common.util.DialogUtil;
-import org.tizen.common.util.HostUtil;
import org.tizen.common.util.ImageUtil;
import org.tizen.nativecommon.ProjectUtil;