Skip to content

Commit

Permalink
refs #10371. Move services to kernel.
Browse files Browse the repository at this point in the history
This needs to be checked on all other OS. I doubt this works yet on windows or linux properly.
  • Loading branch information
OwenArnold committed Oct 16, 2014
1 parent b4f4a1a commit a00b146
Show file tree
Hide file tree
Showing 10 changed files with 2,151 additions and 1,609 deletions.
19 changes: 16 additions & 3 deletions Code/Mantid/Framework/Kernel/CMakeLists.txt
Expand Up @@ -11,8 +11,8 @@ set ( SRC_FILES
src/ConfigService.cpp
src/DataItem.cpp
src/DateAndTime.cpp
src/DateValidator.cpp
src/DateTimeValidator.cpp
src/DateValidator.cpp
src/DeltaEMode.cpp
src/DirectoryValidator.cpp
src/DiskBuffer.cpp
Expand Down Expand Up @@ -65,6 +65,7 @@ set ( SRC_FILES
src/PropertyManager.cpp
src/PropertyManagerOwner.cpp
src/PropertyWithValue.cpp
src/ProxyInfo.cpp
src/PseudoRandomNumberGenerator.cpp
src/Quat.cpp
src/ReadLock.cpp
Expand Down Expand Up @@ -129,8 +130,8 @@ set ( INC_FILES
inc/MantidKernel/DataItem.h
inc/MantidKernel/DataService.h
inc/MantidKernel/DateAndTime.h
inc/MantidKernel/DateValidator.h
inc/MantidKernel/DateTimeValidator.h
inc/MantidKernel/DateValidator.h
inc/MantidKernel/DeltaEMode.h
inc/MantidKernel/DirectoryValidator.h
inc/MantidKernel/DiskBuffer.h
Expand Down Expand Up @@ -185,6 +186,7 @@ set ( INC_FILES
inc/MantidKernel/MultiThreaded.h
inc/MantidKernel/NDPseudoRandomNumberGenerator.h
inc/MantidKernel/NDRandomNumberGenerator.h
inc/MantidKernel/NetworkProxy.h
inc/MantidKernel/NeutronAtom.h
inc/MantidKernel/NexusDescriptor.h
inc/MantidKernel/NullValidator.h
Expand All @@ -197,6 +199,7 @@ set ( INC_FILES
inc/MantidKernel/PropertyManager.h
inc/MantidKernel/PropertyManagerOwner.h
inc/MantidKernel/PropertyWithValue.h
inc/MantidKernel/ProxyInfo.h
inc/MantidKernel/PseudoRandomNumberGenerator.h
inc/MantidKernel/QuasiRandomNumberSequence.h
inc/MantidKernel/Quat.h
Expand Down Expand Up @@ -310,6 +313,7 @@ set ( TEST_FILES
PropertyManagerTest.h
PropertyTest.h
PropertyWithValueTest.h
ProxyInfoTest.h
QuatTest.h
ReadLockTest.h
RebinHistogramTest.h
Expand Down Expand Up @@ -344,6 +348,15 @@ set ( TEST_FILES
WriteLockTest.h
)

if ( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
LIST( APPEND SRC_FILES src/NetworkProxyOSX.cpp )
SET( NETWORK_LIBRARIES "-framework SystemConfiguration" "-framework CoreFoundation" "-framework CoreServices")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
LIST( APPEND SRC_FILES src/NetworkProxyWin.cpp )
else()
LIST( APPEND SRC_FILES src/NetworkProxyLinux.cpp )
endif()

if(UNITY_BUILD)
include(UnityBuild)
enable_unity_build(Kernel SRC_FILES SRC_UNITY_IGNORE_FILES 10)
Expand All @@ -362,7 +375,7 @@ set_target_properties ( Kernel PROPERTIES OUTPUT_NAME MantidKernel
# Add to the 'Framework' group in VS
set_property ( TARGET Kernel PROPERTY FOLDER "MantidFramework" )

target_link_libraries ( Kernel ${MANTIDLIBS} ${GSL_LIBRARIES} ${NEXUS_LIBRARIES} )
target_link_libraries ( Kernel ${MANTIDLIBS} ${GSL_LIBRARIES} ${NEXUS_LIBRARIES} ${NETWORK_LIBRARIES} )
if ( WIN32 )
target_link_libraries ( Kernel Psapi.lib ) # For memory usage queries
endif()
Expand Down
59 changes: 59 additions & 0 deletions Code/Mantid/Framework/Kernel/inc/MantidKernel/NetworkProxy.h
@@ -0,0 +1,59 @@
#ifndef MANTID_KERNEL_NETWORKPROXY_H_
#define MANTID_KERNEL_NETWORKPROXY_H_

#include "MantidKernel/System.h"
#include "MantidKernel/ProxyInfo.h"
#include "MantidKernel/Logger.h"


namespace Mantid
{
namespace Kernel
{

/** NetworkProxy : Network proxy utility for getting network proxy information.
Copyright © 2014 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport NetworkProxy
{
public:
/// Constructor
NetworkProxy();

/// Get http proxy information.
ProxyInfo getHttpProxy(const std::string& targetURLString);

/// Destructor
virtual ~NetworkProxy();

private:

/// Logger object
Mantid::Kernel::Logger m_logger;

};


} // namespace Kernel
} // namespace Mantid

#endif /* MANTID_KERNEL_NETWORKPROXY_H_ */
@@ -1,12 +1,12 @@
#ifndef MANTID_SCRIPTREPOSITORY_PROXYINFO_H_
#define MANTID_SCRIPTREPOSITORY_PROXYINFO_H_
#ifndef MANTID_KERNEL_PROXYINFO_H_
#define MANTID_KERNEL_PROXYINFO_H_

#include "MantidKernel/System.h"
#include <string>

namespace Mantid
{
namespace ScriptRepository
namespace Kernel
{

/** ProxyInfo : Container for carrying around network proxy information
Expand Down Expand Up @@ -52,7 +52,7 @@ namespace Mantid

};

} // namespace ScriptRepository
} // namespace Kernel
} // namespace Mantid

#endif /* MANTID_SCRIPTREPOSITORY_PROXYINFO_H_ */
#endif /* MANTID_KERNEL_PROXYINFO_H_ */
38 changes: 38 additions & 0 deletions Code/Mantid/Framework/Kernel/src/NetworkProxyLinux.cpp
@@ -0,0 +1,38 @@
#include "MantidKernel/NetworkProxy.h"

namespace Mantid
{
namespace Kernel
{

//----------------------------------------------------------------------------------------------
/** Constructor
*/
NetworkProxy::NetworkProxy() :
m_logger("network_proxy_logger_generic")
{
}

//----------------------------------------------------------------------------------------------
/** Destructor
*/
NetworkProxy::~NetworkProxy()
{
}

ProxyInfo NetworkProxy::getHttpProxy(const std::string& targetURLString)
{
ProxyInfo proxyInfo; // NoProxy.
char * proxy_var = getenv("http_proxy");
if (proxy_var == 0)
proxy_var = getenv("HTTP_PROXY");

if (proxy_var != 0)
{
Poco::URI uri_p(proxy_var);
proxyInfo = ProxyInfo(uri_p.getHost(), uri_p.getPort(), true /*http proxy*/);
}
}

} // namespace Kernel
} // namespace Mantid

0 comments on commit a00b146

Please sign in to comment.