Skip to content

Commit 8f182c9

Browse files
committed
Improved mime type to include rdp files
1 parent 3f02773 commit 8f182c9

5 files changed

Lines changed: 209 additions & 7 deletions

File tree

cmake/FindSharedMimeInfo.cmake

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# - Try to find the shared-mime-info package
2+
#
3+
# SHARED_MIME_INFO_MINIMUM_VERSION - Set this to the minimum version you need, default is 0.18
4+
#
5+
# Once done this will define
6+
#
7+
# SHARED_MIME_INFO_FOUND - system has the shared-mime-info package
8+
# UPDATE_MIME_DATABASE_EXECUTABLE - the update-mime-database executable
9+
10+
# Copyright (c) 2007, Pino Toscano, <toscano.pino@tiscali.it>
11+
#
12+
# Redistribution and use is allowed according to the terms of the BSD license.
13+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14+
15+
# the minimum version of shared-mime-database we require
16+
if (NOT SHARED_MIME_INFO_MINIMUM_VERSION)
17+
set(SHARED_MIME_INFO_MINIMUM_VERSION "0.18")
18+
endif (NOT SHARED_MIME_INFO_MINIMUM_VERSION)
19+
20+
if (UPDATE_MIME_DATABASE_EXECUTABLE)
21+
22+
# in cache already
23+
set(SHARED_MIME_INFO_FOUND TRUE)
24+
25+
else (UPDATE_MIME_DATABASE_EXECUTABLE)
26+
27+
include (MacroEnsureVersion)
28+
29+
find_program (UPDATE_MIME_DATABASE_EXECUTABLE NAMES update-mime-database)
30+
31+
if (UPDATE_MIME_DATABASE_EXECUTABLE)
32+
33+
exec_program (${UPDATE_MIME_DATABASE_EXECUTABLE} ARGS -v RETURN_VALUE _null OUTPUT_VARIABLE _smiVersionRaw)
34+
35+
string(REGEX REPLACE "update-mime-database \\([a-zA-Z\\-]+\\) ([0-9]\\.[0-9]+).*"
36+
"\\1" smiVersion "${_smiVersionRaw}")
37+
set (SHARED_MIME_INFO_FOUND TRUE)
38+
endif (UPDATE_MIME_DATABASE_EXECUTABLE)
39+
40+
if (SHARED_MIME_INFO_FOUND)
41+
if (NOT SharedMimeInfo_FIND_QUIETLY)
42+
message(STATUS "Found shared-mime-info version: ${smiVersion}")
43+
macro_ensure_version(${SHARED_MIME_INFO_MINIMUM_VERSION} ${smiVersion} _smiVersion_OK)
44+
if (NOT _smiVersion_OK)
45+
message(FATAL_ERROR "The found version of shared-mime-info (${smiVersion}) is below the minimum required (${SHARED_MIME_INFO_MINIMUM_VERSION})")
46+
endif (NOT _smiVersion_OK)
47+
48+
endif (NOT SharedMimeInfo_FIND_QUIETLY)
49+
else (SHARED_MIME_INFO_FOUND)
50+
if (SharedMimeInfo_FIND_REQUIRED)
51+
message(FATAL_ERROR "Could NOT find shared-mime-info. See http://freedesktop.org/wiki/Software/shared-mime-info.")
52+
endif (SharedMimeInfo_FIND_REQUIRED)
53+
endif (SHARED_MIME_INFO_FOUND)
54+
55+
endif (UPDATE_MIME_DATABASE_EXECUTABLE)
56+
57+
mark_as_advanced(UPDATE_MIME_DATABASE_EXECUTABLE)
58+
59+
60+
macro(UPDATE_XDG_MIMETYPES _path)
61+
get_filename_component(_xdgmimeDir "${_path}" NAME)
62+
if("${_xdgmimeDir}" STREQUAL packages )
63+
get_filename_component(_xdgmimeDir "${_path}" PATH)
64+
else("${_xdgmimeDir}" STREQUAL packages )
65+
set(_xdgmimeDir "${_path}")
66+
endif("${_xdgmimeDir}" STREQUAL packages )
67+
68+
install(CODE "
69+
set(DESTDIR_VALUE \"\$ENV{DESTDIR}\")
70+
if (NOT DESTDIR_VALUE)
71+
# under Windows relative paths are used, that's why it runs from CMAKE_INSTALL_PREFIX
72+
execute_process(COMMAND ${UPDATE_MIME_DATABASE_EXECUTABLE} ${_xdgmimeDir}
73+
WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\")
74+
endif (NOT DESTDIR_VALUE)
75+
")
76+
endmacro (UPDATE_XDG_MIMETYPES)

cmake/MacroEnsureVersion.cmake

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# This file defines the following macros for developers to use in ensuring
2+
# that installed software is of the right version:
3+
#
4+
# MACRO_ENSURE_VERSION - test that a version number is greater than
5+
# or equal to some minimum
6+
# MACRO_ENSURE_VERSION_RANGE - test that a version number is greater than
7+
# or equal to some minimum and less than some
8+
# maximum
9+
# MACRO_ENSURE_VERSION2 - deprecated, do not use in new code
10+
#
11+
12+
# MACRO_ENSURE_VERSION
13+
# This macro compares version numbers of the form "x.y.z" or "x.y"
14+
# MACRO_ENSURE_VERSION( FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK)
15+
# will set FOO_VERSION_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION
16+
# Leading and trailing text is ok, e.g.
17+
# MACRO_ENSURE_VERSION( "2.5.31" "flex 2.5.4a" VERSION_OK)
18+
# which means 2.5.31 is required and "flex 2.5.4a" is what was found on the system
19+
20+
# Copyright (c) 2006, David Faure, <faure@kde.org>
21+
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
22+
#
23+
# Redistribution and use is allowed according to the terms of the BSD license.
24+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
25+
26+
# MACRO_ENSURE_VERSION_RANGE
27+
# This macro ensures that a version number of the form
28+
# "x.y.z" or "x.y" falls within a range defined by
29+
# min_version <= found_version < max_version.
30+
# If this expression holds, FOO_VERSION_OK will be set TRUE
31+
#
32+
# Example: MACRO_ENSURE_VERSION_RANGE3( "0.1.0" ${FOOCODE_VERSION} "0.7.0" FOO_VERSION_OK )
33+
#
34+
# This macro will break silently if any of x,y,z are greater than 100.
35+
#
36+
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
37+
#
38+
# Redistribution and use is allowed according to the terms of the BSD license.
39+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
40+
41+
# NORMALIZE_VERSION
42+
# Helper macro to convert version numbers of the form "x.y.z"
43+
# to an integer equal to 10^4 * x + 10^2 * y + z
44+
#
45+
# This macro will break silently if any of x,y,z are greater than 100.
46+
#
47+
# Copyright (c) 2006, David Faure, <faure@kde.org>
48+
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
49+
#
50+
# Redistribution and use is allowed according to the terms of the BSD license.
51+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
52+
53+
# CHECK_RANGE_INCLUSIVE_LOWER
54+
# Helper macro to check whether x <= y < z
55+
#
56+
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
57+
#
58+
# Redistribution and use is allowed according to the terms of the BSD license.
59+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
60+
61+
62+
MACRO(NORMALIZE_VERSION _requested_version _normalized_version)
63+
STRING(REGEX MATCH "[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" _threePartMatch "${_requested_version}")
64+
if (_threePartMatch)
65+
# parse the parts of the version string
66+
STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major_vers "${_requested_version}")
67+
STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor_vers "${_requested_version}")
68+
STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch_vers "${_requested_version}")
69+
else (_threePartMatch)
70+
STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+" "\\1" _major_vers "${_requested_version}")
71+
STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)" "\\1" _minor_vers "${_requested_version}")
72+
set(_patch_vers "0")
73+
endif (_threePartMatch)
74+
75+
# compute an overall version number which can be compared at once
76+
MATH(EXPR ${_normalized_version} "${_major_vers}*10000 + ${_minor_vers}*100 + ${_patch_vers}")
77+
ENDMACRO(NORMALIZE_VERSION)
78+
79+
MACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER _lower_limit _value _upper_limit _ok)
80+
if (${_value} LESS ${_lower_limit})
81+
set( ${_ok} FALSE )
82+
elseif (${_value} EQUAL ${_lower_limit})
83+
set( ${_ok} TRUE )
84+
elseif (${_value} EQUAL ${_upper_limit})
85+
set( ${_ok} FALSE )
86+
elseif (${_value} GREATER ${_upper_limit})
87+
set( ${_ok} FALSE )
88+
else (${_value} LESS ${_lower_limit})
89+
set( ${_ok} TRUE )
90+
endif (${_value} LESS ${_lower_limit})
91+
ENDMACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER)
92+
93+
MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old)
94+
NORMALIZE_VERSION( ${requested_version} req_vers_num )
95+
NORMALIZE_VERSION( ${found_version} found_vers_num )
96+
97+
if (found_vers_num LESS req_vers_num)
98+
set( ${var_too_old} FALSE )
99+
else (found_vers_num LESS req_vers_num)
100+
set( ${var_too_old} TRUE )
101+
endif (found_vers_num LESS req_vers_num)
102+
103+
ENDMACRO(MACRO_ENSURE_VERSION)
104+
105+
MACRO(MACRO_ENSURE_VERSION2 requested_version2 found_version2 var_too_old2)
106+
MACRO_ENSURE_VERSION( ${requested_version2} ${found_version2} ${var_too_old2})
107+
ENDMACRO(MACRO_ENSURE_VERSION2)
108+
109+
MACRO(MACRO_ENSURE_VERSION_RANGE min_version found_version max_version var_ok)
110+
NORMALIZE_VERSION( ${min_version} req_vers_num )
111+
NORMALIZE_VERSION( ${found_version} found_vers_num )
112+
NORMALIZE_VERSION( ${max_version} max_vers_num )
113+
114+
MACRO_CHECK_RANGE_INCLUSIVE_LOWER( ${req_vers_num} ${found_vers_num} ${max_vers_num} ${var_ok})
115+
ENDMACRO(MACRO_ENSURE_VERSION_RANGE)

