зеркало из https://github.com/mozilla/gecko-dev.git
Moved a couple necessary things out of receipt.c into privacy.c. This
file doesn't build on the tip.
This commit is contained in:
Родитель
664ffb1e78
Коммит
513f2afb33
|
@ -1,3 +1,4 @@
|
|||
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
|
@ -20,6 +21,7 @@
|
|||
/*
|
||||
receipt.c --- functions to deal with transaction receipts/form prefilling.
|
||||
Created: David Meeker <dfm@netscape.com>, 09-Jun-98.
|
||||
Mothballed: 27-Jul-98
|
||||
*/
|
||||
|
||||
#include "xp.h"
|
||||
|
@ -43,18 +45,78 @@
|
|||
#include "vocab.h"
|
||||
#include "receipt.h"
|
||||
|
||||
#undef DEBUG_dfm
|
||||
#define TIME_RDF_CALLS
|
||||
|
||||
|
||||
#ifdef DEBUG_dfm
|
||||
#define TIME_RDF_CALLS
|
||||
#define TIME_RDF_CALLS_OVERKILL
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef TIME_RDF_CALLS
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MICROS_TO_SECOND 1000000
|
||||
#define PROF_RDF(x) x
|
||||
|
||||
static struct timeval tv_rdf_start, tv_rdf_end, tv_rdf_elapsed, tv_main_start, tv_main_end;
|
||||
|
||||
#define PRINT_TIME(tv,label) printf("%s %d seconds, %d microseconds.\n", label, tv.tv_sec, tv.tv_usec)
|
||||
|
||||
#ifdef TIME_RDF_CALLS_OVERKILL
|
||||
#define PRINT_TIME_OVERKILL PRINT_TIME
|
||||
#else
|
||||
#define PRINT_TIME_OVERKILL
|
||||
#endif
|
||||
|
||||
#define RDF_START { gettimeofday(&tv_rdf_start, NULL); }
|
||||
#define RDF_END { gettimeofday(&tv_rdf_end, NULL); \
|
||||
timersub( &tv_rdf_end, &tv_rdf_start, &tv_rdf_start ); \
|
||||
timeradd( &tv_rdf_start, &tv_rdf_elapsed, &tv_rdf_elapsed ); \
|
||||
PRINT_TIME_OVERKILL(tv_rdf_start,"This RDF call: "); }
|
||||
#define PROFILING_START { gettimeofday(&tv_main_start, NULL); }
|
||||
#define PROFILING_END { gettimeofday(&tv_main_end, NULL); \
|
||||
timersub( &tv_main_end, &tv_main_start, &tv_main_start ); \
|
||||
PRINT_TIME(tv_main_start,"Time elapsed: "); \
|
||||
timersub( &tv_main_start, &tv_rdf_elapsed, &tv_main_end ); \
|
||||
PRINT_TIME(tv_main_end,"Transaction code: "); \
|
||||
PRINT_TIME(tv_rdf_elapsed,"RDF code: "); }
|
||||
#else /* TIME_RDF_CALLS */
|
||||
|
||||
#define PROF_RDF(x)
|
||||
#define RDF_START
|
||||
#define RDF_END
|
||||
#define PROFILING_START
|
||||
#define PROFILING_END
|
||||
|
||||
#endif /* TIME_RDF_CALLS */
|
||||
|
||||
|
||||
|
||||
extern char *
|
||||
resourceID(RDF_Resource r);
|
||||
|
||||
extern void
|
||||
setContainerp(RDF_Resource, PRBool val);
|
||||
|
||||
extern RDF gLocalStore;
|
||||
/* extern RDF gLocalStore; */
|
||||
extern RDF_NCVocab gNavCenter;
|
||||
extern RDF_WDVocab gWebData;
|
||||
extern RDF_CoreVocab gCoreVocab;
|
||||
|
||||
#define RDF_SetContainer(x,y) setContainerp(x,y)
|
||||
static char* gRdfDbStr[] = {"rdf:localStore", NULL};
|
||||
static RDF gRDFDB;
|
||||
|
||||
#define RDF_SetContainer(x,y) setContainerp(x,y)
|
||||
#define RDF_GetResourceID(x) resourceID(x)
|
||||
|
||||
#define RT_STR_NOTNULL(x) ((x == NULL)?"":x)
|
||||
|
||||
#ifdef DEBUG_dfm
|
||||
#include <stdio.h>
|
||||
|
@ -67,6 +129,317 @@ extern RDF_CoreVocab gCoreVocab;
|
|||
#pragma profile on
|
||||
#endif
|
||||
|
||||
|
||||
#define STRLEN_SERIAL_NO 11 /* 10 digits, plus one separator char. */
|
||||
|
||||
|
||||
char *
|
||||
rt_MakeNodeID(RDF_Resource parent, int32 serial, char *name, char *type)
|
||||
{
|
||||
char *nodeID;
|
||||
|
||||
/* Yes, I know I'm ignoring name and type. */
|
||||
|
||||
nodeID = XP_ALLOC( XP_STRLEN(resourceID(parent)) + STRLEN_SERIAL_NO + 1);
|
||||
if (!nodeID) return NULL;
|
||||
XP_SPRINTF(nodeID,"%s#%d",resourceID(parent),serial);
|
||||
return nodeID;
|
||||
}
|
||||
|
||||
|
||||
RDF_Resource
|
||||
rt_RDF_MakeResource(RDF_Resource source,
|
||||
char *name,
|
||||
Bool container,
|
||||
RDF_Resource relationship)
|
||||
{
|
||||
RDF_Resource res;
|
||||
|
||||
D(printf("Creating RDF_Resource: %s\n", name));
|
||||
|
||||
RDF_START
|
||||
|
||||
res = RDF_GetResource(NULL, name, 0);
|
||||
|
||||
if (!res) {
|
||||
res = RDF_GetResource(NULL, name, 1);
|
||||
RDF_SetContainer(res, container);
|
||||
} else {
|
||||
D(printf("Resource already existed! \n"));
|
||||
}
|
||||
if (res) {
|
||||
RDF_Assert(gRDFDB,
|
||||
source,
|
||||
relationship,
|
||||
res,
|
||||
RDF_RESOURCE_TYPE);
|
||||
}
|
||||
RDF_END
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
RDF_Resource
|
||||
rt_RDF_MakeChildResource(RDF_Resource parent, char *name, Bool container)
|
||||
{
|
||||
return rt_RDF_MakeResource(parent, name, container, gCoreVocab->RDF_child);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
rt_RDF_NameResource(RDF_Resource source, char *name)
|
||||
{
|
||||
if (name == NULL) return;
|
||||
D(printf("Naming ID(%s) to (%s)\n",RDF_GetResourceID(source),name));
|
||||
RDF_START
|
||||
RDF_Assert(gRDFDB,
|
||||
source,
|
||||
gCoreVocab->RDF_name,
|
||||
name,
|
||||
RDF_STRING_TYPE);
|
||||
RDF_END
|
||||
}
|
||||
|
||||
RDF_Resource
|
||||
rt_RDF_getEntryResourceText(RDF_Resource form_unit,
|
||||
int32 serial,
|
||||
char *name,
|
||||
char *value,
|
||||
int32 size)
|
||||
{
|
||||
RDF_Resource textResource;
|
||||
char *resName;
|
||||
|
||||
if (!name)
|
||||
{
|
||||
D(printf("Name of field was NULL.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
resName = rt_MakeNodeID(form_unit,serial,name,"text");
|
||||
|
||||
if (!resName) return NULL;
|
||||
|
||||
textResource = rt_RDF_MakeChildResource(form_unit,
|
||||
resName,
|
||||
TRUE);
|
||||
XP_FREE(resName);
|
||||
|
||||
if (!textResource) return NULL;
|
||||
|
||||
rt_RDF_NameResource(textResource, name);
|
||||
|
||||
RDF_START
|
||||
|
||||
RDF_Assert(gRDFDB,
|
||||
textResource,
|
||||
gCoreVocab->RDF_stringEquals,
|
||||
RT_STR_NOTNULL(value),
|
||||
RDF_STRING_TYPE);
|
||||
|
||||
RDF_END
|
||||
|
||||
return textResource;
|
||||
}
|
||||
|
||||
RDF_Resource
|
||||
rt_RDF_getEntryResourceToggle(RDF_Resource form_unit,
|
||||
int32 serial,
|
||||
char *name,
|
||||
Bool toggled,
|
||||
char *value)
|
||||
{
|
||||
char *resName;
|
||||
RDF_Resource toggleResource;
|
||||
|
||||
if (!name)
|
||||
{
|
||||
D(printf("Name of field was NULL.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
resName = rt_MakeNodeID(form_unit,serial,name,"toggle");
|
||||
|
||||
if (!resName) return NULL;
|
||||
|
||||
toggleResource = rt_RDF_MakeChildResource(form_unit,
|
||||
resName,
|
||||
FALSE);
|
||||
XP_FREE(resName);
|
||||
|
||||
if (!toggleResource) return NULL;
|
||||
|
||||
rt_RDF_NameResource(toggleResource, name);
|
||||
|
||||
/* Assert the toggle state and value off this node */
|
||||
|
||||
RDF_START
|
||||
|
||||
RDF_Assert(gRDFDB,
|
||||
toggleResource,
|
||||
gCoreVocab->RDF_stringEquals,
|
||||
RT_STR_NOTNULL(value),
|
||||
RDF_STRING_TYPE);
|
||||
|
||||
RDF_Assert(gRDFDB,
|
||||
toggleResource,
|
||||
gCoreVocab->RDF_equals,
|
||||
/* URGENT -- SHOULD THIS BE A POINTER TO THE INT,
|
||||
OR THE INT ITSELF? */
|
||||
&toggled,
|
||||
RDF_INT_TYPE);
|
||||
|
||||
RDF_END
|
||||
|
||||
return toggleResource;
|
||||
|
||||
}
|
||||
|
||||
RDF_Resource
|
||||
rt_RDF_getEntryResourceSelect(RDF_Resource form_unit,
|
||||
int32 serial,
|
||||
char *name,
|
||||
int32 option_cnt)
|
||||
{
|
||||
char *resName;
|
||||
RDF_Resource selectResource;
|
||||
|
||||
|
||||
if (!name)
|
||||
{
|
||||
D(printf("Name of field was NULL.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
resName = rt_MakeNodeID(form_unit,serial,name,"select");
|
||||
|
||||
if (!resName) return NULL;
|
||||
|
||||
selectResource = rt_RDF_MakeChildResource(form_unit,
|
||||
resName,
|
||||
TRUE);
|
||||
XP_FREE(resName);
|
||||
|
||||
if (!selectResource) return NULL;
|
||||
|
||||
rt_RDF_NameResource(selectResource, name);
|
||||
|
||||
/* Assert the option count off this node; children will be added after
|
||||
this function terminates. */
|
||||
|
||||
/* Not necessary right now.. */
|
||||
|
||||
return selectResource;
|
||||
}
|
||||
|
||||
RDF_Resource
|
||||
rt_RDF_chainSubelement(RDF_Resource entry_unit,
|
||||
int32 serial,
|
||||
char *text_value,
|
||||
char *value,
|
||||
Bool selected)
|
||||
{
|
||||
RDF_Resource subelementResource;
|
||||
char *resName;
|
||||
|
||||
if (!value)
|
||||
{
|
||||
D(printf("Value of subelement field was NULL.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
resName = rt_MakeNodeID(entry_unit, serial, value, "subelement");
|
||||
|
||||
if (!resName) return NULL;
|
||||
|
||||
subelementResource = rt_RDF_MakeChildResource(entry_unit,
|
||||
resName,
|
||||
FALSE);
|
||||
XP_FREE(resName);
|
||||
|
||||
if (!subelementResource) return NULL;
|
||||
|
||||
rt_RDF_NameResource(subelementResource,value);
|
||||
|
||||
RDF_START
|
||||
|
||||
RDF_Assert(gRDFDB,
|
||||
subelementResource,
|
||||
gCoreVocab->RDF_stringEquals,
|
||||
RT_STR_NOTNULL(value),
|
||||
RDF_STRING_TYPE);
|
||||
|
||||
/*
|
||||
RDF_Assert(gRDFDB,
|
||||
subelementResource,
|
||||
gCoreVocab->RDF_equals,
|
||||
RT_STR_NOTNULL(text_value),
|
||||
RDF_STRING_TYPE);
|
||||
*/
|
||||
|
||||
RDF_Assert(gRDFDB,
|
||||
subelementResource,
|
||||
gCoreVocab->RDF_equals,
|
||||
/* URGENT -- SHOULD THIS BE AN INT* OR INT? */
|
||||
&selected,
|
||||
RDF_INT_TYPE);
|
||||
|
||||
RDF_END
|
||||
|
||||
return subelementResource;
|
||||
}
|
||||
|
||||
RDF_Resource
|
||||
rt_RDF_getEntryResourceArea(RDF_Resource form_unit,
|
||||
int32 serial,
|
||||
char *name,
|
||||
char *text)
|
||||
{
|
||||
char *resName;
|
||||
RDF_Resource areaResource;
|
||||
|
||||
if (!name)
|
||||
{
|
||||
D(printf("Name of textarea field was NULL.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
resName = rt_MakeNodeID(form_unit,serial,name,"area");
|
||||
|
||||
if (!resName) return NULL;
|
||||
|
||||
areaResource = rt_RDF_MakeChildResource(form_unit,
|
||||
resName,
|
||||
FALSE);
|
||||
XP_FREE(resName);
|
||||
|
||||
if (!areaResource) return NULL;
|
||||
|
||||
rt_RDF_NameResource(areaResource, name);
|
||||
|
||||
/* Assert the text value off this node */
|
||||
|
||||
RDF_START
|
||||
|
||||
RDF_Assert(gRDFDB,
|
||||
areaResource,
|
||||
gCoreVocab->RDF_equals,
|
||||
RT_STR_NOTNULL(text),
|
||||
RDF_STRING_TYPE);
|
||||
|
||||
RDF_END
|
||||
|
||||
return areaResource;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
rt_RDF_GetHostResource(char* host)
|
||||
{
|
||||
|
@ -78,104 +451,78 @@ rt_RDF_GetHostResource(char* host)
|
|||
XP_STRCPY(prefixed_host,RECEIPT_CONTAINER_URL_PREFIX);
|
||||
XP_STRCAT(prefixed_host,host);
|
||||
|
||||
D(printf("Creating RDF_Resource: %s\n",prefixed_host));
|
||||
|
||||
hostResource = RDF_GetResource(NULL, host, 0);
|
||||
if (!hostResource) {
|
||||
hostResource = RDF_GetResource(NULL, host, 1);
|
||||
RDF_SetContainer(hostResource, TRUE);
|
||||
/* setResourceType(hostResource, RECEIPT_RT); */
|
||||
}
|
||||
|
||||
if (hostResource)
|
||||
RDF_Assert(gLocalStore,
|
||||
hostResource,
|
||||
gCoreVocab->RDF_parent,
|
||||
gNavCenter->RDF_Receipts,
|
||||
RDF_RESOURCE_TYPE);
|
||||
hostResource = rt_RDF_MakeChildResource(gNavCenter->RDF_Receipts,
|
||||
prefixed_host,
|
||||
TRUE);
|
||||
|
||||
XP_FREE(prefixed_host);
|
||||
/* Should I name this resource here? */
|
||||
return hostResource;
|
||||
}
|
||||
|
||||
RDF_Resource
|
||||
rt_RDF_GetFormResource(RDF_Resource host,
|
||||
rt_RDF_GetReceiptResource(RDF_Resource host,
|
||||
char *url)
|
||||
{
|
||||
char *receipt_name;
|
||||
RDF_Resource receiptResource;
|
||||
|
||||
/* This needs to have a timestamp in it, too. */
|
||||
receipt_name = XP_ALLOC(XP_STRLEN(resourceID(host)) + XP_STRLEN(url) + 1);
|
||||
XP_STRCPY(receipt_name,resourceID(host));
|
||||
XP_STRCAT(receipt_name,url);
|
||||
|
||||
receiptResource = rt_RDF_MakeChildResource(host,receipt_name,TRUE);
|
||||
/* Name this receipt. */
|
||||
|
||||
XP_FREE(receipt_name);
|
||||
|
||||
return receiptResource;
|
||||
}
|
||||
|
||||
RDF_Resource
|
||||
rt_RDF_GetFormResource(RDF_Resource receipt,
|
||||
#ifdef MOCHA
|
||||
char *name,
|
||||
#endif
|
||||
char *action,
|
||||
int32 ele_cnt)
|
||||
{
|
||||
return NULL;
|
||||
char *form_name = NULL;
|
||||
char *form_url;
|
||||
RDF_Resource formResource;
|
||||
|
||||
#ifdef MOCHA
|
||||
form_name = name;
|
||||
#endif
|
||||
|
||||
if (form_name == NULL) form_name = "";
|
||||
|
||||
form_url = XP_ALLOC(XP_STRLEN(resourceID(receipt)) + XP_STRLEN(form_name) + 2);
|
||||
XP_STRCPY(form_url,resourceID(receipt));
|
||||
XP_STRCAT(form_url,"#");
|
||||
XP_STRCAT(form_url,form_name);
|
||||
|
||||
formResource =
|
||||
rt_RDF_MakeResource(receipt,
|
||||
form_url,
|
||||
TRUE,
|
||||
gCoreVocab->RDF_content);
|
||||
|
||||
XP_FREE(form_url);
|
||||
|
||||
return formResource;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
rt_countEntryBoxes(lo_DocState *top_doc_state,
|
||||
LO_FormElementStruct *ele_struct)
|
||||
{
|
||||
intn form_id;
|
||||
lo_FormData *form_list;
|
||||
lo_DocLists *doc_lists;
|
||||
int32 entry_count;
|
||||
LO_Element **elements;
|
||||
LO_Element *element;
|
||||
LO_ImageStruct *image;
|
||||
int32 element_iter;
|
||||
|
||||
if ((top_doc_state == NULL) || (ele_struct == NULL)) return -1;
|
||||
if (ele_struct->type == LO_IMAGE)
|
||||
{
|
||||
image = (LO_ImageStruct *)ele_struct;
|
||||
form_id = image->image_attr->form_id;
|
||||
} else {
|
||||
form_id = ele_struct->form_id;
|
||||
}
|
||||
|
||||
doc_lists = lo_GetDocListsById(top_doc_state, ele_struct->layer_id);
|
||||
form_list = doc_lists->form_list;
|
||||
while(form_list != NULL)
|
||||
{
|
||||
if (form_list->id == form_id)
|
||||
break;
|
||||
form_list = form_list->next;
|
||||
}
|
||||
if (form_list == NULL) return -1;
|
||||
|
||||
elements = (LO_Element **)form_list->form_elements;
|
||||
if (elements == NULL) return 0;
|
||||
entry_count = 0;
|
||||
for(element_iter = 0;
|
||||
element_iter < form_list->form_ele_cnt;
|
||||
element_iter++)
|
||||
{
|
||||
element = elements[element_iter];
|
||||
if (element == NULL) continue;
|
||||
if (element->type != LO_FORM_ELE) continue;
|
||||
if (element->lo_form.element_data == NULL) continue;
|
||||
if ((element->lo_form.element_data->type == FORM_TYPE_TEXT) &&
|
||||
!(element->lo_form.element_data->ele_text.read_only))
|
||||
entry_count++;
|
||||
}
|
||||
return entry_count;
|
||||
}
|
||||
|
||||
Bool
|
||||
rt_formIsSignificant(MWContext *ctxt,
|
||||
LO_FormElementStruct *ele_struct)
|
||||
{
|
||||
int32 doc_id;
|
||||
lo_TopState *top_state;
|
||||
|
||||
doc_id = XP_DOCID(ctxt);
|
||||
top_state = lo_FetchTopState(doc_id);
|
||||
if (top_state == NULL) return FALSE;
|
||||
|
||||
return rt_countEntryBoxes(top_state->doc_state, ele_struct) > 1;
|
||||
}
|
||||
|
||||
void
|
||||
rt_saveFormElement(MWContext *context, LO_FormElementData *ele)
|
||||
rt_saveFormElement(MWContext *context,
|
||||
LO_FormElementData *ele,
|
||||
RDF_Resource form_unit,
|
||||
int32 ele_serial)
|
||||
{
|
||||
int32 iter;
|
||||
RDF_Resource entry_unit = NULL;
|
||||
|
||||
#define E(x,y) (ele->ele_##x.y)
|
||||
#define ES(x,y) (((lo_FormElementOptionData *)ele->ele_select.options)[x].y)
|
||||
|
@ -189,19 +536,31 @@ rt_saveFormElement(MWContext *context, LO_FormElementData *ele)
|
|||
case FORM_TYPE_TEXT:
|
||||
case FORM_TYPE_PASSWORD:
|
||||
case FORM_TYPE_FILE:
|
||||
D(printf("\tgot text-type field.\n\t\tName: %s"
|
||||
"\n\t\tCurrent_Text: %s\n\t\tSize: %d\n",
|
||||
(char *)E(text,name),
|
||||
(char *)E(text,current_text),
|
||||
E(text,size))); break;
|
||||
rt_RDF_getEntryResourceText(form_unit,
|
||||
ele_serial,
|
||||
(char *)E(text,name),
|
||||
(char *)E(text,current_text),
|
||||
E(text,size));
|
||||
/* D(printf("\tgot text-type field.\n\t\tName: %s"
|
||||
"\n\t\tCurrent_Text: %s\n\t\tSize: %d\n",
|
||||
(char *)E(text,name),
|
||||
(char *)E(text,current_text),
|
||||
E(text,size))); */
|
||||
break;
|
||||
|
||||
case FORM_TYPE_RADIO:
|
||||
case FORM_TYPE_CHECKBOX:
|
||||
D(printf("\tgot toggle-type field.\n\t\tName: %s"
|
||||
"\n\t\tToggled: %d\n\t\tValue: %s\n",
|
||||
(char *)E(toggle,name),
|
||||
E(toggle,toggled),
|
||||
(char *)E(toggle,value))); break;
|
||||
rt_RDF_getEntryResourceToggle(form_unit,
|
||||
ele_serial,
|
||||
(char *)E(toggle,name),
|
||||
E(toggle,toggled),
|
||||
(char *)E(toggle,value));
|
||||
/* D(printf("\tgot toggle-type field.\n\t\tName: %s"
|
||||
"\n\t\tToggled: %d\n\t\tValue: %s\n",
|
||||
(char *)E(toggle,name),
|
||||
E(toggle,toggled),
|
||||
(char *)E(toggle,value))); */
|
||||
break;
|
||||
|
||||
case FORM_TYPE_HIDDEN:
|
||||
case FORM_TYPE_SUBMIT:
|
||||
|
@ -213,27 +572,40 @@ rt_saveFormElement(MWContext *context, LO_FormElementData *ele)
|
|||
case FORM_TYPE_SELECT_ONE:
|
||||
case FORM_TYPE_SELECT_MULT:
|
||||
{
|
||||
int iter;
|
||||
D(printf("\tgot select-type field.\n\t\tName: %s"
|
||||
"\n\t\tOption-Count: %d\n",
|
||||
(char *)E(select,name),
|
||||
E(select,option_cnt)));
|
||||
entry_unit = rt_RDF_getEntryResourceSelect(form_unit,
|
||||
ele_serial,
|
||||
(char *)E(select,name),
|
||||
E(select,option_cnt));
|
||||
/* D(printf("\tgot select-type field.\n\t\tName: %s"
|
||||
"\n\t\tOption-Count: %d\n",
|
||||
(char *)E(select,name),
|
||||
E(select,option_cnt))); */
|
||||
for(iter = 0; iter < E(select,option_cnt); iter++)
|
||||
{
|
||||
D(printf("\t\tsubelement.\n\t\t\t"
|
||||
"Text_value: %s\n\t\t\t"
|
||||
"Value: %s\n\t\t\tSelected: %d\n",
|
||||
(char *)ES(iter,text_value),
|
||||
(char *)ES(iter,value),
|
||||
ES(iter,selected)));
|
||||
rt_RDF_chainSubelement(entry_unit,
|
||||
iter,
|
||||
(char *)ES(iter,text_value),
|
||||
(char *)ES(iter,value),
|
||||
ES(iter,selected));
|
||||
|
||||
/* D(printf("\t\tsubelement.\n\t\t\t"
|
||||
"Text_value: %s\n\t\t\t"
|
||||
"Value: %s\n\t\t\tSelected: %d\n",
|
||||
(char *)ES(iter,text_value),
|
||||
(char *)ES(iter,value),
|
||||
ES(iter,selected))); */
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FORM_TYPE_TEXTAREA:
|
||||
D(printf("\tgot textarea-type field.\n\t\tName: %s"
|
||||
"\n\t\tCurrent_text: %s\n",
|
||||
(char *)E(textarea, name),
|
||||
(char *)E(textarea, current_text)));
|
||||
rt_RDF_getEntryResourceArea(form_unit,
|
||||
ele_serial,
|
||||
(char *)E(textarea,name),
|
||||
(char *)E(textarea,current_text));
|
||||
/* D(printf("\tgot textarea-type field.\n\t\tName: %s"
|
||||
"\n\t\tCurrent_text: %s\n",
|
||||
(char *)E(textarea, name),
|
||||
(char *)E(textarea, current_text))); */
|
||||
break;
|
||||
case FORM_TYPE_ISINDEX:
|
||||
case FORM_TYPE_IMAGE:
|
||||
|
@ -249,23 +621,23 @@ rt_saveFormElement(MWContext *context, LO_FormElementData *ele)
|
|||
void
|
||||
rt_saveFormElements(MWContext *context,
|
||||
lo_FormData *form,
|
||||
RDF_Resource host_resource)
|
||||
RDF_Resource receipt_unit)
|
||||
{
|
||||
LO_Element **elements;
|
||||
LO_Element *element;
|
||||
int32 element_iter;
|
||||
RDF_Resource form_resource;
|
||||
RDF_Resource form_unit;
|
||||
|
||||
|
||||
if (form == NULL) return;
|
||||
elements = (LO_Element **)form->form_elements;
|
||||
if (elements == NULL) return;
|
||||
form_resource = rt_RDF_GetFormResource(host_resource,
|
||||
form_unit = rt_RDF_GetFormResource(receipt_unit,
|
||||
#ifdef MOCHA
|
||||
(char *)form->name,
|
||||
(char *)form->name,
|
||||
#endif /* MOCHA */
|
||||
(char *)form->action,
|
||||
form->form_ele_cnt);
|
||||
(char *)form->action,
|
||||
form->form_ele_cnt);
|
||||
|
||||
|
||||
|
||||
|
@ -275,27 +647,30 @@ rt_saveFormElements(MWContext *context,
|
|||
element = elements[element_iter];
|
||||
if (element == NULL) continue;
|
||||
if (element->type != LO_FORM_ELE) continue;
|
||||
rt_saveFormElement(context, element->lo_form.element_data);
|
||||
rt_saveFormElement(context,
|
||||
element->lo_form.element_data,
|
||||
form_unit,
|
||||
element_iter);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rt_saveFormList (MWContext *context,
|
||||
lo_FormData *form_list,
|
||||
RDF_Resource host_resource)
|
||||
RDF_Resource receipt_unit)
|
||||
{
|
||||
lo_FormData *form = form_list;
|
||||
|
||||
while(form != NULL)
|
||||
{
|
||||
{
|
||||
D(printf("iterating over form %d\n",form->id));
|
||||
#ifdef MOCHA
|
||||
D(printf(" -- it is named %s\n",(char *)form->name));
|
||||
#endif
|
||||
D(printf(" -- it has %d elements\n",form->form_ele_cnt));
|
||||
rt_saveFormElements(context,form,host_resource);
|
||||
rt_saveFormElements(context,form,receipt_unit);
|
||||
form = form->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -308,8 +683,8 @@ RT_SaveDocument (MWContext *context, LO_FormElementStruct *form_element)
|
|||
lo_TopState *top_state;
|
||||
lo_DocLists *doc_lists;
|
||||
lo_FormData *form_list;
|
||||
char *url;
|
||||
RDF_Resource host_unit;
|
||||
char *url, *hostname;
|
||||
RDF_Resource host_unit = NULL, receipt_unit = NULL;
|
||||
|
||||
|
||||
|
||||
|
@ -323,7 +698,7 @@ RT_SaveDocument (MWContext *context, LO_FormElementStruct *form_element)
|
|||
* See if the form is significant.
|
||||
*/
|
||||
D(printf("Transaction Receipts: Checking Significance: "));
|
||||
if (!rt_formIsSignificant(context,form_element))
|
||||
if (!prvcy_formIsSignificant(context,form_element))
|
||||
{
|
||||
D(printf("failed.\n"));
|
||||
return;
|
||||
|
@ -344,14 +719,37 @@ RT_SaveDocument (MWContext *context, LO_FormElementStruct *form_element)
|
|||
return;
|
||||
}
|
||||
|
||||
url = NET_ParseURL(top_state->url, GET_PROTOCOL_PART | GET_HOST_PART |
|
||||
url = NET_ParseURL(top_state->url, /* GET_PROTOCOL_PART | GET_HOST_PART | */
|
||||
GET_PATH_PART);
|
||||
|
||||
D(printf("Processing URL: %s\n",url));
|
||||
|
||||
host_unit = rt_RDF_GetHostResource(url);
|
||||
hostname = NET_ParseURL(top_state->url, GET_HOST_PART);
|
||||
|
||||
if (!host_unit) {
|
||||
PROFILING_START
|
||||
|
||||
D(printf("Initializing RDF db.\n"));
|
||||
|
||||
RDF_START
|
||||
|
||||
gRDFDB = RDF_GetDB((const char **)gRdfDbStr);
|
||||
|
||||
RDF_END
|
||||
|
||||
if (!gRDFDB)
|
||||
/* XXX Error Message */
|
||||
return;
|
||||
|
||||
D(printf("Processing URL: %s\n",url));
|
||||
D(printf("Requesting Host Resource for: %s\n",hostname));
|
||||
|
||||
if (hostname)
|
||||
host_unit = rt_RDF_GetHostResource(hostname);
|
||||
|
||||
|
||||
/* This should also pass in the doc title -- where do I get that?? */
|
||||
if (host_unit)
|
||||
receipt_unit = rt_RDF_GetReceiptResource(host_unit,RT_STR_NOTNULL(url));
|
||||
|
||||
if (!receipt_unit) {
|
||||
D(printf("Unable to get RDF Host Unit!\n"));
|
||||
/* XXX -- BUG BUG BUG -- Move me to allxpstr */
|
||||
FE_Alert(context,"Running low on memory -- \n"
|
||||
|
@ -359,7 +757,6 @@ RT_SaveDocument (MWContext *context, LO_FormElementStruct *form_element)
|
|||
"for this transaction.");
|
||||
}
|
||||
|
||||
|
||||
/* D(printf("processing base document\n")); */
|
||||
/* rt_saveFormList(context,top_state->doc_lists.form_list); */
|
||||
|
||||
|
@ -371,9 +768,42 @@ RT_SaveDocument (MWContext *context, LO_FormElementStruct *form_element)
|
|||
XP_ASSERT(layer_state->doc_lists);
|
||||
doc_lists = layer_state->doc_lists;
|
||||
form_list = doc_lists->form_list;
|
||||
rt_saveFormList(context,form_list,host_unit);
|
||||
rt_saveFormList(context,form_list,receipt_unit);
|
||||
}
|
||||
|
||||
D(printf("Releasing RDF db.\n"));
|
||||
|
||||
RDF_START
|
||||
|
||||
RDF_ReleaseDB(gRDFDB);
|
||||
|
||||
RDF_END
|
||||
|
||||
PROFILING_END
|
||||
|
||||
gRDFDB = NULL;
|
||||
|
||||
XP_FREE(url);
|
||||
XP_FREE(hostname);
|
||||
|
||||
|
||||
}
|
||||
|
||||
PUBLIC Bool
|
||||
RT_GetMakeReceiptToggle(MWContext *m_context)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
PUBLIC Bool
|
||||
RT_GetMakeReceiptEnabled(MWContext *m_context)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
PUBLIC Bool
|
||||
RT_ToggleMakeReceipt(MWContext *m_context)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче