/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* evolution-activity-client.c * * Copyright (C) 2001 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Ettore Perazzoli */ /* Another evil GTK+ object wrapper for a CORBA API. In this case, the wrapper is needed to avoid sending too frequent CORBA requests across the wire, thus slowing the client down. The wrapper makes sure that there is a minimum amount of time between each CORBA method invocation. */ #ifdef HAVE_CONFIG_H #include #endif #include "evolution-activity-client.h" #include "e-shell-corba-icon-utils.h" #include #include #include #include #include #define PARENT_TYPE gtk_object_get_type () static GtkObjectClass *parent_class = NULL; /* The minimum time between updates, in msecs. */ #define UPDATE_DELAY 1000 enum { SHOW_DETAILS, CANCEL, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; struct _EvolutionActivityClientPrivate { /* The ::Activity interface that we QI from the shell. */ GNOME_Evolution_Activity activity_interface; /* BonoboListener used to get notification about actions that the user requested on the activity. */ BonoboListener *listener; /* Id of this activity. */ GNOME_Evolution_Activity_ActivityId activity_id; /* Id for the GTK+ timeout used to do updates. */ int next_update_timeout_id; /* Wether we have to actually push an update at this timeout. */ int have_pending_update; /* Data for the next update. */ char *new_information; double new_progress; }; /* Utility functions. */ static gboolean corba_update_progress (EvolutionActivityClient *activity_client, const char *information, double progress) { EvolutionActivityClientPrivate *priv; CORBA_Environment ev; gboolean retval; priv = activity_client->priv; CORBA_exception_init (&ev); GNOME_Evolution_Activity_operationProgressing (priv->activity_interface, priv->activity_id, information, progress, &ev); if (! BONOBO_EX (&ev)) { retval = TRUE; } else { g_warning ("EvolutionActivityClient: Error updating progress -- %s", BONOBO_EX_REPOID (&ev)); retval = FALSE; } CORBA_exception_free (&ev); return retval; } static gboolean update_timeout_callback (void *data) { EvolutionActivityClient *activity_client; EvolutionActivityClientPrivate *priv; activity_client = EVOLUTION_ACTIVITY_CLIENT (data); priv = activity_client->priv; if (priv->have_pending_update) { priv->have_pending_update = FALSE; corba_update_progress (activity_client, priv->new_information, priv->new_progress); return TRUE; } else { priv->next_update_timeout_id = 0; return FALSE; } } /* BonoboListener callback. */ static void listener_callback (BonoboListener *listener, const char *event_name, const CORBA_any *any, CORBA_Environment *ev, void *data) { EvolutionActivityClient *activity_client; activity_client = EVOLUTION_ACTIVITY_CLIENT (data); if (strcmp (event_name, "ShowDetails") == 0) g_signal_emit (activity_client, signals[SHOW_DETAILS], 0); else if (strcmp (event_name, "Cancel") == 0) g_signal_emit (activity_client, signals[CANCEL], 0); else g_warning ("EvolutionActivityClient: Unknown event from listener -- %s", event_name); } /* GObject methods. */ static void impl_dispose (GObject *object) { EvolutionActivityClient *activity_client; EvolutionActivityClientPrivate *priv; CORBA_Environment ev; activity_client = EVOLUTION_ACTIVITY_CLIENT (object); priv = activity_client->priv; if (priv->next_update_timeout_id != 0) { g_source_remove (priv->next_update_timeout_id); priv->next_update_timeout_id = 0; } CORBA_exception_init (&ev); if (! CORBA_Object_is_nil (priv->activity_interface, &ev)) { GNOME_Evolution_Activity_operationFinished (priv->activity_interface, priv->activity_id, &ev); if (BONOBO_EX (&ev)) g_warning ("EvolutionActivityClient: Error reporting completion of operation -- %s", BONOBO_EX_REPOID (&ev)); CORBA_Object_release (priv->activity_interface, &ev); priv->activity_interface = CORBA_OBJECT_NIL; } CORBA_exception_free (&ev); if (priv->listener != NULL) { bonobo_object_unref (BONOBO_OBJECT (priv->listener)); priv->listener = NULL; } (* G_OBJECT_CLASS (parent_class)->dispose) (object); } static void impl_finalize (GObject *object) { EvolutionActivityClient *activity_client; EvolutionActivityClientPrivate *priv; activity_client = EVOLUTION_ACTIVITY_CLIENT (object); priv = activity_client->priv; g_free (priv->new_information); g_free (priv); (* G_OBJECT_CLASS (parent_class)->finalize) (object); } static void class_init (EvolutionActivityClientClass *klass) { GObjectClass *object_class; parent_class = gtk_type_class (PARENT_TYPE); object_class = G_OBJECT_CLASS (klass); object_class->dispose = impl_dispose; object_class->finalize = impl_finalize; signals[SHOW_DETAILS] = gtk_signal_new ("show_details", GTK_RUN_FIRST, GTK_CLASS_TYPE (object_class), GTK_SIGNAL_OFFSET (EvolutionActivityClientClass, show_details), gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); signals[CANCEL] = gtk_signal_new ("cancel", GTK_RUN_FIRST, GTK_CLASS_TYPE (object_class), GTK_SIGNAL_OFFSET (EvolutionActivityClientClass, cancel), gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); } static void init (EvolutionActivityClient *activity_client) { EvolutionActivityClientPrivate *priv; priv = g_new (EvolutionActivityClientPrivate, 1); priv->activity_interface = CORBA_OBJECT_NIL; priv->listener = bonobo_listener_new (listener_callback, activity_client); priv->activity_id = (GNOME_Evolution_Activity_ActivityId) 0; priv->next_update_timeout_id = 0; priv->have_pending_update = FALSE; priv->new_information = NULL; priv->new_progress = 0.0; activity_client->priv = priv; } gboolean evolution_activity_client_construct (EvolutionActivityClient *activity_client, EvolutionShellClient *shell_client, const char *component_id, GdkPixbuf **animated_icon, const char *information, gboolean cancellable, gboolean *suggest_display_return) { EvolutionActivityClientPrivate *priv; GNOME_Evolution_Activity activity_interface; CORBA_Environment ev; CORBA_boolean suggest_display; GNOME_Evolution_AnimatedIcon *corba_animated_icon; g_return_val_if_fail (activity_client != NULL, FALSE); g_return_val_if_fail (EVOLUTION_IS_ACTIVITY_CLIENT (activity_client), FALSE); g_return_val_if_fail (shell_client != NULL, FALSE); g_return_val_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client), FALSE); g_return_val_if_fail (animated_icon != NULL, FALSE); g_return_val_if_fail (*animated_icon != NULL, FALSE); g_return_val_if_fail (information != NULL, FALSE); g_return_val_if_fail (suggest_display_return != NULL, FALSE); priv = activity_client->priv; g_return_val_if_fail (priv->activity_interface == CORBA_OBJECT_NIL, FALSE); GTK_OBJECT_UNSET_FLAGS (activity_client, GTK_FLOATING); CORBA_exception_init (&ev); activity_interface = evolution_shell_client_get_activity_interface (shell_client); priv->activity_interface = CORBA_Object_duplicate (activity_interface, &ev); if (ev._major != CORBA_NO_EXCEPTION) { priv->activity_interface = CORBA_OBJECT_NIL; CORBA_exception_free (&ev); return FALSE; } corba_animated_icon = e_new_corba_animated_icon_from_pixbuf_array (animated_icon); GNOME_Evolution_Activity_operationStarted (activity_interface, component_id, corba_animated_icon, information, cancellable, bonobo_object_corba_objref (BONOBO_OBJECT (priv->listener)), &priv->activity_id, &suggest_display, &ev); CORBA_free (corba_animated_icon); if (ev._major != CORBA_NO_EXCEPTION) { CORBA_exception_free (&ev); return FALSE; } *suggest_display_return = (gboolean) suggest_display; CORBA_exception_free (&ev); return TRUE; } EvolutionActivityClient * evolution_activity_client_new (EvolutionShellClient *shell_client, const char *component_id, GdkPixbuf **animated_icon, const char *information, gboolean cancellable, gboolean *suggest_display_return) { EvolutionActivityClient *activity_client; g_return_val_if_fail (shell_client != NULL, NULL); g_return_val_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client), NULL); g_return_val_if_fail (animated_icon != NULL, NULL); g_return_val_if_fail (*animated_icon != NULL, NULL); g_return_val_if_fail (information != NULL, NULL); g_return_val_if_fail (suggest_display_return != NULL, NULL); activity_client = g_object_new (evolution_activity_client_get_type (), NULL); if (! evolution_activity_client_construct (activity_client, shell_client, component_id, animated_icon, information, cancellable, suggest_display_return)) { g_object_unref (activity_client); return NULL; } return activity_client; } gboolean evolution_activity_client_update (EvolutionActivityClient *activity_client, const char *information, double progress) { EvolutionActivityClientPrivate *priv; gboolean retval; g_return_val_if_fail (activity_client != NULL, FALSE); g_return_val_if_fail (EVOLUTION_IS_ACTIVITY_CLIENT (activity_client), FALSE); g_return_val_if_fail (information != NULL, FALSE); g_return_val_if_fail (progress == -1.0 || (progress >= 0.0 && progress <= 1.0), FALSE); priv = activity_client->priv; if (priv->next_update_timeout_id == 0) { /* There is no pending timeout, so the last CORBA update happened more than UPDATE_DELAY msecs ago. So we set up a timeout so we can check against it at the next update request. Notice that GLib timeouts or other operations on this object can be invoked within a remote CORBA invocation, so we need to set `next_update_timeout_id' and `have_pending_update' before doing the CORBA call, or nasty race conditions might happen. */ priv->have_pending_update = FALSE; priv->next_update_timeout_id = g_timeout_add (UPDATE_DELAY, update_timeout_callback, activity_client); retval = corba_update_progress (activity_client, information, progress); } else { /* There is a pending timeout, so the last CORBA update happened less than UPDATE_DELAY msecs ago. So just queue an update instead. */ g_free (priv->new_information); priv->new_information = g_strdup (information); priv->new_progress = progress; priv->have_pending_update = TRUE; retval = TRUE; } return retval; } GNOME_Evolution_Activity_DialogAction evolution_activity_client_request_dialog (EvolutionActivityClient *activity_client, GNOME_Evolution_Activity_DialogType dialog_type) { EvolutionActivityClientPrivate *priv; GNOME_Evolution_Activity_DialogAction retval; CORBA_Environment ev; g_return_val_if_fail (activity_client != NULL, GNOME_Evolution_Activity_DIALOG_ACTION_ERROR); g_return_val_if_fail (EVOLUTION_IS_ACTIVITY_CLIENT (activity_client), GNOME_Evolution_Activity_DIALOG_ACTION_ERROR); priv = activity_client->priv; CORBA_exception_init (&ev); retval = GNOME_Evolution_Activity_requestDialog (priv->activity_interface, priv->activity_id, dialog_type, &ev); if (BONOBO_EX (&ev) != CORBA_NO_EXCEPTION) { g_warning ("EvolutionActivityClient: Error requesting a dialog -- %s", BONOBO_EX_REPOID (&ev)); retval = GNOME_Evolution_Activity_DIALOG_ACTION_ERROR; } CORBA_exception_free (&ev); return retval; } E_MAKE_TYPE (evolution_activity_client, "EvolutionActivityClient", EvolutionActivityClient, class_init, init, PARENT_TYPE) ' href='#n267'>267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745
# Process this file with autoconf to produce a configure script.
AC_INIT(camel)
AM_CONFIG_HEADER(config.h)

