示例#1
0
/**
 * In difference to all the other item state handling methods
 * item_state_set_all_read does not immediately apply the
 * changes to the GUI because it is usually called recursively
 * and would be to slow. Instead the node structure flag for
 * recounting is set. By calling feedlist_update() afterwards
 * those recounts are executed and applied to the GUI.
 */
void
itemset_mark_read (nodePtr node)
{
    itemSetPtr	itemSet;

    if (!node->unreadCount)
        return;

    itemSet = node_get_itemset (node);
    GList *iter = itemSet->ids;
    while (iter) {
        gulong id = GPOINTER_TO_UINT (iter->data);
        itemPtr item = item_load (id);
        if (item) {
            if (!item->readStatus) {
                nodePtr node;

                node = node_from_id (item->nodeId);
                if (node) {
                    item_state_set_recount_flag (node);
                    node_source_item_mark_read (node, item, TRUE);
                } else {
                    g_warning ("itemset_mark_read() on lost item (id=%lu, node id=%s)!", item->id, item->nodeId);
                }

                debug_start_measurement (DEBUG_GUI);

                GSList *duplicates = db_item_get_duplicate_nodes (item->sourceId);
                GSList *duplicate = duplicates;
                while (duplicate) {
                    gchar *nodeId = (gchar *)duplicate->data;
                    nodePtr affectedNode = node_from_id (nodeId);
                    if (affectedNode)
                        item_state_set_recount_flag (affectedNode);
                    g_free (nodeId);
                    duplicate = g_slist_next (duplicate);
                }
                g_slist_free(duplicates);

                debug_end_measurement (DEBUG_GUI, "mark read of duplicates");
            }
            item_unload (item);
        }
        iter = g_list_next (iter);
    }
}
示例#2
0
/**
 * In difference to all the other item state handling methods
 * item_state_set_all_read does not immediately apply the 
 * changes to the GUI because it is usually called recursively
 * and would be to slow. Instead the node structure flag for
 * recounting is set. By calling feedlist_update() afterwards
 * those recounts are executed and applied to the GUI.
 */
void
itemset_mark_read (nodePtr node)
{
	itemSetPtr	itemSet;

	itemSet = node_get_itemset (node);
	GList *iter = itemSet->ids;
	while (iter) {
		gulong id = GPOINTER_TO_UINT (iter->data);
		itemPtr item = item_load (id);
		if (item) {
			if (!item->readStatus) {
				nodePtr node = node_from_id (item->nodeId);
				if (node) {
					item_state_set_recount_flag (node);
					node_source_item_mark_read (node, item, TRUE);
				}

				debug_start_measurement (DEBUG_GUI);

				GSList *duplicates = db_item_get_duplicate_nodes (item->sourceId);
				GSList *duplicate = duplicates;
				while (duplicate) {
					gchar *nodeId = (gchar *)duplicate->data;
					nodePtr affectedNode = node_from_id (nodeId);
					if (affectedNode)
						item_state_set_recount_flag (affectedNode);
					g_free (nodeId);
					duplicate = g_slist_next (duplicate);
				}
				g_slist_free(duplicates);

				debug_end_measurement (DEBUG_GUI, "mark read of duplicates");
			}
			item_unload (item);
		}
		iter = g_list_next (iter);
	}

	// FIXME: why not call itemset_free (itemSet); here? Crashes!
}