changeset 212:89c9334d3484

[gaim-migrate @ 222] Added pthread code. Keep your fingers crossed.... :P committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 03 May 2000 10:01:19 +0000
parents 2042a38da38b
children 0eb9e6928d7e
files configure.in src/rvous.c src/toc.c
diffstat 3 files changed, 30 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Wed May 03 00:34:30 2000 +0000
+++ b/configure.in	Wed May 03 10:01:19 2000 +0000
@@ -16,6 +16,16 @@
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h)
+AC_CHECK_HEADERS(pthread.h,,AC_MSG_ERROR([*** POSIX thread support not found ***]))
+
+dnl Taken from Mozilla's and xchat's configure.in's :)
+AC_CHECK_LIB(pthread, pthread_create, _PTHREAD_LDFLAGS="-lpthread",
+    AC_CHECK_LIB(c_r, pthread_create, _PTHREAD_LDFLAGS="-lc_r",
+        AC_CHECK_LIB(pthreads, pthread_create, _PTHREAD_LDFLAGS="-lpthreads",
+	    AC_MSG_ERROR([*** POSIX thread library not found ***])
+	)
+    )
+)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
@@ -38,7 +48,7 @@
 AC_ARG_ENABLE(plugins, [  --disable-plugins       compile with out plugin support],enable_plugins=no,enable_plugins=yes)
 
 GAIM_CFLAGS="$CFLAGS -I../"
-GAIM_LIBS="$LIBS"
+GAIM_LIBS="$LIBS $_PTHREAD_LDFLAGS"
 GAIM_LDADD="$LDADD"
 LIBFAIM_DO=""
 
--- a/src/rvous.c	Wed May 03 00:34:30 2000 +0000
+++ b/src/rvous.c	Wed May 03 10:01:19 2000 +0000
@@ -32,6 +32,7 @@
 #include <unistd.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <pthread.h>
 
 #include <gtk/gtk.h>
 #include "gaim.h"
@@ -149,7 +150,8 @@
 	guint32 rcv;
         char *c;
 	int cont = 1;
-	GtkWidget *fw = NULL, *fbar = NULL, *label = NULL, *button = NULL;
+	GtkWidget *fw = NULL, *fbar = NULL, *label = NULL;
+	GtkWidget *button = NULL, *pct = NULL;
 
 	if (!(ft->f = fopen(file,"w"))) {
 		buf = g_malloc(BUF_LONG);
@@ -248,19 +250,21 @@
 	
 	fw = gtk_dialog_new();
 	buf = g_malloc(2048);
-	snprintf(buf, 2048, "Receiving %s from %s (%d bytes)", ft->filename,
-			ft->user, ft->size);
+	snprintf(buf, 2048, "Receiving %s from %s", ft->filename, ft->user);
 	label = gtk_label_new(buf);
 	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->vbox), label, 0, 0, 5);
 	gtk_widget_show(label);
 	fbar = gtk_progress_bar_new();
 	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->action_area), fbar, 0, 0, 5);
 	gtk_widget_show(fbar);
+	pct = gtk_label_new("0 %");
+	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->action_area), pct, 0, 0, 5);
+	gtk_widget_show(pct);
 	button = gtk_button_new_with_label("Cancel");
 	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->action_area), button, 0, 0, 5);
 	gtk_widget_show(button);
 	gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)toggle, &cont);
-	gtk_window_set_title(GTK_WINDOW(fw), "File Transfer");
+	gtk_window_set_title(GTK_WINDOW(fw), "Gaim - File Transfer");
 	gtk_widget_realize(fw);
 	aol_icon(fw->window);
 	gtk_widget_show(fw);
@@ -284,11 +288,14 @@
 		rcv += read_rv;
 		for (i = 0; i < read_rv; i++)
 			fprintf(ft->f, "%c", buf[i]);
-		snprintf(buf, 2048, "Receiving %s from %s (%d / %d bytes)",
-				header + 186, ft->user, rcv, ft->size);
+		snprintf(buf, 2048, "Receiving %s from %s",
+				header + 186, ft->user);
 		gtk_label_set_text(GTK_LABEL(label), buf);
 		gtk_progress_bar_update(GTK_PROGRESS_BAR(fbar),
 					(float)(rcv)/(float)(ft->size));
+		sprintf(buf, "%d / %d K (%2.0f %%)", rcv/1024, ft->size/1024,
+				100*((float)rcv)/((float)ft->size));
+		gtk_label_set_text(GTK_LABEL(pct), buf);
 		while(gtk_events_pending())
 			gtk_main_iteration();
 	}
--- a/src/toc.c	Wed May 03 00:34:30 2000 +0000
+++ b/src/toc.c	Wed May 03 10:01:19 2000 +0000
@@ -32,6 +32,7 @@
 #include <stdio.h>
 #include <time.h>
 #include <sys/socket.h>
+#include <pthread.h>
 #include "gaim.h"
 #include "gnome_applet_mgr.h"
 
@@ -607,6 +608,8 @@
 
 		if (!strcmp(uuid, FILE_SEND_UID)) {
 			/* we're getting a file */
+			pthread_t thread;
+
 	                for (i=0; i<4; i++) {
 	                        sscanf(strtok(NULL, ":"), "%d", &unk[i]);
 	                        if (unk[i] == 10001)
@@ -644,7 +647,9 @@
 	                for (i--; i >= 0; i--)
 	                        g_free(messages[i]);
                 
-	                accept_file_dialog(ft);
+	                pthread_create(&thread, NULL, 
+				       (void*(*)(void*))accept_file_dialog, ft);
+			pthread_detach(thread);
 		} else if (!strcmp(uuid, FILE_GET_UID)) {
 			/* we're sending a file */
 	                for (i=0; i<4; i++) {