server.c File Reference

clockd 'server' More...

#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/times.h>
#include <signal.h>
#include <libosso.h>
#include "codec.h"
#include <dbus/dbus-glib-lowlevel.h>
#include <assert.h>
#include "logging.h"
#include "server.h"
#include "libtime.h"
#include "clock_dbus.h"
#include "internal_time_utils.h"
#include "mcc_tz_utils.h"

Functions

static gboolean handle_alarm (DBusConnection *bus)
static int read_conf ()
static int save_conf (void)
static int server_send_time_change_indication (time_t t)
static int server_set_time (time_t t)
static DBusMessage * server_new_rsp (DBusMessage *msg, int type,...)
static DBusMessage * server_set_time_cb (DBusMessage *msg)
static DBusMessage * server_activate_net_time_cb (DBusMessage *msg)
static int handle_csd_net_time_change (DBusMessage *msg)
static DBusMessage * server_get_time_format_cb (DBusMessage *msg)
static DBusMessage * server_get_default_tz_cb (DBusMessage *msg)
static DBusMessage * server_get_time_cb (DBusMessage *msg)
static DBusMessage * server_set_time_format_cb (DBusMessage *msg)
static DBusMessage * server_get_tz_cb (DBusMessage *msg)
static DBusMessage * server_is_net_time_changed_cb (DBusMessage *msg)
static DBusMessage * server_set_tz_cb (DBusMessage *msg)
static DBusMessage * server_get_autosync_cb (DBusMessage *msg)
static DBusMessage * server_set_autosync_cb (DBusMessage *msg)
static DBusMessage * server_have_opertime_cb (DBusMessage *msg)
static DBusHandlerResult server_filter (DBusConnection *conn, DBusMessage *msg, void *user_data)
int server_init (void)
void server_quit (void)


Detailed Description

This is D-Bus server for clockd that communicates with clock/time -aware applications. It also listens for CSD NET_TIME_CHANGE signal and reacts to it accordingly.

Copyright (C) 2008 Nokia. All rights reserved.

Author:
Simo Piiroinen <simo.piiroinen@nokia.com>

Raimo Vuonnala <raimo.vuonnala@nokia.com>


Function Documentation

static gboolean handle_alarm ( DBusConnection *  bus  )  [static]

Check DST change and send time change indication when DST changes.

static int read_conf (  )  [static]

Read /home/user/.clockd.conf contents

Returns:
0 if OK, -1 if error

Referenced by server_init().

static int save_conf ( void   )  [static]

Save current config to /home/user/.clockd.conf

Returns:
0 if OK, -1 if error

Referenced by handle_csd_net_time_change(), server_init(), server_set_autosync_cb(), server_set_time_cb(), server_set_time_format_cb(), and server_set_tz_cb().

static int server_send_time_change_indication ( time_t  t  )  [static]

Send "change" indication to all interested parties (via libosso).

Parameters:
t Current time
Returns:
0 if OK, -1 if error

Referenced by handle_alarm(), handle_csd_net_time_change(), server_set_autosync_cb(), server_set_time_cb(), server_set_time_format_cb(), and server_set_tz_cb().

static int server_set_time ( time_t  t  )  [static]

Set system and RTC time using suidroot rclockd helper

Parameters:
t Current time
Returns:
0 if OK, -1 if error

Referenced by handle_csd_net_time_change(), and server_set_time_cb().

static DBusMessage* server_new_rsp ( DBusMessage *  msg,
int  type,
  ... 
) [static]

Create D-Bus method call response message

Parameters:
msg request message
type vararg type/value attributes
Returns:
NULL if fails, pointer to DBusMessage if OK

Referenced by server_activate_net_time_cb(), server_get_autosync_cb(), server_get_default_tz_cb(), server_get_time_cb(), server_get_time_format_cb(), server_get_tz_cb(), server_have_opertime_cb(), server_is_net_time_changed_cb(), server_set_autosync_cb(), server_set_time_cb(), server_set_time_format_cb(), and server_set_tz_cb().

static DBusMessage* server_set_time_cb ( DBusMessage *  msg  )  [static]

Handle D-Bus set_time method. Sets system/RTC time and sends time change indication with libosso.

Parameters:
msg request message
Returns:
NULL if fails, pointer to response DBusMessage if OK

Referenced by server_filter().

static DBusMessage* server_activate_net_time_cb ( DBusMessage *  msg  )  [static]

Handle D-Bus activate_net_time method. Sets system/RTC time and sends time change indication with libosso.

