/* autogenerated file, DO NOT TOUCH !!! */
#ifndef GG2_CORE_H
#define GG2_CORE_H


/* $Id: ggadu_types.h,v 1.23 2005/03/02 13:36:03 krzyzak Exp $ */

/* 
 * GNU Gadu 2 
 * 
 * Copyright (C) 2001-2002 Igor Popik
 * Copyright (C) 2001-2005 GNU Gadu Team 
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * 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 
 */

/*! \file ggadu_types.h */

#ifndef GGadu_TYPES_H
#define GGadu_TYPES_H

#include <glib.h>

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

typedef gpointer(*function_ptr) (gpointer);
typedef void (*signal_func_ptr) (gpointer, gpointer);

/*! \brief Signal ID */
typedef GQuark GGaduSigID;

/*! \brief Plugin type used in GGadu_PLUGIN_INIT(x,type) 
    @see GGaduPlugin
    @see GGadu_PLUGIN_INIT
*/
typedef enum
{
    GGADU_PLUGIN_TYPE_UI = 1,   /*!< User Interface type plugin */
    GGADU_PLUGIN_TYPE_PROTOCOL, /*!< Protocol type plugin */
    GGADU_PLUGIN_TYPE_MISC,     /*!< Misc. type plugin */
    GGADU_PLUGIN_TYPE_ANY       /*!< for internal use only */
} GGaduPluginType;

/*! \brief Some kind of enum, don't know why it is here */
typedef enum
{
    GGADU_ID = 1,
    GGADU_NICK,
    GGADU_FIRST_NAME,
    GGADU_LAST_NAME,
    GGADU_MOBILE,
    GGADU_PASSWORD
} GGaduContactFieldType;

/*! \brief Type of variable
    @see GGaduKeyValue
*/
typedef enum
{
    VAR_STR = 1,		/*!< string  */
    VAR_INT,			/*!< integer */
    VAR_INT_WITH_NEGATIVE,	/*!< integer with negative values */
    VAR_BOOL,			/*!< boolean value */
    VAR_IMG,			/*!< image type */
    VAR_FILE_CHOOSER,		/*!< file chooser type */
    VAR_FONT_CHOOSER,		/*!< font chooser type */
    VAR_COLOUR_CHOOSER,		/*!< colour chooser type */
    VAR_LIST,			/*!< list type */
    VAR_NULL			/*!< null - means nothing */
} GGaduVarType;


/*! \brief Flags for GGaduKeyValue structure 
    @see GGadyKeyValue
*/
typedef enum
{
    VAR_FLAG_NONE = 1,			/*!< Empty, no flag */
    VAR_FLAG_SENSITIVE = 2,	/*!< Widget is sensitive */
    VAR_FLAG_INSENSITIVE = 4,	/*!< Widget is insensitive */
    VAR_FLAG_PASSWORD = 8,		/*!< Password type input */
    VAR_FLAG_SELECTED = 16,		/*!< Mark selected by default */
    VAR_FLAG_FOCUS = 32,		/*!< Grab focus */
    VAR_FLAG_ADVANCED = 64		/*!< Put option into advanced box */
} GGaduKeyValueFlag;

/*! common enums */
enum
{
    GGADU_NONE,
    GGADU_OK,
    GGADU_CANCEL,
    GGADU_YES,
    GGADU_NO
};

/*! \brief History entries */
typedef enum
{
    GGADU_HISTORY_TYPE_RECEIVE,	/*!< Input message */
    GGADU_HISTORY_TYPE_SEND    	/*!< Output message */
} GGaduHistoryType;


/*! \brief Root menu item 
    @see GGaduMenuItem
*/
typedef GNode GGaduMenu;

/*! \brief Menu item
    @see GGaduMenu
*/
typedef struct
{
    gchar *label;		/*!< Label for menu item */
    gpointer data;		/*!< data */
    gpointer callback;		/*!< function_ptr callback for this menu item */
} GGaduMenuItem;

/*! \brief Types of extensions 
    @see GGaduPluginExtension
*/
typedef enum
{
    GGADU_PLUGIN_EXTENSION_USER_MENU_TYPE = 1
} GGaduPluginExtensionType;


