HashList *vcNames = NULL; /* todo: fill with the name strings */
vcField* vcfUnknown = NULL;
+/******************************************************************************
+ * initialize vcard structure *
+ ******************************************************************************/
+
void RegisterVCardToken(vcField* vf, StrBuf *name, int inTokenCount)
{
if (vf->Type == UnKnown) {
FreeStrBuf(&subStr);
}
+/******************************************************************************
+ * VCard template functions *
+ ******************************************************************************/
+
int preeval_vcard_item(WCTemplateToken *Token)
{
WCTemplputParams TPP;
return rc;
}
-
-
-
HashList *getContextVcard(StrBuf *Target, WCTemplputParams *TP)
{
vcField *vf = (vcField*) CTX(CTX_VCARD_TYPE);
}
}
-
int conditional_VC_Havetype(StrBuf *Target, WCTemplputParams *TP)
{
addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
return rc;
}
-wc_mime_attachment *load_vcard(message_summary *Msg)
-{
- HashPos *it;
- StrBuf *FoundCharset = NewStrBuf();
- StrBuf *Error;
- void *vMime;
- const char *Key;
- long len;
- wc_mime_attachment *Mime;
- wc_mime_attachment *VCMime = NULL;
-
- Msg->MsgBody = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
- memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
- Msg->MsgBody->msgnum = Msg->msgnum;
-
- load_message(Msg, FoundCharset, &Error);
-
- FreeStrBuf(&FoundCharset);
- /* look up the vcard... */
- it = GetNewHashPos(Msg->AllAttach, 0);
- while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
- (vMime != NULL))
- {
- Mime = (wc_mime_attachment*) vMime;
- if ((strcmp(ChrPtr(Mime->ContentType),
- "text/x-vcard") == 0) ||
- (strcmp(ChrPtr(Mime->ContentType),
- "text/vcard") == 0))
- {
- VCMime = Mime;
- break;
- }
- }
- DeleteHashPos(&it);
- if (VCMime == NULL)
- return NULL;
-
- if (VCMime->Data == NULL)
- MimeLoadData(VCMime);
- return VCMime;
-}
+/******************************************************************************
+ * parse one VCard *
+ ******************************************************************************/
void PutVcardItem(HashList *thisVC, vcField *thisField, StrBuf *ThisFieldStr, int is_qp, StrBuf *Swap)
{
FreeStrBuf(&thisVCToken);
}
-void tmplput_VCARD_ITEM(StrBuf *Target, WCTemplputParams *TP)
-{
- addrbookent *ab = CTX(CTX_VCARD);
- int evc;
- void *vStr;
-
- evc = GetTemplateTokenNumber(Target, TP, 0, -1);
- if (evc != -1)
- {
- if (GetHash(ab->VC, IKEY(evc), &vStr))
- {
- StrBufAppendTemplate(Target, TP,
- (StrBuf*) vStr,
- 1);
- }
- }
-
-}
-
HashList *CtxGetVcardList(StrBuf *Target, WCTemplputParams *TP)
{
HashList *pb = CTX(CTX_VCARD_LIST);
return pb;
}
-void display_one_vcard (StrBuf *Target, addrbookent *ab, const char *tp_name, size_t tp_name_len)
-{
- WCTemplputParams *TP = NULL;
- WCTemplputParams SubTP;
+/******************************************************************************
+ * Extract an embedded photo from a vCard for display on the client *
+ ******************************************************************************/
- memset(&SubTP, 0, sizeof(WCTemplputParams));
- StackContext(TP, &SubTP, ab, CTX_VCARD, 0, NULL);
-
- DoTemplate(tp_name, tp_name_len, Target, &SubTP);
- UnStackContext(&SubTP);
-}
-
-/*
- * Extract an embedded photo from a vCard for display on the client
- */
void display_vcard_photo_img(void)
{
long msgnum = 0L;
free(photosrc);
}
+wc_mime_attachment *load_vcard(message_summary *Msg)
+{
+ HashPos *it;
+ StrBuf *FoundCharset = NewStrBuf();
+ StrBuf *Error;
+ void *vMime;
+ const char *Key;
+ long len;
+ wc_mime_attachment *Mime;
+ wc_mime_attachment *VCMime = NULL;
+
+ Msg->MsgBody = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
+ memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
+ Msg->MsgBody->msgnum = Msg->msgnum;
+
+ load_message(Msg, FoundCharset, &Error);
+
+ FreeStrBuf(&FoundCharset);
+ /* look up the vcard... */
+ it = GetNewHashPos(Msg->AllAttach, 0);
+ while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
+ (vMime != NULL))
+ {
+ Mime = (wc_mime_attachment*) vMime;
+ if ((strcmp(ChrPtr(Mime->ContentType),
+ "text/x-vcard") == 0) ||
+ (strcmp(ChrPtr(Mime->ContentType),
+ "text/vcard") == 0))
+ {
+ VCMime = Mime;
+ break;
+ }
+ }
+ DeleteHashPos(&it);
+ if (VCMime == NULL)
+ return NULL;
+
+ if (VCMime->Data == NULL)
+ MimeLoadData(VCMime);
+ return VCMime;
+}
+
/*
* Edit the vCard component of a MIME message.
* Supply the message number
FreeStrBuf(&Buf);
}
-
+/******************************************************************************
+ * Render Addressbooks *
+ ******************************************************************************/
typedef struct _vcardview_struct {
long is_singlecard;
int is_new,
int i)
{
+ wcsession *WCC = WC;
+ WCTemplputParams *TP = NULL;
+ WCTemplputParams SubTP;
vcardview_struct *VS;
wc_mime_attachment *VCMime = NULL;
struct vCard *v;
abEntry->name = NewStrBuf();
abEntry->VC = NewHash(0, lFlathash);
abEntry->ab_msgnum = Msg->msgnum;
- parse_vcard(WC->WBuf, v, abEntry->VC, VCMime);
+ parse_vcard(WCC->WBuf, v, abEntry->VC, VCMime);
- display_one_vcard(abEntry->name, abEntry, HKEY("vcard_list_name"));
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ StackContext(TP, &SubTP, abEntry, CTX_VCARD, 0, NULL);
+
+ DoTemplate(HKEY("vcard_list_name"), WCC->WBuf, &SubTP);
+ UnStackContext(&SubTP);
if (StrLength(abEntry->name) == 0) {
StrBufPlain(abEntry->name, _("(no name)"), -1);
v = VCardLoad(Mime->Data);
if (v != NULL) {
+ WCTemplputParams *TP = NULL;
+ WCTemplputParams SubTP;
addrbookent ab;
memset(&ab, 0, sizeof(addrbookent));
ab.ab_msgnum = Mime->msgnum;
parse_vcard(Target, v, ab.VC, Mime);
- display_one_vcard (Target, &ab, HKEY("vcard_msg_display"));
+
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ StackContext(TP, &SubTP, &ab, CTX_VCARD, 0, NULL);
+
+ DoTemplate(HKEY("vcard_msg_display"), Target, &SubTP);
+ UnStackContext(&SubTP);
DeleteHash(&ab.VC);
vcard_free(v);