Skip to content

Commit

Permalink
[ofono] Added voicecall-filter. JB#41404
Browse files Browse the repository at this point in the history
  • Loading branch information
monich committed Jun 27, 2018
1 parent 4cc71c7 commit fa80022
Show file tree
Hide file tree
Showing 7 changed files with 1,889 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ofono/.gitignore
Expand Up @@ -32,6 +32,8 @@ src/ofono.service
dundee/dundee
dundee/dundee.service

test-driver
test-suite.log
unit/test-common
unit/test-util
unit/test-idmap
Expand All @@ -57,6 +59,7 @@ unit/test-sailfish_sim_info
unit/test-sailfish_sim_info_dbus
unit/test-sailfish_watch
unit/test-sms-filter
unit/test-voicecall-filter
unit/test-*.log
unit/test-*.trs

Expand Down
10 changes: 10 additions & 0 deletions ofono/Makefile.am
Expand Up @@ -24,6 +24,7 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
include/sim-mnclength.h \
include/handsfree-audio.h include/siri.h \
include/sms-filter.h include/gprs-filter.h \
include/voicecall-filter.h \
include/netmon.h include/lte.h \
include/storage.h \
gdbus/gdbus.h
Expand Down Expand Up @@ -737,6 +738,7 @@ src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
src/handsfree-audio.c src/bluetooth.h \
src/sim-mnclength.c src/voicecallagent.c \
src/sms-filter.c src/gprs-filter.c src/dbus-queue.c \
src/voicecall-filter.c \
src/hfp.h src/siri.c \
src/netmon.c src/lte.c \
src/netmonagent.c src/netmonagent.h
Expand Down Expand Up @@ -1108,6 +1110,14 @@ unit_test_gprs_filter_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_gprs_filter_OBJECTS)
unit_tests += unit/test-gprs-filter

unit_test_voicecall_filter_SOURCES = unit/test-voicecall-filter.c \
src/voicecall-filter.c src/log.c \
src/common.c src/util.c
unit_test_voicecall_filter_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_voicecall_filter_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_voicecall_filter_OBJECTS)
unit_tests += unit/test-voicecall-filter

test_rilmodem_sources = $(gril_sources) src/log.c src/common.c src/util.c \
gatchat/ringbuffer.h gatchat/ringbuffer.c \
unit/rilmodem-test-server.h \
Expand Down
127 changes: 127 additions & 0 deletions ofono/include/voicecall-filter.h
@@ -0,0 +1,127 @@
/*
* oFono - Open Source Telephony
*
* Copyright (C) 2018 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*/

#ifndef __OFONO_VOICECALL_FILTER_H
#define __OFONO_VOICECALL_FILTER_H

