String workingDir = getWorkingDir(config);
String passwd = SudoPasswdManager.getSudoPassword();
- String httpProxy = PreferencesManager.getHttpProxy();
+ String httpProxy = PreferencesManager.getHttpProxyURL();
if (httpProxy.isEmpty()) {
httpProxy = "noproxy";
}
ArrayList<GitDescription> GitDescs = new ArrayList<GitDescription>();
@Override
- public ArrayList<GitDescription> parse(PreferencesManager.GitConfiguration config) {
+ public ArrayList<GitDescription> parse(PreferencesManager.SiteConfiguration config) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(config.listLocation));
import org.tizen.nativeplatform.preferences.PreferencesManager;
public class GitIndexParserFactory {
- public static IGitIndexParser getIndexParser(PreferencesManager.GitConfiguration config) {
+ public static IGitIndexParser getIndexParser(PreferencesManager.SiteConfiguration config) {
if ( config.listType.equals(PreferencesManager.GIT_LIST_WEB)) {
return new WebGitIndexParser();
}
import org.tizen.nativeplatform.preferences.PreferencesManager;
public interface IGitIndexParser {
- public ArrayList<GitDescription> parse(PreferencesManager.GitConfiguration config);
+ public ArrayList<GitDescription> parse(PreferencesManager.SiteConfiguration config);
}
public class WebGitIndexParser implements IGitIndexParser {
@Override
- public ArrayList<GitDescription> parse(PreferencesManager.GitConfiguration config) {
+ public ArrayList<GitDescription> parse(PreferencesManager.SiteConfiguration config) {
boolean startTable = false;
boolean startTr = false;
boolean getProjectName = false;
import java.util.ResourceBundle;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.FileLocator;
import org.tizen.nativeplatform.Activator;
import org.tizen.nativeplatform.build.PlatformConfigurationManager;
import org.tizen.sdblib.IDevice;
-import org.tizen.nativeplatform.password.SudoPasswdManager;
import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
import org.tizen.nativeplatform.pkgmgr.model.LocalPkgProvider;
import org.tizen.nativeplatform.pkgmgr.model.PackageProvider;
public class RPMPackageDialog extends Dialog {
-
- private String configuration;
private IDevice device;
private TabFolder tabFolder;
x = bounds.x + (bounds.width - width)/2;
y = bounds.y + (bounds.height - height)/2;
- http_proxy = PreferencesManager.getHttpProxy();
- RPMPackageCommander.setHttpProxy(PreferencesManager.getHttpProxy());
+ http_proxy = PreferencesManager.getHttpProxyURL();
+ RPMPackageCommander.setHttpProxy(PreferencesManager.getHttpProxyURL());
this.rootstrap = rootstrap;
}
y = bounds.y + (bounds.height - height)/2;
if (enableRootstrap) {
- IProject _project = CurrentEnabledProject.getCurrentProject();
- IConfiguration config = ManagedBuildManager.getBuildInfo( _project ).getDefaultConfiguration();
- configuration = config.getName();
- http_proxy = PreferencesManager.getHttpProxy();
+ http_proxy = PreferencesManager.getHttpProxyURL();
RPMPackageCommander.setHttpProxy(http_proxy);
}
if (enableTarget) {
}
}
- private String getHttpProxy(IProject project) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo( project ) ;
- IConfiguration cfg = info.getDefaultConfiguration();
- ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg);
- IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
-
- // append "OBS_HTTP_PROXY"
- IEnvironmentVariable var = mngr.getVariable("OBS_HTTP_PROXY", cfgDes, true);
- if ( var != null ) {
- return var.getValue();
- }
- return "";
- }
private void setImage(Shell parentShell) {
try {
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
public class PreferencesManager {
- public static final String HTTPPROXY_KEY = "org.tizen.nativeplatform.http.proxy.addr";
- public static final String PROXYPORT_KEY = "org.tizen.nativeplatform.http.proxy.port";
-
public static final String PASSWORD_KEY = "org.tizen.nativeplatform.sudo.password";
private static final String GIT_ACTIVE_CONFIG = "org.tizen.nativeplatform.git.active.config";
- private static final String GIT_CONFIG_NAME = "org.tizen.nativeplatform.git.config.name";
+ private static final String GIT_CONFIG_NAME = "org.tizen.nativeplatform.site.config.name";
private static final String GIT_BASE_URI = "org.tizen.nativeplatform.git.base.uri";
private static final String GIT_LIST_TYPE = "org.tizen.nativeplatform.git.list.type";
private static final String GIT_LIST_LOCATION = "org.tizen.nativeplatform.git.list.location";
+ private static final String USE_SITE_PROXY = "org.tizen.nativeplatform.site.use.proxy";
+ private static final String PROXY_URL = "rg.tizen.nativeplatform.site.use.proxy.url";
private static final String GIT_CONFIG_DELIMITER = "|";
public static final String GIT_LIST_WEB = "WEB";
public static final String GIT_LIST_LOCAL = "LOCAL";
private static final String DEFAULT_GIT_BASE_URI = "review.tizen.org";
private static final String DEFAULT_GIT_LIST_TYPE = GIT_LIST_WEB;
private static final String DEFAULT_GIT_LIST_LOCATION = "https://review.tizen.org/git/";
+ private static final boolean DEFAULT_USE_SITE_PROXY = false;
+ private static final String DEFAULT_PROXY_URL = "";
private static final String GIT_LIST_CACHE_FILE_FORMAT = ".%s.index.html";
private static IPreferenceStore prefStore = org.tizen.nativecommon.Activator.getDefault().getPreferenceStore();
public static void setDefaultValues() {
if ( !prefStore.contains(GIT_CONFIG_NAME) ) {
- addGitConfiguration(DEFAULT_GIT_CONFIG_NAME,
+ addSiteConfiguration(DEFAULT_GIT_CONFIG_NAME,
DEFAULT_GIT_BASE_URI,
DEFAULT_GIT_LIST_TYPE,
- DEFAULT_GIT_LIST_LOCATION);
+ DEFAULT_GIT_LIST_LOCATION,
+ DEFAULT_USE_SITE_PROXY,
+ DEFAULT_PROXY_URL);
}
}
}
- public static String getHttpProxy() {
- 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());
+
+ public static boolean isProxyUsed() {
+ if ( isSiteProxyUsed() ) return true;
+ if ( isSystemProxyUsed() ) return true;
+ return false;
+ }
+
+
+ public static Proxy getProxy() {
+ if ( isProxyUsed() ) {
+ String host = getProxyHost();
+ int port = getProxyPort();
+ String protocol = getProxyProtocol();
+ Proxy.Type proxyType;
+ if ( protocol.equals("http") || protocol.equals("https")) {
+ proxyType = Proxy.Type.HTTP;
}
- 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());
+ proxyType = Proxy.Type.SOCKS;
}
+
+ return new Proxy(proxyType, new InetSocketAddress(host, port));
+ }
+ else {
+ return null;
+ }
+ }
+
+
+ public static String getProxyURL() {
+ String proxyURL = getSiteProxyURL();
+ if ( proxyURL == null ) {
+ proxyURL = getSystemProxyURL();
}
- return "";
+ return proxyURL;
+ }
+
+
+ public static String getProxyProtocol() {
+ String proxyURL = getProxyURL();
+ if ( proxyURL == null ) return null;
+ URL url;
+
+ try {
+ url = new URL(proxyURL);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ return url.getProtocol();
+ }
+
+
+ public static String getProxyHost() {
+ String proxyURL = getProxyURL();
+ if ( proxyURL == null ) return null;
+ URL url;
+
+ try {
+ url = new URL(proxyURL);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ return url.getHost();
}
+
+ public static int getProxyPort() {
+ String proxyURL = getProxyURL();
+ if ( proxyURL == null ) return -1;
+ URL url;
+
+ try {
+ url = new URL(proxyURL);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ return -1;
+ }
+
+ return url.getPort();
+ }
- public static String getHttpProxyHost() {
- IProxyData data = getHttpProxyData();
- if ( data != null ) {
- return data.getHost();
+
+
+
+ private static boolean isSiteProxyUsed() {
+ SiteConfiguration activeConf = loadActiveSiteConfiguration();
+ if ( activeConf == null ) return false;
+
+ return activeConf.isSiteProxyUsed;
+ }
+
+
+ private static String getSiteProxyURL() {
+ SiteConfiguration activeConf = loadActiveSiteConfiguration();
+ if ( activeConf == null ) return null;
+
+ if ( activeConf.isSiteProxyUsed ) {
+ return activeConf.proxyURL;
}
else {
- return "";
+ return null;
}
}
+
+ private static boolean isSystemProxyUsed() {
+ return getSystemProxyURL() != null ? true:false;
+ }
+
- public static String getHttpProxyPort() {
- IProxyData data = getHttpProxyData();
+ private static String getSystemProxyURL() {
+ IProxyData data = getProxyData(IProxyData.SOCKS_PROXY_TYPE);
+ if ( data != null ) {
+ return String.format("socks://%s:%d", data.getHost(), data.getPort());
+ }
+
+ data = getProxyData(IProxyData.HTTP_PROXY_TYPE);
if ( data != null ) {
- return String.format("%d", data.getPort() );
+ return String.format("http://%s:%d", data.getHost(), data.getPort());
}
+
+ data = getProxyData(IProxyData.HTTPS_PROXY_TYPE);
+ if ( data != null ) {
+ return String.format("https://%s:%d", data.getHost(), data.getPort());
+ }
+
+ return null;
+ }
+
+
+ public static String getHttpProxyURL() {
+ String proxyURL = getSiteProxyURL();
+ if ( proxyURL.split(":")[0].equals("http") ) {
+ return proxyURL;
+ }
+ else {
+ IProxyData data = getProxyData(IProxyData.HTTP_PROXY_TYPE);
+ if ( data != null ) {
+ return String.format("http://%s:%d", data.getHost(), data.getPort());
+ }
+ }
+
return "";
}
- private static IProxyData getHttpProxyData() {
+ private static IProxyData getProxyData( String proxyType ) {
if ( proxyTracker == null ) {
proxyTracker = new ServiceTracker<IProxyService,IProxyService>(FrameworkUtil.getBundle(
PreferencesManager.class).getBundleContext(), IProxyService.class
IProxyService service = proxyTracker.getService();
if ( service.isProxiesEnabled() ) {
- IProxyData data = service.getProxyData(IProxyData.HTTP_PROXY_TYPE);
- if ( data != null && data.getHost() != null ) {
+ IProxyData data = service.getProxyData( proxyType );
+ if ( data != null && data.getHost() != null && !data.getHost().isEmpty()) {
return data;
}
}
return null;
}
-
+
public static String getPassword() {
return prefStore.getString(PASSWORD_KEY);
}
- public static synchronized GitConfiguration loadActiveGitConfiguration() {
- ArrayList<String> names = loadGitConfigName();
+ public static synchronized SiteConfiguration loadActiveSiteConfiguration() {
+ ArrayList<String> names = loadSiteConfigName();
ArrayList<String> baseURIs = loadGitBaseURI();
ArrayList<String> listTypes = loadGitListType();
ArrayList<String> listLocations = loadGitListLocation();
+ ArrayList<String> listUseSiteProxies = loadUseSiteProxies();
+ ArrayList<String> listProxyURLs = loadProxyURLs();
+
int activeId = prefStore.getInt(GIT_ACTIVE_CONFIG);
if ( activeId == -1 ) {
return null;
}
- GitConfiguration newConfig = new GitConfiguration(
+ SiteConfiguration newConfig = new SiteConfiguration(
names.get(activeId),
baseURIs.get(activeId),
listTypes.get(activeId),
- listLocations.get(activeId) );
+ listLocations.get(activeId),
+ listUseSiteProxies.get(activeId).equals("YES") ? true:false,
+ listProxyURLs.get(activeId));
newConfig.setActive(true);
return newConfig;
}
- public static synchronized ArrayList<GitConfiguration> loadGitConfigurations() {
- ArrayList<String> names = loadGitConfigName();
+ public static synchronized ArrayList<SiteConfiguration> loadSiteConfigurations() {
+ ArrayList<String> names = loadSiteConfigName();
ArrayList<String> baseURIs = loadGitBaseURI();
ArrayList<String> listTypes = loadGitListType();
ArrayList<String> listLocations = loadGitListLocation();
+ ArrayList<String> listUseSiteProxies = loadUseSiteProxies();
+ ArrayList<String> listProxyURLs = loadProxyURLs();
int activeId = prefStore.getInt(GIT_ACTIVE_CONFIG);
- ArrayList<GitConfiguration> list = new ArrayList<GitConfiguration>();
+ ArrayList<SiteConfiguration> list = new ArrayList<SiteConfiguration>();
for( int idx = 0; idx < names.size(); idx++ ) {
- GitConfiguration newConfig = new GitConfiguration( names.get(idx),
+ SiteConfiguration newConfig = new SiteConfiguration( names.get(idx),
baseURIs.get(idx),
listTypes.get(idx),
- listLocations.get(idx) );
+ listLocations.get(idx),
+ listUseSiteProxies.get(idx).equals("YES") ? true:false,
+ listProxyURLs.get(idx) );
if ( activeId == idx ) {
newConfig.setActive(true);
}
}
- public static synchronized void addGitConfiguration( String name, String baseURI,
- String listType, String location) {
+ public static synchronized void addSiteConfiguration( String name, String baseURI,
+ String listType, String location, boolean useSiteProxy, String proxyURL ) {
- ArrayList<String> newList = loadGitConfigName();
+ ArrayList<String> newList = loadSiteConfigName();
newList.add(name);
saveGitConfigName( newList );
newList = loadGitListLocation();
newList.add(location);
saveGitListLocation( newList );
-
+
+ newList = loadUseSiteProxies();
+ newList.add(useSiteProxy ? "YES": "NO");
+ saveUseSiteProxies( newList );
+
+ newList = loadProxyURLs();
+ newList.add(proxyURL);
+ saveProxyURLs( newList );
+
if (newList.size() == 1 )
- setActiveGitConfiguration( 0 );
+ setActiveSiteConfiguration( 0 );
}
- public static synchronized void updateGitConfiguration( int id, String name, String baseURI,
- String listType, String location) {
+ public static synchronized void updateSiteConfiguration( int id, String name, String baseURI,
+ String listType, String location, boolean useSiteProxy, String proxyURL ) {
- ArrayList<String> newList = loadGitConfigName();
+ ArrayList<String> newList = loadSiteConfigName();
newList.set(id, name);
saveGitConfigName( newList );
newList = loadGitListLocation();
newList.set(id, location);
saveGitListLocation( newList );
+
+ newList = loadUseSiteProxies();
+ newList.set(id, useSiteProxy ? "YES":"NO");
+ saveUseSiteProxies( newList );
+
+ newList = loadProxyURLs();
+ newList.set(id, proxyURL);
+ saveProxyURLs( newList );
}
- public static synchronized void setActiveGitConfiguration( int id ) {
+ public static synchronized void setActiveSiteConfiguration( int id ) {
prefStore.setValue(GIT_ACTIVE_CONFIG, id);
}
- public static synchronized void removeGitConfiguration( int id ) {
- ArrayList<String> newList = loadGitConfigName();
+ public static synchronized void removeSiteConfiguration( int id ) {
+ ArrayList<String> newList = loadSiteConfigName();
newList.remove(id);
saveGitConfigName( newList );
int prevActiveId = prefStore.getInt(GIT_ACTIVE_CONFIG);
if ( prevActiveId == id ) {
if (newList.size() == 0 ) {
- setActiveGitConfiguration( -1 );
+ setActiveSiteConfiguration( -1 );
}
else {
- setActiveGitConfiguration( 0 );
+ setActiveSiteConfiguration( 0 );
}
}
else if ( prevActiveId > id ) {
- setActiveGitConfiguration( id - 1 );
+ setActiveSiteConfiguration( id - 1 );
}
else {
// do nothing
public static synchronized void refreshGitWebConfiguration( int idx ) throws IOException {
- String name = loadGitConfigName().get(idx);
+ String name = loadSiteConfigName().get(idx);
String path = loadGitListLocation().get(idx);
URL u = new URL(path);
}
- private static ArrayList<String> loadGitConfigName() {
+ private static ArrayList<String> loadSiteConfigName() {
String values = prefStore.getString(GIT_CONFIG_NAME);
if ( !values.isEmpty() ) {
return new ArrayList<String>(Arrays.asList( values.split("[|]") ) );
prefStore.setValue(GIT_LIST_LOCATION, generateListString( list ));
}
+
+ private static ArrayList<String> loadUseSiteProxies() {
+ String values = prefStore.getString(USE_SITE_PROXY);
+ if ( !values.isEmpty() ) {
+ return new ArrayList<String>(Arrays.asList( values.split("[|]") ) );
+ }
+ else {
+ return new ArrayList<String>();
+ }
+ }
+
+
+ private static void saveUseSiteProxies( ArrayList<String> list ) {
+ prefStore.setValue(USE_SITE_PROXY, generateListString( list ));
+ }
+
+
+ private static ArrayList<String> loadProxyURLs() {
+ String values = prefStore.getString(PROXY_URL);
+ if ( !values.isEmpty() ) {
+ ArrayList<String> newList = new ArrayList<String>();
+ for( String url: values.split("[|]") ) {
+ if ( url.equals("EMPTY") ) {
+ newList.add("");
+ }
+ else {
+ newList.add(url);
+ }
+ }
+
+ return newList;
+ }
+ else {
+ return new ArrayList<String>();
+ }
+ }
+
+
+ private static void saveProxyURLs( ArrayList<String> list ) {
+ ArrayList<String> newList = new ArrayList<String>();
+ for( String url: list ) {
+ if ( url.isEmpty() ) {
+ newList.add("EMPTY");
+ }
+ else {
+ newList.add(url);
+ }
+ }
+
+ prefStore.setValue(PROXY_URL, generateListString( newList ));
+ }
+
private static String generateListString( ArrayList<String> list ) {
String newList = "";
for( String item : list ) {
}
- public static class GitConfiguration {
+ public static class SiteConfiguration {
public String name;
public String baseURI;
public String listType;
public String listLocation;
public boolean isActive;
+ public boolean isSiteProxyUsed;
+ public String proxyURL;
- public GitConfiguration(String name1, String baseURI1, String listType1, String listLocation1) {
+ public SiteConfiguration(String name1, String baseURI1, String listType1, String listLocation1,
+ boolean isSiteProxyUsed1, String proxyURL1 ) {
name = name1;
baseURI = baseURI1;
listType = listType1;
listLocation = listLocation1;
+ isSiteProxyUsed = isSiteProxyUsed1;
+ proxyURL = proxyURL1;
+
isActive = false;
}
GitConfDlg.Info.Input.GitWeb = Git web address should be input for listing git project
GitConfDlg.Info.Input.GitListFile = Git list file should be input for listing git project
-GitConfDlg.Label.GitConfigName = Name:
-GitConfDlg.Label.GitBaseURI = Base URI:
-GitConfDlg.Label.GitListType = Type:
-GitConfDlg.Label.GitListLocation = Location:
+SiteConfDlg.Label.ConfigName = Name:
+
+SiteConfDlg.Group.Git = Git Configuration
+SiteConfDlg.Label.GitBaseURI = Git Base URI:
+SiteConfDlg.Label.GitBaseURI.Ex = ex) ssh://myid:mypasswd@my.host.name:29418
+SiteConfDlg.Label.GitListType = Type:
+SiteConfDlg.Label.GitListLocation = Location:
+SiteConfDlg.Button.Browse = Browse
+
+SiteConfDlg.Group.Proxy = Proxy Configuration
+SiteConfDlg.Button.UseSiteProxy = Use Site Proxy
+SiteConfDlg.Label.ProxyURL = Proxy URL:
+SiteConfDlg.Label.ProxyURL.Ex = ex) http://proxy.host.name:8080
GitConfPref.Button.Add = Add
GitConfPref.Button.Edit = Edit
GitConfDlg.Error.NoName = Must specify configuration name field!
GitConfDlg.Error.NoBaseURI = Must specify base URI field!
-GitConfDlg.Error.NoLocation = Must specify location field!
\ No newline at end of file
+GitConfDlg.Error.NoLocation = Must specify location field!
+GitConfDlg.Error.NoProxyURL = Must specify proxy URL!
+GitConfDlg.Error.MalformedURL = Malformed URL is used!
\ No newline at end of file
package org.tizen.nativeplatform.preferences.ui;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.IPath;
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;
private Combo gitListTypeCombo;
private Text gitListLocationText;
private Button fileBrowseBt;
-
+ private Button useSiteProxyBt;
+ private Text proxyURLText;
+
private String siteConfigName = "";
private String gitBaseURI = "";
private String gitListType = "";
private String gitListLocation = "";
+ private boolean useSiteProxy = false;
+ private String proxyURL = "";
private int x = 0;
private int y = 0;
private final int width = 500;
- private final int height = 250;
private Shell shell;
private final String BUNDLE_NAME = SiteConfigurationDialog.class.getPackage().getName() + ".GitConfUIMessages";//$NON-NLS-1$
gitBaseURI = "";
gitListType = "";
gitListLocation = "";
+ useSiteProxy= false;
+ proxyURL = "";
this.shell = parentShell;
}
protected SiteConfigurationDialog(Shell parentShell,
- String gitConfigName1, String gitBaseURI1 , String gitListType1, String gitListLocation1 ) {
+ String gitConfigName1, String gitBaseURI1 , String gitListType1, String gitListLocation1,
+ boolean useSiteProxy1, String proxyURL1 ) {
super(parentShell);
siteConfigName = gitConfigName1;
gitBaseURI = gitBaseURI1;
gitListType = gitListType1;
gitListLocation = gitListLocation1;
+ useSiteProxy= useSiteProxy1;
+ proxyURL = proxyURL1;
this.shell = parentShell;
}
}
Rectangle bounds = newShell.getBounds();
x = bounds.x + (bounds.width - width)/2;
- y = bounds.y + (bounds.height - height)/2;
newShell.setLocation(x, y);
- newShell.setSize(width, height);
+ newShell.setMinimumSize(width, 0);
}
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setLayout(new GridLayout(1, false));
- createGitConfigNameComposite(composite);
- createGitBaseURIComposite(composite);
- createGitListComposite(composite);
+ createSiteConfigNameComposite(composite);
+ createGitConfigGroupComposite( composite );
+ createProxyConfigGroupComposite( composite );
return null;
}
- private void createGitConfigNameComposite(Composite parent) {
+ private void createSiteConfigNameComposite(Composite parent) {
Composite composite = new Composite( parent, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setLayout(new GridLayout(2, false));
Label configNameLabel = new Label(composite, SWT.NONE);
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.widthHint = 70;
+ gridData.widthHint = 50;
configNameLabel.setLayoutData(gridData);
configNameLabel.setAlignment(SWT.RIGHT);
- configNameLabel.setText(resources.getString("GitConfDlg.Label.GitConfigName"));
+ configNameLabel.setText(resources.getString("SiteConfDlg.Label.ConfigName"));
siteConfigNameText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- gridData.minimumHeight = 0;
+ gridData.minimumWidth = 200;
siteConfigNameText.setLayoutData(gridData);
siteConfigNameText.setText(siteConfigName);
}
-
- private void createGitBaseURIComposite(Composite parent) {
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new GridLayout(2, false));
+
+ private void createGitConfigGroupComposite(Composite parent) {
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout(3, false));
+ group.setText(resources.getString("SiteConfDlg.Group.Git"));
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ group.setLayoutData(gridData);
+
+ createGitBaseURIComposite(group);
+ createGitListComposite(group);
+ }
+
+
+ private void createGitBaseURIComposite(Composite composite) {
Label gitBaseURILebel = new Label(composite, SWT.NONE);
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.widthHint = 70;
+ gridData.widthHint = 100;
gitBaseURILebel.setLayoutData(gridData);
gitBaseURILebel.setAlignment(SWT.RIGHT);
- gitBaseURILebel.setText(resources.getString("GitConfDlg.Label.GitBaseURI"));
+ gitBaseURILebel.setText(resources.getString("SiteConfDlg.Label.GitBaseURI"));
gitBaseURIText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- gridData.minimumHeight = 0;
+ gridData.horizontalSpan = 2;
gitBaseURIText.setLayoutData(gridData);
gitBaseURIText.setText(gitBaseURI);
+
+ new Label( composite, SWT.NONE );
+
+ Label gitBaseURIExLabel = new Label(composite, SWT.NONE);
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gridData.horizontalSpan = 2;
+ gitBaseURIExLabel.setLayoutData(gridData);
+ gitBaseURIExLabel.setText(resources.getString("SiteConfDlg.Label.GitBaseURI.Ex"));
+
}
- private void createGitListComposite(Composite parent) {
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new GridLayout(2, false));
+ private void createGitListComposite(Composite composite) {
Label gitListTypeLebel = new Label(composite, SWT.NONE);
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.widthHint = 70;
+ gridData.widthHint = 100;
gitListTypeLebel.setLayoutData(gridData);
gitListTypeLebel.setAlignment(SWT.RIGHT);
- gitListTypeLebel.setText(resources.getString("GitConfDlg.Label.GitListType"));
+ gitListTypeLebel.setText(resources.getString("SiteConfDlg.Label.GitListType"));
gitListTypeCombo = new Combo(composite, SWT.READ_ONLY);
gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- gridData.minimumHeight = 0;
+ gridData.horizontalSpan = 2;
gitListTypeCombo.setLayoutData(gridData);
String newItems[] = { PreferencesManager.GIT_LIST_LOCAL, PreferencesManager.GIT_LIST_WEB };
gitListTypeCombo.setItems(newItems);
gitListTypeCombo.select(1);
}
- Label gitListLocationLebel = new Label(composite, SWT.NONE);
+ Label gitListLocationLabel = new Label(composite, SWT.NONE);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.widthHint = 70;
- gitListLocationLebel.setLayoutData(gridData);
- gitListLocationLebel.setAlignment(SWT.RIGHT);
- gitListLocationLebel.setText(resources.getString("GitConfDlg.Label.GitListLocation"));
+ gridData.widthHint = 100;
+ gitListLocationLabel.setLayoutData(gridData);
+ gitListLocationLabel.setAlignment(SWT.RIGHT);
+ gitListLocationLabel.setText(resources.getString("SiteConfDlg.Label.GitListLocation"));
createGitListLocationComposite(composite);
}
- private void createGitListLocationComposite(Composite parent) {
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new GridLayout(2, false));
+ private void createGitListLocationComposite(Composite composite) {
gitListLocationText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- gridData.minimumHeight = 0;
gitListLocationText.setLayoutData(gridData);
gitListLocationText.setText(gitListLocation);
fileBrowseBt = new Button(composite, SWT.PUSH);
- fileBrowseBt.setText("Browse");
+ fileBrowseBt.setText(resources.getString("SiteConfDlg.Button.Browse"));
fileBrowseBt.addMouseListener(new MouseListener()
{
}
+ private void createProxyConfigGroupComposite( Composite parent ) {
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout(2, false));
+ group.setText(resources.getString("SiteConfDlg.Group.Proxy"));
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ group.setLayoutData(gridData);
+
+ // check box
+ useSiteProxyBt = new Button(group, SWT.CHECK);
+ useSiteProxyBt.setText(resources.getString("SiteConfDlg.Button.UseSiteProxy"));
+ gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gridData.horizontalSpan = 2;
+ useSiteProxyBt.setLayoutData(gridData);
+ useSiteProxyBt.setSelection(useSiteProxy);
+ useSiteProxyBt.addSelectionListener( new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ useSiteProxy = useSiteProxyBt.getSelection();
+ proxyURLText.setEnabled(useSiteProxy);
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ });
+
+ // label , text
+ Label proxyURLLabel = new Label(group, SWT.NONE);
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.widthHint = 100;
+ proxyURLLabel.setLayoutData(gridData);
+ proxyURLLabel.setAlignment(SWT.RIGHT);
+ proxyURLLabel.setText(resources.getString("SiteConfDlg.Label.ProxyURL"));
+
+ proxyURLText = new Text(group, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
+ gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ proxyURLText.setLayoutData(gridData);
+ proxyURLText.setText(proxyURL);
+ proxyURLText.setEnabled(false);
+
+ new Label( group, SWT.NONE );
+
+ Label gitBaseURIExLabel = new Label(group, SWT.NONE);
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gitBaseURIExLabel.setLayoutData(gridData);
+ gitBaseURIExLabel.setText(resources.getString("SiteConfDlg.Label.ProxyURL.Ex"));
+ }
+
+
@Override
protected void okPressed() {
siteConfigName = siteConfigNameText.getText().trim();
gitBaseURI = gitBaseURIText.getText().trim();
gitListType = gitListTypeCombo.getText();
gitListLocation = gitListLocationText.getText().trim();
+ useSiteProxy = useSiteProxyBt.getSelection();
+ proxyURL = proxyURLText.getText().trim();
+
if ( siteConfigName.isEmpty()) {
DialogUtil.openErrorDialog(resources.getString("GitConfDlg.Error.NoName"));
+ return;
}
- else if ( gitBaseURI.isEmpty() ) {
+ if ( gitBaseURI.isEmpty() ) {
DialogUtil.openErrorDialog(resources.getString("GitConfDlg.Error.NoBaseURI"));
+ return;
}
- else if ( gitListLocation.isEmpty() ) {
+ if ( gitListLocation.isEmpty() ) {
DialogUtil.openErrorDialog(resources.getString("GitConfDlg.Error.NoLocation"));
+ return;
}
- else {
- super.okPressed();
+ if ( useSiteProxy ) {
+ if ( proxyURL.isEmpty() ) {
+ DialogUtil.openErrorDialog(resources.getString("GitConfDlg.Error.NoProxyURL"));
+ }
+
+ try {
+ URL url = new URL(proxyURL);
+ String protocol = url.getProtocol();
+ String host = url.getHost();
+ int port = url.getPort();
+
+ if ( ( protocol.compareToIgnoreCase("socks") != 0 &&
+ protocol.compareToIgnoreCase("http") != 0 &&
+ protocol.compareToIgnoreCase("https") != 0 ) ||
+ host == null ||host.isEmpty() ) {
+ DialogUtil.openErrorDialog(resources.getString("GitConfDlg.Error.MalformedURL"));
+ return;
+ }
+ // use default port
+ if ( port == -1 ) port = 8080;
+
+ // make new URL
+ proxyURL = String.format("%s://%s:%d", protocol, host, port);
+
+ } catch (MalformedURLException e) {
+ DialogUtil.openErrorDialog(resources.getString("GitConfDlg.Error.MalformedURL"));
+ return;
+ }
+
}
+
+ super.okPressed();
}
public String getSiteConfigName() {
public String getGitListLocation() {
return gitListLocation;
}
+
+
+ public boolean isSiteProxyUsed() {
+ return useSiteProxy;
+ }
+
+
+ public String getProxyURL() {
+ if ( useSiteProxy ) {
+ return proxyURL;
+ }
+ else {
+ return "";
+ }
+ }
}
public class SiteConfigurationPreferencePage extends PreferencePage implements IWorkbenchPreferencePage{
- private ArrayList<PreferencesManager.GitConfiguration> gitConfigList;
+ private ArrayList<PreferencesManager.SiteConfiguration> siteConfigList;
private TableViewer gitConfigTable;
private Button addBt;
private Button editBt;
private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
public SiteConfigurationPreferencePage() {
- gitConfigList = new ArrayList<PreferencesManager.GitConfiguration>();
+ siteConfigList = new ArrayList<PreferencesManager.SiteConfiguration>();
}
@Override
public void selectionChanged(SelectionChangedEvent event) {
int idx = gitConfigTable.getTable().getSelectionIndex();
if ( idx != -1 ) {
- String gitListType = gitConfigList.get(idx).listType;
+ String gitListType = siteConfigList.get(idx).listType;
if ( gitListType.equals(PreferencesManager.GIT_LIST_WEB) ) {
updateBt.setEnabled(true);
}
});
- gitConfigTable.setInput(gitConfigList);
+ gitConfigTable.setInput(siteConfigList);
}
private void updateData() {
- gitConfigList = PreferencesManager.loadGitConfigurations();
+ siteConfigList = PreferencesManager.loadSiteConfigurations();
if (gitConfigTable != null ) {
- gitConfigTable.setInput(gitConfigList);
+ gitConfigTable.setInput(siteConfigList);
}
}
SiteConfigurationDialog dialog = new SiteConfigurationDialog(getShell());
if (dialog.open() == SiteConfigurationDialog.OK) {
- PreferencesManager.addGitConfiguration(
+ PreferencesManager.addSiteConfiguration(
dialog.getSiteConfigName(),
dialog.getGitBaseURI(),
dialog.getGitListType(),
- dialog.getGitListLocation() );
+ dialog.getGitListLocation(),
+ dialog.isSiteProxyUsed(),
+ dialog.getProxyURL());
updateData();
}
@Override
public void mouseDown(MouseEvent e) {
int idx = gitConfigTable.getTable().getSelectionIndex();
- String gitConfigName = gitConfigList.get(idx).name;
- String gitBaseURI = gitConfigList.get(idx).baseURI;
- String gitListType = gitConfigList.get(idx).listType;
- String gitListLocation = gitConfigList.get(idx).listLocation;
+ String siteConfigName = siteConfigList.get(idx).name;
+ String gitBaseURI = siteConfigList.get(idx).baseURI;
+ String gitListType = siteConfigList.get(idx).listType;
+ String gitListLocation = siteConfigList.get(idx).listLocation;
+ boolean useSiteProxy = siteConfigList.get(idx).isSiteProxyUsed;
+ String proxyURL = siteConfigList.get(idx).proxyURL;
SiteConfigurationDialog dialog = new SiteConfigurationDialog(getShell(),
- gitConfigName, gitBaseURI, gitListType, gitListLocation );
+ siteConfigName, gitBaseURI, gitListType, gitListLocation,
+ useSiteProxy, proxyURL );
if (dialog.open() == SiteConfigurationDialog.OK) {
- PreferencesManager.updateGitConfiguration(
+ PreferencesManager.updateSiteConfiguration(
gitConfigTable.getTable().getSelectionIndex(),
dialog.getSiteConfigName(),
dialog.getGitBaseURI(),
dialog.getGitListType(),
- dialog.getGitListLocation() );
+ dialog.getGitListLocation(),
+ dialog.isSiteProxyUsed(),
+ dialog.getProxyURL() );
updateData();
}
}
@Override
public void mouseDown(MouseEvent e) {
- PreferencesManager.setActiveGitConfiguration(
+ PreferencesManager.setActiveSiteConfiguration(
gitConfigTable.getTable().getSelectionIndex());
updateData();
@Override
public void mouseDown(MouseEvent e) {
- PreferencesManager.removeGitConfiguration(
+ PreferencesManager.removeSiteConfiguration(
gitConfigTable.getTable().getSelectionIndex());
updateData();
}
@Override
public String getColumnText(Object element, int columnIndex) {
- PreferencesManager.GitConfiguration config = (PreferencesManager.GitConfiguration)element;
+ PreferencesManager.SiteConfiguration config = (PreferencesManager.SiteConfiguration)element;
switch(columnIndex) {
case 0:
import org.tizen.nativecommon.build.model.SBIModel;
import org.tizen.nativecommon.build.model.Target;
import org.tizen.nativeplatform.password.SudoPasswdManager;
+import org.tizen.nativeplatform.preferences.PreferencesManager;
import org.tizen.nativeplatform.views.model.PlatformRootstrap;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
String path = sbi.getRootstrapPathFromRootstrapID(id);
ArrayList<String> reposURLs = new ArrayList<String>();
String rootstrapPath = sbi.getRootstrapPropertyValue(id, "REPOSITORY_URLS");
- if ( rootstrapPath != null && rootstrapPath.split("|").length >= 1 ) {
- for ( String url : rootstrapPath.split("|") ) {
+ if ( rootstrapPath != null && rootstrapPath.split("[|]").length >= 1 ) {
+ for ( String url : rootstrapPath.split("[|]") ) {
reposURLs.add( url );
}
}
for( String url: reposURLs ) {
urlData += (urlData.isEmpty() ? url : "," + url );
}
- String command = String.format( "%s -n %s -a %s -u %s -p rpm --ctrl GBS -g TizenPlatform", rogen, id, baseArch, urlData );
+
+ String command;
+ if ( PreferencesManager.isProxyUsed() ) {
+ String protocol = PreferencesManager.getProxyProtocol();
+ String host = PreferencesManager.getProxyHost();
+ int port = PreferencesManager.getProxyPort();
+ String envSetup = String.format("%s_proxy=%s://%s:%d", protocol, protocol, host, port);
+ command = String.format( "%s %s -n %s -a %s -u %s -p rpm --ctrl GBS -g TizenPlatform",
+ envSetup, rogen, id, baseArch, urlData );
+ }
+ else {
+ command = String.format( "%s -n %s -a %s -u %s -p rpm --ctrl GBS -g TizenPlatform",
+ rogen, id, baseArch, urlData );
+ }
+
if ( !commandWithSudo( command, "Platform Internal") ) {
return false;
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.Proxy;
-import java.net.SocketAddress;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
public ArrayList<ICheckTreeItem> parse(String url)
throws MalformedURLException, IOException {
- String proxyHost = PreferencesManager.getHttpProxyHost();
-
- Proxy p = null;
- if (proxyHost != null && !proxyHost.isEmpty() ) {
- int porxyPort = Integer.parseInt(PreferencesManager.getHttpProxyPort());
- SocketAddress addr = new InetSocketAddress(proxyHost, porxyPort);
- p = new Proxy(Proxy.Type.HTTP, addr);
- }
if (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}
URL u = new URL(repoPath);
URLConnection yc;
+ Proxy p = PreferencesManager.getProxy();
if (p == null) {
yc = u.openConnection();
} else {
monitor.beginTask(resources.getString("GenRootDlg.Progress.Msg.Searching"), -1);
try {
final SnapshotURLParser c = new SnapshotURLParser();
+ snapshotInfos = null;
snapshotInfos = c.parse(snapshotUrl);
} catch (final IOException e) {
e.printStackTrace();
SWTUtil.getDisplay().asyncExec( new Runnable() {
@Override
public void run() {
- DialogUtil.openErrorDialog(e.toString());
+ DialogUtil.openErrorDialog(
+ resources.getString("GenRootDlg.Error.Snapshot.Failed")+
+ "("+e.toString()+")");
}
});
}
return;
}
+ archCombo.removeAll();
if (snapshotInfos == null || snapshotInfos.size() == 0 ) {
+ UpdateRepositoryURL();
return;
}
// add architecture list
- archCombo.removeAll();
for ( ICheckTreeItem item: snapshotInfos ) {
archCombo.add(item.getText());
}
int selectIdx = archCombo.getSelectionIndex();
// show repository URLs
ArrayList<String> data = new ArrayList<String>();
- ArrayList<ICheckTreeItem> children = snapshotInfos.get(selectIdx).getChildren();
- for ( int idx = 0; idx < children.size(); idx++ ) {
- data.add(String.format("url%d|%s", idx, children.get(idx).getText() ) );
+ if ( selectIdx >= 0 ) {
+ ArrayList<ICheckTreeItem> children = snapshotInfos.get(selectIdx).getChildren();
+ for ( int idx = 0; idx < children.size(); idx++ ) {
+ data.add(String.format("url%d|%s", idx, children.get(idx).getText() ) );
+ }
}
reposURLViewer.setInput(data);
}
GenRootDlg.Error.Fail.Generate = Failed to generate rootstrap
GenRootDlg.Error.Empty.Snapshot = Snapshot URL is empty
GenRootDlg.Error.Empty.Rootstrap = Rootstrap is empty
+GenRootDlg.Error.Snapshot.Failed = Getting snapshot information failed!\n
+GenRootDlg.Error.Gen.Rootstrap.Failed = Generating rootstrap failed!!\n
SelectRootDlg.Title = Warning
SelectRootDlg.Msg.LastOne = "%s [%s]" rootstrap is the last one. You can not remove it
});
} catch (Exception e1) {
e1.printStackTrace();
- DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Progress.Msg.Generating") );
+ DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed") );
return;
}
/* create git items */
String projTypeName = PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE;
- PreferencesManager.GitConfiguration config = PreferencesManager.loadActiveGitConfiguration();
+ PreferencesManager.SiteConfiguration config = PreferencesManager.loadActiveSiteConfiguration();
if (config != null ) {
EntryDescriptor gitEntryDes = null;