Exemplo n.º 1
0
static gboolean foldersel_search_name_func(GtkTreeModel *model, gint column,
		const gchar *key, GtkTreeIter *iter, gpointer search_data)
{
	gchar *store_string = NULL;
	FolderItem *item;
	gboolean retval;

	if (column == FOLDERSEL_FOLDERNAME) {
		/* get the name of the FolderItem, not the displayed string */
		gtk_tree_model_get(model, iter,
			   FOLDERSEL_FOLDERITEM, &item, -1);
		store_string = folder_item_get_name(item);
	} else {
		gtk_tree_model_get(model, iter, column, &store_string, -1);
	}

	if (!store_string || !key)
		return FALSE;

	retval = (strcasestr(store_string, key) == NULL);

	g_free(store_string);

	return retval;
}
Exemplo n.º 2
0
/* Helper function for foldercheck_insert_gnode_in_store */
static void foldercheck_append_item(GtkTreeStore *store, FolderItem *item,
				    GtkTreeIter *iter, GtkTreeIter *parent)
{
  gchar *name, *tmpname;
  GdkPixbuf *pixbuf, *pixbuf_open;

  name = tmpname = folder_item_get_name(item);

  if (item->stype != F_NORMAL && FOLDER_IS_LOCAL(item->folder)) {
    switch (item->stype) {
    case F_INBOX:
      if (!strcmp2(item->name, INBOX_DIR))
	name = "Inbox";
      break;
    case F_OUTBOX:
      if (!strcmp2(item->name, OUTBOX_DIR))
	name = "Sent";
      break;
    case F_QUEUE:
      if (!strcmp2(item->name, QUEUE_DIR))
	name = "Queue";
      break;
    case F_TRASH:
      if (!strcmp2(item->name, TRASH_DIR))
	name = "Trash";
      break;
    case F_DRAFT:
      if (!strcmp2(item->name, DRAFT_DIR))
	name = "Drafts";
      break;
    default:
      break;
    }
  }

  if (folder_has_parent_of_type(item, F_QUEUE) && item->total_msgs > 0) {
    name = g_strdup_printf("%s (%d)", name, item->total_msgs);
  } else if (item->unread_msgs > 0) {
    name = g_strdup_printf("%s (%d)", name, item->unread_msgs);
  } else
    name = g_strdup(name);
  
  pixbuf = item->no_select ? foldernoselect_pixbuf : folder_pixbuf;
  pixbuf_open =
    item->no_select ? foldernoselectopen_pixbuf : folderopen_pixbuf;
  
  /* insert this node */
  gtk_tree_store_append(store, iter, parent);
  gtk_tree_store_set(store, iter,
		     FOLDERCHECK_FOLDERNAME, name,
		     FOLDERCHECK_FOLDERITEM, item,
		     FOLDERCHECK_PIXBUF, pixbuf,
		     FOLDERCHECK_PIXBUF_OPEN, pixbuf_open,
		     -1);

  g_free(tmpname);
}
Exemplo n.º 3
0
static void free_msg_trash(MsgTrash* trash) {
    if (trash) {
        debug_print("Freeing files in %s\n", folder_item_get_name(trash->item));
        if (trash->msgs) {
            g_slist_free(trash->msgs);
        }
        g_free(trash);
    }
}
Exemplo n.º 4
0
void archive_free_archived_files() {
    MsgTrash* mt = NULL;
    gint    res;
    GSList* l = NULL;
   
    for (l = msg_trash_list; l; l = g_slist_next(l)) {
        mt = (MsgTrash *) l->data;
        debug_print("Trashing messages in folder: %s\n", 
                folder_item_get_name(mt->item));
        res = folder_item_remove_msgs(mt->item, mt->msgs);
        debug_print("Result was %d\n", res);
        free_msg_trash(mt);
    }
    g_slist_free(msg_trash_list);
    msg_trash_list = NULL;
}
Exemplo n.º 5
0
static void rssyl_update_format_func(FolderItem *item, gpointer data)
{
	RFolderItem *ritem;
	RUpdateFormatCtx *ctx = (RUpdateFormatCtx *)data;
	Folder *f = NULL;
	FolderItem *new_item = NULL;
	gchar *name;
	OldRFeed *of;

	if( !IS_RSSYL_FOLDER_ITEM(item) )
		return;

	/* Do not do anything once we reached first new folder
	 * (which we created earlier in this process) */
	if( ctx->reached_first_new )
		return;

	if( item->folder == ctx->n_first ) {
		ctx->reached_first_new = TRUE;
		debug_print("RSSyl: (FORMAT) reached first new folder\n");
		return;
	}

	debug_print("RSSyl: (FORMAT) item '%s'\n", item->name);

	if( folder_item_parent(item) == NULL ) {
		/* Root rssyl folder */
		ctx->oldroots = g_slist_prepend(ctx->oldroots, item);

		/* Create its counterpart */
		name = rssyl_strreplace(folder_item_get_name(item), " (RSSyl)", "");
		debug_print("RSSyl: (FORMAT) adding new root folder '%s'\n", name);
		f = folder_new(rssyl_folder_get_class(), name, NULL);
		g_free(name);
		g_return_if_fail(f != NULL);
		folder_add(f);

		folder_write_list();

		new_item = FOLDER_ITEM(f->node->data);

		/* If user has more than one old rssyl foldertrees, keep the n_first
		 * pointer at the beginning of first one. */
		if (ctx->n_first == NULL)
			ctx->n_first = f;

		ctx->n_parent = new_item;
	} else {
		/* Non-root folder */

		if (folder_item_parent(item) == ctx->o_prev) {
			/* We went one step deeper in folder hierarchy, adjust pointers
			 * to parents */
			ctx->o_parent = ctx->o_prev;
			ctx->n_parent = ctx->n_prev;
		} else if (folder_item_parent(item) != ctx->o_parent) {
			/* We are not in same folder anymore, which can only mean we have
			 * moved up in the hierarchy. Find a correct parent */
			while (folder_item_parent(item) != ctx->o_parent) {
				ctx->o_parent = folder_item_parent(ctx->o_parent);
				ctx->n_parent = folder_item_parent(ctx->n_parent);
				if (ctx->o_parent == NULL) {
					/* This shouldn't happen, unless we are magically moved to a
					 * completely different folder structure */
					debug_print("RSSyl: MISHAP WHILE UPGRADING STORAGE FORMAT: couldn't find folder parent\n");
					alertpanel_error(_("Internal problem while upgrading storage format. This should not happen. Please report this, with debug output attached.\n"));
					return;
				}
			}
		} else {
			/* We have remained in the same subfolder, nothing to do here */
		}

		debug_print("RSSyl: (FORMAT) adding folder '%s'\n", item->name);
		new_item = folder_create_folder(ctx->n_parent, item->name);

		if (new_item == NULL) {
			debug_print("RSSyl: (FORMAT) couldn't add folder '%s', skipping it\n",
					item->name);
			return;
		}

		of = rssyl_old_feed_get_by_name(ctx->oldfeeds, item->name);
		if (of != NULL && of->url != NULL) {
			/* Folder with an actual subscribed feed */
			debug_print("RSSyl: (FORMAT) making '%s' a feed with URL '%s'\n",
					item->name, of->url);

			ritem = (RFolderItem *)new_item;
			ritem->url = g_strdup(of->url);

			rssyl_feed_start_refresh_timeout(ritem);

			ritem->official_title = g_strdup(of->official_name);
			ritem->default_refresh_interval =
				(of->default_refresh_interval != 0 ? TRUE : FALSE);
			ritem->refresh_interval = of->refresh_interval;
			ritem->keep_old = (of->expired_num > -1 ? TRUE : FALSE);
			ritem->fetch_comments =
				(of->fetch_comments != 0 ? TRUE : FALSE);
			ritem->fetch_comments_max_age = of->fetch_comments_for;
			ritem->silent_update = of->silent_update;
			ritem->ssl_verify_peer = of->ssl_verify_peer;

			folder_item_prefs_copy_prefs(item, &ritem->item);
		}

		rssyl_update_format_move_contents(item, new_item);

		/* destroy the new folder's cache so we'll re-read the migrated one */
		if (new_item->cache) {
			msgcache_destroy(new_item->cache);
			new_item->cache = NULL;
		}

		/* Store folderlist with the new folder */
		folder_item_scan(new_item);
		folder_write_list();
	}

	ctx->o_prev = item;
	ctx->n_prev = new_item;
}
Exemplo n.º 6
0
static void foldersel_append_item(GtkTreeStore *store, FolderItem *item,
				  GtkTreeIter *iter, GtkTreeIter *parent)
{
	gchar *name, *tmpname;
	GdkPixbuf *pixbuf, *pixbuf_open;
	gboolean use_color;
	PangoWeight weight = PANGO_WEIGHT_NORMAL;
	GdkColor *foreground = NULL;
	static GdkColor color_noselect = {0, COLOR_DIM, COLOR_DIM, COLOR_DIM};
	static GdkColor color_new;

	gtkut_convert_int_to_gdk_color(prefs_common.color_new, &color_new);

        name = tmpname = folder_item_get_name(item);

	if (item->stype != F_NORMAL && FOLDER_IS_LOCAL(item->folder)) {
		switch (item->stype) {
		case F_INBOX:
			if (!strcmp2(item->name, INBOX_DIR))
				name = _("Inbox");
			break;
		case F_OUTBOX:
			if (!strcmp2(item->name, OUTBOX_DIR))
				name = _("Sent");
			break;
		case F_QUEUE:
			if (!strcmp2(item->name, QUEUE_DIR))
				name = _("Queue");
			break;
		case F_TRASH:
			if (!strcmp2(item->name, TRASH_DIR))
				name = _("Trash");
			break;
		case F_DRAFT:
			if (!strcmp2(item->name, DRAFT_DIR))
				name = _("Drafts");
			break;
		default:
			break;
		}
	}

	if (folder_has_parent_of_type(item, F_QUEUE) && item->total_msgs > 0) {
		name = g_strdup_printf("%s (%d)", name, item->total_msgs);
	} else if (item->unread_msgs > 0) {
		name = g_strdup_printf("%s (%d)", name, item->unread_msgs);
	} else
		name = g_strdup(name);

	pixbuf = item->no_select ? foldernoselect_pixbuf : folder_pixbuf;
	pixbuf_open =
		item->no_select ? foldernoselectopen_pixbuf : folderopen_pixbuf;

	if (folder_has_parent_of_type(item, F_DRAFT) ||
	    folder_has_parent_of_type(item, F_OUTBOX) ||
	    folder_has_parent_of_type(item, F_TRASH)) {
		use_color = FALSE;
	} else if (folder_has_parent_of_type(item, F_QUEUE)) {
		use_color = (item->total_msgs > 0);
		if (item->total_msgs > 0)
			weight = PANGO_WEIGHT_BOLD;
	} else {
		if (item->unread_msgs > 0)
			weight = PANGO_WEIGHT_BOLD;
		use_color = (item->new_msgs > 0);
	}

	if (item->no_select)
		foreground = &color_noselect;
	else if (use_color)
		foreground = &color_new;

	/* insert this node */
	gtk_tree_store_append(store, iter, parent);
	gtk_tree_store_set(store, iter,
			   FOLDERSEL_FOLDERNAME, name,
			   FOLDERSEL_FOLDERITEM, item,
			   FOLDERSEL_PIXBUF, pixbuf,
			   FOLDERSEL_PIXBUF_OPEN, pixbuf_open,
			   FOLDERSEL_FOREGROUND, foreground,
			   FOLDERSEL_BOLD, weight,
			   -1);
        
        g_free(tmpname);
}