summaryrefslogtreecommitdiff
path: root/WebMail.c
diff options
context:
space:
mode:
authorDave Hibberd <d@vehibberd.com>2023-12-28 10:31:09 +0000
committerDave Hibberd <d@vehibberd.com>2023-12-28 10:31:09 +0000
commit7a61c594e1bf9fd62e156d3d8db772fe7c4bfd03 (patch)
tree19d55bf6fcd52ce7bd67c10591c04a3cd2549b56 /WebMail.c
parent2ccd083256a3a05ae1f402a0ef259fbfff709088 (diff)
New upstream version 6.0.24.25upstream/6.0.24.25
Diffstat (limited to 'WebMail.c')
-rw-r--r--WebMail.c92
1 files changed, 64 insertions, 28 deletions
diff --git a/WebMail.c b/WebMail.c
index f626975..157938b 100644
--- a/WebMail.c
+++ b/WebMail.c
@@ -76,6 +76,8 @@ VOID SendTemplateSelectScreen(struct HTTPConnectionInfo * Session, char *URLPara
BOOL isAMPRMsg(char * Addr);
char * doXMLTransparency(char * string);
Dll BOOL APIENTRY APISendAPRSMessage(char * Text, char * ToCall);
+void SendMessageReadEvent(char * Call, struct MsgInfo * Msg);
+void SendNewMessageEvent(char * call, struct MsgInfo * Msg);
extern char NodeTail[];
extern char BBSName[10];
@@ -719,26 +721,27 @@ VOID ProcessFormDir(char * FormSet, char * DirName, struct HtmlFormDir *** xxx,
{
if (entry->d_type == DT_DIR)
{
- if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
+ char Dir[MAX_PATH];
+
+ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
continue;
- Debugprintf("Recurse %s/%s/%s", FormSet, DirName, entry->d_name);
- continue;
+ // Recurse in subdir
+
+ sprintf(Dir, "%s/%s", DirName, entry->d_name);
+ ProcessFormDir(FormSet, Dir, &FormDir->Dirs, &FormDir->DirCount);
+ continue;
}
- // see if initial html
-// if (stristr(entry->d_name, "initial.html"))
- {
- // Add to list
+ // Add to list
- Form = zalloc(sizeof (struct HtmlForm));
+ Form = zalloc(sizeof (struct HtmlForm));
- Form->FileName = _strdup(entry->d_name);
+ Form->FileName = _strdup(entry->d_name);
- FormDir->Forms=realloc(FormDir->Forms, (FormDir->FormCount + 1) * sizeof(void *));
- FormDir->Forms[FormDir->FormCount++] = Form;
- }
+ FormDir->Forms=realloc(FormDir->Forms, (FormDir->FormCount + 1) * sizeof(void *));
+ FormDir->Forms[FormDir->FormCount++] = Form;
}
closedir(dir);
#endif
@@ -808,22 +811,23 @@ int GetHTMLFormSet(char * FormSet)
if (!(dir = opendir(name)))
{
Debugprintf("cant open forms dir %s %d %d", name, errno, dir);
- return 0;
}
-
- while ((entry = readdir(dir)) != NULL)
+ else
{
- if (entry->d_type == DT_DIR)
+ while ((entry = readdir(dir)) != NULL)
{
- if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
- continue;
+ if (entry->d_type == DT_DIR)
+ {
+ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
+ continue;
- // Add to Directory List
+ // Add to Directory List
- ProcessFormDir(FormSet, entry->d_name, &HtmlFormDirs, &FormDirCount);
- }
- }
- closedir(dir);
+ ProcessFormDir(FormSet, entry->d_name, &HtmlFormDirs, &FormDirCount);
+ }
+ }
+ closedir(dir);
+ }
#endif
// List for testing
@@ -1122,7 +1126,7 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu
Msg->status = 'Y';
Msg->datechanged=time(NULL);
SaveMessageDatabase();
-
+ SendMessageReadEvent(Session->Callsign, Msg);
}
}
}
@@ -1190,6 +1194,7 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu
Msg->status = 'Y';
Msg->datechanged=time(NULL);
SaveMessageDatabase();
+ SendMessageReadEvent(Session->Callsign, Msg);
}
}
}
@@ -1303,6 +1308,7 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu
Msg->status = 'Y';
Msg->datechanged=time(NULL);
SaveMessageDatabase();
+ SendMessageReadEvent(Session->Callsign, Msg);
}
}
}
@@ -2776,11 +2782,16 @@ VOID SaveNewMessage(struct HTTPConnectionInfo * Session, char * MsgPtr, char * R
if (Msg->status != 'H' && Msg->type == 'B' && memcmp(Msg->fbbs, zeros, NBMASK) != 0)
Msg->status = '$'; // Has forwarding
+
if (EnableUI)
SendMsgUI(Msg);
user = LookupCall(Msg->to);
+ // If Event Notifications enabled report a new message event
+
+ SendNewMessageEvent(user->Call, Msg);
+
if (user && (user->flags & F_APRSMFOR))
{
char APRS[128];
@@ -2838,13 +2849,26 @@ char * GetHTMLViewerTemplate(char * FN)
{
for (l = 0; l < Dir->DirCount; l++)
{
- for (k = 0; k < Dir->Dirs[l]->FormCount; k++)
+ struct HtmlFormDir * SDir = Dir->Dirs[l];
+
+ if (SDir->DirCount)
{
- if (strcmp(FN, Dir->Dirs[l]->Forms[k]->FileName) == 0)
+ struct HtmlFormDir * SSDir = SDir->Dirs[0];
+ int x = 1;
+ }
+
+ for (k = 0; k < SDir->FormCount; k++)
+ {
+ if (_stricmp(FN, SDir->Forms[k]->FileName) == 0)
{
- return CheckFile(Dir, Dir->Dirs[l]->Forms[k]->FileName);
+ return CheckFile(SDir, SDir->Forms[k]->FileName);
}
}
+ if (SDir->DirCount)
+ {
+ struct HtmlFormDir * SSDir = SDir->Dirs[0];
+ int x = 1;
+ }
}
}
}
@@ -3224,7 +3248,7 @@ BOOL ParseXML(WebMailInfo * WebMail, char * XMLOrig)
*ptr2++ = 0;
- ptr3 = strchr(ptr2, '<'); // end of value string
+ ptr3 = strstr(ptr2, "</"); // end of value string
if (ptr3 == NULL)
goto quit;
@@ -3236,6 +3260,14 @@ BOOL ParseXML(WebMailInfo * WebMail, char * XMLOrig)
XMLKeys++;
ptr1 = strchr(ptr3, '<');
+
+ if (_memicmp(ptr1, "</", 2) == 0)
+ {
+ // end of a parameter block. Find start of next block
+
+ ptr1 = strchr(++ptr1, '<');
+ ptr1 = strchr(++ptr1, '<'); // Skip start of next block
+ }
}
@@ -5349,6 +5381,8 @@ char * CheckFile(struct HtmlFormDir * Dir, char * FN)
#endif
+ printf("%s\n", MsgFile);
+
if (stat(MsgFile, &STAT) != -1)
{
hFile = fopen(MsgFile, "rb");
@@ -5365,6 +5399,8 @@ char * CheckFile(struct HtmlFormDir * Dir, char * FN)
MsgBytes[FileSize] = 0;
fclose(hFile);
+ printf("%d %s\n", strlen(MsgBytes), MsgBytes);
+
return MsgBytes;
}
return NULL;