core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/CarbideNewsReaderPlugin.java
changeset 417 f902e026d524
parent 0 fb279309251b
child 433 93ea4941aeb5
equal deleted inserted replaced
414:393919dade6d 417:f902e026d524
    16 */
    16 */
    17 
    17 
    18 package com.nokia.carbide.cpp.internal.news.reader;
    18 package com.nokia.carbide.cpp.internal.news.reader;
    19 
    19 
    20 import java.io.IOException;
    20 import java.io.IOException;
       
    21 import java.net.URISyntaxException;
    21 import java.net.URL;
    22 import java.net.URL;
    22 
    23 
       
    24 import org.eclipse.core.net.proxy.IProxyData;
       
    25 import org.eclipse.core.net.proxy.IProxyService;
    23 import org.eclipse.core.runtime.FileLocator;
    26 import org.eclipse.core.runtime.FileLocator;
    24 import org.eclipse.core.runtime.IPath;
    27 import org.eclipse.core.runtime.IPath;
    25 import org.eclipse.core.runtime.IProgressMonitor;
    28 import org.eclipse.core.runtime.IProgressMonitor;
    26 import org.eclipse.core.runtime.IStatus;
    29 import org.eclipse.core.runtime.IStatus;
    27 import org.eclipse.core.runtime.Path;
    30 import org.eclipse.core.runtime.Path;
    32 import org.eclipse.ui.IWorkbench;
    35 import org.eclipse.ui.IWorkbench;
    33 import org.eclipse.ui.IWorkbenchWindow;
    36 import org.eclipse.ui.IWorkbenchWindow;
    34 import org.eclipse.ui.PlatformUI;
    37 import org.eclipse.ui.PlatformUI;
    35 import org.eclipse.ui.plugin.AbstractUIPlugin;
    38 import org.eclipse.ui.plugin.AbstractUIPlugin;
    36 import org.osgi.framework.BundleContext;
    39 import org.osgi.framework.BundleContext;
       
    40 import org.osgi.framework.ServiceReference;
    37 
    41 
    38 import com.nokia.carbide.cpp.internal.news.reader.editor.NewsEditor;
    42 import com.nokia.carbide.cpp.internal.news.reader.editor.NewsEditor;
    39 import com.nokia.carbide.cpp.internal.news.reader.feed.FeedManager;
    43 import com.nokia.carbide.cpp.internal.news.reader.feed.FeedManager;
    40 import com.nokia.carbide.cpp.internal.news.reader.ui.NewsControlContribution;
    44 import com.nokia.carbide.cpp.internal.news.reader.ui.NewsControlContribution;
    41 import com.nokia.cpp.internal.api.utils.core.Logging;
    45 import com.nokia.cpp.internal.api.utils.core.Logging;
   116 	public static IPreferenceStore getPrefsStore(){
   120 	public static IPreferenceStore getPrefsStore(){
   117 		if (prefsStore == null){
   121 		if (prefsStore == null){
   118 			prefsStore = getDefault().getPreferenceStore();
   122 			prefsStore = getDefault().getPreferenceStore();
   119 		}
   123 		}
   120 		return prefsStore;
   124 		return prefsStore;
       
   125 	}
       
   126 
       
   127 	/**
       
   128 	 * Retrieve proxy data for a given URL.
       
   129 	 * @param url - URL in question
       
   130 	 * @return proxy data associated with the URL if one is available, null otherwise
       
   131 	 */
       
   132 	public static IProxyData getProxyData(URL url) {
       
   133 		BundleContext context = getDefault().getBundle().getBundleContext();
       
   134 		if (context != null) {
       
   135 			ServiceReference reference = context.getServiceReference(IProxyService.class.getName());
       
   136 			if (reference != null) {
       
   137 				IProxyService proxyService = (IProxyService) context.getService(reference);
       
   138 				if (proxyService != null) {
       
   139 					try {
       
   140 						IProxyData[] proxyData = proxyService.select(url.toURI());
       
   141 						if (proxyData != null && proxyData.length > 0) {
       
   142 							return proxyData[0];
       
   143 						}
       
   144 					} catch (URISyntaxException e) {
       
   145 						return null;
       
   146 					}
       
   147 				}
       
   148 			}
       
   149 		}
       
   150 		return null;
   121 	}
   151 	}
   122 
   152 
   123 	/**
   153 	/**
   124 	 * Launch the Carbide.c++ news page.
   154 	 * Launch the Carbide.c++ news page.
   125 	 */
   155 	 */