/*! \brief Plugins extensions
    @see GGaduPluginExtensionType
*/
typedef struct
{
    const gchar *txt;				/*!< extension label */
    GGaduPluginExtensionType type;		/*!< extension type  */
    gpointer(*callback) (gpointer user_data);	/*!< extension callback */
} GGaduPluginExtension;



/*
 * GGaduVar
 * Zmienne dla protokolu
 */
typedef struct
{
    gchar *name;		/* nazwa zmiennej */
    GGaduVarType type;		/* typ */
    gpointer ptr;		/* wskaznik gdzie bedzie przechowywana */
    gpointer def;		/* default value */
} GGaduVar;

/*! \brief Protocol description data
    GGaduPlugin ->plugin_data where type is  \a GGADU_PLUGIN_TYPE_PROTOCOL should point to this structure
    @see GGaduPluginType
    @see GGaduPlugin
*/
typedef struct
{
    gchar *display_name;	/*!< displayable name of protocol */
    gchar *protocol_uri; 	/*!< URI for protocols eg.: gg://  icq:// tlen://  */
    gchar *img_filename;	/*!< Path to picture with protocol label */
    GSList *statuslist;		/*!< List of available status codes */
    GSList *offline_status;	/*!< List of "offline" status codes */
    GSList *away_status;	/*!< List of "away" status codes */
    GSList *online_status;	/*!< List of "online" status codes */
} GGaduProtocol;

/*! Internal SIGNAL structure used by core */
typedef struct
{
    GGaduSigID name;		/*!< integer representation of signal name */
    gchar *source_plugin_name;	/*!< source plugin name */
    gchar *destination_plugin_name; /*!< destination plugin name */
    gpointer data;		/*!< data send with this signal */
    gpointer data_return;	/*!< data that should be returned by emit_sianal function */
    gint error;			/*!< error flag, -1 mean no error */
    gboolean free_me;		/*!< mark if signal sould be freed with given function, TRUE by default */
    void (*free) (gpointer signal); /*!< callback to function which can free data send with signal */
} GGaduSignal;

/*! GGaduSignalInfo */
typedef struct
{
    GGaduSigID name; 		/*!< integer representation of signal name */
} GGaduSignalInfo;

/*! Structure of data specific for plugins */
typedef struct
{
    GGaduPluginType type;	/*!< type of plugin */
    gchar *name;		/*!< plugin name */
    gchar *description;		/*!< descriptive text about plugin */
    gpointer plugin_data;	/*!< data specific for types of plugins, ex. protocols have GGaduProtocol* */
    void *plugin_so_handler;

    gchar *config_file;		/* plik konfiguracyjny dla tego pluginu */
    GSList *variables;		/* zmienne czytane z pliku */
    GSList *signals;		/* lista zarejestrowanych signali */

    GSList *extensions;		/* GGaduPluginExtension's */

    void (*signal_receive_func) (gpointer, gpointer);	/* wskaznik na receiver signali */
    void (*destroy_plugin) ();	/* wskaznik na zwalniacza plugina */
    void (*start_plugin) ();	/* wskaznik na funkcję startującą plugina */
} GGaduPlugin;


/*! \brief Represent data about plugin file */
typedef struct
{
    gchar *name;	/*!< plugin name */
    gchar *path;	/*!< plugin file path */
} GGaduPluginFile;

/*! \brief Global configuration data accessible from any plugin */
typedef struct
{
    gboolean send_on_enter;	/*!< shuldn't be here */
    guint main_on_start;	/*!< show main window on start ? (shouldn't be here) */
    guint width;		/*!< shuldn't be here */
    guint height;		/*!< shuldn't be here */
    gint pos_x;			/*!< shuldn't be here */
    gint pos_y;			/*!< shuldn't be here */
    gboolean all_plugins_loaded;	/*!< TRUE if all plugins are loaded */
    GSList *all_available_plugins;	/*!< All available plugins */
    GSList *loaded_plugins;		/*!< All loaded plugins */
    gchar *configdir;			/*!< Main configuration data directory reflecting HOME_ETC etc. (~/.gg2) */
    gpointer repos;			/*!< Pointer to repos */
    GMainLoop *main_loop;		/*!< GMainLoop used by GNU Gadu */
    GSList *waiting_signals;		/*!< private used by internal core */
    GSList *signal_hooks;		/*!< private used by core */
    gpointer argc;
    gpointer argv;
} GGaduConfig;

