MicrofeedPublisher
[libmicrofeed-provider - Modules that are used in the provider side]

A publisher's connection to the DBus system. More...

Data Structures

struct  _MicrofeedPublisherCallbacks
 Functions that are called when a publisher receives a message from a subscriber. More...

Typedefs

typedef struct _MicrofeedPublisher MicrofeedPublisher
 Opaque data type representing a publisher.
typedef MicrofeedFeed *(* MicrofeedPublisherInstantiateFeedCallback )(MicrofeedPublisher *publisher, const char *uri, void *user_data)
 A function that is called when a subscriber subscribes a feed that is not previously subscribed by any subscriber.
typedef void(* MicrofeedPublisherNoMoreSubscribersCallback )(MicrofeedPublisher *publisher, void *user_data)
typedef void(* MicrofeedPublisherInitializeSettingsCallback )(MicrofeedPublisher *publisher, void *user_data)
 A function that is called after a new publisher is created.
typedef int(* MicrofeedPublisherUpdateSettingCallback )(MicrofeedPublisher *publisher, const char *key, const char *value, void *user_data)
 A function that is called when a subscriber tries to update a setting.
typedef MicrofeedError *(* MicrofeedPublisherDownloadImageCallback )(MicrofeedPublisher *publisher, const char *uid, void **data, size_t *length, void *user_data)
typedef void(* MicrofeedPublisherTimeoutHandler )(void *data)
typedef void *(* MicrofeedPublisherAddTimeoutCallback )(MicrofeedPublisher *publisher, unsigned long int interval, MicrofeedPublisherTimeoutHandler handler, void *data, void *user_data)
typedef void(* MicrofeedPublisherRemoveTimeoutCallback )(MicrofeedPublisher *publisher, void *timeout_implementation, void *user_data)
typedef struct
_MicrofeedPublisherCallbacks 
MicrofeedPublisherCallbacks
 Functions that are called when a publisher receives a message from a subscriber.

Functions

MicrofeedPublishermicrofeed_publisher_new (const char *unique_identifier, const char *directory, DBusConnection *connection, MicrofeedPublisherCallbacks *callbacks, void *user_data)
 Instantiates a new publisher.
void microfeed_publisher_free (MicrofeedPublisher *publisher)
 Frees the resources allocated for the publisher.
void microfeed_publisher_add_setting (MicrofeedPublisher *publisher, const char *uid, const char *text, const char *unit, const char *type, const char *length, const char *value)
 Adds a new setting or changes other properties than the value of an existing setting in the org.microfeed.Publisher.Settings feed.
void microfeed_publisher_remove_setting (MicrofeedPublisher *publisher, const char *uid)
 Removes a setting from the org.microfeed.Publisher.Settings feed.
char * microfeed_publisher_get_setting_value (MicrofeedPublisher *publisher, const char *uid, const char *default_value)
 Returns a copy of a value of a setting, or if the setting does not exist returns a copy of the given default value.
long int microfeed_publisher_get_setting_value_integer (MicrofeedPublisher *publisher, const char *uid, long int default_value)
 Returns a value of a setting in integer, or if the setting does not exist returns the given default value.
int microfeed_publisher_set_setting_value (MicrofeedPublisher *publisher, const char *uid, const char *value)
 Sets the value of a setting if the setting exists.
MicrofeedThreadmicrofeed_publisher_queue_thread (MicrofeedPublisher *publisher, MicrofeedThreadFunction function, void *data)
MicrofeedThreadmicrofeed_publisher_start_singleton_update_thread (MicrofeedPublisher *publisher, MicrofeedThreadFunction function, void *user_data)
MicrofeedThreadmicrofeed_publisher_get_singleton_update_thread (MicrofeedPublisher *publisher)

Detailed Description

A publisher's connection to the DBus system.

Publisher can be used as a stand-alone module, but it is suggested that an application uses MicrofeedProvider instead and leaves the instantiation of specific publishers to the provider.


Typedef Documentation

Opaque data type representing a publisher.

Definition at line 23 of file microfeedpublisher.h.

