[Evolution-hackers] libebook and E-D-S questions / help



Hey there Evolution folks!

Before asking some questions, let me briefly introduce my self. I am Sven Pfaller, a student from Erlangen, Germany, participating in this years GSoC. More precisely I am working on libsoylent [1], a people-management-library. It is a subproject of Soylent [2], perhaps you've heard of it. If you want to know more about libsoylent see [1].

libsoylent uses libebook extensively, so I am working longer than a month with libebook and libebook-data now. Some questions queued up, and I would also be thankful for some help as I am stuck with some bugs (?) at the moment.

Okay, here are my points:

 * attribute-value-lists:

When I call e_vcard_attribute_get_values, I get a list of values. For example if I call it on the ADDR attribute, I get a list like:

"foo-street", "foo-city", "foo-region" ...

If two addresses exist, the list looks like this:

"foo-street", "foo-city", "foo-region", "bar-street", "bar-city", "bar-region" ...

Is there a way to retrieve the raw vCard strings as a list?

e.g.: "foo-street;foo-city;foo-region", "bar-street;bar-city;bar-region"

 * creating a system-addressbook

On a fresh system, where Evolution hasn't been run yet, there exists no system-addressbook. libsoylent relies on a system-addressbook, so it has to create it if it doesn't exist yet. I didn't find anything about that in the documentation or in the Evolution source. Could you please give me a hint or point me to the right location in the Evolution source?

 * adding contacts to an addressbook

libsoylent creates addressbooks with calls to e_source_new, e_source_group_add, e_sourc_list_sync. However, if I try to add contacts to an addressbook created this way, E-D-S will just hang forever. Detailed source-code is attached. Help would be highly appreciated :) . Should I file a bug for this?

 * deleting an addressbook

This one seems related to the "adding contacts" problem. Trying to delete addressbooks that were created like described above will result in e_book_remove throwing an "EDS-Status returned 20" error. After that E-D-S crashes with a coredump. Any ideas about that? Source code again is attached. Should I file a bug for this?

---

Okay, that's it. If you could help me, that would make me ueber-happy ;) . Just tell me if you need more information.

If you're interested in the full libsoylent source-code, just look at [1]. If you're also interested in the libsoylent development: should I post libsoylent release-announcements on this list?

Thanks for listening :)
Looking forward to answers
- Sven

---

[1] http://live.gnome.org/Soylent/libsoylent
[2] http://live.gnome.org/Soylent
--- create an addressbook ---
gchar *name: name of the book to create

  ESourceList *source_tree = NULL;
  if (!e_book_get_addressbooks (&source_tree, error))
    {
      return NULL;
    }

  GSList *groups = e_source_list_peek_groups (source_tree);
  g_assert (groups != NULL);
  ESourceGroup *default_group = groups->data;

  ESource *source = e_source_new (name, "");
  e_source_group_add_source (default_group, source, -1);
  if (!e_source_list_sync (source_tree, error))
    {
      return NULL;
    }

--- delete an addressbook ---
gchar *name: name of the book to delete

  ESourceList *source_tree = NULL;
  if (!e_book_get_addressbooks (&source_tree, error))
    {
      return FALSE;
    }
  
  ESource *source = NULL;

  GSList *groups = e_source_list_peek_groups (source_tree);
  for (; groups != NULL; groups = groups->next)
    {
      ESourceGroup *group = groups->data;
      GSList *sources = e_source_group_peek_sources (group);
      for (; sources != NULL; sources = sources->next)
        {
          const gchar *source_name = e_source_peek_name (sources->data);
          if (g_str_equal (name, source_name))
            {
              source = sources->data;
              break;
            }
        }
    }

  if (source == NULL)
    {
      g_set_error (error, SL_BOOK_ERROR, SL_BOOK_ERROR_NOT_EXISTING,
        "There is no book \"%s\".", (gchar *) name);
      return FALSE;
    }
  
  /* get ebook and delete its related data */
  EBook *ebook = e_book_new (source, error);
  if (ebook == NULL)
    {
      return FALSE;
    }
  gboolean removed = e_book_remove (ebook, error);
  g_object_unref (ebook);
  if (!removed)
    {
      return FALSE;
    }
  
  /* remove the source from the source-tree */
  ESourceGroup *group = e_source_peek_group (source);
  e_source_group_remove_source (group, source);
  if (!e_source_list_sync (source_tree, error))
    {
      return FALSE;
    }
  g_object_unref (source_tree);
  
  return TRUE;

--- add a contact to an addressbook ---

  if (!e_book_add_contact (ebook, econtact,
                           error))
    {
      return FALSE;
    }
  
  return TRUE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]