summaryrefslogtreecommitdiff
path: root/telepathy-logger
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2010-04-19 19:20:44 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2010-04-23 14:27:00 +0100
commitc30cf7d603b57ffe8a789ec552e808a4027d81dd (patch)
tree2627dbdb05b9e15b98d7ad2f162b63cb1e9547e8 /telepathy-logger
parent83ca82a5b38d31cefce83fad1390dd627fcd9a8a (diff)
downloadtelepathy-logger-c30cf7d603b57ffe8a789ec552e808a4027d81dd.tar.gz
Internalize datetime code
Diffstat (limited to 'telepathy-logger')
-rw-r--r--telepathy-logger/Makefile.am2
-rw-r--r--telepathy-logger/channel-text.c4
-rw-r--r--telepathy-logger/datetime-internal.h (renamed from telepathy-logger/datetime.h)16
-rw-r--r--telepathy-logger/datetime.c16
-rw-r--r--telepathy-logger/log-manager.c6
-rw-r--r--telepathy-logger/log-store-sqlite.c12
-rw-r--r--telepathy-logger/log-store-xml.c10
-rw-r--r--telepathy-logger/util.c4
8 files changed, 35 insertions, 35 deletions
diff --git a/telepathy-logger/Makefile.am b/telepathy-logger/Makefile.am
index 4ecd8f2..e082ef7 100644
--- a/telepathy-logger/Makefile.am
+++ b/telepathy-logger/Makefile.am
@@ -25,7 +25,6 @@ LIBTPL_HEADERS = \
channel-text.h \
conf.h \
contact.h \
- datetime.h \
dbus-service.h \
log-entry.h \
log-entry-text.h \
@@ -46,6 +45,7 @@ libtelepathy_logger_la_SOURCES = \
conf.c \
contact.c \
datetime.c \
+ datetime-internal.h \
dbus-service.c \
debug-internal.h \
debug.c \
diff --git a/telepathy-logger/channel-text.c b/telepathy-logger/channel-text.c
index 189651d..9d66808 100644
--- a/telepathy-logger/channel-text.c
+++ b/telepathy-logger/channel-text.c
@@ -34,9 +34,9 @@
#include <telepathy-logger/log-entry-text.h>
#include <telepathy-logger/log-manager-priv.h>
#include <telepathy-logger/log-store-sqlite.h>
-#include <telepathy-logger/datetime.h>
#define DEBUG_FLAG TPL_DEBUG_CHANNEL
+#include <telepathy-logger/datetime-internal.h>
#include <telepathy-logger/debug-internal.h>
#include <telepathy-logger/util-internal.h>
@@ -569,7 +569,7 @@ pendingproc_cleanup_pending_messages_db (TplActionChain *ctx,
{
/* five days ago in seconds */
TplChannelText *self = tpl_action_chain_get_object (ctx);
- const time_t time_limit = tpl_time_get_current () -
+ const time_t time_limit = _tpl_time_get_current () -
TPL_LOG_STORE_SQLITE_CLEANUP_DELTA_LIMIT;
TplLogStore *cache = tpl_log_store_sqlite_dup ();
GList *l;
diff --git a/telepathy-logger/datetime.h b/telepathy-logger/datetime-internal.h
index cae7c59..77b4d20 100644
--- a/telepathy-logger/datetime.h
+++ b/telepathy-logger/datetime-internal.h
@@ -29,14 +29,14 @@
#include <glib.h>
G_BEGIN_DECLS
-#define TPL_TIME_FORMAT_DISPLAY_SHORT "%H:%M"
-#define TPL_TIME_FORMAT_DISPLAY_LONG "%a %d %b %Y"
-time_t tpl_time_get_current (void);
-time_t tpl_time_get_local_time (struct tm *tm);
-time_t tpl_time_parse (const gchar * str);
-gchar *tpl_time_to_string_utc (time_t t, const gchar * format);
-gchar *tpl_time_to_string_local (time_t t, const gchar * format);
-gchar *tpl_time_to_string_relative (time_t t);
+#define _TPL_TIME_FORMAT_DISPLAY_SHORT "%H:%M"
+#define _TPL_TIME_FORMAT_DISPLAY_LONG "%a %d %b %Y"
+time_t _tpl_time_get_current (void);
+time_t _tpl_time_get_local_time (struct tm *tm);
+time_t _tpl_time_parse (const gchar * str);
+gchar *_tpl_time_to_string_utc (time_t t, const gchar * format);
+gchar *_tpl_time_to_string_local (time_t t, const gchar * format);
+gchar *_tpl_time_to_string_relative (time_t t);
G_END_DECLS
#endif /* __TPL_TIME_H__ */
diff --git a/telepathy-logger/datetime.c b/telepathy-logger/datetime.c
index 8afe00e..d4a0205 100644
--- a/telepathy-logger/datetime.c
+++ b/telepathy-logger/datetime.c
@@ -21,7 +21,7 @@
*/
#include "config.h"
-#include "datetime.h"
+#include "datetime-internal.h"
#include <glib/gi18n.h>
#include <stdio.h>
@@ -33,13 +33,13 @@
/* Note: TplTime is always in UTC. */
time_t
-tpl_time_get_current (void)
+_tpl_time_get_current (void)
{
return time (NULL);
}
time_t
-tpl_time_get_local_time (struct tm *tm)
+_tpl_time_get_local_time (struct tm *tm)
{
const gchar *tz;
time_t t;
@@ -65,7 +65,7 @@ tpl_time_get_local_time (struct tm *tm)
* failure. The alternative format "20021209" is also accepted.
*/
time_t
-tpl_time_parse (const gchar *str)
+_tpl_time_parse (const gchar *str)
{
struct tm tm;
gint year, month;
@@ -85,12 +85,12 @@ tpl_time_parse (const gchar *str)
tm.tm_mon = month - 1;
tm.tm_isdst = -1;
- return tpl_time_get_local_time (&tm);
+ return _tpl_time_get_local_time (&tm);
}
/* Converts the UTC timestamp to a string, also in UTC. Returns NULL on failure. */
gchar *
-tpl_time_to_string_utc (time_t t,
+_tpl_time_to_string_utc (time_t t,
const gchar * format)
{
gchar stamp[128];
@@ -109,7 +109,7 @@ tpl_time_to_string_utc (time_t t,
/* Converts the UTC timestamp to a string, in local time. Returns NULL on failure. */
gchar *
-tpl_time_to_string_local (time_t t,
+_tpl_time_to_string_local (time_t t,
const gchar *format)
{
gchar stamp[128];
@@ -127,7 +127,7 @@ tpl_time_to_string_local (time_t t,
}
gchar *
-tpl_time_to_string_relative (time_t then)
+_tpl_time_to_string_relative (time_t then)
{
time_t now;
gint seconds;
diff --git a/telepathy-logger/log-manager.c b/telepathy-logger/log-manager.c
index f5042c1..5b3c534 100644
--- a/telepathy-logger/log-manager.c
+++ b/telepathy-logger/log-manager.c
@@ -39,9 +39,9 @@
#include <telepathy-logger/log-store.h>
#include <telepathy-logger/log-store-xml.h>
#include <telepathy-logger/log-store-sqlite.h>
-#include <telepathy-logger/datetime.h>
#define DEBUG_FLAG TPL_DEBUG_LOG_MANAGER
+#include <telepathy-logger/datetime-internal.h>
#include <telepathy-logger/debug-internal.h>
#include <telepathy-logger/util-internal.h>
@@ -716,9 +716,9 @@ tpl_log_manager_get_date_readable (const gchar *date)
{
time_t t;
- t = tpl_time_parse (date);
+ t = _tpl_time_parse (date);
- return tpl_time_to_string_local (t, TPL_TIME_FORMAT_DISPLAY_LONG);
+ return _tpl_time_to_string_local (t, _TPL_TIME_FORMAT_DISPLAY_LONG);
}
diff --git a/telepathy-logger/log-store-sqlite.c b/telepathy-logger/log-store-sqlite.c
index e35cb41..aaa5139 100644
--- a/telepathy-logger/log-store-sqlite.c
+++ b/telepathy-logger/log-store-sqlite.c
@@ -29,9 +29,9 @@
#include "log-entry-text.h"
#include "log-store-sqlite.h"
-#include "datetime.h"
#define DEBUG_FLAG TPL_DEBUG_LOG_STORE
+#include "datetime-internal.h"
#include "debug-internal.h"
#include "util-internal.h"
@@ -291,7 +291,7 @@ get_date (TplLogEntry *entry)
t = tpl_log_entry_get_timestamp (entry);
- return tpl_time_to_string_utc (t, "%Y-%m-%d");
+ return _tpl_time_to_string_utc (t, "%Y-%m-%d");
}
static char *
@@ -301,7 +301,7 @@ get_datetime (TplLogEntry *entry)
t = tpl_log_entry_get_timestamp (entry);
- return tpl_time_to_string_utc (t, TPL_LOG_STORE_SQLITE_TIMESTAMP_FORMAT);
+ return _tpl_time_to_string_utc (t, TPL_LOG_STORE_SQLITE_TIMESTAMP_FORMAT);
}
static const char *
@@ -792,7 +792,7 @@ out:
* older than this value (time_t). Set it to %G_MAXUINT or any other value in
* the future to obtain all the entries.
* For example, to obtain entries older than one day ago, use
- * @timestamp = (#tpl_time_get_current()-86400)
+ * @timestamp = (#_tpl_time_get_current()-86400)
*
* Note that (in case @channel is not %NULL) this method might return log-ids
* which are not currently related to @channel but just share the object-path,
@@ -839,7 +839,7 @@ tpl_log_store_sqlite_get_log_ids (TplLogStore *self,
goto out;
}
- date = tpl_time_to_string_utc (timestamp,
+ date = _tpl_time_to_string_utc (timestamp,
TPL_LOG_STORE_SQLITE_TIMESTAMP_FORMAT);
sqlite3_bind_text (sql, 1, date, -1, SQLITE_TRANSIENT);
@@ -1060,7 +1060,7 @@ tpl_log_store_sqlite_purge (TplLogStoreSqlite *self,
g_return_if_fail (error == NULL || *error == NULL);
g_return_if_fail (TPL_IS_LOG_STORE_SQLITE (self));
- date = tpl_time_to_string_utc ((tpl_time_get_current () - delta),
+ date = _tpl_time_to_string_utc ((_tpl_time_get_current () - delta),
TPL_LOG_STORE_SQLITE_TIMESTAMP_FORMAT);
DEBUG ("Purging entries older than %s (%u seconds ago)", date, (guint) delta);
diff --git a/telepathy-logger/log-store-xml.c b/telepathy-logger/log-store-xml.c
index 412dbd4..e2b3b0c 100644
--- a/telepathy-logger/log-store-xml.c
+++ b/telepathy-logger/log-store-xml.c
@@ -44,9 +44,9 @@
#include <telepathy-logger/log-entry-text.h>
#include <telepathy-logger/log-manager.h>
#include <telepathy-logger/log-store.h>
-#include <telepathy-logger/datetime.h>
#define DEBUG_FLAG TPL_DEBUG_LOG_STORE
+#include <telepathy-logger/datetime-internal.h>
#include <telepathy-logger/debug-internal.h>
#include <telepathy-logger/util-internal.h>
@@ -313,8 +313,8 @@ log_store_xml_get_timestamp_filename (void)
gchar *time_str;
gchar *filename;
- t = tpl_time_get_current ();
- time_str = tpl_time_to_string_local (t, LOG_TIME_FORMAT);
+ t = _tpl_time_get_current ();
+ time_str = _tpl_time_to_string_local (t, LOG_TIME_FORMAT);
filename = g_strconcat (time_str, LOG_FILENAME_SUFFIX, NULL);
g_free (time_str);
@@ -331,7 +331,7 @@ log_store_xml_get_timestamp_from_message (TplLogEntry *message)
t = tpl_log_entry_get_timestamp (message);
/* We keep the timestamps in the messages as UTC */
- return tpl_time_to_string_utc (t, LOG_TIME_FORMAT_FULL);
+ return _tpl_time_to_string_utc (t, LOG_TIME_FORMAT_FULL);
}
@@ -826,7 +826,7 @@ log_store_xml_get_messages_for_file (TplLogStoreXml *self,
/* we have no way in non empathy-legacy mode to know it */
pending_id = TPL_LOG_ENTRY_MSG_ID_UNKNOWN;
- t = tpl_time_parse (time_);
+ t = _tpl_time_parse (time_);
sender = tpl_contact_new (sender_id);
tpl_contact_set_alias (sender, sender_name);
diff --git a/telepathy-logger/util.c b/telepathy-logger/util.c
index 3bf57c4..d769c9e 100644
--- a/telepathy-logger/util.c
+++ b/telepathy-logger/util.c
@@ -21,7 +21,7 @@
#include "util-internal.h"
-#include "datetime.h"
+#include "datetime-internal.h"
#include "log-store-sqlite.h"
/* Bug#26838 prevents us to trust Messages' iface message-token
@@ -34,7 +34,7 @@ _tpl_create_message_token (const gchar *channel,
{
GChecksum *log_id = g_checksum_new (G_CHECKSUM_SHA1);
gchar *retval;
- gchar *date = tpl_time_to_string_local (timestamp,
+ gchar *date = _tpl_time_to_string_local (timestamp,
TPL_LOG_STORE_SQLITE_TIMESTAMP_FORMAT);
g_checksum_update (log_id, (guchar *) channel, -1);