<commit_before>/* $Id$ */
/* Copyright (c) 2011 <NAME> <<EMAIL>> */
/* 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/>. */



#include <System.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <gtk/gtk.h>
#include "Phone.h"


/* Blacklist */
/* private */
/* types */
typedef struct _Blacklist
{
	GtkWidget * window;
	GtkListStore * store;
	GtkWidget * view;
} Blacklist;


/* prototypes */
static int _blacklist_init(PhonePlugin * plugin);
static void _blacklist_destroy(PhonePlugin * plugin);
static int _blacklist_event(PhonePlugin * plugin, PhoneEvent * event);
static void _blacklist_settings(PhonePlugin * plugin);


/* public */
/* variables */
PhonePlugin plugin =
{
	NULL,
	"Blacklist",
	"network-error",
	_blacklist_init,
	_blacklist_destroy,
	_blacklist_event,
	_blacklist_settings,
	NULL
};


/* private */
/* functions */
/* blacklist_init */
static void _init_foreach(char const * variable, char const * value,
		void * priv);

static int _blacklist_init(PhonePlugin * plugin)
{
	Blacklist * blacklist;

	if((blacklist = object_new(sizeof(*blacklist))) == NULL)
		return 1;
	plugin->priv = blacklist;
	blacklist->window = NULL;
	blacklist->store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
	plugin->helper->config_foreach(plugin->helper->phone, "blacklist",
			_init_foreach, blacklist);
	return 0;
}

static void _init_foreach(char const * variable, char const * value,
		void * priv)
{
	Blacklist * blacklist = priv;
	GtkTreeIter iter;

	gtk_list_store_append(blacklist->store, &iter);
	gtk_list_store_set(blacklist->store, &iter, 0, variable, 1, value, -1);
}


/* blacklist_destroy */
static void _blacklist_destroy(PhonePlugin * plugin)
{
	Blacklist * blacklist = plugin->priv;

	if(blacklist->window != NULL)
		gtk_widget_destroy(blacklist->window);
	object_delete(blacklist);
}


/* blacklist_event */
static int _blacklist_event(PhonePlugin * plugin, PhoneEvent * event)
{
	char const * number = NULL;
	char const * reason;

	switch(event->type)
	{
		case PHONE_EVENT_TYPE_MODEM_EVENT:
			if(event->modem_event.type != MODEM_EVENT_TYPE_CALL)
				break; /* FIXME many more events to handle */
			number = event->modem_event.event->call.number;<commit_msg>Fixed event handling<commit_after>/* $Id$ */
/* Copyright (c) 2011 <NAME> <<EMAIL>> */
/* 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/>. */



#include <System.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <gtk/gtk.h>
#include "Phone.h"


/* Blacklist */
/* private */
/* types */
typedef struct _Blacklist
{
	GtkWidget * window;
	GtkListStore * store;
	GtkWidget * view;
} Blacklist;


/* prototypes */
static int _blacklist_init(PhonePlugin * plugin);
static void _blacklist_destroy(PhonePlugin * plugin);
static int _blacklist_event(PhonePlugin * plugin, PhoneEvent * event);
static void _blacklist_settings(PhonePlugin * plugin);


/* public */
/* variables */
PhonePlugin plugin =
{
	NULL,
	"Blacklist",
	"network-error",
	_blacklist_init,
	_blacklist_destroy,
	_blacklist_event,
	_blacklist_settings,
	NULL
};


/* private */
/* functions */
/* blacklist_init */
static void _init_foreach(char const * variable, char const * value,
		void * priv);

static int _blacklist_init(PhonePlugin * plugin)
{
	Blacklist * blacklist;

	if((blacklist = object_new(sizeof(*blacklist))) == NULL)
		return 1;
	plugin->priv = blacklist;
	blacklist->window = NULL;
	blacklist->store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
	plugin->helper->config_foreach(plugin->helper->phone, "blacklist",
			_init_foreach, blacklist);
	return 0;
}

static void _init_foreach(char const * variable, char const * value,
		void * priv)
{
	Blacklist * blacklist = priv;
	GtkTreeIter iter;

	gtk_list_store_append(blacklist->store, &iter);
	gtk_list_store_set(blacklist->store, &iter, 0, variable, 1, value, -1);
}


/* blacklist_destroy */
static void _blacklist_destroy(PhonePlugin * plugin)
{
	Blacklist * blacklist = plugin->priv;

	if(blacklist->window != NULL)
		gtk_widget_destroy(blacklist->window);
	object_delete(blacklist);
}


/* blacklist_event */
static int _blacklist_event(PhonePlugin * plugin, PhoneEvent * event)
{
	char const * number = NULL;
	char const * reason;

	switch(event->type)
	{
		case PHONE_EVENT_TYPE_MODEM_EVENT:
			if(event->modem_event.event->type
					!= MODEM_EVENT_TYPE_CALL)
				break; /* FIXME many more events to handle */
			number = event->modem_event.event->call.number;
{'fraction_non_alphanumeric': 0.11630802062955718, 'fraction_numerical': 0.003912502223012627, 'mean_word_length': 4.486829268292683, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4518521', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1767, 'n_words': 529}