/*! \brief Main config available for any plugin */
extern GGaduConfig *config;

/*
 *  GGaduSignalHook
 */
typedef struct
{
    GGaduSigID name;
    GSList *hooks;
    void (*perl_handler) (GGaduSignal *, gchar *, void *);
} GGaduSignalHook;

/*! \brief Universal contact data structure
    if some value is NULL then GUI should ignore such entry
    @see GGaduContact_free
*/
typedef struct
{
    gchar *id;			/*!< unique id: GG number, Jabber jid, etc.. */
    gchar *first_name;		/*!< Name */
    gchar *last_name;		/*!< Surname */
    gchar *nick;		/*!< Nick */
    gchar *mobile;		/*!< Mobile */
    gchar *email;		/*!< Email */
    gchar *gender;		/*!< Gender */
    gchar *group;		/*!< Group */
    gchar *comment;		/*!< Comment */
    gchar *birthdate;		/*!< Birth Date */
    gchar *ip;			/*!< IP address "IP:PORT" */
    gchar *city;		/*!< City */
    gchar *age;			/*!< Age */
    gchar *resource;		/*!< Resource (ex. Jabber) */
    gint status;		/*!< Status code */
    gchar *status_descr;	/*!< Status Description */
} GGaduContact;

void 	      GGaduContact_free(GGaduContact * k);
GGaduContact *GGaduContact_copy(GGaduContact * k);


/*! \brief Classes of message */
typedef enum
{
    GGADU_CLASS_CHAT,
    GGADU_CLASS_MSG,
    GGADU_CLASS_CONFERENCE,
    GGADU_MSG_SEND,
    GGADU_MSG_RECV
} GGaduMessageClass;

/*! \brief some useful constants to search engine */
enum
{
    GGADU_SEARCH_FIRSTNAME,
    GGADU_SEARCH_LASTNAME,
    GGADU_SEARCH_NICKNAME,
    GGADU_SEARCH_CITY,
    GGADU_SEARCH_BIRTHYEAR,
    GGADU_SEARCH_GENDER,
    GGADU_SEARCH_ACTIVE,
    GGADU_SEARCH_ID,
    GGADU_SEARCH_EMAIL
};


/*! \brief Structure to send message */
typedef struct
{
    gchar *id;		/*!< Recipient ID */
    gchar *message;	/*!< Message in UTF-8 */
    guint time;		/*!< Time of message */
    GGaduMessageClass class;	/*!< Kind of message */
    GSList *recipients;	/*!< Holds recipients of message if GGADU_CLASS_CONFERENCE */
} GGaduMsg;

void GGaduMsg_free(gpointer msg);

/*
 *	GGaduNotify
 *	opisuje pojawienie sie kogos, lub zmiane stanu
 */
typedef struct
{
    gchar *id;
    unsigned long status;
    gchar *ip;			/* adres ip, nie musi byc ustawiony */
} GGaduNotify;

void GGaduNotify_free(GGaduNotify * n);

/*! \brief Status prototype structure
*/
typedef struct
{
    gint status;		 /*!< Status code */
    gchar *status_description;   /*!< Status description example: "I'm away from computer" */
    gchar *description;		 /*!< Status label example: "Available" */
    gchar *image;		 /*!< Image name  */
    gboolean receive_only;	 /*!< Identify if status is only received by other contacts */
} GGaduStatusPrototype;

void GGaduStatusPrototype_free(GGaduStatusPrototype * s);

/*! \brief Key<->Value pair of data 
    @see GGaduKeyValueFlag
*/
typedef struct
{
    gint key;			/*!< Key */
    gpointer value;		/*!< Value for this key */
    GGaduVarType type;		/*!< GGaduVarType      */
    guint flag;			/*!< GGaduKeyValueFlag */
    gchar *description;		/*!< Description assigned to this key */
    gpointer user_data;		/*!< User data assigned to this structure */
} GGaduKeyValue;