cflags_set=${CFLAGS+set}

EVOLUTION_MAJOR_VERSION=0
EVOLUTION_MINOR_VERSION=0
EVOLUTION_MICRO_VERSION=6
VERSION=$EVOLUTION_MINOR_VERSION.$EVOLUTION_MICRO_VERSION
PACKAGE=evolution

AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
AC_SUBST(VERSION)


dnl Initialize libtool
AM_PROG_LIBTOOL

dnl Initialize maintainer mode
AM_MAINTAINER_MODE

AC_CANONICAL_HOST

AM_ACLOCAL_INCLUDE(macros)
GNOME_INIT(capplet)
GNOME_COMPILE_WARNINGS
AC_ISC_POSIX
AC_PROG_CC
AC_PROG_CPP
AM_PROG_LEX
AC_PROG_YACC
AC_STDC_HEADERS
AC_ARG_PROGRAM
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, /usr/sbin:/usr/lib)
AC_DEFINE_UNQUOTED(SENDMAIL_PATH, "$SENDMAIL")

AC_MSG_CHECKING(system mail directory)
if test -d /var/mail; then
    system_mail_dir=/var/mail
else
    system_mail_dir=/var/spool/mail
fi
AC_MSG_RESULT($system_mail_dir)
AC_DEFINE_UNQUOTED(SYSTEM_MAIL_DIR, "$system_mail_dir")

