Exemplo n.º 1
0
GSList *grouplist_dialog(Folder *folder)
{
	GNode *node;
	FolderItem *item;

	if (dialog && gtk_widget_get_visible(dialog)) return NULL;

	if (!dialog)
		grouplist_dialog_create();

	news_folder = folder;

	gtk_widget_show(dialog);
	gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
	manage_window_set_transient(GTK_WINDOW(dialog));
	gtk_widget_grab_focus(ok_button);
	gtk_widget_grab_focus(ctree);
	GTK_EVENTS_FLUSH();

	subscribed = NULL;
	for (node = folder->node->children; node != NULL; node = node->next) {
		item = FOLDER_ITEM(node->data);
		subscribed = g_slist_append(subscribed, g_strdup(item->path));
	}

	grouplist_dialog_set_list(NULL, TRUE);

	if (ack) gtk_main();

	manage_window_focus_out(dialog, NULL, NULL);
	gtk_widget_hide(dialog);

	if (!ack) {
		slist_free_strings_full(subscribed);
		subscribed = NULL;

		for (node = folder->node->children; node != NULL;
		     node = node->next) {
			item = FOLDER_ITEM(node->data);
			subscribed = g_slist_append(subscribed,
						    g_strdup(item->path));
		}
	}

	grouplist_clear();

	return subscribed;
}
Exemplo n.º 2
0
AvatarCacheStats *libravatar_cache_stats()
{
    gchar *rootdir;
    AvatarCacheStats *stats;
    GSList *items = NULL;
    guint errors = 0;

    stats = g_new0(AvatarCacheStats, 1);
    cm_return_val_if_fail(stats != NULL, NULL);

    rootdir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
                          LIBRAVATAR_CACHE_DIR, G_DIR_SEPARATOR_S,
                          NULL);
    cache_items_deep_first(rootdir, &items, &errors);
    stats->errors += errors;
    g_slist_foreach(items, (GFunc) cache_stat_item, (gpointer) stats);
    slist_free_strings_full(items);
    g_free(rootdir);

    return stats;
}
Exemplo n.º 3
0
AvatarCleanupResult *libravatar_cache_clean()
{
    gchar *rootdir;
    AvatarCleanupResult *acr;
    GSList *items = NULL;
    guint errors = 0;

    acr = g_new0(AvatarCleanupResult, 1);
    cm_return_val_if_fail(acr != NULL, NULL);

    rootdir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
                          LIBRAVATAR_CACHE_DIR, G_DIR_SEPARATOR_S,
                          NULL);
    cache_items_deep_first(rootdir, &items, &errors);
    acr->e_stat = (gint) errors;

    g_slist_foreach(items, (GFunc) cache_delete_item, (gpointer) acr);

    slist_free_strings_full(items);
    g_free(rootdir);

    return acr;
}
Exemplo n.º 4
0
static void rssyl_expire_items(RFolderItem *ritem, Feed *feed)
{
	FeedItem *item = NULL;
	GSList *i = NULL;
	RSSylExpireItemsCtx *ctx = NULL;
	RFeedCtx *fctx;

	debug_print("RSSyl: rssyl_expire_items()\n");

	g_return_if_fail(ritem != NULL);
	g_return_if_fail(ritem->items != NULL);
	g_return_if_fail(feed != NULL);

	ctx = malloc( sizeof(RSSylExpireItemsCtx) );
	ctx->expired_ids = NULL;

	/* Check each locally stored item, if it is still in the upstream
	 * feed - xnay it if not. */
	for( i = ritem->items; i != NULL; i = i->next ) {
		item = (FeedItem *)i->data;

		/* Comments will be expired later, once we know which parent items
		 * have been expired. */
		if (feed_item_get_parent_id(item) != NULL)
			continue;

		/* Find matching item in the fresh feed. */
		ctx->exists = FALSE;
		ctx->item = item;
		feed_foreach_item(feed, expire_items_func, ctx);

		if( !ctx->exists ) {
			/* No match, add item ids to the list and get rid of it. */
			debug_print("RSSyl: expiring '%s'\n", feed_item_get_id(item));
			ctx->expired_ids = g_slist_prepend(ctx->expired_ids,
					g_strdup(feed_item_get_id(item)));
			fctx = (RFeedCtx *)item->data;
			g_remove(fctx->path);
		}
	}

	/* Now do one more pass over folder contents, and expire comments
	 * whose parents are gone. */
	for( i = ritem->items; i != NULL; i = i->next ) {
		item = (FeedItem *)i->data;

		/* Handle comments expiration. */
		if (feed_item_get_parent_id(item) != NULL) {
			/* If its parent's id is on list of expired ids, this comment
			 * can go as well. */
			if (g_slist_find_custom(ctx->expired_ids,
					feed_item_get_parent_id(item), (GCompareFunc)g_strcmp0)) {
				debug_print("RSSyl: expiring comment '%s'\n", feed_item_get_id(item));
				fctx = (RFeedCtx *)item->data;
				g_remove(fctx->path);
			}
		}
	}

	debug_print("RSSyl: expired %d items\n", g_slist_length(ctx->expired_ids));

	slist_free_strings_full(ctx->expired_ids);
	g_free(ctx);
}
Exemplo n.º 5
0
static void subscribe_newsgroup_cb(GtkAction *action, gpointer data)
{
	FolderView *folderview = (FolderView *)data;
	Folder *folder;
	FolderItem *item;
	FolderItem *rootitem;
	FolderItem *newitem;
	GSList *new_subscr;
	GSList *cur;
	GNode *gnode;
	MainWindow *mainwin = mainwindow_get_mainwindow();
	
	if ((item = folderview_get_selected_item(folderview)) == NULL) return;

	if (mainwin->lock_count || news_folder_locked(item->folder))
		return;

	folder = item->folder;
	cm_return_if_fail(folder != NULL);
	cm_return_if_fail(FOLDER_TYPE(folder) == F_NEWS);
	cm_return_if_fail(folder->account != NULL);

	if ((rootitem = folder_item_parent(item)) == NULL)
		rootitem = item;

	new_subscr = grouplist_dialog(folder);

	/* remove unsubscribed newsgroups */
	for (gnode = folder->node->children; gnode != NULL; ) {
		GNode *next = gnode->next;

		item = FOLDER_ITEM(gnode->data);
		if (g_slist_find_custom(new_subscr, item->path,
					(GCompareFunc)g_ascii_strcasecmp) != NULL) {
			gnode = next;
			continue;
		}

		if (folderview_get_opened_item(folderview) == item) {
			summary_clear_all(folderview->summaryview);
			folderview_close_opened(folderview, TRUE);
		}

		folderview_remove_item(folderview, item);
		folder_item_remove(item);

		gnode = next;
	}

	folderview_freeze(folderview);

	/* add subscribed newsgroups */
	for (cur = new_subscr; cur != NULL; cur = cur->next) {
		gchar *name = (gchar *)cur->data;
		FolderUpdateData hookdata;

		if (news_find_child_item(rootitem, name) != NULL)
			continue;

		newitem = folder_item_new(folder, name, name);
		folder_item_append(rootitem, newitem);

		hookdata.folder = newitem->folder;
		hookdata.update_flags = FOLDER_TREE_CHANGED | FOLDER_ADD_FOLDERITEM;
		hookdata.item = newitem;
		hookdata.item2 = NULL;
		hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
	}

	folderview_thaw(folderview);

	slist_free_strings_full(new_subscr);

	folder_write_list();
}