Exemplo n.º 1
0
static void
_icon_thumb_finish(Elm_Icon_Smart_Data *sd,
                   Ethumb_Client *ethumbd)
{
   const char *file = NULL, *group = NULL;
   Eina_Bool ret;

   elm_image_file_get(ELM_WIDGET_DATA(sd)->obj, &file, &group);
   file = eina_stringshare_ref(file);
   group = eina_stringshare_ref(group);

   ret = _icon_thumb_display(sd);

   if (!ret && file)
     {
        if (!sd->thumb.retry)
          {
             _elm_icon_retry = eina_list_append(_elm_icon_retry, sd);
             sd->thumb.retry = EINA_TRUE;
          }

        /* Back to previous image */
        elm_image_file_set(ELM_WIDGET_DATA(sd)->obj, file, group);
     }

   _icon_thumb_cleanup(ethumbd);

   eina_stringshare_del(file);
   eina_stringshare_del(group);
}
Exemplo n.º 2
0
static void
_e_drop_handler_active_check(E_Drop_Handler *h, const E_Drag *drag, Eina_Stringshare *type)
{
   unsigned int i, j;

   if (h->hidden) return;
   for (i = 0; i < h->num_types; i++)
     {
        if (drag)
          {
             for (j = 0; j < drag->num_types; j++)
               {
                  if (h->types[i] != drag->types[j]) continue;
                  h->active = 1;
                  h->active_type = eina_stringshare_ref(h->types[i]);
                  return;
               }
          }
        else
          {
             if (h->types[i] != type) continue;
             h->active = 1;
             h->active_type = eina_stringshare_ref(h->types[i]);
             return;
          }
     }
}
Exemplo n.º 3
0
static void
_db_build_implement(Eolian_Class *cl, Eolian_Function *foo_id)
{
   if (foo_id->type == EOLIAN_PROP_SET)
     {
        if (foo_id->set_impl) return;
     }
   else if (foo_id->type == EOLIAN_PROP_GET)
     {
        if (foo_id->get_impl) return;
     }
   else if (foo_id->get_impl && foo_id->set_impl) return;

   Eolian_Implement *impl = calloc(1, sizeof(Eolian_Implement));

   if (foo_id->type == EOLIAN_PROP_SET)
     impl->base = foo_id->set_base;
   else
     impl->base = foo_id->base;
   eina_stringshare_ref(impl->base.file);

   impl->klass = cl;
   impl->foo_id = foo_id;
   impl->full_name = eina_stringshare_printf("%s.%s", cl->full_name,
                                             foo_id->name);

   if (foo_id->type == EOLIAN_PROPERTY)
     {
        if (foo_id->get_impl)
          {
             impl->is_prop_set = EINA_TRUE;
             foo_id->set_impl = impl;
          }
        else if (foo_id->set_impl)
          {
             impl->is_prop_get = EINA_TRUE;
             foo_id->get_impl = impl;
          }
        else
          foo_id->get_impl = foo_id->set_impl = impl;
     }
   else if (foo_id->type == EOLIAN_PROP_SET)
     {
        impl->is_prop_set = EINA_TRUE;
        foo_id->set_impl = impl;
     }
   else if (foo_id->type == EOLIAN_PROP_GET)
     {
        impl->is_prop_get = EINA_TRUE;
        foo_id->get_impl = impl;
     }
   else
     foo_id->get_impl = foo_id->set_impl = impl;

   cl->implements = eina_list_append(cl->implements, impl);
}
Exemplo n.º 4
0
EAPI Eina_Bool
eolian_function_is_constructor(const Eolian_Function *fid, const Eolian_Class *klass)
{
   EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
   Eina_Stringshare *s = eina_stringshare_ref(klass->base.name);
   Eina_Bool r = !!eina_list_search_sorted_list
     (fid->ctor_of, EINA_COMPARE_CB(strcmp), s);
   eina_stringshare_del(s);
   return r;
}
Exemplo n.º 5
0
void
eio_progress_send(Ecore_Thread *thread, Eio_File_Progress *op, long long current, long long max)
{
   Eio_Progress *progress;

   if (op->progress_cb == NULL)
     return ;

   progress = eio_progress_malloc();
   if (!progress) return ;

   progress->op = op->op;
   progress->current = current;
   progress->max = max;
   progress->percent = (float) current * 100.0 / (float) max;
   progress->source = eina_stringshare_ref(op->source);
   progress->dest = eina_stringshare_ref(op->dest);

   ecore_thread_feedback(thread, progress);
}
Exemplo n.º 6
0
static void
_url_activated_cb(void *data, Evas_Object *obj, void *event_info)
{
   App_Data *ad = data;
   Tab_Data *td;
   const char *uri = eina_stringshare_ref(elm_object_text_get(obj));

   if (!ad->current_tab)
     td = tab_add(ad);
   else
     td = ad->current_tab;
   tab_uri_set(td, uri);
   eina_stringshare_del(uri);
}
Exemplo n.º 7
0
static void
_wkb_config_theme_changed(struct wkb_config_key *key)
{
   const char *theme;
   if (!(theme = wkb_config_key_get_string(key)))
     {
       DBG("Error retrieving theme value");
       return;
     }

   DBG("New theme '%s'", theme);
   eina_stringshare_ref(theme);
   ecore_event_add(WKB_THEME_CHANGED, (void *) theme, _wkb_theme_changed_end_cb, (void *) theme);
}
Exemplo n.º 8
0
static void
_joystick_register(const char* syspath)
{
   int fd, index;
   const char *devnode;
   Joystick_Info *ji;
   Joystick_Mapper mapper;

   devnode = eeze_udev_syspath_get_devpath(syspath);
   if (!devnode) return;
   if (!eina_str_has_prefix(devnode, joystickPrefix)) goto register_failed;

   mapper = _joystick_mapping_info_get(syspath);
   if (!mapper)
     {
        ERR("Unsupported joystick.");
        goto register_failed;
     }

   index = _joystick_index_get(devnode);
   if (index == -1)
     {
        ERR("Invalid index value.");
        goto register_failed;
     }

   ji = calloc(1, sizeof(Joystick_Info));
   if (!ji)
     {
        ERR("Cannot allocate memory.");
        goto register_failed;
     }

   ji->index = index;
   ji->mapper = mapper;
   ji->system_path = eina_stringshare_ref(syspath);

   fd = open(devnode, O_RDONLY | O_NONBLOCK);
   ji->fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ,
                                             _fd_handler_cb, ji, 0, 0);

   joystick_list = eina_list_append(joystick_list, ji);
   _joystick_connected_event_add(index, EINA_TRUE);

