2008-12-27 01:07:07 +00:00
|
|
|
/* (C) 2008 by Jan Luebbe <jluebbe@debian.org>
|
2009-01-01 18:02:05 +00:00
|
|
|
* (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
|
2022-05-14 13:35:49 +00:00
|
|
|
* (C) 2022 by Harald Welte <laforge@osmocom.org>
|
2008-12-27 01:07:07 +00:00
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2008-12-27 01:07:07 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2008-12-27 01:07:07 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-12-27 01:07:07 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _DB_H
|
|
|
|
#define _DB_H
|
|
|
|
|
2016-06-30 08:25:49 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2011-04-12 19:33:35 +00:00
|
|
|
#include "gsm_subscriber.h"
|
2008-12-27 01:07:07 +00:00
|
|
|
|
2019-02-19 01:36:35 +00:00
|
|
|
#define VSUB_USE_SMS_RECEIVER "SMS-receiver"
|
|
|
|
|
2010-12-22 17:21:14 +00:00
|
|
|
struct gsm_network;
|
|
|
|
struct gsm_sms;
|
|
|
|
|
2009-01-01 18:02:05 +00:00
|
|
|
/* one time initialisation */
|
2022-05-14 13:35:49 +00:00
|
|
|
int db_init(void *ctx, const char *fname, bool enable_sqlite_logging);
|
2011-07-16 11:24:09 +00:00
|
|
|
int db_prepare(void);
|
|
|
|
int db_fini(void);
|
2008-12-27 01:07:07 +00:00
|
|
|
|
2009-03-30 20:56:32 +00:00
|
|
|
/* SMS store-and-forward */
|
|
|
|
int db_sms_store(struct gsm_sms *sms);
|
2010-12-24 22:18:31 +00:00
|
|
|
struct gsm_sms *db_sms_get(struct gsm_network *net, unsigned long long id);
|
2016-06-19 16:06:02 +00:00
|
|
|
struct gsm_sms *db_sms_get_next_unsent(struct gsm_network *net,
|
|
|
|
unsigned long long min_sms_id,
|
2022-05-14 13:35:49 +00:00
|
|
|
int max_failed);
|
2016-06-19 16:06:02 +00:00
|
|
|
struct gsm_sms *db_sms_get_next_unsent_rr_msisdn(struct gsm_network *net,
|
|
|
|
const char *last_msisdn,
|
2022-05-14 13:35:49 +00:00
|
|
|
int max_failed);
|
2016-06-19 16:06:02 +00:00
|
|
|
struct gsm_sms *db_sms_get_unsent_for_subscr(struct vlr_subscr *vsub,
|
2022-05-14 13:35:49 +00:00
|
|
|
int max_failed);
|
2014-03-08 20:27:37 +00:00
|
|
|
int db_sms_mark_delivered(struct gsm_sms *sms);
|
2010-09-16 16:35:46 +00:00
|
|
|
int db_sms_inc_deliver_attempts(struct gsm_sms *sms);
|
2016-06-19 16:06:02 +00:00
|
|
|
int db_sms_delete_by_msisdn(const char *msisdn);
|
2018-01-18 17:55:26 +00:00
|
|
|
int db_sms_delete_sent_message_by_id(unsigned long long sms_id);
|
2018-01-22 16:05:37 +00:00
|
|
|
int db_sms_delete_expired_message_by_id(unsigned long long sms_id);
|
2018-01-22 16:31:20 +00:00
|
|
|
void db_sms_delete_oldest_expired_message(void);
|
2009-12-22 18:07:32 +00:00
|
|
|
|
2008-12-27 01:07:07 +00:00
|
|
|
#endif /* _DB_H */
|