%bcond_with telepathy

%define _unpackaged_files_terminate_build 1

Summary: 	Remote Desktop Connection utility
Summary(ja): 	リモートデスクトップ接続ユーティリティ
Name: 		remmina
Version: 	1.4.3
Release:    1%{?_dist_release}
Group: 		User Interface/Desktops
Vendor:		Project Vine
Distribution:	Vine Linux

License: 	GPLv2+ and MIT
URL: 		https://remmina.org/
Source0:	https://gitlab.com/Remmina/Remmina/-/archive/v%{version}/Remmina-v%{version}.tar.bz2

# Cmake helper file to easy build plugins outside remmina source tree
# See http://www.muflone.com/remmina-plugin-rdesktop/english/install.html which
# use http://www.muflone.com/remmina-plugin-builder/ with remmina bundled source.
# So we can't use it directly only as instructions.
Source1:       pluginBuild-CMakeLists.txt

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires:  gtk3-devel
BuildRequires:  vte3-devel
BuildRequires:  libgcrypt-devel
BuildRequires:  libssh-devel
BuildRequires:  avahi-ui-gtk3-devel
BuildRequires:  libxkbfile-devel
BuildRequires:  desktop-file-utils
BuildRequires:  gnutls-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libvncserver-devel
BuildRequires:  libsecret-devel
BuildRequires:  libsodium-devel
BuildRequires:  freerdp-devel >= 1.0.1
%if %{with telepathy}
BuildRequires:  telepathy-glib-devel
%endif
BuildRequires:  json-glib-devel
BuildRequires:  libsoup-devel

BuildRequires:  cmake
BuildRequires:  gettext
BuildRequires:  intltool

Obsoletes: grdc < 0.7.0
Provides: grdc = %{version}
Obsoletes: remmina-gnome <= 0.7.3

%description
Remmina is a remote desktop client written in GTK+, aiming to be
useful for system administrators and travelers, who need to work 
with lots of remote computers in front of either large monitors or 
tiny netbooks.


%package devel
Summary:        Development tools for remmina
Summary(ja):    remmina の開発環境
Group:          Development/Libraries
Requires:       %{name} = %{version}-%{release}
Requires:       pkgconfig

%description devel
Header files and libraries for building a extension library for the
remmina.


%package        plugins-exec
Summary:        External execution plugin for Remmina Remote Desktop Client
Summary(ja):	Remmina の外部プロセス実行プラグイン
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description    plugins-exec
Remmina is a remote desktop client written in GTK+, aiming to be useful for
system administrators and travelers, who need to work with lots of remote
computers in front of either large monitors or tiny net-books.

This package contains the plugin to execute external processes (commands or
applications) from the Remmina window.


%package        plugins-secret
Summary:        GNOME keyring integration for Remmina Remote Desktop Client
Summary(ja):	Remmina の GNOMEキーリング統合
Group: 		User Interface/Desktops
Requires:       %{name} = %{version}-%{release}
Obsoletes:      %{name}plugins-gnome < 1.2
Provides:       %{name}-plugins-gnome = %{version}-%{release}

%description    plugins-secret
Remmina is a remote desktop client written in GTK+, aiming to be
useful for system administrators and travelers, who need to work 
with lots of remote computers in front of either large monitors or
tiny netbooks.

This package contains the plugin with GNOME keyring support for the
Remmina remote desktop client.


%package        plugins-nx
Summary:        NX plugin for Remmina Remote Desktop Client
Summary(ja):	Remmina の NX プラグイン
Group: 		User Interface/Desktops
Requires:       %{name} = %{version}-%{release}
# temporally disabled
#Requires:       nx

%description    plugins-nx
Remmina is a remote desktop client written in GTK+, aiming to be
useful for system administrators and travelers, who need to work 
with lots of remote computers in front of either large monitors or
tiny netbooks.

This package contains the NX plugin for the Remmina remote desktop
client.


%package        plugins-rdp
Summary:        RDP plugin for Remmina Remote Desktop Client
Summary(ja):	Remmina の RDP プラグイン
Group: 		User Interface/Desktops
Requires:       %{name} = %{version}-%{release}
Requires:       freerdp

%description    plugins-rdp
Remmina is a remote desktop client written in GTK+, aiming to be
useful for system administrators and travelers, who need to work 
with lots of remote computers in front of either large monitors or
tiny netbooks.

This package contains the Remote Desktop Protocol (RDP) plugin for the
Remmina remote desktop client.

%if %{with telepathy}
%package        plugins-telepathy
Summary:        Telepathy plugin for Remmina Remote Desktop Client
Summary(ja):	Remmina の Telepathy プラグイン
Group: 		User Interface/Desktops
Requires:       %{name} = %{version}-%{release}

%description    plugins-telepathy
Remmina is a remote desktop client written in GTK+, aiming to be
useful for system administrators and travelers, who need to work 
with lots of remote computers in front of either large monitors or
tiny netbooks.