register_failed:
   eina_stringshare_del(devnode);
}
static int
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
   Population *pop;

   pop = cfd->data;
   e_border_button_bindings_ungrab_all();
   
   pop->conf->penguins_count = cfdata->penguins_count;
   pop->conf->zoom = cfdata->zoom;
   pop->conf->alpha = cfdata->alpha;
   
   eina_stringshare_del(pop->conf->theme);
   pop->conf->theme = eina_stringshare_ref(cfdata->theme);

   e_config_save_queue();
   e_border_button_bindings_grab_all();

   _penguins_cb_config_updated(pop);
   return 1;
}
Exemplo n.º 10
0
static Evry_Item_App *
_item_exe_add(Plugin *p, const char *exe, int match)
{
   Evry_Item_App *app = NULL;

   if ((app = eina_hash_find(p->added, exe)))
     {
        if (eina_list_data_find_list(p->base.items, app))
          return app;
     }

   if (!app)
     {
        app = _item_new(p, ecore_file_file_get(exe), exe);
        app->file = eina_stringshare_ref(EVRY_ITEM(app)->id);
     }

   EVRY_ITEM(app)->fuzzy_match = match;
   EVRY_PLUGIN_ITEM_APPEND(p, app);

   return app;
}
Exemplo n.º 11
0
int
main(int argc, char **argv)
{
   const char *str, *str2;
   const char *prologe = "The Cylons were created by man. They rebelled. They "
                         "evolved.";
   const char *prologe2 = "%d Cylon models. %d are known. %d live in secret. "
                          "%d will be revealed.";
   const char *prologe3 = "There are many copies. And they have a plan.";

   eina_init();

   str = eina_stringshare_add_length(prologe, 31);
   printf("%s\n", str);
   printf("length: %d\n", eina_stringshare_strlen(str));
   eina_stringshare_del(str);

   str = eina_stringshare_printf(prologe2, 12, 7, 4, 1);
   printf("%s\n", str);
   eina_stringshare_del(str);

   str = eina_stringshare_nprintf(45, "%s", prologe3);
   printf("%s\n", str);
   str2 = eina_stringshare_add(prologe3);
   printf("%s\n", str2);
   eina_stringshare_ref(str2);
   eina_stringshare_del(str2);
   printf("%s\n", str2);

   eina_stringshare_replace(&str, prologe);
   printf("%s\n", str);

   eina_stringshare_del(str);
   eina_stringshare_del(str2);

   eina_shutdown();

   return 0;
}
Exemplo n.º 12
0
static Emotion_Webcam *
_emotion_webcam_new(const char *syspath)
{
   Emotion_Webcam *test;
   const char *device;
   char *local;

   test = malloc(sizeof (Emotion_Webcam));
   if (!test) return NULL;

   test->custom = NULL;
   test->syspath = eina_stringshare_ref(syspath);
   test->name = eeze_udev_syspath_get_sysattr(syspath, "name");

   device = eeze_udev_syspath_get_property(syspath, "DEVNAME");
   local = alloca(eina_stringshare_strlen(device) + 8);
   snprintf(local, eina_stringshare_strlen(device) + 8, "v4l2://%s", device);
   test->device = eina_stringshare_add(local);
   eina_stringshare_del(device);
   test->filename = test->device + 7;

   return test;
}
Exemplo n.º 13
0
static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
   /* stacking */
   if ((!cfdata->escfg->popup) && (cfdata->escfg->layer == 1))
     cfdata->layer = 0;
   else if ((cfdata->escfg->popup) && (cfdata->escfg->layer == 0))
     cfdata->layer = 1;
   else if ((cfdata->escfg->popup) && (cfdata->escfg->layer == E_LAYER_ABOVE))
     cfdata->layer = 2;
   else
     cfdata->layer = 2;
   cfdata->overlap = cfdata->escfg->overlap;

   /* position */
   cfdata->orient = cfdata->escfg->orient;
   cfdata->fit_along = cfdata->escfg->fit_along;

   /* size */
   cfdata->size = cfdata->escfg->size;

   /* style */
   if (cfdata->escfg->style)
     cfdata->style = eina_stringshare_ref(cfdata->escfg->style);
   else
     cfdata->style = eina_stringshare_add("");

   /* autohide */
   cfdata->autohide = cfdata->escfg->autohide;
   cfdata->autohide_action = cfdata->escfg->autohide_show_action;
   cfdata->hide_timeout = cfdata->escfg->hide_timeout;
   cfdata->hide_duration = cfdata->escfg->hide_duration;

   /* desktop */
   cfdata->desk_show_mode = cfdata->escfg->desk_show_mode;
   cfdata->desk_list = cfdata->escfg->desk_list;
}
Exemplo n.º 14
0
/**
 * @return Returns the XDG Trash local directory or NULL on errors
 * return value must be freed with eina_stringshare_del.
 * @brief Retrieves the XDG Trash local directory
 */
