static Evas * _wl_evas_get_from_win(unsigned int win);
static Eina_Bool
+_wl_is_uri_type_data(const char *data, int len)
+{
+ char *p;
+ if (len < 6) return EINA_FALSE;
+
+ p = (char *)data;
+ if (!p) return EINA_FALSE;
+ if (strncmp(p, "file:/", 6))
+ {
+ if (*p != '/') return EINA_FALSE;
+ }
+ return EINA_TRUE;
+}
+
+static Eina_Bool
_wl_targets_converter(char *target, Wl_Cnp_Selection *sel EINA_UNUSED, void *data EINA_UNUSED, int size EINA_UNUSED, void **data_ret, int *size_ret)
{
cnp_debug("in\n");
//Wl_Cnp_Selection *sel = &wl_cnp_selection;
Wl_Cnp_Selection *sel = wl_cnp_selections + selection;
//
+ // TIZEN_ONLY(20160811): To distinguish clipboard selection in cbhm
+ const char **t = NULL;
+ //
+
if ((!selbuf) && (format != ELM_SEL_FORMAT_IMAGE))
return elm_object_cnp_selection_clear(obj, selection);
if (selbuf)
{
+ int i = 0, count = 0;
+ Eina_Bool is_uri = EINA_FALSE;
+ const char **types;
+
if (format & ELM_SEL_FORMAT_IMAGE)
{
/* FIXME */
}
else
{
- const char *types[10] = {0, };
- int i = -1;
+ free(sel->selbuf);
+ sel->buflen = buflen;
+ sel->selbuf = strdup((char*)selbuf);
+ }
- // TIZEN_ONLY(20160706): To distinguish clipboard selection in cbhm
- if (selection == ELM_SEL_TYPE_CLIPBOARD)
+ is_uri = _wl_is_uri_type_data(selbuf, buflen);
+ types = malloc(sizeof(char *));
+ if (!types) return EINA_FALSE;
+
+// TIZEN_ONLY(20160811): To distinguish clipboard selection in cbhm
+ if (selection == ELM_SEL_TYPE_CLIPBOARD)
+ {
+ types[count] = "CLIPBOARD_BEGIN";
+ count++;
+ t = realloc(types, sizeof(char *) * count);
+ if (!t)
{
- types[++i] = "CLIPBOARD_BEGIN";
+ free(types);
+ return EINA_FALSE;
}
- //
+ types = t;
+ }
- if ((format & ELM_SEL_FORMAT_MARKUP) ||
- (format & ELM_SEL_FORMAT_TEXT))
+ for (i = 0, count = count + 1; i < CNP_N_ATOMS; i++)
+ {
+ if (format & _atoms[i].formats)
{
- types[++i] = "application/x-elementary-markup";
- types[++i] = "text/plain";
- types[++i] = "text/plain;charset=utf-8";
+ if ((is_uri) || ((!is_uri) &&
+ strcmp(_atoms[i].name, "text/uri-list")))
+ {
+
+ types[count - 1] = _atoms[i].name;
+ count++;
+ t = realloc(types, sizeof(char *) * count);
+ if (!t)
+ {
+ free(types);
+ return EINA_FALSE;
+ }
+ types = t;
+ }
}
+ }
- if (format & ELM_SEL_FORMAT_HTML)
+/*
+ for (i = 0, count = 1; i < CNP_N_ATOMS; i++)
+ {
+ if (format & _atoms[i].formats)
{
- types[++i] = "text/html";
- types[++i] = "text/html;charset=utf-8";
- }
+ if ((is_uri) || ((!is_uri) &&
+ strcmp(_atoms[i].name, "text/uri-list")))
+ {
+ const char **t = NULL;
- // TIZEN_ONLY(20160706): To distinguish clipboard selection in cbhm
- if (selection == ELM_SEL_TYPE_CLIPBOARD)
+ types[count - 1] = _atoms[i].name;
+ count++;
+ t = realloc(types, sizeof(char *) * count);
+ if (!t)
+ {
+ free(types);
+ return EINA_FALSE;
+ }
+ types = t;
+ }
+ }
+ }
+*/
+ if (selection == ELM_SEL_TYPE_CLIPBOARD)
+ {
+ types[count] = "CLIPBOARD_END";
+ count++;
+ t = realloc(types, sizeof(char *) * count);
+ if (!t)
{
- types[++i] = "CLIPBOARD_END";
+ free(types);
+ return EINA_FALSE;
}
- //
+ types = t;
+ }
+//
+ types[count - 1] = 0;
- if (i < 0) return EINA_FALSE;
+ if (i < 0) return EINA_FALSE;
- ecore_wl_dnd_selection_set(ecore_wl_input_get(), types);
+ ecore_wl_dnd_selection_set(ecore_wl_input_get(), types);
- free(sel->selbuf);
- sel->buflen = buflen;
- sel->selbuf = strdup((char*)selbuf);
-
- return EINA_TRUE;
- }
+ free(types);
+ return EINA_TRUE;
}
else
- sel->selbuf = NULL;
+ {
+ sel->selbuf = NULL;
+ }
return EINA_FALSE;
}