This commit is contained in:
guha 1998-05-19 21:01:38 +00:00
Родитель 44ebed2fda
Коммит 8e0b2d726a
9 изменённых файлов: 177 добавлений и 12 удалений

Просмотреть файл

@ -43,6 +43,7 @@ NSPR_BEGIN_EXTERN_C
typedef struct RDF_ResourceStruct* RDF_Resource;
typedef struct RDF_CursorStruct* RDF_Cursor;
typedef struct RDF_DBStruct* RDF;
typedef struct RDF_TranslatorStruct *RDFT;
typedef uint32 RDF_EventType;
#define RDF_ASSERT_NOTIFY ((RDF_EventType)0x00000001)
@ -106,6 +107,8 @@ typedef void (*RDF_NotificationProc)(RDF_Event theEvent, void* pdata);
PR_PUBLIC_API(RDF) RDF_GetDB(const char** dbs);
PR_PUBLIC_API(RDF_Error) RDF_ReleaseDB(RDF rdf);
PR_PUBLIC_API(RDFT) RDF_AddDataSource(RDF rdf, char* dataSource);
PR_PUBLIC_API(RDF_Error) RDF_ReleaseDataSource(RDF rdf, RDFT dataSource);
PR_PUBLIC_API(RDF_Resource) RDF_GetResource(RDF db, char* id, PRBool createp);
PR_PUBLIC_API(RDF_Error) RDF_ReleaseResource(RDF db, RDF_Resource resource);
PR_PUBLIC_API(RDF_Error) RDF_DeleteAllArcs(RDF rdfDB, RDF_Resource source);

Просмотреть файл

@ -92,6 +92,7 @@ typedef struct _RDF_NCVocabStruct {
RDF_Resource RDF_HTMLType;
RDF_Resource RDF_Command;
RDF_Resource RDF_URLShortcut;
RDF_Resource RDF_Cookies;
/* NavCenter appearance styles */

Просмотреть файл

@ -939,7 +939,7 @@ gNavCenterDataSources1[15] =
#endif
"rdf:lfs", "rdf:ht",
"rdf:columns", NULL
"rdf:columns", "rdf:CookieStore", NULL
};
@ -7387,7 +7387,7 @@ populateSBProviders (HT_Pane htPane)
sb->name = RDF_GetResourceName(db, prov);
sb->url = copyString(resourceID(prov));
sb->containerp = (!RDF_HasAssertion(db, prov, gNavCenter->RDF_resultType,
"HTML", RDF_STRING_TYPE, 1));
"TEXT/HTML", RDF_STRING_TYPE, 1));
sb->next = htPane->smartBrowsingProviders;
htPane->smartBrowsingProviders = sb;
}
@ -7558,6 +7558,7 @@ HT_AddRelatedLinksFor(HT_Pane htPane, char *pUrl)
sprintf(buffer, "%s%s", prov->url, &pUrl[7]);
nu = RDF_GetResource(htPane->db, buffer, 1);
setContainerp(nu, prov->containerp);
setResourceType(nu, RDF_RT);
nsmp = makeNewSMP(htPane, pUrl, buffer);
nsmp->sitemap = nu;
nsmp->next = htPane->sbp;

Просмотреть файл

@ -66,7 +66,9 @@ getTranslator (char* url)
return MakeColumnStore (url);
} else if (startsWith("rdf:ht", url) || startsWith("rdf:scook", url)) {
return MakeSCookDB(url);
} else return NULL;
} else if (startsWith("rdf:CookieStore", url)) {
return MakeCookieStore(url);
} else return NULL;
}
@ -96,12 +98,51 @@ RDF_GetDB (const char** dataSources)
n++;
}
r->numTranslators = m;
r->translatorArraySize = n-1;
nrl->rdf = r;
nrl->next = gAllDBs;
gAllDBs = nrl;
return r;
}
PR_PUBLIC_API(RDFT) RDF_AddDataSource(RDF rdf, char* dataSource) {
RDFT newDB;
if (rdf->numTranslators == rdf->translatorArraySize) {
RDFT* tmp = (RDFT*)getMem((rdf->numTranslators+5)*(sizeof(RDFT)));
memcpy(tmp, rdf->translators, (rdf->numTranslators * sizeof(RDFT)));
rdf->translatorArraySize = rdf->numTranslators + 5;
freeMem(rdf->translators);
rdf->translators = tmp;
}
newDB = getTranslator(dataSource);
if (!newDB) {
return NULL;
} else {
RDFL rl = (RDFL)getMem(sizeof(struct RDF_ListStruct));
rl->rdf = rdf;
rl->next = newDB->rdf;
newDB->rdf = rl;
rdf->numTranslators++;
return newDB;
}
}
PR_PUBLIC_API(RDF_Error) RDF_ReleaseDataSource(RDF rdf, RDFT dataSource) {
RDFT* temp = (RDFT*)getMem((rdf->numTranslators-1)*(sizeof(RDFT)));
int16 m = 0;
int16 n= 0;
RDFT next;
while (next = rdf->translators[n++]) {
if (next != dataSource) {
*(temp + m) = (RDFT) next;
}
}
memset(rdf->translators, '\0', sizeof(RDFT) * rdf->numTranslators);
memcpy(rdf->translators, temp, sizeof(RDFT) * (rdf->numTranslators -1));
rdf->numTranslators--;
deleteFromRDFList(dataSource->rdf, rdf);
return 0;
}
RDFL