This package contains the Telepathy plugin for the Remmina remote
desktop  client.
%endif

%package        plugins-st
Summary:        Simple Terminal plugin for Remmina Remote Desktop Client
Summary(ja):	Remmina のシンプルな端末プラグイン
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description    plugins-st
Remmina is a remote desktop client written in GTK+, aiming to be useful for
system administrators and travelers, who need to work with lots of remote
computers in front of either large monitors or tiny net-books.

This package contains the Simple Terminal plugin for the Remmina remote desktop
client.


%package        plugins-vnc
Summary:        VNC plugin for Remmina Remote Desktop Client
Summary(ja):	Remmina の VNC プラグイン
Group: 		User Interface/Desktops
Requires:       %{name} = %{version}-%{release}

%description    plugins-vnc
Remmina is a remote desktop client written in GTK+, aiming to be
useful for system administrators and travelers, who need to work 
with lots of remote computers in front of either large monitors or 
tiny netbooks.

This package contains the VNC plugin for the Remmina remote desktop 
client.


%package        plugins-xdmcp
Summary:        XDMCP plugin for Remmina Remote Desktop Client
Summary(ja):	Remmina の XDMCP プラグイン
Group: 		User Interface/Desktops
Requires:       %{name} = %{version}-%{release}
Requires:       xorg-x11-server-Xephyr

%description    plugins-xdmcp
Remmina is a remote desktop client written in GTK+, aiming to be
useful for system administrators and travelers, who need to work 
with lots of remote computers in front of either large monitors or 
tiny netbooks.

This package contains the XDMCP plugin for the Remmina remote desktop 
client.


%package        gnome-session
Summary:        Gnome Shell session for Remmina kiosk mode
Summary(ja):	Remmina の GNOME Shell セッション
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       gnome-session

%description    gnome-session
Remmina is a remote desktop client written in GTK+, aiming to be useful for
system administrators and travelers, who need to work with lots of remote
computers in front of either large monitors or tiny net-books.

This package contains Remmina kiosk mode, including a Gnome Shell session
that shows up under the display manager session menu.


%prep
%autosetup -n Remmina-v%{version}

%build
mkdir -p build

LDFLAGS="-Wl,-z,relro -Wl,--no-as-needed"

%cmake --build=build \
  -DCMAKE_INSTALL_LIBDIR=%{_lib} \
  -DCMAKE_INSTALL_PREFIX=%{_prefix} \
  -DWITH_APPINDICATOR=NO \
  -DWITH_AVAHI=ON \
  -DWITH_FREERDP=ON \
  -DWITH_GCRYPT=ON \
  -DWITH_GETTEXT=ON \
  -DWITH_LIBSSH=ON \
  -DWITH_PTHREAD=ON \
  -DWITH_LIBSSH=ON \
%if %{with telepathy}
  -DWITH_TELEPATHY=ON \
%endif
  -DWITH_VTE=ON \
  -DWITH_ZLIB=ON \
  -DWITH_GETTEXT=ON \
  -LIBVNCSERVER_INCLUDE_DIRS=%{_includedir} \
  .

make %{?_smp_mflags}

%install
rm -rf %{buildroot}
# make install DESTDIR=%{buildroot}
%makeinstall DESTDIR=%{buildroot}

mkdir -p %{buildroot}/%{_libdir}/cmake/%{name}/
cp -pr cmake/*.cmake %{buildroot}/%{_libdir}/cmake/%{name}/
cp -pr config.h.in %{buildroot}/%{_includedir}/%{name}/
cp -p %{SOURCE1} %{buildroot}/%{_includedir}/%{name}/

%find_lang %{name}

%clean
rm -rf $RPM_BUILD_ROOT

%post
update-desktop-database -q
touch --no-create %{_datadir}/icons/hicolor
if [ -x /usr/bin/gtk-update-icon-cache ]; then
  gtk-update-icon-cache -q %{_datadir}/icons/hicolor &>/dev/null ||:
fi

%postun
update-desktop-database -q
touch --no-create %{_datadir}/icons/hicolor
if [ -x /usr/bin/gtk-update-icon-cache ]; then
  gtk-update-icon-cache -q %{_datadir}/icons/hicolor &>/dev/null ||:
fi

%posttrans
if [ -x /usr/bin/gtk-update-icon-cache ]; then
  gtk-update-icon-cache -q %{_datadir}/icons/hicolor &>/dev/null ||:
fi

%files -f %{name}.lang
%defattr(-,root,root,-)
%license LICENSE
%doc AUTHORS ChangeLog README.md
%{_bindir}/%{name}
%{_bindir}/%{name}-file-wrapper
%{_datadir}/metainfo/*.appdata.xml
%{_datadir}/applications/*.desktop
%{_datadir}/icons/hicolor/*/actions/*.*
%{_datadir}/icons/hicolor/*/apps/*.*
%{_datadir}/icons/hicolor/*/emblems/remmina-*.svg
%{_datadir}/icons/hicolor/apps/*.*
%{_datadir}/icons/hicolor/scalable/panel/remmina-*.svg
%{_datadir}/mime/packages/*.xml
%{_datadir}/%{name}/
%dir %{_libdir}/remmina/
%dir %{_libdir}/remmina/plugins/
%{_mandir}/man1/%{name}.*
%{_mandir}/man1/%{name}-file-wrapper.*

%files devel
%defattr(-,root,root,-)
%doc
%{_includedir}/%{name}/
%{_libdir}/pkgconfig/%{name}.pc
%{_libdir}/cmake/%{name}/*.cmake

%files plugins-exec
%{_libdir}/remmina/plugins/remmina-plugin-exec.so

%files plugins-secret
%defattr(-,root,root,-)
%{_libdir}/remmina/plugins/remmina-plugin-secret.so

%files plugins-nx
%defattr(-,root,root,-)
%{_libdir}/remmina/plugins/remmina-plugin-nx.so
%{_datadir}/icons/hicolor/*/emblems/remmina-nx-symbolic.svg

