/* * Check if folder of a node changed in TinyTinyRSS and move * node to the correct folder. */ static void ttrss_source_update_folder (ttrssSourcePtr source, nodePtr node) { nodePtr parent; gint category; const gchar *feedId; feedId = (const gchar *)metadata_list_get (node->subscription->metadata, "ttrss-feed-id"); if (!feedId) return; category = GPOINTER_TO_INT (g_hash_table_lookup (source->categories, GINT_TO_POINTER (atoi (feedId)))); parent = g_hash_table_lookup (source->categoryToNode, GINT_TO_POINTER (category)); if (!parent) return; if (parent != node->parent) { debug2 (DEBUG_UPDATE, "TinyTinyRSS Moving node \"%s\" to folder \"%s\"", node->title, parent->title); node_reparent (node, parent); } /* if feed has no category and parent is not source root, reparent to source root */ if (parent == NULL && node->parent != source->root) { debug1 (DEBUG_UPDATE, "TinyTinyRSS Moving node \"%s\" back to root", node->title); node_reparent (node, source->root); } }
/* * Check if folder of a node changed in Google Reader and move * node to the folder with the same name. */ static void aol_source_update_folder (xmlNodePtr match, AolSourcePtr gsource, nodePtr node) { xmlNodePtr xml; xmlChar *label; const gchar *ptitle; nodePtr parent; /* check if label of a feed changed */ parent = node->parent; ptitle = node_get_title (parent); xml = xpath_find (match, "./list[@name='categories']/object/string[@name='label']"); if (xml) { label = xmlNodeListGetString (xml->doc, xml->xmlChildrenNode, 1); if (parent == gsource->root || ! g_str_equal (label, ptitle)) { debug2 (DEBUG_UPDATE, "GSource feed label changed for %s to '%s'", node->id, label); parent = aol_source_find_or_create_folder ((gchar*)label, gsource->root); node_reparent (node, parent); } xmlFree (label); } else { /* if feed has no label and parent is not gsource root, reparent to gsource root */ if (parent != gsource->root) node_reparent (node, gsource->root); } }