diff src/ft.c @ 9796:68574cef02e2

[gaim-migrate @ 10664] Thanks to Dave West for being cool. When I grow up I want to be a p scichologiest. Sometimes I wish the coyote would catch the road runner. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 20 Aug 2004 21:57:18 +0000
parents 719fc957e9ee
children 255596f41014
line wrap: on
line diff
--- a/src/ft.c	Fri Aug 20 20:15:09 2004 +0000
+++ b/src/ft.c	Fri Aug 20 21:57:18 2004 +0000
@@ -112,63 +112,29 @@
 	xfer->status = status;
 }
 
-/*
- * XXX - I REALLY feel like this should be using strerror.
- * Also, should this use gaim_xfer_error?
- */
-static void gaim_xfer_show_file_error(const char *filename)
+static void gaim_xfer_show_file_error(GaimXfer *xfer, const char *filename)
 {
 	gchar *msg = NULL;
+	GaimXferType xfer_type = gaim_xfer_get_type(xfer);
 
-	switch (errno) 
-	{
-		case ENOENT: 
-			msg = g_strdup_printf(_("%s does not exist.\n"), filename);
-			break;
-		case EISDIR: 
-			msg = g_strdup_printf(_("%s is a directory, not a file.\n"), filename);
-			break;
-		case ENOTDIR: 
-			msg = g_strdup_printf( _("A component of %s is not a directory.\n"), filename);
-			break;
-#ifndef _WIN32
-		case ELOOP: 
-			msg = g_strdup_printf( _("Too many symbolic links in path for %s\n"), filename);
-			break;
-		case ETXTBSY:
-			msg = g_strdup_printf(_("Cannot write %s: File is in use\n"), filename);
+	switch(xfer_type) {
+		case GAIM_XFER_SEND:
+			msg = g_strdup_printf(_("Error reading %s: \n%s.\n"),
+								  filename, strerror(errno));
 			break;
-#endif
-		case EACCES: 
-			msg = g_strdup_printf( _("Permission denied accessing %s\n"), filename);
-			break;
-		case ENAMETOOLONG: 
-			msg = g_strdup_printf(_("File name too long: %s\n"), filename);
-			break;
-		case EROFS: 
-			msg = g_strdup_printf(_("Cannot write %s: Read only filesystem\n"), filename);
-			break;
-		case ENOSPC:
-			msg = g_strdup_printf(_("Cannot write %s: No space on filesystem\n"), filename);
-			break;
-		case EMFILE:
-			msg = g_strdup_printf(_("Cannot open %s: Gaim has too many files open\n"), filename);
-			break;
-		case ENFILE:
-			msg = g_strdup_printf(_("Cannot open %s: Your user or system has too many files open\n"), filename);
-			break;
-		case ENOMEM:
-			msg = g_strdup_printf(_("Cannot open %s: Not enough memory\n"), filename);
+		case GAIM_XFER_RECEIVE:
+			msg = g_strdup_printf(_("Error writing %s: \n%s.\n"),
+								  filename, strerror(errno));
 			break;
 		default:
 			msg = NULL;
+			msg = g_strdup_printf(_("Error accessing %s: \n%s.\n"),
+								  filename, strerror(errno));
 			break;
-	}
+		}
 
-	if (msg != NULL) {
-		gaim_notify_error(NULL, NULL, msg, NULL);
-		g_free(msg);
-	}
+	gaim_xfer_error(xfer_type, xfer->who, msg);
+	g_free(msg);
 }
 
 static void
@@ -185,7 +151,7 @@
 			gaim_xfer_request_accepted(xfer, filename);
 		}
 		else {
-		  	gaim_xfer_show_file_error(filename);
+		  	gaim_xfer_show_file_error(xfer, filename);
 			gaim_xfer_request_denied(xfer);
 		}
 	}
@@ -365,7 +331,7 @@
 		}
 
 		if (stat(filename, &st) == -1) {
-		  	gaim_xfer_show_file_error(filename);
+		  	gaim_xfer_show_file_error(xfer, filename);
 			gaim_xfer_unref(xfer);
 			return;
 		}
@@ -769,7 +735,7 @@
 						  type == GAIM_XFER_RECEIVE ? "wb" : "rb");
 
 	if (xfer->dest_fp == NULL) {
-		gaim_xfer_show_file_error(gaim_xfer_get_local_filename(xfer));
+		gaim_xfer_show_file_error(xfer, gaim_xfer_get_local_filename(xfer));
 		gaim_xfer_cancel_local(xfer);
 		return;
 	}