From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 2/2] Added SQLite history plugin
Date: Tue, 06 Apr 2010 12:56:45 -0500 [thread overview]
Message-ID: <201004061256.46026.denkenz@gmail.com> (raw)
In-Reply-To: <4BBB104F.2090604@djdas.net>
[-- Attachment #1: Type: text/plain, Size: 2549 bytes --]
Hi Dario,
> +#define SQL_HISTORY_DB_PATH STORAGEDIR "/ofono_history.sqlite"
> +#define SQL_HISTORY_DB_SQL STORAGEDIR "/oFono_History_DB.sql"
So I have my concerns about storing this in /. This should be in a proper
directory, like /var/lib/ofono or something like that.
> +static int sqlite_history_probe(struct ofono_history_context *context)
> +{
> + char *execerror;
> +
> + ofono_debug("SQLite History Probe for modem: %p", context->modem);
> +
> + if (sqlite3_open(SQL_HISTORY_DB_PATH, &db) != SQLITE_OK) {
> + ofono_debug("Error opening DB: %s", sqlite3_errmsg(db));
Please use DBG macro instead of ofono_debug.
> + sqlite3_close(db);
> + return -1;
> + }
> +
> + if (sqlite3_exec(db, SELECT_CALLS, NULL, NULL, &execerror) != SQLITE_OK)
> { + char *sqlscript;
Should be
if (sqlite3_exec == SQLITE_OK)
return 0;
Then the rest of the if statement follows unnested.
> + GError *sqlerror = NULL;
> +
> + ofono_debug("Creating DB");
> +
> + g_file_get_contents(SQL_HISTORY_DB_SQL, &sqlscript, NULL, &sqlerror);
> +
> + if (sqlerror != NULL) {
> + ofono_debug("Error opening sql script: %s", sqlerror->message);
> + g_error_free(sqlerror);
> + return -1;
> + }
> +
> + if (sqlite3_exec(db, sqlscript, NULL, NULL, &execerror) != SQLITE_OK) {
> + ofono_debug("Error executing sql script: %s", execerror);
> + sqlite3_free(execerror);
> + g_free(sqlscript);
> + return -1;
> + }
> +
> + g_free(sqlscript);
> + }
> +
> + return 0;
> +}
> +
> +static void sqlite_history_remove(struct ofono_history_context *context)
> +{
> + ofono_debug("SQLite History Remove for modem: %p", context->modem);
> +
> + if (db != NULL)
> + sqlite3_close(db);
> +}
> +
So remember that the history plugin is instantiated for each and every modem,
so you will be sqlite_open/sqlite_closing the db in each instance. Not really
sure if this is what you want, or whether you want a reference-counted
database connection here.
Another thing to consider is that you might want to store the IMSI of the
modem along with the history information for every call / sms event. That way
when a SIM card is changed, the user can be shown a different set of call / sms
history.
Finally, you might want to set limits on the number of entries in the
database, and expire them as the limit is reached. Otherwise you'd need to
expire them periodically from e.g. cron, but would need to release control of
the database during that time.
Regards,
-Denis
next prev parent reply other threads:[~2010-04-06 17:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-06 10:43 [PATCH 2/2] Added SQLite history plugin Dario
2010-04-06 17:56 ` Denis Kenzior [this message]
2010-04-07 8:50 ` Dario
2010-04-07 17:01 ` Denis Kenzior
2010-04-07 17:54 ` Nicola Mfb
2010-04-07 18:05 ` Denis Kenzior
2010-04-07 19:20 ` Nicola Mfb
2010-04-07 19:33 ` Denis Kenzior
2010-04-07 21:26 ` Nicola Mfb
2010-04-07 11:47 ` Nicola Mfb
2010-04-07 17:28 ` Bastian, Waldo
2010-04-07 17:33 ` Denis Kenzior
2010-04-07 17:43 ` Nicola Mfb
2010-04-07 17:55 ` Denis Kenzior
2010-04-07 18:09 ` Nicola Mfb
2010-04-07 18:20 ` Denis Kenzior
2010-04-07 18:03 ` Bastian, Waldo
2010-04-07 18:27 ` Denis Kenzior
2010-04-07 19:28 ` Denis Kenzior
-- strict thread matches above, loose matches on Subject: below --
2010-04-04 21:51 Dario
2010-04-05 2:54 ` Bastian, Waldo
2010-04-06 10:55 ` Dario
2010-04-06 16:12 ` Bastian, Waldo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201004061256.46026.denkenz@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.