Index: src/preferences/network/NetworkWindow.cpp
===================================================================
--- src/preferences/network/NetworkWindow.cpp	(revisione 39856)
+++ src/preferences/network/NetworkWindow.cpp	(copia locale)
@@ -4,9 +4,8 @@
  *
  * Author:
  *		Andre Alves Garzia, andre@andregarzia.com
+ *		Dario Casalinuovo
  */
-
-
 #include "NetworkWindow.h"
 
 #include <Application.h>
@@ -14,19 +13,19 @@
 #include <GroupLayout.h>
 #include <Locale.h>
 
-#include "EthernetSettingsView.h"
+#include <stdio.h>
 
+#include "NetworkView.h"
 
 #undef B_TRANSLATE_CONTEXT
 #define B_TRANSLATE_CONTEXT "NetworkWindow"
 
-
 NetworkWindow::NetworkWindow()
-	:
-	BWindow(BRect(50, 50, 269, 302), B_TRANSLATE("Network"), B_TITLED_WINDOW,
-		B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
-		| B_AUTO_UPDATE_SIZE_LIMITS | B_QUIT_ON_WINDOW_CLOSE)
+	: BWindow(BRect(50, 50, 300, 400), "Network", B_TITLED_WINDOW,
+		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
+		| B_AUTO_UPDATE_SIZE_LIMITS |  B_QUIT_ON_WINDOW_CLOSE)
 {
 	SetLayout(new BGroupLayout(B_HORIZONTAL));
-	GetLayout()->AddView(new EthernetSettingsView());
+	fNetworkView = new NetworkView();
+	GetLayout()->AddView(fNetworkView);
 }
