Esempio n. 1
0
void
parseNextBkToken (RDFFile f, char* token)
{
 /*	printf(token); */
  if (token[0] == '<') {
    bkStateTransition(f, token);
  } else {
    /* ok, we have a piece of content.
       can be the title, or a description or */
    if ((f->status == IN_TITLE) || (f->status == IN_H3) || 
	(f->status == IN_ITEM_TITLE)) {
      if (IN_H3 && gBkFolderDate) {
	char url[150];
	RDF_Resource newFolder;
	sprintf(url, "%s%s.rdf", gBkFolderDate, token);
	newFolder = createContainer(url);
	addSlotValue(f,newFolder, gCoreVocab->RDF_parent, f->stack[f->depth-1], 
		     RDF_RESOURCE_TYPE, true);
	freeMem(gBkFolderDate);
	gBkFolderDate = NULL;
	f->lastItem = newFolder;
      }
      addSlotValue(f, f->lastItem, gCoreVocab->RDF_name, 
		   copyString(token), RDF_STRING_TYPE, true);
      if (startsWith("Personal Toolbar", token) && (containerp(f->lastItem)))
	nlocalStoreAssert(gLocalStore, f->lastItem, gCoreVocab->RDF_instanceOf, 
			  gNavCenter->RDF_PersonalToolbarFolderCategory, 
			  RDF_RESOURCE_TYPE, true);
    } else if (f->status == IN_ITEM_DESCRIPTION) {
      addDescription(f, f->lastItem, token);
    }
  }
}
Esempio n. 2
0
void
newLeafBkItem (RDFFile f, char* token)
{
  char* url = NULL;
  char* addDate = NULL;
  char* lastVisit = NULL;
  char* lastModified = NULL;
  uint8 current = 0;
  int32 len = strlen(token); 
  int32 n = 0;
  char c = token[n++];
  PRBool inString = false;
  RDF_Resource newR;
  
  while (n < len) {
    if (c == '"') {
      if (inString) {
	token[n-1] = '\0';
	inString = false;
      } else {
	inString = true;
	if (current == 0) {
	  url = &token[n];
	} else if (current == 1) {
	  addDate = &token[n];
	} else if (current == 2) {
	  lastVisit = &token[n];
	} else if (current == 3) {
	  lastModified = &token[n];
	}
	current++;
      }
    }
    c = token[n++];
  }
  if (url == NULL) return;
  newR = RDF_GetResource(NULL, url, true);
  addSlotValue(f, newR, gCoreVocab->RDF_parent, f->stack[f->depth-1],  
	       RDF_RESOURCE_TYPE, true);
  /* addSlotValue(f, newR, gWebData->RDF_URL, (void*)copyString(url), 
	       RDF_STRING_TYPE, true); */
  if (addDate != NULL)
    {
      addSlotValue(f, newR, gNavCenter->RDF_bookmarkAddDate, (void*)copyString(addDate), 
	       RDF_STRING_TYPE, true);
    }
  if (lastVisit != NULL)
    {
      addSlotValue(f, newR, gWebData->RDF_lastVisitDate, (void*)copyString(lastVisit), 
	       RDF_STRING_TYPE, true);
    }
  if (lastModified != NULL)
    {
      addSlotValue(f, newR, gWebData->RDF_lastModifiedDate, (void*)copyString(lastModified),
	       RDF_STRING_TYPE, true);
    }
  f->lastItem = newR;
}
Esempio n. 3
0
void
addDescription (RDFFile f, RDF_Resource r, char* token)
{
  char* desc = (char*)  nlocalStoreGetSlotValue(gLocalStore, r, gWebData->RDF_description, 
				       RDF_STRING_TYPE, false, true);
  if (desc == NULL) {
    addSlotValue(f, f->lastItem, gWebData->RDF_description, copyString(token),
		 RDF_STRING_TYPE, true);
  } else {
   addSlotValue(f, f->lastItem, gWebData->RDF_description, 
		 append2Strings(desc, token), RDF_STRING_TYPE, true); 
    nlocalStoreUnassert(gLocalStore, f->lastItem, gWebData->RDF_description, desc, RDF_STRING_TYPE);
  }
}
Esempio n. 4
0
void
bkStateTransition (RDFFile f, char* token)
{
  if (startsWith("<A", token)) {
    newLeafBkItem(f, token);
    f->status = IN_ITEM_TITLE;
  } else if (startsWith(OPEN_H3_STRING, token)) {
    newFolderBkItem(f, token);
    f->status = IN_H3;
  } else if (startsWith(OPEN_TITLE_STRING, token)) {
    f->status = IN_TITLE;
  } else if (startsWith(OPEN_H3_STRING, token)) {
    f->status = IN_H3;
  } else if (startsWith(DD_STRING, token)) {
    if (nlocalStoreGetSlotValue(gLocalStore, f->lastItem, gWebData->RDF_description, 
				RDF_STRING_TYPE, false, true) 
		== NULL) f->status = IN_ITEM_DESCRIPTION;
  } else if (startsWith(OPEN_DL_STRING, token)) {
    f->stack[f->depth++] = f->lastItem;
  } else if (startsWith(CLOSE_DL_STRING, token)) {
    f->depth--;
  } else if (startsWith("<HR>", token)) {
    addSlotValue(f, createSeparator(), gCoreVocab->RDF_parent, f->stack[f->depth-1], 
		 RDF_RESOURCE_TYPE, true);
    f->status = 0;
  } else if ((f->status == IN_ITEM_DESCRIPTION) && (startsWith("<BR>", token))) {
    addDescription(f, f->lastItem, token);
  } else f->status = 0;
}
Esempio n. 5
0
void
resourceTransition (RDFFile f)
{
  if ((f->currentResource)  && (!f->genlAdded))
    addSlotValue(f, f->currentResource, gCoreVocab->RDF_parent, f->rtop, 
		 RDF_RESOURCE_TYPE, NULL); 
  f->genlAdded = false;
}
Esempio n. 6
0
void
assignSlot (RDF_Resource u, char* slot, char* value, RDFFile f)
{
  PRBool tv = true;
  char* tvstr;
  if (value[0] == '(') {
    tv = false;
    value = &value[1];
    value[strlen(value)-1] = '\0';
  } 

  if (tv) {
    tvstr = "true";
  } else tvstr = "false";

  if (startsWith("default_genl", slot)) return;
  
  if (startsWith("name", slot) || (startsWith("local-name", slot))) { 
    value[strlen(value)-1] = '\0';
    addSlotValue(f, u, gCoreVocab->RDF_name, copyString(&value[1]), RDF_STRING_TYPE, tvstr);  
  }  else if (startsWith("specs", slot) || (startsWith("child", slot))) {
    RDF_Resource spec = resolveReference(value, f);  
    if (!nullp(spec)) addSlotValue(f, spec, gCoreVocab->RDF_parent, u, RDF_RESOURCE_TYPE, tvstr); 
  }  else if (startsWith("genls_pos", slot)) {
    RDF_Resource genl = resolveGenlPosReference(value, f);  
    if (!nullp(genl)) addSlotValue(f, u, gCoreVocab->RDF_parent, genl, RDF_RESOURCE_TYPE, tvstr);
  }  else if ((startsWith("genls", slot)) || (startsWith("parent", slot))) {
    RDF_Resource genl = resolveReference(value, f);
    if (!nullp(genl)) addSlotValue(f, u, gCoreVocab->RDF_parent, genl, RDF_RESOURCE_TYPE, tvstr);
  } else {
    void* parsed_value;
    RDF_ValueType data_type;
    RDF_Resource s = RDF_GetResource(NULL, slot, true);
    RDF_Error err = parseSlotValue(f, s, value, &parsed_value, &data_type); 
    if ((err == noRDFErr) && (!nullp(parsed_value)))   
      addSlotValue(f, u, s, parsed_value, data_type, tvstr);
  } 
}