palm-client: tap and hold a DM on Home for Contact Info, Reset Path, Remove Contact

The contact screen's Reset Path and Remove become ContactResetPath/ContactRemove
for any contact. Unknown senders fall back to a tap. The popup now flips above
the row against the list's bottom, not the row's (it always opened below).
This commit is contained in:
rich committed 2026-11-03 11:23:08 -05:00
1 parent a11d20bfe0
commit 9cca51a8dd
3 files changed
+109 -41

No files matched your search

+43 -22
View File
@@ -34,6 +34,7 @@ static void Status(const Char *text) VM_SECT3;
static Boolean Login(FormType *form) VM_SECT3;
static void OpenConversation(void) VM_SECT3;
static Boolean ReloadContact(void) VM_SECT3;
static Boolean Connected(void) VM_SECT3;
static void More(FormType *form) VM_SECT3;
static void ShowButtons(FormType *form) VM_SECT3;
static Boolean Add(FormType *form) VM_SECT3;
@@ -222,19 +223,51 @@ static Boolean ReloadContact(void)
return ContactsFindByPrefixN(gContact.pubKey, VM_PUB_KEY_SIZE, &gContact);
}
static Boolean Connected(void)
{
if (SessionIsConnected())
return true;
Error("Connect to the radio first (Node).");
return false;
}
void ContactResetPath(const VmContact *c)
{
Err err;
if (!Connected())
return;
err = SessionKeyCommand(VM_CMD_RESET_PATH, c->pubKey);
if (err == errNone)
err = ContactsRefresh(NULL);
if (err != errNone)
ErrorFor(err);
}
Boolean ContactRemove(const VmContact *c)
{
Err err;
if (!Connected() || FrmCustomAlert(RemoveContactAlert, c->name, "", "") != 0)
return false;
err = SessionKeyCommand(VM_CMD_REMOVE_CONTACT, c->pubKey);
if (err == errNone)
err = ContactsRefresh(NULL);
if (err != errNone) {
ErrorFor(err);
return false;
}
return true;
}
static void More(FormType *form)
{
ListType *list = GetObject(form, ContactMoreList);
Int16 pick = LstPopupList(list);
Err err;
if (pick < 0)
return;
if (!SessionIsConnected()) {
Error("Connect to the radio first (Node).");
return;
}
if (pick == 0) { /* Admin Console */
if (!Connected())
return;
if (gContact.type != VM_ADV_TYPE_ROOM && gContact.type != VM_ADV_TYPE_REPEATER) {
Error("Only repeaters and rooms have an admin console.");
return;
@@ -242,24 +275,12 @@ static void More(FormType *form)
if (SessionIsLoggedIn(gContact.pubKey) || Login(form))
RemoteOpen(&gContact);
} else if (pick == 1) { /* Reset Path */
err = SessionKeyCommand(VM_CMD_RESET_PATH, gContact.pubKey);
if (err == errNone)
err = ContactsRefresh(NULL);
if (err != errNone)
ErrorFor(err);
ContactResetPath(&gContact);
ReloadContact();
RowListDraw(&gList);
} else if (pick == 2) { /* Remove */
if (FrmCustomAlert(RemoveContactAlert, gContact.name, "", "") != 0)
return;
err = SessionKeyCommand(VM_CMD_REMOVE_CONTACT, gContact.pubKey);
if (err == errNone)
err = ContactsRefresh(NULL);
if (err != errNone) {
ErrorFor(err);
return;
}
FrmGotoForm(ContactsForm);
if (ContactRemove(&gContact))
FrmGotoForm(ContactsForm);
}
}
+5
View File
@@ -10,4 +10,9 @@ void ContactFormOpen(const VmContact *c) VM_SECT3;
Boolean ContactFormHandleEvent(EventType *event) VM_SECT3;
Boolean ContactAddFormHandleEvent(EventType *event) VM_SECT3;
/* The More actions, for any contact (also Home's tap-and-hold); errors show in an alert. */
void ContactResetPath(const VmContact *c) VM_SECT3;
/* Asks first; true if it was removed. */
Boolean ContactRemove(const VmContact *c) VM_SECT3;
#endif
+61 -19
View File
@@ -2,7 +2,8 @@
* Home: the conversation list, MeshTerm's chat picker. Channels in slot
* order, then direct conversations (most recent first). Each row: marker,
* name, unread badge or failed mark, age, preview. Tap to open; tap and hold
* a channel for its actions (mute, scope, leave).
* for a channel's actions (mute, scope, leave) or a contact's (info, reset
* path, remove).
*/
#include <PalmOS.h>
#include "resources.h"
@@ -16,6 +17,8 @@
#include "mutes.h"
#include "scopes.h"
#include "channel_form.h"
#include "contacts.h"
#include "contact_form.h"
/* In the second code segment: see sections.h for the rules. */
static void DrawRow(UInt16 row, const RectangleType *b, void *ctx) VM_SECT2;
@@ -24,6 +27,9 @@ static void DrawTitleStatus(void) VM_SECT2;
static void ShowStatus(const Char *text) VM_SECT2;
static void TitleRight(const Char *text) VM_SECT2;
static void Rebuild(Boolean draw) VM_SECT2;
static Int16 PopupActions(const RectangleType *b, Char **items) VM_SECT2;
static Boolean HoldChannel(const VmConvRow *r, const RectangleType *b) VM_SECT2;
static Boolean HoldDirect(const VmConvRow *r, const RectangleType *b) VM_SECT2;
static Boolean Hold(UInt16 row, const RectangleType *b, void *ctx) VM_SECT2;
#define HOME_MAX_ROWS 64
@@ -74,32 +80,33 @@ static void DrawRow(UInt16 row, const RectangleType *b, void *ctx)
#define HOLD_LIST_X 28
#define HOLD_LIST_H (HOLD_ITEMS * 11 + 2) /* stdFont rows and the frame */
/* Tap and hold on a channel: a popup of its actions beside the row. DMs open as a tap. */
static Boolean Hold(UInt16 row, const RectangleType *b, void *ctx)
/* Shows the popup beside the row (below it, or above near the bottom of the list); returns the pick. */
static Int16 PopupActions(const RectangleType *b, Char **items)
{
const VmConvRow *r = &gRows[row];
FormType *form = FrmGetActiveForm();
ListType *list;
Char *items[HOLD_ITEMS];
Coord y;
UInt8 slot;
ListType *list = FrmGetObjectPtr(form, FrmGetObjectIndex(form, HomeActionList));
RectangleType area;
Coord y = b->topLeft.y + b->extent.y;
if (r->kind != VM_ROW_CONV || r->conv.type != VM_CONV_CHANNEL)
return false;
slot = r->conv.channel;
items[0] = r->muted ? "Unmute" : "Mute";
items[1] = "Channel Scope...";
items[2] = "Leave Channel";
/* below the row, or above it near the bottom of the list */
y = b->topLeft.y + b->extent.y;
if (y + HOLD_LIST_H > b->topLeft.y + RowListVisibleRows(&gList) * gList.rowH)
FrmGetObjectBounds(form, FrmGetObjectIndex(form, HomeGadget), &area);
if (y + HOLD_LIST_H > area.topLeft.y + area.extent.y)
y = b->topLeft.y - HOLD_LIST_H;
list = FrmGetObjectPtr(form, FrmGetObjectIndex(form, HomeActionList));
LstSetListChoices(list, items, HOLD_ITEMS);
LstSetHeight(list, HOLD_ITEMS);
LstSetPosition(list, HOLD_LIST_X, y);
LstSetSelection(list, noListSelection);
switch (LstPopupList(list)) {
return LstPopupList(list);
}
static Boolean HoldChannel(const VmConvRow *r, const RectangleType *b)
{
Char *items[HOLD_ITEMS];
UInt8 slot = r->conv.channel;
items[0] = r->muted ? "Unmute" : "Mute";
items[1] = "Channel Scope...";
items[2] = "Leave Channel";
switch (PopupActions(b, items)) {
case 0:
ChannelMuteToggle(slot);
Rebuild(true);
@@ -114,6 +121,41 @@ static Boolean Hold(UInt16 row, const RectangleType *b, void *ctx)
return true;
}
/* A sender we have no contact for has nothing to act on: that hold is a tap. */
static Boolean HoldDirect(const VmConvRow *r, const RectangleType *b)
{
Char *items[HOLD_ITEMS];
VmContact c;
if (!ContactsFindByPrefix(r->conv.key, &c))
return false;
items[0] = "Contact Info";
items[1] = "Reset Path";
items[2] = "Remove Contact";
switch (PopupActions(b, items)) {
case 0:
ContactFormOpen(&c);
break;
case 1:
ContactResetPath(&c);
break;
case 2:
if (ContactRemove(&c))
Rebuild(true);
break;
}
return true;
}
static Boolean Hold(UInt16 row, const RectangleType *b, void *ctx)
{
const VmConvRow *r = &gRows[row];
if (r->kind != VM_ROW_CONV)
return false;
return r->conv.type == VM_CONV_CHANNEL ? HoldChannel(r, b) : HoldDirect(r, b);
}
static Boolean Selectable(UInt16 row, void *ctx)
{
return gRows[row].kind == VM_ROW_CONV;