#!/bin/sh
#
#    Copyright (C) 2022  Luis Guzmán <ark@switnet.org>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
#

VERSION=2
. ./config

#Replace name & paths.
rpl -R '/.thunderbird' '/.icedove' .
rpl -R 'Mozilla Thunderbird' 'Icedove Mail' .
rpl -R 'Thunderbirda' 'Icedove' src/translations
rpl -R 'Thunderbird' 'Icedove' src/translations \
                               contrib \
                               debian \
                               CMakeLists.txt \
                               README.md
rpl -R ' Thunderbird' ' Icedove' src/
rpl -R 'thunderbird' 'icedove' debian/
sed -i '/bindir/s|thunderbird|icedove|' $(find . -name birdtray.spec)
sed -i 's|Thunderbird|Icedove|g' $(find . -name com.ulduzsoft.Birdtray.desktop)
sed -i '/return/s|Thunderbird|Icedove|g' src/utils.cpp
sed -i '/return/s|thunderbird|icedove|g' src/utils.cpp
sed -si '/string/s|Thunderbird|Icedove|g' src/*.ui

#Replace icons
cp -r $DATA/* src/res/

#Set path
cat << EOF | patch -p0
--- src/utils.cpp	2022-09-08 03:46:23.713263610 -0500
+++ src/utils.cpp_fix	2022-09-08 03:48:19.925695988 -0500
@@ -195,13 +195,7 @@
 }
 
 QStringList Utils::getDefaultThunderbirdCommand() {
-#if defined (OPT_THUNDERBIRD_CMDLINE)
-    return Utils::splitCommandLine( OPT_THUNDERBIRD_CMDLINE );
-#elif defined (Q_OS_WIN)
-    return {R"("%ProgramFiles(x86)%\Icedove Mail\icedove.exe")"};
-#else
     return { "/usr/bin/icedove" };
-#endif
 }
 
 QStringList Utils::splitCommandLine(const QString &src)
EOF

changelog "Customization for Icedove."
compile
