Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 39 additions & 19 deletions server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,28 @@ set (GDIAL_VERSION_MINOR 0)
find_package (PkgConfig REQUIRED)
pkg_search_module (GLIB REQUIRED glib-2.0)
pkg_search_module (GIO REQUIRED gio-2.0)
pkg_search_module (GSSDP12 gssdp-1.2)
pkg_search_module (LIBSOUP3 libsoup-3.0)
if (GSSDP12_FOUND)
pkg_search_module (GSSDP REQUIRED gssdp-1.2)
add_definitions(-DHAVE_GSSDP_VERSION_1_2_OR_NEWER)
message("Using gssdp-1.2")
else()
pkg_search_module (GSSDP REQUIRED gssdp-1.0)
endif()
if (LIBSOUP3_FOUND)
pkg_search_module (GSSDP16 gssdp-1.6)
pkg_search_module (GSSDP12 gssdp-1.2)

if (LIBSOUP3_FOUND AND GSSDP16_FOUND)
pkg_search_module (SOUP REQUIRED libsoup-3.0)
add_definitions(-DHAVE_LIBSOUP_VERSION_3)
message("Using libsoup-3.0")
else()
pkg_search_module (GSSDP REQUIRED gssdp-1.6)
add_definitions(-DHAVE_GSSDP_VERSION_1_6_OR_NEWER)
message("Using gssdp-1.6")
else ()
pkg_search_module (SOUP REQUIRED libsoup-2.4)
endif()
if(GSSDP12_FOUND)
pkg_search_module (GSSDP REQUIRED gssdp-1.2)
add_definitions(-DHAVE_GSSDP_VERSION_1_2_OR_NEWER)
message("Using gssdp-1.2")
else ()
pkg_search_module (GSSDP REQUIRED gssdp-1.0)
message("Using gssdp-1.0")
endif ()
endif ()
pkg_search_module (XML2 REQUIRED libxml-2.0)

set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g")
Expand Down Expand Up @@ -73,14 +80,27 @@ include_directories (
${PROJECT_GLIB_INCLUDE_DIRS}
)

set (GDIAL_EXEC_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/gdial-util.c
${CMAKE_CURRENT_SOURCE_DIR}/gdial-app.c
${CMAKE_CURRENT_SOURCE_DIR}/gdial-rest.c
${CMAKE_CURRENT_SOURCE_DIR}/gdial-ssdp.c
${CMAKE_CURRENT_SOURCE_DIR}/gdial-shield.c
${CMAKE_CURRENT_SOURCE_DIR}/gdialservice.cpp
)
if (LIBSOUP3_FOUND AND GSSDP16_FOUND)
set (GDIAL_EXEC_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/gdial-util.c
${CMAKE_CURRENT_SOURCE_DIR}/gdial-app.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup-3p0/gdial-rest.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup-3p0/gdial-ssdp.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup-3p0/gdial-shield.c
${CMAKE_CURRENT_SOURCE_DIR}/gdialservice.cpp
)
message("Using libsoup-3.0 compatible source files from libsoup-3p0/")
else()
set (GDIAL_EXEC_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/gdial-util.c
${CMAKE_CURRENT_SOURCE_DIR}/gdial-app.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup-2p4/gdial-rest.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup-2p4/gdial-ssdp.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup-2p4/gdial-shield.c
${CMAKE_CURRENT_SOURCE_DIR}/gdialservice.cpp
)
message("Using libsoup-2.4 compatible source files from libsoup-2p4/")
endif()

link_directories (
${GLIB_LIBRARY_DIRS}
Expand Down
23 changes: 23 additions & 0 deletions server/gdialservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,22 @@ static void signal_handler_rest_server_rest_enable(GDialRestServer *dial_rest_se
}

static void gdial_http_server_throttle_callback(SoupServer *server,
#ifdef HAVE_LIBSOUP_VERSION_3
SoupServerMessage *msg, const gchar *path, GHashTable *query,
gpointer user_data)
#else
SoupMessage *msg, const gchar *path, GHashTable *query,
SoupClientContext *client, gpointer user_data)
#endif
{
GDIAL_LOGINFO("gdial_http_server_throttle_callback ");
#ifdef HAVE_LIBSOUP_VERSION_3
soup_message_headers_replace(soup_server_message_get_response_headers(msg), "Connection", "close");
soup_server_message_set_status(msg, SOUP_STATUS_NOT_FOUND, NULL);
#else
soup_message_headers_replace(msg->response_headers, "Connection", "close");
soup_message_set_status(msg, SOUP_STATUS_NOT_FOUND);
#endif
}

static void gdial_quit_thread(int signum)
Expand Down Expand Up @@ -490,6 +500,18 @@ int gdialServiceImpl::start_GDialServer(int argc, char *argv[])
GSList *uris = soup_server_get_uris(m_servers[i]);
for (GSList *uri = uris; uri != NULL; uri = uri->next)
{
#ifdef HAVE_LIBSOUP_VERSION_3
GUri *origin_uri = (GUri *)uri->data;
if (!origin_uri)
{
GDIAL_LOGWARNING("Failed to get GUri from SoupServer at index [%d]", i);
continue;
}
char *uri_string = g_uri_to_string(origin_uri);
GDIAL_LOGINFO("Listening on %s", uri_string);
g_free(uri_string);
g_uri_unref(origin_uri);
#else
SoupURI *origin_uri = (SoupURI *)uri->data;
if (!origin_uri)
{
Expand All @@ -500,6 +522,7 @@ int gdialServiceImpl::start_GDialServer(int argc, char *argv[])
GDIAL_LOGINFO("Listening on %s", uri_string);
g_free(uri_string);
soup_uri_free(origin_uri);
#endif
}
g_slist_free(uris);
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading