Bug #242988 --> land thunderbird specific rendering for vCards inline with the message. The changes to mimevcrd

should effect thunderbird only.
This commit is contained in:
scott%scott-macgregor.org 2004-05-24 00:10:25 +00:00
parent 701fb9a70f
commit de1e0482af
4 changed files with 435 additions and 34 deletions

View File

@ -7,6 +7,7 @@ classic.jar:
+ skin/classic/messenger/primaryToolbar.css (primaryToolbar.css)
+ skin/classic/messenger/accountCentral.css (accountCentral.css)
+ skin/classic/messenger/messageHeader.css (messageHeader.css)
+ skin/classic/messenger/messageBody.css (messageBody.css)
+ skin/classic/messenger/mailWindow1.css (mailWindow1.css)
+ skin/classic/messenger/junkMail.css (junkMail.css)
+ skin/classic/messenger/folderMenus.css (folderMenus.css)

View File

@ -263,9 +263,51 @@ span.moz-smiley-s16 {
background-image: url("chrome://communicator/skin/icons/smileys/smiley-sealed.png");
}
/* ::::: vcard ::::: */
.moz-vcard-table {
-moz-border-radius: 8px;
border: thin solid gray;
margin-top: 10px;
}
.moz-vcard-property {
font-size: 80%;
color: gray;
}
.moz-vcard-title-property {
}
.moz-vcard-badge {
height: 32px;
width: 32px;
background-color: transparent;
display: block;
background-image: url("chrome://messenger/skin/addressbook/icons/addressbook-toolbar.png");
-moz-image-region: rect(0px 32px 32px 0px);
}
.moz-vcard-badge:hover {
-moz-image-region: rect(32px 32px 64px 0px);
}
.moz-vcard-badge:focus {
-moz-outline: none;
}
/* Quote Levels Colors */
blockquote[type=cite] { color: blue !important;
border-color: blue !important; } blockquote[type=cite] > blockquote { color: green !important;
border-color: green !important; } blockquote[type=cite] > blockquote > blockquote { color: maroon !important;
border-color: maroon !important; }
blockquote[type=cite] {
color: blue !important;
border-color: blue !important;
}
blockquote[type=cite] > blockquote {
color: green !important;
border-color: green !important;
}
blockquote[type=cite] > blockquote > blockquote {
color: maroon !important;
border-color: maroon !important;
}

View File

@ -0,0 +1,183 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* ===== messageBody.css =================================================
== Styles for the body of a mail message.
======================================================================= */
@import url(chrome://communicator/skin/smileys.css);
/* XXX Breaks the HTML rules below (.moz-class stuff), at least on Linux.
"html|.class" doesn't work.
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
@namespace html url("http://www.w3.org/1999/xhtml");
*/
window {
overflow: auto;
}
html|html {
/* XXX Doesn't seem to work. (Same with "html|body".) */
background-color: window;
}
mailattachcount {
display: none;
}
/* :::: message header ::::: */
header {
text-align: left;
}
headerdisplayname {
font-weight: bold;
white-space: pre;
}
.header-part1 {
background-color: #EFEFEF;
}
.header-part2,
.header-part3 {
background-color: #DEDEDE;
}
div.headerdisplayname {
display: inline;
font-weight: bold;
white-space: pre;
}
/* ::::: message text, incl. quotes ::::: */
.moz-text-flowed blockquote {
margin: inherit;
border-width: medium;
border-color: gray;
}
.moz-text-plain pre {
margin: inherit;
font-family: inherit;
}
.moz-text-plain[wrap="true"] {
white-space: -moz-pre-wrap;
}
.moz-text-plain[wrap="false"] {
white-space: pre;
}
.moz-text-plain[wrap="flow"] .moz-txt-sig {
white-space: -moz-pre-wrap;
}
.moz-text-plain[graphical-quote="false"] blockquote {
margin: inherit;
border-left: inherit;
padding-left: inherit;
}
.moz-text-plain[graphical-quote="true"] blockquote {
margin: inherit;
border-width: medium;
border-color: gray;
}
.moz-text-plain[graphical-quote="true"] .moz-txt-citetags {
display: none;
}
span.moz-txt-underscore {
text-decoration: underline;
}
span.moz-txt-formfeed {
display: block;
height: 100%;
}
/* ::::: signature ::::: */
.moz-txt-sig,
.moz-signature {
color: gray;
}
.moz-txt-sig > a,
.moz-signature > a {
color: #7777FF; /* light blue */
}
/* ::::: vcard ::::: */
.moz-vcard-table {
-moz-border-radius: 8px;
border: thin solid gray;
margin-top: 10px;
}
.moz-vcard-property {
font-size: 80%;
color: gray;
}
.moz-vcard-title-property {
}
.moz-vcard-badge {
height: 30px;
width: 30px;
background-color: transparent;
display: block;
background-image: url("chrome://messenger/skin/addressbook/icons/addressbook-toolbar.png");
-moz-image-region: rect(0px 30px 30px 0px);
}
.moz-vcard-badge:hover {
-moz-image-region: rect(30px 30px 60px 0px);
}
.moz-vcard-badge:focus {
-moz-outline: none;
}

View File

@ -57,6 +57,7 @@
#include "nsIStringBundle.h"
#include "nsVCardStringResources.h"
#include "nsPrintfCString.h"
#include "nsCRT.h"
#include "prprf.h"
@ -75,6 +76,12 @@ static int s_unique = 0;
static int BeginVCard (MimeObject *obj);
static int EndVCard (MimeObject *obj);
static int WriteOutVCard (MimeObject *obj, VObject* v);
#ifdef MOZ_THUNDERBIRD
static int GenerateVCardData(MimeObject * aMimeObj, VObject* aVcard);
static int OutputVcardAttribute(MimeObject *aMimeObj, VObject *aVcard, const char* id, nsACString& vCardOutput);
static int OutputBasicVcard(MimeObject *aMimeObj, VObject *aVcard, nsACString& vCardOutput);
#else
static int WriteOutEachVCardProperty (MimeObject *obj, VObject* v, int* numEmail);
static int WriteOutVCardProperties (MimeObject *obj, VObject* v, int* numEmail);
static int WriteLineToStream (MimeObject *obj, const char *line, PRBool aDoCharConversion);
@ -86,6 +93,7 @@ static int WriteValue (MimeObject *obj, const char *);
static int WriteAttribute (MimeObject *obj, const char *);
static int WriteOutVCardPhoneProperties (MimeObject *obj, VObject* v);
static int WriteOutEachVCardPhoneProperty (MimeObject *obj, VObject* o);
#endif
typedef struct
{
@ -297,6 +305,38 @@ MimeInlineTextVCard_parse_eof (MimeObject *obj, PRBool abort_p)
return 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), PR_FALSE);
if (status < 0) return status;
return 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), PR_TRUE);
if (status < 0) return status;
return 0;
}
#ifndef MOZ_THUNDERBIRD
static int WriteEachLineToStream (MimeObject *obj, const char *line)
{
int status = 0;
@ -1209,36 +1249,6 @@ function showBasic%d()\
return 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), PR_FALSE);
if (status < 0) return status;
return 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), PR_TRUE);
if (status < 0) return status;
return 0;
}
static int WriteOutVCard (MimeObject *obj, VObject* v)
{
int status = 0;
@ -1939,3 +1949,168 @@ nsCOMPtr<nsIStringBundle> stringBundle = nsnull;
else
return tempString;
}
#else // THUNDERBIRD specific vCard formatting
static int WriteOutVCard (MimeObject * aMimeObj, VObject* aVcard)
{
int status = 0;
BeginVCard (aMimeObj);
GenerateVCardData(aMimeObj, aVcard);
return EndVCard (aMimeObj);
}
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;
nsCAutoString vCard;
nsCAutoString vEscCard;
int len = 0;
vCard.Adopt(vCardService->WriteMemoryVObjects(0, &len, aVcard, PR_FALSE));
vEscCard.Adopt(nsEscape (vCard.get(), url_XAlphas));
// 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(), PR_TRUE);
}
static int OutputBasicVcard(MimeObject *aMimeObj, VObject *aVcard, nsACString& vCardOutput)
{
int status = 0;
VObject *prop = NULL;
VObject *prop2 = NULL;
nsCAutoString urlstring;
nsCAutoString namestring;
nsCAutoString emailstring;
nsCOMPtr<nsIMsgVCardService> vCardService = do_GetService(MSGVCARDSERVICE_CONTRACT_ID);
if (!vCardService)
return -1;
/* get the name and email */
prop = vCardService->IsAPropertyOf(aVcard, VCFullNameProp);
if (prop)
{
if (VALUE_TYPE(prop))
{
if (VALUE_TYPE(prop) != VCVT_RAW)
namestring.Adopt(vCardService->FakeCString(prop));
else
namestring.Adopt(vCardService->VObjectAnyValue(prop));
if (!namestring.IsEmpty())
{
vCardOutput += "<td class=\"moz-vcard-title-property\"> ";
prop = vCardService->IsAPropertyOf(aVcard, VCURLProp);
if (prop)
{
urlstring.Adopt(vCardService->FakeCString(prop));
if (urlstring.IsEmpty())
vCardOutput += namestring;
else
vCardOutput += nsPrintfCString(512, "<a href=""%s"" private>%s</a>", urlstring.get(), namestring.get());
}
else
vCardOutput += namestring;
/* get the email address */
prop = vCardService->IsAPropertyOf(aVcard, VCEmailAddressProp);
if (prop)
{
emailstring.Adopt(vCardService->FakeCString(prop));
if (!emailstring.IsEmpty())
{
/* if its an internet address prepend the mailto url */
prop2 = vCardService->IsAPropertyOf(prop, VCInternetProp);
if (prop2)
vCardOutput += nsPrintfCString(512, "&nbsp;&lt;<a href=""mailto:%s"" private>%s</a>&gt;", emailstring.get(), emailstring.get());
else
vCardOutput += emailstring;
}
} // if email address property
vCardOutput += "</td> </tr> "; // end the cell for the name/email address
} // if we have a name property
}
} // if full name property
// now each basic property goes on its own line
// title
status = OutputVcardAttribute (aMimeObj, aVcard, VCTitleProp, vCardOutput);
// org name and company name
prop = vCardService->IsAPropertyOf(aVcard, VCOrgProp);
if (prop)
{
OutputVcardAttribute (aMimeObj, prop, VCOrgUnitProp, vCardOutput);
OutputVcardAttribute (aMimeObj, prop, VCOrgNameProp, vCardOutput);
}
return 0;
}
static int OutputVcardAttribute(MimeObject *aMimeObj, VObject *aVcard, const char* id, nsACString& vCardOutput)
{
int status = 0;
VObject *prop = NULL;
nsCAutoString string;
nsCOMPtr<nsIMsgVCardService> vCardService = do_GetService(MSGVCARDSERVICE_CONTRACT_ID);
if (!vCardService)
return -1;
prop = vCardService->IsAPropertyOf(aVcard, id);
if (prop)
if (VALUE_TYPE(prop))
{
if (VALUE_TYPE(prop) != VCVT_RAW)
string.Adopt(vCardService->FakeCString(prop));
else
string.Adopt(vCardService->VObjectAnyValue(prop));
if (!string.IsEmpty())
{
vCardOutput += "<tr> <td class=\"moz-vcard-property\">";
vCardOutput += string;
vCardOutput += "</td> </tr> ";
}
}
return 0;
}
#endif