MicrofeedFeed is thread-aware, because it implements internal lock. Usually an MicrofeedFeed object is accessed simultaneously from multiple threads, for example from a feed update thread and from the main thread responding to DBus messages. When one thread is accessing the object, others are waiting.
Note that MicrofeedFeed launches a new thread for every update and similar operation that may take some time. Thus, you have to call microfeed_thread_init at the very first and microfeed_thread_cleanup at the very last in your application.
typedef struct _MicrofeedFeed MicrofeedFeed |
typedef void(* MicrofeedFeedDestroyCallback)(MicrofeedFeed *feed, void *user_data) |
Definition at line 46 of file microfeedfeed.h.
typedef MicrofeedError*(* MicrofeedFeedDownloadItemDataCallback)(MicrofeedFeed *feed, const char *uid, void **data, size_t *length, void *user_data) |
Definition at line 84 of file microfeedfeed.h.
typedef struct _MicrofeedFeedIterator MicrofeedFeedIterator |
Opaque data type representing Microfeed feed iterator that iterates over the items of the feed.
Definition at line 31 of file microfeedfeed.h.
typedef MicrofeedError*(* MicrofeedFeedMarkCallback)(MicrofeedFeed *feed, const char *uid, int mark_status, void *user_data) |
Definition at line 85 of file microfeedfeed.h.
typedef MicrofeedError*(* MicrofeedFeedModifyItemCallback)(MicrofeedFeed *feed, MicrofeedItem *existing_item, MicrofeedItem *new_item, void *user_data) |
This function is called when a subscriber wants to add a new item, modify an existing item, or delete an existing item.
If the existing item parameter is null, the new item parameter contains a new item to be added. If the new item parameter is null, the existing item parameter contains an esiting item to be deleted. In other case, the existing item parameter contains the current properties of a modified item and the new item parameter contains the new properties for the existing item.
feed | Instantiated MicrofeedFeed. | |
existing_item | An existing item or NULL. | |
new_item | A new item or NULL. | |
user_data | The pointer given when the feed has been instantiated. |
Definition at line 83 of file microfeedfeed.h.
typedef MicrofeedError*(* MicrofeedFeedUpdateCallback)(MicrofeedFeed *feed, int user_initiated, void *user_data) |
This function is called when a subscriber wants to update the feed.
The actual network operations are happening here. The function is called in a separate thread, so it may also block. For pull-type services, typically one update cycle is implemented. For push-type services, this function initializes the connection and waits for the events indefinitely. However, the function must check peridiocally if the subscriber count (microfeed_feed_get_subscriber_count) has dropped to zero and in that case close the connection and return.
The update thread has one reference to the feed meaning that the feed is not freed before the thread finishes. The reference count is incremented and decremented automatically.
If this function returns non-NULL error object, a signal to subscribers is sent.
feed | Instantiated MicrofeedFeed. | |
user_intiatied | Boolean value telling if the update is requested by a subscriber (true), or periodical event (false). | |
user_data | The pointer given when the feed has been instantiated. |
Definition at line 67 of file microfeedfeed.h.
Definition at line 95 of file microfeedfeed.h.
void microfeed_feed_add_subscriber | ( | MicrofeedFeed * | feed, | |
const char * | bus_name | |||
) |
Definition at line 340 of file microfeedfeed.c.
References microfeed_mutex_lock(), microfeed_mutex_unlock(), _MicrofeedFeed::mutex, _MicrofeedFeed::reference_count, and _MicrofeedFeed::subscriber_count.
Referenced by microfeed_publisher_new().
void microfeed_feed_free | ( | MicrofeedFeed * | feed | ) |
Definition at line 122 of file microfeedfeed.c.
References _MicrofeedFeed::callbacks, _MicrofeedFeed::database, MicrofeedFeedCallbacks::destroy, _MicrofeedFeedIterator::feed, _MicrofeedFeed::item_data_database, _MicrofeedFeed::iterators, microfeed_database_unref(), microfeed_mutex_free(), microfeed_weak_reference_invalidate(), _MicrofeedFeed::mutex, _MicrofeedFeedIterator::next, _MicrofeedFeed::publisher, _MicrofeedFeed::statuses_database, _MicrofeedFeed::subscriber_count, MicrofeedFeedCallbacks::update, _MicrofeedFeed::uri, _MicrofeedFeed::user_data, and _MicrofeedFeed::weak_reference.
Referenced by microfeed_feed_remove_subscriber(), and microfeed_feed_unref().
MicrofeedItem* microfeed_feed_get_item | ( | MicrofeedFeed * | feed, | |
const char * | uid | |||
) |
Definition at line 361 of file microfeedfeed.c.
References _MicrofeedFeed::database_index, microfeed_database_index_get_data(), microfeed_item_demarshal_properties(), microfeed_item_new(), microfeed_mutex_lock(), microfeed_mutex_unlock(), and _MicrofeedFeed::mutex.
Referenced by microfeed_publisher_add_setting(), microfeed_publisher_get_setting_value(), microfeed_publisher_get_setting_value_integer(), and microfeed_publisher_set_setting_value().
MicrofeedItem* microfeed_feed_get_metadata_item | ( | MicrofeedFeed * | feed | ) |
const char* microfeed_feed_get_name | ( | MicrofeedFeed * | feed | ) |
MicrofeedPublisher* microfeed_feed_get_publisher | ( | MicrofeedFeed * | feed | ) |
int microfeed_feed_get_subscriber_count | ( | MicrofeedFeed * | feed | ) |
Definition at line 349 of file microfeedfeed.c.
References microfeed_mutex_lock(), microfeed_mutex_unlock(), _MicrofeedFeed::mutex, and _MicrofeedFeed::subscriber_count.
Referenced by microfeed_publisher_remove_subscriber().
const char* microfeed_feed_get_uri | ( | MicrofeedFeed * | feed | ) |
Definition at line 385 of file microfeedfeed.c.
References _MicrofeedFeed::uri.
Referenced by microfeed_publisher_new().
MicrofeedWeakReference* microfeed_feed_get_weak_reference | ( | MicrofeedFeed * | feed | ) |
Definition at line 178 of file microfeedfeed.c.
References microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_weak_reference_new(), _MicrofeedFeed::mutex, and _MicrofeedFeed::weak_reference.
int microfeed_feed_is_using_threads | ( | MicrofeedFeed * | feed | ) |
MicrofeedFeedIterator* microfeed_feed_iterate | ( | MicrofeedFeed * | feed, | |
const char * | start_uid, | |||
int | backwards | |||
) |
Definition at line 408 of file microfeedfeed.c.
References _MicrofeedFeedIterator::backwards, _MicrofeedFeed::database_index, _MicrofeedFeedIterator::database_iterator, _MicrofeedFeedIterator::feed, _MicrofeedFeed::iterators, microfeed_database_index_iterate(), microfeed_memory_allocate, microfeed_mutex_lock(), microfeed_mutex_unlock(), _MicrofeedFeed::mutex, _MicrofeedFeedIterator::next, _MicrofeedFeedIterator::previous, and _MicrofeedFeedIterator::timeline.
MicrofeedFeedIterator* microfeed_feed_iterate_timeline | ( | MicrofeedFeed * | feed, | |
time_t | start_timestamp, | |||
int | backwards | |||
) |
Definition at line 433 of file microfeedfeed.c.
References _MicrofeedFeedIterator::backwards, _MicrofeedFeed::database, _MicrofeedFeedIterator::database_iterator, _MicrofeedFeedIterator::feed, _MicrofeedFeed::iterators, microfeed_database_iterate(), microfeed_memory_allocate, microfeed_mutex_lock(), microfeed_mutex_unlock(), _MicrofeedFeed::mutex, _MicrofeedFeedIterator::next, _MicrofeedFeedIterator::previous, and _MicrofeedFeedIterator::timeline.
void microfeed_feed_iterator_free | ( | MicrofeedFeedIterator * | iterator | ) |
Definition at line 771 of file microfeedfeed.c.
References _MicrofeedFeedIterator::database_iterator, _MicrofeedFeedIterator::feed, _MicrofeedFeed::iterators, microfeed_database_iterator_free(), microfeed_memory_free(), _MicrofeedFeedIterator::next, and _MicrofeedFeedIterator::previous.
MicrofeedFeed* microfeed_feed_iterator_get_feed | ( | MicrofeedFeedIterator * | iterator | ) |
MicrofeedItem* microfeed_feed_iterator_get_item | ( | MicrofeedFeedIterator * | iterator | ) |
Definition at line 791 of file microfeedfeed.c.
References _MicrofeedFeedIterator::database_iterator, _MicrofeedFeedIterator::feed, microfeed_database_iterator_get(), microfeed_item_demarshal_properties(), microfeed_item_new(), microfeed_mutex_lock(), microfeed_mutex_unlock(), and _MicrofeedFeed::mutex.
int microfeed_feed_iterator_jump_and_remove_previous_items | ( | MicrofeedFeedIterator * | iterator, | |
const char * | uid | |||
) |
Definition at line 818 of file microfeedfeed.c.
References _MicrofeedFeedIterator::backwards, _MicrofeedFeed::database, _MicrofeedFeed::database_index, _MicrofeedFeedIterator::database_iterator, _MicrofeedFeedIterator::feed, microfeed_database_index_get_data(), microfeed_database_index_remove_data_range(), microfeed_database_iterator_get(), microfeed_database_iterator_next(), microfeed_database_remove_data_range(), microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_send_item_uid_signal(), MICROFEED_SIGNAL_NAME_ITEM_REMOVED, _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::statuses_database, _MicrofeedFeedIterator::timeline, and _MicrofeedFeed::uri.
void microfeed_feed_iterator_next | ( | MicrofeedFeedIterator * | iterator | ) |
Definition at line 814 of file microfeedfeed.c.
References _MicrofeedFeedIterator::database_iterator, and microfeed_database_iterator_next().
MicrofeedFeed* microfeed_feed_new | ( | MicrofeedPublisher * | publisher, | |
const char * | uri, | |||
const char * | name, | |||
MicrofeedFeedPermission | feed_permission, | |||
MicrofeedFeedCallbacks * | callbacks, | |||
void * | user_data | |||
) |
Definition at line 78 of file microfeedfeed.c.
References _MicrofeedFeed::callbacks, _MicrofeedFeed::database, _MicrofeedFeed::database_index, MicrofeedFeedCallbacks::download_item_data, _MicrofeedFeed::feed_permission, _MicrofeedFeed::item_data_database, _MicrofeedFeed::iterators, _MicrofeedFeed::metadata_item, microfeed_database_environment_get_database(), microfeed_database_get_index(), microfeed_feed_permission_to_string(), microfeed_item_new(), MICROFEED_ITEM_PROPERTY_NAME_FEED_NAME, MICROFEED_ITEM_PROPERTY_NAME_FEED_PERMISSION, microfeed_item_set_property(), MICROFEED_ITEM_UID_FEED_METADATA, microfeed_memory_allocate, microfeed_mutex_new(), microfeed_publisher_get_database_environment(), microfeed_store_new_sorted(), microfeed_util_string_concatenate(), _MicrofeedFeed::mutex, _MicrofeedFeed::name, _MicrofeedFeed::publisher, _MicrofeedFeed::reference_count, _MicrofeedFeed::send_item_data_datas, _MicrofeedFeed::statuses_database, _MicrofeedFeed::uri, _MicrofeedFeed::user_data, and _MicrofeedFeed::weak_reference.
Referenced by microfeed_publisher_new().
MicrofeedFeedPermission microfeed_feed_permission_from_string | ( | const char * | string | ) |
char* microfeed_feed_permission_to_string | ( | MicrofeedFeedPermission | item_permission | ) |
Definition at line 757 of file microfeedfeed.c.
References MICROFEED_FEED_PERMISSION_ADD.
Referenced by microfeed_feed_new().
MicrofeedFeed* microfeed_feed_ref | ( | MicrofeedFeed * | feed | ) |
Definition at line 155 of file microfeedfeed.c.
References microfeed_mutex_lock(), microfeed_mutex_unlock(), _MicrofeedFeed::mutex, and _MicrofeedFeed::reference_count.
void microfeed_feed_ref_item_data | ( | MicrofeedFeed * | feed, | |
const char * | uid | |||
) |
Definition at line 676 of file microfeedfeed.c.
References _MicrofeedFeed::database, _MicrofeedFeed::item_data_database, microfeed_database_get_data_partial(), microfeed_database_replace_data(), microfeed_database_replace_data_partial(), microfeed_item_get_timestamp(), microfeed_item_marshal_properties(), microfeed_item_new(), microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_send_item_signal(), MICROFEED_SIGNAL_NAME_ITEM_ADDED, _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::statuses_database, and _MicrofeedFeed::uri.
Referenced by microfeed_publisher_handle_item_property_change().
void microfeed_feed_remove_item | ( | MicrofeedFeed * | feed, | |
const char * | uid | |||
) |
Definition at line 274 of file microfeedfeed.c.
References _MicrofeedFeed::database_index, _MicrofeedFeed::item_data_database, microfeed_database_index_get_data(), microfeed_database_index_remove_data(), microfeed_database_remove_data(), microfeed_item_demarshal_properties(), microfeed_item_free(), microfeed_item_new(), microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_handle_item_property_change(), microfeed_publisher_send_item_uid_signal(), MICROFEED_SIGNAL_NAME_ITEM_REMOVED, _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::statuses_database, and _MicrofeedFeed::uri.
Referenced by microfeed_publisher_remove_setting().
void microfeed_feed_remove_items | ( | MicrofeedFeed * | feed, | |
const char * | start_uid, | |||
const char * | end_uid | |||
) |
Definition at line 306 of file microfeedfeed.c.
References _MicrofeedFeed::database_index, _MicrofeedFeed::item_data_database, microfeed_database_index_iterate(), microfeed_database_index_remove_data(), microfeed_database_iterator_free(), microfeed_database_iterator_get(), microfeed_database_iterator_next(), microfeed_database_remove_data(), microfeed_item_demarshal_properties(), microfeed_item_free(), microfeed_item_new(), microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_handle_item_property_change(), microfeed_publisher_send_item_uid_signal(), MICROFEED_SIGNAL_NAME_ITEM_REMOVED, _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::statuses_database, and _MicrofeedFeed::uri.
void microfeed_feed_remove_subscriber | ( | MicrofeedFeed * | feed, | |
const char * | bus_name | |||
) |
Definition at line 467 of file microfeedfeed.c.
References microfeed_feed_free(), microfeed_mutex_lock(), microfeed_mutex_unlock(), _MicrofeedFeed::mutex, _MicrofeedFeed::reference_count, and _MicrofeedFeed::subscriber_count.
Referenced by microfeed_publisher_free(), and microfeed_publisher_remove_subscriber().
void microfeed_feed_replace_item | ( | MicrofeedFeed * | feed, | |
MicrofeedItem * | item | |||
) |
Definition at line 206 of file microfeedfeed.c.
References _MicrofeedFeed::database, _MicrofeedFeed::database_index, microfeed_database_get_data(), microfeed_database_index_get_data(), microfeed_database_index_remove_data(), microfeed_database_replace_data(), microfeed_item_demarshal_properties(), microfeed_item_free(), microfeed_item_get_timestamp(), microfeed_item_get_uid(), microfeed_item_marshal_properties(), microfeed_item_new_with_status(), MICROFEED_ITEM_STATUS_ACTIVE, MICROFEED_ITEM_STATUS_NEW, microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_handle_item_property_change(), microfeed_publisher_send_item_signal(), MICROFEED_SIGNAL_NAME_ITEM_ADDED, MICROFEED_SIGNAL_NAME_ITEM_CHANGED, _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::statuses_database, and _MicrofeedFeed::uri.
Referenced by microfeed_publisher_add_setting(), and microfeed_publisher_set_setting_value().
void microfeed_feed_republish | ( | MicrofeedFeed * | feed, | |
const char * | start_uid, | |||
const char * | end_uid, | |||
unsigned int | max_count, | |||
const char * | bus_name | |||
) |
Definition at line 519 of file microfeedfeed.c.
References RepublishingData::bus_name, RepublishingData::end_uid, RepublishingData::feed, RepublishingData::max_count, microfeed_memory_allocate, microfeed_publisher_queue_thread(), _MicrofeedFeed::publisher, and RepublishingData::start_uid.
void microfeed_feed_send_item_data | ( | MicrofeedFeed * | feed, | |
const char * | uid, | |||
const char * | bus_name | |||
) |
Definition at line 639 of file microfeedfeed.c.
References _SendItemDataData::bus_names, _MicrofeedFeed::database_index, _SendItemDataData::feed, _MicrofeedFeed::item_data_database, microfeed_database_get_data(), microfeed_database_index_get_data(), MICROFEED_ERROR_NO_ITEM_DATA, MICROFEED_ERROR_NO_SUCH_ITEM, microfeed_memory_allocate, microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_queue_thread(), microfeed_publisher_send_error_signal(), microfeed_publisher_send_item_data_signal(), microfeed_store_compare_keys_direct(), microfeed_store_get, microfeed_store_get_key_direct(), microfeed_store_insert(), microfeed_store_new_sorted(), _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::send_item_data_datas, _SendItemDataData::uid, and _MicrofeedFeed::uri.
int microfeed_feed_set_item_status | ( | MicrofeedFeed * | feed, | |
const char * | uid, | |||
MicrofeedItemStatus | status_to_set | |||
) |
Definition at line 532 of file microfeedfeed.c.
References _MicrofeedFeed::callbacks, _MicrofeedFeed::database_index, MicrofeedFeedCallbacks::mark_item, microfeed_database_get_data(), microfeed_database_index_get_data(), microfeed_database_remove_data(), microfeed_database_replace_data(), MICROFEED_ITEM_STATUS_MARKED, microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_send_status_changed_signal(), _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::statuses_database, _MicrofeedFeed::uri, and _MicrofeedFeed::user_data.
void microfeed_feed_set_name | ( | MicrofeedFeed * | feed, | |
const char * | name | |||
) |
void microfeed_feed_stop_update | ( | MicrofeedFeed * | feed | ) |
Definition at line 195 of file microfeedfeed.c.
References microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_get_singleton_update_thread(), microfeed_publisher_send_feed_signal(), MICROFEED_SIGNAL_NAME_FEED_UPDATE_ENDED, _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::updating, and _MicrofeedFeed::uri.
void microfeed_feed_unref | ( | MicrofeedFeed * | feed | ) |
Definition at line 165 of file microfeedfeed.c.
References microfeed_feed_free(), microfeed_mutex_lock(), microfeed_mutex_unlock(), _MicrofeedFeed::mutex, and _MicrofeedFeed::reference_count.
Referenced by microfeed_publisher_remove_subscriber().
void microfeed_feed_unref_item_data | ( | MicrofeedFeed * | feed, | |
const char * | uid | |||
) |
Definition at line 715 of file microfeedfeed.c.
References _MicrofeedFeed::database_index, _MicrofeedFeed::item_data_database, microfeed_database_get_data_partial(), microfeed_database_index_remove_data(), microfeed_database_remove_data(), microfeed_database_replace_data_partial(), microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_send_item_uid_signal(), MICROFEED_SIGNAL_NAME_ITEM_REMOVED, _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::statuses_database, and _MicrofeedFeed::uri.
Referenced by microfeed_publisher_handle_item_property_change().
int microfeed_feed_unset_item_status | ( | MicrofeedFeed * | feed, | |
const char * | uid, | |||
MicrofeedItemStatus | status_to_unset | |||
) |
Definition at line 573 of file microfeedfeed.c.
References _MicrofeedFeed::callbacks, MicrofeedFeedCallbacks::mark_item, microfeed_database_get_data(), microfeed_database_remove_data(), microfeed_database_replace_data(), MICROFEED_ITEM_STATUS_MARKED, microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_send_status_changed_signal(), _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::statuses_database, _MicrofeedFeed::uri, and _MicrofeedFeed::user_data.
void microfeed_feed_unset_item_statuses | ( | MicrofeedFeed * | feed, | |
const char * | start_uid, | |||
const char * | end_uid, | |||
MicrofeedItemStatus | status_to_unset | |||
) |
Definition at line 605 of file microfeedfeed.c.
References _MicrofeedFeed::callbacks, MicrofeedFeedCallbacks::mark_item, microfeed_database_iterate(), microfeed_database_iterator_free(), microfeed_database_iterator_get(), microfeed_database_iterator_next(), microfeed_database_remove_data(), microfeed_database_replace_data(), MICROFEED_ITEM_STATUS_MARKED, microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_send_status_changed_signal(), _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::statuses_database, _MicrofeedFeed::uri, and _MicrofeedFeed::user_data.
void microfeed_feed_update | ( | MicrofeedFeed * | feed, | |
const char * | bus_name | |||
) |
Definition at line 480 of file microfeedfeed.c.
References _MicrofeedFeed::callbacks, microfeed_error_free(), microfeed_error_get_message(), microfeed_error_get_name(), microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_get_singleton_update_thread(), microfeed_publisher_queue_thread(), microfeed_publisher_send_error_signal(), microfeed_publisher_send_feed_signal(), MICROFEED_SIGNAL_NAME_FEED_UPDATE_STARTED, _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::reference_count, MicrofeedFeedCallbacks::update, _MicrofeedFeed::updating, _MicrofeedFeed::uri, and _MicrofeedFeed::user_data.