static void
setup_hash()
{

        int i;

        key1 = ecore_hash_new(ecore_str_hash, ecore_str_compare);
        key2 = ecore_hash_new(ecore_str_hash, ecore_str_compare);

        for (i = 0; keywords1[i] != NULL; i++)
                ecore_hash_set(key1, keywords1[i], keywords1[i]);

        for (i = 0; keywords2[i] != NULL; i++)
                ecore_hash_set(key2, keywords2[i], keywords2[i]);
}
Exemplo n.º 2
0
int egxp_opcode_add (Egxp_Opcode * op, const char * name) {
#ifdef EGXP_DEBUG
  printf("TRACE: egxp_opcode_add\n");
#endif
  
  assert (op && name);
  
  int * id = NULL;
  /* check if the name already exist */
  if ( (id = ecore_hash_get (op->string_id, (char*) name)) != NULL) {
#ifdef EGXP_DEBUG
    printf("TRACE: egxp_opcode_add -> %s already exists\n", name);
#endif 
    return *id;
  }

  /* allocate the memory for the id */
  id = (int*) malloc (sizeof (int));
  *id = op->id++;
  
#ifdef EGXP_DEBUG
  printf("TRACE: egxp_opcode_add -> %s %d\n", name, *id);
#endif 

  /* add the new element */
  ecore_hash_set (op->string_id, (char*)name, id);

  /* the id_string must be updated */
  op->need_update = 1;
  
  return *id;
}
Exemplo n.º 3
0
static const char *
ewl_icon_theme_icon_path_get_helper(const char *icon, unsigned int size,
                                        const char *theme, const char *key,
                                        Ecore_Hash *cache)
{
        char *ret;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(icon, EWL_THEME_KEY_NOMATCH);

#if BUILD_EFREET_SUPPORT
        ret = ecore_hash_get(cache, key);
        if (!ret)
        {
                /* XXX: How to store NOMATCH in the cache? The cache is strings which must be free'd */
                ret = efreet_icon_path_find(theme, icon, size);
                if (!ret) ret = EWL_THEME_KEY_NOMATCH;
                else ecore_hash_set(cache, strdup(key), (void *)ret);
        }
#else
        ret = EWL_THEME_KEY_NOMATCH;
#endif

        DRETURN_PTR(ret, DLEVEL_STABLE);
}
Exemplo n.º 4
0
void egxp_node_add_child (Egxp_Node * parent, Egxp_Node * child) {
#ifdef EGXP_DEBUG
  printf("TRACE: egxp_node_add_child\n");
#endif
  
  assert (parent && child);

  if (parent->childs == NULL) {
    /* create a hash */
    parent->childs = ecore_hash_new (ecore_direct_hash, ecore_direct_compare);
    /* destroy each element */
    ecore_hash_set_free_value (parent->childs, (Ecore_Free_Cb)ecore_dlist_destroy);
  }
  
  /* try to get the list for the special tag */
  Ecore_DList * ltmp = ECORE_DLIST (ecore_hash_get (parent->childs, (int*)child->tag));
  
  if (ltmp == NULL) {
    /* doesn't exist, so create it */
    ltmp = ecore_dlist_new ();
    ecore_dlist_set_free_cb (ltmp,(Ecore_Free_Cb)egxp_node_free);
    
    /* append the list to the hash, hash is indexed by the tag id */
    ecore_hash_set (parent->childs, (int*)child->tag, ltmp);
  }
  
  /* now append the child to the list */
  egxp_node_add_in_order (ltmp, child);

  /* set the parent for the child */
  child->parent = parent;
}
Exemplo n.º 5
0
void
eke_gui_ewl_feed_register(Eke *eke, Eke_Feed *feed)
{
    Eke_Gui_Ewl_Feed *disp;

    disp = NEW(Eke_Gui_Ewl_Feed, 1);
    ecore_hash_set(eke->feeds, feed, disp);
}
Exemplo n.º 6
0
int
posix_monitor_add(evfs_client * client, evfs_command * command)
{
   Ecore_List *mon_list =
      ecore_hash_get(posix_monitor_hash, evfs_command_first_file_get(command)->path);
   evfs_file_monitor *mon;
   evfs_file_monitor *old;

   mon = calloc(1, sizeof(evfs_file_monitor));
   mon->client = client;
   mon->monitor_path = strdup(evfs_command_first_file_get(command)->path);

   /*Check if we are already monitoring, if not, make a new list of monitors.. */
   if (!mon_list)
     {
        /*printf("No previous instance, making a new list, monitoring..\n"); */

        mon_list = ecore_list_new();
        ecore_hash_set(posix_monitor_hash, mon->monitor_path, mon_list);

        printf("Adding monitor on path '%s'\n", mon->monitor_path);
        if (!
            (mon->em =
             ecore_file_monitor_add(mon->monitor_path,
                                    &evfs_file_monitor_fam_handler,
                                    mon->monitor_path)))
          {
             fprintf(stderr, "EVFS: Error monitoring '%s'\n",
                     mon->monitor_path);
          }

        ecore_list_append(mon_list, mon);
     }
   else
     {
        if (!client_already_monitoring(client, mon_list))
          {
             /*We assume there is something already in the list.  This is probably bad a bad assumption */
             ecore_list_first_goto(mon_list);
             old = ecore_list_current(mon_list);

             /*Make sure we have the ecore ref, so the last monitor can nuke it */
             mon->em = old->em;
             ecore_list_append(mon_list, mon);
          }
        else
          {
             printf("Oi, dufus, you're already monitoring this object\n");
          }

     }

   return 0;

}
Exemplo n.º 7
0
Eina_Bool eli_highscore_entry_add(const char * game, const char * username,
                                  float points, pointsType type)
{
    Eina_List * l = NULL;
    Eli_Highscore_Entry * entry;
    
    int (*list_sort) (const void *, const void *);
    int count = 0;

    if (!game || !username || !eet_file_name) return 0;

    entry = _eli_entry_new(username, points, type);

    l = eli_highscore_get(game);
    if (l) count = eina_list_count(l);
    else count = 0;

    /* select the right sorting function */
    switch (type) {
    case POINTS_TYPE_INTEGER_BAD:
    case POINTS_TYPE_FLOAT_BAD:
        list_sort = _eli_highscore_list_sort_bad;
        break;
    default:
        list_sort = _eli_highscore_list_sort_good;
        break;
    }

    /* 10 entries should be enough */
    if (count >= 10) {
        Eina_List * last_l;
        Eli_Highscore_Entry * last_e;

        last_l = eina_list_last(l);
        last_e = eina_list_data_get(last_l);

        if ( list_sort(last_e, entry) < 0) {
            free(entry->username);
            free(entry);
            return 0;
        }
    }

    l = eina_list_append(l, entry);
    if (count) l = eina_list_sort(l, (count + 1), list_sort);
    if (count >= 10) l = eina_list_remove_list(l, eina_list_last(l));

    ecore_hash_set(hiscore_hash, strdup(game), l);
  
    _eli_highscore_write(game);
    
    return 1;
}
Exemplo n.º 8
0
/**
 * Set an attribute for this tag
 * @param   xml The xml document to modify
 * @param   attr The attribute to set
 * @param   value The value to set this attribute to
 * @return  @c TRUE if successful, @c FALSE if an error occurs.
 * @ingroup EXML_Modfiy_Element_Group
 */
