Polling mechanism test.

git-svn-id: svn://10.0.0.236/trunk@9827 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rjc%netscape.com
1998-09-11 07:45:49 +00:00
parent 86ad096869
commit 2d16ebc092
6 changed files with 122 additions and 9 deletions

View File

@@ -110,6 +110,10 @@ typedef struct _RDF_NCVocabStruct {
RDF_Resource RDF_prompt;
RDF_Resource RDF_HTMLType;
RDF_Resource RDF_URLShortcut;
RDF_Resource RDF_Poll;
RDF_Resource RDF_PollInterval;
RDF_Resource RDF_PollURL;
RDF_Resource RDF_Cookies;
#ifdef TRANSACTION_RECEIPTS
RDF_Resource RDF_Receipts;

View File

@@ -34,6 +34,7 @@
#include "es2mcf.h"
#include "mcff2mcf.h"
#include "nlcstore.h"
#include "ht.h"
/* external routines */
@@ -149,22 +150,35 @@ rdf_Converter(FO_Present_Types format_out, void *client_data,
void
rdf_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx)
{
RDFFile f;
char *navCenterURL = NULL;
if ((status < 0) && (urls != NULL))
{
RDFFile f = (RDFFile) urls->fe_data;
if ((cx != NULL) && (urls->error_msg != NULL))
{
FE_Alert(cx, urls->error_msg);
}
/* if unable to read in navcntr.rdf file, create some default views */
if (strcmp(f->url, gNavCntrUrl) == 0) {
parseNextRDFXMLBlobInt(f, gDefaultNavcntr, strlen(gDefaultNavcntr));
}
if ((f = (RDFFile) urls->fe_data) != NULL)
{
if (strcmp(f->url, gNavCntrUrl) == 0)
{
parseNextRDFXMLBlobInt(f, gDefaultNavcntr,
strlen(gDefaultNavcntr));
}
}
}
if (urls != NULL)
{
if ((f = (RDFFile) urls->fe_data) != NULL)
{
htLoadComplete(f->url, status);
}
}
NET_FreeURLStruct (urls);
}

View File

@@ -47,6 +47,8 @@ HT_MenuCommand menuCommandsList = NULL;
void *htTimerID = NULL;
_htmlElementPtr htmlElementList = NULL;
static int32 htCounter = 0;
static RDF_Resource pollingResource = NULL;
static RDFT gPollRDFT = NULL;
HT_Pane gNavigationTemplate = NULL;
HT_Pane gChromeTemplate = NULL;
@@ -136,12 +138,41 @@ HT_Shutdown()
void
htLoadComplete(char *url, int status)
{
RDF_Resource pollR;
if (url != NULL)
{
if ((pollR = RDF_GetResource(gNCDB, url, PR_TRUE)) != NULL)
{
if (pollR == pollingResource)
{
pollingResource = NULL;
if (gPollRDFT != NULL)
{
DeleteRemStore(gPollRDFT);
gPollRDFT = NULL;
}
}
}
}
}
void
htTimerRoutine(void *timerData)
{
PRBool foundFlag = PR_FALSE;
HT_Pane pane;
HT_View view;
RDF_Cursor c;
RDF_Resource r, pollR;
char *pollURL, *pollInterval;
uint32 now, pollTime, lastPoll;
PRTime prNow, oneMillion, temp;
htTimerID = NULL;
@@ -161,6 +192,63 @@ htTimerRoutine(void *timerData)
pane = pane->next;
}
if (pollingResource == NULL)
{
if ((c = RDF_Find(gNavCenter->RDF_PollURL, gCoreVocab->RDF_stringNotEquals,
"", RDF_STRING_TYPE)) != NULL)
{
prNow = PR_Now();
LL_I2L(oneMillion, PR_USEC_PER_SEC);
LL_DIV(temp, prNow, oneMillion);
LL_L2I(now, temp);
while ((r = RDF_NextValue(c)) != NULL)
{
pollURL = RDF_GetSlotValue(gNCDB, r, gNavCenter->RDF_PollURL,
RDF_STRING_TYPE, PR_FALSE, PR_TRUE);
pollInterval = RDF_GetSlotValue(gNCDB, r, gNavCenter->RDF_PollInterval,
RDF_STRING_TYPE, PR_FALSE, PR_TRUE);
if ((pollURL != NULL) && (pollInterval != NULL))
{
pollTime = (time_t)(60L * atol(pollInterval));
if ((pollR = RDF_GetResource(gNCDB, pollURL, PR_TRUE)) != NULL)
{
lastPoll = (time_t)RDF_GetSlotValue(gNCDB, pollR,
gNavCenter->RDF_PollInterval, RDF_INT_TYPE,
PR_FALSE, PR_TRUE);
if ((pollTime > 0L) && ((lastPoll == 0L) ||
((now - lastPoll) > pollTime)))
{
remoteStoreRemove(gRemoteStore, pollR,
gNavCenter->RDF_PollInterval,
(void *)lastPoll, RDF_INT_TYPE);
remoteStoreAdd(gRemoteStore, pollR,
gNavCenter->RDF_PollInterval,
(void *)now, RDF_INT_TYPE, PR_TRUE);
if ((gPollRDFT = NewRemoteStore(resourceID(pollR))) != NULL)
{
gPollRDFT->possiblyAccessFile = RDFFilePossiblyAccessFile;
if (readRDFFile(resourceID(pollR), pollR, 0, gPollRDFT) != NULL)
{
pollingResource = pollR;
break;
}
else
{
pollingResource = NULL;
DeleteRemStore(gPollRDFT);
gPollRDFT = NULL;
}
}
}
}
}
if (pollURL != NULL) freeMem(pollURL);
if (pollInterval != NULL) freeMem(pollInterval);
}
RDF_DisposeCursor(c);
}
}
/* if found/updated something, try again a bit (half second later),
otherwise try again in 12 seconds */
htTimerID = FE_SetTimeout(htTimerRoutine, NULL, ((foundFlag == PR_TRUE) ? (500) : (1000 * 12)));

View File

@@ -254,6 +254,7 @@ XP_BEGIN_PROTOS
void HT_Startup();
void HT_Shutdown();
void htLoadComplete(char *url, int status);
void htTimerRoutine(void *timerID);
PRBool possiblyUpdateView(HT_View view);
void updateViewItem(HT_Resource node);

View File

@@ -624,8 +624,11 @@ readRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db)
return f;
}
RDFFile
makeNewRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db) {
makeNewRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db)
{
if ((!strstr(url, ":/")) ||
(fileReadp(db, url, true))) {
return NULL;
@@ -709,10 +712,10 @@ NewRemoteStore (char* url)
ntr->nextValue = remoteStoreNextValue;
ntr->disposeCursor = remoteStoreDisposeCursor;
ntr->url = copyString(url);
ntr->destroy = DeleteRemStore;
ntr->destroy = DeleteRemStore;
ntr->arcLabelsIn = remoteStoreArcLabelsIn;
ntr->arcLabelsOut = remoteStoreArcLabelsOut;
ntr->update = remStoreUpdate;
ntr->update = remStoreUpdate;
}
return(ntr);
}

View File

@@ -186,8 +186,11 @@ createNavCenterVocab () {
gNavCenter->RDF_prompt = RDF_GetResource (gCoreDB, "prompt", true);
gNavCenter->RDF_HTMLType = RDF_GetResource (gCoreDB, "HTMLPage", true);
gNavCenter->RDF_URLShortcut = RDF_GetResource(gCoreDB, "URLShortcut", true);
gNavCenter->RDF_Poll = RDF_GetResource(gCoreDB, "poll", true);
gNavCenter->RDF_PollInterval = RDF_GetResource(gCoreDB, "pollInterval", true);
gNavCenter->RDF_PollURL = RDF_GetResource(gCoreDB, "pollURL", true);
gNavCenter->RDF_Cookies = createContainer("NC:Cookies");
setResourceType(gNavCenter->RDF_Cookies, COOKIE_RT);
gNavCenter->RDF_Toolbar = createContainer("NC:Toolbar");