void delete_dialog (GtkAction * a, gpointer data) { gftp_file * tempfle, * newfle; GList * templist, * filelist; gftp_transfer * transfer; gftp_window_data * wdata; int ret; GtkTreeSelection *select; GtkTreeIter iter; GtkTreeModel * model; wdata = data; if (!check_status (_("Delete"), wdata, gftpui_common_use_threads (wdata->request), 0, 1, 1)) return; transfer = g_malloc0 (sizeof (*transfer)); transfer->fromreq = gftp_copy_request (wdata->request); transfer->fromwdata = wdata; select = gtk_tree_view_get_selection (GTK_TREE_VIEW (wdata->listbox)); templist = gtk_tree_selection_get_selected_rows(select, &model); for (filelist = templist ; filelist != NULL; filelist = g_list_next(filelist)) { gtk_tree_model_get_iter(model, &iter, (GtkTreePath*)filelist->data); gtk_tree_model_get(model, &iter, 0, &tempfle, -1); if (strcmp (tempfle->file, "..") == 0 || strcmp (tempfle->file, ".") == 0) continue; newfle = copy_fdata (tempfle); transfer->files = g_list_append (transfer->files, newfle); } g_list_foreach (templist, (GFunc) gtk_tree_path_free, NULL); g_list_free (templist); if (transfer->files == NULL) { free_tdata (transfer); return; } gftp_swap_socks (transfer->fromreq, wdata->request); ret = gftp_gtk_get_subdirs (transfer); gftp_swap_socks (wdata->request, transfer->fromreq); if (!GFTP_IS_CONNECTED (wdata->request)) { gftpui_disconnect (wdata); return; } if (!ret) return; askdel (transfer); }
void transfer_window_files (gftp_window_data * fromwdata, gftp_window_data * towdata) { gftp_file * tempfle, * newfle; GList * templist, * filelist; gftp_transfer * transfer; int num, ret, disconnect; if (!check_status (_("Transfer Files"), fromwdata, 1, 0, 1, towdata->request->put_file != NULL && fromwdata->request->get_file != NULL)) return; if (!GFTP_IS_CONNECTED (fromwdata->request) || !GFTP_IS_CONNECTED (towdata->request)) { ftp_log (gftp_logging_error, NULL, _("Retrieve Files: Not connected to a remote site\n")); return; } if (check_reconnect (fromwdata) < 0 || check_reconnect (towdata) < 0) return; transfer = g_malloc0 (sizeof (*transfer)); transfer->fromreq = gftp_copy_request (fromwdata->request); transfer->toreq = gftp_copy_request (towdata->request); transfer->fromwdata = fromwdata; transfer->towdata = towdata; num = 0; templist = gftp_gtk_get_list_selection (fromwdata); filelist = fromwdata->files; while (templist != NULL) { templist = get_next_selection (templist, &filelist, &num); tempfle = filelist->data; if (strcmp (tempfle->file, "..") != 0) { newfle = copy_fdata (tempfle); transfer->files = g_list_append (transfer->files, newfle); } } if (transfer->files != NULL) { gftp_swap_socks (transfer->fromreq, fromwdata->request); gftp_swap_socks (transfer->toreq, towdata->request); ret = gftp_gtk_get_subdirs (transfer); if (ret < 0) disconnect = 1; else disconnect = 0; if (!GFTP_IS_CONNECTED (transfer->fromreq)) { gftpui_disconnect (fromwdata); disconnect = 1; } if (!GFTP_IS_CONNECTED (transfer->toreq)) { gftpui_disconnect (towdata); disconnect = 1; } if (disconnect) { free_tdata (transfer); return; } gftp_swap_socks (fromwdata->request, transfer->fromreq); gftp_swap_socks (towdata->request, transfer->toreq); } if (transfer->files != NULL) { gftpui_common_add_file_transfer (transfer->fromreq, transfer->toreq, transfer->fromwdata, transfer->towdata, transfer->files); g_free (transfer); } else free_tdata (transfer); }
static void do_view_or_edit_file (gftp_window_data * fromwdata, int is_view) { GList * templist, * filelist, * newfile; gftp_window_data * towdata; gftp_file * new_fle; char *suffix; int num; if (!check_status (is_view ? _("View") : _("Edit"), fromwdata, 0, 1, 1, 1)) return; towdata = fromwdata == &window1 ? &window2 : &window1; templist = GTK_CLIST (fromwdata->listbox)->selection; num = 0; filelist = fromwdata->files; templist = get_next_selection (templist, &filelist, &num); curfle = filelist->data; if (S_ISDIR (curfle->st_mode)) { if (is_view) ftp_log (gftp_logging_error, NULL, _("View: %s is a directory. Cannot view it.\n"), curfle->file); else ftp_log (gftp_logging_error, NULL, _("Edit: %s is a directory. Cannot edit it.\n"), curfle->file); return; } if (strcmp (gftp_protocols[fromwdata->request->protonum].name, "Local") == 0) view_file (curfle->file, 0, is_view, 0, 1, 1, NULL, fromwdata); else { new_fle = copy_fdata (curfle); if (new_fle->destfile) g_free (new_fle->destfile); if ((suffix = strrchr (curfle->file, '.')) != NULL) { new_fle->destfile = g_strconcat (g_get_tmp_dir (), "/gftp-view.XXXXXX", suffix, NULL); new_fle->fd = mkstemps (new_fle->destfile, strlen (suffix)); } else { new_fle->destfile = g_strconcat (g_get_tmp_dir (), "/gftp-view.XXXXXX", NULL); new_fle->fd = mkstemps (new_fle->destfile, 0); } if (new_fle->fd < 0) { ftp_log (gftp_logging_error, NULL, _("Error: Cannot open %s for writing: %s\n"), new_fle->destfile, g_strerror (errno)); gftp_file_destroy (new_fle, 1); return; } fchmod (new_fle->fd, S_IRUSR | S_IWUSR); if (is_view) { new_fle->done_view = 1; new_fle->done_rm = 1; } else new_fle->done_edit = 1; newfile = g_list_append (NULL, new_fle); gftpui_common_add_file_transfer (fromwdata->request, towdata->request, fromwdata, towdata, newfile); } }