void GGaduKeyValue_free(GGaduKeyValue * kv);


#endif

/* $Id: ggadu_dialog.h,v 1.12 2004/12/26 22:23:16 shaster Exp $ */

/* 
 * GNU Gadu 2 
 * 
 * Copyright (C) 2001-2005 GNU Gadu Team 
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * 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 
 */

#ifndef GGadu_DIALOG_H
#define GGadu_DIALOG_H

#ifndef GG2_CORE_H 
#include "ggadu_types.h"
#endif

typedef gboolean(*watch_func) (gpointer);

typedef enum
{
	GGADU_DIALOG_GENERIC,
	GGADU_DIALOG_CONFIG,
	GGADU_DIALOG_YES_NO/*,
	GGADU_DIALOG_PROGRESS*/
} GGaduDialogType;

typedef enum
{
	GGADU_DIALOG_FLAG_NONE = 0,
	GGADU_DIALOG_FLAG_PROGRESS = 1,
	GGADU_DIALOG_FLAG_ONLY_OK = 2
} GGaduDialogFlags;

typedef struct
{
	gchar *title;
	gchar *callback_signal;
	GSList *optlist;	/* List of GGaduKeyValue's */
	gpointer user_data;
	gint type;
	guint flags; /* GGaduDialogFlags */
	
	gboolean(*watch_func) (gpointer);
	
	/* private */
	gint response;
} GGaduDialog;

#define ggadu_dialog_new(type, title, callback_signal) \
		ggadu_dialog_new_full(type, title, callback_signal, NULL)

GGaduDialog*		ggadu_dialog_new_full			(GGaduDialogType type, gchar * title, gchar * callback_signal, gpointer user_data);

void 			ggadu_dialog_add_entry			(GGaduDialog * dialog, gint key, gchar * desc, GGaduVarType var_type, gpointer value, gint flags);

GSList*			ggadu_dialog_get_entries		(GGaduDialog * dialog);

void			ggadu_dialog_set_callback_signal	(GGaduDialog * dialog, const gchar * signal);

void			ggadu_dialog_set_progress_watch		(GGaduDialog * dialog, watch_func watch);

void			ggadu_dialog_set_title			(GGaduDialog * dialog, const gchar * title);

const gchar*		ggadu_dialog_get_title			(GGaduDialog * dialog);

void			ggadu_dialog_set_type			(GGaduDialog * dialog, GGaduDialogType dialog_type);

GGaduDialogType		ggadu_dialog_get_type			(GGaduDialog * dialog);

gint 			ggadu_dialog_get_response		(GGaduDialog * dialog);

void			ggadu_dialog_set_flags			(GGaduDialog * dialog, guint flags);

guint			ggadu_dialog_get_flags			(GGaduDialog * dialog);

void			GGaduDialog_free			(GGaduDialog * dialog);

#endif

/* $Id: perl_embed.h,v 1.5 2004/12/26 22:23:16 shaster Exp $ */

/* 
 * GNU Gadu 2 
 * 
 * Copyright (C) 2001-2005 GNU Gadu Team 
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * 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 
 */

#ifndef GGadu_PERL_EMBED_H
#define GGadu_PERL_EMBED_H 1

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#ifndef PERL_EMBED
#define perl_load_script(x)	/* */
#define perl_unload_script(x)	/* */
#define perl_load_scripts() 0
#else

int perl_load_script(char *script_name);
int perl_unload_script(char *script_name);

gint perl_load_scripts(void);

#endif
#endif

/* $Id: ggadu_repo.h,v 1.4 2004/12/26 22:23:16 shaster Exp $ */

/* 
 * GNU Gadu 2 
 * 
 * Copyright (C) 2001-2005 GNU Gadu Team 
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * 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 
 */

#ifndef GGadu_REPO_H
#define GGadu_REPO_H 1

#include <glib.h>
#include <limits.h>

#ifndef GG2_CORE_H
#include "ggadu_types.h"
#endif

typedef void (*watch_ptr) (gchar *, gpointer, gint);
typedef gpointer GGaduRepoKey;