EAPI const char*
efreet_trash_dir_get(const char *file)
{
    char buf[PATH_MAX];
    struct stat s_dest;
    struct stat s_src;
    const char *trash_dir = NULL;

    if (file)
    {
        if (stat(efreet_data_home_get(), &s_dest) != 0)
            return NULL;

        if (stat(file, &s_src) != 0)
            return NULL;
    }

    if (!file || s_src.st_dev == s_dest.st_dev)
    {
        if (efreet_trash_dir && ecore_file_exists(efreet_trash_dir))
        {
            eina_stringshare_ref(efreet_trash_dir);
            return efreet_trash_dir;
        }

        snprintf(buf, sizeof(buf), "%s/Trash", efreet_data_home_get());
        if (!ecore_file_exists(buf) && !ecore_file_mkpath(buf))
            return NULL;

        IF_RELEASE(efreet_trash_dir);
        efreet_trash_dir = eina_stringshare_add(buf);
        trash_dir = eina_stringshare_ref(efreet_trash_dir);
    }
    else
    {
        char *dir;
        char path[PATH_MAX];

        strncpy(buf, file, PATH_MAX);
        buf[PATH_MAX - 1] = 0;
        path[0] = 0;

        while (strlen(buf) > 1)
        {
            strncpy(path, buf, PATH_MAX);
            dir = dirname(buf);

            if (stat(dir, &s_dest) == 0)
            {
                if (s_src.st_dev == s_dest.st_dev){

                    strncpy(buf, dir, PATH_MAX);
                    continue;
                }
                else
                {
                    /* other device */
                    break;
                }
            }
            path[0] = 0;
            break;
        }

        if (path[0])
        {
            snprintf(buf, sizeof(buf), "%s/.Trash-%d", path, getuid());
            if (!ecore_file_exists(buf) && !ecore_file_mkpath(buf))
                return NULL;

            trash_dir = eina_stringshare_add(buf);
        }
    }
    if (trash_dir)
    {
        snprintf(buf, sizeof(buf), "%s/files", trash_dir);
        if (!ecore_file_exists(buf) && !ecore_file_mkpath(buf))
        {
            eina_stringshare_del(trash_dir);
            return NULL;
        }

        snprintf(buf, sizeof(buf), "%s/info", trash_dir);
        if (!ecore_file_exists(buf) && !ecore_file_mkpath(buf))
        {
            eina_stringshare_del(trash_dir);
            return NULL;
        }
    }

    return trash_dir;
}
Exemplo n.º 15
0
/**
 * @brief Make a method call using a connected client
 *
 * This function is used to make a method call on @p client as defined in
 * @p content, using content-type defined by @p transport and the deserialization
 * function specified by @p cb.  This should generally not be used by users, as azy_parser
 * will automatically generate the correct calls from a .azy file.
 * @param client The client (NOT NULL)
 * @param content The content containing the method name and parameters (NOT NULL)
 * @param transport The content-type (xml/json/etc) to use
 * @param cb The deserialization callback to use for the response
 * @return The #Azy_Client_Call_Id of the transmission, to be used with azy_client_callback_set,
 * or 0 on failure
 */
