Add Gambatte GB/GBC emulator, Call/SMS anti-spam blocklist, and Lua/bc/dc/Yabasic
This commit is contained in:
1 parent
b7f0dc08c9
commit
6db14be799
113 files changed
+20006
-237
No files matched your search
+315
-36
@@ -28,6 +28,8 @@ enum class ViewMode {
|
||||
PickContact = 3,
|
||||
Options = 4,
|
||||
ConfirmDelete = 5,
|
||||
Blocklist = 6,
|
||||
AddBlock = 7,
|
||||
};
|
||||
|
||||
enum class TextCaseMode {
|
||||
@@ -171,6 +173,9 @@ int runSmsApp(int argc, char** argv) {
|
||||
auto& colRed = pt.colRed;
|
||||
|
||||
ContactBook book;
|
||||
BlockList blockList;
|
||||
std::vector<SmsThread> inboxThreads;
|
||||
std::vector<SmsThread> spamThreads;
|
||||
std::vector<SmsThread> allThreads;
|
||||
std::vector<SmsThread> filteredThreads;
|
||||
std::vector<SmsMessage> threadMessages;
|
||||
@@ -178,7 +183,10 @@ int runSmsApp(int argc, char** argv) {
|
||||
|
||||
FileStamp contactsStamp;
|
||||
FileStamp modemLogStamp;
|
||||
FileStamp blockFileStamp;
|
||||
FileStamp blockLogStamp;
|
||||
bool loadedOnce = false;
|
||||
bool viewingSpamFolder = false;
|
||||
|
||||
ViewMode mode = ViewMode::Threads;
|
||||
ViewMode prevMode = ViewMode::Threads;
|
||||
@@ -188,6 +196,8 @@ int runSmsApp(int argc, char** argv) {
|
||||
int selectedOption = 0;
|
||||
int selectedPicker = 0;
|
||||
int confirmSelected = 0;
|
||||
int blockSelected = 0;
|
||||
std::string addBlockInput;
|
||||
|
||||
std::string activeNumber;
|
||||
std::string composeRecipient;
|
||||
@@ -216,10 +226,15 @@ int runSmsApp(int argc, char** argv) {
|
||||
int id;
|
||||
std::string icon;
|
||||
std::string label;
|
||||
bool danger = false;
|
||||
};
|
||||
std::vector<OptionEntry> optionsList;
|
||||
|
||||
auto updateFilter = [&]() {
|
||||
allThreads = viewingSpamFolder ? spamThreads : inboxThreads;
|
||||
for (auto& t : allThreads) {
|
||||
t.isBlocked = viewingSpamFolder || blockList.isBlocked(t.number);
|
||||
}
|
||||
filteredThreads.clear();
|
||||
if (searchQuery.empty()) {
|
||||
filteredThreads = allThreads;
|
||||
@@ -247,13 +262,22 @@ int runSmsApp(int argc, char** argv) {
|
||||
auto reloadAllData = [&](bool force = false) {
|
||||
bool cChanged = contactsStamp.checkAndUpdate(getContactsFilePath());
|
||||
bool lChanged = modemLogStamp.checkAndUpdate(getModemLogFilePath());
|
||||
if (force || cChanged || lChanged || !loadedOnce) {
|
||||
bool bChanged = blockFileStamp.checkAndUpdate(getBlockFilePath());
|
||||
bool blChanged = blockLogStamp.checkAndUpdate(getBlockedModemLogFilePath());
|
||||
if (force || cChanged || lChanged || bChanged || blChanged || !loadedOnce) {
|
||||
loadedOnce = true;
|
||||
book.load();
|
||||
allThreads = loadSmsThreads(book);
|
||||
blockList.load();
|
||||
inboxThreads = loadSmsThreads(book, getModemLogDirPath());
|
||||
spamThreads = loadSmsThreads(book, getBlockDirPath());
|
||||
updateFilter();
|
||||
if (blockSelected >= static_cast<int>(blockList.entries().size())) {
|
||||
blockSelected = std::max(0, static_cast<int>(blockList.entries().size()) - 1);
|
||||
}
|
||||
if (!activeNumber.empty()) {
|
||||
threadMessages = loadSmsThreadMessages(activeNumber);
|
||||
std::string curBase =
|
||||
viewingSpamFolder ? getBlockDirPath() : getModemLogDirPath();
|
||||
threadMessages = loadSmsThreadMessages(activeNumber, curBase);
|
||||
if (selectedMsg >= static_cast<int>(threadMessages.size())) {
|
||||
selectedMsg =
|
||||
std::max(0, static_cast<int>(threadMessages.size()) - 1);
|
||||
@@ -266,7 +290,9 @@ int runSmsApp(int argc, char** argv) {
|
||||
|
||||
auto openThreadView = [&](const std::string& num) {
|
||||
activeNumber = trimStr(num);
|
||||
threadMessages = loadSmsThreadMessages(activeNumber);
|
||||
std::string curBase =
|
||||
viewingSpamFolder ? getBlockDirPath() : getModemLogDirPath();
|
||||
threadMessages = loadSmsThreadMessages(activeNumber, curBase);
|
||||
selectedMsg = std::max(0, static_cast<int>(threadMessages.size()) - 1);
|
||||
mode = ViewMode::ThreadView;
|
||||
};
|
||||
@@ -289,22 +315,55 @@ int runSmsApp(int argc, char** argv) {
|
||||
auto buildOptions = [&]() {
|
||||
optionsList.clear();
|
||||
if (mode == ViewMode::Threads) {
|
||||
optionsList.push_back({1, kIconPlus, "New Message"});
|
||||
optionsList.push_back({1, kIconPlus, "New Message", false});
|
||||
if (!filteredThreads.empty()) {
|
||||
optionsList.push_back({2, kIconEye, "Open Conversation"});
|
||||
optionsList.push_back({3, kIconSend, "Reply to Selected"});
|
||||
optionsList.push_back({4, kIconPhone, "Call Contact"});
|
||||
optionsList.push_back({5, kIconUser, "Open in Contacts"});
|
||||
optionsList.push_back({6, kIconTrash, "Delete Conversation"});
|
||||
const auto& selTh = filteredThreads[selectedThread];
|
||||
bool isBlk = blockList.isBlocked(selTh.number);
|
||||
optionsList.push_back({2, kIconEye, "Open Conversation", false});
|
||||
optionsList.push_back({3, kIconSend, "Reply to Selected", false});
|
||||
optionsList.push_back({4, kIconPhone, "Call Contact", false});
|
||||
if (isBlk || viewingSpamFolder) {
|
||||
optionsList.push_back({8, kIconCheck, "Unblock & Restore", false});
|
||||
} else {
|
||||
optionsList.push_back({8, kIconBan, "Block Number (Spam)", true});
|
||||
}
|
||||
optionsList.push_back({5, kIconUser, "Open in Contacts", false});
|
||||
optionsList.push_back({6, kIconTrash, "Delete Conversation", true});
|
||||
}
|
||||
if (viewingSpamFolder) {
|
||||
optionsList.push_back(
|
||||
{9, kIconSms,
|
||||
"Switch to Inbox (" + std::to_string(inboxThreads.size()) + ")",
|
||||
false});
|
||||
} else {
|
||||
optionsList.push_back(
|
||||
{9, kIconShield,
|
||||
"Spam Folder (" + std::to_string(spamThreads.size()) + ")",
|
||||
false});
|
||||
}
|
||||
optionsList.push_back(
|
||||
{10, kIconBan,
|
||||
"Manage Blocklist (" + std::to_string(blockList.entries().size()) + ")",
|
||||
false});
|
||||
optionsList.push_back({11, kIconPlus, "Block a Number...", false});
|
||||
} else if (mode == ViewMode::ThreadView) {
|
||||
optionsList.push_back({3, kIconSend, "Reply / Compose"});
|
||||
optionsList.push_back({4, kIconPhone, "Call Contact"});
|
||||
bool isBlk = blockList.isBlocked(activeNumber);
|
||||
optionsList.push_back({3, kIconSend, "Reply / Compose", false});
|
||||
optionsList.push_back({4, kIconPhone, "Call Contact", false});
|
||||
if (!threadMessages.empty()) {
|
||||
optionsList.push_back({7, kIconCopy, "Forward Selected Msg"});
|
||||
optionsList.push_back({7, kIconCopy, "Forward Selected Msg", false});
|
||||
}
|
||||
optionsList.push_back({5, kIconUser, "Save / View Contact"});
|
||||
optionsList.push_back({6, kIconTrash, "Delete Conversation"});
|
||||
if (isBlk || viewingSpamFolder) {
|
||||
optionsList.push_back({8, kIconCheck, "Unblock & Restore", false});
|
||||
} else {
|
||||
optionsList.push_back({8, kIconBan, "Block Number (Spam)", true});
|
||||
}
|
||||
optionsList.push_back({5, kIconUser, "Save / View Contact", false});
|
||||
optionsList.push_back({6, kIconTrash, "Delete Conversation", true});
|
||||
optionsList.push_back(
|
||||
{10, kIconBan,
|
||||
"Manage Blocklist (" + std::to_string(blockList.entries().size()) + ")",
|
||||
false});
|
||||
}
|
||||
selectedOption = 0;
|
||||
};
|
||||
@@ -462,9 +521,13 @@ int runSmsApp(int argc, char** argv) {
|
||||
XDrawLine(dpy, pix, gc, 0, 37, kWinWidth, 37);
|
||||
|
||||
if (searchQuery.empty()) {
|
||||
drawPango(layoutIcon, &colYellow, 8, 2, 34, kIconSms);
|
||||
drawPango(layoutMain, &colWhite, 30, 2, 34, "Messages", 145);
|
||||
std::string cnt = "[" + std::to_string(allThreads.size()) + "]";
|
||||
drawPango(layoutIcon, viewingSpamFolder ? &colRed : &colYellow, 8, 2,
|
||||
34, viewingSpamFolder ? kIconBan : kIconSms);
|
||||
std::string hdrTitle =
|
||||
viewingSpamFolder ? "Spam / Blocked" : "Messages";
|
||||
drawPango(layoutMain, viewingSpamFolder ? &colRed : &colWhite, 30, 2,
|
||||
34, hdrTitle, 145);
|
||||
std::string cnt = "< [" + std::to_string(allThreads.size()) + "] >";
|
||||
pango_layout_set_width(layoutSmall, -1);
|
||||
pango_layout_set_text(layoutSmall, cnt.c_str(),
|
||||
static_cast<int>(cnt.size()));
|
||||
@@ -489,9 +552,15 @@ int runSmsApp(int argc, char** argv) {
|
||||
|
||||
if (filteredThreads.empty()) {
|
||||
drawPango(layoutMain, &colMuted, 16, 110, 24,
|
||||
searchQuery.empty() ? "No messages yet" : "No matches", 208);
|
||||
searchQuery.empty()
|
||||
? (viewingSpamFolder ? "No blocked messages"
|
||||
: "No messages yet")
|
||||
: "No matches",
|
||||
208);
|
||||
drawPango(layoutSmall, &colBlue, 16, 138, 20,
|
||||
"Press Left Softkey for New SMS", 208);
|
||||
viewingSpamFolder ? "Left/Right: Switch to Inbox"
|
||||
: "Left Softkey: Options / Blocklist",
|
||||
208);
|
||||
} else {
|
||||
int scroll = 0;
|
||||
if (selectedThread >= visibleRows) {
|
||||
@@ -515,17 +584,22 @@ int runSmsApp(int argc, char** argv) {
|
||||
XFillRectangle(dpy, pix, gc, 0, ry, kWinWidth, rowH - 1);
|
||||
}
|
||||
|
||||
const char* ic = th.hasDraft
|
||||
? kIconEdit
|
||||
: (th.lastIncoming ? kIconInCall : kIconOutCall);
|
||||
XftColor* icCol = th.hasDraft
|
||||
? &colYellow
|
||||
: (th.lastIncoming ? &colGreen : &colBlue);
|
||||
const char* ic =
|
||||
th.isBlocked
|
||||
? kIconBan
|
||||
: (th.hasDraft ? kIconEdit
|
||||
: (th.lastIncoming ? kIconInCall : kIconOutCall));
|
||||
XftColor* icCol =
|
||||
th.isBlocked
|
||||
? &colRed
|
||||
: (th.hasDraft ? &colYellow
|
||||
: (th.lastIncoming ? &colGreen : &colBlue));
|
||||
drawPango(layoutIcon, icCol, 6, ry + 1, 20, ic);
|
||||
|
||||
std::string title =
|
||||
th.contactName.empty() ? th.number : th.contactName;
|
||||
drawPango(layoutMain, &colWhite, 26, ry + 1, 20, title, 128);
|
||||
drawPango(layoutMain, th.isBlocked ? &colRed : &colWhite, 26, ry + 1,
|
||||
20, title, 128);
|
||||
|
||||
if (!th.lastDisplayTime.empty()) {
|
||||
pango_layout_set_width(layoutSmall, -1);
|
||||
@@ -807,18 +881,89 @@ int runSmsApp(int argc, char** argv) {
|
||||
|
||||
const int listY = 38;
|
||||
const int rowH = 36;
|
||||
for (size_t i = 0; i < optionsList.size(); ++i) {
|
||||
int ry = listY + static_cast<int>(i) * rowH;
|
||||
bool isSel = (static_cast<int>(i) == selectedOption);
|
||||
const int visRows = 6;
|
||||
int scroll = 0;
|
||||
if (selectedOption >= visRows) {
|
||||
scroll = selectedOption - visRows + 1;
|
||||
}
|
||||
for (int i = 0; i < visRows; ++i) {
|
||||
int idx = scroll + i;
|
||||
if (idx >= static_cast<int>(optionsList.size())) break;
|
||||
int ry = listY + i * rowH;
|
||||
bool isSel = (idx == selectedOption);
|
||||
XSetForeground(dpy, gc, isSel ? pt.spec.selBg : pt.spec.bgMain);
|
||||
XFillRectangle(dpy, pix, gc, 0, ry, kWinWidth, rowH - 1);
|
||||
drawPango(layoutIcon, isSel ? &colYellow : &colBlue, 10, ry, rowH,
|
||||
optionsList[i].icon);
|
||||
drawPango(layoutMain, &colWhite, 34, ry, rowH, optionsList[i].label,
|
||||
198);
|
||||
XftColor* icCol =
|
||||
optionsList[idx].danger ? &colRed : (isSel ? &colYellow : &colBlue);
|
||||
XftColor* txCol = optionsList[idx].danger ? &colRed : &colWhite;
|
||||
drawPango(layoutIcon, icCol, 10, ry, rowH, optionsList[idx].icon);
|
||||
drawPango(layoutMain, txCol, 34, ry, rowH, optionsList[idx].label, 198);
|
||||
}
|
||||
drawSoftkeyBar("Select", "Select", "Back");
|
||||
|
||||
} else if (mode == ViewMode::Blocklist) {
|
||||
XSetForeground(dpy, gc, pt.spec.bgHeader);
|
||||
XFillRectangle(dpy, pix, gc, 0, 0, kWinWidth, 34);
|
||||
drawPango(layoutIcon, &colRed, 8, 0, 34, kIconBan);
|
||||
std::string hdr =
|
||||
"Blocklist (" + std::to_string(blockList.entries().size()) + ")";
|
||||
drawPango(layoutMain, &colWhite, 30, 0, 34, hdr, 200);
|
||||
|
||||
const auto& entries = blockList.entries();
|
||||
if (entries.empty()) {
|
||||
drawPango(layoutIcon, &colMuted, 112, 94, 24, kIconShield);
|
||||
drawPango(layoutMain, &colMuted, 44, 124, 24, "Blocklist is empty",
|
||||
180);
|
||||
drawPango(layoutSmall, &colBlue, 22, 152, 20,
|
||||
"Left Softkey: Block a Number", 204);
|
||||
} else {
|
||||
const int listY = 36;
|
||||
const int rowH = 38;
|
||||
const int visRows = 6;
|
||||
int scroll = 0;
|
||||
if (blockSelected >= visRows) {
|
||||
scroll = blockSelected - visRows + 1;
|
||||
}
|
||||
for (int i = 0; i < visRows; ++i) {
|
||||
int idx = scroll + i;
|
||||
if (idx >= static_cast<int>(entries.size())) break;
|
||||
const auto& e = entries[idx];
|
||||
int ry = listY + i * rowH;
|
||||
bool isSel = (idx == blockSelected);
|
||||
XSetForeground(dpy, gc, isSel ? pt.spec.selBg : pt.spec.bgMain);
|
||||
XFillRectangle(dpy, pix, gc, 0, ry, kWinWidth, rowH - 1);
|
||||
std::string cname = book.resolveName(e.number);
|
||||
std::string topLine = cname.empty() ? e.number : cname;
|
||||
std::string subLine =
|
||||
cname.empty() ? e.label : (e.number + " (" + e.label + ")");
|
||||
drawPango(layoutIcon, &colRed, 8, ry + 1, 20, kIconBan);
|
||||
drawPango(layoutMain, &colWhite, 28, ry + 1, 20, topLine, 204);
|
||||
drawPango(layoutSmall, isSel ? &colLight : &colMuted, 28, ry + 20, 16,
|
||||
subLine, 204);
|
||||
}
|
||||
}
|
||||
drawSoftkeyBar("Add New", entries.empty() ? "" : "Unblock", "Back");
|
||||
|
||||
} else if (mode == ViewMode::AddBlock) {
|
||||
XSetForeground(dpy, gc, pt.spec.bgHeader);
|
||||
XFillRectangle(dpy, pix, gc, 0, 0, kWinWidth, 34);
|
||||
drawPango(layoutIcon, &colRed, 8, 0, 34, kIconBan);
|
||||
drawPango(layoutMain, &colWhite, 30, 0, 34, "Block Phone Number", 200);
|
||||
|
||||
drawPango(layoutSmall, &colMuted, 12, 54, 20,
|
||||
"Enter number or prefix (e.g. +1800*):", 216);
|
||||
XSetForeground(dpy, gc, pt.spec.bgInputFocus);
|
||||
XFillRectangle(dpy, pix, gc, 12, 80, kWinWidth - 24, 34);
|
||||
XSetForeground(dpy, gc, pt.spec.accentAlt);
|
||||
XDrawRectangle(dpy, pix, gc, 12, 80, kWinWidth - 25, 33);
|
||||
std::string disp = addBlockInput + "|";
|
||||
drawPango(layoutMain, &colWhite, 18, 83, 28, disp, kWinWidth - 36);
|
||||
drawPango(layoutSmall, &colMuted, 12, 124, 20,
|
||||
"0-9 / * / #: Digits #: + prefix", 216);
|
||||
drawPango(layoutSmall, &colMuted, 12, 146, 20,
|
||||
"BackSpace/Left: Delete digit", 216);
|
||||
drawSoftkeyBar("Block", "Save", "Cancel");
|
||||
|
||||
} else if (mode == ViewMode::ConfirmDelete) {
|
||||
XSetForeground(dpy, gc, pt.spec.bgHeader);
|
||||
XFillRectangle(dpy, pix, gc, 0, 0, kWinWidth, 36);
|
||||
@@ -997,6 +1142,49 @@ int runSmsApp(int argc, char** argv) {
|
||||
} else if (optId == 7 && !threadMessages.empty()) {
|
||||
std::string body = threadMessages[selectedMsg].text;
|
||||
openComposeView("", body);
|
||||
} else if (optId == 8) {
|
||||
std::string target = (prevMode == ViewMode::ThreadView)
|
||||
? activeNumber
|
||||
: (!filteredThreads.empty()
|
||||
? filteredThreads[selectedThread].number
|
||||
: "");
|
||||
if (!target.empty()) {
|
||||
if (blockList.isBlocked(target) || viewingSpamFolder) {
|
||||
blockList.unblockNumber(target);
|
||||
moveSmsThreadBetweenDirs(target, getBlockDirPath(),
|
||||
getModemLogDirPath());
|
||||
std::lock_guard<std::mutex> lk(sendMutex);
|
||||
statusBanner = "Unblocked & restored " + target;
|
||||
statusBannerUntilMs = nowMs() + 2000;
|
||||
} else {
|
||||
std::string cname = book.resolveName(target);
|
||||
blockList.blockNumber(target, cname.empty() ? "SMS Spam" : cname);
|
||||
moveSmsThreadBetweenDirs(target, getModemLogDirPath(),
|
||||
getBlockDirPath());
|
||||
std::lock_guard<std::mutex> lk(sendMutex);
|
||||
statusBanner = "Blocked " + target;
|
||||
statusBannerUntilMs = nowMs() + 2000;
|
||||
}
|
||||
reloadAllData(true);
|
||||
}
|
||||
mode = ViewMode::Threads;
|
||||
} else if (optId == 9) {
|
||||
viewingSpamFolder = !viewingSpamFolder;
|
||||
selectedThread = 0;
|
||||
reloadAllData(true);
|
||||
mode = ViewMode::Threads;
|
||||
} else if (optId == 10) {
|
||||
blockList.load();
|
||||
blockSelected = 0;
|
||||
mode = ViewMode::Blocklist;
|
||||
} else if (optId == 11) {
|
||||
std::string target = (prevMode == ViewMode::ThreadView)
|
||||
? activeNumber
|
||||
: (!filteredThreads.empty()
|
||||
? filteredThreads[selectedThread].number
|
||||
: "");
|
||||
addBlockInput = target;
|
||||
mode = ViewMode::AddBlock;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1010,6 +1198,10 @@ int runSmsApp(int argc, char** argv) {
|
||||
if (!searchQuery.empty()) {
|
||||
popUtf8Char(searchQuery);
|
||||
updateFilter();
|
||||
} else if (viewingSpamFolder) {
|
||||
viewingSpamFolder = false;
|
||||
selectedThread = 0;
|
||||
updateFilter();
|
||||
} else {
|
||||
hideWindow();
|
||||
return;
|
||||
@@ -1066,10 +1258,40 @@ int runSmsApp(int argc, char** argv) {
|
||||
} else {
|
||||
mode = prevMode;
|
||||
}
|
||||
} else if (mode == ViewMode::Blocklist) {
|
||||
if (isLeft) {
|
||||
addBlockInput.clear();
|
||||
mode = ViewMode::AddBlock;
|
||||
} else {
|
||||
reloadAllData(true);
|
||||
mode = prevMode;
|
||||
}
|
||||
} else if (mode == ViewMode::AddBlock) {
|
||||
if (isLeft) {
|
||||
std::string num = trimStr(addBlockInput);
|
||||
if (!normalizePhone(num).empty()) {
|
||||
blockList.blockNumber(num, "SMS Blocklist");
|
||||
moveSmsThreadBetweenDirs(num, getModemLogDirPath(),
|
||||
getBlockDirPath());
|
||||
reloadAllData(true);
|
||||
std::lock_guard<std::mutex> lk(sendMutex);
|
||||
statusBanner = "Blocked " + num;
|
||||
statusBannerUntilMs = nowMs() + 2000;
|
||||
}
|
||||
mode = ViewMode::Blocklist;
|
||||
} else {
|
||||
if (!addBlockInput.empty()) {
|
||||
popUtf8Char(addBlockInput);
|
||||
} else {
|
||||
mode = ViewMode::Blocklist;
|
||||
}
|
||||
}
|
||||
} else if (mode == ViewMode::ConfirmDelete) {
|
||||
if (isLeft) {
|
||||
if (confirmSelected == 1) {
|
||||
deleteSmsThread(activeNumber);
|
||||
deleteSmsThread(activeNumber, viewingSpamFolder
|
||||
? getBlockDirPath()
|
||||
: getModemLogDirPath());
|
||||
reloadAllData(true);
|
||||
mode = ViewMode::Threads;
|
||||
} else {
|
||||
@@ -1189,7 +1411,13 @@ int runSmsApp(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if (mode == ViewMode::Threads) {
|
||||
if (sym == XK_Up || sym == XK_KP_Up) {
|
||||
if (sym == XK_Left || sym == XK_KP_Left || sym == XK_Right ||
|
||||
sym == XK_KP_Right) {
|
||||
viewingSpamFolder = !viewingSpamFolder;
|
||||
selectedThread = 0;
|
||||
updateFilter();
|
||||
drawUI();
|
||||
} else if (sym == XK_Up || sym == XK_KP_Up) {
|
||||
if (!filteredThreads.empty()) {
|
||||
selectedThread =
|
||||
(selectedThread - 1 + static_cast<int>(filteredThreads.size())) %
|
||||
@@ -1346,6 +1574,57 @@ int runSmsApp(int argc, char** argv) {
|
||||
} else if (sym == XK_Return || sym == XK_KP_Enter) {
|
||||
handleSoftkeyAction(true);
|
||||
}
|
||||
} else if (mode == ViewMode::Blocklist) {
|
||||
if (sym == XK_Up || sym == XK_KP_Up) {
|
||||
if (!blockList.entries().empty()) {
|
||||
int n = static_cast<int>(blockList.entries().size());
|
||||
blockSelected = (blockSelected + n - 1) % n;
|
||||
drawUI();
|
||||
}
|
||||
} else if (sym == XK_Down || sym == XK_KP_Down) {
|
||||
if (!blockList.entries().empty()) {
|
||||
int n = static_cast<int>(blockList.entries().size());
|
||||
blockSelected = (blockSelected + 1) % n;
|
||||
drawUI();
|
||||
}
|
||||
} else if (sym == XK_Return || sym == XK_KP_Enter) {
|
||||
if (!blockList.entries().empty() && blockSelected >= 0 &&
|
||||
blockSelected < static_cast<int>(blockList.entries().size())) {
|
||||
std::string num = blockList.entries()[blockSelected].number;
|
||||
blockList.unblockNumber(num);
|
||||
moveSmsThreadBetweenDirs(num, getBlockDirPath(),
|
||||
getModemLogDirPath());
|
||||
reloadAllData(true);
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(sendMutex);
|
||||
statusBanner = "Unblocked " + num;
|
||||
statusBannerUntilMs = nowMs() + 1800;
|
||||
}
|
||||
drawUI();
|
||||
}
|
||||
}
|
||||
} else if (mode == ViewMode::AddBlock) {
|
||||
if (sym == XK_Left || sym == XK_KP_Left) {
|
||||
if (!addBlockInput.empty()) {
|
||||
popUtf8Char(addBlockInput);
|
||||
drawUI();
|
||||
}
|
||||
} else if (sym == XK_Return || sym == XK_KP_Enter) {
|
||||
handleSoftkeyAction(true);
|
||||
} else {
|
||||
char d = mapDialKey(sym, kc, ev.xkey.state);
|
||||
if (d == '#') {
|
||||
if (addBlockInput.empty()) {
|
||||
addBlockInput.push_back('+');
|
||||
} else {
|
||||
addBlockInput.push_back('#');
|
||||
}
|
||||
drawUI();
|
||||
} else if (d != '\0') {
|
||||
addBlockInput.push_back(d);
|
||||
drawUI();
|
||||
}
|
||||
}
|
||||
} else if (mode == ViewMode::ConfirmDelete) {
|
||||
if (sym == XK_Up || sym == XK_Down || sym == XK_KP_Up ||
|
||||
sym == XK_KP_Down) {
|
||||
|
||||
Reference in new issue
Block a user