typedef struct
{
    gpointer key;
    gpointer value;
    gint type;
    GSList *watches;
} GGaduRepoValue;

typedef struct
{
    gchar *name;
    GSList *values;
    GSList *watches;
} GGaduRepo;

typedef struct
{
    gint actions;
    gint types;
    watch_ptr callback;
} GGaduRepoWatch;

gboolean ggadu_repo_check_value(gchar * repo_name, gpointer key);
gpointer ggadu_repo_find_value(gchar * repo_name, gpointer key);
gboolean ggadu_repo_exists(gchar * repo_name);

enum
{
    REPO_VALUE_DC = 0,		/* don't change */
    REPO_VALUE_CONTACT = 1,
    REPO_VALUE_SETTING = 2,
    REPO_VALUE_PROTOCOL = 4,
    REPO_VALUE_OTHER = 8,

    REPO_VALUE_ANY = INT_MAX
};

void ggadu_repo_disable_notification();
void ggadu_repo_enable_notification();

GGaduRepoKey ggadu_repo_key_from_string(gchar * key);
gboolean ggadu_repo_add(gchar * repo_name);
gboolean ggadu_repo_add_value(gchar * repo_name, gpointer key, gpointer value, gint type);
gboolean ggadu_repo_change_value(gchar * repo_name, gpointer key, gpointer value, gint type);
gboolean ggadu_repo_del_value(gchar * repo_name, gpointer key);
gboolean ggadu_repo_del(gchar * repo_name);

gpointer ggadu_repo_value_first(gchar * repo_name, gint type, gpointer * data);
gpointer ggadu_repo_value_next(gchar * repo_name, gint type, gpointer * data, gpointer index);
GSList*  ggadu_repo_get_as_slist(gchar * repo_name, gint type);

enum
{
    REPO_ACTION_NEW = 1,	/* dodanie nowego repo */
    REPO_ACTION_DEL = 2,	/* usunięcie danego repo */
    REPO_ACTION_CHANGE = 4,	/* zmiana w danym repo (wartości) */
    REPO_ACTION_VALUE_NEW = 8,	/* nowa wartość w repo */
    REPO_ACTION_VALUE_DEL = 16,	/* usunięcie wartości */
    REPO_ACTION_VALUE_CHANGE = 32	/* zmiana wartości */
};

extern const gint REPO_mask;
extern const gint REPO_value_mask;

/* Czym się różni REPO_ACTION_VALUE_* od REPO_ACTION_CHANGE?
 * Ano tym, że REPO_ACTION_CHANGE stwierdza tylko, czy coś się zmieniło w repo.
 * A to coś to dowolna wartość.
 *
 * REPO_ACTION_VALUE_* tyczy się tylko jednej, podanej wartości.
 *
 * Jeśli jeden callback obsługuje np. REPO_ACTION_VALUE_NEW
 * i REPO_ACTION_CHANGE,
 * to gdy zostanie dodana nowa wartość, to callback zostanie poinformowany
 * o REPO_ACTION_VALUE_NEW.
 *
 * Jeśli jest usuwane repo, to niezależnie od podanych masek, zawsze wysyłany
 * jest REPO_ACTION_DEL.
 *
 * Informacje o usunięciu są wysyłane przed usunięciem danych z repo, natomiast
 * inne informacje już po dodaniu/modyfikacji.
 */

/* GGaduRepo_watch_add(gchar *repo_name,gpointer key,gint actions,gpointer callback)
 *
 * repo_name - nazwa repo, w którym jest nasłuch
 * actions   - maska, określająca akcje, przy których wywoływany jest callback
 * key       - klucz, który ma być sprawdzany (jeśli w actions siedzi jedno
 *             z *_VALUE_*)
 * callback  - wskaźnik do funkcji, przyjmującej trzy argumenty:
 *             callback (gchar *repo_name, gpointer key, gint actions)
 *             actions zawiera informacje o akcji na danym repo lub key
 *
 * Kolejne wywołania GGaduRepo_watch_add z tymi samymi danymi (repo_name, key,
 * callback)
 * uaktualnia maskę akcji (dodaje brakujące elementy).
 * 
 * GGaduRepo_watch_del() usuwa podane akcje odnoszące się do danego repo
 * (repo_name), klucza
 * (key) oraz callbacku (callback). Jeśli actions jest równe actions podanym
 * funkcji
 * GGaduRepo_watch_add(), to watch jest całkowicie usuwany.
 */