remmina/desktop/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,12 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/remmina-file.desktop
9393
install(FILES appdata.xml
9494
RENAME ${UNIQUE_APPNAME}.appdata.xml
9595
DESTINATION "${REMMINA_DATADIR}/metainfo")
96-
install(FILES remmina-mime.xml DESTINATION "${REMMINA_DATADIR}/mime/packages")
96+
# XML mime types
97+
set( SHARED_MIME_INFO_MINIMUM_VERSION "0.30" )
98+
set( XDG_MIME_INSTALL_DIR "${REMMINA_DATADIR}/mime/packages" )
99+
find_package( SharedMimeInfo )
100+
if( SHARED_MIME_INFO_FOUND )
101+
install( FILES remmina-mime.xml DESTINATION ${XDG_MIME_INSTALL_DIR} )
102+
update_xdg_mimetypes( ${XDG_MIME_INSTALL_DIR} )
103+
endif()
97104

remmina/desktop/remmina-mime.xml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
3-
<mime-type type="application/x-remmina">
4-
<sub-class-of type="text/plain"/>
5-
<comment>Remote Desktop (Remmina) file</comment>
6-
<glob pattern="*.remmina"/>
7-
<icon name="remmina"/>
8-
</mime-type>
3+
<mime-type type="application/x-remmina">
4+
<sub-class-of type="text/plain"/>
5+
<comment>Remote Desktop (Remmina) file</comment>
6+
<glob pattern="*.remmina"/>
7+
<glob pattern="*.rdp"/>
8+
<glob pattern="*.rdpx"/>
9+
<glob pattern="*.RDP"/>
10+
<icon name="remmina"/>
11+
</mime-type>
912
</mime-info>

remmina/desktop/remmina.desktop.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Terminal=false
7272
Type=Application
7373
Categories=GTK;GNOME;X-GNOME-NetworkSettings;Network;
7474
Actions=Profile;Tray;Quit;
75+
MimeType=application/x-remmina;
7576
Keywords=remote desktop;rdp;vnc;nx;ssh;spice;xdmcp;
7677
StartupWMClass=remmina
7778

0 commit comments

Comments
 (0)