Re: [Evolution-hackers] Re: Strange console messages when accessing e-d-s through the libecal C API



On Wed, 2005-08-24 at 19:34 +0200, vseguip gmail com wrote:
> On 8/24/05, vseguip gmail com <vseguip gmail com> wrote:
> > On 8/24/05, Not Zed <notzed ximian com> wrote:
> > >
> > > Duh, of course.  You can't just 'run it once'.  It has to keep running.
> > > i.e. all your code has to run *under* that stack point, or if not, that
> > > stack point has to keep running whilst you run things in other threads.
> > >
> > I guess I need much more reading on Glib ;-). I've tried to put the
> > get_all_appointment call inside the idle callback (which meas it will
> > be called after the bonobo_main call) but it still prints the message,
> > I guess I need to read on some "Hello World" tutorial on GLib.
> > 
> 
> Well after some reading I must confess I'm still a little bit lost.
> According to what I've figured out, this should work:
> 
> 
> #include <stdio.h>
> #include <unistd.h>
> #include <libebook/e-book.h>
> #include <libebook/e-contact.h>
> #include <libecal/e-cal.h>
> #include <libecal/e-cal-time-util.h>
> #include <libbonobo-2.0/libbonobo.h>
> 
> 
> gboolean end_program=FALSE;
> 
> ECal* open_calendar() {
>   ECal* cal;
>   GError* error = 0;
>   cal = e_cal_new_system_calendar();
>   e_cal_open(cal, FALSE, &error);
>   if (error)
>     printf("ERROR!");
>   return cal;
> }
> 
> static void get_all_appointments() {
>   GError* error = 0;
>   GList* appts, *l;
>   ECal* cal = open_calendar();
>   e_cal_get_object_list_as_comp(cal, "#t", &appts, &error);
>   if((error)||( e_cal_get_load_state (cal) !=   E_CAL_LOAD_LOADED))
>     printf("ERROR\n");
>   for (l = appts; l;l = l->next) {
>     ECalComponent *ev_appt = E_CAL_COMPONENT(l->data);
>     g_object_unref(ev_appt);
>   }
>   g_list_free(appts);
>   g_object_unref(cal);   
> }
> 
> gboolean cb_work(void *data)
> {
>   get_all_appointments();
>   bonobo_main_quit(); 
>   return FALSE;
> }
> 
> 
> int main(int argc, char** argv) {
> 
>   g_type_init();
>   bonobo_init(&argc,argv);
>   bonobo_activate();
>  
>   if(bonobo_is_initialized())
>     printf("Init (pid %i)\n", getpid());
>   g_idle_add(cb_work, NULL); 
>   bonobo_main();
>   bonobo_debug_shutdown();
>   if(!bonobo_is_initialized())
>     printf("Not init!\n");
>   return 0;
> }
> 
> 
> but the truth is that it still displays the "waiting for completion"
> message :-(. If I execute bonobo_main_quit in a timeout callback only
> after cb_work gets executed, it does work, but I guess it's just like
> if it's doing a sleep.  I feel I'm missing something terribly obvious
> but I can't figure out what.

Well it should be reasonably obvious - for whatever reason - some call
you're making isn't complete yet.  Even though YOUR call is complete, it
may have triggered extra processing which isn't yet.  e.g. an
asynchronous signal may be pending as a result of the process.  A sleep
or whatever lets it finish.

>  Anyway, from the post I previously referred [1] it seems like it
> shouldn't need to run bonobo_main (and in fact, retrieving the
> appointments, etc, runs fine even if there is no bonobo_main),
> although the post could be outdated as of now. Maybe some of the
> internal e-d-s hackers could give a clue on how it is supposed to be
> used?

Maybe it's just a bug in eds libraries then, or maybe you need to call
something to 'init' them.

> Cheers,
>  V. Seguí
> 
> [1] http://lists.ximian.com/pipermail/evolution-hackers/2004-February/002729.html
> _______________________________________________
> evolution-hackers maillist  -  evolution-hackers lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-hackers
-- 
adfa(evolution-2.4:20087): gtkhtml-WARNING **: cannot find icon:
'stock_insert-url' in gnome 




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