30 lines
1.2 KiB
Bash
Executable file
30 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# chatty-import-sms-mms
|
|
#
|
|
# Copyright (C) 2022 Gilles Filippini <gilles.filippini@pini.fr>
|
|
#
|
|
# 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
set -euo pipefail
|
|
|
|
database="$1"
|
|
|
|
# Saving binary files only
|
|
# .smil parts are ignored (not used by Chatty)
|
|
# Plain text attachments will be converted into message bodies
|
|
# cf. chatty:src/mm/chatty-mmsd.c:chatty_mmsd_process_mms_message_attachments
|
|
while read path; do
|
|
mkdir -p "$(dirname "$path")"
|
|
sqlite3 "$database" "select binary_data from part where savepath='$path';" | base64 -d >"$path"
|
|
done <<<"$(sqlite3 "$database" "select savepath from part where binary_data is not null;")"
|