From 4c97ee7ab1c5a56860b2d267d68541c48e1b206e Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sat, 7 Aug 2010 00:29:27 +0000 Subject: [PATCH] Added a plug-in to allow blacklisting of certain numbers --- src/plugins/Makefile | 21 ++++++++-- src/plugins/blacklist.c | 82 ++++++++++++++++++++++++++++++++++++++++ src/plugins/project.conf | 14 +++++-- 3 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 src/plugins/blacklist.c diff --git a/src/plugins/Makefile b/src/plugins/Makefile index 1d30e12..c92863c 100644 --- a/src/plugins/Makefile +++ b/src/plugins/Makefile @@ -1,12 +1,12 @@ -TARGETS = engineering.so openmoko.so panel.so profiles.so smscrypt.so +TARGETS = blacklist.so engineering.so openmoko.so panel.so profiles.so smscrypt.so PREFIX = /usr/local DESTDIR = LIBDIR = $(PREFIX)/lib CC = cc CPPFLAGSF= -I ../../include CPPFLAGS= -I $(PREFIX)/include -CFLAGSF = -W -CFLAGS = -Wall -g -O2 -pedantic -fPIC `pkg-config --cflags gtk+-2.0` +CFLAGSF = -W `pkg-config --cflags gtk+-2.0` +CFLAGS = -Wall -g -O2 -pedantic -fPIC AR = ar -rc RANLIB = ranlib LD = $(CC) -shared @@ -18,6 +18,13 @@ INSTALL = install all: $(TARGETS) +blacklist_OBJS = blacklist.o +blacklist_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) +blacklist_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) + +blacklist.so: $(blacklist_OBJS) + $(LD) -o blacklist.so $(blacklist_OBJS) + engineering_OBJS = engineering.o engineering_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) engineering_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) @@ -53,6 +60,9 @@ smscrypt_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) smscrypt.so: $(smscrypt_OBJS) $(LD) -o smscrypt.so $(smscrypt_OBJS) +blacklist.o: blacklist.c ../../include/Phone.h + $(CC) $(blacklist_CFLAGS) -c blacklist.c + engineering.o: engineering.c ../../include/Phone.h $(CC) $(engineering_CFLAGS) -c engineering.c @@ -69,12 +79,14 @@ smscrypt.o: smscrypt.c ../../include/Phone.h $(CC) $(smscrypt_CFLAGS) -c smscrypt.c clean: - $(RM) -- $(engineering_OBJS) $(openmoko_OBJS) $(panel_OBJS) $(profiles_OBJS) $(smscrypt_OBJS) + $(RM) -- $(blacklist_OBJS) $(engineering_OBJS) $(openmoko_OBJS) $(panel_OBJS) $(profiles_OBJS) $(smscrypt_OBJS) distclean: clean $(RM) -- $(TARGETS) install: all + $(MKDIR) $(DESTDIR)$(LIBDIR)/Phone/plugins + $(INSTALL) -m 0644 -- blacklist.so $(DESTDIR)$(LIBDIR)/Phone/plugins/blacklist.so $(MKDIR) $(DESTDIR)$(LIBDIR)/Phone/plugins $(INSTALL) -m 0644 -- engineering.so $(DESTDIR)$(LIBDIR)/Phone/plugins/engineering.so $(MKDIR) $(DESTDIR)$(LIBDIR)/Phone/plugins @@ -87,6 +99,7 @@ install: all $(INSTALL) -m 0644 -- smscrypt.so $(DESTDIR)$(LIBDIR)/Phone/plugins/smscrypt.so uninstall: + $(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/blacklist.so $(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/engineering.so $(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/openmoko.so $(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/panel.so diff --git a/src/plugins/blacklist.c b/src/plugins/blacklist.c new file mode 100644 index 0000000..039e451 --- /dev/null +++ b/src/plugins/blacklist.c @@ -0,0 +1,82 @@ +/* $Id$ */ +/* Copyright (c) 2010 Pierre Pronchery */ +/* 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 . */ + + + +#include +#include +#include +#include +#include +#include +#include "Phone.h" + + +/* Blacklist */ +/* private */ +/* prototypes */ +static int _blacklist_event(PhonePlugin * plugin, PhoneEvent event, ...); +static void _blacklist_settings(PhonePlugin * plugin); + + +/* public */ +/* variables */ +PhonePlugin plugin = +{ + NULL, + "Blacklist", + NULL, + NULL, + NULL, + _blacklist_event, + _blacklist_settings, + NULL +}; + + +/* private */ +/* functions */ +/* blacklist_event */ +static int _blacklist_event(PhonePlugin * plugin, PhoneEvent event, ...) +{ + va_list ap; + char const * number = NULL; + char const * reason; + + va_start(ap, event); + switch(event) + { + case PHONE_EVENT_CALLING: + number = va_arg(ap, char const *); + break; + default: + break; + } + va_end(ap); + if(number == NULL) + return 0; + reason = plugin->helper->config_get(plugin->helper->phone, "blacklist", + number); + if(reason == NULL) + return 0; + return plugin->helper->error(plugin->helper->phone, reason, 1); +} + + +/* blacklist_settings */ +static void _blacklist_settings(PhonePlugin * plugin) +{ + /* FIXME implement */ +} diff --git a/src/plugins/project.conf b/src/plugins/project.conf index 5a30245..536d904 100644 --- a/src/plugins/project.conf +++ b/src/plugins/project.conf @@ -1,10 +1,18 @@ -targets=engineering,openmoko,panel,profiles,smscrypt +targets=blacklist,engineering,openmoko,panel,profiles,smscrypt cppflags_force=-I ../../include cppflags=-I $(PREFIX)/include -cflags_force=-W -cflags=-Wall -g -O2 -pedantic -fPIC `pkg-config --cflags gtk+-2.0` +cflags_force=-W `pkg-config --cflags gtk+-2.0` +cflags=-Wall -g -O2 -pedantic -fPIC dist=Makefile +[blacklist] +type=plugin +sources=blacklist.c +install=$(LIBDIR)/Phone/plugins + +[blacklist.c] +depends=../../include/Phone.h + [engineering] type=plugin sources=engineering.c