Fix SMART_MAIL for Mac.

This commit is contained in:
rjc%netscape.com 1998-08-12 19:58:08 +00:00
parent 803289486a
commit 5f7d8eb417
6 changed files with 205 additions and 75 deletions

View File

@ -254,7 +254,7 @@ PR_PUBLIC_API(uint32) HT_GetViewListCount(HT_Pane pane);
/*
* HT_GetNthItem / HT_GetNodeIndex
* get the nth resource in a view (or NULL if not in view),
* or find a resource's index in a view (or -1 if not in view)
* or find a resource's index in a view
*/
PR_PUBLIC_API(HT_Resource) HT_GetNthItem (HT_View view, uint32 theIndex);
PR_PUBLIC_API(uint32) HT_GetNodeIndex(HT_View view, HT_Resource node);
@ -267,14 +267,13 @@ PR_PUBLIC_API(uint16) HT_GetItemIndentation(HT_Resource r);
PR_PUBLIC_API(HT_Resource) HT_GetParent (HT_Resource node);
/*
* HT_NodeDisplayString (XXX needs work)
* HT_NodeDisplayString/HT_ViewDisplayString (obsolete)
* obtain the name of a node
*/
PR_PUBLIC_API(HT_Error) HT_NodeDisplayString (HT_Resource node, char *buffer, int bufferLen); /* obsolete! */
PR_PUBLIC_API(HT_Error) HT_ViewDisplayString (HT_View view, char *buffer, int bufferLen); /* obsolete! */
PR_PUBLIC_API(PRBool)
HT_GetTemplateData(HT_Resource node, void* token, uint32 tokenType, void **nodeData);
PR_PUBLIC_API(PRBool) HT_GetTemplateData(HT_Resource node, void* token, uint32 tokenType, void **nodeData);
PR_PUBLIC_API(PRBool) HT_GetNodeData (HT_Resource node, void *token,
uint32 tokenType, void **data);
PR_PUBLIC_API(PRBool) HT_IsNodeDataEditable(HT_Resource node,
@ -353,7 +352,8 @@ enum _HT_MenuCmd {
HT_CMD_REFRESH, HT_CMD_EXPORT, HT_CMD_REMOVE_BOOKMARK_MENU,
HT_CMD_REMOVE_BOOKMARK_FOLDER, HT_CMD_SET_PASSWORD, HT_CMD_REMOVE_PASSWORD,
HT_CMD_EXPORTALL, HT_CMD_UNDO, HT_CMD_NEW_WORKSPACE, HT_CMD_RENAME, HT_CMD_FIND,
HT_CMD_GET_NEW_MAIL};
HT_CMD_GET_NEW_MAIL
};
typedef enum _HT_MenuCmd HT_MenuCmd;
@ -450,6 +450,8 @@ PR_PUBLIC_API(HT_Error) HT_SetEnabledState(HT_Resource node, PRBool isEnabled);
PR_PUBLIC_API(PRBool) HT_Launch(HT_Resource node, MWContext *context);
PR_PUBLIC_API(PRBool) HT_LaunchURL(HT_Pane pane, char *url, MWContext *context);
PR_PUBLIC_API(void) HT_TypeTo(HT_Pane pane, char *typed);
/*
* HT_NewCursor, HT_GetNextItem, HT_DeleteCursor
* Used to iterate over a container's children. Until the container has been

View File

@ -58,7 +58,7 @@ char * gNavCenterDataSources1[15] = {
#ifdef XP_MAC
"rdf:appletalk",
#endif
"rdf:lfs", "rdf:ht",
"rdf:lfs", "rdf:ht",
"rdf:columns", "rdf:find", NULL
};
@ -8559,6 +8559,37 @@ HT_GetPane (HT_View view)
PR_PUBLIC_API(void)
HT_TypeTo(HT_Pane pane, char *typed)
{
HT_Resource node;
HT_View view;
uint32 count, loop;
char *name;
XP_ASSERT(pane != NULL);
XP_ASSERT(typed != NULL);
if ((pane == NULL) || (typed == NULL)) return;
if ((view = HT_GetSelectedView(pane)) == NULL) return;
count = HT_GetItemListCount(view);
for (loop=0; loop<count; loop++)
{
if ((node = HT_GetNthItem(view, loop)) == NULL) break;
if ((name = HT_GetNodeName(node)) != NULL)
{
if (compareStrings(typed, name) >= 0)
{
HT_SetSelection(node);
sendNotification(node, HT_EVENT_NODE_SCROLLTO);
break;
}
}
}
}
/*******************************************************************************/
/* Drag and Drop Stuff */
/*******************************************************************************/

