Beispiel #1
0
PRBool
MoveMessage (char* to, char* from, MM message) {
  RDFT todb = getBFTranslator(to);
  RDFT fromdb = getBFTranslator(from);
  MF tom = todb->pdata;
  MF fom = fromdb->pdata;
  RDF_Resource r;
  MM newMsg = (MM)getMem(sizeof(struct MailMessage));
  char* buffer = getMem(BUFF_SIZE);
  if (!buffer) return 0;
  setMessageFlag(fromdb, message->r, "0008"); 
  fseek(tom->mfile, 0L, SEEK_END);
  fseek(fom->mfile, message->offset, SEEK_SET);
  fputs("From -\n", tom->mfile);
  sprintf(buffer, "mailbox://%s?%d", &to[17], ftell(tom->mfile));
  r = RDF_GetResource(NULL, buffer, 1);
  newMsg->subject = copyString(message->subject);
  newMsg->from = copyString(message->from);
  newMsg->date = copyString(message->date);
  newMsg->r = r;
  r->pdata = newMsg;
  setResourceType(r, PM_RT);        
  newMsg->summOffset = -1;
  newMsg->offset = ftell(tom->mfile);
  writeMsgSum(tom, newMsg);
  addMsgToFolder (tom, newMsg) ;
  fflush(tom->sfile);
  while (fgets(buffer, BUFF_SIZE, fom->mfile) && strncmp("From ", buffer, 5)) {
    fputs(buffer, tom->mfile);
  }
  sendNotifications2(todb, RDF_ASSERT_NOTIFY, r, gCoreVocab->RDF_parent, tom->top, 
                     RDF_RESOURCE_TYPE, 1);       
  sendNotifications2(fromdb, RDF_DELETE_NOTIFY, message->r, gCoreVocab->RDF_parent, fom->top, 
                     RDF_RESOURCE_TYPE, 1);       
  freeMem(buffer);
  return 1;
}
Beispiel #2
0
void 
RDF_FinishMessageDelivery (RDFT rdf)
{
  MF folder = (MF) rdf->pdata;
  MM msg    = folder->add;
  folder->add = NULL;
  addMsgToFolder(folder, msg);
  setResourceType(msg->r, PM_RT);
  fseek(folder->sfile, 0L, SEEK_END);
  msg->summOffset = ftell(folder->sfile);
  writeMsgSum(folder, msg);
  fseek(folder->mfile, 0L, SEEK_END);
  fputs("\n", folder->mfile);
  sendNotifications2(rdf, RDF_ASSERT_NOTIFY, msg->r, gCoreVocab->RDF_parent, folder->top, 
                     RDF_RESOURCE_TYPE, 1);       
}
Beispiel #3
0
Assertion
histAddParent (RDF_Resource child, RDF_Resource parent)
{
  Assertion nextAs, prevAs, newAs; 
  RDF_Resource s = gCoreVocab->RDF_parent;
  RDF_ValueType type = RDF_RESOURCE_TYPE;
  nextAs = prevAs = child->rarg1;
  while (nextAs != null) {
    if (asEqual(nextAs, child, s, parent, type)) return null;
    prevAs = nextAs;
    nextAs = nextAs->next;
  }
  newAs = makeNewAssertion(child, s, parent, type, 1);
  if (prevAs == null) {
    child->rarg1 = newAs;
  } else {
    prevAs->next = newAs;
  }
  nextAs = prevAs = parent->rarg2;
  if (nextAs == NULL) {
    parent->rarg2 = newAs;
  } else {
    PRBool added = 0;
    while (nextAs != null) {
		char* nid =  resourceID(nextAs->u);
      if (strcmp( resourceID(child),  resourceID(nextAs->u)) > 0) {
	if (prevAs == nextAs) {
	  newAs->invNext = prevAs;
	  parent->rarg2  = newAs;
	  added = 1;
	  break;
	  } else {
	    newAs->invNext = nextAs;	    
	    prevAs->invNext = newAs;
	    added = 1;
	    break;
	  }
      } 
      prevAs = nextAs;
      nextAs = nextAs->invNext;
    }
    if (!added) prevAs->invNext = newAs;
  }
  sendNotifications2(gHistoryStore, RDF_ASSERT_NOTIFY, child, s, parent, type, 1);
  /* XXX have to mark the entire subtree XXX */
  /*  sendNotifications(gRemoteStore->rdf, RDF_ASSERT_NOTIFY, child, s, parent, type, 1); */
}
Beispiel #4
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;
}
Beispiel #5
0
PRBool
ESDBRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
{
  Assertion nextAs, prevAs,  ans;
  PRBool found = false;
  nextAs = prevAs = u->rarg1;
  while (nextAs != null) {
    if (asEqual(nextAs, u, s, v, type)) {
      if (prevAs == null) {
	u->rarg1 = nextAs->next;
      } else {
	prevAs->next = nextAs->next;
      }
      found = true;
      ans = nextAs;
      break;
    }
    prevAs = nextAs;
    nextAs = nextAs->next; 
  }
  if (found == false) return false;
  if (type == RDF_RESOURCE_TYPE) {
    nextAs = prevAs = ((RDF_Resource)v)->rarg2;
    while (nextAs != null) {
      if (nextAs == ans) {
	if (prevAs == nextAs) {
	  ((RDF_Resource)v)->rarg2 =  nextAs->invNext;
	} else {
	  prevAs->invNext = nextAs->invNext;
	}
      }
      prevAs = nextAs;
      nextAs = nextAs->invNext;
    }
  }
  sendNotifications2(rdf, RDF_DELETE_NOTIFY, u, s, v, type, 1);
  return true;
}
Beispiel #6
0
PRBool
ESDBAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, 
		RDF_ValueType type)
{
  Assertion nextAs, prevAs, newAs; 
  if ((s == gCoreVocab->RDF_instanceOf) && (v == gWebData->RDF_Container)) {
    setContainerp(u, true);
    return 1;
  }
 	
  nextAs = prevAs = u->rarg1;
  while (nextAs != null) {
    if (asEqual(nextAs, u, s, v, type)) return 1;
    prevAs = nextAs;
    nextAs = nextAs->next;
  }
  newAs = makeNewAssertion(u, s, v, type, 1);
  if (prevAs == null) {
    u->rarg1 = newAs;
  } else {
    prevAs->next = newAs;
  }
  if (type == RDF_RESOURCE_TYPE) {
    nextAs = prevAs = ((RDF_Resource)v)->rarg2;
    while (nextAs != null) {
      prevAs = nextAs;
      nextAs = nextAs->invNext;
    }
    if (prevAs == null) {
      ((RDF_Resource)v)->rarg2 = newAs;
    } else {
      prevAs->invNext = newAs;
    }
  }
  sendNotifications2(rdf, RDF_ASSERT_NOTIFY, u, s, v, type, 1);
  return true;
}