Network: removed now superfluous services add-on.
This commit is contained in:
@@ -1,19 +0,0 @@
|
|||||||
SubDir HAIKU_TOP src preferences network ServicesAddOn ;
|
|
||||||
|
|
||||||
UseHeaders [ FDirName $(HAIKU_TOP) src preferences network ] ;
|
|
||||||
|
|
||||||
AddResources Services : Services.rdef ;
|
|
||||||
|
|
||||||
Addon Services :
|
|
||||||
ServicesAddOn.cpp
|
|
||||||
|
|
||||||
DNSSettingsView.cpp
|
|
||||||
: be <nogrist>Network network [ TargetLibstdc++ ] localestub
|
|
||||||
;
|
|
||||||
|
|
||||||
DoCatalogs Services :
|
|
||||||
x-vnd.Haiku-NetworkServices
|
|
||||||
:
|
|
||||||
ServicesAddOn.cpp
|
|
||||||
DNSSettingsView.cpp
|
|
||||||
;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
resource app_signature "application/x-vnd.Haiku-NetworkServices";
|
|
||||||
|
|
||||||
resource app_version {
|
|
||||||
major = 1,
|
|
||||||
middle = 1,
|
|
||||||
minor = 0,
|
|
||||||
variety = 0,
|
|
||||||
internal = 0,
|
|
||||||
short_info = "1.1.0",
|
|
||||||
long_info = "Haiku Network Services preferences."
|
|
||||||
};
|
|
||||||
@@ -1,243 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2004-2011 Haiku Inc. All rights reserved.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Alexander von Gluck, [email protected]
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "ServicesAddOn.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <Catalog.h>
|
|
||||||
#include <ListView.h>
|
|
||||||
#include <ScrollView.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
#include "DNSSettingsView.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define B_TRANSLATION_CONTEXT "Services"
|
|
||||||
|
|
||||||
|
|
||||||
static const int32 kSelectionChanged = 'ssrv';
|
|
||||||
|
|
||||||
static const char* kDNSSettingsName = B_TRANSLATE_MARK("DNS Client");
|
|
||||||
|
|
||||||
|
|
||||||
NetworkSetupAddOn*
|
|
||||||
get_nth_addon(image_id image, int index)
|
|
||||||
{
|
|
||||||
if (index != 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return new ServicesAddOn(image);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
ServicesAddOn::ServicesAddOn(image_id image)
|
|
||||||
:
|
|
||||||
NetworkSetupAddOn(image),
|
|
||||||
BGroupView("Services"),
|
|
||||||
fServicesListView(NULL)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BView*
|
|
||||||
ServicesAddOn::CreateView()
|
|
||||||
{
|
|
||||||
fServicesListView = new BListView("system_services",
|
|
||||||
B_SINGLE_SELECTION_LIST);
|
|
||||||
fServicesListView->SetSelectionMessage(new BMessage(kSelectionChanged));
|
|
||||||
|
|
||||||
BScrollView* sv = new BScrollView( "ScrollView",
|
|
||||||
fServicesListView, B_WILL_DRAW | B_FRAME_EVENTS, false, true);
|
|
||||||
|
|
||||||
fServicesListView->AddItem(new BStringItem(
|
|
||||||
B_TRANSLATE_NOCOLLECT(kDNSSettingsName)));
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Enable this when the inetd view is ready
|
|
||||||
if (_ParseInetd() != B_OK)
|
|
||||||
_ParseXinetd();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
AddChild(sv);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ServicesAddOn::AttachedToWindow()
|
|
||||||
{
|
|
||||||
fServicesListView->SetTarget(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ServicesAddOn::MessageReceived(BMessage* message)
|
|
||||||
{
|
|
||||||
switch (message->what) {
|
|
||||||
case kSelectionChanged:
|
|
||||||
{
|
|
||||||
_ShowPanel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
BGroupView::MessageReceived(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ServicesAddOn::Show()
|
|
||||||
{
|
|
||||||
BView::Show();
|
|
||||||
_ShowPanel();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
ServicesAddOn::Save()
|
|
||||||
{
|
|
||||||
BView* panel = Window()->FindView("panel");
|
|
||||||
DNSSettingsView* settingsView = dynamic_cast<DNSSettingsView*>(
|
|
||||||
panel->ChildAt(0));
|
|
||||||
|
|
||||||
// View not active - nothing to save
|
|
||||||
if (settingsView == NULL)
|
|
||||||
return B_OK;
|
|
||||||
|
|
||||||
return settingsView->Apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
ServicesAddOn::Revert()
|
|
||||||
{
|
|
||||||
BView* panel = Window()->FindView("panel");
|
|
||||||
DNSSettingsView* settingsView = dynamic_cast<DNSSettingsView*>(
|
|
||||||
panel->ChildAt(0));
|
|
||||||
|
|
||||||
// View not active - nothing to revert
|
|
||||||
if (settingsView == NULL)
|
|
||||||
return B_OK;
|
|
||||||
|
|
||||||
return settingsView->Revert();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
ServicesAddOn::_ParseInetd()
|
|
||||||
{
|
|
||||||
FILE *f = fopen("/etc/inetd.conf", "r");
|
|
||||||
if (f) {
|
|
||||||
char line[1024], *linePtr;
|
|
||||||
char *token;
|
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), f)) {
|
|
||||||
linePtr = line;
|
|
||||||
if (! *linePtr)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (line[0] == '#') {
|
|
||||||
if (line[1] == ' ' || line[1] == '\t' ||
|
|
||||||
line[1] == '\0' || line[1] == '\n' ||
|
|
||||||
line[1] == '\r')
|
|
||||||
// skip comments
|
|
||||||
continue;
|
|
||||||
linePtr++; // jump the disable/comment service mark
|
|
||||||
}
|
|
||||||
|
|
||||||
BString label;
|
|
||||||
token = strtok(linePtr, " \t"); // service name
|
|
||||||
label << token;
|
|
||||||
token = strtok(NULL, " \t"); // type
|
|
||||||
label << " (" << token << ")";
|
|
||||||
token = strtok(NULL, " \t"); // protocol
|
|
||||||
label << " " << token;
|
|
||||||
|
|
||||||
fServicesListView->AddItem(new BStringItem(label.String()));
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
ServicesAddOn::_ParseXinetd()
|
|
||||||
{
|
|
||||||
FILE *f = fopen("/boot/system/settings/network/services", "r");
|
|
||||||
if (f) {
|
|
||||||
char line[1024], *linePtr;
|
|
||||||
char *token;
|
|
||||||
char *loc;
|
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), f)) {
|
|
||||||
linePtr = line;
|
|
||||||
|
|
||||||
if (! *linePtr)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (line[0] == '#' || line[0] == '\n') {
|
|
||||||
// Skip commented out lines
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
loc = strstr(linePtr, "service ");
|
|
||||||
|
|
||||||
if (loc) {
|
|
||||||
BString label;
|
|
||||||
strtok(loc, " ");
|
|
||||||
token = strtok(NULL, " ");
|
|
||||||
label << token;
|
|
||||||
fServicesListView->AddItem(new BStringItem(label.String()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ServicesAddOn::_ShowPanel()
|
|
||||||
{
|
|
||||||
BStringItem* item = static_cast<BStringItem*>(
|
|
||||||
fServicesListView->ItemAt(fServicesListView->CurrentSelection()));
|
|
||||||
|
|
||||||
if (item == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BView* panel = Window()->FindView("panel");
|
|
||||||
BView* settingsView = panel->ChildAt(0);
|
|
||||||
|
|
||||||
// Remove currently displayed settings view
|
|
||||||
if (settingsView != NULL) {
|
|
||||||
settingsView->RemoveSelf();
|
|
||||||
delete settingsView;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(item->Text(), B_TRANSLATE_NOCOLLECT(kDNSSettingsName)) == 0) {
|
|
||||||
settingsView = new DNSSettingsView();
|
|
||||||
panel->AddChild(settingsView);
|
|
||||||
} else {
|
|
||||||
// TODO show a standard "inetd service" view
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2004-2011 Haiku Inc. All rights reserved.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Alexander von Gluck, [email protected]
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "NetworkSetupAddOn.h"
|
|
||||||
|
|
||||||
#include <GroupView.h>
|
|
||||||
|
|
||||||
|
|
||||||
class BListView;
|
|
||||||
|
|
||||||
|
|
||||||
class ServicesAddOn : public NetworkSetupAddOn, public BGroupView {
|
|
||||||
public:
|
|
||||||
ServicesAddOn(image_id addon_image);
|
|
||||||
BView* CreateView();
|
|
||||||
|
|
||||||
void AttachedToWindow();
|
|
||||||
void MessageReceived(BMessage*);
|
|
||||||
void Show();
|
|
||||||
|
|
||||||
status_t Save();
|
|
||||||
status_t Revert();
|
|
||||||
|
|
||||||
private:
|
|
||||||
status_t _ParseInetd();
|
|
||||||
status_t _ParseXinetd();
|
|
||||||
void _ShowPanel();
|
|
||||||
|
|
||||||
private:
|
|
||||||
BListView* fServicesListView;
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user