summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiep Ha <thiepha@gmail.com>2015-05-10 17:05:09 +0900
committerThiep Ha <thiepha@gmail.com>2015-06-02 21:50:24 +0900
commit52e61b58cda08627ed7f086db7c60ba7620a62a8 (patch)
treeb418ed42e545abb2041654b71df95e5826745653
parentd322f798e8c7760301cfa4f6d0292e4af24d8344 (diff)
CnP_DnD/Wl: only providing uri type when data is uri type
When selection owner provides uri types (text/uri; text/uri-list), it should check if data is in correct format.
-rw-r--r--src/lib/elm_cnp.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index cdf89fb1a..2ef6f0b5f 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -2557,19 +2557,32 @@ _wl_targets_converter(char *target, Wl_Cnp_Selection *sel EINA_UNUSED, void *dat
2557 int len = 0; 2557 int len = 0;
2558 int i = 0; 2558 int i = 0;
2559 Elm_Sel_Format formats = ELM_SEL_FORMAT_NONE; 2559 Elm_Sel_Format formats = ELM_SEL_FORMAT_NONE;
2560 Eina_Bool is_uri_data = EINA_TRUE;
2560 2561
2561 for (i = 0; i < CNP_N_ATOMS; i++) 2562 if (sel->format)
2562 { 2563 {
2563 if (!strcmp(target, _atoms[i].name)) 2564 formats = sel->format;
2565 is_uri_data = _wl_is_uri_type_data(sel->selbuf, sel->buflen);
2566 }
2567 else
2568 {
2569 for (i = 0; i < CNP_N_ATOMS; i++)
2564 { 2570 {
2565 formats = _atoms[i].formats; 2571 if (!strcmp(target, _atoms[i].name))
2572 {
2573 formats = _atoms[i].formats;
2574 }
2566 } 2575 }
2567 } 2576 }
2577 /* Only provide formats which selection owner can send */
2568 for (i = 0; i < CNP_N_ATOMS; i++) 2578 for (i = 0; i < CNP_N_ATOMS; i++)
2569 { 2579 {
2570 if (formats & _atoms[i].formats) 2580 if (formats & _atoms[i].formats)
2571 { 2581 {
2572 len += strlen(_atoms[i].name) + strlen(sep); 2582 if ((is_uri_data) || (!is_uri_data &&
2583 strcmp(_atoms[i].name, "text/uri") &&
2584 strcmp(_atoms[i].name, "text/uri-list")))
2585 len += strlen(_atoms[i].name) + strlen(sep);
2573 } 2586 }
2574 } 2587 }
2575 aret = calloc(1, len * sizeof(char)); 2588 aret = calloc(1, len * sizeof(char));
@@ -2578,8 +2591,13 @@ _wl_targets_converter(char *target, Wl_Cnp_Selection *sel EINA_UNUSED, void *dat
2578 { 2591 {
2579 if (formats & _atoms[i].formats) 2592 if (formats & _atoms[i].formats)
2580 { 2593 {
2581 aret = strcat(aret, _atoms[i].name); 2594 if ((is_uri_data) || (!is_uri_data &&
2582 aret = strcat(aret, sep); 2595 strcmp(_atoms[i].name, "text/uri") &&
2596 strcmp(_atoms[i].name, "text/uri-list")))
2597 {
2598 aret = strcat(aret, _atoms[i].name);
2599 aret = strcat(aret, sep);
2600 }
2583 } 2601 }
2584 } 2602 }
2585 *data_ret = aret; 2603 *data_ret = aret;