Beispiel #1
0
static void
fr_command_7z_handle_error (FrCommand *command,
			    FrError   *error)
{
	FrArchive *archive = FR_ARCHIVE (command);

	if (error->type == FR_ERROR_NONE) {
		FileData *first;
		char     *basename;
		char     *testname;

		/* This is a way to fix bug #582712. */

		if (archive->files->len != 1)
			return;

		if (! g_str_has_suffix (command->filename, ".001"))
			return;

		first = g_ptr_array_index (archive->files, 0);
		basename = g_path_get_basename (command->filename);
		testname = g_strconcat (first->original_path, ".001", NULL);

		if (strcmp (basename, testname) == 0)
			fr_error_take_gerror (error, g_error_new_literal (FR_ERROR, FR_ERROR_ASK_PASSWORD, ""));

		g_free (testname);
		g_free (basename);

		return;
	}

	if (error->status <= 1) {
		/* ignore warnings */
		fr_error_clear_gerror (error);
	}
	else {
		GList *scan;

		for (scan = g_list_last (command->process->out.raw); scan; scan = scan->prev) {
			char *line = scan->data;

			if ((strstr (line, "Wrong password?") != NULL)
			    || (strstr (line, "Enter password") != NULL))
			{
				fr_error_take_gerror (error, g_error_new_literal (FR_ERROR, FR_ERROR_ASK_PASSWORD, ""));
				break;
			}
		}
	}
}
static void
fr_command_unarchiver_handle_error (FrCommand   *comm,
				    FrError *error)
{
	GList *scan;

#if 0
	{
		for (scan = g_list_last (comm->process->err.raw); scan; scan = scan->prev)
			g_print ("%s\n", (char*)scan->data);
	}
#endif

	if (error->type == FR_ERROR_NONE)
		return;

	for (scan = g_list_last (comm->process->err.raw); scan; scan = scan->prev) {
		char *line = scan->data;

		if (strstr (line, "password") != NULL) {
			fr_error_take_gerror (error, g_error_new_literal (FR_ERROR, FR_ERROR_ASK_PASSWORD, ""));
			break;
		}
	}
}