#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <ctype.h>
#include "libtime.h"
#include "codec.h"
#include <dbus/dbus.h>
#include "clock_dbus.h"
#include <pthread.h>
#include <semaphore.h>
Functions | |
static DBusMessage * | client_new_req (const char *method, int dbus_type,...) |
static DBusMessage * | client_get_rsp (DBusMessage *msg) |
static int | client_set_time (time_t tck) |
static int | client_activate_net_time (void) |
static const char * | client_get_time_format (void) |
static const char * | client_get_default_tz (void) |
static int | client_set_time_format (const char *fmt) |
static const char * | client_get_tz (void) |
static int | client_set_tz (const char *tz) |
static int | client_get_net_time (time_t *t, char *s, size_t max) |
static int | client_get_autosync (void) |
static int | client_set_autosync (int enable) |
static int | client_is_operator_time_accessible (void) |
static int | get_synced (void) |
static void | libtime_init (void) |
static void | libtime_fini (void) |
int | time_get_synced (void) |
time_t | time_get_time (void) |
int | time_set_time (time_t tick) |
int | time_activate_net_time (void) |
int | time_get_timezone (char *buf, size_t max) |
int | time_get_tzname (char *buf, size_t max) |
int | time_set_timezone (const char *tz) |
int | time_get_utc (struct tm *tm) |
int | time_get_utc_ex (time_t tick, struct tm *tm) |
int | time_get_local (struct tm *tm) |
int | time_get_local_ex (time_t tick, struct tm *tm) |
int | time_get_remote (time_t tick, const char *tz, struct tm *tm) |
int | time_get_time_format (char *buf, size_t max) |
int | time_get_default_timezone (char *buf, size_t max) |
int | time_set_time_format (const char *fmt) |
int | time_format_time (const struct tm *tm, const char *fmt, char *s, size_t max) |
int | time_get_utc_offset (const char *tz) |
int | time_get_dst_usage (time_t tick, const char *tz) |
double | time_diff (time_t t1, time_t t2) |
time_t | time_mktime (struct tm *tm, const char *tz) |
int | time_get_net_time (time_t *tick, char *s, size_t max) |
int | time_is_net_time_changed (time_t *tick, char *s, size_t max) |
int | time_set_autosync (int enable) |
int | time_get_autosync (void) |
int | time_is_operator_time_accessible (void) |
int | time_get_time_diff (time_t tick, const char *tz1, const char *tz2) |
Copyright (C) 2008 Nokia. All rights reserved.
static DBusMessage* client_new_req | ( | const char * | method, | |
int | dbus_type, | |||
... | ||||
) | [static] |
Create a new DBUs request.
method | D-Bus method | |
dbus_type | Vararg list of type/value pairs, last shall be DBUS_TYPE_INVALID |
Referenced by client_activate_net_time(), client_get_autosync(), client_get_default_tz(), client_get_net_time(), client_get_time_format(), client_get_tz(), client_is_operator_time_accessible(), client_set_autosync(), client_set_time(), client_set_time_format(), and client_set_tz().
static DBusMessage* client_get_rsp | ( | DBusMessage * | msg | ) | [static] |
Send method call and wait for response
msg | D-Bus message (from client_new_req) |
Referenced by client_activate_net_time(), client_get_autosync(), client_get_default_tz(), client_get_net_time(), client_get_time_format(), client_get_tz(), client_is_operator_time_accessible(), client_set_autosync(), client_set_time(), client_set_time_format(), and client_set_tz().
static int client_set_time | ( | time_t | tck | ) | [static] |
Execute 'set_time' method call over D-Bus
tck | Current time (from Epoch) |
Referenced by time_set_time().
static int client_activate_net_time | ( | void | ) | [static] |
Execute 'activate_net_time' method call over D-Bus
Referenced by time_activate_net_time().
static const char* client_get_time_format | ( | void | ) | [static] |
Execute 'get_timefmt' method call over D-Bus
Referenced by get_synced().
static const char* client_get_default_tz | ( | void | ) | [static] |
Execute 'get_default_tz' method call over D-Bus
Referenced by get_synced().
static int client_set_time_format | ( | const char * | fmt | ) | [static] |
Execute 'set_timefmt' method call over D-Bus
fmt | Time formatter string |
Referenced by time_set_time_format().
static const char* client_get_tz | ( | void | ) | [static] |
Execute 'get_tz' method call over D-Bus
Referenced by get_synced().
static int client_set_tz | ( | const char * | tz | ) | [static] |
Execute 'set_tz' method call over D-Bus
tz | Timezone |
Referenced by time_set_timezone().
static int client_get_net_time | ( | time_t * | t, | |
char * | s, | |||
size_t | max | |||
) | [static] |
Execute 'net_time_changed' method call over D-Bus
t | Pointer to (tick) to store time | |
s | Pointer to buffer to store timezone | |
max | Size of 's' |
Referenced by time_get_net_time().
static int client_get_autosync | ( | void | ) | [static] |
Execute 'get_autosync' method call over D-Bus
Referenced by get_synced().
static int client_set_autosync | ( | int | enable | ) | [static] |
Execute 'set_autosync' method call over D-Bus
enable | >0 if autosync is enabled, 0 if not |
Referenced by time_set_autosync().
static int client_is_operator_time_accessible | ( | void | ) | [static] |
Execute 'have_opertime' method call over D-Bus
Referenced by get_synced().
static int get_synced | ( | void | ) | [static] |
Sync local (cached) data with clockd.
Referenced by libtime_init(), and time_get_synced().
static void libtime_init | ( | void | ) | [static] |
Initialize libtime shlib:
static void libtime_fini | ( | void | ) | [static] |
De-nitialize libtime shlib:
int time_get_synced | ( | void | ) |
Function to call when "time changed" indication (see osso_time_set_notification_cb) has been received by the application.
If the application does not wish to link with libosso, then it can listen to the CLOCKD_TIME_CHANGED D-Bus signal, that clockd sends also.
The time changed indication is broadcasted to all libtime users when:
time_t time_get_time | ( | void | ) |
Get current time - see time()
int time_set_time | ( | time_t | tick | ) |
Set current system and RTC time
tick | Time since Epoch |
int time_activate_net_time | ( | void | ) |
Set current system and RTC time according to operator network time in case time_is_net_time_changed() indicates change
int time_get_timezone | ( | char * | s, | |
size_t | max | |||
) |
Get current time zone. May return empty string if time zone has not been set.
Example output:
:US/Central
GMT+5:00GMT+4:00,0,365
The latter format is returned when network has indicated time zone change (the actual location is not known)
s | Supplied buffer to store timezone | |
max | Size of 's', including terminating NUL |
int time_get_tzname | ( | char * | s, | |
size_t | max | |||
) |
Get current time zone name (like "EET")
s | Supplied buffer to store tzname | |
max | Size of 's', including terminating NUL |
int time_set_timezone | ( | const char * | tz | ) |
Set current time zone ("TZ")
tz | Time zone variable. All formats that glibc supports can be given. See http://www.gnu.org/software/libtool/manual/libc/TZ-Variable.html It is, however recommended to use /usr/share/zoneinfo -method, for example: :Europe/Rome and not like this: EST+5EDT,M4.1.0/2,M10.5.0/2 |
int time_get_utc | ( | struct tm * | tm | ) |
Get current time in UTC. Inspired by time() and gmtime_r()
tm | Supplied buffer to store result |
int time_get_utc_ex | ( | time_t | tick, | |
struct tm * | tm | |||
) |
Get time in UTC.
tick | Time | |
tm | Supplied buffer to store result |
int time_get_local | ( | struct tm * | tm | ) |
Get current local time. Inspired by time() and localtime_r().
tm | Supplied buffer to store tm |
int time_get_local_ex | ( | time_t | tick, | |
struct tm * | tm | |||
) |
Get local time.
tick | Time | |
tm | Supplied buffer to store tm |
int time_get_remote | ( | time_t | tick, | |
const char * | tz, | |||
struct tm * | tm | |||
) |
Get local time in given zone. Inspired by setting TZ temporarily and localtime_r().
tick | Time since Epoch | |
tz | Time zone variable. All formats that glibc supports can be given. See http://www.gnu.org/software/libtool/manual/libc/TZ-Variable.html | |
tm | Supplied buffer to store tm |
int time_get_time_format | ( | char * | s, | |
size_t | max | |||
) |
Get current time string formatter. Inspired by strftime().
s | Supplied buffer to store formatter | |
max | Size of 's', including terminating NUL |
int time_get_default_timezone | ( | char * | s, | |
size_t | max | |||
) |
Get the default time zone. Empty string is returned if no default zone has been defined.
s | Supplied buffer to store the zone | |
max | Size of 's', including terminating NUL |
int time_set_time_format | ( | const char * | fmt | ) |
Set current time string formatter. Inspired by strftime().
fmt | Formatter string |
int time_format_time | ( | const struct tm * | tm, | |
const char * | fmt, | |||
char * | s, | |||
size_t | max | |||
) |
Format given time to string. Inspired by strftime() and localtime_r().
tm | Time | |
fmt | Formatter, see strftime and time_set_time_format and time_get_time_format, NULL if active formatter is used. | |
s | Supplied buffer to store result | |
max | Size of 's', including terminating NUL |
int time_get_utc_offset | ( | const char * | tz | ) |
Get utc offset (secs west of GMT) in the named TZ. The current daylight saving time offset is included.
tz | Time zone, all formats that glibc supports can be given. NULL to use current tz. See http://www.gnu.org/software/libtool/manual/libc/TZ-Variable.html |
int time_get_dst_usage | ( | time_t | tick, | |
const char * | tz | |||
) |
Return if daylight-saving-time is in use in given time.
tick | Time since Epoch | |
tz | Time zone, all formats that glibc supports can be given. NULL to use current tz. See http://www.gnu.org/software/libtool/manual/libc/TZ-Variable.html |
double time_diff | ( | time_t | t1, | |
time_t | t2 | |||
) |
See difftime()
time_t time_mktime | ( | struct tm * | tm, | |
const char * | tz | |||
) |
Make time_t from struct tm. Like mktime() but timezone can be given.
tm | See mktime | |
tz | Time zone variable. All formats that glibc supports can be given. NULL if current zone is used. See http://www.gnu.org/software/libtool/manual/libc/TZ-Variable.html |
int time_get_net_time | ( | time_t * | tick, | |
char * | s, | |||
size_t | max | |||
) |
Get the network time (in case that autosync is not enabled and a network time change indication has received)
tick | Supplied buffer to store network time (ticks since Epock) | |
s | Supplied buffer to store network timezone | |
max | Size of 's', including terminating NUL |
Referenced by time_is_net_time_changed().
int time_is_net_time_changed | ( | time_t * | tick, | |
char * | s, | |||
size_t | max | |||
) |
Deprecated, see time_get_net_time
int time_set_autosync | ( | int | enable | ) |
Enable or disable automatic time settings based on cellular network time.
enable | Nonzero to enable, zero to disable |
int time_get_autosync | ( | void | ) |
Get the state of automatic time settings based on cellular network time.
int time_is_operator_time_accessible | ( | void | ) |
Get info if the device supports network time updates (i.e. has CellMo).
int time_get_time_diff | ( | time_t | tick, | |
const char * | tz1, | |||
const char * | tz2 | |||
) |
Get time difference between two timezones
tick | Time since Epoch | |
tz1 | Timezone 1 | |
tz2 | Timezone 2 |