/* ====================================================================
 * FTD4Linux Software License, Version 1.0
 *
 * Copyright (c) 2000-2004 The FTD4Linux Development Team.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        FTD4Linux Development Team (http://www.ftd4linux.2y.net/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "FTD" and "FTD4Linux" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact alguno@ftd4linux.2y.net.
 *
 * 5. Products derived from this software may not be called "FTD4Linux",
 *    nor may "FTD4Linux" appear in their name, without prior written
 *    permission of the FTD4Linux Development Team.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE FTD4LINUX DEVELOPMENT TEAM OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#ifndef _FTD_APP_CORE_H_
#define _FTD_APP_CORE_H_

typedef struct _ftd_app_core FtdAppCore;	///< De structuur voor de volledige core.

#include "ftd_events.h"
#include "ftd_category.h"
#include "ftd_mail.h"
#include "ftd_filter.h"
#ifdef HAVE_SQLITE
#include "ftd_eventinfo_cache.h"
#endif

/**
 * De structuur voor de volledige core.
 * Deze structuur wordt bij het opstarten geinitialiseerd en bevat alle componenten om de volledige functionaliteit van FTD4linux uit te voeren.
 */
struct _ftd_app_core {
    FtdConfig       *config;                    ///< De configuratie van FTD4linux.
    FTDFilterlist   *filterlist;                ///< De lijst met ::FtdFilter pointers naar alle bekende filters.
    FTDEventlist    *eventlist;                 ///< De volledige boom met ::FtdEvent pointers naar alle events.
    int              watchlist_state;           ///< De status van de watchlist. Deze waarde wordt gebruikt om te alterneren tussen twee waarden (0 en 1) teneinde een telkens oplichtend icoon weergegeven kan worden in een GUI of om aan te geven dat dit niet hoeft (2).
    int              watcher_state;
    FtdGroupList    *groups;                    ///< De lijst met alle groepen die bekend zijn.
    FtdCategoryList *categories;                ///< De lijst met alle categorieen. Deze wordt gegenereerd aan de hand van de filters.
    FtdList         *mail;                      ///< De lijst met ::FtdMailBericht pointers naar alle bekende FTD-mails.
    FtdList         *tags;                      ///< De lijst met ::FtdTag pointers naar alle bekende tags. Deze zijn gesorteerd: eerst komt een ouder-tag, daarna de kinderen van  die tag, gesorteerd op tag-code. De ouders zijn onderling ook gesorteerd.
#ifdef HAVE_SQLITE
    FTDEventInfoCache *eventinfo_cache;         ///< Een cache waarin reeds opgehaalde postinfo's in opgeslagen staan en periodiek opgeschoond worden
#endif
};

extern FtdAppCore *core;        ///< De enige echte core.

void    ftd_tags_init(void);
void    ftd_tags_free(void);

gboolean    ftd_dbus_initialize(gboolean is_gui, const char *frontend_name, gboolean *is_already_active, char **errmsg);
void        ftd_dbus_cleanup(void);

gboolean    ftd_watcher_test_event(const FtdEvent *event);

#endif /* _FTD_APP_CORE_H_ */
