From 2e1a62865f95a77a3abb824ea2a2ab89cdd71be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 9 Dec 2010 23:56:22 +0000 Subject: [PATCH] NetworkStatus now joins a network when you select one. If you need a password, you need to have it configured in your "interfaces" settings file. This could look like this: network my-ssid-name { authentication wep password gurkensalat } Of course, the cleartext password will go away in the future. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39796 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/networkstatus/NetworkStatusView.cpp | 28 +++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/apps/networkstatus/NetworkStatusView.cpp b/src/apps/networkstatus/NetworkStatusView.cpp index 6f37dc7459..e88abc1110 100644 --- a/src/apps/networkstatus/NetworkStatusView.cpp +++ b/src/apps/networkstatus/NetworkStatusView.cpp @@ -64,6 +64,7 @@ extern "C" _EXPORT BView *instantiate_deskbar_item(void); const uint32 kMsgShowConfiguration = 'shcf'; const uint32 kMsgOpenNetworkPreferences = 'onwp'; +const uint32 kMsgJoinNetwork = 'join'; const uint32 kMinIconWidth = 16; const uint32 kMinIconHeight = 16; @@ -350,6 +351,27 @@ NetworkStatusView::MessageReceived(BMessage* message) _OpenNetworksPreferences(); break; + case kMsgJoinNetwork: + { + const char* deviceName; + const char* name; + if (message->FindString("device", &deviceName) == B_OK + && message->FindString("name", &name) == B_OK) { + BNetworkDevice device(deviceName); + status_t status = device.JoinNetwork(name); + if (status != B_OK) { + BString text + = B_TRANSLATE("Could not join wireless network:\n"); + text << strerror(status); + BAlert* alert = new BAlert(name, text.String(), + B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, + B_STOP_ALERT); + alert->Go(NULL); + } + } + break; + } + case B_ABOUT_REQUESTED: _AboutRequested(); break; @@ -515,9 +537,13 @@ NetworkStatusView::MouseDown(BPoint point) int32 count = 0; cookie = 0; while (device.GetNextNetwork(cookie, network) == B_OK) { + BMessage* message = new BMessage(kMsgJoinNetwork); + message->AddString("device", device.Name()); + message->AddString("name", network.name); + BMenuItem* item = new WirelessNetworkMenuItem(network.name, network.signal_strength, - (network.flags & B_NETWORK_IS_ENCRYPTED) != 0, NULL); + (network.flags & B_NETWORK_IS_ENCRYPTED) != 0, message); menu->AddItem(item); if (associated.find(network.address) != associated.end()) item->SetMarked(true);