typedef void*(* MicrofeedPublisherAddTimeoutCallback)(MicrofeedPublisher *publisher, unsigned long int interval, MicrofeedPublisherTimeoutHandler handler, void *data, void *user_data)

Definition at line 78 of file microfeedpublisher.h.

Functions that are called when a publisher receives a message from a subscriber.

typedef MicrofeedError*(* MicrofeedPublisherDownloadImageCallback)(MicrofeedPublisher *publisher, const char *uid, void **data, size_t *length, void *user_data)

Definition at line 74 of file microfeedpublisher.h.

typedef void(* MicrofeedPublisherInitializeSettingsCallback)(MicrofeedPublisher *publisher, void *user_data)

A function that is called after a new publisher is created.

The function call is a consequence of the CreatePublisher DBus Message.

This function should initialize settings by calling microfeed_publisher_add_setting function.

Definition at line 60 of file microfeedpublisher.h.

typedef MicrofeedFeed*(* MicrofeedPublisherInstantiateFeedCallback)(MicrofeedPublisher *publisher, const char *uri, void *user_data)

A function that is called when a subscriber subscribes a feed that is not previously subscribed by any subscriber.

The function call is a consequence of the SubscribeFeed DBus Message.

Note that this function just instantiates a MicrofeedFeed instance with suitable callbacks rather than creates a whole new feed into a service.

Definition at line 49 of file microfeedpublisher.h.

typedef void(* MicrofeedPublisherNoMoreSubscribersCallback)(MicrofeedPublisher *publisher, void *user_data)

Definition at line 51 of file microfeedpublisher.h.

typedef void(* MicrofeedPublisherRemoveTimeoutCallback)(MicrofeedPublisher *publisher, void *timeout_implementation, void *user_data)

Definition at line 80 of file microfeedpublisher.h.

typedef void(* MicrofeedPublisherTimeoutHandler)(void *data)

Definition at line 76 of file microfeedpublisher.h.

typedef int(* MicrofeedPublisherUpdateSettingCallback)(MicrofeedPublisher *publisher, const char *key, const char *value, void *user_data)

A function that is called when a subscriber tries to update a setting.

This function call is a consequence of the ModifyItem DBus Message targeted at org.microfeed.Publisher.Settings feed.

The setting value is actually changed only if this function returns true. In other case, the error message is automatically generated.

Returns:
Boolean value telling if the updating of the setting value succeeded.

Definition at line 72 of file microfeedpublisher.h.


Function Documentation

void microfeed_publisher_add_setting ( MicrofeedPublisher publisher,
const char *  uid,
const char *  text,
const char *  unit,
const char *  type,
const char *  length,
const char *  value 
)

void microfeed_publisher_free ( MicrofeedPublisher publisher  ) 

char* microfeed_publisher_get_setting_value ( MicrofeedPublisher publisher,
const char *  uid,
const char *  default_value 
)

Returns a copy of a value of a setting, or if the setting does not exist returns a copy of the given default value.

Parameters:
publisher Instantiated MicrofeedPublisher.
key The unique identifier of the setting item.
default_value The value that is returned if the setting does not exist.
Returns:
The value of the setting (must be freed).

Definition at line 251 of file microfeedpublisher.c.

References microfeed_feed_get_item(), microfeed_item_free(), microfeed_item_get_property(), MICROFEED_ITEM_PROPERTY_NAME_SETTING_VALUE, and _MicrofeedPublisher::settings_feed.

long int microfeed_publisher_get_setting_value_integer ( MicrofeedPublisher publisher,
const char *  uid,
long int  default_value 
)

Returns a value of a setting in integer, or if the setting does not exist returns the given default value.

Parameters:
publisher Instantiated MicrofeedPublisher.
key The unique identifier of the setting item.
default_value The value that is returned if the setting does not exist.
Returns:
The value of the setting in integer.

Definition at line 278 of file microfeedpublisher.c.

References microfeed_feed_get_item(), microfeed_item_free(), microfeed_item_get_property(), MICROFEED_ITEM_PROPERTY_NAME_SETTING_VALUE, and _MicrofeedPublisher::settings_feed.

