gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Adding time window to SMSD


From: Martin White
Subject: Adding time window to SMSD
Date: Sat, 12 Mar 2005 13:58:19 -0000

I recently setup gnokii and smsd here and it all works very well.

I've had a quick skim of the archives for this mailing list and can't see
any mention of this subject before, so here goes.

I'm using smsd here for two things:

1) Alert me when something breaks on one of the systems here.
2) Send alerts to users when they have new email waiting to be read.

Now for option 1) the SMS needs to be delivered immediately. But for option
2) the user may not want to be woken up in the middle of the night just to
be told about a new email. I've added a time window for messages that can be
set when the SMS is generated, if it's outside that time window the message
will not be sent until the window is next open.

I've added two columns to the outbox table, both time fields, called
not_before and not_after. The field 'not_before' defaults to '00:00:00' and
'not_after' to '23:59:59' if not specified when a record is inserted.

In addition, a simple change has been made to mysql.c to accommodate the new
fields, see below:

hathor:/usr/local/src/gnokii-0.6.4/smsd # diff -c mysql.c.original mysql.c
*** mysql.c.original    Sun Oct 17 20:44:20 2004
--- mysql.c     Sat Mar 12 11:38:47 2005
***************
*** 149,155 ****
    buf = g_string_sized_new (128);

    g_string_sprintf (buf, "SELECT id, number, text, dreport FROM outbox \
!                           WHERE processed='0' %s", phnStr->str);
    g_string_free (phnStr, TRUE);

    if (mysql_real_query (&mysqlOut, buf->str, buf->len))
--- 149,155 ----
    buf = g_string_sized_new (128);

    g_string_sprintf (buf, "SELECT id, number, text, dreport FROM outbox \
!                           WHERE processed='0' AND CURRENT_TIME() >
not_before AND CURRENT_TIME() < not_after %s", phnStr->str);
    g_string_free (phnStr, TRUE);

    if (mysql_real_query (&mysqlOut, buf->str, buf->len))
hathor:/usr/local/src/gnokii-0.6.4/smsd #

Is it worth adding this change to the next version of smsd?

Regards,
    Martin






reply via email to

[Prev in Thread] Current Thread [Next in Thread]