int exml_attribute_set(EXML *xml, char *attr, char *value)
{
	char *oldvalue;

	CHECK_PARAM_POINTER_RETURN("xml", xml, FALSE);
	CHECK_PARAM_POINTER_RETURN("attr", attr, FALSE);

	oldvalue = ecore_hash_get( xml->current->attributes, attr );
	IF_FREE(oldvalue);

	if (value)
		value = strdup(value);

	ecore_hash_set( xml->current->attributes, strdup( attr ), value );

	return TRUE;
}
Exemplo n.º 9
0
/**
 * add a file to the project listing
 */
void
project_file_add( char *name, char *filename )
{
	/* TODO check for dups */
	name = strdup(name);
	filename = strdup(filename);

	if( !name || !filename ) {
		ewler_error("project_file_add: out of memory!");
		IF_FREE(name);
		return;
	}

	ecore_hash_set(active_project->files, name, filename);
	active_project->dirty = true;
	project_update();
}
Exemplo n.º 10
0
/**
 * Write the xml document out to a memory location.
 * @param   xml The xml document
 * @param   len The size of the memory buffer
 * @return  a pointer to the memory location, or @c NULL if an error occurs.
 * @ingroup EXML_Write_Group
 */
void *exml_mem_write(EXML *xml, size_t *len)
{
	xmlTextWriterPtr writer;
	xmlBufferPtr buf;

	CHECK_PARAM_POINTER_RETURN("xml", xml, FALSE);

	buf = xmlBufferCreate();
	writer = xmlNewTextWriterMemory( buf, 0 );

	if (_exml_write(xml, writer)) {
		ecore_hash_set( xml->buffers, (void *) xmlBufferContent( buf ), buf );

		*len = xmlBufferLength( buf );
		return (void *) xmlBufferContent( buf );
	} else {
		*len = 0;
		xmlBufferFree( buf );
		return NULL;
	}
}
Exemplo n.º 11
0
static void
eina_bench_lookup_ecore(int request)
{
   Ecore_Hash *hash = NULL;
   Eina_Bench_Ecore *elm;
   unsigned int i;
   unsigned int j;

   hash = ecore_hash_new(ecore_str_hash, ecore_str_compare);

   ecore_hash_free_key_cb_set(hash, NULL);
   ecore_hash_free_value_cb_set(hash, free);

   for (i = 0; i < (unsigned int)request; ++i)
     {
        elm = malloc(sizeof (Eina_Bench_Ecore) + 10);
        if (!elm)
           continue;

        elm->key = (char *)(elm + 1);
        eina_convert_itoa(i, elm->key);
        elm->value = i;

        ecore_hash_set(hash, elm->key, elm);
     }

   srand(time(NULL));

   for (j = 0; j < 200; ++j)
      for (i = 0; i < (unsigned int)request; ++i)
        {
           char tmp_key[10];

           eina_convert_itoa(rand() % request, tmp_key);

           elm = ecore_hash_get(hash, tmp_key);
        }

   ecore_hash_destroy(hash);
}
Exemplo n.º 12
0
static EWL_CALLBACK_DEFN(project_file_settings_cb)
{
	int *response = ev_data;
	char *name = user_data;
	char *new_name, *new_path;

	if( *response == EWL_RESPONSE_SAVE ) {
		Ewler_Form *form;

		new_name = ewl_text_text_get(EWL_TEXT(file_settings.name_entry));
		new_path = ewl_text_text_get(EWL_TEXT(file_settings.path_entry));

		if( (form = form_get(name)) )
			form_name_set(form, new_name);

		ecore_hash_remove(active_project->files, name);
		ecore_hash_set(active_project->files, new_name, new_path);

		project_update();
	}

	ewl_widget_destroy(settings_win);
	settings_win = NULL;
}
Exemplo n.º 13
0
/**
 * Retrieves an instance of a string for use in an ecore program.
 * @param   string The string to retrieve an instance of.
 * @return  A pointer to an instance of the string on success.
 *          @c NULL on failure.
 * @ingroup Ecore_String_Group
 */
