%define tar_ver 4.4

Summary: Multimedia framework api
Summary(ja): マルチメディアフレームワーク API
Name: phonon
Version: 4.4.0
Release: 1%{?_dist_release}
Group: System Environment/Libraries
License: LGPLv2+
URL: http://phonon.kde.org/
Source0: ftp://ftp.kde.org/pub/kde/stable/phonon/4.4.0/phonon-%{version}.tgz

Source10: http://gstreamer.freedesktop.org/data/images/artwork/gstreamer-logo.svg
Source11: hi16-phonon-gstreamer.png
Source12: hi22-phonon-gstreamer.png
Source13: hi32-phonon-gstreamer.png
Source14: hi48-phonon-gstreamer.png
Source15: hi64-phonon-gstreamer.png
Source16: hi128-phonon-gstreamer.png

## Mandriva/upstreamable patches
Patch51: phonon-4.3.50-fix-decodebin-usage.patch
Patch52: phonon-4.3.50-gstreamer-fix-seekable-query-failed.patch
Patch53: phonon-4.3.50-phonon-allow-stop-empty-source.patch
Patch57: phonon-4.3.80-pulse-devicemove-rejig.patch

## Upstream patches

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: automoc4 >= 0.9.86
BuildRequires: cmake >= 2.6.2
BuildRequires: glib2-devel
BuildRequires: gstreamer-devel
BuildRequires: gstreamer-plugins-base-devel
BuildRequires: libxcb-devel
BuildRequires: libxml2-devel
BuildRequires: qt4-devel >= 4.4.0
BuildRequires: xine-lib-devel
BuildRequires: pulseaudio-libs-devel 

Requires: phonon-backend >= %{version}
Requires: qt4 >= 4.4.0

%description
Phonon is a cross-platform portable Multimedia Support Abstraction,
which allows you to play multiple audio or video formats with the same
quality on all platforms, no matter which underlying architecture is
used.

%package backend-gstreamer
Summary: Gstreamer phonon backend
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release}
Requires: gstreamer-plugins-good
Obsoletes: %{name}-backend-gst < 4.2.0-4
Provides:  %{name}-backend-gst = %{version}-%{release}
Provides: phonon-backend = %{version}-%{release}

%description backend-gstreamer
%{summary}.

%package backend-xine
Summary: xine phonon backend
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release}
Provides: phonon-backend = %{version}-%{release}

%description backend-xine
%{summary}.

%package devel
Summary: Development files for phonon
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: qt4-devel >= 4.4.0

%description devel
Header files for developing applications using phonon

%prep
%setup -q -n %{name}-%{tar_ver}

%patch51 -p0 -b .fix-decodebin-usage
%patch52 -p1 -b .gstreamer-fix-seekable-query-failed
%patch53 -p1 -b .phonon-allow-stop-empty-source
%patch57 -p1 -b .pulse-devicemove-rejig


%build
%ifarch x86_64
PATH="$PATH:`/usr/bin/pkg-config --variable=bindir Qt`"
%endif

mkdir -p %{_target_platform}
pushd %{_target_platform}
unset QTDIR || : ; . /etc/profile.d/qt4.sh
%cmake \
    -DUSE_INSTALL_PLUGIN=TRUE \
    ..
popd

make %{?_smp_mflags} -C %{_target_platform}

%install
rm -rf $RPM_BUILD_ROOT
make install/fast DESTDIR=$RPM_BUILD_ROOT -C %{_target_platform}

# symlink for qt/phonon compatibility
ln -s ../KDE/Phonon $RPM_BUILD_ROOT%{_includedir}/phonon/Phonon

# move the oxygen-only phonon-xine icons to hicolor
test -d $RPM_BUILD_ROOT%{_datadir}/icons/hicolor && exit 0
mv $RPM_BUILD_ROOT%{_datadir}/icons/oxygen \
   $RPM_BUILD_ROOT%{_datadir}/icons/hicolor