%files plugins-rdp
%defattr(-,root,root,-)
%{_libdir}/remmina/plugins/remmina-plugin-rdp.so
%{_datadir}/icons/hicolor/*/emblems/remmina-rdp-ssh-symbolic.svg
%{_datadir}/icons/hicolor/*/emblems/remmina-rdp-symbolic.svg

%if %{with telepathy}
%files plugins-telepathy
%defattr(-,root,root,-)
%{_libdir}/remmina/plugins/remmina-plugin-telepathy.so
%{_datadir}/dbus-1/services/org.freedesktop.Telepathy.Client.Remmina.service
%{_datadir}/telepathy/clients/Remmina.client
%endif

%files plugins-st
%{_libdir}/remmina/plugins/remmina-plugin-st.so
%{_datadir}/icons/hicolor/*/emblems/remmina-tool-symbolic.svg

%files plugins-vnc
%defattr(-,root,root,-)
%{_libdir}/remmina/plugins/remmina-plugin-vnc.so
%{_datadir}/icons/hicolor/*/emblems/remmina-vnc-ssh-symbolic.svg
%{_datadir}/icons/hicolor/*/emblems/remmina-vnc-symbolic.svg

%files plugins-xdmcp
%defattr(-,root,root,-)
%{_libdir}/remmina/plugins/remmina-plugin-xdmcp.so
%{_datadir}/icons/hicolor/*/emblems/remmina-xdmcp-ssh-symbolic.svg
%{_datadir}/icons/hicolor/*/emblems/remmina-xdmcp-symbolic.svg

%files gnome-session
%{_bindir}/gnome-session-remmina
%{_bindir}/remmina-gnome
%{_datadir}/gnome-session/sessions/remmina-gnome.session
%{_datadir}/xsessions/remmina-gnome.desktop
%{_mandir}/man1/gnome-session-remmina.1.*
%{_mandir}/man1/remmina-gnome.1.*

%changelog
* Sat May 16 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.4.3-1
- new upstream release.

* Sun Dec 02 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.2.32.1-1
- new upstream release.
- dropped all patches.
- dropped Source10.
- added Source1.
- droped a subpackage 'remmina-plugins-common'.
- renamed a subpackage 'remmina-plugins-gnome' to 'remmina-plugins-secret'.
- added subpackages 'remmina-{plugins-{exec,st},gnome-session}'.

* Fri Feb 26 2016 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 1.0.0-5
- rebuild with libssh 0.7.3

* Wed Dec 30 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.0.0-4
- rebuild with gnutls-3.4.7

* Sun Jul 19 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.0.0-3
- change BuildRequires: vte3-devel  instead of vte290-devel
- add Pach100 (remmina-1.0.0-vte3.patch)

* Mon Jan 12 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 1.0.0-2
- rebuilt with libgcrypt 1.6.0 and gnutls 3.2.20
- modified BR: vte290-devel instead of vte3-devel
- moved to User Interface/Desktops Group

* Fri Oct 19 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 1.0.0-1
- Update to 1.0.0
- add BuildRequires
- add patches from fedora package (upstream patches)
- add subpackage for plugins

* Thu Aug 18 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.9.3-1
- new upstream release
- add BuildRequires: avahi-ui-devel, vte-devel, unique-devel, desktop-file-utils
- create devel sub package

* Wed Mar 17 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 0.7.4-1
- new upstream release with new name 'remmina'
- add Obsoletes/Provides: grdc

* Tue Sep 15 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.6.0-1
- initial build for Vine Linux

* Tue Jul 07 2009 slick50 <lxgator@gmail.com> 0.6.0-1pclos2009 
- new version 0.6.0

* Sun May 17 2009 don_crissti <don_crissti@gmx.com> 0.5.1-1pclos2009
- build for PCLOS

