/* ***********************IMPORTANT *********************************************
 *  Copyright (C) 2004-2007 Thierry Lagarde <tlagarde@users.sourceforge.net>
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License.
 *
 *
 *                      ********************
 *
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *
 *                      ********************
 *
 *
 * You are highly encouraged to send your changes to <tlagarde@users.sourceforge.net>
 * for possible incorporation into the main distribution.
 * By sending these changes to <tlagarde@users.sourceforge.net>,
 * it is assumed that you are offering <tlagarde@users.sourceforge.net>
 * the unlimited, non-exclusive right to reuse, modify, and relicense the code.
 *
 *
 *                      ********************
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **************************************************************************************/
#ifdef         __SAMBA_ENABLE

#include <gtk/gtk.h>
#include <sys/types.h>
#include <unistd.h>

#include "NetSend_Callbacks.h"
#include "NetSend_Interface.h"
#include "../Equipement.h"
#include "../Debug.h"
#include "../Macro.h"

void on_button_NetSend_clicked (GtkButton * button, gpointer user_data)
{
	pid_t     pid_fils;
	gchar      Command[255],*buf = NULL;
	GtkTextBuffer *buffer = NULL;
	GtkTextIter start;
	GtkTextIter end;
	
	DEBUG_ACTION_USER();
	buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview_NetSend));
	gtk_text_buffer_get_start_iter(buffer,&start);
	gtk_text_buffer_get_end_iter(buffer,&end);
	buf=gtk_text_buffer_get_text(buffer,&start, &end,TRUE);
	sprintf (Command, "echo \"%s\" | smbclient -M %s", buf, Equipement_Selectionner->Smb.HostName);
	MYFREE(buf);
	pid_fils = fork ();
	if (pid_fils == 0) {
	
		debug_printf (INTERFACE, D_INFO, __FILE__, __PRETTY_FUNCTION__, __LINE__, "Commande : [%s]", Command);
		system (Command);
		_exit (0);
	}
}

#endif