Index: src/preferences/network/NetworkView.cpp
===================================================================
--- src/preferences/network/NetworkView.cpp	(revisione 0)
+++ src/preferences/network/NetworkView.cpp	(revisione 0)
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2008-2010 Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Author:
+ *		Dario Casalinuovo     
+ *      
+ */
+#include "NetworkView.h"
+
+#include <Alert.h>
+#include <Box.h>
+#include <Button.h>
+#include <CheckBox.h>
+#include <Deskbar.h>
+#include <File.h>
+#include <GridView.h>
+#include <GroupView.h>
+#include <LayoutItem.h>
+#include <SpaceLayoutItem.h>
+#include <Roster.h>
+#include <FindDirectory.h>
+#include <TextControl.h>
+#include <View.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+static const uint32 kMsgInstallInDeskbar = 'iidb';
+static const uint32 kMsgSetName = 'stnm';
+
+NetworkView::NetworkView() 
+	: BView("NetworkView", 0, NULL)
+{
+	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+	BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL);
+	SetLayout(rootLayout);
+	BGridView* informationsGroup = new BGridView();
+	BGridLayout* layout = informationsGroup->GridLayout();
+
+	// insets
+
+	float inset = ceilf(be_plain_font->Size() * 0.7);
+	rootLayout->SetInsets(inset, inset, inset, inset);
+	rootLayout->SetSpacing(inset);
+	layout->SetSpacing(inset, inset); 
+
+	fComputerNameTextControl = new BTextControl("Computer Name :", "",
+		new BMessage(kMsgSetName));
+
+	layout->AddItem(fComputerNameTextControl->CreateLabelLayoutItem(),
+		0, 1.5);
+	layout->AddItem(fComputerNameTextControl->CreateTextViewLayoutItem(),
+		1, 1.5);
+
+	fComputerNameTextControl->SetText(_ReadComputerName());
+
+	BGroupView* guiGroup = new BGroupView(B_VERTICAL);
+	fPreferencesBox = new BBox("Preferences", B_WILL_DRAW,
+		B_FANCY_BORDER, guiGroup);
+
+	EthernetSettingsView* fEthernetView = new EthernetSettingsView();
+	guiGroup->GroupLayout()->AddView(fEthernetView);
+
+	fShowNetworkInDeskbar = new BCheckBox("Show Network icon in Deskbar.",
+		new BMessage(kMsgInstallInDeskbar));
+	fShowNetworkInDeskbar->SetValue(_IsInstalled());
+
+	rootLayout->AddView(informationsGroup);
+	rootLayout->AddView(fPreferencesBox);
+	rootLayout->AddView(fShowNetworkInDeskbar);
+}
+
+
+NetworkView::~NetworkView()
+{
+	BString str = fComputerNameTextControl->Text();
+	if(str != fComputerName)
+		_SaveComputerName(str.String());
+}
+
+
+void
+NetworkView::AttachedToWindow()
+{
+	fShowNetworkInDeskbar->SetTarget(this);
+	fComputerNameTextControl->SetTarget(this);
+}
+
+
+void
+NetworkView::MessageReceived(BMessage* message)
+{
+	switch (message->what) {
+	
+		case kMsgInstallInDeskbar:
+		{
+			if (fShowNetworkInDeskbar->Value() == B_CONTROL_ON) {
+				_InstallInDeskbar();
+			} else if (fShowNetworkInDeskbar->Value() == B_CONTROL_OFF) {
+				_RemoveFromDeskbar();	
+			}
+			break;
+		}	
+
+		case kMsgSetName:
+		{
+			_SaveComputerName(fComputerNameTextControl->Text());
+			fComputerNameTextControl->MakeFocus(false);
+			break;
+		}
+		
+		default:
+			BView::MessageReceived(message);
+	}
+}
+
+
+// TODO: The methods _ReadComputerName() and _SaveComputerName()
+// should be removed from here
+const char*
+NetworkView::_ReadComputerName()
+{
+	BFile hostname;
+	fComputerName = BString();
+	char buf[128];
+	ssize_t ret;
+
+	find_directory(B_COMMON_SETTINGS_DIRECTORY,
+		&fHostNamePath, true);
+
+	fHostNamePath.Append("network/hostname"); 
+	hostname = BFile(fHostNamePath.Path(),
+		B_READ_ONLY);
+	
+	if (hostname.InitCheck() != B_OK)
+		fprintf(stderr, "failed to open the file %s: %s\n",
+			fHostNamePath.Path(), strerror(hostname.InitCheck()));
+	
+	ret = hostname.Read((void*) buf, 128);
+
+	if (ret < 0)
+		fprintf(stderr, "failed to read the file %s: %s\n",
+			fHostNamePath.Path(), strerror(hostname.InitCheck()));
+
+	if (ret > 0)
+		buf[ret] = '\0';
+
+	fComputerName.Append(buf);
+
+	return fComputerName.String();
+}
+
+
+void
+NetworkView::_SaveComputerName(const char* name)
+{
+	BFile file(fHostNamePath.Path(),
+		B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
+	
+	if (file.InitCheck() != B_OK)
+		fprintf(stderr, "failed to open the file %s: %s\n",
+			fHostNamePath.Path(), strerror(file.InitCheck()));
+
+	file.Write(name, strlen(name));
+}
+
+
+void
+NetworkView::_InstallInDeskbar()
+{
+	char* argv[] = {const_cast<char *>("--deskbar"), NULL};
+
+	status_t ret = be_roster->Launch(
+		"application/x-vnd.Haiku-NetworkStatus", 1, argv); 
+
+		if (ret != B_OK) {
+			BString errorMessage(
+				"Installing NetworkStatus in Deskbar failed.\n\n" 
+					"Error: ");
+			errorMessage << strerror(ret);
+			BAlert* alert = new BAlert("launch error",
+				errorMessage.String(), "Ok");
+			alert->Go(NULL);
+		}
+}
+
+
+int32
+NetworkView::_IsInstalled()
+{
+	BDeskbar deskbar;
+	bool ret = deskbar.HasItem("NetworkStatus");
+	if (ret == false)
+		return 0;
+
+	return 1;
+}
+
+
+void
+NetworkView::_RemoveFromDeskbar()
+{
+	BDeskbar deskbar;
+	deskbar.RemoveItem("NetworkStatus");
+}
Index: src/preferences/network/Jamfile
===================================================================
--- src/preferences/network/Jamfile	(revisione 39856)
+++ src/preferences/network/Jamfile	(copia locale)
@@ -6,6 +6,7 @@
 Preference Network :
 	NetworkApp.cpp
 	NetworkWindow.cpp
+	NetworkView.cpp
 	EthernetSettingsView.cpp
 	Settings.cpp
 
Index: src/preferences/network/NetworkWindow.h
===================================================================
--- src/preferences/network/NetworkWindow.h	(revisione 39856)
+++ src/preferences/network/NetworkWindow.h	(copia locale)
@@ -11,11 +11,15 @@
 
 #include <Window.h>
 
+#include "NetworkView.h"
 
+
 class NetworkWindow : public BWindow {
 public:
-								NetworkWindow();
+					NetworkWindow();
+
+private:
+	NetworkView*	fNetworkView;
 };
 
-
-#endif	// NETWORK_WINDOW_H
+#endif	/* NETWORK_WINDOW_H */
Index: src/preferences/network/NetworkView.h
===================================================================
--- src/preferences/network/NetworkView.h	(revisione 0)
+++ src/preferences/network/NetworkView.h	(revisione 0)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2008-2010 Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Author:
+ *      Dario Casalinuovo
+ *      
+ *      
+ */
+#ifndef NETWORK_VIEW_H
+#define NETWORK_VIEW_H
+
+#include <Path.h>
+#include <String.h>
+#include <View.h>
+
+#include "EthernetSettingsView.h"
+
+class BBox;
+class BButton;
+class BCheckBox;
+class BPath;
+class BTextControl;
+
+
+class NetworkView : public BView {
+public: 
+					NetworkView();
+					NetworkView(BMessage*);
+	virtual			~NetworkView();
+
+	void			MessageReceived(BMessage* message);
+
+	virtual void 	AttachedToWindow();
+
+private:
+	void 			_InstallInDeskbar();
+	int32 			_IsInstalled();
+	void 			_RemoveFromDeskbar();
+	
+	const char*		_ReadComputerName();
+	void			_SaveComputerName(const char* name);
+
+	BTextControl* 	fComputerNameTextControl;
+	BBox* 			fPreferencesBox;
+	BCheckBox* 		fShowNetworkInDeskbar;
+
+	BPath			fHostNamePath;
+	BString			fComputerName;
+
+	EthernetSettingsView* fEthernetView;
+};
+
+#endif
