/* $Id: plugin.h,v 1.1.2.2 2011/01/15 13:29:41 khorben Exp $ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Phone */
/* 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, version 3 of the License.
 *
 * 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, see <http://www.gnu.org/licenses/>. */



#ifndef DESKTOP_PHONE_PLUGIN_H
# define DESKTOP_PHONE_PLUGIN_H


/* PhonePlugin */
/* types */
typedef struct _PhonePlugin PhonePlugin;

typedef int (PhoneTriggerCallback)(PhonePlugin * plugin, char const * result);
typedef void (PhoneConfigForeachCallback)(char const * variable,
		char const * value, void * priv);

typedef struct _PhonePluginHelper
{
	Phone * phone;
	void (*config_foreach)(Phone * phone, char const * section,
			PhoneConfigForeachCallback callback, void * priv);
	char const * (*config_get)(Phone * phone, char const * section,
			char const * variable);
	int (*config_set)(Phone * phone, char const * section,
			char const * variable, char const * value);
	int (*error)(Phone * phone, char const * message, int ret);
	int (*event)(Phone * phone, PhoneEvent * event, ...);
	int (*queue)(Phone * phone, char const * command);
	int (*register_trigger)(Phone * phone, PhonePlugin * plugin,
			char const * trigger, PhoneTriggerCallback callback);
} PhonePluginHelper;

struct _PhonePlugin
{
	PhonePluginHelper * helper;
	char const * name;
	char const * icon;
	int (*init)(PhonePlugin * plugin);
	int (*destroy)(PhonePlugin * plugin);
	int (*event)(PhonePlugin * plugin, PhoneEvent * event, ...);
	void (*settings)(PhonePlugin * plugin);
	void * priv;
};

#endif /* !DESKTOP_PHONE_PLUGIN_H */