gpgme_data_t seahorse_vfs_data_create (const gchar *uri, guint mode, GError **err) { GFile *file = g_file_new_for_uri (uri); gpgme_data_t data; data = seahorse_vfs_data_create_full (file, mode, NULL, NULL, err); g_object_unref (file); return data; }
static gboolean step_operation (FilesCtx *ctx, SeahorseToolMode *mode, GError **err) { SeahorsePGPOperation *pop = NULL; gpgme_data_t data = NULL; gboolean ret = FALSE; SeahorseOperation *op; FileInfo *finfo; GList *l; gchar *filename; /* Reset our done counter */ ctx->done = 0; for (l = ctx->finfos; l; l = g_list_next (l)) { finfo = (FileInfo*)l->data; if (!finfo || !finfo->file) continue; ctx->cur = finfo; /* A new operation for each context */ pop = seahorse_pgp_operation_new (NULL); op = SEAHORSE_OPERATION (pop); data = seahorse_vfs_data_create_full (finfo->file, SEAHORSE_VFS_READ, (SeahorseVfsProgressCb)progress_cb, ctx, err); if (!data) goto finally; /* Inhibit popping up of progress dialog */ seahorse_tool_progress_block (TRUE); /* Embed filename during encryption */ if (mode_encrypt) { filename = g_file_get_basename (finfo->file); gpgme_data_set_file_name (data, filename); g_free (filename); } /* The start callback */ if (mode->startcb) { if (!(mode->startcb) (mode, finfo->uri, data, pop, err)) goto finally; } /* Let progress dialog pop up */ seahorse_tool_progress_block (FALSE); /* Run until the operation completes */ seahorse_util_wait_until ((!seahorse_operation_is_running (op) || !seahorse_tool_progress_check ())); /* If cancel then reflect that */ if (seahorse_operation_is_running (op)) { seahorse_operation_cancel (op); goto finally; } if (!seahorse_operation_is_successful (op)) { seahorse_operation_copy_error (op, err); goto finally; } /* The done callback */ if (mode->donecb) { if (!(mode->donecb) (mode, finfo->uri, data, pop, err)) goto finally; } ctx->done += g_file_info_get_size (finfo->info); ctx->cur = NULL; g_object_unref (pop); pop = NULL; gpgme_data_release (data); data = NULL; } seahorse_tool_progress_update (1.0, ""); ret = TRUE; finally: if (pop) g_object_unref (pop); if (data) gpgme_data_release (data); return ret; }