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 64 of file microfeedfeed.h.
typedef MicrofeedError*(* MicrofeedFeedDownloadItemDataCallback)(MicrofeedFeed *feed, const char *uid, void **data, size_t *length, void *user_data) |
Definition at line 102 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 49 of file microfeedfeed.h.
typedef MicrofeedError*(* MicrofeedFeedMarkCallback)(MicrofeedFeed *feed, const char *uid, int mark_status, void *user_data) |
Definition at line 103 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 101 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 85 of file microfeedfeed.h.
Definition at line 113 of file microfeedfeed.h.
void microfeed_feed_add_free_callback | ( | MicrofeedFeed * | feed, | |
MicrofeedFreeCallback | free_callback, | |||
void * | user_data | |||
) |
Definition at line 188 of file microfeedfeed.c.
References microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_weak_reference_add_free_callback(), _MicrofeedFeed::mutex, and _MicrofeedFeed::weak_reference.
void microfeed_feed_free | ( | MicrofeedFeed * | feed | ) |
Definition at line 118 of file microfeedfeed.c.
References _MicrofeedFeed::callbacks, _MicrofeedFeed::database, MicrofeedFeedCallbacks::destroy, _MicrofeedFeedIterator::feed, _MicrofeedFeed::get_item_data_mutexes, _MicrofeedFeed::item_data_database, _MicrofeedFeed::iterators, microfeed_database_unref(), microfeed_mutex_free(), microfeed_store_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_unref().
MicrofeedItem* microfeed_feed_get_item | ( | MicrofeedFeed * | feed, | |
const char * | uid | |||
) |
Definition at line 343 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 | ) |
const char* microfeed_feed_get_uri | ( | MicrofeedFeed * | feed | ) |
Definition at line 367 of file microfeedfeed.c.
References _MicrofeedFeed::uri.
Referenced by microfeed_publisher_new().
MicrofeedWeakReference* microfeed_feed_get_weak_reference | ( | MicrofeedFeed * | feed | ) |
Definition at line 176 of file microfeedfeed.c.
References microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_weak_reference_new(), _MicrofeedFeed::mutex, and _MicrofeedFeed::weak_reference.
MicrofeedFeedIterator* microfeed_feed_iterate | ( | MicrofeedFeed * | feed, | |
const char * | start_uid, | |||
int | backwards | |||
) |
Definition at line 390 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 415 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 819 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 839 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 866 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 862 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 74 of file microfeedfeed.c.
References _MicrofeedFeed::callbacks, _MicrofeedFeed::database, _MicrofeedFeed::database_index, MicrofeedFeedCallbacks::download_item_data, _MicrofeedFeed::feed_permission, _MicrofeedFeed::get_item_data_mutexes, _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::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 805 of file microfeedfeed.c.
References MICROFEED_FEED_PERMISSION_ADD.
Referenced by microfeed_feed_new().
MicrofeedFeed* microfeed_feed_ref | ( | MicrofeedFeed * | feed | ) |
Definition at line 153 of file microfeedfeed.c.
References microfeed_mutex_lock(), microfeed_mutex_unlock(), _MicrofeedFeed::mutex, and _MicrofeedFeed::reference_count.
Referenced by microfeed_feed_call_modify_item_callback(), microfeed_feed_send_item_data(), and microfeed_feed_update().
void microfeed_feed_ref_item_data | ( | MicrofeedFeed * | feed, | |
const char * | uid | |||
) |
Definition at line 724 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_free_callback | ( | MicrofeedFeed * | feed, | |
MicrofeedFreeCallback | free_callback, | |||
void * | user_data | |||
) |
Definition at line 196 of file microfeedfeed.c.
References microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_weak_reference_remove_free_callback(), _MicrofeedFeed::mutex, and _MicrofeedFeed::weak_reference.
void microfeed_feed_remove_item | ( | MicrofeedFeed * | feed, | |
const char * | uid | |||
) |
Definition at line 277 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 309 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_replace_item | ( | MicrofeedFeed * | feed, | |
MicrofeedItem * | item | |||
) |
Definition at line 209 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 485 of file microfeedfeed.c.
References _MicrofeedFeed::database, microfeed_database_get_data(), microfeed_database_iterate(), microfeed_database_iterator_free(), microfeed_database_iterator_get(), microfeed_database_iterator_next(), microfeed_item_demarshal_properties(), microfeed_item_free(), microfeed_item_new_with_status(), MICROFEED_ITEM_STATUS_NONE, microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_send_feed_signal(), microfeed_publisher_send_item_signal(), MICROFEED_SIGNAL_NAME_FEED_REPUBLISHING_ENDED, MICROFEED_SIGNAL_NAME_FEED_REPUBLISHING_STARTED, MICROFEED_SIGNAL_NAME_ITEM_REPUBLISHED, _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, _MicrofeedFeed::statuses_database, and _MicrofeedFeed::uri.
MicrofeedError* microfeed_feed_send_item_data | ( | MicrofeedFeed * | feed, | |
const char * | uid, | |||
const char * | bus_name | |||
) |
Definition at line 650 of file microfeedfeed.c.
References _MicrofeedFeed::callbacks, _MicrofeedFeed::database_index, MicrofeedFeedCallbacks::download_item_data, _MicrofeedFeed::get_item_data_mutexes, _MicrofeedFeed::item_data_database, microfeed_database_get_data(), microfeed_database_index_get_data(), microfeed_database_replace_data(), microfeed_error_new(), MICROFEED_ERROR_NO_ITEM_DATA, MICROFEED_ERROR_NO_SUCH_ITEM, microfeed_feed_ref(), microfeed_feed_unref(), microfeed_memory_allocate, microfeed_memory_free(), microfeed_mutex_free(), microfeed_mutex_lock(), microfeed_mutex_new(), microfeed_mutex_unlock(), microfeed_publisher_send_item_data_signal(), microfeed_store_get, microfeed_store_insert(), microfeed_store_remove(), GetItemDataMutex::mutex, _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, GetItemDataMutex::reference_count, GetItemDataMutex::uid, _MicrofeedFeed::uri, and _MicrofeedFeed::user_data.
MicrofeedError* microfeed_feed_set_item_status | ( | MicrofeedFeed * | feed, | |
const char * | uid, | |||
MicrofeedItemStatus | status_to_set | |||
) |
Definition at line 530 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_error_new(), MICROFEED_ERROR_NO_SUCH_ITEM, 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_unref | ( | MicrofeedFeed * | feed | ) |
Definition at line 163 of file microfeedfeed.c.
References microfeed_feed_free(), microfeed_mutex_lock(), microfeed_mutex_unlock(), _MicrofeedFeed::mutex, and _MicrofeedFeed::reference_count.
Referenced by microfeed_feed_call_modify_item_callback(), microfeed_feed_send_item_data(), microfeed_feed_update(), microfeed_publisher_free(), and microfeed_publisher_remove_subscriber().
void microfeed_feed_unref_item_data | ( | MicrofeedFeed * | feed, | |
const char * | uid | |||
) |
Definition at line 763 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().
MicrofeedError* microfeed_feed_unset_item_status | ( | MicrofeedFeed * | feed, | |
const char * | uid, | |||
MicrofeedItemStatus | status_to_unset | |||
) |
Definition at line 576 of file microfeedfeed.c.
References _MicrofeedFeed::callbacks, MicrofeedFeedCallbacks::mark_item, microfeed_database_get_data(), microfeed_database_remove_data(), microfeed_database_replace_data(), microfeed_error_new(), MICROFEED_ERROR_NO_SUCH_ITEM, 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.
MicrofeedError* microfeed_feed_unset_item_statuses | ( | MicrofeedFeed * | feed, | |
const char * | start_uid, | |||
const char * | end_uid, | |||
MicrofeedItemStatus | status_to_unset | |||
) |
Definition at line 611 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 449 of file microfeedfeed.c.
References _MicrofeedFeed::callbacks, microfeed_error_free(), microfeed_error_get_message(), microfeed_error_get_name(), microfeed_feed_ref(), microfeed_feed_unref(), microfeed_mutex_lock(), microfeed_mutex_unlock(), microfeed_publisher_send_error_signal(), microfeed_publisher_send_feed_signal(), MICROFEED_SIGNAL_NAME_FEED_UPDATE_ENDED, MICROFEED_SIGNAL_NAME_FEED_UPDATE_STARTED, _MicrofeedFeed::mutex, _MicrofeedFeed::publisher, MicrofeedFeedCallbacks::update, _MicrofeedFeed::updating, _MicrofeedFeed::uri, and _MicrofeedFeed::user_data.