X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fvcard_edit.c;h=81efa290fe6c8f8d3c2d7d16d0d493cca4990b70;hb=3b2b93ca40ee734fc69a69e94a183c1a7e2bfb69;hp=69b04ca40ded6390a13445b2a2a461f359a6339f;hpb=4d0a622d2d3ae20770258981c6062f58c9fc01a3;p=citadel.git diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c index 69b04ca40..81efa290f 100644 --- a/webcit/vcard_edit.c +++ b/webcit/vcard_edit.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996-2012 by the citadel.org team + * Copyright (c) 1996-2017 by the citadel.org team * * This program is open source software. You can redistribute it and/or * modify it under the terms of the GNU General Public License, version 3. @@ -212,8 +212,7 @@ int preeval_vcard_item(WCTemplateToken *Token) TP->Tokens = Token; searchFieldNo = GetTemplateTokenNumber(Target, TP, 0, 0); if (searchFieldNo >= VCEnumCounter) { - LogTemplateError(NULL, "VCardItem", ERR_PARM1, TP, - "Invalid define"); + LogTemplateError(NULL, "VCardItem", ERR_PARM1, TP, "Invalid define"); return 0; } return 1; @@ -236,8 +235,7 @@ void tmpl_vcard_context_item(StrBuf *Target, WCTemplputParams *TP) addrbookent *ab = (addrbookent*) CTX(CTX_VCARD); if (t == NULL) { - LogTemplateError(NULL, "VCard item", ERR_NAME, TP, - "Missing context"); + LogTemplateError(NULL, "VCard item", ERR_NAME, TP, "Missing context"); return; } @@ -318,16 +316,17 @@ int filter_VC_ByType(const char* key, long len, void *Context, StrBuf *Target, W long searchType; long type = 0; void *v; - int rc = 0; vcField *vf = (vcField*) Context; + int rc = 0; memcpy(&type, key, sizeof(long)); searchType = GetTemplateTokenNumber(Target, TP, IT_ADDT_PARAM(0), 0); if (vf->Type == searchType) { addrbookent *ab = (addrbookent*) CTX(CTX_VCARD); - if (GetHash(ab->VC, LKEY(vf->cval), &v) && v != NULL) + if (GetHash(ab->VC, LKEY(vf->cval), &v) && v != NULL) { return 1; + } } return rc; } @@ -426,11 +425,11 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachme FlushStrBuf(thisVCToken); is_qp = 0; is_b64 = 0; - syslog(LOG_DEBUG, "i: %d oneprop: %s - value: %s", i, v->prop[i].name, v->prop[i].value); + // syslog(LOG_DEBUG, "i: %d oneprop: %s - value: %s", i, v->prop[i].name, v->prop[i].value); StrBufPlain(thisname, v->prop[i].name, -1); StrBufLowerCase(thisname); - /*len = */extract_token(firsttoken, ChrPtr(thisname), 0, ';', sizeof firsttoken); + extract_token(firsttoken, ChrPtr(thisname), 0, ';', sizeof firsttoken); ntokens = num_tokens(ChrPtr(thisname), ';'); for (j=0, k=0; j < ntokens && k < 10; ++j) { len = extract_token(buf, ChrPtr(thisname), j, ';', sizeof buf); @@ -440,7 +439,7 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachme else if (!strcasecmp(buf, "encoding=base64")) { is_b64 = 1; } - else{ + else { if (StrLength(thisVCToken) > 0) { StrBufAppendBufPlain(thisVCToken, HKEY(";"), 0); } @@ -454,7 +453,7 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachme (vField != NULL)) { vcField *thisField = (vcField *)vField; StrBuf *ThisFieldStr = NULL; - syslog(LOG_DEBUG, "got this token: %s, found: %s", ChrPtr(thisVCToken), thisField->STR.Key); + // syslog(LOG_DEBUG, "got this token: %s, found: %s", ChrPtr(thisVCToken), thisField->STR.Key); switch (thisField->Type) { case StringCluster: { int j = 0; @@ -464,7 +463,6 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachme while (thisField->Sub[j].STR.len > 0) { StrBufExtract_NextToken(Buf, thisArray, &Pos, ';'); ThisFieldStr = NewStrBufDup(Buf); - PutVcardItem(VC, &thisField->Sub[j], ThisFieldStr, is_qp, Swap); j++; } @@ -925,18 +923,23 @@ int vcard_LoadMsgFromServer(SharedMessageStatus *Stat, abEntry->name = NewStrBuf(); abEntry->VC = NewHash(0, lFlathash); abEntry->ab_msgnum = Msg->msgnum; + parse_vcard(WCC->WBuf, v, abEntry->VC, VCMime); memset(&SubTP, 0, sizeof(WCTemplputParams)); StackContext(TP, &SubTP, abEntry, CTX_VCARD, 0, NULL); - DoTemplate(HKEY("vcard_list_name"), WCC->WBuf, &SubTP); + // No, don't display the name, it just shits all over the screen + // DoTemplate(HKEY("vcard_list_name"), WCC->WBuf, &SubTP); + UnStackContext(&SubTP); if (StrLength(abEntry->name) == 0) { StrBufPlain(abEntry->name, _("(no name)"), -1); } + syslog(LOG_DEBUG, "abEntry->name : %s", ChrPtr(abEntry->name)); + vcard_free(v); Put(VS->addrbook, SKEY(abEntry->name), abEntry, deleteAbEnt); @@ -1029,10 +1032,12 @@ int vcard_RenderView_or_Tail(SharedMessageStatus *Stat, void **ViewSpecific, lon vcardview_struct *VS; VS = (vcardview_struct*) *ViewSpecific; - if (VS->is_singlecard) + if (VS->is_singlecard) { read_message(WC->WBuf, HKEY("view_message"), lbstr("startmsg"), NULL, &Mime, NULL); - else + } + else { do_addrbook_view(VS); /* Render the address book */ + } return 0; } @@ -1042,11 +1047,12 @@ int vcard_Cleanup(void **ViewSpecific) VS = (vcardview_struct*) *ViewSpecific; wDumpContent(1); - if ((VS != NULL) && - (VS->addrbook != NULL)) + if ((VS != NULL) && (VS->addrbook != NULL)) { DeleteHash(&VS->addrbook); - if (VS != NULL) + } + if (VS != NULL) { free(VS); + } return 0; } @@ -1055,8 +1061,9 @@ void render_MIME_VCard(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharse { wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH); wcsession *WCC = WC; - if (StrLength(Mime->Data) == 0) + if (StrLength(Mime->Data) == 0) { MimeLoadData(Mime); + } if (StrLength(Mime->Data) > 0) { struct vCard *v; StrBuf *Buf;