Re: [Evolution-hackers] bugs?



Would be better with the test program perhaps...


Le dim, 02/05/2004 à 16:22 +0200, Damien Sandras a écrit :
> Hi all,
> 
> I think I found a few bugs regarding E-D-S, but as I'm not sure, I have
> written a small test program so that somebody here can really confirm me
> there is a bug.
> 
> The test program is doing 3 things :
> 1) it will return the list of contacts for which the VIDEO URL contains
> the given string: the list is erroneously empty. It works with a search
> on FULL NAME though.
> 
> 2) it will return the list of contacts for which the CATEGORY contains
> teh given string: the list is erroneously empty even for pre-made
> categories like "Affaires" (Business in french).
> 
> 3) it will try to add a new local address book, it gives a segfault in
> E-D-S' code. I already reported a bug about that 2 weeks ago:
> http://bugzilla.ximian.com/show_bug.cgi?id=57074
> 
> The usage of the test case is pretty simple :
> ./test file:///home/damien/.evolution/addressbook/local/system Business
> 
> To search for all users having Business in their video url or in their
> category. Both are empty. The program will crash later when trying to
> add an ESource to the ESourceGroup.
> 
> Sorry to bother you all the time (I'm really ashamed), perhaps it was
> too early to start porting GM to E-D-S now, and the amount of spare time
> I have to do this is more and more limited :(
> 
> 
> Thanks,
> 
> Damien
#include <libebook/e-book.h>

struct GmAddressbook_ {

  char *name;
  char *uri;
};


typedef struct GmAddressbook_ GmAddressbook;
typedef struct GmContact_ GmContact;


/* Returns the ESourceGroup for local sources */
static ESourceGroup *
gnomemeeting_addressbook_get_local_source_group ()
{
  EBook *ebook = NULL;
  
  ESourceGroup *result = NULL;
  ESourceList *source_list = NULL;
  
  GSList *source_groups = NULL;
  GSList *addressbooks = NULL;
  GSList *l = NULL;
  GSList *j = NULL;

  gchar *uri = NULL;
  
  e_book_get_default_addressbook (&ebook, NULL);


  /* Get the list of possible sources */
  if (e_book_get_addressbooks (&source_list, NULL)) {

    source_groups = e_source_list_peek_groups (source_list);

    l = source_groups;
    while (l) {

      addressbooks = e_source_group_peek_sources (E_SOURCE_GROUP (l->data));
    
      j = addressbooks;
      while (j) {


        uri = e_source_get_uri (E_SOURCE (j->data));
        if (g_str_has_prefix (uri, "file:"))
          result = E_SOURCE_GROUP (l->data);
	printf ("Found addressbook with URI: %s\n", uri);

	g_free (uri);

        j = g_slist_next (j);
      }
      
      g_slist_free (addressbooks);

      l = g_slist_next (l);
    }

    g_slist_free (source_groups);
  }

  return result;
}


/* Add a new Source */
gboolean 
gnomemeeting_addressbook_add (GmAddressbook *addressbook)
{
  ESource *source = NULL;
  ESourceGroup *source_group = NULL;

  g_return_val_if_fail (addressbook != NULL, FALSE);

  source_group = gnomemeeting_addressbook_get_local_source_group ();
  printf ("Will add Address Book to Source Group: %s\n",
	  e_source_group_peek_name (source_group));

  source = e_source_new ("", "");
  
  e_source_set_name (source, addressbook->name);
  e_source_set_relative_uri (source, e_source_peek_uid (source));
  
  e_source_group_add_source (source_group, source, -1); 
    
  return FALSE;
}


void get_contacts (gchar *uri, gchar *search)
{
  EBook *ebook = NULL;
  EBookQuery *query = NULL;

  GList *list = NULL;

  ebook = e_book_new ();
  if (e_book_load_uri (ebook, uri, FALSE, NULL)) {

    query = e_book_query_field_test (E_CONTACT_VIDEO_URL,
				     E_BOOK_QUERY_CONTAINS,
				     search);

    if (e_book_get_contacts (ebook, query, &list, NULL)) {


      if (list == NULL)
	printf ("No Elements found querying E_CONTACT_VIDEO_URL for %s\n",
		search);
    }

    
    query = e_book_query_field_test (E_CONTACT_CATEGORIES,
				     E_BOOK_QUERY_CONTAINS,
				     search);

    if (e_book_get_contacts (ebook, query, &list, NULL)) {


      if (list == NULL)
	printf ("No Elements found querying E_CONTACT_CATEGORIES for %s\n\n",
		search);
    }
  }
}


int main (int argc, char **argv) 
{
  GmAddressbook a;

  if (argc < 3) {

    printf ("Usage test addressbook_uri search_value\n");
    exit (-1);
  }
  
  g_type_init ();

  
  get_contacts (argv [1], argv [2]);

  a.name = g_strdup ("Foo");

  gnomemeeting_addressbook_add (&a);
  
  g_free (a.name);
  
  return 0;
}

Attachment: signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=



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