2010-07-11 14:19:27 -07:00
|
|
|
#include "private.h"
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
typedef struct _Elm_Params_Notify Elm_Params_Notify;
|
|
|
|
|
2012-11-06 11:54:16 -08:00
|
|
|
struct _Elm_Params_Notify
|
|
|
|
{
|
|
|
|
Elm_Params base;
|
|
|
|
Evas_Object *content; /* part name whose obj is to be set as content */
|
|
|
|
Eina_Bool allow_events_exists;
|
|
|
|
Eina_Bool allow_events;
|
|
|
|
Eina_Bool timeout_exists;
|
|
|
|
double timeout;
|
2010-07-11 14:19:27 -07:00
|
|
|
|
2012-11-06 11:54:16 -08:00
|
|
|
const char *orient;
|
2010-07-11 14:19:27 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char *orients[] = {
|
2012-11-06 11:54:16 -08:00
|
|
|
"top",
|
|
|
|
"center",
|
|
|
|
"bottom",
|
|
|
|
"left",
|
|
|
|
"right",
|
|
|
|
"top_left",
|
|
|
|
"top_right",
|
|
|
|
"bottom_left",
|
|
|
|
"bottom_right",
|
|
|
|
NULL
|
2010-07-11 14:19:27 -07:00
|
|
|
};
|
|
|
|
|
2012-11-06 11:54:16 -08:00
|
|
|
/* keeping old externals orient api for notify, but taking away the
|
|
|
|
* introduced deprecation warning by copying the deprecated code
|
|
|
|
* here */
|
|
|
|
static Elm_Notify_Orient
|
|
|
|
_elm_notify_orient_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Elm_Notify_Orient orient;
|
|
|
|
double horizontal, vertical;
|
|
|
|
|
|
|
|
elm_notify_align_get(obj, &horizontal, &vertical);
|
|
|
|
|
2020-05-09 01:25:21 -07:00
|
|
|
if (EINA_DBL_EQ(horizontal, 0.5) && EINA_DBL_EQ(vertical, 0.0))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_TOP;
|
2020-05-09 01:25:21 -07:00
|
|
|
else if (EINA_DBL_EQ(horizontal, 0.5) && EINA_DBL_EQ(vertical, 0.5))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_CENTER;
|
2020-05-09 01:25:21 -07:00
|
|
|
else if (EINA_DBL_EQ(horizontal, 0.5) && EINA_DBL_EQ(vertical, 1.0))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_BOTTOM;
|
2020-05-09 01:25:21 -07:00
|
|
|
else if (EINA_DBL_EQ(horizontal, 0.0) && EINA_DBL_EQ(vertical, 0.5))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_LEFT;
|
2020-05-09 01:25:21 -07:00
|
|
|
else if (EINA_DBL_EQ(horizontal, 1.0) && EINA_DBL_EQ(vertical, 0.5))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_RIGHT;
|
2020-05-09 01:25:21 -07:00
|
|
|
else if (EINA_DBL_EQ(horizontal, 0.0) && EINA_DBL_EQ(vertical, 0.0))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_TOP_LEFT;
|
2020-05-09 01:25:21 -07:00
|
|
|
else if (EINA_DBL_EQ(horizontal, 1.0) && EINA_DBL_EQ(vertical, 0.0))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_TOP_RIGHT;
|
2020-05-09 01:25:21 -07:00
|
|
|
else if (EINA_DBL_EQ(horizontal, 0.0) && EINA_DBL_EQ(vertical, 1.0))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_BOTTOM_LEFT;
|
2020-05-09 01:25:21 -07:00
|
|
|
else if (EINA_DBL_EQ(horizontal, 1.0) && EINA_DBL_EQ(vertical, 1.0))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_BOTTOM_RIGHT;
|
|
|
|
else
|
|
|
|
orient = ELM_NOTIFY_ORIENT_TOP;
|
|
|
|
return orient;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_notify_orient_set(Evas_Object *obj,
|
|
|
|
Elm_Notify_Orient orient)
|
|
|
|
{
|
|
|
|
double horizontal = 0, vertical = 0;
|
|
|
|
|
|
|
|
switch (orient)
|
|
|
|
{
|
|
|
|
case ELM_NOTIFY_ORIENT_TOP:
|
|
|
|
horizontal = 0.5; vertical = 0.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_CENTER:
|
|
|
|
horizontal = 0.5; vertical = 0.5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_BOTTOM:
|
|
|
|
horizontal = 0.5; vertical = 1.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_LEFT:
|
|
|
|
horizontal = 0.0; vertical = 0.5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_RIGHT:
|
|
|
|
horizontal = 1.0; vertical = 0.5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_TOP_LEFT:
|
|
|
|
horizontal = 0.0; vertical = 0.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_TOP_RIGHT:
|
|
|
|
horizontal = 1.0; vertical = 0.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_BOTTOM_LEFT:
|
|
|
|
horizontal = 0.0; vertical = 1.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT:
|
|
|
|
horizontal = 1.0; vertical = 1.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_LAST:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_notify_align_set(obj, horizontal, vertical);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Elm_Notify_Orient
|
|
|
|
_orient_get(const char *orient)
|
2010-07-11 14:19:27 -07:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2012-11-06 11:54:16 -08:00
|
|
|
assert(sizeof(orients) / sizeof(orients[0]) ==
|
|
|
|
ELM_NOTIFY_ORIENT_LAST + 1);
|
2010-07-11 14:19:27 -07:00
|
|
|
|
elementary - fixed some logic errors patched by rajeev.r@samsung.com
Hi all,
I found few memory related issues in elementary package when performed static analysis on it.
These issues include:
Array indices getting out of bounds, freed memory address being passed to a function as parameter, memory not getting cleaned up because of earlier return statement.
Issues details:
1. In elm_widget.c inside function elm_widget_signal_callback_del(), it is possible that freed memory address esd is passed to the sd->callback_del_func(). I think it should be data, not esd.
Moreover what if the callback frees memory for data, then the other problem is that the return value is data from the function elm_widget_signal_callback_del() which in my opinion can be a problem.
2. Inside directory src/edje_externals for files elm_genlist.c, elm_notify.c, elm_list.c, elm_thumb.c and elm_map.c, array indices can go beyound bounary.
sizeof() operator for an array of character pointers will return [number of elements in the array * size of (char*)], basically 4 times the number of elements which has been taken care in assertion inside src/edje_extenarnals
while performing assertion but has been missed in the next statement in the loop condition.
3. In file src/lib/elm_config.c inside function _elm_config_profiles_list, freeing of file iterator has been missed out.
Please review the attached patch and let me know your opinion.
Thanks.
Regards,
Rajeev
SVN revision: 63550
2011-09-22 17:02:13 -07:00
|
|
|
for (i = 0; i < ELM_NOTIFY_ORIENT_LAST; i++)
|
2010-10-22 14:41:27 -07:00
|
|
|
if (!strcmp(orient, orients[i])) return i;
|
2010-07-11 14:19:27 -07:00
|
|
|
|
|
|
|
return ELM_NOTIFY_ORIENT_LAST;
|
|
|
|
}
|
|
|
|
|
2012-11-06 11:54:16 -08:00
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
external_notify_state_set(void *data EINA_UNUSED,
|
2012-11-06 11:54:16 -08:00
|
|
|
Evas_Object *obj, const void *from_params,
|
2014-01-06 06:30:02 -08:00
|
|
|
const void *to_params, float pos EINA_UNUSED)
|
2010-07-11 14:19:27 -07:00
|
|
|
{
|
2012-11-06 11:54:16 -08:00
|
|
|
const Elm_Params_Notify *p;
|
|
|
|
|
|
|
|
if (to_params) p = to_params;
|
|
|
|
else if (from_params)
|
|
|
|
p = from_params;
|
|
|
|
else return;
|
|
|
|
|
|
|
|
if (p->content)
|
|
|
|
{
|
|
|
|
elm_object_content_set(obj, p->content);
|
|
|
|
}
|
|
|
|
if (p->allow_events_exists)
|
|
|
|
elm_notify_allow_events_set(obj, p->allow_events);
|
|
|
|
if (p->timeout_exists)
|
|
|
|
elm_notify_timeout_set(obj, p->timeout);
|
|
|
|
if (p->orient)
|
|
|
|
{
|
|
|
|
Elm_Notify_Orient set = _orient_get(p->orient);
|
|
|
|
if (set == ELM_NOTIFY_ORIENT_LAST) return;
|
|
|
|
_elm_notify_orient_set(obj, set);
|
|
|
|
}
|
2010-07-11 14:19:27 -07:00
|
|
|
}
|
|
|
|
|
2012-11-06 11:54:16 -08:00
|
|
|
static Eina_Bool
|
2014-01-06 06:30:02 -08:00
|
|
|
external_notify_param_set(void *data EINA_UNUSED,
|
2012-11-06 11:54:16 -08:00
|
|
|
Evas_Object *obj, const Edje_External_Param *param)
|
2010-07-11 14:19:27 -07:00
|
|
|
{
|
2012-11-06 11:54:16 -08:00
|
|
|
if ((!strcmp(param->name, "content"))
|
|
|
|
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
|
|
|
|
{
|
|
|
|
Evas_Object *content =
|
2016-02-04 23:13:11 -08:00
|
|
|
external_common_param_elm_layout_get(obj, param);
|
2012-11-06 11:54:16 -08:00
|
|
|
if ((strcmp(param->s, "")) && (!content))
|
|
|
|
return EINA_FALSE;
|
|
|
|
elm_object_content_set(obj, content);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if ((!strcmp(param->name, "allow_events"))
|
|
|
|
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
|
|
|
|
{
|
|
|
|
elm_notify_allow_events_set(obj, param->i);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if ((!strcmp(param->name, "timeout"))
|
|
|
|
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
|
|
|
|
{
|
|
|
|
elm_notify_timeout_set(obj, param->d);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if ((!strcmp(param->name, "orient"))
|
|
|
|
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE))
|
|
|
|
{
|
|
|
|
Elm_Notify_Orient set = _orient_get(param->s);
|
|
|
|
if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
|
|
|
|
_elm_notify_orient_set(obj, set);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ERR("unknown parameter '%s' of type '%s'",
|
|
|
|
param->name, edje_external_param_type_str(param->type));
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
2010-07-11 14:19:27 -07:00
|
|
|
}
|
|
|
|
|
2012-11-06 11:54:16 -08:00
|
|
|
static Eina_Bool
|
2014-01-06 06:30:02 -08:00
|
|
|
external_notify_param_get(void *data EINA_UNUSED,
|
2012-11-06 11:54:16 -08:00
|
|
|
const Evas_Object *obj, Edje_External_Param *param)
|
2010-07-11 14:19:27 -07:00
|
|
|
{
|
2012-11-06 11:54:16 -08:00
|
|
|
if (!strcmp(param->name, "content"))
|
|
|
|
{
|
|
|
|
/* not easy to get content name back from live object */
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
else if ((!strcmp(param->name, "allow_events"))
|
|
|
|
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
|
|
|
|
{
|
|
|
|
param->i = elm_notify_allow_events_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if ((!strcmp(param->name, "timeout"))
|
|
|
|
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
|
|
|
|
{
|
|
|
|
param->d = elm_notify_timeout_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if ((!strcmp(param->name, "orient"))
|
|
|
|
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE))
|
|
|
|
{
|
|
|
|
Elm_Notify_Orient set = _elm_notify_orient_get(obj);
|
|
|
|
if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
|
|
|
|
param->s = orients[set];
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ERR("unknown parameter '%s' of type '%s'",
|
|
|
|
param->name, edje_external_param_type_str(param->type));
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
2010-07-11 14:19:27 -07:00
|
|
|
}
|
|
|
|
|
2012-11-06 11:54:16 -08:00
|
|
|
static void *
|
2014-01-06 06:30:02 -08:00
|
|
|
external_notify_params_parse(void *data EINA_UNUSED, Evas_Object *obj,
|
2014-01-23 03:08:10 -08:00
|
|
|
const Eina_List *params)
|
|
|
|
{
|
2012-11-06 11:54:16 -08:00
|
|
|
Elm_Params_Notify *mem;
|
|
|
|
Edje_External_Param *param;
|
|
|
|
const Eina_List *l;
|
|
|
|
|
|
|
|
mem = calloc(1, sizeof(Elm_Params_Notify));
|
|
|
|
if (!mem)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(params, l, param)
|
|
|
|
{
|
|
|
|
if (!strcmp(param->name, "content"))
|
2016-02-04 23:13:11 -08:00
|
|
|
mem->content = external_common_param_elm_layout_get(obj, param);
|
2012-11-06 11:54:16 -08:00
|
|
|
else if (!strcmp(param->name, "timeout"))
|
|
|
|
{
|
|
|
|
mem->timeout = param->d;
|
|
|
|
mem->timeout_exists = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "allow_events"))
|
|
|
|
{
|
|
|
|
mem->allow_events = param->i;
|
|
|
|
mem->allow_events_exists = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "orient"))
|
|
|
|
mem->orient = eina_stringshare_add(param->s);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mem;
|
2010-07-11 14:19:27 -07:00
|
|
|
}
|
|
|
|
|
2012-11-06 11:54:16 -08:00
|
|
|
static Evas_Object *
|
2014-01-06 06:30:02 -08:00
|
|
|
external_notify_content_get(void *data EINA_UNUSED,
|
2012-11-06 11:54:16 -08:00
|
|
|
const Evas_Object *obj, const char *content)
|
2010-08-01 10:29:20 -07:00
|
|
|
{
|
2012-11-06 11:54:16 -08:00
|
|
|
if (!strcmp(content, "content"))
|
|
|
|
return elm_object_content_get(obj);
|
2010-08-01 10:29:20 -07:00
|
|
|
|
2012-11-06 11:54:16 -08:00
|
|
|
ERR("unknown content '%s'", content);
|
|
|
|
return NULL;
|
2010-08-01 10:29:20 -07:00
|
|
|
}
|
|
|
|
|
2012-11-06 11:54:16 -08:00
|
|
|
static void
|
2014-01-23 03:08:10 -08:00
|
|
|
external_notify_params_free(void *params)
|
|
|
|
{
|
2012-11-06 11:54:16 -08:00
|
|
|
free(params);
|
2010-07-11 14:19:27 -07:00
|
|
|
}
|
|
|
|
|
2014-01-23 03:08:10 -08:00
|
|
|
static Edje_External_Param_Info external_notify_params[] =
|
|
|
|
{
|
2012-11-06 11:54:16 -08:00
|
|
|
DEFINE_EXTERNAL_COMMON_PARAMS,
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_STRING("content"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_BOOL("allow_events"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_DOUBLE("timeout"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_SENTINEL
|
2010-07-11 14:19:27 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_EXTERNAL_ICON_ADD(notify, "notify");
|
2012-11-06 11:54:16 -08:00
|
|
|
DEFINE_EXTERNAL_TYPE_SIMPLE(notify, "Notify");
|