Просмотреть файл

@ -142,7 +142,6 @@ struct RDF_AssertionStruct {
typedef struct RDF_AssertionStruct *Assertion;
typedef struct RDF_TranslatorStruct *RDFT;
typedef struct RDF_FileStruct *RDFFile;
@ -189,6 +188,7 @@ struct RDF_TranslatorStruct {
extern PLHashTable* resourceHash;
struct RDF_DBStruct {
int16 numTranslators;
int16 translatorArraySize;
RDFT* translators;
struct RDF_FileStruct* files;
struct RDF_NotificationStruct* notifs;
@ -378,6 +378,9 @@ PRBool remoteStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void*
PRBool remoteStoreHasAssertionInt (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
PRBool nlocalStoreAddChildAt(RDFT mcf, RDF_Resource obj, RDF_Resource ref, RDF_Resource new,
PRBool beforep);
RDFT MakeCookieStore (char* url);
char* advertURLOfContainer (RDF r, RDF_Resource u) ;
RDFT RDFTNamed (RDF rdf, char* name) ;

Просмотреть файл

@ -46,7 +46,7 @@ char * gNavCenterDataSources[15] =
{"rdf:localStore", "rdf:remoteStore", "rdf:remoteStore", "rdf:history",
/* "rdf:ldap", */
"rdf:esftp",
"rdf:lfs",
"rdf:lfs", "rdf:CookieStore",
"rdf:columns", NULL
};

Просмотреть файл

@ -49,7 +49,7 @@ MakeRemoteStore (char* url)
ntr->hasAssertion = remoteStoreHasAssertion;
ntr->nextValue = remoteStoreNextValue;
ntr->disposeCursor = remoteStoreDisposeCursor;
ntr->possiblyAccessFile = RDFFilePossiblyAccessFile ;
/* ntr->possiblyAccessFile = RDFFilePossiblyAccessFile ; */
gRemoteStore = ntr;
ntr->url = copyString(url);
return ntr;
@ -250,11 +250,12 @@ possiblyAccessFile (RDFT mcf, RDF_Resource u, RDF_Resource s, PRBool inversep)
}
void RDFFilePossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) {
if ((resourceType(u) == RDF_RT) && (strstr(rdf->url, ".rdf") || strstr(rdf->url, ".mcf")) &&
(strstr(resourceID(u), ".rdf") || strstr(resourceID(u), ".mcf")) &&
if ((resourceType(u) == RDF_RT) &&
(strstr(rdf->url, ".rdf") || strstr(rdf->url, ".mcf")) &&
(strstr(resourceID(u), ".rdf") || strstr(resourceID(u), ".mcf")) &&
(s == gCoreVocab->RDF_parent) && (containerp(u))) {
RDFFile newFile = readRDFFile( resourceID(u), u, false, rdf);
if(newFile) newFile->lastReadTime = PR_Now();
/* if(newFile) newFile->lastReadTime = PR_Now(); */
}
}
@ -511,7 +512,7 @@ void
SCookPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
{
if ((resourceType(u) == RDF_RT) && (strcmp(rdf->url, "rdf:ht") ==0) &&
(strstr(resourceID(u), ".rdf") || strstr(resourceID(u), ".mcf")) &&
/* (strstr(resourceID(u), ".rdf") || strstr(resourceID(u), ".mcf")) && */
(s == gCoreVocab->RDF_parent) &&
(containerp(u))) {
RDFFile newFile = readRDFFile( resourceID(u), u, false, rdf);
@ -533,7 +534,7 @@ MakeSCookDB (char* url)
ntr->hasAssertion = remoteStoreHasAssertion;
ntr->nextValue = remoteStoreNextValue;
ntr->disposeCursor = remoteStoreDisposeCursor;
ntr->possiblyAccessFile = RDFFilePossiblyAccessFile ;
ntr->possiblyAccessFile = SCookPossiblyAccessFile ;
ntr->url = copyString(url);
return ntr;
} else return NULL;

Просмотреть файл

@ -512,3 +512,117 @@ RDFUtil_SetDefaultSelectedView(RDF_Resource container)
{
RDFUtil_SetFirstInstance(gNavCenter->RDF_DefaultSelectedView, container);
}
/* I am putting the cookies stuff here for now */
RDFT gCookieStore = 0;
void AddCookieResource(char* name, char* path, char* host, char* expires) {
char* url = getMem(strlen(name) + strlen(host));
RDF_Resource ru;
sprintf(url, "%s [%s]", host, name);
ru = RDF_GetResource(NULL, url, 1);
remoteStoreAdd(gCookieStore, ru, gCoreVocab->RDF_parent, gNavCenter->RDF_Cookies, RDF_RESOURCE_TYPE, 1);
}
#define LINE_BUFFER_SIZE 4096
void
RDF_ReadCookies(char * filename)
{
XP_File fp;
char buffer[LINE_BUFFER_SIZE];
char *host, *is_domain, *path, *secure, *expires, *name, *cookie;
Bool added_to_list;
if(!(fp = XP_FileOpen(filename, xpHTTPCookie, XP_FILE_READ)))
return;
/* format is:
*
* host \t is_domain \t path \t secure \t expires \t name \t cookie
*
* if this format isn't respected we move onto the next line in the file.
* is_domain is TRUE or FALSE -- defaulting to FALSE
* secure is TRUE or FALSE -- should default to TRUE
* expires is a time_t integer
* cookie can have tabs
*/
while(XP_FileReadLine(buffer, LINE_BUFFER_SIZE, fp))
{
added_to_list = FALSE;
if (*buffer == '#' || *buffer == '\n' || *buffer == '\r' || *buffer == 0)
continue;
host = buffer;
if( !(is_domain = XP_STRCHR(host, '\t')) )
continue;
*is_domain++ = '\0';
if(*is_domain == CR || *is_domain == LF || *is_domain == 0)
continue;
if( !(path = XP_STRCHR(is_domain, '\t')) )
continue;
*path++ = '\0';
if(*path == '\n' || *path == '\r' || *path == 0)
continue;
if( !(secure = XP_STRCHR(path, '\t')) )
continue;
*secure++ = '\0';
if(*secure == CR || *secure == LF || *secure == 0)
continue;
if( !(expires = XP_STRCHR(secure, '\t')) )
continue;
*expires++ = '\0';
if(*expires == '\r' || *expires == '\n' || *expires == 0)
continue;
if( !(name = XP_STRCHR(expires, '\t')) )
continue;
*name++ = '\0';
if(*name == CR || *name == LF || *name == 0)
continue;
if( !(cookie = XP_STRCHR(name, '\t')) )
continue;
*cookie++ = '\0';
if(*cookie == CR || *cookie == LF || *cookie == 0)
continue;
/* remove the '\n' from the end of the cookie */
XP_StripLine(cookie);
/* construct a new cookie resource
*/
AddCookieResource(name, path, host, expires);
}
XP_FileClose(fp);
}
RDFT
MakeCookieStore (char* url)
{
if (startsWith("rdf:CookieStore", url)) {
if (gCookieStore == 0) {
RDFT ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct));
ntr->assert = NULL;
ntr->unassert = NULL;
ntr->getSlotValue = remoteStoreGetSlotValue;
ntr->getSlotValues = remoteStoreGetSlotValues;
ntr->hasAssertion = remoteStoreHasAssertion;
ntr->nextValue = remoteStoreNextValue;
ntr->disposeCursor = remoteStoreDisposeCursor;
gCookieStore = ntr;
ntr->url = copyString(url);
RDF_ReadCookies("");
return ntr;
} else return gCookieStore;
} else return NULL;
}

Просмотреть файл

@ -148,7 +148,8 @@ createNavCenterVocab () {
gNavCenter->RDF_HTMLType = RDF_GetResource (gCoreDB, "HTMLPage", true);
gNavCenter->RDF_Command = RDF_GetResource (gCoreDB, "Command", true);
gNavCenter->RDF_URLShortcut = RDF_GetResource(gCoreDB, "URLShortcut", true);
gNavCenter->RDF_Cookies = createContainer("NC:Cookies");
/* NavCenter appearance styles */
gNavCenter->treeFGColor = newResource("treeFGColor", RDF_FOREGROUND_COLOR_STR);