1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
/*
Copyright (C) 2024 Selwin van Dijk
This file is part of signalbackup-tools.
signalbackup-tools 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.
signalbackup-tools 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 signalbackup-tools. If not, see <https://www.gnu.org/licenses/>.
*/
#include "signalbackup.ih"
void SignalBackup::HTMLwriteMsgReceiptInfo(std::ofstream &htmloutput, std::map<long long int, RecipientInfo> *recipient_info,
long long int message_id, bool isgroup, long long int read_count, long long int delivered_count,
long long int timestamp, int indent) const
{
if (!isgroup)
{
if (read_count > 0)
htmloutput << std::string(indent, ' ') << " <div class=\"msg-receipt-info\">\n"
<< std::string(indent, ' ') << " Read" << (timestamp != -1 ?
" - " + bepaald::toDateString(timestamp / 1000, "%b %d, %Y %H:%M:%S") : "") << '\n'
<< std::string(indent, ' ') << " </div>\n";
else if (delivered_count > 0)
htmloutput << std::string(indent, ' ') << " <div class=\"msg-receipt-info\">\n"
<< std::string(indent, ' ') << " Delivered" << (timestamp != -1 ?
" - " + bepaald::toDateString(timestamp / 1000, "%b %d, %Y %H:%M:%S") : "") << '\n'
<< std::string(indent, ' ') << " </div>\n";
}
else // isgroup
{
SqliteDB::QueryResults group_receipts;
if (d_database.exec("SELECT address, status, timestamp FROM group_receipts WHERE mms_id = ? ORDER BY status DESC",
message_id, &group_receipts) &&
group_receipts.rows() > 0)
{
htmloutput << std::string(indent, ' ') << " <div class=\"msg-receipt-info\">\n"
<< std::string(indent, ' ') << " <span class=\"columnview\">\n";
long long int prevstatus = -10;
for (unsigned int i = 0; i < group_receipts.rows(); ++i)
{
long long int status = group_receipts.valueAsInt(i, "status", -10);
if (status != prevstatus)
{
switch (status)
{
case 4: // enum SKIPPED
htmloutput << std::string(indent, ' ') << " "
"<span class=\"columnview-header\">Skipped</span>\n";
break;
case 3: // enum VIEWED
htmloutput << std::string(indent, ' ') << " "
"<span class=\"columnview-header\">Viewed by</span>\n";
break;
case 2: // enum READ
htmloutput << std::string(indent, ' ') << " "
"<span class=\"columnview-header\">Read by</span>\n";
break;
case 1: // enum DELIVERED
htmloutput << std::string(indent, ' ') << " "
"<span class=\"columnview-header\">Delivered to</span>\n";
break;
case 0: // enum UNDELIVERED
htmloutput << std::string(indent, ' ') << " "
"<span class=\"columnview-header\">Sent to</span>\n"; // I think...
break;
default: // -1 // enum UNKNOWN
break;
}
prevstatus = status;
}
if (status >= 0)
htmloutput << std::string(indent, ' ') << " <span class=\"column-left-align\">"
<< HTMLescapeString(getRecipientInfoFromMap(recipient_info, group_receipts.valueAsInt(i, "address", -1)).display_name) << "</span>"
<< "<span class=\"column-right-align\">"
<< bepaald::toDateString(group_receipts.valueAsInt(i, "timestamp", -1) / 1000, "%b %d, %Y %H:%M:%S") << "</span>\n";
}
htmloutput << std::string(indent, ' ') << " </span>\n"
<< std::string(indent, ' ') << " </div>\n";
}
}
}
|