gboolean ggadu_repo_watch_add(gchar * repo_name, gint actions, gint types, watch_ptr callback);
gboolean ggadu_repo_watch_del(gchar * repo_name, gint actions, gint types, watch_ptr callback);

gboolean ggadu_repo_watch_value_add(gchar * repo_name, gpointer key, gint actions, watch_ptr callback);
gboolean ggadu_repo_watch_value_del(gchar * repo_name, gpointer key, gint actions, watch_ptr callback);

gboolean ggadu_repo_watch_clear_callback(watch_ptr callback);

#endif

/* $Id: ggadu_support.h,v 1.17 2005/01/31 14:15:31 krzyzak Exp $ */

/* 
 * GNU Gadu 2 
 * 
 * Copyright (C) 2001-2005 GNU Gadu Team 
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * 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 
 */

/*! \file ggadu_support.h
    \brief Commonly used functions
*/


#ifndef GGadu_SUPPORT_H
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define GGadu_SUPPORT_H 1


#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <glib.h>
#include <time.h>
#include <stdio.h>

#ifndef GG2_CORE_H
#include "ggadu_types.h"
#endif

/*
 * Standard gettext macros.
 */
#ifdef ENABLE_NLS
#  include <libintl.h>
#  undef _
#  define _(String) dgettext (PACKAGE, String)
#  ifdef gettext_noop
#    define N_(String) gettext_noop (String)
#  else
#    define N_(String) (String)
#  endif
#else
#  define textdomain(String) (String)
#  define gettext(String) (String)
#  define dgettext(Domain,Message) (Message)
#  define dcgettext(Domain,Message,Type) (Message)
#  define bindtextdomain(Domain,Directory) (Domain)
#  define _(String) (String)
#  define N_(String) (String)
#endif

#ifndef __func__
#define __func__ __FUNCTION__
#endif

#endif /* DOXYGEN_SHOULD_SHIP_THIS */


/*! @name Conversion Macros
*/

/*! \def to_iso
    \brief Macro that convert \a text from \a from_enc encoding to ISO-8859-2 encoding
*/
#define to_iso(from_enc,text) ggadu_convert(from_enc,"ISO-8859-2",text)

/*! \def to_cp
    \brief Macro that convert \a text from \a from_enc encoding to CP-1250 encoding
*/
#define to_cp(from_enc,text) ggadu_convert(from_enc,"CP1250",text)

/*! \def to_utf8
    \brief Macro that convert \a text from \a from_enc encoding to UTF-8 encoding
*/
#define to_utf8(from_enc,text) ggadu_convert(from_enc,"UTF-8",text)

/*! \def from_utf8
    \brief Macro that convert text to to_enc from UTF-8 encoding
*/
#define from_utf8(to_enc,text) ggadu_convert("UTF-8",to_enc,text)

/*! @name Debug
*/
/*! \def print_debug
    \brief Print debug information if compiled with --enable-debug option. Usage like printf()
*/
#define print_debug(...) print_debug_raw(__func__,__VA_ARGS__)

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define ggadu_iso_in_utf_str "ĹÄĂłĹÄĹźĹşÄĹÄĹĂÄĹĹĹťĹšÄĹ"
#endif

/*! @name Array related
*/
#define array_length(arr,type) sizeof(arr) / sizeof(type)
char		**array_make(const char *string, const char *sep, int max, int trim, int quotes);
void		array_free(char **array);
/*! @name Various functions */

gint		ggadu_strcasecmp(const gchar *s1,const gchar *s2);
gint		ggadu_strcmp(const gchar *s1,const gchar *s2);
gchar		*ggadu_get_image_path(const gchar * directory, const gchar * filename);
gboolean	ggadu_is_in_status(gint status, GSList * list);