Referenced by microfeed_publisher_new().

MicrofeedThread* microfeed_publisher_get_singleton_update_thread ( MicrofeedPublisher publisher  ) 

MicrofeedPublisher* microfeed_publisher_new ( const char *  publisher_identifier,
const char *  directory,
DBusConnection *  connection,
MicrofeedPublisherCallbacks callbacks,
void *  user_data 
)

Instantiates a new publisher.

The publisher registers a DBus object path /org/microfeed/publisher/<publisher_identifier> and creates or opens a database environment in the given directory using publisher_identifier as a name.

Parameters:
publisher_identifier A string containing unique publisher identifier.
directory A directory where the database environment is created or opened (if exists).
connection A DBus connection.
callbacks Functions that are called when a publisher receives a message from a subscriber.
user_data A pointer to user data that is given as a parameter when a callback function is called.
Returns:
Instantiated MicrofeedPublisher.

Definition at line 132 of file microfeedpublisher.c.

References _MicrofeedPublisher::callbacks, _MicrofeedPublisher::connection, _MicrofeedPublisher::database_environment, _MicrofeedPublisher::feeds, _MicrofeedPublisher::identifier, _MicrofeedPublisher::image_properties, _MicrofeedPublisher::images_feed, microfeed_database_environment_new(), MICROFEED_DBUS_OBJECT_PATH_PREFIX_PUBLISHER, microfeed_feed_add_subscriber(), microfeed_feed_get_uri(), microfeed_feed_new(), MICROFEED_FEED_PERMISSION_NONE, MICROFEED_FEED_URI_IMAGES, MICROFEED_FEED_URI_SETTINGS, MICROFEED_ITEM_PROPERTY_NAME_CONTENT_IMAGE, MICROFEED_ITEM_PROPERTY_NAME_USER_IMAGE, microfeed_memory_allocate, microfeed_memory_free(), microfeed_publisher_get_setting_value_integer(), MICROFEED_PUBLISHER_IDENTIFIER_SEPARATOR_CHAR, microfeed_store_compare_keys_direct(), microfeed_store_insert(), microfeed_store_new_sorted(), microfeed_thread_pool_new_with_exit_callback(), microfeed_util_string_concatenate(), _MicrofeedPublisher::object_path, _MicrofeedPublisher::settings_feed, _MicrofeedPublisher::subscribers, _MicrofeedPublisher::thread_pool, _MicrofeedPublisher::timeouts, and _MicrofeedPublisher::user_data.

MicrofeedThread* microfeed_publisher_queue_thread ( MicrofeedPublisher publisher,
MicrofeedThreadFunction  function,
void *  data 
)

void microfeed_publisher_remove_setting ( MicrofeedPublisher publisher,
const char *  uid 
)

Removes a setting from the org.microfeed.Publisher.Settings feed.

Parameters:
publisher Instantiated MicrofeedPublisher.
uid The unique identifier of the setting item.

Definition at line 239 of file microfeedpublisher.c.

References microfeed_feed_remove_item(), and _MicrofeedPublisher::settings_feed.

int microfeed_publisher_set_setting_value ( MicrofeedPublisher publisher,
const char *  uid,
const char *  value 
)

Sets the value of a setting if the setting exists.

Parameters:
publisher Instantiated MicrofeedPublisher.
uid The unique identified of the setting item.
value The new value for the setting.
Returns:
A boolean value: true, if the operation succeeded, or false if the setting does not exist.

Definition at line 310 of file microfeedpublisher.c.

References microfeed_feed_get_item(), microfeed_feed_replace_item(), microfeed_item_free(), MICROFEED_ITEM_PROPERTY_NAME_SETTING_VALUE, microfeed_item_set_property(), and _MicrofeedPublisher::settings_feed.

MicrofeedThread* microfeed_publisher_start_singleton_update_thread ( MicrofeedPublisher publisher,
MicrofeedThreadFunction  function,
void *  user_data 
)


Generated on Fri Jun 26 21:48:58 2009 for Microfeed by  doxygen 1.5.6