EAPI const char *
ecore_string_instance(const char *string)
{
   Ecore_String *str;

   CHECK_PARAM_POINTER_RETURN("string", string, NULL);

   /*
    * Check for a previous instance of the string, if not found, create
    * it.
    */
   str = ecore_hash_get(ecore_strings, string);
   if (!str)
     {
        int length;

        /*
         * Allocate and initialize a new string reference.
         */
        length = strlen(string) + 1;

        str =
           (Ecore_String *)malloc(sizeof(Ecore_String) + length * sizeof(char));

        str->string = (char *)(str + 1);
        str->references = 0;

        memcpy(str->string, string, length);

        ecore_hash_set(ecore_strings, str->string, str);
     }

   str->references++;

   return str->string;
}
Exemplo n.º 14
0
/**
 * @internal
 * @param tx: The context to search for
 * @param context_mask the mask of differences
 * @param tx_changes: the set of differences to the given context to use
 * @return Returns the desired context
 * @brief Retrieves, or creates, the needed context
 */
Ewl_Text_Context *
ewl_text_context_find(Ewl_Text_Context *tx, unsigned int context_mask,
                                        Ewl_Text_Context *tx_change)
{
        Ewl_Text_Context tmp_tx;
        Ewl_Text_Context *new_tx;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(tx, NULL);

        /* only need the tx_change if we have a context mask */
        if (context_mask > 0)
                DCHECK_PARAM_PTR_RET(tx_change, NULL);

        memcpy(&tmp_tx, tx, sizeof(Ewl_Text_Context));
        ewl_text_context_merge(&tmp_tx, context_mask, tx_change);
        new_tx = ecore_hash_get(context_hash, &tmp_tx);
        if (!new_tx)
        {
                if ((new_tx = ewl_text_context_dup(tx)))
                {
                        if (context_mask & EWL_TEXT_CONTEXT_MASK_FONT)
                        {
                                IF_RELEASE(new_tx->font);
                                new_tx->font = ecore_string_instance(
                                                        tx_change->font);

                                IF_RELEASE(new_tx->font_source);
                                if (tx_change->font_source)
                                        new_tx->font_source = ecore_string_instance(tx_change->font_source);
                        }

                        if (context_mask & EWL_TEXT_CONTEXT_MASK_SIZE)
                                new_tx->size = tx_change->size;

                        if (context_mask & EWL_TEXT_CONTEXT_MASK_STYLES)
                                new_tx->styles = tx_change->styles;

                        if (context_mask & EWL_TEXT_CONTEXT_MASK_ALIGN)
                                new_tx->align = tx_change->align;

                        if (context_mask & EWL_TEXT_CONTEXT_MASK_WRAP)
                                new_tx->wrap = tx_change->wrap;

                        if (context_mask & EWL_TEXT_CONTEXT_MASK_COLOR)
                                memcpy(&(new_tx->color), &(tx_change->color),
                                                        sizeof(Ewl_Color_Set));

                        if (context_mask & EWL_TEXT_CONTEXT_MASK_BG_COLOR)
                                memcpy(&(new_tx->style_colors.bg),
                                                &(tx_change->style_colors.bg),
                                                sizeof(Ewl_Color_Set));

                        if (context_mask & EWL_TEXT_CONTEXT_MASK_GLOW_COLOR)
                                memcpy(&(new_tx->style_colors.glow),
                                                &(tx_change->style_colors.glow),
                                                sizeof(Ewl_Color_Set));

                        if (context_mask & EWL_TEXT_CONTEXT_MASK_OUTLINE_COLOR)
                                memcpy(&(new_tx->style_colors.outline),
                                                &(tx_change->style_colors.outline),
                                                sizeof(Ewl_Color_Set));

                        if (context_mask & EWL_TEXT_CONTEXT_MASK_SHADOW_COLOR)
                                memcpy(&(new_tx->style_colors.shadow),
                                                &(tx_change->style_colors.shadow),
                                                sizeof(Ewl_Color_Set));

                        if (context_mask & EWL_TEXT_CONTEXT_MASK_STRIKETHROUGH_COLOR)
                                memcpy(&(new_tx->style_colors.strikethrough),
                                                &(tx_change->style_colors.strikethrough),
                                                sizeof(Ewl_Color_Set));

                        if (context_mask & EWL_TEXT_CONTEXT_MASK_UNDERLINE_COLOR)
                                memcpy(&(new_tx->style_colors.underline),
                                                &(tx_change->style_colors.underline),
                                                sizeof(Ewl_Color_Set));

                        if (context_mask & EWL_TEXT_CONTEXT_MASK_DOUBLE_UNDERLINE_COLOR)
                                memcpy(&(new_tx->style_colors.double_underline),
                                                &(tx_change->style_colors.double_underline),
                                                sizeof(Ewl_Color_Set));

                        IF_RELEASE(new_tx->format);
                        ecore_hash_set(context_hash, new_tx, new_tx);
                }
        }
        if (new_tx) ewl_text_context_acquire(new_tx);

        DRETURN_PTR(new_tx, DLEVEL_STABLE);
}
Exemplo n.º 15
0
/**
 * @return Returns TRUE on successful initialization, FALSE otherwise
 * @brief Initializes the IO manager system.
 */