#ifndef DOXYGEN_SHOULD_SKIP_THIS
void		print_debug_raw(const gchar * func, const char *format, ...);
void		show_error(gchar * errstr);
const char	*itoa(long int i);
gchar		*get_timestamp(time_t t);
#endif

char		*base64_decode(char *);
char		*base64_encode(const char *buf);

gchar		*ggadu_strchomp(gchar * str);
gchar		*ggadu_convert(gchar * from_encoding, gchar * to_encoding, gchar * text);

gboolean	ggadu_save_history(GGaduHistoryType type, gchar *filepath, gchar *nick, GGaduMsg *msg);
gboolean	ggadu_write_line_to_file(gchar * path, gchar * line, gchar * enc);
gchar		*check_file_exists(const gchar * directory, const gchar * filename);

GGaduStatusPrototype *ggadu_find_status_prototype(GGaduProtocol * gp, gint status);

gboolean ggadu_spawn(const gchar *command, const gchar *argument_value);


/*! @name DEPRECATED */
/* DEPRECATED */
void set_userlist_status(GGaduNotify * n, gchar * status_descr, GSList * userlist);
/* DEPRECATED */
GSList *ggadu_userlist_remove_id(GSList * userlist, gchar * id);
/* DEPRECATED */
GGaduContact *ggadu_find_contact_in_userlist(GSList * list, gchar * id);

#endif

/* $Id: ggadu_menu.h,v 1.5 2004/12/26 22:23:16 shaster Exp $ */

/* 
 * GNU Gadu 2 
 * 
 * Copyright (C) 2001-2005 GNU Gadu Team 
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * 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 
 */

#ifndef GGadu_MENU_H
#define GGadu_MENU_H 1

#ifndef GG2_CORE_H
#include "ggadu_types.h"
#endif

void ggadu_menu_free(GGaduMenu * menu);

/*
 * tworzy nowe menu
 */
GGaduMenu *ggadu_menu_create();

/*
 * tworzy nowy item ktory pozniej pozna podlaczac
 */
GGaduMenu *ggadu_menu_new_item(gchar * label, function_ptr callback, gpointer data);

/* 
 * dodaje element (item) do menu, zwraca dodany item
 * zwraca GGaduMenu reprezentujace dodany item
 */
GGaduMenu *ggadu_menu_add_item(GGaduMenu * menu, gchar * label, function_ptr callback, gpointer user_data);


/*
 * dodaje submenu do menu a konkretnie do item'u
 */
void ggadu_menu_add_submenu(GGaduMenu * to_item, GGaduMenu * menu);

/*
 * zwraca submenu dla podanego menu
 */
GGaduMenu *ggadu_menu_get_submenu(GGaduMenu * menu);


/*
 * zwraca liste zawierajaca GGaduMenuItem dla jednego poziomu podanego menu
 */
GSList *ggadu_menu_get_items(GGaduMenu * menu);

/*
 * zwraca menu nadrzedne
 */
GGaduMenu *ggadu_menu_get_parent(GGaduMenu * children);


void ggadu_menu_add_user_menu_extensions(GGaduMenu * menu, GGaduPlugin *handler);

/*
 * wypisuje strukture zbudowanego drzewa, raczej przydatne tylko do debugu
 */
void ggadu_menu_print(GGaduMenu * node, gchar * p);

#endif

/* $Id: plugins.h,v 1.13 2004/12/28 17:48:04 krzyzak Exp $ */

/* 
 * GNU Gadu 2 
 * 
 * Copyright (C) 2001-2005 GNU Gadu Team 
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * 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 
 */

#ifndef GGadu_PROTOCOLS_H
#define GGadu_PROTOCOLS_H 1

#ifndef GG2_CORE_H
#include "ggadu_types.h"
#endif

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#define GGadu_CONFIG_DEFINE_PLUGIN GGaduConfig *config;

#define GGadu_PLUGIN_INIT(x,type) \
	GGadu_CONFIG_DEFINE_PLUGIN \
	guint GGADU_PLUGIN_TYPE = type; \
	gchar *ggadu_plugin_name() { return x; } \
	gint  ggadu_plugin_type() { return type; }