dnl Check for new enough gnome-libs
CFLAGS_save=$CFLAGS
LIBS_save=$LIBS
CFLAGS=`gnome-config --cflags gnomeui`
LIBS=`gnome-config --libs gnomeui`

AC_CHECK_LIB(gnomeui, gnome_window_icon_set_default_from_file, ,[
AC_MSG_ERROR(gnome-libs 1.0.59 or higher is required.)])

CFLAGS=$CFLAGS_save
LIBS=$LIBS_save

ALL_LINGUAS="ca da de el en_GB es fi fr ga gl hu it ja ko lt nl nn no pl pt ru sl sv tr uk"

AM_GNOME_GETTEXT
localedir='$(prefix)/$(DATADIRNAME)/locale'
AC_SUBST(localedir)

GNOME_X_CHECKS

dnl
dnl Purify support
dnl
AC_ARG_ENABLE(purify, 
[  --enable-purify=[no/yes]      Enable support for building executables with
                                Purify.],,enable_purify=no)
AC_PATH_PROG(PURIFY, purify, impure)
AC_ARG_WITH(purify-options, [  --with-purify-options=OPTIONS      Options passed to the purify command line (defaults to PURIFYOPTIONS variable).])
if test "x$with_purify_options" = "xno"; then
  with_purify_options="-always-use-cache-dir=yes -cache-dir=/gnome/lib/purify"
fi
if test "x$PURIFYOPTIONS" = "x"; then
  PURIFYOPTIONS=$with_purify_options
fi
AC_SUBST(PURIFY)
AM_CONDITIONAL(ENABLE_PURIFY, test "x$enable_purify" = "xyes" -a "x$PURIFY" != "ximpure")
PURIFY="$PURIFY $PURIFYOPTIONS"

