diff src/gtk/misc-gtk.c @ 186:13ca1defdc75

2003-6-16 Brian Masney <masneyb@gftp.org> * lib/gftp.h src/text/gftp-text.c src/gtk/misc-gtk.c - changed 2nd parameter of logging function to be a request structure, instead of request->user_data. In the logging functions, if the string isn't in UTF-8, convert it with gftp_string_to_utf8() * lib/bookmark.c lib/cache.c lib/gftp.h lib/https.c lib/local.c lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c lib/sslcommon.c src/gtk/chmod_dialog.c src/gtk/delete_dialog.c src/gtk/gftp-gtk.h src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/mkdir_dialog.c src/gtk/rename_dialog.c src/gtk/transfer.c src/text/gftp-text.c src/gtk/gftp-gtk.h src/text/gftp-text.h - pass request structure to logging function instead of request->user_data
author masneyb
date Tue, 17 Jun 2003 10:49:16 +0000
parents 65eb40fb4f03
children 876747813a60
line wrap: on
line diff
--- a/src/gtk/misc-gtk.c	Tue Jun 17 10:13:26 2003 +0000
+++ b/src/gtk/misc-gtk.c	Tue Jun 17 10:49:16 2003 +0000
@@ -36,7 +36,8 @@
 
 
 void
-ftp_log (gftp_logging_level level, void *ptr, const char *string, ...)
+ftp_log (gftp_logging_level level, gftp_request * request, 
+         const char *string, ...)
 {
   guint max_log_window_size;
   int upd, free_logstr;
@@ -49,11 +50,10 @@
   gftp_color * color;
   GdkColor fore;
 #else
+  char *utf8_str;
   GtkTextBuffer * textbuf;
   GtkTextIter iter, iter2;
-  gsize bread, bwrite;
   const char *descr;
-  char *tempstr;
 #endif
 
   if (pthread_self () != main_thread_id)
@@ -83,6 +83,21 @@
     }
   va_end (argp);
 
+#if GTK_MAJOR_VERSION > 1
+  if (!g_utf8_validate (logstr, -1, NULL))
+    {
+      if ((utf8_str = gftp_string_to_utf8 (request, logstr)) != NULL)
+        {
+          if (free_logstr)
+            g_free (logstr);
+          else
+            free_logstr = 1;
+
+          logstr = utf8_str;
+        }
+    }
+#endif
+
   if (gftp_logfd != NULL)
     {
       if (fwrite (logstr, strlen (logstr), 1, gftp_logfd) != 1)
@@ -161,20 +176,6 @@
         break;
     }
 
-  /* If the current log message is not in UTF8 format, convert it to UTF8 
-     format based on the current locale */
-  if (!g_utf8_validate (logstr, -1, NULL))
-    {
-      tempstr = g_locale_to_utf8 (logstr, -1, &bread, &bwrite, NULL);
-      if (tempstr != NULL)
-        {
-          if (free_logstr)
-            g_free (logstr);
-          logstr = tempstr;
-          free_logstr = 1;
-        }
-    }
-
   textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw));
   len = gtk_text_buffer_get_char_count (textbuf);
   gtk_text_buffer_get_iter_at_offset (textbuf, &iter, len);
@@ -1251,7 +1252,7 @@
   while (templist != NULL)
     { 
       templog = (gftp_log *) templist->data;
-      ftp_log (templog->type, (void *) 0x2, "%s", templog->msg);
+      ftp_log (templog->type, NULL, "%s", templog->msg);
       g_free (templog->msg);
       g_free (templog); 
       templist->data = NULL;