Exemplo 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);
    }
  }
}
Exemplo n.º 2
0
void
PopGetNewMail (RDF_Resource r)
{
  if (containerp(r) && (resourceType(r) == PM_RT)) {
    MF folder = (MF) r->pdata;
    GetPopToRDF(folder->rdf);
  }
}
Exemplo n.º 3
0
void
possiblyAccessES(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
{
   if ((ESFTPRT(u)) && 
       (s == gCoreVocab->RDF_parent) && (containerp(u))) {
     char* id =  resourceID(u);
     readRDFFile((resourceType(u) == ES_RT ? &id[4] : id), u, false);
   }
}
Exemplo n.º 4
0
void
es_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx)
{
	RDF_Resource		parent = NULL, child = NULL, r;
	_esFEData		*feData;
	char			*newURL, *p;

	feData = (_esFEData *)urls->fe_data;
	if ((status >= 0) && (feData != NULL))
	{
		parent = RDF_GetResource(gNCDB, feData->parent, false);
		child = RDF_GetResource(gNCDB, feData->child, false);
		if ((parent != NULL) && (child != NULL))
		{
			switch(feData->method)
			{
				case	URL_POST_METHOD:
				if (((p = strrchr(resourceID(child), '/')) != NULL) && (*++p != '\0'))
				{
					if ((newURL = append2Strings(resourceID(parent), p)) != NULL)
					{
						if ((r = RDF_GetResource(gNCDB, newURL, 1)) != NULL)
						{
							setContainerp(r, containerp(child));
							setResourceType(r, resourceType(child));
						
							remoteStoreAdd(gRemoteStore, r,
								gCoreVocab->RDF_parent, parent,
								RDF_RESOURCE_TYPE, 1);
						}
						freeMem(newURL);
					}
				}
				break;

				case	URL_DELETE_METHOD:
				remoteStoreRemove(gRemoteStore, child,
					gCoreVocab->RDF_parent, parent,
					RDF_RESOURCE_TYPE);
				break;
			}
		}
	}
	else if (status < 0)
	{
		if ((cx != NULL) && (urls != NULL) && (urls->error_msg != NULL))
		{
			FE_Alert(cx, urls->error_msg);
		}
	}
	if (feData != NULL)
	{
		esFreeFEData(feData);
	}
        NET_FreeURLStruct (urls);
}
Exemplo n.º 5
0
PRBool
ESUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, 
		   RDF_ValueType type)
{
  if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE)  &&
      (ESFTPRT((RDF_Resource)v)) &&
      (containerp((RDF_Resource)v))) {
    ESRemoveChild((RDF_Resource)v, u);
  } else {
    return 0;
  }
}
Exemplo n.º 6
0
PRBool
pmRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
{
  XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
  if ((startsWith("mailbox://", rdf->url)) && (resourceType(u) == PM_RT) && (s == gCoreVocab->RDF_parent)
      && (type == RDF_RESOURCE_TYPE)) {
    RDF_Resource mbox = (RDF_Resource) v;
    if (!(containerp(mbox) && (resourceType(mbox) == PM_RT))) {
      return false;
    } else {
      MF folder = (MF)mbox->pdata;
      sendNotifications2(rdf, RDF_DELETE_NOTIFY, u, s, v, type, 1);
      MoveMessage(folder->trash, resourceID(mbox), (MM)u->pdata);
      return 1;
    }
  } else return false;
}
Exemplo n.º 7
0
int
ldapModifyEntry (RDFT rdf, RDF_Resource parent, RDF_Resource child, PRBool addFlag)
{
	RDF_Cursor	c;
	RDF_Resource	newParent, r;
	char		*urivals[2];
	LDAP		*ld;
	LDAPMod		urimod, *mods[2];
	LDAPURLDesc	*ldURL=NULL;
	int		err;
	char		*errStr, *parentID;

	parentID = resourceID(parent);

	if (containerp(child))
	{
		if (newParent = ldapNewContainer(parentID))
		{
			if ((c = RDF_GetSources(rdf->rdf->rdf, child,
				gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, 1)) != NULL)
			{
				while ((r = RDF_NextValue(c)) != NULL)
				{
					err = ldapModifyEntry(rdf, newParent, r, addFlag);
					if (err)
					{
						/* XXX MAJOR rollback issues!
							Punt for now! */

						return(err);
					}
				}
			}
			else
			{
				return(-1);
			}
		}
		else
		{
			return(-1);
		}
	}

	ldap_url_parse(parentID, &ldURL);
	if (ldURL == NULL)	return(-1);
	ld = ldap_init (ldURL->lud_host, ldURL->lud_port);
	if (ld == NULL)
	{
		ldap_free_urldesc(ldURL);
		return(-1);
	}
	if ((err = ldap_simple_bind_s(ld, ADMIN_ID, ADMIN_PW))		/* XXX */
		!= LDAP_SUCCESS)
	{
		if ((errStr = ldap_err2string(err)) != NULL)
		{
			XP_MakeHTMLAlert(NULL, errStr);
		}

		ldap_unbind(ld);
		ldap_free_urldesc(ldURL);
		return(-1);
	}

	urivals[0] = resourceID(child);
	urivals[1] = NULL;

	urimod.mod_op = ((addFlag == true) ? LDAP_MOD_ADD : LDAP_MOD_DELETE);
	urimod.mod_type = "labeledURI";
	urimod.mod_values = urivals;

	mods[0] = &urimod;
	mods[1] = NULL;

	err = ldap_modify_s(ld, ldURL->lud_dn, mods);
	if (err != LDAP_SUCCESS)
	{
		if ((errStr = ldap_err2string(err)) != NULL)
		{
			XP_MakeHTMLAlert(NULL, errStr);
		}
	}

	ldap_unbind(ld);
	ldap_free_urldesc(ldURL);
	return(err);
}
Exemplo n.º 8
0
void
HT_WriteOutAsBookmarks1 (RDF rdf, PRFileDesc *fp, RDF_Resource u, RDF_Resource top, int indent)
{
    RDF_Cursor c = RDF_GetSources(rdf, u, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true);
    RDF_Resource next;
    char *date, *name, *url;
    int loop;

    if (c == NULL) return;
    if (u == top) {
      name = RDF_GetResourceName(rdf, u);
      ht_rjcprintf(fp, "<!DOCTYPE NETSCAPE-Bookmark-file-1>\n", NULL);
      ht_rjcprintf(fp, "<!-- This is an automatically generated file.\n", NULL);
      ht_rjcprintf(fp, "It will be read and overwritten.\n", NULL);
      ht_rjcprintf(fp, "Do Not Edit! -->\n", NULL);

      ht_rjcprintf(fp, "<TITLE>%s</TITLE>\n", (name) ? name:"");
      ht_rjcprintf(fp, "<H1>%s</H1>\n<DL><p>\n", (name) ? name:"");
    }
    while (next = RDF_NextValue(c)) {

      url = resourceID(next);
      if (containerp(next) && (!startsWith("ftp:",url)) && (!startsWith("file:",url))
	    && (!startsWith("IMAP:", url)) && (!startsWith("nes:", url))
	    && (!startsWith("mail:", url)) && (!startsWith("cache:", url))
	    && (!startsWith("ldap:", url))) {
		for (loop=0; loop<indent; loop++)	ht_rjcprintf(fp, "    ", NULL);

		date = numericDate(resourceID(next));
		ht_rjcprintf(fp, "<DT><H3 ADD_DATE=\"%s\">", (date) ? date:"");
		if (date) freeMem(date);
		name = RDF_GetResourceName(rdf, next);
		ht_rjcprintf(fp, "%s</H3>\n", name);

		for (loop=0; loop<indent; loop++)	ht_rjcprintf(fp, "    ", NULL);
		ht_rjcprintf(fp, "<DL><p>\n", NULL);
		HT_WriteOutAsBookmarks1(rdf, fp, next, top, indent+1);

		for (loop=0; loop<indent; loop++)	ht_rjcprintf(fp, "    ", NULL);

		ht_rjcprintf(fp, "</DL><p>\n", NULL);
      }
      else if (isSeparator(next)) {
	for (loop=0; loop<indent; loop++)	ht_rjcprintf(fp, "    ", NULL);
	ht_rjcprintf(fp, "<HR>\n", NULL);
      }
      else {
	char* bkAddDate = (char*)RDF_GetSlotValue(rdf, next, 
						  gNavCenter->RDF_bookmarkAddDate, 
						  RDF_STRING_TYPE, false, true);

        for (loop=0; loop<indent; loop++)	ht_rjcprintf(fp, "    ", NULL);

	ht_rjcprintf(fp, "<DT><A HREF=\"%s\" ", resourceID(next));
	date = numericDate(bkAddDate);
	ht_rjcprintf(fp, "ADD_DATE=\"%s\" ", (date) ? date: "");
	if (date) freeMem(date);
	ht_rjcprintf(fp, "LAST_VISIT=\"%s\" ", resourceLastVisitDate(rdf, next));
	ht_rjcprintf(fp, "LAST_MODIFIED=\"%s\">", resourceLastModifiedDate(rdf, next));
	ht_rjcprintf(fp, "%s</A>\n", RDF_GetResourceName(rdf, next));

	if (resourceDescription(rdf, next) != NULL) {
	  ht_rjcprintf(fp, "<DD>%s\n", resourceDescription(rdf, next));
	}
      }
    }
    RDF_DisposeCursor(c);
    if (u == top) {
      ht_rjcprintf(fp, "</DL>\n", NULL);
    }
}