diff options
author | Antenore Gatta <antenore@simbiosi.org> | 2018-03-04 03:26:59 +0300 |
---|---|---|
committer | Antenore Gatta <antenore@simbiosi.org> | 2018-03-04 03:26:59 +0300 |
commit | 8f182c9cbb2ef269b825fd128dedc244e0c7682c (patch) | |
tree | f2d7f8c0be35b01e90799e8fbf66d4347e279cad | |
parent | 3f027730910292df1de9d30d112bc33c2c1cd073 (diff) |
Improved mime type to include rdp files
-rw-r--r-- | cmake/FindSharedMimeInfo.cmake | 76 | ||||
-rw-r--r-- | cmake/MacroEnsureVersion.cmake | 115 | ||||
-rw-r--r-- | remmina/desktop/CMakeLists.txt | 9 | ||||
-rw-r--r-- | remmina/desktop/remmina-mime.xml | 15 | ||||
-rw-r--r-- | remmina/desktop/remmina.desktop.in | 1 |
5 files changed, 209 insertions, 7 deletions
diff --git a/cmake/FindSharedMimeInfo.cmake b/cmake/FindSharedMimeInfo.cmake new file mode 100644 index 000000000..ee6495627 --- /dev/null +++ b/cmake/FindSharedMimeInfo.cmake @@ -0,0 +1,76 @@ +# - Try to find the shared-mime-info package +# +# SHARED_MIME_INFO_MINIMUM_VERSION - Set this to the minimum version you need, default is 0.18 +# +# Once done this will define +# +# SHARED_MIME_INFO_FOUND - system has the shared-mime-info package +# UPDATE_MIME_DATABASE_EXECUTABLE - the update-mime-database executable + +# Copyright (c) 2007, Pino Toscano, <toscano.pino@tiscali.it> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# the minimum version of shared-mime-database we require +if (NOT SHARED_MIME_INFO_MINIMUM_VERSION) + set(SHARED_MIME_INFO_MINIMUM_VERSION "0.18") +endif (NOT SHARED_MIME_INFO_MINIMUM_VERSION) + +if (UPDATE_MIME_DATABASE_EXECUTABLE) + + # in cache already + set(SHARED_MIME_INFO_FOUND TRUE) + +else (UPDATE_MIME_DATABASE_EXECUTABLE) + + include (MacroEnsureVersion) + + find_program (UPDATE_MIME_DATABASE_EXECUTABLE NAMES update-mime-database) + + if (UPDATE_MIME_DATABASE_EXECUTABLE) + + exec_program (${UPDATE_MIME_DATABASE_EXECUTABLE} ARGS -v RETURN_VALUE _null OUTPUT_VARIABLE _smiVersionRaw) + + string(REGEX REPLACE "update-mime-database \\([a-zA-Z\\-]+\\) ([0-9]\\.[0-9]+).*" + "\\1" smiVersion "${_smiVersionRaw}") + set (SHARED_MIME_INFO_FOUND TRUE) + endif (UPDATE_MIME_DATABASE_EXECUTABLE) + + if (SHARED_MIME_INFO_FOUND) + if (NOT SharedMimeInfo_FIND_QUIETLY) + message(STATUS "Found shared-mime-info version: ${smiVersion}") + macro_ensure_version(${SHARED_MIME_INFO_MINIMUM_VERSION} ${smiVersion} _smiVersion_OK) + if (NOT _smiVersion_OK) + message(FATAL_ERROR "The found version of shared-mime-info (${smiVersion}) is below the minimum required (${SHARED_MIME_INFO_MINIMUM_VERSION})") + endif (NOT _smiVersion_OK) + + endif (NOT SharedMimeInfo_FIND_QUIETLY) + else (SHARED_MIME_INFO_FOUND) + if (SharedMimeInfo_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find shared-mime-info. See http://freedesktop.org/wiki/Software/shared-mime-info.") + endif (SharedMimeInfo_FIND_REQUIRED) + endif (SHARED_MIME_INFO_FOUND) + +endif (UPDATE_MIME_DATABASE_EXECUTABLE) + +mark_as_advanced(UPDATE_MIME_DATABASE_EXECUTABLE) + + +macro(UPDATE_XDG_MIMETYPES _path) + get_filename_component(_xdgmimeDir "${_path}" NAME) + if("${_xdgmimeDir}" STREQUAL packages ) + get_filename_component(_xdgmimeDir "${_path}" PATH) + else("${_xdgmimeDir}" STREQUAL packages ) + set(_xdgmimeDir "${_path}") + endif("${_xdgmimeDir}" STREQUAL packages ) + + install(CODE " + set(DESTDIR_VALUE \"\$ENV{DESTDIR}\") + if (NOT DESTDIR_VALUE) + # under Windows relative paths are used, that's why it runs from CMAKE_INSTALL_PREFIX + execute_process(COMMAND ${UPDATE_MIME_DATABASE_EXECUTABLE} ${_xdgmimeDir} + WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\") + endif (NOT DESTDIR_VALUE) + ") +endmacro (UPDATE_XDG_MIMETYPES) diff --git a/cmake/MacroEnsureVersion.cmake b/cmake/MacroEnsureVersion.cmake new file mode 100644 index 000000000..a4f1c524a --- /dev/null +++ b/cmake/MacroEnsureVersion.cmake @@ -0,0 +1,115 @@ +# This file defines the following macros for developers to use in ensuring +# that installed software is of the right version: +# +# MACRO_ENSURE_VERSION - test that a version number is greater than +# or equal to some minimum +# MACRO_ENSURE_VERSION_RANGE - test that a version number is greater than +# or equal to some minimum and less than some +# maximum +# MACRO_ENSURE_VERSION2 - deprecated, do not use in new code +# + +# MACRO_ENSURE_VERSION +# This macro compares version numbers of the form "x.y.z" or "x.y" +# MACRO_ENSURE_VERSION( FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK) +# will set FOO_VERSION_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION +# Leading and trailing text is ok, e.g. +# MACRO_ENSURE_VERSION( "2.5.31" "flex 2.5.4a" VERSION_OK) +# which means 2.5.31 is required and "flex 2.5.4a" is what was found on the system + +# Copyright (c) 2006, David Faure, <faure@kde.org> +# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# MACRO_ENSURE_VERSION_RANGE +# This macro ensures that a version number of the form +# "x.y.z" or "x.y" falls within a range defined by +# min_version <= found_version < max_version. +# If this expression holds, FOO_VERSION_OK will be set TRUE +# +# Example: MACRO_ENSURE_VERSION_RANGE3( "0.1.0" ${FOOCODE_VERSION} "0.7.0" FOO_VERSION_OK ) +# +# This macro will break silently if any of x,y,z are greater than 100. +# +# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# NORMALIZE_VERSION +# Helper macro to convert version numbers of the form "x.y.z" +# to an integer equal to 10^4 * x + 10^2 * y + z +# +# This macro will break silently if any of x,y,z are greater than 100. +# +# Copyright (c) 2006, David Faure, <faure@kde.org> +# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# CHECK_RANGE_INCLUSIVE_LOWER +# Helper macro to check whether x <= y < z +# +# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +MACRO(NORMALIZE_VERSION _requested_version _normalized_version) + STRING(REGEX MATCH "[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" _threePartMatch "${_requested_version}") + if (_threePartMatch) + # parse the parts of the version string + STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major_vers "${_requested_version}") + STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor_vers "${_requested_version}") + STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch_vers "${_requested_version}") + else (_threePartMatch) + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+" "\\1" _major_vers "${_requested_version}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)" "\\1" _minor_vers "${_requested_version}") + set(_patch_vers "0") + endif (_threePartMatch) + + # compute an overall version number which can be compared at once + MATH(EXPR ${_normalized_version} "${_major_vers}*10000 + ${_minor_vers}*100 + ${_patch_vers}") +ENDMACRO(NORMALIZE_VERSION) + +MACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER _lower_limit _value _upper_limit _ok) + if (${_value} LESS ${_lower_limit}) + set( ${_ok} FALSE ) + elseif (${_value} EQUAL ${_lower_limit}) + set( ${_ok} TRUE ) + elseif (${_value} EQUAL ${_upper_limit}) + set( ${_ok} FALSE ) + elseif (${_value} GREATER ${_upper_limit}) + set( ${_ok} FALSE ) + else (${_value} LESS ${_lower_limit}) + set( ${_ok} TRUE ) + endif (${_value} LESS ${_lower_limit}) +ENDMACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER) + +MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) + NORMALIZE_VERSION( ${requested_version} req_vers_num ) + NORMALIZE_VERSION( ${found_version} found_vers_num ) + + if (found_vers_num LESS req_vers_num) + set( ${var_too_old} FALSE ) + else (found_vers_num LESS req_vers_num) + set( ${var_too_old} TRUE ) + endif (found_vers_num LESS req_vers_num) + +ENDMACRO(MACRO_ENSURE_VERSION) + +MACRO(MACRO_ENSURE_VERSION2 requested_version2 found_version2 var_too_old2) + MACRO_ENSURE_VERSION( ${requested_version2} ${found_version2} ${var_too_old2}) +ENDMACRO(MACRO_ENSURE_VERSION2) + +MACRO(MACRO_ENSURE_VERSION_RANGE min_version found_version max_version var_ok) + NORMALIZE_VERSION( ${min_version} req_vers_num ) + NORMALIZE_VERSION( ${found_version} found_vers_num ) + NORMALIZE_VERSION( ${max_version} max_vers_num ) + + MACRO_CHECK_RANGE_INCLUSIVE_LOWER( ${req_vers_num} ${found_vers_num} ${max_vers_num} ${var_ok}) +ENDMACRO(MACRO_ENSURE_VERSION_RANGE) diff --git a/remmina/desktop/CMakeLists.txt b/remmina/desktop/CMakeLists.txt index df884e732..714b3f1e0 100644 --- a/remmina/desktop/CMakeLists.txt +++ b/remmina/desktop/CMakeLists.txt @@ -93,5 +93,12 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/remmina-file.desktop install(FILES appdata.xml RENAME ${UNIQUE_APPNAME}.appdata.xml DESTINATION "${REMMINA_DATADIR}/metainfo") -install(FILES remmina-mime.xml DESTINATION "${REMMINA_DATADIR}/mime/packages") +# XML mime types +set( SHARED_MIME_INFO_MINIMUM_VERSION "0.30" ) +set( XDG_MIME_INSTALL_DIR "${REMMINA_DATADIR}/mime/packages" ) +find_package( SharedMimeInfo ) +if( SHARED_MIME_INFO_FOUND ) + install( FILES remmina-mime.xml DESTINATION ${XDG_MIME_INSTALL_DIR} ) + update_xdg_mimetypes( ${XDG_MIME_INSTALL_DIR} ) +endif() diff --git a/remmina/desktop/remmina-mime.xml b/remmina/desktop/remmina-mime.xml index caaba5a2b..bbb7a8c54 100644 --- a/remmina/desktop/remmina-mime.xml +++ b/remmina/desktop/remmina-mime.xml @@ -1,9 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> - <mime-type type="application/x-remmina"> - <sub-class-of type="text/plain"/> - <comment>Remote Desktop (Remmina) file</comment> - <glob pattern="*.remmina"/> - <icon name="remmina"/> - </mime-type> + <mime-type type="application/x-remmina"> + <sub-class-of type="text/plain"/> + <comment>Remote Desktop (Remmina) file</comment> + <glob pattern="*.remmina"/> + <glob pattern="*.rdp"/> + <glob pattern="*.rdpx"/> + <glob pattern="*.RDP"/> + <icon name="remmina"/> + </mime-type> </mime-info> diff --git a/remmina/desktop/remmina.desktop.in b/remmina/desktop/remmina.desktop.in index 489f05c89..bd2e36c6d 100644 --- a/remmina/desktop/remmina.desktop.in +++ b/remmina/desktop/remmina.desktop.in @@ -72,6 +72,7 @@ Terminal=false Type=Application Categories=GTK;GNOME;X-GNOME-NetworkSettings;Network; Actions=Profile;Tray;Quit; +MimeType=application/x-remmina; Keywords=remote desktop;rdp;vnc;nx;ssh;spice;xdmcp; StartupWMClass=remmina |