Azy_Client_Call_Id
azy_client_call(Azy_Client       *client,
                Azy_Content      *content,
                Azy_Net_Transport transport,
                Azy_Content_Cb    cb)
{
   Eina_Strbuf *msg;
   Azy_Client_Handler_Data *hd;

   DBG("(client=%p, net=%p, content=%p)", client, client->net, content);

   if (!AZY_MAGIC_CHECK(client, AZY_MAGIC_CLIENT))
     {
        AZY_MAGIC_FAIL(client, AZY_MAGIC_CLIENT);
        return 0;
     }
   EINA_SAFETY_ON_NULL_RETURN_VAL(client->net, 0);
   EINA_SAFETY_ON_NULL_RETURN_VAL(content, 0);
   EINA_SAFETY_ON_NULL_RETURN_VAL(content->method, 0);

   INFO("New method call: '%s'", content->method);

   while (++azy_client_send_id__ < 1) ;

   content->id = azy_client_send_id__;

   azy_net_transport_set(client->net, transport);
   if (!azy_content_serialize_request(content, transport))
     return 0;
   azy_net_type_set(client->net, AZY_NET_TYPE_POST);
   if (!client->net->http.req.http_path)
     {
        WARN("URI currently set to NULL, defaulting to \"/\"");
        azy_net_uri_set(client->net, "/");
     }

   azy_net_message_length_set(client->net, content->length);
   msg = azy_net_header_create(client->net);
   EINA_SAFETY_ON_NULL_GOTO(msg, error);

   if (azy_rpc_log_dom >= 0)
     {
        char buf[64];
        snprintf(buf, sizeof(buf), "\nSENDING >>>>>>>>>>>>>>>>>>>>>>>>\n%%.%is%%.%llis\n>>>>>>>>>>>>>>>>>>>>>>>>",
            eina_strbuf_length_get(msg), content->length);
        RPC_DBG(buf, eina_strbuf_string_get(msg), content->buffer);
     }

   EINA_SAFETY_ON_TRUE_GOTO(!ecore_con_server_send(client->net->conn, eina_strbuf_string_get(msg), eina_strbuf_length_get(msg)), error);
   INFO("Send [1/2] complete! %zu bytes queued for sending.", eina_strbuf_length_get(msg));
   eina_strbuf_free(msg);
   msg = NULL;

   EINA_SAFETY_ON_TRUE_GOTO(!ecore_con_server_send(client->net->conn, content->buffer, content->length), error);
   INFO("Send [2/2] complete! %lli bytes queued for sending.", content->length);
   ecore_con_server_flush(client->net->conn);

   hd = calloc(1, sizeof(Azy_Client_Handler_Data));
   EINA_SAFETY_ON_NULL_RETURN_VAL(hd, 0);
   hd->client = client;
   hd->method = eina_stringshare_ref(content->method);
   hd->callback = cb;
   hd->type = AZY_NET_TYPE_POST;
   hd->content_data = content->data;
   hd->send = eina_strbuf_new();
   eina_strbuf_append_length(hd->send, (char *)content->buffer, content->length);

   hd->id = azy_client_send_id__;
   AZY_MAGIC_SET(hd, AZY_MAGIC_CLIENT_DATA_HANDLER);
   if (!client->conns)
     {
        client->recv = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
                                               (Ecore_Event_Handler_Cb)_azy_client_handler_data, hd);
        ecore_con_server_data_set(client->net->conn, client);
     }

   client->conns = eina_list_append(client->conns, hd);

   DBG("(client=%p, net=%p, content=%p, hd=%p)", client, client->net, content, hd);
   return azy_client_send_id__;
