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

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)
  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))
  for (l = appts; l;l = l->next) {
    ECalComponent *ev_appt = E_CAL_COMPONENT(l->data);

gboolean cb_work(void *data)
  return FALSE;

int main(int argc, char** argv) {

    printf("Init (pid %i)\n", getpid());
  g_idle_add(cb_work, NULL); 
    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.

 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

 V. Seguí


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