Main Page | Data Structures | File List | Data Fields | Globals

alarm_event.c File Reference

#include <stdlib.h>
#include <string.h>
#include <dbus/dbus.h>
#include <time.h>
#include "include/alarm_dbus.h"
#include "include/alarm_event.h"

Include dependency graph for alarm_event.c:

Go to the source code of this file.

Defines

#define DBUS_API_SUBJECT_TO_CHANGE
 This file is part of alarmd.
#define _strdup(x)   ((x) != NULL ? strdup(x) : NULL)
#define NULL0(x)   ((x) != NULL ? 1 : 0)
#define ZERO0(x)   ((x) != 0 ? 1 : 0)
#define APPEND_ARG(msg, value, type, code)
#define dbus_message_iter_get_string(iter, var)

Enumerations

enum  Properties {
  TIME,
  TITLE,
  MESSAGE,
  SOUND,
  ICON,
  INTERFACE,
  SERVICE,
  PATH,
  NAME,
  FLAGS,
  ACTION,
  RECURRENCE,
  RECURRENCE_COUNT,
  SNOOZE_INT,
  SNOOZE,
  COUNT
}

Functions

static int _get_id (const char *name)
static size_t strstrcount (const char *haystack, const char *needle)
static size_t strchrcount (const char *haystack, const char needle)
static size_t strspncount (const char *haystack, const char *needles)
static DBusMessage * _alarm_event_dbus_call (const char *method, int first_arg_type,...)
cookie_t alarm_event_add (alarm_event_t *event)
 alarm_event_add: : alarm_event_t struct describing the event to be added.
int alarm_event_del (cookie_t event_cookie)
 alarm_event_del: : Unique identifier of the alarm to be removed.
cookie_talarm_event_query (const time_t first, const time_t last, int32_t flag_mask, int32_t flags)
 alarm_event_query: : Alarms happening after this time will be returned.
alarm_event_talarm_event_get (cookie_t event_cookie)
 alarm_event_get: : Unique identifier of the alarm.
void alarm_event_free (alarm_event_t *event)
 alarm_event_free: : The alarm_event struct to be free'd.
char * alarm_escape_string (const char *string)
 alarm_escape_string: : The string that should be escaped.
static void _alarm_do_unescape (const char *read, char *write)
char * alarm_unescape_string_noalloc (char *string)
 alarm_unescape_string_noalloc: : The string that should be unescaped.
char * alarm_unescape_string (const char *string)
 alarm_unescape_string: : The string that should be unescaped.
alarm_error_t alarmd_get_error (void)
 alarmd_get_error:
int alarmd_set_default_snooze (unsigned int snooze)
 alarmd_set_default_snooze: : The preferred snooze time in minutes.
unsigned int alarmd_get_default_snooze (void)
 alarmd_get_default_snooze:

Variables

static const char *const property [COUNT]
static alarm_error_t error_code


Define Documentation

#define _strdup  )     ((x) != NULL ? strdup(x) : NULL)
 

Definition at line 30 of file alarm_event.c.

#define APPEND_ARG msg,
value,
type,
code   ) 
 

Value:

while ((int)(value) != 0) { \
        if (!dbus_message_append_args(msg, DBUS_TYPE_STRING, \
                                &property[(code)], \
                                (type), &(value), DBUS_TYPE_INVALID)) { \
                error_code = ALARMD_ERROR_MEMORY; \
                return 0; \
        } \
                break; \
}

Definition at line 33 of file alarm_event.c.

Referenced by alarm_event_add().

#define DBUS_API_SUBJECT_TO_CHANGE
 

This file is part of alarmd.

Contact Person: David Weinehall <david.weinehall@nokia.com>

Copyright (C) 2006 Nokia Corporation alarmd and libalarm are free software; you can redistribute them and/or modify them under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.

alarmd and libalarm are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Definition at line 22 of file alarm_event.c.

#define dbus_message_iter_get_string iter,
var   ) 
 

Value:

dbus_message_iter_get_basic(iter, &value_string); \
                        var = _strdup(value_string); \
                        value_string = NULL;

Referenced by alarm_event_get().

#define NULL0  )     ((x) != NULL ? 1 : 0)
 

Definition at line 31 of file alarm_event.c.

Referenced by alarm_event_add().

#define ZERO0  )     ((x) != 0 ? 1 : 0)
 

Definition at line 32 of file alarm_event.c.

Referenced by alarm_event_add().


Enumeration Type Documentation

enum Properties
 

Enumeration values:
TIME 
TITLE 
MESSAGE 
SOUND 
ICON 
INTERFACE 
SERVICE 
PATH 
NAME 
FLAGS 
ACTION 
RECURRENCE 
RECURRENCE_COUNT 
SNOOZE_INT 
SNOOZE 
COUNT 