error:
   if (msg)
     eina_strbuf_free(msg);
   return 0;
}
Exemplo n.º 16
0
void
vm_info_cb(void *data, Evas_Object *obj, void *event_info)
{
	Elm_Genlist_Item *gl;
	vmitem *item;
	zrpc_vm *vm;
	const char *os_icon, *state;
	char tmp[PATH_MAX];
	Eina_List *l;
	zrpc_disk *d;
	zrpc_vif *v;
	int cpus;

	elm_toolbar_item_unselect_all(win->main_vm->bar);
	gl = elm_genlist_selected_item_get(win->main_vm->list);
	if (!gl) return;

	ecore_timer_del(win->timerget);

	item = (vmitem*)elm_genlist_item_data_get(gl);
	vm = item->vm;
	win->info->vmuuid = eina_stringshare_ref(vm->uuid);
	evas_object_smart_callback_del(win->main_vm->list, "clicked", vm_info_cb);
	create_info_vm();
	win->info->state = NULL;
	zinfo_job_updatevm(win);


	for (cpus = 0;cpus < vm->vcpus;cpus++)
	{
		
		win->info->cpus = elm_icon_add(win->win);
		elm_icon_file_set(win->info->cpus, "images/cpu.png", NULL);
		elm_icon_scale_set(win->info->cpus, 0, 0);
		elm_icon_smooth_set(win->info->cpus, 1);
		evas_object_size_hint_weight_set(win->info->state_icon, 0.0, 0.0);
		evas_object_size_hint_align_set(win->info->state_icon, 0.0, 1.0);
		elm_box_pack_after(win->info->vbox2, win->info->cpus, win->info->state_label);
		evas_object_show(win->info->cpus);
	}

	elm_frame_label_set(win->info->frame, vm->name);
	os_icon = get_os_icon(vm);
	elm_icon_file_set(win->info->os_icon, os_icon, NULL);
	eina_stringshare_del(os_icon);
	elm_label_label_set(win->info->os, vm->os);
	elm_label_label_set (win->info->uuid, vm->uuid);
	elm_label_label_set(win->info->puuid, vm->puuid);
	EINA_LIST_FOREACH(vm->disks, l, d)
		elm_hoversel_item_add(win->info->disks, d->ext_dev, NULL, ELM_ICON_NONE, NULL, d);
		
	state = get_state_icon(vm->state);
	elm_icon_file_set(win->info->state_icon, state, NULL);
	eina_stringshare_del(state);

	EINA_LIST_FOREACH(vm->vifs, l, v)
		elm_hoversel_item_add(win->info->vifs, v->name, NULL, ELM_ICON_NONE, NULL, v);


	sprintf(tmp, "Kernel: %s", vm->kernel);
	elm_label_label_set(win->info->kernel, tmp);
	sprintf(tmp, "Ramdisk: %s", vm->ramdisk);
	elm_label_label_set(win->info->ramdisk, tmp);
	sprintf(tmp, "Kernel args: %s", vm->cmdline);
	elm_label_label_set(win->info->cmdline, tmp);

	evas_object_key_ungrab(win->win, "Up", 0, 0);
	evas_object_key_ungrab(win->win, "Down", 0, 0);
	evas_object_key_ungrab(win->win, "Left", 0, 0);
	evas_object_key_ungrab(win->win, "Right", 0, 0);
	evas_object_key_ungrab(win->win, "Home", 0, 0);
	evas_object_key_ungrab(win->win, "End", 0, 0);
	
	elm_flip_content_back_set(win->main_vm->fl, win->info->frame);
	win->view = win->info->vmview;
	elm_flip_go(win->main_vm->fl, ELM_FLIP_ROTATE_X_CENTER_AXIS);

	EINA_LIST_FREE(win->elist, item)
		free_vmitem(item);
	win->elist = NULL;
	eina_list_free(win->list);
	win->list = NULL;
	evas_object_hide(win->main_vm->box2);
	evas_object_del(win->main_vm->box2);

	win->timerget = ecore_timer_add(5, zinfo_job_updatevm, NULL);
}
Exemplo n.º 17
0
static void
_dbus_cb_name_owner_changed(void *data, DBusMessage *msg)
{
   DBusError err;
   Eina_List *l;
   const char *tmp;
   const char *name, *from, *to;

   if (!conn) return;

   dbus_error_init(&err);
   if (!dbus_message_get_args(msg, &err,
			      DBUS_TYPE_STRING, &name,
			      DBUS_TYPE_STRING, &from,
			      DBUS_TYPE_STRING, &to,
			      DBUS_TYPE_INVALID))
     {
	printf("could not get NameOwnerChanged arguments: %s: %s\n",
	    err.name, err.message);
	dbus_error_free(&err);
	return;
     }

   if (strncmp(name, "org.mpris.", 10) != 0)
     return;

   printf("NameOwnerChanged from=[%s] to=[%s]\n", from, to);

   tmp = eina_stringshare_add(name);

   if (to[0] == '\0')
     {
	players = eina_list_remove(players, tmp);

	/* vanished player was current? */
	if (tmp == bus_name)
	  {
	     /* make another player current */
	     if (eina_list_count(players) > 0)
	       {
		  bus_name = players->data;
		  printf("use::%s", bus_name);
		  active = EINA_TRUE;
	       }
	     else
	       {
		  active = EINA_FALSE;
	       }
	  }

	eina_stringshare_del(tmp);
     }
   else
     {
	/* new player appeared? */
	if (!eina_list_data_find(players, tmp))
	  {
	     eina_stringshare_ref(tmp);
	     players = eina_list_append(players, tmp);
	  }

	/* no active player - make player current */
	if (!active)
	  {
	     bus_name = tmp;
	     active = EINA_TRUE;
	  }
     }

   eina_stringshare_del(tmp);
}