#define GGadu_PLUGIN_NAME ggadu_plugin_name()
#define GGadu_PLUGIN_ACTIVATE(x) config = x;

#define GGadu_MAX_PLUGIN_NAME 100

gboolean load_plugin(gchar * path);
void	 unload_plugin(gchar * name);

GGaduPlugin*		register_plugin(gchar * name, gchar * desc);
void			register_signal_receiver(GGaduPlugin * plugin_handler, void (*sgr) (gpointer, gpointer));

void			register_extension_for_plugins(GGaduPluginExtension * ext);
void			register_extension_for_plugin(GGaduPluginExtension * ext, gint plugin_type);
void			unregister_extension_for_plugins(GGaduPluginExtension * ext);
GGaduPluginExtension*	ggadu_find_extension(GGaduPlugin * handler, gint type);
gpointer		ggadu_get_extensions_list(GGaduPlugin * handler);
guint			ggadu_extension_get_type(GGaduPluginExtension *ext);

GGaduPlugin*		find_plugin_by_name(gchar * name);
GSList*			find_plugin_by_pattern(gchar * pattern);

GSList*			get_list_modules_load();

#endif

/* $Id: ggadu_conf.h,v 1.12 2004/12/26 22:23:16 shaster Exp $ */

/* 
 * GNU Gadu 2 
 * 
 * Copyright (C) 2001-2005 GNU Gadu Team 
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * 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 
 */

#ifndef GGadu_CONF_H
#define GGadu_CONF_H 1

#ifndef GG2_CORE_H
#include "ggadu_types.h"
#endif

void		ggadu_config_set_filename	(GGaduPlugin * plugin_handler, gchar *config_file);

gboolean	ggadu_config_read_from_file	(GGaduPlugin * plugin_handler, gchar *file_path);

gboolean	ggadu_config_read		(GGaduPlugin * plugin_handler);

gboolean	ggadu_config_save		(GGaduPlugin * plugin_handler);

gpointer	ggadu_config_var_get		(GGaduPlugin * handler, gchar * name);

void		ggadu_config_var_set		(GGaduPlugin * handler, gchar * name, gpointer val);

GGaduVarType	ggadu_config_var_get_type	(GGaduPlugin * handler, gchar * name);

gint		ggadu_config_var_check		(GGaduPlugin * handler, gchar * name);

void		ggadu_config_var_add		(GGaduPlugin * handler, gchar * name, gint type);

void		ggadu_config_var_add_with_default(GGaduPlugin * handler, gchar * name, gint type, gpointer default_value);

#endif

/* $Id: signals.h,v 1.12 2004/12/26 22:23:16 shaster Exp $ */

/* 
 * GNU Gadu 2 
 * 
 * Copyright (C) 2001-2005 GNU Gadu Team 
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * 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 
 */

#ifndef GGadu_SIGNALS_H
#define GGadu_SIGNALS_H 1

#ifndef GG2_CORE_H
#include "ggadu_types.h"
#endif

/* DEPRECATED */
#define signal_emit(src_name,name,data,dest_data) \
    signal_emit_full(src_name,name,data,dest_data,NULL)

#define signal_emit_from_thread(src_name,name,data,dest_data) \
    signal_emit_from_thread_full(src_name,name,data,dest_data,NULL)

GGaduSignalInfo *find_signal(gpointer signal_name);

void *signal_emit_full(gpointer src_name, gpointer name, gpointer data, gpointer dest_name, void (*signal_free) (gpointer));

GGaduSigID register_signal(GGaduPlugin * plugin_handler, gpointer name);

void register_signal_perl(gchar * name, void (*perl_handler) (GGaduSignal *, gchar *, void *));

void hook_signal(GGaduSigID q_name, void (*hook) (GGaduSignal * signal, void (*perl_handler) (GGaduSignal *, gchar *, void *)));

void flush_queued_signals();

GGaduSignal *signal_cpy(GGaduSignal * sig);

void GGaduSignal_free(GGaduSignal * sig);

gboolean signal_from_thread_enabled();

void signal_emit_from_thread_full(gpointer src_name, gpointer name, gpointer data, gpointer dest_name, void (*signal_free) (gpointer));

#endif

#endif