Definition at line 46 of file alarm_event.c.


Function Documentation

static void _alarm_do_unescape const char *  read,
char *  write
[static]
 

Definition at line 590 of file alarm_event.c.

Referenced by alarm_unescape_string(), and alarm_unescape_string_noalloc().

static DBusMessage* _alarm_event_dbus_call const char *  method,
int  first_arg_type,
  ...
[static]
 

Definition at line 131 of file alarm_event.c.

References ALARMD_ERROR_DBUS, ALARMD_ERROR_INTERNAL, ALARMD_ERROR_MEMORY, ALARMD_INTERFACE, ALARMD_PATH, ALARMD_SERVICE, conn, and error_code.

Referenced by alarm_event_del(), alarm_event_get(), alarm_event_query(), alarmd_get_default_snooze(), and alarmd_set_default_snooze().

static int _get_id const char *  name  )  [static]
 

Definition at line 544 of file alarm_event.c.

References COUNT, and property.

Referenced by alarm_event_get().

char* alarm_escape_string const char *  string  ) 
 

alarm_escape_string: : The string that should be escaped.

Escapes a string to be used as alarm dialog message or title. All { and } characters will be escaped with backslash and all backslashes will be duplicated. Returns: Newly allocated string, should be freed with free().

Definition at line 560 of file alarm_event.c.

References strspncount().

cookie_t alarm_event_add alarm_event_t event  ) 
 

alarm_event_add: : alarm_event_t struct describing the event to be added.

Adds an event to the alarm queue. If event->exec_name and event->dbus_path are NULL, the alarm will be only show a dialog (unless ALARM_EVENT_NO_DIALOG is set in flags, in which case, the event does nothing). If only event->dbus_path is NULL, the alarm will run a program at given time (and show a dialog unless otherwise instructed). If recurrence > 0, the alarm will repeat recurrence_count times. If snooze_time is zero, default of 10 minutes is used. Returns: Unique identifier for the alarm, or 0 on failure.

Definition at line 180 of file alarm_event.c.

References ACTION, ALARM_EVENT_ADD, alarm_event_t::alarm_time, ALARMD_ERROR_ARGUMENT, ALARMD_ERROR_CONNECTION, ALARMD_ERROR_DBUS, ALARMD_ERROR_INTERNAL, ALARMD_ERROR_MEMORY, ALARMD_INTERFACE, ALARMD_PATH, ALARMD_SERVICE, ALARMD_SUCCESS, APPEND_ARG, conn, alarm_event_t::dbus_interface, alarm_event_t::dbus_name, alarm_event_t::dbus_path, alarm_event_t::dbus_service, error_code, alarm_event_t::exec_name, FLAGS, alarm_event_t::flags, alarm_event_t::icon, ICON, INTERFACE, alarm_event_t::message, MESSAGE, NAME, NULL0, PATH, property, alarm_event_t::recurrence, RECURRENCE, alarm_event_t::recurrence_count, RECURRENCE_COUNT, SERVICE, alarm_event_t::snooze, SNOOZE_INT, alarm_event_t::sound, SOUND, TIME, alarm_event_t::title, TITLE, and ZERO0.

Referenced by main(), and tool_add().

int alarm_event_del cookie_t  event_cookie  ) 
 

alarm_event_del: : Unique identifier of the alarm to be removed.

Deletes alarm from the alarm queue. The alarm with the event_cookie identifier will be removed from the alarm queue, if it exists. Returns: 1 If alarm was on the queue, 0 otherwise.

Definition at line 304 of file alarm_event.c.

References _alarm_event_dbus_call(), ALARM_EVENT_DEL, ALARMD_ERROR_INTERNAL, ALARMD_SUCCESS, and error_code.

Referenced by main(), and tool_remove().

void alarm_event_free alarm_event_t event  ) 
 

alarm_event_free: : The alarm_event struct to be free'd.

Frees given alarm_event struct. Will free all memory associated with the alarm_event struct.

Definition at line 507 of file alarm_event.c.

References alarm_event_t::dbus_interface, alarm_event_t::dbus_name, alarm_event_t::dbus_path, alarm_event_t::dbus_service, alarm_event_t::exec_name, alarm_event_t::icon, alarm_event_t::message, alarm_event_t::sound, and alarm_event_t::title.

Referenced by main().

alarm_event_t* alarm_event_get cookie_t  event_cookie  ) 
 

alarm_event_get: : Unique identifier of the alarm.

Fetches alarm defails. Finds an alarm with given identifier and returns alarm_event struct describing it. Returns: Newly allocated alarm_event struct, should be free'd with alarm_event_free().

Definition at line 392 of file alarm_event.c.