dnl * Time zone stuff
AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
    AC_TRY_COMPILE([
        #include <time.h>
    ], [
        timezone = 1;
    ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
if test $ac_cv_var_timezone = yes; then
    AC_DEFINE(HAVE_TIMEZONE)
else
    AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
        AC_TRY_COMPILE([
            #include <time.h>
            ], [
            struct tm tm;
            tm.tm_gmtoff = 1;
            ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
    if test $ac_cv_struct_tm_gmtoff = yes; then
        AC_DEFINE(HAVE_TM_GMTOFF)
    else
        AC_ERROR(unable to find a way to determine timezone)
    fi
fi

AC_CHECK_FUNCS(mkstemp mkdtemp isblank)

dnl **************************************************
dnl ctime_r prototype
dnl **************************************************

AC_CACHE_CHECK([if ctime_r wants three arguments], ac_cv_ctime_r_three_args,
[
    AC_TRY_COMPILE([
        #include <time.h>
    ],[
        char *buf;
        time_t date;
        ctime_r( &date, buf, 100 );
    ],[
        ac_cv_ctime_r_three_args=yes
    ],[
        ac_cv_ctime_r_three_args=no
    ])
])
    
if test x"$ac_cv_ctime_r_three_args" = xyes ; then
    AC_DEFINE(CTIME_R_THREE_ARGS)
fi

dnl **************************************************
dnl * pas-backend-file stuff.
dnl * check for db_185.h.  if it's there, we use it.
dnl * otherwise, we use db.h (since it'll be 185).
dnl * Except on RH7.0, which puts db in yet another place
dnl **************************************************
AC_CHECK_HEADERS(db_185.h)
AC_CHECK_HEADERS(db1/db.h)

dnl **************************************************
dnl * ldap related stuff.
dnl **************************************************
AC_CHECK_LIB(lber, ber_get_tag, LDAP_LIBS="-llber")
if test x$ac_cv_lib_lber_ber_get_tag = xyes; then
AC_CHECK_LIB(ldap, ldap_open, LDAP_LIBS="-lldap $LDAP_LIBS", ,-llber)
fi
if test x$ac_cv_lib_ldap_ldap_open = xyes; then
    AC_DEFINE(HAVE_LDAP)
    AC_SUBST(LDAP_LIBS)
    msg_ldap=Yes
else
    AC_MSG_WARN(no ldap support present)
    msg_ldap=No
fi
AM_CONDITIONAL(ENABLE_LDAP, test x$ac_cv_lib_ldap_ldap_open = xyes)

dnl **************************************************
dnl * Posix thread support
dnl **************************************************

dnl Hah! Threads are no longer an option
dnl AC_ARG_WITH(threads, [  --with-threads          Include thread support],[
dnl FIXME: support more thread types, pth at least

GNOME_PTHREAD_CHECK

if test "x$PTHREAD_LIB" = "x" ; then
    AC_MSG_ERROR([POSIX threads are currently required for Evolution])
fi

dnl
dnl Notice that this is a hack, and we wont be able to use this forever, but
dnl at least for some time
dnl

THREADS_LIBS="$PTHREAD_LIB `glib-config --libs gthread`"
THREADS_CFLAGS="`glib-config --cflags gthread`"

AC_SUBST(THREADS_LIBS)
AC_SUBST(THREADS_CFLAGS)

dnl **************************************************
dnl * File locking
dnl **************************************************

AC_ARG_ENABLE(dot-locking, 
[  --enable-dot-locking=[yes/no] Enable support for locking mail files with dot locking],,enable_dot_locking=yes)
if test "x$enable_dot_locking" = "xyes"; then
  AC_DEFINE(USE_DOT)
  msg_dot=Yes
else
  msg_dot=No    
fi

AC_ARG_ENABLE(file-locking, 
[  --enable-file-locking=[fcntl/flock/no] Enable support for locking mail files with file locking],,enable_file_locking=fcntl)
if test "x$enable_file_locking" = "xfcntl"; then
  AC_DEFINE(USE_FCNTL)
  msg_file=fcntl
else
  if test "x$enable_file_locking" = "xflock"; then
    AC_DEFINE(USE_FLOCK)
    msg_file=flock
  else
    msg_file=No 
  fi
fi

dnl **************************************************
dnl * Print check
dnl **************************************************
AC_MSG_CHECKING(for GnomePrint libraries version either 0.20 or later)
  if gnome-config --libs print > /dev/null 2>&1; then 
    vers=`gnome-config --modversion print | sed -e "s/gnome-print-//" | awk 'BEGIN { FS = "."; } { print $1 * 1000 + $2;}'`
    if test "$vers" -ge 20; then
      if test "$vers" -ge 21; then
          AC_MSG_RESULT(found >=0.21)
      else
          AC_MSG_RESULT(found 0.20)
      AC_DEFINE(USING_GNOME_PRINT_0_20)
      fi
    else
        AC_MSG_ERROR(Please upgrade your gnome-print to version 0.20 or later.)
    fi
  else
     AC_MSG_ERROR(Did not find GnomePrint installed)
  fi

GNOME_PRINT_LIBS=`gnome-config --libs print`
GNOME_PRINT_CFLAGS=`gnome-config --cflags print`
AC_SUBST(GNOME_PRINT_LIBS)
AC_SUBST(GNOME_PRINT_CFLAGS)

dnl ******************************
dnl Check for Bonobo
dnl ******************************
AC_MSG_CHECKING(for Bonobo >= 0.29)
if gnome-config --libs bonobox > /dev/null 2>&1; then
    vers=`gnome-config --modversion bonobo | sed -e "s/bonobo-//" | \
        awk 'BEGIN { FS = "."; } { printf "%d", $1 * 1000 + $2;}'`
    if test "$vers" -ge 29; then
        bonobo_ok=true
    else
        bonobo_ok=false
    fi
else
    bonobo_ok=false
fi

if $bonobo_ok; then
    AC_MSG_RESULT($vers found)
else
    AC_MSG_ERROR(Bonobo 0.29 or newer is required to compile Evolution)
fi

dnl ******************************
dnl OAF
dnl ******************************

AC_PATH_PROG(OAF_CONFIG,oaf-config,no)
if test x$OAF_CONFIG = xno; then
    AC_MSG_ERROR("The oaf-config program was not found")
else
    OAF_LIBS=`$OAF_CONFIG --libs`
    OAF_CFLAGS=`$OAF_CONFIG --cflags`
fi

AC_SUBST(OAF_LIBS)
AC_SUBST(OAF_CFLAGS)


dnl ******************************
dnl LibGlade checking
dnl ******************************
AC_MSG_CHECKING(for Glade libraries)
if gnome-config --libs libglade > /dev/null 2>&1; then 
    AC_MSG_RESULT(found)
else
    AC_MSG_ERROR(Did not find libGlade installed)
fi

dnl ******************************
dnl libunicode checking
dnl ******************************
AC_MSG_CHECKING(for libunicode)
if unicode-config --libs > /dev/null 2>&1; then 
    UNICODE_LIBS=`unicode-config --libs`
    UNICODE_CFLAGS=`unicode-config --cflags`
    AC_SUBST(UNICODE_LIBS)
    AC_SUBST(UNICODE_CFLAGS)
    AC_MSG_RESULT(found)
else
    AC_MSG_ERROR(libunicode not found)
fi

dnl ******************************
dnl GdkPixbuf checking
dnl ******************************
AC_MSG_CHECKING(for Gdkpixbuf libraries)
if gnome-config --libs gdk_pixbuf gnomecanvaspixbuf > /dev/null 2>&1; then 
    AC_MSG_RESULT(found)
else
    AC_MSG_ERROR(Did not find gdkpixbuf installed)
fi

dnl ******************************
dnl Gnome App Lib checking
dnl ******************************
AC_MSG_CHECKING(for Gnome App libraries (GAL) >= 0.3)
if gnome-config --libs gal > /dev/null 2>&1; then 
    vers=`gnome-config --modversion gal | sed -e "s/gal-//" -e 's/cvs$//' -e 's/pre$//' | \
        awk 'BEGIN { FS = "."; } { print $1 * 1000000 + $2 * 10000 + $3 * 100 + $4;}'`
    if test "$vers" -ge 30000; then
        AC_MSG_RESULT(found)
    else
        AC_MSG_ERROR(You need at least GNOME Application libs 0.3 for this version of Evolution)
    fi
else
    AC_MSG_ERROR(Did not find GnomeAppLib (GAL) installed)
fi

GLIB_CFLAGS="`glib-config --cflags`"
GLIB_LIBS="`glib-config --libs`"

AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)


EXTRA_GNOME_LIBS="`gnome-config --libs libglade gdk_pixbuf gnomecanvaspixbuf gnomeui gal` $THREADS_LIBS $UNICODE_LIBS"
EXTRA_GNOME_CFLAGS="`gnome-config --cflags libglade gdk_pixbuf gnomecanvaspixbuf gnomeui gal` $THREADS_CFLAGS $UNICODE_CFLAGS"

AC_SUBST(EXTRA_GNOME_LIBS)
AC_SUBST(EXTRA_GNOME_CFLAGS)


BONOBO_GNOME_LIBS="`gnome-config --libs bonobox_print libglade gdk_pixbuf gnomecanvaspixbuf gnomeui` $UNICODE_LIBS $OAF_LIBS"
BONOBO_GNOME_CFLAGS="`gnome-config --cflags bonobox_print libglade gdk_pixbuf gnomecanvaspixbuf gnomeui ` $UNICODE_CFLAGS $OAF_CFLAGS"
AC_SUBST(BONOBO_GNOME_LIBS)
AC_SUBST(BONOBO_GNOME_CFLAGS)

BONOBO_HTML_GNOME_LIBS="`gnome-config --libs bonobox_print libglade gdk_pixbuf gtkhtml gnomecanvaspixbuf gnomeui ` $THREAD_LIBS $UNICODE_LIBS"
BONOBO_HTML_GNOME_CFLAGS="`gnome-config --cflags bonobox_print libglade gdk_pixbuf gtkhtml gnomecanvaspixbuf gnomeui ` $THREAD_CFLAGS $UNICODE_CFLAGS"
AC_SUBST(BONOBO_HTML_GNOME_LIBS)
AC_SUBST(BONOBO_HTML_GNOME_CFLAGS)

dnl ******************************
dnl GtkHTML checking
dnl ******************************

AC_MSG_CHECKING(for GtkHTML)
if gnome-config --libs gtkhtml > /dev/null 2>&1; then
    vers=`gnome-config --modversion gtkhtml`
    case $vers
    in
        gtkhtml-0.[012345678]) gtkhtml_ok=false ;;
        *) gtkhtml_ok=true ;;
    esac
else
    gtkhtml_ok=false
fi

if $gtkhtml_ok; then
    AC_MSG_RESULT($vers found)
else
    AC_MSG_ERROR(GtkHTML 0.8 or later is required to compile Evolution)
fi

GTKHTML_CFLAGS="`gnome-config --cflags gtkhtml`"
GTKHTML_LIBS="`gnome-config --libs gtkhtml`"

AC_SUBST(GTKHTML_CFLAGS)
AC_SUBST(GTKHTML_LIBS)

if test x${prefix} = xNONE; then
    html_prefix=$ac_default_prefix
else
    html_prefix=$prefix
fi
AC_MSG_CHECKING(for Editor.idl in `gnome-config --datadir`/gtkhtml or ${html_prefix}/share/gtkhtml)
if test -f `gnome-config --datadir`/gtkhtml/Editor.idl; then
    GTK_HTML_EDITOR_IDL=`gnome-config --datadir`/gtkhtml/Editor.idl
    AC_MSG_RESULT(found)
else
    if test -f ${html_prefix}/share/gtkhtml/Editor.idl; then
        GTK_HTML_EDITOR_IDL=${html_prefix}/share/gtkhtml/Editor.idl
        AC_MSG_RESULT(found)
    else
        AC_MSG_ERROR(Editor.idl is required to compile Evolution composer, it's included in GtkHTML
You need GtkHTML build with html-editor-control)
    fi
fi

AC_SUBST(GTK_HTML_EDITOR_IDL)

dnl ******************************
dnl Gnome-VFS checking
dnl ******************************
AC_MSG_CHECKING(for GNOME-VFS)
if gnome-config --libs vfs > /dev/null 2>&1; then
    vers=`gnome-config --modversion vfs`
    case $vers
    in
        gnome-vfs-0.[012]) vfs_ok=false ;;
        *) vfs_ok=true ;;
    esac
else
    vfs_ok=false
fi

if $vfs_ok; then
    AC_MSG_RESULT($vers)
else
    AC_MSG_ERROR(GNOME-VFS 0.3 or newer is required to compile Evolution)
fi

GNOME_VFS_LIBS="`gnome-config --libs vfs`"
GNOME_VFS_CFLAGS="`gnome-config --cflags vfs`"
AC_SUBST(GNOME_VFS_LIBS)
AC_SUBST(GNOME_VFS_CFLAGS)

BONOBO_VFS_GNOME_LIBS="`gnome-config --libs bonobox libglade gdk_pixbuf gnomecanvaspixbuf vfs gnomeui `"
BONOBO_VFS_GNOME_CFLAGS="`gnome-config --cflags bonobox libglade gdk_pixbuf gnomecanvaspixbuf vfs gnomeui `"
AC_SUBST(BONOBO_VFS_GNOME_LIBS)
AC_SUBST(BONOBO_VFS_GNOME_CFLAGS)

dnl ******************************
dnl Pilot checking
dnl ******************************
AC_ARG_ENABLE(pilot-conduits, 
[  --enable-pilot-conduits=[no/yes] Enable support for building pilot conduits.],,enable_pilot_conduits=no)
if test "x$enable_pilot_conduits" = "xyes"; then
GNOME_PILOT_CHECK
fi
AM_CONDITIONAL(ENABLE_PILOT_CONDUITS, test "x$enable_pilot_conduits" = "xyes")
if test x$enable_pilot_conduits = xyes; then
   msg_pilot=Yes
else
   msg_pilot=No
fi

dnl ******
dnl XML
dnl ******
GNOME_XML_CHECK
xmlversion=`xml-config --version | sed 's/^libxml//'`
xmlmajor=`echo $xmlversion | awk -F. '{print $1;}'`
xmlminor=`echo $xmlversion | awk -F. '{print $2;}'`
xmlpatch=`echo $xmlversion | awk -F. '{print $3;}'`
if test "$xmlmajor" -ne 1 -o "$xmlminor" -ne 8 -o "$xmlpatch" -lt 7; then
    AC_MSG_ERROR(gnome-xml 1.8.7 (or later, but not 2.0) is required to compile Evolution)
fi

AC_SUBST(CAPPLET_LIBS)


dnl ********
dnl Kerberos
dnl ********
AC_ARG_WITH(krb5, [  --with-krb5=PREFIX      Location of Kerberos 5 libs/includes])
AC_ARG_WITH(krb4, [  --with-krb4=PREFIX      Location of Kerberos 4 libs/includes])
msg_krb5=No
if test x${with_krb5:=no} != xno; then
    CFLAGS_save="$CFLAGS"
    LDFLAGS_save="$LDFLAGS"
    CFLAGS="-I$with_krb5/include/krb5"
    LDFLAGS="-L$with_krb5/lib"
    AC_CHECK_LIB(krb5, krb5_init_context,
    [
        AC_DEFINE(HAVE_KRB5)
        KRB5_CFLAGS="$CFLAGS"
        KRB5_LDFLAGS="$LDFLAGS -lkrb5 -lk5crypto -lcom_err"
        msg_krb5=Yes
    ],[
        AC_MSG_WARN([A sample Kerberos 5 program could not be compiled with the
Kerberos found in $with_krb5. Please verify that the prefix is correct.])
        with_krb5=no
    ], [-lk5crypto -lcom_err])
    CFLAGS="$CFLAGS_save"
    LDFLAGS="$LIBS_save"
else
    AC_MSG_CHECKING(for Kerberos 5)
    AC_MSG_RESULT($with_krb5)
fi

msg_krb4=No
if test x${with_krb4:=no} != xno; then
    CFLAGS_save="$CFLAGS"
    LDFLAGS_save="$LDFLAGS"
    CFLAGS="-I$with_krb4/include/kerberosIV -I$with_krb4/include/kerberos"
    test -f "$with_krb4/include/krb.h" && \
        CFLAGS="$CFLAGS -I$with_krb4/include"
    test -f "$with_krb4/include/port-sockets.h" && \
        CFLAGS="$CFLAGS -I$with_krb4/include"

    LDFLAGS="-L$with_krb4/lib"
    AC_CHECK_LIB(krb, krb_mk_req,
    [
        AC_DEFINE(HAVE_KRB4)
        KRB4_CFLAGS="$CFLAGS"
        KRB4_LDFLAGS="$LDFLAGS -lkrb"
        msg_krb4=Yes
    ],[
        AC_CHECK_LIB(krb, krb_rd_req,
        [
            AC_DEFINE(HAVE_KRB4)
            KRB4_CFLAGS="$CFLAGS"
            KRB4_LDFLAGS="$LDFLAGS -lkrb -ldes"
            msg_krb4=Yes
        ],[
            AC_CHECK_LIB(krb4, krb_mk_req,
            [
                AC_DEFINE(HAVE_KRB4)
                KRB4_CFLAGS="$CFLAGS"
                KRB4_LDFLAGS="$LDFLAGS -lkrb4 -ldes425 $KRB5_LDFLAGS"
                msg_krb4=Yes
            ],[
                AC_MSG_WARN([A sample Kerberos 4 program could not be compiled with the
Kerberos found in $with_krb4. Please verify that the prefix is correct.])
                with_krb4=no
            ],[-ldes425 $KRB5_LDFLAGS])
        ],[-ldes])
    ])

    AC_TRY_COMPILE([#include "krb.h"
    int krb_sendauth;
    ],[return 0],[AC_DEFINE(NEED_KRB_SENDAUTH_PROTO)],)

    CFLAGS="$CFLAGS_save"
    LDFLAGS="$LIBS_save"
else
    AC_MSG_CHECKING(for Kerberos 4)
    AC_MSG_RESULT(${with_krb4})
fi

AC_SUBST(KRB5_CFLAGS)
AC_SUBST(KRB5_LDFLAGS)
AC_SUBST(KRB4_CFLAGS)
AC_SUBST(KRB4_LDFLAGS)


dnl ******************************
dnl gtk-doc
dnl ******************************

AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
AM_CONDITIONAL(HAVE_GTK_DOC, $GTKDOC)
AC_SUBST(HAVE_GTK_DOC)

dnl Let people disable the gtk-doc stuff.
AC_ARG_ENABLE(gtk-doc, [  --enable-gtk-doc  Use gtk-doc to build documentation [default=auto]], enable_gtk_doc="$enableval", enable_gtk_doc=auto)

if test x$enable_gtk_doc = xauto ; then
  if test x$GTKDOC = xtrue ; then
    enable_gtk_doc=yes
  else
    enable_gtk_doc=no
  fi
fi

dnl NOTE: We need to use a separate automake conditional for this
dnl       to make this work with the tarballs.
AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)

dnl ********
dnl movemail
dnl ********
AC_ARG_WITH(movemail, [  --with-movemail=PATH    Path to a movemail binary])
AC_MSG_CHECKING(for movemail)
if test x$with_movemail = xyes -o x$with_movemail = x; then
    with_movemail=no
fi
if test x$with_movemail != xno; then
    AC_DEFINE_UNQUOTED(MOVEMAIL_PATH, "$with_movemail")
    AC_MSG_RESULT($with_movemail)
else
    emacs_exec_dir=`emacs --batch --eval '(message exec-directory)' 2>&1`
    case $emacs_exec_dir in
    /*) if test -x $emacs_exec_dir/movemail; then
        if test -u $emacs_exec_dir/movemail -o -g $emacs_exec_dir/movemail; then
        AC_MSG_RESULT($emacs_exec_dir/movemail)
        AC_DEFINE_UNQUOTED(MOVEMAIL_PATH, "$emacs_exec_dir/movemail")
        else
        AC_MSG_RESULT($emacs_exec_dir/movemail... not set-id: ignored)
        fi
    else
        AC_MSG_RESULT(no)
    fi
    ;;
    *)
    AC_MSG_RESULT(no)
    ;;
    esac
fi

dnl **********
dnl GPGPGPGPGP
dnl **********
AC_PATH_PROG(GPGME_CONFIG, gpgme-config)
if test -n "$GPGME_CONFIG"; then
    AC_DEFINE(HAVE_LIBGPGME)
    GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
    GPGME_LIBS=`$GPGME_CONFIG --libs`
    msg_crypto="GNU PG (via libgpgme)"
else
    msg_crypto=None
    AC_PATH_PROG(GPG, gpg)
    if test -n "$GPG"; then
        AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG")
        AC_DEFINE(PGP_PROGRAM, "GPG")
        msg_crypto="GNU PG"
    else
        AC_PATH_PROG(PGP5, pgpv)
        if test -n "$PGP5"; then
            AC_DEFINE_UNQUOTED(PGP5_PATH, "$PGP5")
            AC_DEFINE(PGP_PROGRAM, "PGP")
            msg_crypto="PGP5"
        else
            AC_PATH_PROG(PGP, pgp)
            if test -n "$PGP"; then
                AC_DEFINE_UNQUOTED(PGP_PATH, "$PGP")
                AC_DEFINE(PGP_PROGRAM, "PGP")
                msg_crypto=PGP
            fi
        fi
    fi
fi
AC_SUBST(GPGME_CFLAGS)
AC_SUBST(GPGME_LIBS)

dnl ******************************
dnl Makefiles
dnl ******************************

AC_CONFIG_SUBDIRS(libical)

EVOLUTION_DIR=`(cd $srcdir; pwd)`
AC_SUBST(EVOLUTION_DIR)

AC_OUTPUT([
Makefile
macros/Makefile
intl/Makefile
po/Makefile.in
e-util/Makefile
e-util/ename/Makefile
libibex/Makefile
executive-summary/Makefile
executive-summary/evolution-services/Makefile
executive-summary/widgets/Makefile
executive-summary/idl/Makefile
 executive-summary/component/Makefile
executive-summary/test-service/Makefile
camel/Makefile
camel/providers/Makefile
camel/providers/mbox/Makefile
camel/providers/pop3/Makefile
camel/providers/sendmail/Makefile
camel/providers/smtp/Makefile
camel/providers/vee/Makefile
camel/providers/imap/Makefile
camel/providers/mh/Makefile
camel/providers/nntp/Makefile
camel/providers/local/Makefile
camel/tests/Makefile
camel/tests/lib/Makefile
camel/tests/message/Makefile
camel/tests/folder/Makefile
camel/tests/stream/Makefile
composer/Makefile
widgets/Makefile
widgets/meeting-time-sel/Makefile
widgets/misc/Makefile
widgets/shortcut-bar/Makefile
widgets/menus/Makefile
addressbook/Makefile
addressbook/conduit/Makefile
addressbook/contact-editor/Makefile
addressbook/printing/Makefile
addressbook/backend/Makefile
addressbook/backend/idl/Makefile
addressbook/backend/pas/Makefile
addressbook/backend/ebook/Makefile
addressbook/gui/Makefile
addressbook/gui/widgets/Makefile
addressbook/gui/search/Makefile
addressbook/gui/component/Makefile
addressbook/gui/component/select-names/Makefile
shell/Makefile
shell/glade/Makefile
mail/Makefile
data/Makefile
libversit/Makefile
libibex/Makefile
calendar/Makefile
calendar/idl/Makefile
calendar/cal-util/Makefile
calendar/cal-client/Makefile
calendar/pcs/Makefile
calendar/gui/Makefile
calendar/gui/dialogs/Makefile
calendar/conduits/Makefile
calendar/conduits/calendar/Makefile
calendar/conduits/todo/Makefile
filter/Makefile
wombat/Makefile
art/Makefile
ui/Makefile
default_user/Makefile
default_user/local/Makefile
default_user/local/Calendar/Makefile
default_user/local/Contacts/Makefile
default_user/local/Drafts/Makefile
default_user/local/Executive-Summary/Makefile
default_user/local/Inbox/Makefile
default_user/local/Outbox/Makefile
default_user/local/Sent/Makefile
default_user/local/Trash/Makefile
tools/Makefile
doc/Makefile
doc/C/Makefile
doc/devel/Makefile
doc/devel/calendar/Makefile
doc/devel/calendar/cal-client/Makefile
doc/devel/calendar/cal-util/Makefile
])

echo "
    Evolution has been configured as follows:

    Mail Directory:   $system_mail_dir
    LDAP support:     $msg_ldap
    Pilot conduits:   $msg_pilot
    Kerberos 4/5:     $msg_krb4/$msg_krb5
    Use movemail:     $with_movemail
    Dot Locking:      $msg_dot
    File Locking:     $msg_file
    Crypto support:   $msg_crypto
"