Ejemplo n.º 1
0
static int
MimeInlineTextVCard_parse_line (const char *line, int32_t length, MimeObject *obj)
{
  // This routine gets fed each line of data, one at a time.
  char* linestring;
  MimeInlineTextVCardClass *clazz = ((MimeInlineTextVCardClass *) obj->clazz);

  if (!obj->output_p) return 0;
  if (!obj->options || !obj->options->output_fn) return 0;
  if (!obj->options->write_html_p)
  {
    return COM_MimeObject_write(obj, line, length, true);
  }

  linestring = (char *) PR_MALLOC (length + 1);
  memset(linestring, 0, (length + 1));

  if (linestring)
  {
    strcpySafe((char *)linestring, line, length + 1);
    NS_MsgSACat (&clazz->vCardString, linestring);
    PR_Free (linestring);
  }

  return 0;
}
Ejemplo n.º 2
0
static int
MimeInlineTextSMIMEStub_parse_eof (MimeObject *obj, bool abort_p)
{
  if (obj->closed_p)
    return 0;

  /* Run parent method first, to flush out any buffered data. */
  int status = ((MimeObjectClass*)COM_GetmimeInlineTextClass())->parse_eof(obj, abort_p);
  if (status < 0)
    return status;

  if (  (obj->options) &&
        ((obj->options->format_out == nsMimeOutput::nsMimeMessageQuoting) ||
         (obj->options->format_out == nsMimeOutput::nsMimeMessageBodyQuoting))
     )
    return 0;

  char* html = NULL;
  status = GenerateMessage(&html);
  if (status < 0)
    return status;

  status = COM_MimeObject_write(obj, html, PL_strlen(html), true);
  PR_FREEIF(html);
  if (status < 0)
    return status;

  return 0;
}
Ejemplo n.º 3
0
static int EndVCard (MimeObject *obj)
{
  int status = 0;

  /* Scribble HTML-ending stuff into the stream */
  char htmlFooters[32];
  PR_snprintf (htmlFooters, sizeof(htmlFooters), "</BODY>%s</HTML>%s", MSG_LINEBREAK, MSG_LINEBREAK);
  status = COM_MimeObject_write(obj, htmlFooters, strlen(htmlFooters), false);

  if (status < 0) return status;

  return 0;
}
Ejemplo n.º 4
0
static int BeginVCard (MimeObject *obj)
{
  int status = 0;

  /* Scribble HTML-starting stuff into the stream */
  char htmlHeaders[32];

  s_unique++;
  PR_snprintf (htmlHeaders, sizeof(htmlHeaders), "<HTML>%s<BODY>%s", MSG_LINEBREAK, MSG_LINEBREAK);
    status = COM_MimeObject_write(obj, htmlHeaders, strlen(htmlHeaders), true);

  if (status < 0) return status;

  return 0;
}
Ejemplo n.º 5
0
static int
MimeInlineTextSMIMEStub_parse_line(const char *line, PRInt32 length, MimeObject *obj)
{
 /*
  * This routine gets fed each line of data, one at a time. We just buffer
  * it all up, to be dealt with all at once at the end.
  */
  if (!obj->output_p || !obj->options || !obj->options->output_fn)
    return 0;

  if (!obj->options->write_html_p)
    return COM_MimeObject_write(obj, line, length, true);

  return 0;
}
Ejemplo n.º 6
0
static int GenerateVCardData(MimeObject * aMimeObj, VObject* aVcard)
{
  // style is driven from CSS not here. Just layout the minimal vCard data
  nsCString vCardOutput;

  vCardOutput = "<table class=\"moz-vcard-table\"> <tr> ";  // outer table plus the first (and only row) we use for this table

  // we need to get an escaped vCard url to bind to our add to address book button
  nsCOMPtr<nsIMsgVCardService> vCardService = do_GetService(MSGVCARDSERVICE_CONTRACT_ID);
  if (!vCardService)
      return -1;

  nsAutoCString vCard;
  nsAutoCString vEscCard;
  int len = 0;

  vCard.Adopt(vCardService->WriteMemoryVObjects(0, &len, aVcard, false));
  MsgEscapeString(vCard, nsINetUtil::ESCAPE_XALPHAS, vEscCard);

  // first cell in the outer table row is a clickable image which brings up the rich address book UI for the vcard
  vCardOutput += "<td valign=\"top\"> <a class=\"moz-vcard-badge\" href=\"addbook:add?action=add?vcard=";
  vCardOutput += vEscCard; // the href is the vCard
  vCardOutput += "\"></a></td>";

  // the 2nd cell in the outer table row is a nested table containing the actual vCard properties
  vCardOutput += "<td> <table id=\"moz-vcard-properties-table\"> <tr> ";

  OutputBasicVcard(aMimeObj, aVcard, vCardOutput);

  // close the properties table
  vCardOutput += "</table> </td> ";

  // 2nd  cell in the outer table is our vCard image

  vCardOutput += "</tr> </table>";

  // now write out the vCard
  return COM_MimeObject_write(aMimeObj, (char *) vCardOutput.get(), vCardOutput.Length(), true);
}