diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a10d6c95b71404d92e6accf73f893adc3fa467f..aea57c9c58c657e8914a371f2d33509c403fe317 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,7 @@ endif() # FIND SQLITE3 if (ENABLE_SQLITE3) if (NOT CMAKE_COMPILER_IS_GNUCXX) - ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/msvc-deps/sqlite3) + ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/msvc-deps) else() if (WIN32) ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/msvc-deps/sqlite3) diff --git a/backends/twitter/CMakeLists.txt b/backends/twitter/CMakeLists.txt index 26da4cb7b2864645b819e9d0c1ef0a2bab161b83..981e404634be7bf6d51920dc79c18756275bc956 100644 --- a/backends/twitter/CMakeLists.txt +++ b/backends/twitter/CMakeLists.txt @@ -5,6 +5,7 @@ add_executable(spectrum2_twitter_backend ${SRC}) if (NOT WIN32) target_link_libraries(spectrum2_twitter_backend curl transport pthread ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES}) else () +include_directories("${CMAKE_SOURCE_DIR}/msvc-deps/curl/include") target_link_libraries(spectrum2_twitter_backend libcurl_imp transport ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES}) endif() diff --git a/docs/guide/postgresql.textile b/docs/guide/postgresql.textile index 85d27c0c76c0c1d90548202ad8b8373e9686a288..a8f5aa1a23724f84d6e5136f0bc2ceb7d8ebd1ad 100644 --- a/docs/guide/postgresql.textile +++ b/docs/guide/postgresql.textile @@ -1,16 +1,33 @@ h2. 1. Editing the configuration file -To configure Spectrum 2 to use PostgreSQL database, you have to edit following options in database section: +To configure Spectrum 2 to use PostgreSQL database, you have to edit some or more of the following options in database section. Please note that connectionstring overrides everything else (aside from type). |_. Section |_. Key |_. Type |_. Change to value |_. Description | | database| type | string | pqxx | Database type - "none", "mysql", "sqlite3", "pqxx". | | database| database | string | Name of the already create empty database | Database used to store data. | | database| server | string | Database server | Database server. | +| database| port | string | Database port | Database port. | | database| user | string | PostgreSQL user. | PostgreSQL user. | | database| password | string | PostgreSQL Password. | PostgreSQL Password. | | database| prefix | string | | Prefix of tables in database. | +| database| connectionstring | string | Postgres connection string | If you set this, it will ignore all other options above aside from type and prefix. This allows you to set any typical postgres connection string option, separated by spaces (no semicolons). | h2. 2. Creating the database -Spectrum 2 will create the database on the first execution. Once the database is created, you can remove the CREATE TABLE permissions to the PostgreSQL database user you use to connect the SQL. \ No newline at end of file +Spectrum 2 will create the database on the first execution. Once the database is created, you can remove the CREATE TABLE permissions to the PostgreSQL database user you use to connect the SQL. + +h2. 3. Some examples + +Using connectionstring: +[database] +type=pqxx +connectionstring=host=localhost database=spectrum2 user=myuser password=whatever + +Using traditional options: +[database] +type=pqxx +server=localhost +database=spectrum2 +user=myuser +password=whatever diff --git a/packaging/fedora/spectrum2.spec b/packaging/fedora/spectrum2.spec index 7bae9b13d0e2ec066b7e9cdfcdb8f3a290ff4c5b..91b6025605560cad7f46556f382e8191f1778aa8 100644 --- a/packaging/fedora/spectrum2.spec +++ b/packaging/fedora/spectrum2.spec @@ -25,7 +25,7 @@ BuildRequires: libidn-devel BuildRequires: expat-devel BuildRequires: avahi-devel BuildRequires: log4cxx-devel -BuildRequires: swiften-devel +#BuildRequires: swiften-devel BuildRequires: libcommuni-devel Requires: libtransport%{?_isa} = %{version}-%{release} diff --git a/spectrum/src/sample2.cfg b/spectrum/src/sample2.cfg index 0da3b1ecbbc380ee5d940a93155993c0a79d379b..cc0a7aef8e0d611c4f98a0f23a7415d0a490269a 100644 --- a/spectrum/src/sample2.cfg +++ b/spectrum/src/sample2.cfg @@ -96,6 +96,10 @@ type = none # Prefix used for tables #prefix = jabber_ +# Connection string (for pqxx only!) +# If you set this, it ignores every other database option except for type and prefix. +#connectionstring = host=localhost user=specturm password=secret + [registration] # Enable public registrations enable_public_registration=1 diff --git a/src/pqxxbackend.cpp b/src/pqxxbackend.cpp index 400de53bf8f29c792223ab67400a1311c4c2df88..8422d9a97017d6069756b4653bcd6cafd2411bb6 100644 --- a/src/pqxxbackend.cpp +++ b/src/pqxxbackend.cpp @@ -48,21 +48,34 @@ void PQXXBackend::disconnect() { } bool PQXXBackend::connect() { - LOG4CXX_INFO(logger, "Connecting PostgreSQL server " << CONFIG_STRING(m_config, "database.server") << ", user " << - CONFIG_STRING(m_config, "database.user") << ", database " << CONFIG_STRING(m_config, "database.database") << - ", port " << CONFIG_INT(m_config, "database.port") - ); - - std::string str = "dbname="; - str += CONFIG_STRING(m_config, "database.database") + " "; - - str += "user=" + CONFIG_STRING(m_config, "database.user") + " "; - if (!CONFIG_STRING(m_config, "database.password").empty()) { - str += "password=" + CONFIG_STRING(m_config, "database.password") + " "; + std::string connection_str; + connection_str = CONFIG_STRING(m_config, "database.connectionstring"); + if (connection_str.empty()) { + LOG4CXX_INFO(logger, "Connecting PostgreSQL server " << CONFIG_STRING(m_config, "database.server") << ", user " << + CONFIG_STRING(m_config, "database.user") << ", database " << CONFIG_STRING(m_config, "database.database") << + ", port " << CONFIG_INT(m_config, "database.port") + ); + connection_str = "dbname="; + connection_str += CONFIG_STRING(m_config, "database.database"); + if (!CONFIG_STRING(m_config, "database.server").empty()) { + connection_str += " host=" + CONFIG_STRING(m_config, "database.server"); + } + if (!CONFIG_STRING(m_config, "database.user").empty()) { + connection_str += " user=" + CONFIG_STRING(m_config, "database.user"); + } + if (!CONFIG_STRING(m_config, "database.password").empty()) { + connection_str += " password=" + CONFIG_STRING(m_config, "database.password"); + } + if (!CONFIG_STRING(m_config, "database.port").empty()) { + connection_str += " port=" + CONFIG_STRING(m_config, "database.password"); + } + } + else { + LOG4CXX_INFO(logger, "Connecting PostgreSQL server via provided connection string."); } try { - m_conn = new pqxx::connection(str); + m_conn = new pqxx::connection(connection_str); } catch (std::exception& e) { LOG4CXX_ERROR(logger, e.what());