View File

@ -44,12 +44,15 @@
#include "math.h"
#include "htrdf.h"
#ifdef SMART_MAIL
#include "pm2rdf.h"
#endif
/* HT data structures and defines */
#define ITEM_LIST_SIZE 500 /* XXX ITEM_LIST_SIZE should be dynamic */
#define ITEM_LIST_ELEMENT_SIZE 20
#define NUM_MENU_CMDS 40
#define RDF_SITEMAP 1

View File

@ -37,13 +37,16 @@
#include "ht.h"
#include "utils.h"
/* globals */
RDFL gAllDBs = 0;
#ifdef DEBUG_guha
#define SMART_MAIL 1
#endif
/* globals */
RDFL gAllDBs = 0;
RDFT
getTranslator (char* url)
{

View File

@ -24,46 +24,24 @@
#ifdef SMART_MAIL
#include "net.h"
#include "rdf-int.h"
#include <stdio.h>
#include "pm2rdf.h"
extern MWContext *FE_GetRDFContext(void);
extern char* profileDirURL;
struct MailFolder {
FILE *sfile;
FILE *mfile;
struct MailMessage* msg;
struct MailMessage* tail;
struct MailMessage* add;
RDF_Resource top;
int32 status;
RDFT rdf;
char* trash;
};
typedef struct MailFolder* MF;
extern char *profileDirURL;
struct MailMessage {
char* subject;
char* from;
char* date;
int32 offset;
char* flags;
int32 summOffset;
RDF_Resource r;
struct MailMessage *next;
};
typedef struct MailMessage* MM;
void
Pop_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx) {
Pop_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx)
{
}
void
GetPopToRDF (RDFT rdf) {
GetPopToRDF (RDFT rdf)
{
MF folder = (MF) rdf->pdata;
if (endsWith("/inbox", rdf->url)) {
char* popurl = getMem(100);
@ -80,29 +58,43 @@ GetPopToRDF (RDFT rdf) {
urls = NET_CreateURLStruct(popurl, NET_DONT_RELOAD);
if (urls != NULL) {
urls->fe_data = rdf;
NET_GetURL(urls, FO_PRESENT, FE_GetRDFContext(), Pop_GetUrlExitFunc);
NET_GetURL(urls, FO_PRESENT, gRDFMWContext(), Pop_GetUrlExitFunc);
}
}
}
void PopGetNewMail (RDF_Resource r) {
void
PopGetNewMail (RDF_Resource r)
{
if (containerp(r) && (resourceType(r) == PM_RT)) {
MF folder = (MF) r->pdata;
GetPopToRDF(folder->rdf);
}
}
char* stripCopy (char* str) {
char *
stripCopy (char* str)
{
return copyString(XP_StripLine(str));
}
PRBool msgDeletedp (MM msg) {
PRBool
msgDeletedp (MM msg)
{
return (msg && (msg->flags) && (msg->flags[4] == '8'));
}
FILE *openPMFile (char* path) {
FILE *
openPMFile (char* path)
{
FILE* ans = fopen(path, "r+");
if (!ans) {
ans = fopen(path, "w");
@ -113,7 +105,10 @@ FILE *openPMFile (char* path) {
}
void addMsgToFolder (MF folder, MM msg) {
void
addMsgToFolder (MF folder, MM msg)
{
if (!folder->tail) {
folder->msg = folder->tail = msg;
} else {
@ -122,8 +117,11 @@ void addMsgToFolder (MF folder, MM msg) {
}
}
void
RDF_StartMessageDelivery (RDFT rdf) {
RDF_StartMessageDelivery (RDFT rdf)
{
MF folder = (MF) rdf->pdata;
MM msg = (MM) getMem(sizeof(struct MailMessage));
char* nurl = getMem(100);
@ -141,7 +139,10 @@ RDF_StartMessageDelivery (RDFT rdf) {
}
char* MIW1 (const char* block, int32 len) {
char *
MIW1 (const char* block, int32 len)
{
char* blk = XP_ALLOC(len +1);
int32 n = 0;
int32 m = 0;
@ -163,8 +164,11 @@ char* MIW1 (const char* block, int32 len) {
return blk;
}
void
RDF_AddMessageLine (RDFT rdf, char* block, int32 length) {
RDF_AddMessageLine (RDFT rdf, char* block, int32 length)
{
MF folder = (MF) rdf->pdata;
MM msg = folder->add;
char* temp = getMem(length+1);
@ -181,8 +185,11 @@ RDF_AddMessageLine (RDFT rdf, char* block, int32 length) {
freeMem(temp);
}
#define TON(s) ((s == NULL) ? "" : s)
void writeMsgSum (MF folder, MM msg) {
void
writeMsgSum (MF folder, MM msg)
{
if (!msg->flags) msg->flags = getMem(4);
if (msg->summOffset == -1) {
fseek(folder->sfile, 0L, SEEK_END);
@ -194,9 +201,12 @@ void writeMsgSum (MF folder, MM msg) {
msg->flags, ftell(folder->sfile),
TON(msg->from), TON(msg->subject), TON(msg->date), msg->offset );
}
void
RDF_FinishMessageDelivery (RDFT rdf) {
RDF_FinishMessageDelivery (RDFT rdf)
{
MF folder = (MF) rdf->pdata;
MM msg = folder->add;
folder->add = NULL;
@ -211,8 +221,11 @@ RDF_FinishMessageDelivery (RDFT rdf) {
RDF_RESOURCE_TYPE, 1);
}
void
setMessageFlag (RDFT rdf, RDF_Resource r, char* newFlag) {
setMessageFlag (RDFT rdf, RDF_Resource r, char* newFlag)
{
MF folder = (MF) rdf->pdata;
MM msg = (MM)r->pdata;
fseek(folder->sfile, msg->summOffset+9, SEEK_SET);
@ -220,10 +233,16 @@ setMessageFlag (RDFT rdf, RDF_Resource r, char* newFlag) {
/* need to mark the flag in the message file */
fflush(folder->sfile);
}
#define BUFF_SIZE 100000
PRBool
MoveMessage (char* to, char* from, MM message) {
MoveMessage (char* to, char* from, MM message)
{
RDFT todb = getTranslator(to);
RDFT fromdb = getTranslator(from);
MF tom = todb->pdata;
@ -237,11 +256,15 @@ MoveMessage (char* to, char* from, MM message) {
while (fgets(buffer, BUFF_SIZE, fom->mfile) && strncmp("From ", buffer, 5)) {
fputs(buffer, tom->mfile);
}
freeMem(buffer);
return 1;
}
void readSummaryFile (RDFT rdf) {
void
readSummaryFile (RDFT rdf)
{
if (startsWith("mailbox://", rdf->url)) {
char* url = rdf->url;
char* folderURL = &url[10];
@ -270,9 +293,6 @@ void readSummaryFile (RDFT rdf) {
folder->sfile = f;
folder->mfile = mf;
while (f && fgets(buff, BUFF_SIZE, f)) {
if (startsWith("Status:", buff)) {
msg = (MM) getMem(sizeof(struct MailMessage));
@ -334,9 +354,12 @@ void readSummaryFile (RDFT rdf) {
}
}
void *
pmGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
PRBool inversep, PRBool tv) {
PRBool inversep, PRBool tv)
{
if ((resourceType(u) == PM_RT) && tv && (!inversep) && (type == RDF_STRING_TYPE) && (u->pdata)) {
MM msg = (MM) u->pdata;
if (s == gNavCenter->from) {
@ -349,10 +372,12 @@ pmGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
} else return NULL;
}
RDF_Cursor
pmGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
PRBool inversep, PRBool tv) {
PRBool inversep, PRBool tv)
{
if ((resourceType(u) == PM_RT) && tv && (inversep) && (type == RDF_RESOURCE_TYPE)
&& (s == gCoreVocab->RDF_parent)) {
MF folder = (MF)rdf->pdata;
@ -371,6 +396,7 @@ pmGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
}
void *
pmNextValue (RDFT rdf, RDF_Cursor c)
{
@ -387,6 +413,7 @@ pmNextValue (RDFT rdf, RDF_Cursor c)
}
RDF_Error
pmDisposeCursor (RDFT mcf, RDF_Cursor c)
{
@ -394,12 +421,17 @@ pmDisposeCursor (RDFT mcf, RDF_Cursor c)
return noRDFErr;
}
FILE *getPopMBox (RDFT db) {
FILE *
getPopMBox (RDFT db)
{
MF folder = (MF)db->pdata;
return folder->mfile;
}
PRBool
pmHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
{
@ -408,9 +440,10 @@ pmHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType
}
PRBool
pmRemove (RDFT rdf, RDF_Resource u, RDF_Resource s,
void* v, RDF_ValueType type) {
pmRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
{
if ((startsWith("mailbox://", rdf->url)) && (resourceType(u) == PM_RT) && (s == gCoreVocab->RDF_parent)
&& (type == RDF_RESOURCE_TYPE)) {
RDF_Resource mbox = (RDF_Resource) v;
@ -425,6 +458,8 @@ pmRemove (RDFT rdf, RDF_Resource u, RDF_Resource s,
} else return false;
}
RDFT
MakePopDB (char* url)
{
@ -459,10 +494,12 @@ MakePopDB (char* url)
return NULL;
}
}
else return NULL;
} else return NULL;
}
RDFT
MakeMailAccountDB (char* url)
{
@ -478,7 +515,7 @@ MakeMailAccountDB (char* url)
if (dir == NULL) {
if ( CallPRMkDirUsingFileURL(fileurl, 00700) > -1) dir = OpenDir(fileurl);
}
while (dir && (de = PR_ReadDir(dir, n++))) {
while ((dir != NULL) && ((de = PR_ReadDir(dir, (PRDirFlags)(n++))) != NULL)) {
if ((!endsWith(".ssf", de->name)) && (!endsWith(".dat", de->name)) &&
(!endsWith(".snm", de->name)) && (!endsWith("~", de->name))) {
RDF_Resource r;
@ -496,8 +533,3 @@ MakeMailAccountDB (char* url)
}
#endif

View File

@ -19,22 +19,81 @@
#ifndef _RDF_PM2RDF_H_
#define _RDF_PM2RDF_H_
#include "net.h"
#include "rdf.h"
#include "rdf-int.h"
#include "prio.h"
#include "glue.h"
#include "utils.h"
#include "xp_str.h"
#include <stdio.h>
/* pm2rdf.c data structures and defines */
#define TON(s) ((s == NULL) ? "" : s)
#define pmUnitp(u) ((resourceType(u) == PM_RT) || (resourceType(u) == IM_RT))
struct MailFolder {
FILE *sfile;
FILE *mfile;
struct MailMessage* msg;
struct MailMessage* tail;
struct MailMessage* add;
RDF_Resource top;
int32 status;
RDFT rdf;
char* trash;
};
typedef struct MailFolder* MF;
struct MailMessage {
char* subject;
char* from;
char* date;
int32 offset;
char* flags;
int32 summOffset;
RDF_Resource r;
struct MailMessage *next;
};
typedef struct MailMessage* MM;
/* pm2rdf.c function prototypes */
XP_BEGIN_PROTOS
void Pop_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx);
void GetPopToRDF (RDFT rdf);
void PopGetNewMail (RDF_Resource r);
char * stripCopy (char* str);
PRBool msgDeletedp (MM msg);
FILE * openPMFile (char* path);
void addMsgToFolder (MF folder, MM msg);
void RDF_StartMessageDelivery (RDFT rdf);
char * MIW1 (const char* block, int32 len);
void RDF_AddMessageLine (RDFT rdf, char* block, int32 length);
void writeMsgSum (MF folder, MM msg);
void RDF_FinishMessageDelivery (RDFT rdf);
void setMessageFlag (RDFT rdf, RDF_Resource r, char* newFlag);
PRBool MoveMessage (char* to, char* from, MM message);
void readSummaryFile (RDFT rdf);
void * pmGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
RDF_Cursor pmGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
void * pmNextValue (RDFT rdf, RDF_Cursor c);
RDF_Error pmDisposeCursor (RDFT mcf, RDF_Cursor c);
FILE * getPopMBox (RDFT db);
PRBool pmHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
PRBool pmRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
RDFT MakePopDB (char* url);
RDFT MakeMailAccountDB (char* url);
XP_END_PROTOS