Parameters:
msg request message
Returns:
NULL if fails, pointer to response DBusMessage if OK

Referenced by server_filter().

static int handle_csd_net_time_change ( DBusMessage *  msg  )  [static]

Handle D-Bus net_time_change signal from CSD. If network autosync is enabled, set system/RTC time and sends time change indication with libosso; otherwise just store the data (that can be activated with activate_net_time method later)

Parameters:
msg signal message
Returns:
-1 if failed to update time (e.g. NITZ does not supported by carrier), otherwise 0

Referenced by mcc_tz_handle_network_timeinfo_reply(), mcc_tz_utils_init(), mcc_tz_utils_quit(), server_filter(), and server_init().

static DBusMessage* server_get_time_format_cb ( DBusMessage *  msg  )  [static]

Handle D-Bus get_time_fmt method

Parameters:
msg request message
Returns:
NULL if fails, pointer to response DBusMessage if OK

Referenced by server_filter().

static DBusMessage* server_get_default_tz_cb ( DBusMessage *  msg  )  [static]

Handle D-Bus get_default_tz method

Parameters:
msg request message
Returns:
NULL if fails, pointer to response DBusMessage if OK

Referenced by server_filter().

static DBusMessage* server_get_time_cb ( DBusMessage *  msg  )  [static]

Handle D-Bus get_time method

Parameters:
msg request message
Returns:
NULL if fails, pointer to response DBusMessage if OK

Referenced by server_filter().

static DBusMessage* server_set_time_format_cb ( DBusMessage *  msg  )  [static]

Handle D-Bus get_time_fmt method. Sets the time format locally and sends time change indication with libosso. Saves config to /home/user/.clockd.conf.

Parameters:
msg request message
Returns:
NULL if fails, pointer to response DBusMessage if OK

Referenced by server_filter().

static DBusMessage* server_get_tz_cb ( DBusMessage *  msg  )  [static]

Handle D-Bus get_tz method.

Parameters:
msg request message
Returns:
NULL if fails, pointer to response DBusMessage if OK

Referenced by server_filter().

static DBusMessage* server_is_net_time_changed_cb ( DBusMessage *  msg  )  [static]

Handle D-Bus is_net_time_changed method

Parameters:
msg request message
Returns:
NULL if fails, pointer to response DBusMessage if OK

Referenced by server_filter().

static DBusMessage* server_set_tz_cb ( DBusMessage *  msg  )  [static]

Handle D-Bus set_tz method. Sets the time zone and sends time change indication. Saves config to /home/user/.clockd.conf.

Parameters:
msg request message
Returns:
NULL if fails, pointer to response DBusMessage if OK

Referenced by server_filter().

static DBusMessage* server_get_autosync_cb ( DBusMessage *  msg  )  [static]

Handle D-Bus get_autosync method

Parameters:
msg request message
Returns:
NULL if fails, pointer to response DBusMessage if OK

Referenced by server_filter().

static DBusMessage* server_set_autosync_cb ( DBusMessage *  msg  )  [static]

Handle D-Bus set_autosync method. Set autosync on/off and sends time change indication with libosso. Saves config to /home/user/.clockd.conf.

Parameters:
msg request message
Returns:
NULL if fails, pointer to response DBusMessage if OK

Referenced by server_filter().

static DBusMessage* server_have_opertime_cb ( DBusMessage *  msg  )  [static]

Handle D-Bus have_opertime method

Parameters:
msg request message
Returns:
NULL if fails, pointer to response DBusMessage if OK

Referenced by server_filter().

static DBusHandlerResult server_filter ( DBusConnection *  conn,
DBusMessage *  msg,
void *  user_data 
) [static]

Handle requests (methods or signals) coming via D-Bus

Parameters:
conn D-Bus connection
msg D-Bus message
user_data User data (not used)
Returns:
DBusHandlerResult

Referenced by server_init(), and server_quit().

int server_init ( void   ) 

Init D-Bus server

The following is set up:

  • settings from environment (/etc/clockd/clockd-settings.default)
  • settings from configuration file (/home/user/.clockd.conf)
  • D-Bus connections
  • libosso init
  • timezone from /etc/localtime or /home/user/.clockd.conf

Returns:
0 if OK, -1 if error

Referenced by mainloop_run().

void server_quit ( void   ) 

Deinitialize D-Bus server

Referenced by mainloop_run().


Generated on Mon Jun 21 15:45:53 2010 for clockd by  doxygen 1.5.6