+ if (!CAL_STRCMP(part, "elm.text.3"))
+ {
+ return strdup(C_("IDS_CLD_BODY_REPEAT"));
+ }
+
+ if(!CAL_STRCMP(part, "elm.text.4"))
+ {
+ __cal_detail_get_repeat(cs, buf, sizeof(buf));
+
+ return strdup(buf);
+ }
+
+ return NULL;
+}
+
+static Eina_Bool __cal_detail_check_autolink_delimiter(char ch)
+{
+ if (isdigit(ch) || isalpha(ch))
+ {
+ return false;
+ }
+
+ char undeli[] = "@-_.+"; /* The char in the string is not a delimiter */
+
+ int i = 0;
+ for (i = 0; i < sizeof(undeli) / sizeof(undeli[0]); ++i)
+ {
+ if (ch == undeli[i])
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
+static int __cal_detail_check_autolink_phone_number(const char *word)
+{
+ const int min_phone_num_len = 3;
+ const int max_phone_num_len = 15;
+ int i = 0;
+ int num_counter = 0;
+
+ if (word[0] == '+')
+ {
+ i++;
+ }
+
+ while (isdigit(word[i]) || word[i] == '-')
+ {
+ if (isdigit(word[i]))
+ {
+ num_counter++;
+ if (num_counter > max_phone_num_len)
+ {
+ break;
+ }
+ }
+ else if (i == 0 || word[i - 1] == '-')
+ {
+ /* The first char is '-' or two consecutive '-' */
+ break;
+ }
+ i++;
+ }
+
+ /* Make sure that the last char is digit */
+ while (!isdigit(word[i]))
+ {
+ i--;
+ }
+
+ if (num_counter < min_phone_num_len)
+ {
+ return 0;
+ }
+ else
+ {
+ return i + 1;
+ }
+}
+
+static enum anchor_t __cal_detail_get_autolink_anchor_type(const char *word)
+{
+ CAL_ASSERT(word);
+ int i = 0;
+
+ if (NULL != strstr(word, EMAIL_LINK_FLAG))
+ {
+ return ANCHOR_EMAIL_LINK;
+ }
+
+ /* Email */
+ if (strchr(word, '@') != NULL)
+ {
+ return ANCHOR_EMAIL;
+ }
+
+ /* Url */
+ char *url_prefix[] = { "http://", "HTTP://", "www.", "WWW." };
+ for (i = 0; i < sizeof(url_prefix) / sizeof(url_prefix[0]); ++i)
+ {
+ if (g_str_has_prefix(word, url_prefix[i]))
+ {
+ return ANCHOR_URL;
+ }
+ }
+
+ /* Phone number */
+ if (__cal_detail_check_autolink_phone_number(word))
+ {
+ return ANCHOR_PHONE;
+ }
+
+ return NOT_ANCHOR;
+}
+
+static void __cal_detail_process_autolink_anchor_word(GString *anchor)
+{
+ CAL_ASSERT(anchor);
+
+ int len = 0;
+ GString *word = g_string_new(anchor->str);
+ g_string_assign(anchor, ""); /* clear */
+ char *snote_display = NULL;
+ char *email_link = NULL;
+
+ switch (__cal_detail_get_autolink_anchor_type(word->str))
+ {
+ case ANCHOR_EMAIL:
+ g_string_append(anchor, "<color=#72b1f2FF>");
+ g_string_append_printf(anchor,
+ "<a href=email|%s underline=on underline_color=#72b1f2FF>",
+ word->str);
+ g_string_append(anchor, word->str);
+ g_string_append(anchor, "</a></color>");
+ break;
+
+ case ANCHOR_URL:
+ g_string_append(anchor, "<color=#72b1f2FF>");
+ g_string_append_printf(anchor,
+ "<a href=url|%s underline=on underline_color=#72b1f2FF>",
+ word->str);
+ g_string_append(anchor, word->str);
+ g_string_append(anchor, "</a></color>");
+ break;
+
+ case ANCHOR_PHONE:
+ len = __cal_detail_check_autolink_phone_number(word->str);
+ char num[32] = { 0 };
+ snprintf(num, len + 1, "%s", word->str);
+
+ g_string_append(anchor, "<color=#72b1f2FF>");
+ g_string_append_printf(anchor,
+ "<a href=phone_num|%s underline=on underline_color=#72b1f2FF>",
+ num);
+ g_string_append(anchor, num);
+ g_string_append(anchor, "</a></color>");
+ g_string_append(anchor, word->str + len);
+ break;
+ case ANCHOR_EMAIL_LINK:
+
+ email_link = strstr(word->str, EMAIL_LINK_FLAG);
+ int nsize = email_link - word->str + 1;
+ CAL_CALLOC(snote_display, nsize, char);
+ if(NULL != snote_display)
+ {
+ strncpy(snote_display, word->str, nsize-1);
+ }
+ g_string_append(anchor, "<color=#72b1f2FF>");
+ g_string_append_printf(anchor,
+ "<a href=email_link|%s underline=on underline_color=#72b1f2FF>",
+ email_link+strlen(EMAIL_LINK_FLAG));
+
+ g_string_append(anchor, snote_display);
+ g_string_append(anchor, "</a></color>");
+ free(snote_display);
+ break;
+ default:
+ g_string_append(anchor, word->str);
+ break;
+ }
+}
+
+static GString *__cal_detail_add_autolink_anchor(const char *content)
+{
+ c_retvm_if(!content, NULL, "Input parameter is null");
+
+ const char *p = content;
+ char *gt = NULL;
+ GString *text = g_string_new("");
+ GString *buf = g_string_new("");
+
+ while (*p != '\0') {
+ g_string_assign(buf, ""); /* reset buffer */
+
+ if(NULL != strstr(p, EMAIL_LINK_FLAG))
+ {
+
+ g_string_append_len(buf, p, CAL_STRLEN(content));
+ __cal_detail_process_autolink_anchor_word(buf);
+ g_string_append(text, buf->str);
+ break;;
+ }
+ else if (__cal_detail_check_autolink_delimiter(p[0]))
+ {
+ g_string_append_c(text, p[0]);
+ p++;
+ }
+ else if (p[0] == '<')
+ { /* tag begin */
+ gt = strchr(p, '>'); /* search tag end */
+ CAL_ASSERT(gt); /* assert '<' and '>' are matched */
+ g_string_append_len(text, p, gt - p + 1);
+ p = gt + 1;
+ }
+ else
+ {
+ int i = 0;
+ while (p[i] != '\0')
+ {
+ if (__cal_detail_check_autolink_delimiter(p[i]) || p[i] == '<')
+ {
+ break;
+ }
+ i++;
+ }
+
+ g_string_append_len(buf, p, i);
+ p = p + i;
+
+ __cal_detail_process_autolink_anchor_word(buf);
+ g_string_append(text, buf->str);
+ }
+ }
+
+ g_string_free(buf, TRUE);
+
+ return text;
+}
+
+static char* __cal_detail_get_note_text(Evas_Object *obj, const char *part, cal_detail_genlist_item_data *item_data)
+{
+ cal_struct *cs;
+
+ cal_detail_data *p = item_data->p;
+ cs = p->cs;
+ if (NULL == cs)
+ {
+ return NULL;
+ }
+
+ return NULL;
+}
+
+static void __cal_detail_autolink_popup_response_callback(void *data, Evas_Object *obj, void *event_info)
+{
+ c_retm_if(!data, "data is null");
+ c_retm_if(!obj, "obj is null");
+
+ struct autolink_data_t *ald = data;
+
+ free(ald->info);
+ free(ald);
+
+ evas_object_del(obj);
+}
+
+void __cal_detail_show_autolink_popup(struct autolink_data_t *ald, cal_detail_data* p)
+{
+ c_retm_if(!ald, "ald is null");
+ c_retm_if(!p, "p is null");
+
+ struct anchor_popup_item_t *list = NULL;
+ int count = 0;
+ int i = 0;
+ Evas_Object *ctx;
+ Elm_Object_Item *item = NULL;
+
+ switch (ald->type)
+ {
+ case ANCHOR_EMAIL:
+ list = g_email_list;
+ count = ARRAY_SIZE(g_email_list);
+ break;
+ case ANCHOR_PHONE:
+ list = g_phone_list;
+ count = ARRAY_SIZE(g_phone_list);
+ break;
+ default:
+ break;
+ }
+
+ ctx = elm_ctxpopup_add(p->ly);
+ c_retm_if(!ctx, "elm_ctxpopup_add is failed");
+
+ evas_object_smart_callback_add(ctx, "dismissed", __cal_detail_autolink_popup_response_callback, ald);
+
+ for (i = 0; i < count; ++i)
+ {
+ item = elm_ctxpopup_item_append(ctx, list[i].label, NULL, list[i].response, ald);
+ if (!item)
+ {
+ ERR("elm_ctxpopup_item_append returned null");
+ evas_object_del(ctx);
+ }
+ }
+
+ evas_object_move(ctx, p->x, p->y);
+ evas_object_show(ctx);
+}
+
+static char *__cal_detail_get_autolink_anchor_type_str(enum anchor_t type)
+{
+ switch (type) {
+ case ANCHOR_EMAIL:
+ return "email";
+ case ANCHOR_PHONE:
+ return "phone_num";
+ case ANCHOR_URL:
+ return "url";
+ case ANCHOR_EMAIL_LINK:
+ return "email_link";
+ default:
+ return "";
+ }
+}
+
+static enum anchor_t __cal_detail_parse_autolink_anchor_type(char *s)
+{
+ int i = 0;
+ for (i = NOT_ANCHOR + 1; i < NOT_ANCHOR + 5; ++i)
+ {
+ if (CAL_STRCMP(s, __cal_detail_get_autolink_anchor_type_str(i)) == 0)
+ {
+ return (enum anchor_t)i;
+ }
+ }
+ return NOT_ANCHOR;
+}
+
+
+static void __cal_detail_autolink_email_link_clicked(char *info)
+{
+ c_retm_if(!info, "Input parameter is null");
+ bundle *req = NULL;
+ char *account_id= NULL;
+ char *email_id= NULL;
+ char *src_box= NULL;
+ char *temp= NULL;
+ int ret = 0;
+
+ req = bundle_create();
+ c_retm_if(!req, "bundle_create is failed");
+
+ char livemagazine[30] = { 0, };
+ snprintf(livemagazine, sizeof(livemagazine), "%d", 0);
+ char internal[30] = { 0, };
+ snprintf(internal, sizeof(internal), "%d", 1);
+ account_id = info;
+ temp = strchr(info, '_');
+ if (NULL != temp)
+ {
+ *temp = '\0';
+ bundle_add(req, "ACCOUNT_ID", account_id);
+ }
+
+ if (NULL != temp)
+ {
+ email_id = temp+1;
+ temp = NULL;
+ temp = strchr(email_id, '_');
+ if(NULL != temp)
+ {
+ *temp = '\0';
+ bundle_add(req, "MAIL_ID", email_id);
+ }
+ }
+
+ if (NULL != temp)
+ {
+ src_box= temp+1;
+ bundle_add(req, "MAILBOX", src_box);
+ }
+
+
+ bundle_add(req, "RUN_TYPE", "7");
+ ret = aul_launch_app("org.tizen.email", req);
+ c_warn_if(!ret, "aul_launch_app(org.tizen.email) is failed(%d)", ret);