Added a plug-in to allow blacklisting of certain numbers

This commit is contained in:
Pierre Pronchery 2010-08-07 00:29:27 +00:00
parent 0563b798aa
commit 4c97ee7ab1
3 changed files with 110 additions and 7 deletions

View File

@ -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 PREFIX = /usr/local
DESTDIR = DESTDIR =
LIBDIR = $(PREFIX)/lib LIBDIR = $(PREFIX)/lib
CC = cc CC = cc
CPPFLAGSF= -I ../../include CPPFLAGSF= -I ../../include
CPPFLAGS= -I $(PREFIX)/include CPPFLAGS= -I $(PREFIX)/include
CFLAGSF = -W CFLAGSF = -W `pkg-config --cflags gtk+-2.0`
CFLAGS = -Wall -g -O2 -pedantic -fPIC `pkg-config --cflags gtk+-2.0` CFLAGS = -Wall -g -O2 -pedantic -fPIC
AR = ar -rc AR = ar -rc
RANLIB = ranlib RANLIB = ranlib
LD = $(CC) -shared LD = $(CC) -shared
@ -18,6 +18,13 @@ INSTALL = install
all: $(TARGETS) 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_OBJS = engineering.o
engineering_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) engineering_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
engineering_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) engineering_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
@ -53,6 +60,9 @@ smscrypt_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
smscrypt.so: $(smscrypt_OBJS) smscrypt.so: $(smscrypt_OBJS)
$(LD) -o 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 engineering.o: engineering.c ../../include/Phone.h
$(CC) $(engineering_CFLAGS) -c engineering.c $(CC) $(engineering_CFLAGS) -c engineering.c
@ -69,12 +79,14 @@ smscrypt.o: smscrypt.c ../../include/Phone.h
$(CC) $(smscrypt_CFLAGS) -c smscrypt.c $(CC) $(smscrypt_CFLAGS) -c smscrypt.c
clean: 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 distclean: clean
$(RM) -- $(TARGETS) $(RM) -- $(TARGETS)
install: all install: all
$(MKDIR) $(DESTDIR)$(LIBDIR)/Phone/plugins
$(INSTALL) -m 0644 -- blacklist.so $(DESTDIR)$(LIBDIR)/Phone/plugins/blacklist.so
$(MKDIR) $(DESTDIR)$(LIBDIR)/Phone/plugins $(MKDIR) $(DESTDIR)$(LIBDIR)/Phone/plugins
$(INSTALL) -m 0644 -- engineering.so $(DESTDIR)$(LIBDIR)/Phone/plugins/engineering.so $(INSTALL) -m 0644 -- engineering.so $(DESTDIR)$(LIBDIR)/Phone/plugins/engineering.so
$(MKDIR) $(DESTDIR)$(LIBDIR)/Phone/plugins $(MKDIR) $(DESTDIR)$(LIBDIR)/Phone/plugins
@ -87,6 +99,7 @@ install: all
$(INSTALL) -m 0644 -- smscrypt.so $(DESTDIR)$(LIBDIR)/Phone/plugins/smscrypt.so $(INSTALL) -m 0644 -- smscrypt.so $(DESTDIR)$(LIBDIR)/Phone/plugins/smscrypt.so
uninstall: uninstall:
$(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/blacklist.so
$(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/engineering.so $(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/engineering.so
$(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/openmoko.so $(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/openmoko.so
$(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/panel.so $(RM) -- $(DESTDIR)$(LIBDIR)/Phone/plugins/panel.so

82
src/plugins/blacklist.c Normal file
View File

@ -0,0 +1,82 @@
/* $Id$ */
/* Copyright (c) 2010 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/>. */
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <System.h>
#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 */
}

View File

@ -1,10 +1,18 @@
targets=engineering,openmoko,panel,profiles,smscrypt targets=blacklist,engineering,openmoko,panel,profiles,smscrypt
cppflags_force=-I ../../include cppflags_force=-I ../../include
cppflags=-I $(PREFIX)/include cppflags=-I $(PREFIX)/include
cflags_force=-W cflags_force=-W `pkg-config --cflags gtk+-2.0`
cflags=-Wall -g -O2 -pedantic -fPIC `pkg-config --cflags gtk+-2.0` cflags=-Wall -g -O2 -pedantic -fPIC
dist=Makefile dist=Makefile
[blacklist]
type=plugin
sources=blacklist.c
install=$(LIBDIR)/Phone/plugins
[blacklist.c]
depends=../../include/Phone.h
[engineering] [engineering]
type=plugin type=plugin
sources=engineering.c sources=engineering.c