Exemple #1
0
void
EthernetSettingsView::MessageReceived(BMessage* message)
{
    switch (message->what) {
    case kMsgStaticMode:
    case kMsgDHCPMode:
    case kMsgDisabledMode:
    case kMsgNetwork:
        _EnableTextControls(message->what == kMsgStaticMode);
        fApplyButton->SetEnabled(true);
        fRevertButton->SetEnabled(true);
        break;
    case kMsgInfo:
    {
        const char* name;
        if (message->FindString("interface", &name) != B_OK)
            break;
        for (int32 i = 0; i < fSettings.CountItems(); i++) {
            Settings* settings = fSettings.ItemAt(i);
            if (strcmp(settings->Name(), name) == 0) {
                _ShowConfiguration(settings);
                break;
            }
        }
        break;
    }
    case kMsgRevert:
        _ShowConfiguration(fCurrentSettings);
        fRevertButton->SetEnabled(false);
        break;
    case kMsgApply:
        if (_ValidateControl(fIPTextControl)
                && _ValidateControl(fNetMaskTextControl)
                && (strlen(fGatewayTextControl->Text()) == 0
                    || _ValidateControl(fGatewayTextControl))
                && (strlen(fPrimaryDNSTextControl->Text()) == 0
                    || _ValidateControl(fPrimaryDNSTextControl))
                && (strlen(fSecondaryDNSTextControl->Text()) == 0
                    || _ValidateControl(fSecondaryDNSTextControl)))
            _SaveConfiguration();
        break;
    case kMsgChange:
        fErrorMessage->SetText("");
        fApplyButton->SetEnabled(true);
        break;
    default:
        BView::MessageReceived(message);
    }
}
void
NetworkStatusView::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case B_NETWORK_MONITOR:
			_Update();
			break;

		case kMsgShowConfiguration:
			_ShowConfiguration(message);
			break;

		case kMsgOpenNetworkPreferences:
			_OpenNetworksPreferences();
			break;

		case kMsgJoinNetwork:
		{
			const char* deviceName;
			const char* name;
			BNetworkAddress address;
			if (message->FindString("device", &deviceName) == B_OK
				&& message->FindString("name", &name) == B_OK
				&& message->FindFlat("address", &address) == B_OK) {
				BNetworkDevice device(deviceName);
				status_t status = device.JoinNetwork(address);
				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->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
					alert->Go(NULL);
				}
			}
			break;
		}

		case B_ABOUT_REQUESTED:
			_AboutRequested();
			break;

		case B_QUIT_REQUESTED:
			_Quit();
			break;

		default:
			BView::MessageReceived(message);
	}
}
void
EthernetSettingsView::AttachedToWindow()
{
	fApplyButton->SetTarget(this);
	fRevertButton->SetTarget(this);
	fIPTextControl->SetTarget(this);
	fNetMaskTextControl->SetTarget(this);
	fGatewayTextControl->SetTarget(this);
	fPrimaryDNSTextControl->SetTarget(this);
	fSecondaryDNSTextControl->SetTarget(this);
	fDeviceMenuField->Menu()->SetTargetForItems(this);
	fTypeMenuField->Menu()->SetTargetForItems(this);

	// display settigs of first adapter on startup
	_ShowConfiguration(fSettings.ItemAt(0));
}
Exemple #4
0
void
IPSettingsView::AttachedToWindow()
{
	fApplyButton->SetTarget(this);
	fRevertButton->SetTarget(this);
	fIPTextControl->SetTarget(this);
	fNetMaskTextControl->SetTarget(this);
	fGatewayTextControl->SetTarget(this);
	fPrimaryDNSTextControl->SetTarget(this);
	fSecondaryDNSTextControl->SetTarget(this);
	fDomainTextControl->SetTarget(this);
	fDeviceMenuField->Menu()->SetTargetForItems(this);
	fNetworkMenuField->Menu()->SetTargetForItems(this);
	fTypeMenuField->Menu()->SetTargetForItems(this);

	// Display settigs of first adapter on startup, if any
	_ShowConfiguration(fSettings);
}