References _alarm_event_dbus_call(), _get_id(), ACTION, ALARM_EVENT_GET, alarm_event_t::alarm_time, ALARMD_ERROR_INTERNAL, ALARMD_SUCCESS, alarm_event_t::dbus_interface, dbus_message_iter_get_string, alarm_event_t::dbus_name, alarm_event_t::dbus_path, error_code, alarm_event_t::exec_name, FLAGS, alarm_event_t::flags, ICON, alarm_event_t::icon, INTERFACE, MESSAGE, alarm_event_t::message, NAME, PATH, RECURRENCE, alarm_event_t::recurrence, RECURRENCE_COUNT, alarm_event_t::recurrence_count, alarm_event_t::snooze, SNOOZE, SNOOZE_INT, alarm_event_t::snoozed, SOUND, alarm_event_t::sound, TIME, TITLE, and alarm_event_t::title.

Referenced by main(), and tool_get().

cookie_t* alarm_event_query const time_t  first,
const time_t  last,
int32_t  flag_mask,
int32_t  flags
 

alarm_event_query: : Alarms happening after this time will be returned.

: Alarms: happening before this time will be returned. : A mask describing which flags you're interested in. Pass 0 to get all events. : Values for the flags you're querying.

Queries alarms in given time span. Finds every alarm whose _next_ occurence time is between first and last. Returns: Newly allocated, zero-terminated list of alarm id's, should be free()'d.

Definition at line 341 of file alarm_event.c.

References _alarm_event_dbus_call(), ALARM_EVENT_QUERY, ALARMD_ERROR_INTERNAL, ALARMD_SUCCESS, and error_code.

Referenced by main(), and tool_list().

char* alarm_unescape_string const char *  string  ) 
 

alarm_unescape_string: : The string that should be unescaped.

Unescapes a string escaped with alarm_escape_string. Returns: Newly allocated string, should be freed with free().

Definition at line 615 of file alarm_event.c.

References _alarm_do_unescape(), strchrcount(), and strstrcount().

char* alarm_unescape_string_noalloc char *  string  ) 
 

alarm_unescape_string_noalloc: : The string that should be unescaped.

Unescapes a string escaped with alarm_escape_string. Note, is modified. Returns: .

Definition at line 604 of file alarm_event.c.

References _alarm_do_unescape().

unsigned int alarmd_get_default_snooze void   ) 
 

alarmd_get_default_snooze:

Gets the amount events will be snoozed by default. Returns: The preferred snooze time in minutes.

Definition at line 679 of file alarm_event.c.

References _alarm_event_dbus_call(), ALARMD_ERROR_ARGUMENT, ALARMD_ERROR_INTERNAL, ALARMD_SNOOZE_GET, ALARMD_SUCCESS, and error_code.

alarm_error_t alarmd_get_error void   ) 
 

alarmd_get_error:

Gets the error code for previous action.

Definition at line 634 of file alarm_event.c.

References error_code.

int alarmd_set_default_snooze unsigned int  snooze  ) 
 

alarmd_set_default_snooze: : The preferred snooze time in minutes.

Sets the amount events will be snoozed by default. Returns: 1 on success, 0 on failure.

Definition at line 639 of file alarm_event.c.

References _alarm_event_dbus_call(), ALARMD_ERROR_ARGUMENT, ALARMD_ERROR_INTERNAL, ALARMD_SNOOZE_SET, ALARMD_SUCCESS, and error_code.

static size_t strchrcount const char *  haystack,
const char  needle
[static]
 

Definition at line 103 of file alarm_event.c.

Referenced by alarm_unescape_string().

static size_t strspncount const char *  haystack,
const char *  needles
[static]
 

Definition at line 120 of file alarm_event.c.

Referenced by alarm_escape_string().

static size_t strstrcount const char *  haystack,
const char *  needle
[static]
 

Definition at line 85 of file alarm_event.c.

Referenced by alarm_unescape_string().


Variable Documentation

alarm_error_t error_code [static]
 

Definition at line 83 of file alarm_event.c.

Referenced by _alarm_event_dbus_call(), alarm_event_add(), alarm_event_del(), alarm_event_get(), alarm_event_query(), alarmd_get_default_snooze(), alarmd_get_error(), and alarmd_set_default_snooze().

const char* const property[COUNT] [static]
 

Initial value:

 {
        "time",
        "title",
        "message",
        "sound",
        "icon",
        "interface",
        "service",
        "path",
        "name",
        "flags",
        "action",
        "recurr_interval",
        "recurr_count",
        "snooze_interval",
        "snooze",
}

Definition at line 65 of file alarm_event.c.

Referenced by _get_id(), and alarm_event_add().


Generated on Thu Dec 21 18:23:30 2006 for Alarmd by  doxygen 1.4.2