int
ewl_io_manager_init(void)
{
        DENTER_FUNCTION(DLEVEL_STABLE);

        if (!ewl_io_manager_ext_icon_map)
        {
                /* XXX this is a dumb way to do this.... */
                ewl_io_manager_ext_icon_map = ecore_hash_new(ecore_str_hash,
                                                ewl_io_manager_strcasecompare);
                /* Images */
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".png",
                                                EWL_ICON_IMAGE_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".jpg",
                                                EWL_ICON_IMAGE_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".gif",
                                                EWL_ICON_IMAGE_X_GENERIC);

                /* Videos */
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".wmv",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mpg",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mpeg",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".avi",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mov",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".asf",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mp4",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mkv",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".ogm",
                                                EWL_ICON_VIDEO_X_GENERIC);

                /* Audio */
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mp3",
                                                EWL_ICON_AUDIO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mka",
                                                EWL_ICON_AUDIO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".ogg",
                                                EWL_ICON_AUDIO_X_GENERIC);

                /* HTML */
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".html",
                                                EWL_ICON_TEXT_HTML);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".htm",
                                                EWL_ICON_TEXT_HTML);

                /* Scirpts */
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".pl",
                                                EWL_ICON_TEXT_X_SCRIPT);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".sh",
                                                EWL_ICON_TEXT_X_SCRIPT);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".ksh",
                                                EWL_ICON_TEXT_X_SCRIPT);

                ewl_io_manager_plugins = ecore_hash_new(ecore_str_hash,
                                                        ecore_str_compare);
                ecore_hash_free_key_cb_set(ewl_io_manager_plugins, free);
                ecore_hash_free_value_cb_set(ewl_io_manager_plugins,
                                                ewl_io_manager_cb_free_plugin);
        }

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 16
0
static Ewl_IO_Manager_Plugin *
ewl_io_manager_plugin_get(const char *mime)
{
        Ewl_IO_Manager_Plugin *plugin = NULL;
        char name[PATH_MAX];
        char *m = NULL, *ptr;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(mime, NULL);

        /* see if this was already cached */
        plugin = ecore_hash_get(ewl_io_manager_plugins, mime);
        if (plugin)
                DRETURN_PTR(plugin, DLEVEL_STABLE);

        if (!ewl_io_manager_path)
        {
                ewl_io_manager_path = ecore_path_group_new();
                snprintf(name, sizeof(name), "%s/%s",
                                ewl_system_directory_get(EWL_DIRECTORY_LIB),
                                EWL_PLUGIN_DIR);
                ecore_path_group_add(ewl_io_manager_path, name);
        }

        m = strdup(mime);
        while ((ptr = strchr(m, '/')))
                *ptr = '_';

        snprintf(name, sizeof(name), "ewl_io_manager_%s_plugin", m);
        FREE(m);

        plugin = NEW(Ewl_IO_Manager_Plugin, 1);
        plugin->plugin = ecore_plugin_load(ewl_io_manager_path, name, NULL);
        if (!plugin->plugin)
        {
                FREE(plugin);
                m = strdup(mime);
                plugin = NULL;

                /* check for fallback plugins */
                ptr = strrchr(m, '/');
                if (ptr)
                {
                        *ptr = '\0';
                        plugin = ewl_io_manager_plugin_get(m);
                }

                FREE(m);
                DRETURN_PTR(plugin, DLEVEL_STABLE);
        }

        plugin->uri_read =
                ecore_plugin_symbol_get(plugin->plugin,
                                        "ewl_io_manager_plugin_uri_read");
        plugin->string_read =
                ecore_plugin_symbol_get(plugin->plugin,
                                        "ewl_io_manager_plugin_string_read");

        plugin->uri_write =
                ecore_plugin_symbol_get(plugin->plugin,
                                        "ewl_io_manager_plugin_uri_write");
        plugin->string_write =
                ecore_plugin_symbol_get(plugin->plugin,
                                        "ewl_io_manager_plugin_string_write");

        if (!plugin->uri_read || !plugin->uri_write
                        || !plugin->uri_write || !plugin->string_write)
        {
                if (plugin->plugin)
                        ecore_plugin_unload(plugin->plugin);

                FREE(plugin);
                DRETURN_PTR(NULL, DLEVEL_STABLE);
        }

        ecore_hash_set(ewl_io_manager_plugins, strdup(mime), plugin);

        DRETURN_PTR(plugin, DLEVEL_STABLE);
}
Exemplo n.º 17
0
evfs_connection *
evfs_connect(void (*callback_func) (EvfsEvent *, void *), void *obj)
{
   ecore_init();
   ecore_ipc_init();
   int connect_attempts = 0;

   evfs_connection *connection = NEW(evfs_connection);

   connection->id = MAX_CLIENT;
   connection->prog_event = NULL;
   connection->callback_func = callback_func;
   connection->obj = obj;

   evfs_io_initialise();
   evfs_vfolder_initialise();

   if (!_libevfs_init)
     {
        _libevfs_init = 1;
	_libevfs_next_command_id = 1;
	evfs_session_servers = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);

	/*Register the callback*/
        ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, evfs_server_data,
                                NULL);
        client_list = ecore_list_new();

        ecore_list_append(client_list, connection);
     }
   else
     {
        ecore_list_prepend(client_list, connection);
     }

 retry:

   if (connect_attempts > MAX_ATTEMPTS)
     {
        fprintf(stderr, "Could not start server after max attempts\n");
        exit(1);                /*We shouldn't really kill the libraries parent! */
        return NULL;
     }

   if (!
       (connection->server =
        ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, EVFS_IPC_TITLE,0,
                                 connection)))	   
     {	     
        fprintf(stderr,
                "Cannot connect to evfs server with '%s', making new server and trying again..\n",
                EVFS_IPC_TITLE);

        if (!connect_attempts)
          {
             if (evfs_server_spawn())
               {
                  printf("Failure to start evfs server!\n");
               }
          }

        connect_attempts++;
        usleep(100000 * connect_attempts);
        goto retry;

     } else {
	     ecore_hash_set(evfs_session_servers, connection->server, (int*)1);

	     while (connection->id == MAX_CLIENT) {
		        /*printf("Waiting for connection id..\n");*/
			ecore_main_loop_iterate();
	     }
	     /*printf("Got connection ID: %d\n", connection->id);*/
	     
     }

   return connection;
}
Exemplo n.º 18
0
void eli_highscore_init(const char * app)
{
    char buffer[1024];
    char * home;
    Eet_File * ef;
    eet_init();

    edd_entry = eet_data_descriptor_new("Eli_Highscore_Entry",
                                        sizeof(Eli_Highscore_Entry),
                                        (list_next) eina_list_next,
                                        (list_append) eina_list_append,
                                        (list_data) eina_list_data_get,
                                        (list_free) eina_list_free,
                                        (hash_foreach) eina_hash_foreach,
                                        (hash_add) eina_hash_add /* FIXME: YOU SHOULD NOT USE EINA_HASH_ADD DIRECTLY */,
                                        (hash_free) eina_hash_free);

    EET_DATA_DESCRIPTOR_ADD_BASIC(edd_entry, Eli_Highscore_Entry,
                                  "username", username, EET_T_STRING);
    EET_DATA_DESCRIPTOR_ADD_BASIC(edd_entry, Eli_Highscore_Entry,
                                  "points", points, EET_T_FLOAT);
    EET_DATA_DESCRIPTOR_ADD_BASIC(edd_entry, Eli_Highscore_Entry,
                                  "type", type, EET_T_INT);

    edd_hiscore = eet_data_descriptor_new("Eli_Highscore",
                                          sizeof(Eli_Highscore),
                                          (list_next) eina_list_next,
                                          (list_append) eina_list_append,
                                          (list_data) eina_list_data_get,
                                          (list_free) eina_list_free,
                                          (hash_foreach) eina_hash_foreach,
                                          (hash_add) eina_hash_add /* FIXME: YOU SHOULD NOT USE EINA_HASH_ADD DIRECTLY */,
                                          (hash_free) eina_hash_free);

    EET_DATA_DESCRIPTOR_ADD_LIST(edd_hiscore, Eli_Highscore,
                                 "entries", entries, edd_entry);

    /* this is just a temporally hack, the right path should be
     * some thing like /var/games/elitaire.score, but
     * for some reasons eet segv when the directory is not
     * writable, although the file is */
    home = getenv("HOME");
    if (!home)
	    home = "/tmp";

    snprintf(buffer, sizeof(buffer), 
		    "%s/.e/apps/%s/score.eet", home, app);
    eet_file_name = strdup(buffer);

    /*
     * setup the hiscore hash
     */
    hiscore_hash = ecore_hash_new(ecore_str_hash, ecore_str_compare);
    ecore_hash_free_key_cb_set(hiscore_hash, free);

    /*
     * fill the hash
     */
    ef = eet_open(eet_file_name, EET_FILE_MODE_READ);

    if (ef) {
        char **list;
	int num, i;

	list = eet_list(ef, "*", &num);
	
	for(i = 0; i < num; i++) {
	    Eli_Highscore * hiscore;

	    hiscore = eet_data_read(ef, edd_hiscore, list[i]);
	    ecore_hash_set(hiscore_hash, strdup(list[i]), hiscore->entries);
	}
	free(list);
	eet_close(ef);
    }
}
Exemplo n.º 19
0
void layout_etk_simple_add_header(entropy_gui_component_instance* instance, Entropy_Config_Structure* structure_obj)
{
  void *(*structure_plugin_init) (entropy_core * core,
				  entropy_gui_component_instance *,
				  void* parent_visual,
				  void *data);

  entropy_plugin *structure;
  entropy_generic_file* file;
  Etk_Tree_Row* row;
  Etk_Tree_Col* col;
  entropy_layout_gui* gui = instance->data;
  char* icon_string = NULL;
  Ecore_List* layouts;
  _layout_etk_row_structure_plugin* struct_ref = NULL;

  col = etk_tree_nth_col_get(ETK_TREE(gui->tree), 0);

  /*Parse the file from the URI*/
   file = entropy_core_parse_uri (structure_obj->uri);

   printf("Object for %s/%s is %p....\n", file->path, file->filename, file);
   

   /*This will be moved to a central function. TODO*/
   if (!strcmp(file->uri_base, "file"))
	   icon_string = PACKAGE_DATA_DIR "/icons/local-system.png";
  else if (!strcmp(file->uri_base, "smb"))
	  icon_string = PACKAGE_DATA_DIR "/icons/samba-system.png";
   else if (!strcmp(file->uri_base,"sftp"))
	  icon_string = PACKAGE_DATA_DIR "/icons/sftp-system.png"; 
   else if (!strcmp(file->uri_base,"vfolder"))
	  icon_string = PACKAGE_DATA_DIR "/icons/vfolder-system.png"; 
			   
	
  etk_tree_freeze(ETK_TREE(gui->tree));
  row = etk_tree_row_append(ETK_TREE(gui->tree), NULL, col,
			  icon_string, NULL, structure_obj->name, NULL);
  etk_tree_thaw(ETK_TREE(gui->tree));
  
  
  structure = entropy_plugins_type_get_first(ENTROPY_PLUGIN_GUI_COMPONENT,ENTROPY_PLUGIN_GUI_COMPONENT_STRUCTURE_VIEW);
   structure_plugin_init =
      dlsym (structure->dl_ref, "entropy_plugin_gui_instance_new");

   /*We shouldn't really assume it's a folder - but it bootstraps us for
    * now- FIXME*/
   strcpy(file->mime_type, "file/folder");
   file->filetype = FILE_FOLDER;

  if (!strlen (file->mime_type)) {
	    entropy_mime_file_identify (file);
  }
   
   instance = (*structure_plugin_init)(instance->core, instance, row,file);
   instance->plugin = structure;

   /*Add to tracker*/
  ecore_hash_set(_etk_layout_row_reference, row, structure_obj);

  printf ("LOADED: %s/%s\n", file->path, file->filename);
  
  /*Add to layout/plugin tracker - this is to destroy if the user removes a location*/
  if (! (layouts = ecore_hash_get(_etk_layout_structure_plugin_reference, structure_obj))) {
	  layouts = ecore_list_new();
	  ecore_hash_set(_etk_layout_structure_plugin_reference, structure_obj, layouts);
  }

  struct_ref = entropy_malloc(sizeof(_layout_etk_row_structure_plugin));
  struct_ref->row = row;
  struct_ref->structure_plugin = structure;

  ecore_list_append(layouts, struct_ref);

}
Exemplo n.º 20
0
void
gui_event_callback (entropy_notify_event * eevent, void *requestor,
		    void *el, entropy_gui_component_instance * comp)
{
    entropy_layout_gui* view = (entropy_layout_gui*)comp->data;

    switch (eevent->event_type) {
	    case ENTROPY_NOTIFY_FILE_PROGRESS:{
		entropy_file_progress_window* window;
		entropy_file_progress *progress = el;
		

		if (! (window = ecore_hash_get(view->progress_hash, (long*)progress->identifier))) {
			window = entropy_etk_progress_window_create();
			entropy_etk_progress_dialog_show(window);
			entropy_etk_progress_dialog_set_file_from_to(window, progress->file_from, progress->file_to);
			entropy_etk_progress_dialog_set_progress_pct(window, &progress->progress);

			ecore_hash_set(view->progress_hash, (long*)progress->identifier, window);
		} else {
			entropy_etk_progress_dialog_set_file_from_to(window, progress->file_from, progress->file_to);
			entropy_etk_progress_dialog_set_progress_pct(window, &progress->progress);
		}

		if (progress->type == TYPE_END) {
			window = ecore_hash_get(view->progress_hash, (long*)progress->identifier);
			if (window) {
				ecore_hash_remove(view->progress_hash, (long*)progress->identifier);
				entropy_etk_progress_dialog_destroy(window);
			}
		}

	     }
	     break;

	     case ENTROPY_NOTIFY_USER_INTERACTION_YES_NO_ABORT: {
		/*FIXME: We need to handle different types here*/
		entropy_etk_user_interaction_dialog_new((entropy_file_operation*)el);
	     }
	     break;

	     case ENTROPY_NOTIFY_EXTENDED_STAT: {
		 printf("**** Extended stat at layout\n");
		 ecore_hash_set(view->properties_request_hash, (entropy_generic_file*)el, (int*)1);
	     };
	     break;

	     case ENTROPY_NOTIFY_FILE_STAT_AVAILABLE:{
		entropy_file_stat *file_stat = (entropy_file_stat *) eevent->return_struct;							     
		
		if (ecore_hash_get(view->properties_request_hash, file_stat->file)) {
			ecore_hash_remove(view->properties_request_hash, file_stat->file);	
			
			/*Lauch a properties window*/
			etk_properties_dialog_new(file_stat->file);
		}
	     }
	     break;

	     case ENTROPY_NOTIFY_PASTE_REQUEST: {
		printf("Paste request..\n");
							
		Entropy_Selection_Type stype = entropy_core_selection_type_get();
		entropy_generic_file* cfolder = 
			((entropy_gui_component_instance_layout*)comp)->current_folder; 
		Ecore_List* files = entropy_core_selected_files_get();
		
		if (cfolder) {
			char* f_uri = 	cfolder->uri;
			if (f_uri) {
				if (stype == ENTROPY_SELECTION_COPY) {
					printf("Copy type..: %d:%s\n", ecore_list_count(files), f_uri);
					entropy_plugin_filesystem_file_copy_multi(files, f_uri, 
						comp);
				} else if (stype == ENTROPY_SELECTION_CUT) {
					printf("Cut type..:%d:%s\n", ecore_list_count(files), f_uri);
					entropy_plugin_filesystem_file_move_multi(files, f_uri, 
						comp);					
				} else {
					printf("Unsupported copy type at context menu paste\n");
				}
			}
		} else {
			printf("Current folder is NULL at layout paste\n");
		}
	     }
	     break;

	     case ENTROPY_NOTIFY_AUTH_REQUEST: {
		  printf("Requested auth for: %s\n",(char*)el); 
		  etk_auth_request_dialog_create(strdup((char*)el));
	     }
	     break;

	     case ENTROPY_NOTIFY_METADATA_ALL: {
			entropy_etk_efolder_dialog_show((Eina_List*)el);
	     }
	     break;

     }
}
Exemplo n.º 21
0
void
entropy_file_wait_list_add (entropy_icon_viewer * viewer, Ecore_List * list)
{
  ecore_hash_set (viewer->file_wait_list, list, list);
}
Exemplo n.º 22
0
gui_file *
ewl_icon_local_viewer_add_icon (entropy_gui_component_instance * comp,
				entropy_generic_file * list_item, int do_mime)
{
  entropy_icon_viewer *view = comp->data;


  Ewl_Iconbox_Icon *icon;
  gui_file *gui_object;

  if (!ecore_hash_get (view->gui_hash, list_item)) {
    entropy_core_file_cache_add_reference (list_item->md5);

    icon =
      ewl_iconbox_icon_add (EWL_ICONBOX (view->iconbox), list_item->filename,
			    PACKAGE_DATA_DIR "/icons/default.png");

    ewl_callback_append (EWL_WIDGET (icon), EWL_CALLBACK_MOUSE_DOWN,
			 icon_click_cb, view);
    ewl_callback_append (EWL_WIDGET (icon), EWL_CALLBACK_MOUSE_MOVE,
			 hover_icon_mouse_move_cb, comp);


    gui_object = gui_file_new ();
    gui_object->file = list_item;
    gui_object->thumbnail = NULL;
    gui_object->instance = comp;
    gui_object->icon = EWL_WIDGET (icon);


    ewl_attach_tooltip_widget_set (EWL_WIDGET (icon), view->hover_properties);

    ecore_hash_set (view->gui_hash, list_item, gui_object);
    ecore_hash_set (view->icon_hash, icon, gui_object);

    /*Associate this icon with this file in the core, so DND works */
    entropy_core_object_file_associate (icon, list_item);

    if (do_mime == DO_MIME) {
      char *mime;
      entropy_plugin *thumb;

      mime = entropy_mime_file_identify (list_item);


      if (mime && strcmp (mime, ENTROPY_NULL_MIME)) {
	entropy_plugin_thumbnail_request(comp,list_item,(void*)gui_event_callback);
      }
      else {
	thumb = NULL;
      }

    }

    return gui_object;

  }

  return NULL;

}
Exemplo n.º 23
0
int
file_project_open( Ewler_Project *p )
{
	EXML *xml;
	char *tag;

	xml = exml_new();

	exml_file_read(xml, p->filename);

	if( !(tag = exml_tag_get(xml)) || strcmp(tag, "project") ) {
		EWLER_ERROR("not a ewler project file\n");
		return -1;
	}

	/* check version and source */

	if( !exml_down(xml) ) {
		EWLER_ERROR("no project information\n");
		return -1;
	}

	do {
		tag = exml_tag_get(xml);

		if( !strcmp(tag, "path") ) {
			p->path = exml_value_get(xml);
			if( p->path )
				p->path = strdup(p->path);
			else
				p->path = strdup("");
		} else if( !strcmp(tag, "name") ) {
			p->name = exml_value_get(xml);
			if( p->name )
				p->name = strdup(p->name);
			else
				p->name = strdup("");
		} else if( !strcmp(tag, "files") ) {
			exml_down(xml);

			do {
				char *name, *file;

				tag = exml_tag_get(xml);

				if( strcmp( tag, "file" ) )
					continue;

				name = exml_attribute_get(xml, "name");
				name = strdup(name);
				file = exml_value_get(xml);
				file = strdup(file);
				ecore_hash_set(p->files, name, file);
			} while(exml_next_nomove(xml));
		}
	} while(exml_next_nomove(xml));

	exml_destroy(xml);

	return 0;
}
Exemplo n.º 24
0
void 
evfs_io_event_edd_set(int type, Eet_Data_Descriptor* desc)
{
	ecore_hash_set(evfs_io_edd_hash, (int*)type,desc);
}
Exemplo n.º 25
0
void
inspector_update( Ecore_List *selected )
{
	Ewl_Widget *prow;
	Ecore_Sheap *slist, *sheap;
	Ecore_Hash *elems;
	Ecore_List *keys;
	Ecore_List *prow_stack, *sheap_stack, *elems_stack;
	Ewler_Widget *w;
	char *key;

	ewl_container_reset(EWL_CONTAINER(tree));

	if( !selected )
		return;
	/* add support for multiple selections later */
	w = ecore_list_first_goto(selected);

	if( !w )
		return;
	
	keys = ecore_hash_keys(w->elems);
	slist = ecore_sheap_new(ecore_str_compare, ecore_list_count(keys));

	while( (key = ecore_list_next(keys)) )
		ecore_sheap_insert(slist, key);

	ecore_list_destroy(keys);
	ecore_sheap_sort(slist);

	sheap = slist;
	elems = w->elems;

	sheap_stack = ecore_list_new();
	elems_stack = ecore_list_new();
	prow_stack = ecore_list_new();
	prow = NULL;

	while( (key = ecore_sheap_extract(sheap)) ) {
		Ewler_Widget_Elem *elem;
		Ewl_Widget *row_items[2], *row;
		Ewl_Widget *text, *entry;
		int len;

		elem = ecore_hash_get(elems, key);
		text = ewl_text_new(key);
		len = ewl_text_length_get(EWL_TEXT(text));
		ewl_text_cursor_position_set(EWL_TEXT(text), 0);
		if( elem->changed )
			ewl_text_color_apply(EWL_TEXT(text), 255, 0, 0, 255, len);

		switch( elem->spec->type ) {
			case EWLER_SPEC_ELEM_STRUCT: entry = NULL; break;
			case EWLER_SPEC_ELEM_ENUM:
				entry = ewl_combo_new(elem_to_s(elem));

				if( elem->items )
					ecore_hash_destroy(elem->items);

				elem->items = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);
				
				keys = ecore_hash_keys(elem->spec->info.edata.map_rev);
				while( (key = ecore_list_next(keys)) ) {
					Ewl_Widget *combo_item;
					int value;

					value = (int) ecore_hash_get(elem->spec->info.edata.map_rev, key);

					combo_item = ewl_menu_item_new(NULL, key);
					ecore_hash_set(elem->items, (void *) value, combo_item);
					ewl_container_child_append(EWL_CONTAINER(entry), combo_item);
					ewl_widget_show(combo_item);
				}

				ecore_list_destroy(keys);

				ewl_callback_append(entry, EWL_CALLBACK_VALUE_CHANGED,
														combo_value_changed, elem);
				break;
			default:
				entry = ewl_entry_new(elem_to_s(elem));
				if( !elem->spec->modifiable )
					ewl_entry_editable_set(EWL_ENTRY(entry), false);

				ewl_callback_append(entry, EWL_CALLBACK_VALUE_CHANGED,
														entry_value_changed, elem);
				ewl_callback_append(entry, EWL_CALLBACK_DESELECT,
														entry_value_changed, elem);
				ewl_callback_append(entry, EWL_CALLBACK_FOCUS_OUT,
														entry_focus_out, elem);
				break;
		}

		elem->text = text;
		elem->entry = entry;

		row_items[0] = text;
		row_items[1] = entry;

		row = ewl_tree_row_add(EWL_TREE(tree), EWL_ROW(prow), row_items);
		ewl_widget_show(text);
		if( entry )
			ewl_widget_show(entry);

		if( elem->spec->type == EWLER_SPEC_ELEM_STRUCT ) {
			ecore_list_prepend(prow_stack, prow);
			ecore_list_prepend(sheap_stack, sheap);
			ecore_list_prepend(elems_stack, elems);

			prow = row;
			elems = elem->info.children;

			/* TODO: check for indexed struct */
			keys = ecore_hash_keys(elems);
			sheap = ecore_sheap_new(ecore_str_compare, ecore_list_count(keys));

			while( (key = ecore_list_next(keys)) )
				ecore_sheap_insert(sheap, key);

			ecore_list_destroy(keys);
			ecore_sheap_sort(sheap);
		}

		if( sheap->size == 0 && ecore_list_count(sheap_stack) ) {
			ecore_sheap_destroy(sheap);

			prow = ecore_list_first_remove(prow_stack);
			sheap = ecore_list_first_remove(sheap_stack);
			elems = ecore_list_first_remove(elems_stack);
		}
	}

	ecore_list_destroy(sheap_stack);
	ecore_list_destroy(elems_stack);
	ecore_sheap_destroy(slist);
}