summaryrefslogtreecommitdiff
path: root/common/ctsvc_vcard.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/ctsvc_vcard.c')
-rw-r--r--common/ctsvc_vcard.c144
1 files changed, 134 insertions, 10 deletions
diff --git a/common/ctsvc_vcard.c b/common/ctsvc_vcard.c
index 3d86384..b2be924 100644
--- a/common/ctsvc_vcard.c
+++ b/common/ctsvc_vcard.c
@@ -131,10 +131,24 @@ enum {
enum{
CTSVC_VCARD_IMG_NONE,
- CTSVC_VCARD_IMG_JPEG,
- CTSVC_VCARD_IMG_PNG,
- CTSVC_VCARD_IMG_GIF,
- CTSVC_VCARD_IMG_TIFF,
+ CTSVC_VCARD_IMG_PNG, // Portable Network Graphics
+ // vcard 2.1 spec
+ CTSVC_VCARD_IMG_JPEG, // ISO JPEG format
+ CTSVC_VCARD_IMG_GIF, //Graphics Interchange Format
+ CTSVC_VCARD_IMG_TIFF, // Tagged Image File Format
+ CTSVC_VCARD_IMG_CGM, //ISO Computer Graphics Metafile
+ CTSVC_VCARD_IMG_WMF, // MS Windows Metafile
+ CTSVC_VCARD_IMG_BMP, // MS Windows Bitmap
+ CTSVC_VCARD_IMG_MET, // IBM PM Metafile
+ CTSVC_VCARD_IMG_PMB, // IBM PM Bitmap
+ CTSVC_VCARD_IMG_DIB, // MS Windows DIB
+ CTSVC_VCARD_IMG_PICT, // Apple Picture format
+ CTSVC_VCARD_IMG_PDF, // Adobe Page Description Format
+ CTSVC_VCARD_IMG_PS, // Adobe PostScript format
+ CTSVC_VCARD_IMG_QTIME, // Apple QuickTime format
+ CTSVC_VCARD_IMG_MPEG, // ISO MPEG format
+ CTSVC_VCARD_IMG_MPEG2, // ISO MPEG version 2 format
+ CTSVC_VCARD_IMG_AVI, // Intel AVI format
};
static const char *content_name[CTSVC_VCARD_VALUE_MAX] = {0};
@@ -303,8 +317,10 @@ static inline int __ctsvc_vcard_add_folding(char **buf, int *buf_size, int buf_l
free(buf_copy);
return -1;
}
- else
+ else {
buf_copy = tmp;
+ r = (buf_copy + result_len);
+ }
}
if ('\r' == *s)
@@ -431,6 +447,32 @@ static inline const char* __ctsvc_get_img_suffix(int type)
return "gif";
case CTSVC_VCARD_IMG_PNG:
return "png";
+ case CTSVC_VCARD_IMG_CGM:
+ return "cgm";
+ case CTSVC_VCARD_IMG_WMF:
+ return "wmf";
+ case CTSVC_VCARD_IMG_BMP:
+ return "bmp";
+ case CTSVC_VCARD_IMG_MET:
+ return "met";
+ case CTSVC_VCARD_IMG_PMB:
+ return "pmb";
+ case CTSVC_VCARD_IMG_DIB:
+ return "dib";
+ case CTSVC_VCARD_IMG_PICT:
+ return "pict";
+ case CTSVC_VCARD_IMG_PDF:
+ return "pdf";
+ case CTSVC_VCARD_IMG_PS:
+ return "ps";
+ case CTSVC_VCARD_IMG_QTIME:
+ return "qtime";
+ case CTSVC_VCARD_IMG_MPEG:
+ return "mpeg";
+ case CTSVC_VCARD_IMG_MPEG2:
+ return "mpeg2";
+ case CTSVC_VCARD_IMG_AVI:
+ return "avi";
case CTSVC_VCARD_IMG_JPEG:
case CTSVC_VCARD_IMG_NONE:
default:
@@ -463,6 +505,45 @@ static inline int __ctsvc_vcard_get_image_type(char *val)
result = strstr(val, "tiff");
if (result) return CTSVC_VCARD_IMG_TIFF;
+ result = strstr(val, "cgm");
+ if (result) return CTSVC_VCARD_IMG_CGM;
+
+ result = strstr(val, "wmf");
+ if (result) return CTSVC_VCARD_IMG_WMF;
+
+ result = strstr(val, "bmp");
+ if (result) return CTSVC_VCARD_IMG_BMP;
+
+ result = strstr(val, "met");
+ if (result) return CTSVC_VCARD_IMG_MET;
+
+ result = strstr(val, "pmb");
+ if (result) return CTSVC_VCARD_IMG_PMB;
+
+ result = strstr(val, "dib");
+ if (result) return CTSVC_VCARD_IMG_DIB;
+
+ result = strstr(val, "pict");
+ if (result) return CTSVC_VCARD_IMG_PICT;
+
+ result = strstr(val, "pdf");
+ if (result) return CTSVC_VCARD_IMG_PDF;
+
+ result = strstr(val, "ps");
+ if (result) return CTSVC_VCARD_IMG_PS;
+
+ result = strstr(val, "qtime");
+ if (result) return CTSVC_VCARD_IMG_QTIME;
+
+ result = strstr(val, "mpeg");
+ if (result) return CTSVC_VCARD_IMG_MPEG;
+
+ result = strstr(val, "mpeg2");
+ if (result) return CTSVC_VCARD_IMG_MPEG2;
+
+ result = strstr(val, "avi");
+ if (result) return CTSVC_VCARD_IMG_AVI;
+
return CTSVC_VCARD_IMG_NONE;
}
@@ -476,6 +557,32 @@ static inline const char* __ctsvc_get_image_type_str(int type)
return "GIF";
case CTSVC_VCARD_IMG_PNG:
return "PNG";
+ case CTSVC_VCARD_IMG_CGM:
+ return "CGM";
+ case CTSVC_VCARD_IMG_WMF:
+ return "WMF";
+ case CTSVC_VCARD_IMG_BMP:
+ return "BMP";
+ case CTSVC_VCARD_IMG_MET:
+ return "MET";
+ case CTSVC_VCARD_IMG_PMB:
+ return "PMB";
+ case CTSVC_VCARD_IMG_DIB:
+ return "DIB";
+ case CTSVC_VCARD_IMG_PICT:
+ return "PICT";
+ case CTSVC_VCARD_IMG_PDF:
+ return "PDF";
+ case CTSVC_VCARD_IMG_PS:
+ return "PS";
+ case CTSVC_VCARD_IMG_QTIME:
+ return "QTIME";
+ case CTSVC_VCARD_IMG_MPEG:
+ return "MPEG";
+ case CTSVC_VCARD_IMG_MPEG2:
+ return "MPEG2";
+ case CTSVC_VCARD_IMG_AVI:
+ return "AVI";
case CTSVC_VCARD_IMG_JPEG:
default:
return "JPEG";
@@ -868,6 +975,10 @@ static inline int __ctsvc_vcard_put_number_type(int type, char *label, char **bu
CTSVC_VCARD_APPEND_STR(buf, buf_size, len, ";TYPE=PCS");
if (type & CONTACTS_NUMBER_TYPE_ASSISTANT)
CTSVC_VCARD_APPEND_STR(buf, buf_size, len, ";TYPE=X-ASSISTANT");
+ if (type & CONTACTS_NUMBER_TYPE_RADIO)
+ CTSVC_VCARD_APPEND_STR(buf, buf_size, len, ";TYPE=X-RADIO");
+ if (type & CONTACTS_NUMBER_TYPE_COMPANY_MAIN)
+ CTSVC_VCARD_APPEND_STR(buf, buf_size, len, ";TYPE=X-COMPANY-MAIN");
if (type == CONTACTS_NUMBER_TYPE_CUSTOM) {
if (__ctsvc_vcard_is_valid_custom_label(label)) {
CTSVC_VCARD_APPEND_STR(buf, buf_size, len, ";TYPE=X-");
@@ -1738,7 +1849,8 @@ API int contacts_vcard_make_from_person(contacts_record_h record, char **vcard_s
return CONTACTS_ERROR_INVALID_PARAMETER;
}
contacts_query_create(_contacts_contact._uri, &query);
- contacts_query_set_filter(query, filter);
+ ret = contacts_query_set_filter(query, filter);
+ WARN_IF(CONTACTS_ERROR_NONE != ret, "contacts_query_set_filter() Failed(%d)", ret);
ret = contacts_db_get_records_with_query(query, 0, 0, &list);
if (ret == CONTACTS_ERROR_NONE)
@@ -2319,6 +2431,12 @@ static inline int __ctsvc_vcard_get_photo(contacts_record_h contact, ctsvc_list_
type = __ctsvc_vcard_get_image_type(val);
+ buf = g_base64_decode(temp+1, &size);
+ if (0 == size) {
+ g_free(buf);
+ return CONTACTS_ERROR_NONE;
+ }
+
gettimeofday(&tv, NULL);
ret = snprintf(dest, sizeof(dest), "%s/vcard-image-%ld%ld.%s",
CTSVC_VCARD_IMAGE_LOCATION, tv.tv_sec, tv.tv_usec, __ctsvc_get_img_suffix(type));
@@ -2327,8 +2445,6 @@ static inline int __ctsvc_vcard_get_photo(contacts_record_h contact, ctsvc_list_
fd = open(dest, O_WRONLY|O_CREAT|O_TRUNC, 0660);
RETVM_IF(fd < 0, CONTACTS_ERROR_SYSTEM, "System : open(%s) Failed(%d)", dest, errno);
- buf = g_base64_decode(temp+1, &size);
-
while (0 < size) {
ret = write(fd, buf, size);
if (ret <= 0) {
@@ -2567,6 +2683,12 @@ static inline int __ctsvc_vcard_get_company_logo(ctsvc_list_s *company_list, cha
*temp = '\0';
type = __ctsvc_vcard_get_image_type(val);
+ buf = g_base64_decode(temp+1, &size);
+ if (0 == size) {
+ g_free(buf);
+ return CONTACTS_ERROR_NONE;
+ }
+
gettimeofday(&tv, NULL);
ret = snprintf(dest, sizeof(dest), "%s/%d-%ld%ld-logo.%s", CTSVC_VCARD_IMAGE_LOCATION,
getpid(), tv.tv_sec, tv.tv_usec, __ctsvc_get_img_suffix(type));
@@ -2575,8 +2697,6 @@ static inline int __ctsvc_vcard_get_company_logo(ctsvc_list_s *company_list, cha
fd = open(dest, O_WRONLY|O_CREAT|O_TRUNC, 0660);
RETVM_IF(fd < 0, CONTACTS_ERROR_INTERNAL, "System : open(%s) Failed(%d)", dest, errno);
- buf = g_base64_decode(temp+1, &size);
-
while (0 < size) {
ret = write(fd, buf, size);
if (ret <= 0) {
@@ -2788,6 +2908,10 @@ static inline bool __ctsvc_vcard_get_number_type(contacts_record_h number, char
if (result) {
if (strstr(lower, "x-assistant"))
type |= CONTACTS_NUMBER_TYPE_ASSISTANT;
+ else if (strstr(lower, "x-radio"))
+ type |= CONTACTS_NUMBER_TYPE_RADIO;
+ else if (strstr(lower, "x-company-main"))
+ type |= CONTACTS_NUMBER_TYPE_COMPANY_MAIN;
else {
type = CONTACTS_NUMBER_TYPE_CUSTOM;
contacts_record_set_str(number, _contacts_number.label, temp+(result-lower)+2);