Debugger: Flesh out network config view.
NetworkConnectionConfigView: - Port input field is now prepopulated with the default remote debug port number. - Changes to either field now trigger listener notifications.
This commit is contained in:
+53
-13
@@ -1,31 +1,47 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016, Rene Gollent, [email protected].
|
* Copyright 2016-2017, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#include "NetworkConnectionConfigView.h"
|
#include "NetworkConnectionConfigView.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
|
|
||||||
|
#include "Settings.h"
|
||||||
|
#include "SettingsDescription.h"
|
||||||
|
#include "TargetHostInterfaceInfo.h"
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MSG_NET_CONFIG_INPUT_CHANGED = 'ncic'
|
MSG_NET_CONFIG_INPUT_CHANGED = 'ncic'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static const char* kHostSetting = "hostname";
|
||||||
|
static const char* kPortSetting = "port";
|
||||||
|
|
||||||
|
|
||||||
NetworkConnectionConfigView::NetworkConnectionConfigView()
|
NetworkConnectionConfigView::NetworkConnectionConfigView()
|
||||||
:
|
:
|
||||||
ConnectionConfigView("NetworkConnectionConfig"),
|
ConnectionConfigView("NetworkConnectionConfig"),
|
||||||
fProtocolField(NULL),
|
fProtocolField(NULL),
|
||||||
fHostInput(NULL),
|
fHostInput(NULL),
|
||||||
fPortInput(NULL)
|
fPortInput(NULL),
|
||||||
|
fSettings(NULL),
|
||||||
|
fHostSetting(NULL),
|
||||||
|
fPortSetting(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NetworkConnectionConfigView::~NetworkConnectionConfigView()
|
NetworkConnectionConfigView::~NetworkConnectionConfigView()
|
||||||
{
|
{
|
||||||
|
if (fSettings != NULL)
|
||||||
|
fSettings->ReleaseReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -45,10 +61,12 @@ NetworkConnectionConfigView::MessageReceived(BMessage* message)
|
|||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case MSG_NET_CONFIG_INPUT_CHANGED:
|
case MSG_NET_CONFIG_INPUT_CHANGED:
|
||||||
{
|
{
|
||||||
// TODO: implement
|
fSettings->SetValue(fHostSetting, fHostInput->Text());
|
||||||
|
uint16 port = (uint16)strtoul(fPortInput->Text(), NULL, 10);
|
||||||
|
fSettings->SetValue(fPortSetting, port);
|
||||||
|
NotifyConfigurationChanged(fSettings);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ConnectionConfigView::MessageReceived(message);
|
ConnectionConfigView::MessageReceived(message);
|
||||||
@@ -61,25 +79,47 @@ NetworkConnectionConfigView::MessageReceived(BMessage* message)
|
|||||||
status_t
|
status_t
|
||||||
NetworkConnectionConfigView::InitSpecific()
|
NetworkConnectionConfigView::InitSpecific()
|
||||||
{
|
{
|
||||||
|
SettingsDescription* description
|
||||||
|
= InterfaceInfo()->GetSettingsDescription();
|
||||||
|
|
||||||
|
for (int32 i = 0; i < description->CountSettings(); i++) {
|
||||||
|
Setting* setting = description->SettingAt(i);
|
||||||
|
if (strcmp(setting->ID(), kPortSetting) == 0)
|
||||||
|
fPortSetting = setting;
|
||||||
|
else if (strcmp(setting->ID(), kHostSetting) == 0)
|
||||||
|
fHostSetting = setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fPortSetting == NULL || fHostSetting == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
fSettings = new Settings(description);
|
||||||
fPortInput = new BTextControl("port_input", "Port:", "",
|
fPortInput = new BTextControl("port_input", "Port:", "",
|
||||||
new BMessage(MSG_NET_CONFIG_INPUT_CHANGED));
|
new BMessage(MSG_NET_CONFIG_INPUT_CHANGED));
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
BLayoutItem* textLayoutItem;
|
||||||
.AddGroup(B_HORIZONTAL)
|
BLayoutBuilder::Group<>(this, B_HORIZONTAL)
|
||||||
.Add((fHostInput = new BTextControl("host_input", "Host:", "",
|
.Add((fHostInput = new BTextControl("host_input", "Host:", "",
|
||||||
new BMessage(MSG_NET_CONFIG_INPUT_CHANGED))))
|
new BMessage(MSG_NET_CONFIG_INPUT_CHANGED))))
|
||||||
.Add(fPortInput->CreateLabelLayoutItem())
|
.Add(fPortInput->CreateLabelLayoutItem())
|
||||||
.Add(fPortInput->CreateTextViewLayoutItem())
|
.Add((textLayoutItem = fPortInput->CreateTextViewLayoutItem()))
|
||||||
.End()
|
|
||||||
.End();
|
.End();
|
||||||
|
|
||||||
// since port numbers are limited to 5 digits, there's no need for
|
// since port numbers are limited to 5 digits, there's no need for
|
||||||
// the port input to expand farther than that. Instead, let the
|
// the port input to expand farther than that. Instead, let the
|
||||||
// host field take the extra space.
|
// host field take the extra space.
|
||||||
fPortInput->CreateTextViewLayoutItem()->SetExplicitMaxSize(BSize(
|
textLayoutItem->SetExplicitMaxSize(BSize(
|
||||||
be_plain_font->StringWidth("999999"), B_SIZE_UNSET));
|
be_plain_font->StringWidth("999999"), B_SIZE_UNSET));
|
||||||
|
|
||||||
// TODO: init settings and protocol input
|
|
||||||
|
BString buffer;
|
||||||
|
buffer.SetToFormat("%" B_PRIu16, fPortSetting->DefaultValue().ToUInt16());
|
||||||
|
fPortInput->SetText(buffer);
|
||||||
|
|
||||||
|
fHostInput->SetModificationMessage(
|
||||||
|
new BMessage(MSG_NET_CONFIG_INPUT_CHANGED));
|
||||||
|
fPortInput->SetModificationMessage(
|
||||||
|
new BMessage(MSG_NET_CONFIG_INPUT_CHANGED));
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
class BMenuField;
|
class BMenuField;
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
|
class Setting;
|
||||||
|
|
||||||
|
|
||||||
class NetworkConnectionConfigView : public ConnectionConfigView{
|
class NetworkConnectionConfigView : public ConnectionConfigView{
|
||||||
@@ -27,6 +28,9 @@ private:
|
|||||||
BMenuField* fProtocolField;
|
BMenuField* fProtocolField;
|
||||||
BTextControl* fHostInput;
|
BTextControl* fHostInput;
|
||||||
BTextControl* fPortInput;
|
BTextControl* fPortInput;
|
||||||
|
Settings* fSettings;
|
||||||
|
Setting* fHostSetting;
|
||||||
|
Setting* fPortSetting;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user