-- 
_________________________
Ryan Niebur
ryanrya...@gmail.com
diff -urN gstm-1.2/src/callbacks.c 3.has_restart_callback_and_dock_menu_entry/src/callbacks.c
--- gstm-1.2/src/callbacks.c	2006-08-03 04:39:51.000000000 -0400
+++ 3.has_restart_callback_and_dock_menu_entry/src/callbacks.c	2007-01-29 02:13:38.865578287 -0500
@@ -446,6 +446,31 @@
 }
 
 void
+on_dockletmenu_reset_current_connections (GtkMenuItem *menuitem,
+                                          gpointer user_data) {
+	/* Here we don't care about the menu item or the user data. */
+	/* add tunnels to the menu, based on the maindialog list (it's sorted) */
+	gboolean ret;
+	int v_id;
+	extern GtkWidget *maindialog;
+	extern GtkListStore *tunnellist_store;
+	GtkTreeIter i;
+
+	ret = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(tunnellist_store),&i);
+	while (ret) {
+		gtk_tree_model_get (GTK_TREE_MODEL(tunnellist_store), &i, COL_ID, &v_id, -1);
+		if (gSTMtunnels[v_id]!=NULL) {
+			gboolean active = gSTMtunnels[v_id]->active;
+			if (active) {
+				gstm_ssht_stoptunnel(v_id);
+				gstm_ssht_starttunnel(v_id);
+			}
+		}
+		ret=gtk_tree_model_iter_next(GTK_TREE_MODEL(tunnellist_store),&i);
+	}
+}
+
+void
 on_btn_copy_clicked                  (GtkButton       *button,
                                         gpointer         user_data)
 {
diff -urN gstm-1.2/src/callbacks.h 3.has_restart_callback_and_dock_menu_entry/src/callbacks.h
--- gstm-1.2/src/callbacks.h	2006-08-03 02:31:13.000000000 -0400
+++ 3.has_restart_callback_and_dock_menu_entry/src/callbacks.h	2007-01-29 02:13:39.002073385 -0500
@@ -165,3 +165,7 @@
 void
 on_btn_copy_clicked                  (GtkButton       *button,
                                         gpointer         user_data);
+
+void
+on_dockletmenu_reset_current_connections (GtkMenuItem *menuitem,
+                                          gpointer user_data);
diff -urN gstm-1.2/src/conffile.h 3.has_restart_callback_and_dock_menu_entry/src/conffile.h
--- gstm-1.2/src/conffile.h	2006-07-20 05:26:51.000000000 -0400
+++ 3.has_restart_callback_and_dock_menu_entry/src/conffile.h	2007-01-29 02:13:38.763963108 -0500
@@ -35,6 +35,7 @@
 		gboolean active;
 		int sshpid;
 		char *fn;
+	  GThread* thread;
 	} stunnel, *sshtunnelPtr;
 	
 	struct sshtunnel **gSTMtunnels;
diff -urN gstm-1.2/src/fniface.c 3.has_restart_callback_and_dock_menu_entry/src/fniface.c
--- gstm-1.2/src/fniface.c	2006-08-03 03:04:12.000000000 -0400
+++ 3.has_restart_callback_and_dock_menu_entry/src/fniface.c	2007-01-29 02:14:31.720420742 -0500
@@ -481,6 +481,9 @@
   GtkWidget *dmenu;
   GtkWidget *item_toggle;
   GtkWidget *separator1;
+  GtkWidget *item_reset;
+  GtkWidget *image_reset;
+  GtkWidget *separator3;
   GtkWidget *image_toggle;
   GtkWidget *separator2;
   GtkWidget *item_quit;
@@ -511,6 +514,18 @@
   gtk_container_add (GTK_CONTAINER (dmenu), separator1);
   gtk_widget_set_sensitive (separator1, FALSE);
 
+  /* Add a reset button to the menu */
+  image_reset = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_MENU);
+  item_reset = gtk_image_menu_item_new_with_mnemonic (_("Restart active connections"));
+  gtk_widget_show(item_reset);
+  gtk_container_add (GTK_CONTAINER (dmenu), item_reset);
+  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item_reset), image_reset);
+
+  separator3 = gtk_separator_menu_item_new ();
+  gtk_widget_show (separator3);
+  gtk_container_add (GTK_CONTAINER (dmenu), separator3);
+  gtk_widget_set_sensitive (separator3, FALSE);
+
   /* add tunnels to the menu, based on the maindialog list (it's sorted) */
   ret = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(tunnellist_store),&i);
   while (ret) {
@@ -537,6 +552,9 @@
   g_signal_connect ((gpointer) item_quit, "activate",
                     G_CALLBACK (on_dockletmenu_quit_activate),
                     NULL);
+  g_signal_connect ((gpointer) item_reset, "activate",
+                    G_CALLBACK(on_dockletmenu_reset_current_connections),
+                    NULL);
   
   return dmenu;
 }
diff -urN gstm-1.2/src/fnssht.c 3.has_restart_callback_and_dock_menu_entry/src/fnssht.c
--- gstm-1.2/src/fnssht.c	2006-08-03 04:36:35.000000000 -0400
+++ 3.has_restart_callback_and_dock_menu_entry/src/fnssht.c	2007-01-29 02:13:38.194706492 -0500
@@ -179,7 +179,19 @@
 	int i,k;
 	GThread *ret;
 	
-	if (!gSTMtunnels[id]->active) {
+	if (gSTMtunnels[id]->active) {
+	  // if we tried to start an active tunnel, then stop it
+	  // and wait on its thread.
+		//hmm, we tried to activate an active tunnel ?
+		//perhaps an error dialog, but for now just ignore this cause it shouldn't happen
+	  gstm_ssht_stoptunnel(id);
+	  if(gSTMtunnels[id]->thread != NULL) {
+	    g_thread_join(gSTMtunnels[id]->thread);
+	  }
+	}
+	  
+	g_assert(!gSTMtunnels[id]->active);
+
 		hargs = malloc(sizeof(struct Shelperargs));
 		hargs->tid = id;
 		hargs->sshargs=NULL;
@@ -219,18 +231,18 @@
 		hargs->sshargs = gstm_ssht_addssharg(hargs->sshargs, NULL); //end list
 		
 		// good, now start the helper thread
-		ret = g_thread_create((GThreadFunc)gstm_ssht_helperthread,hargs,FALSE,NULL);
+		ret = g_thread_create((GThreadFunc)gstm_ssht_helperthread,hargs,TRUE,NULL);
 		if (ret!=NULL) {
 			gSTMtunnels[id]->active = TRUE;
+			gSTMtunnels[id]->thread = ret;
 			activeCount++;
 		} else {
 			gSTMtunnels[id]->active=FALSE;
+			gSTMtunnels[id]->thread=NULL;
 			gstm_interface_error("g_thread_create error!\n");
+
 		}
-	} else {
-		//hmm, we tried to activate an active tunnel ?
-		//perhaps an error dialog, but for now just ignore this cause it shouldn't happen
-	}
+
 }
 
 int gstm_ssht_stoptunnel(int id) {

Attachment: signature.asc
Description: Digital signature



Reply via email to