Jan Luebbe | faaa49c | 2008-12-27 01:07:07 +0000 | [diff] [blame] | 1 | /* (C) 2008 by Jan Luebbe <jluebbe@debian.org> |
Holger Freyther | 12aa50d | 2009-01-01 18:02:05 +0000 | [diff] [blame] | 2 | * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org> |
Jan Luebbe | faaa49c | 2008-12-27 01:07:07 +0000 | [diff] [blame] | 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 6 | * it under the terms of the GNU Affero General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
Jan Luebbe | faaa49c | 2008-12-27 01:07:07 +0000 | [diff] [blame] | 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 13 | * GNU Affero General Public License for more details. |
Jan Luebbe | faaa49c | 2008-12-27 01:07:07 +0000 | [diff] [blame] | 14 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 15 | * You should have received a copy of the GNU Affero General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Jan Luebbe | faaa49c | 2008-12-27 01:07:07 +0000 | [diff] [blame] | 17 | * |
| 18 | */ |
| 19 | |
| 20 | #ifndef _DB_H |
| 21 | #define _DB_H |
| 22 | |
Max | e6052c4 | 2016-06-30 10:25:49 +0200 | [diff] [blame] | 23 | #include <stdbool.h> |
| 24 | |
Holger Hans Peter Freyther | 81863cd | 2011-04-12 21:33:35 +0200 | [diff] [blame] | 25 | #include "gsm_subscriber.h" |
Jan Luebbe | faaa49c | 2008-12-27 01:07:07 +0000 | [diff] [blame] | 26 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 27 | #define VSUB_USE_SMS_RECEIVER "SMS-receiver" |
| 28 | |
Holger Hans Peter Freyther | 28dcbc5 | 2010-12-22 18:21:14 +0100 | [diff] [blame] | 29 | struct gsm_network; |
Holger Hans Peter Freyther | 28dcbc5 | 2010-12-22 18:21:14 +0100 | [diff] [blame] | 30 | struct gsm_sms; |
Holger Hans Peter Freyther | 28dcbc5 | 2010-12-22 18:21:14 +0100 | [diff] [blame] | 31 | |
Holger Freyther | 12aa50d | 2009-01-01 18:02:05 +0000 | [diff] [blame] | 32 | /* one time initialisation */ |
Holger Freyther | c7b86f9 | 2009-06-06 13:54:20 +0000 | [diff] [blame] | 33 | int db_init(const char *name); |
Harald Welte | d1476bc | 2011-07-16 13:24:09 +0200 | [diff] [blame] | 34 | int db_prepare(void); |
| 35 | int db_fini(void); |
Jan Luebbe | faaa49c | 2008-12-27 01:07:07 +0000 | [diff] [blame] | 36 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 37 | /* SMS store-and-forward */ |
| 38 | int db_sms_store(struct gsm_sms *sms); |
Holger Hans Peter Freyther | 812dad0 | 2010-12-24 23:18:31 +0100 | [diff] [blame] | 39 | struct gsm_sms *db_sms_get(struct gsm_network *net, unsigned long long id); |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 40 | struct gsm_sms *db_sms_get_next_unsent(struct gsm_network *net, |
| 41 | unsigned long long min_sms_id, |
| 42 | unsigned int max_failed); |
| 43 | struct gsm_sms *db_sms_get_next_unsent_rr_msisdn(struct gsm_network *net, |
| 44 | const char *last_msisdn, |
| 45 | unsigned int max_failed); |
| 46 | struct gsm_sms *db_sms_get_unsent_for_subscr(struct vlr_subscr *vsub, |
| 47 | unsigned int max_failed); |
Alexander Chemeris | 1e77e3d | 2014-03-08 21:27:37 +0100 | [diff] [blame] | 48 | int db_sms_mark_delivered(struct gsm_sms *sms); |
Holger Hans Peter Freyther | 212e105 | 2010-09-17 00:35:46 +0800 | [diff] [blame] | 49 | int db_sms_inc_deliver_attempts(struct gsm_sms *sms); |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 50 | int db_sms_delete_by_msisdn(const char *msisdn); |
Stefan Sperling | 6ba2d5a | 2018-01-18 18:55:26 +0100 | [diff] [blame] | 51 | int db_sms_delete_sent_message_by_id(unsigned long long sms_id); |
Stefan Sperling | 87cba1f | 2018-01-22 17:05:37 +0100 | [diff] [blame] | 52 | int db_sms_delete_expired_message_by_id(unsigned long long sms_id); |
Stefan Sperling | 14e0517 | 2018-01-22 17:31:20 +0100 | [diff] [blame] | 53 | void db_sms_delete_oldest_expired_message(void); |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 54 | |
Jan Luebbe | faaa49c | 2008-12-27 01:07:07 +0000 | [diff] [blame] | 55 | #endif /* _DB_H */ |