# gstreamer icons
install -D -m 0644 %{SOURCE10} $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/scalable/apps/phonon-gstreamer.svg
install -D -m 0644 %{SOURCE11} $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/16x16/apps/phonon-gstreamer.png
install -D -m 0644 %{SOURCE12} $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/22x22/apps/phonon-gstreamer.png
install -D -m 0644 %{SOURCE13} $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/32x32/apps/phonon-gstreamer.png
install -D -m 0644 %{SOURCE14} $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/48x48/apps/phonon-gstreamer.png
install -D -m 0644 %{SOURCE15} $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/64x64/apps/phonon-gstreamer.png
install -D -m 0644 %{SOURCE16} $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/128x128/apps/phonon-gstreamer.png

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%posttrans backend-gstreamer
gtk-update-icon-cache %{_datadir}/icons/hicolor &> /dev/null ||:

%posttrans backend-xine
gtk-update-icon-cache %{_datadir}/icons/hicolor &> /dev/null ||:

%postun backend-gstreamer
if [ $1 -eq 0 ] ; then
  gtk-update-icon-cache %{_datadir}/icons/hicolor &> /dev/null ||:
fi

%postun backend-xine
if [ $1 -eq 0 ] ; then
  gtk-update-icon-cache %{_datadir}/icons/hicolor &> /dev/null ||:
fi

%files
%defattr(-,root,root)
%doc COPYING.LIB
%{_libdir}/*.so.*
%{_datadir}/dbus-1/interfaces/*
# kde4-specific dirs
%dir %{_libdir}/kde4/plugins/phonon_backend
%dir %{_datadir}/kde4/services/phononbackends

%files backend-gstreamer
%defattr(-,root,root,-)
%{_libdir}/kde4/plugins/phonon_backend/phonon_gstreamer.so
%{_datadir}/kde4/services/phononbackends/gstreamer.desktop
%{_datadir}/icons/hicolor/*/apps/phonon-gstreamer.*

%files backend-xine
%defattr(-,root,root,-)
%{_libdir}/kde4/plugins/phonon_backend/phonon_xine.so
%{_datadir}/kde4/services/phononbackends/xine.desktop
%{_datadir}/icons/hicolor/*/apps/phonon-xine.*

%files devel
%defattr(-,root,root)
%dir %{_includedir}/KDE
%{_includedir}/KDE/Phonon/
%{_includedir}/phonon/
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc

%changelog
* Sat Mar 14 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.4.0-1
- new upstream release
- dropt Patch1, 50, 54 and 100
- added Patch57
  * Fri Jan 22 2010 Rex Dieter <rdieter@fedoraproject.org> - 4.3.80-5.2
  - F11: patch/modularize pa device-manager bits 

* Sun Feb 14 2010 Shu KONNO <owa@bg.wakwak.com> 4.3.80-2
- added qmake path to PATH (if x86_64)

* Sat Feb 13 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.3.80-1
- new upstream release
- built with new toolchain

* Sat Aug 29 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.3.1-3
- added Patch102 and 103 from FC
  * Thu Jun 18 2009 Rex Dieter <rdieter@fedoraproject.org> - 4.3.1-11
  - fix for '#' in filenames
  * Fri Jun 05 2009 Kevin Kofler <Kevin@tigcc.ticalc.org> - 4.3.1-8
  - restore patches to the xine backend

* Fri Aug 14 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.3.1-2
- added Patch100 and 101 from FC
  * Tue Mar  3 2009 Lukáš Tinkl <ltinkl@redhat.com> - 4.3.1-2
  - backport GStreamer backend bugfixes (UTF-8 file handling, volume fader)
- added backend sub-pakcages

* Thu Mar 26 2009 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.3.1-1
- new upstream release
- add BuildPrereq: cmake

* Sat Jan 24 2009 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.3.0-1
- new upstream release

* Wed Jan 14 2009 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.2.96-1
- new upstream release
- update %%files
- add BuildPrereq: xine-lib-devel libxcb-devel

* Wed Nov 26 2008 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.2.80-1
- new upstream release

* Thu Oct 09 2008 Shu KONNO <owa@bg.wakwak.com> 4.2.0-2
- added script to append qmake path
- added option -DLIB_INSTALL_DIR at cmake

* Tue Oct  7 2008 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.2.0-1
- initial release for VineSeed
