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;
-
- 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 *
+ ******************************************************************************/
-/*
- * 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);
+
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ StackContext(TP, &SubTP, abEntry, CTX_VCARD, 0, NULL);
- display_one_vcard(abEntry->name, abEntry, HKEY("vcard_list_name"));
+ DoTemplate(HKEY("vcard_list_name"), WCC->WBuf, &SubTP);
+ UnStackContext(&SubTP);
if (StrLength(abEntry->name) == 0) {
StrBufPlain(abEntry->name, _("(no name)"), -1);
}
if (num_ab > 1) {
- ///SortByHashKey(VS->addrbook, 0);
+ SortByHashKey(VS->addrbook, 1);
}
num_pages = (GetCount(VS->addrbook) / NAMESPERPAGE) + 1;
if (GetHashAt(VS->addrbook, tabfirst, &hklen1, &c1, &v1)) {
a1 = (addrbookent*) v1;
StrBufAppendBuf(headline, a1->name, 0);
-
+ StrBuf_Utf8StrCut(headline, 3);
if (GetHashAt(VS->addrbook, tablast, &hklen2, &c2, &v2)) {
a2 = (addrbookent*) v2;
StrBufAppendBufPlain(headline, HKEY(" - "), 0);
StrBufAppendBuf(headline, a2->name, 0);
+ StrBuf_Utf8StrCut(headline, 9);
}
}
tablabels[i] = headline;
DoTemplate(HKEY("vcard_list"), WCC->WBuf, &SubTP);
UnStackContext(&SubTP);
- /* Placeholders for empty columns at end */
- if ((num_ab % 4) != 0) {
- for (i=0; i<(4-(num_ab % 4)); ++i) {
- do_template("vcard_list_cell_end");
- }
- }
-
- do_template("vcard_list_section_end");
- end_tab((num_pages-1), num_pages);
-
- begin_tab(num_pages, num_pages);
- /* FIXME there ought to be something here */
- end_tab(num_pages, num_pages);
-
DeleteHash(&headlines);
free(tablabels);
- wDumpContent(1);
+ StrBufAppendBufPlain(WCC->WBuf, HKEY("</div>"), 0);/* closes: id=global */
}
VS = (vcardview_struct*) *ViewSpecific;
if (VS->is_singlecard)
- read_message(WC->WBuf, HKEY("view_message"), lbstr("startmsg"), NULL, &Mime);
+ read_message(WC->WBuf, HKEY("view_message"), lbstr("startmsg"), NULL, &Mime, NULL);
else
do_addrbook_view(VS); /* Render the address book */
return 0;
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);