#ifdef __cplusplus
extern "C" {
#endif

#include <ofono/voicecall.h>

/* 27.007 Section 7.6 */
enum ofono_clip_validity {
OFONO_CLIP_VALIDITY_VALID = 0,
OFONO_CLIP_VALIDITY_WITHHELD,
OFONO_CLIP_VALIDITY_NOT_AVAILABLE
};

/* 27.007 Section 7.18 */
enum ofono_call_status {
OFONO_CALL_STATUS_ACTIVE = 0,
OFONO_CALL_STATUS_HELD,
OFONO_CALL_STATUS_DIALING,
OFONO_CALL_STATUS_ALERTING,
OFONO_CALL_STATUS_INCOMING,
OFONO_CALL_STATUS_WAITING,
OFONO_CALL_STATUS_DISCONNECTED
};

/* 27.007 Section 7.18 */
enum ofono_call_direction {
OFONO_CALL_DIRECTION_MOBILE_ORIGINATED = 0,
OFONO_CALL_DIRECTION_MOBILE_TERMINATED
};

/* 27.007 Section 7.30 */
enum ofono_cnap_validity {
OFONO_CNAP_VALIDITY_VALID = 0,
OFONO_CNAP_VALIDITY_WITHHELD,
OFONO_CNAP_VALIDITY_NOT_AVAILABLE
};

enum ofono_voicecall_filter_dial_result {
OFONO_VOICECALL_FILTER_DIAL_CONTINUE, /* Run the next filter */
OFONO_VOICECALL_FILTER_DIAL_BLOCK /* Don't dial*/
};

enum ofono_voicecall_filter_incoming_result {
OFONO_VOICECALL_FILTER_INCOMING_CONTINUE, /* Run the next filter */
OFONO_VOICECALL_FILTER_INCOMING_HANGUP, /* Hangup incoming call */
OFONO_VOICECALL_FILTER_INCOMING_IGNORE /* Ignore incoming call */
};

typedef void (*ofono_voicecall_filter_dial_cb_t)
(enum ofono_voicecall_filter_dial_result result,
void *data);

typedef void (*ofono_voicecall_filter_incoming_cb_t)
(enum ofono_voicecall_filter_incoming_result result,
void *data);

#define OFONO_VOICECALL_FILTER_PRIORITY_LOW (-100)
#define OFONO_VOICECALL_FILTER_PRIORITY_DEFAULT (0)
#define OFONO_VOICECALL_FILTER_PRIORITY_HIGH (100)

/*
* The api_version field makes it possible to keep using old plugins
* even if struct ofono_voicecall_filter gets extended with new callbacks.
*/

#define OFONO_VOICECALL_FILTER_API_VERSION (0)

/*
* The filter callbacks either invoke the completion callback directly
* or return the id of the cancellable asynchronous operation (but never
* both). If non-zero value is returned, the completion callback has to
* be invoked later on a fresh stack. Once the asynchronous filtering
* operation is cancelled, the associated completion callback must not
* be invoked.
*
* Please avoid making blocking D-Bus calls from the filter callbacks.
*/
struct ofono_voicecall_filter {
const char *name;
int api_version; /* OFONO_VOICECALL_FILTER_API_VERSION */
int priority;
void (*filter_cancel)(unsigned int id);
unsigned int (*filter_dial)(struct ofono_voicecall *vc,
const struct ofono_phone_number *number,
enum ofono_clir_option clir,
ofono_voicecall_filter_dial_cb_t cb,
void *data);
unsigned int (*filter_incoming)(struct ofono_voicecall *vc,
const struct ofono_call *call,
ofono_voicecall_filter_incoming_cb_t cb,
void *data);
};

int ofono_voicecall_filter_register(const struct ofono_voicecall_filter *f);
void ofono_voicecall_filter_unregister(const struct ofono_voicecall_filter *f);

#ifdef __cplusplus
}
#endif

#endif /* __OFONO_VOICECALL_FILTER_H */

/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/
21 changes: 21 additions & 0 deletions ofono/src/ofono.h
Expand Up @@ -610,6 +610,27 @@ void __ofono_gprs_filter_chain_check(struct gprs_filter_chain *chain,
gprs_filter_check_cb_t cb, ofono_destroy_func destroy,
void *user_data);

#include <ofono/voicecall-filter.h>

struct voicecall_filter_chain;

struct voicecall_filter_chain *__ofono_voicecall_filter_chain_new
(struct ofono_voicecall *vc);
void __ofono_voicecall_filter_chain_cancel(struct voicecall_filter_chain *c,
const struct ofono_call *call);
void __ofono_voicecall_filter_chain_restart(struct voicecall_filter_chain *c,
const struct ofono_call *call);
void __ofono_voicecall_filter_chain_free(struct voicecall_filter_chain *c);
void __ofono_voicecall_filter_chain_dial(struct voicecall_filter_chain *c,
const struct ofono_phone_number *number,
enum ofono_clir_option clir,
ofono_voicecall_filter_dial_cb_t cb,
ofono_destroy_func destroy, void *user_data);
void __ofono_voicecall_filter_chain_incoming(struct voicecall_filter_chain *c,
const struct ofono_call *call,
ofono_voicecall_filter_incoming_cb_t cb,
ofono_destroy_func destroy, void *user_data);

#include <ofono/sim-mnclength.h>

int __ofono_sim_mnclength_get_mnclength(const char *imsi);
Expand Down

0 comments on commit fa80022

Please sign in to comment.