Name: sipwitchqt
Version: 0.3.0
Release: 1
Summary: Sip server system daemon

License: GPLv3+
URL:     https://gitlab.com/tychosoft/sipwitchqt
Source0: https:///pub.cherokeesofidaho.org/tarballs/%{name}-%{version}.tar.gz
Group:	 system/telephony

BuildRequires: cmake >= 3.1.0, openssl-devel >= 1.1.0
BuildRequires: qt5-qtbase-devel, qt5-linguist, gcc-c++
BuildRequires: gperftools-devel, systemd-devel, avahi-devel

%package server
Recommends: qt5-qtbase-mysql
Summary: A pbx and messaging server for the SIP protocol.
Requires(post): systemd									
Requires(preun): systemd								
Requires(postun): systemd

%package utils
Requires: ruby
Summary: Utility scripts and commands

%package local
Requires: rubygem-sqlite3, sipwitchqt-server, sipwitchqt-utils
Summary: Complete local sipwitchqt server with sqlite database

%package desktop
Summary: A SIP messaging desktop client

%description
A pbx server and desktop client for the sip protocol

%description server
A sip server that focuses on reliable delivery of and support for persistent
messaging.  The server also tries to maintain inter-operation with existing
SIP softphones and devices.  Features like calling, video, and a security
model will also be added in the future.

%description utils
Extra utility commands and scripts to use with sipwitchqt.  This may be 
used stand-alone to initialize mysql databases for sipwitchqt servers.  
This also includes sqlite3 local db administration support for use with
a server setup with sqlite.

%description desktop
A desktop client specifically adapted for use with a SipWitchQt server.
This includes support for persistent messaging over SIP, as well as
automatic management of the server's roster, and the ability to
administer a sipwitch server directly from the client.  In the future
this will include sip calling, video, and a session based security model.

%description local
Self contained SIP server that bundles sipwitchqt with a local sqlite
database and essential supporting utilities to manipulate the database
from the command line.

%prep
%setup -q

%build
%cmake  \
		-DCMAKE_INSTALL_SYSCONFDIR=%{_sysconfdir} \
        -DCMAKE_INSTALL_LOCALSTATEDIR=%{_localstatedir}

%{__make} %{?_smp_mflags}

%install
%make_install

%post server
systemctl preset sipwitchd.service

%preun server
systemctl --no-reload disable sipwitchd.service
systemctl stop sipwitchd.service

%postun server
systemctl daemon-reload

%files server
%defattr(-,root,root)
%doc README.md DOCKER.md CONTRIBUTING.md LICENSE CHANGELOG
%{_sbindir}/sipwitchqt-server
%{_sysconfdir}/sv/sipwitchqt/run
%attr(0660,root,root) %config(noreplace) %{_sysconfdir}/default/sipwitchqt
%attr(0660,root,root) %config(noreplace) %{_sysconfdir}/sipwitchqt.conf
%attr(0664,root,root) %{_prefix}/lib/systemd/system/sipwitchd.service
%attr(0750,root,root) %{_prefix}/lib/systemd/system-sleep/sipwqt-sleep.sh
%{_mandir}/man1/sipwitchqt-server.*

%files utils
%defattr(-,root,root)
%{_sbindir}/ipl-*
%{_sbindir}/swcert-*
%{_mandir}/man1/swcert-*
%{_mandir}/man1/ipl-*
%{_datadir}/schemas/*.sql

%files local
%defattr(-,root,root)
%{_sbindir}/swlite-*
%{_mandir}/man1/swlite-*

%files desktop
%defattr(-,root,root)
%{_bindir}/sipwitchqt-desktop
%{_datadir}/applications/sipwitchqt.desktop
%{_datadir}/translations/*.qm
%{_datadir}/metainfo/sipwitchqt.appdata.xml
%{_datadir}/pixmaps/sipwitchqt.png
%{_mandir}/man1/sipwitchqt-desktop.*