Remove the "old" network preflet.
This code is unused since 2007 and it's in the git history if you ever need it again.
This commit is contained in:
@@ -1,178 +0,0 @@
|
|||||||
#include <Alert.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <File.h>
|
|
||||||
#include "BackupWindow.h"
|
|
||||||
#include "NetworkWindow.h"
|
|
||||||
#include "NetListView.h"
|
|
||||||
#include "ConfigData.h"
|
|
||||||
|
|
||||||
BackupWin::BackupWin(const BRect &frame)
|
|
||||||
: BWindow(frame,"Backup Win",B_MODAL_WINDOW,
|
|
||||||
B_NOT_ANCHORED_ON_ACTIVATE | B_NOT_RESIZABLE,B_CURRENT_WORKSPACE)
|
|
||||||
{
|
|
||||||
BRect r(Bounds());
|
|
||||||
|
|
||||||
BView *view=new BView(Bounds(),"Backup",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
|
|
||||||
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
AddChild(view);
|
|
||||||
|
|
||||||
fDone=new BButton(BRect(0,0,1,1),"Done","Done",new BMessage(kSaveBackup_M));
|
|
||||||
fDone->ResizeToPreferred();
|
|
||||||
fDone->MoveTo(r.right - 5 - fDone->Bounds().Width(),
|
|
||||||
r.bottom - 5 - fDone->Bounds().Height());
|
|
||||||
|
|
||||||
fCancel=new BButton(BRect(100,50,190,70),"Cancel","Cancel",
|
|
||||||
new BMessage(kCancel_bak_M));
|
|
||||||
fCancel->ResizeToPreferred();
|
|
||||||
fCancel->MoveTo(fDone->Frame().left - 5 - fCancel->Frame().Width(),
|
|
||||||
fDone->Frame().top);
|
|
||||||
|
|
||||||
fName=new BTextControl(BRect(5,5,r.right - 10,40),"Backup As","Backup As:",
|
|
||||||
NULL,new BMessage(),B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
|
||||||
float w,h;
|
|
||||||
fName->GetPreferredSize(&w,&h);
|
|
||||||
fName->ResizeTo(r.right - 10, h);
|
|
||||||
fName->MoveTo(5, 5 + (fCancel->Frame().top-h-10)/2);
|
|
||||||
fName->SetDivider(fName->StringWidth("Backup As:")+10);
|
|
||||||
|
|
||||||
view->AddChild(fName);
|
|
||||||
view->AddChild(fCancel);
|
|
||||||
view->AddChild(fDone);
|
|
||||||
fDone->MakeDefault(true);
|
|
||||||
fName->MakeFocus(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
BackupWin::MessageReceived(BMessage *message)
|
|
||||||
{
|
|
||||||
switch (message->what) {
|
|
||||||
|
|
||||||
case kCancel_bak_M: {
|
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kSaveBackup_M: {
|
|
||||||
|
|
||||||
if (strlen(fName->Text()) > 0) {
|
|
||||||
SaveBackup(fName->Text()); //Writes the new config file
|
|
||||||
fParentWindow->Lock();
|
|
||||||
fParentWindow->LoadConfigEntries(); //Update the list
|
|
||||||
fParentWindow->fConfigurationsList->SelectionChanged(); //Update the buttons
|
|
||||||
fParentWindow->Unlock();
|
|
||||||
Quit();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
BAlert *alert = new BAlert("Backup Info Alert","You must specify a name.","OK");
|
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
|
||||||
alert->Go();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
BackupWin::SaveBackup(const char *bak_name)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
// GLOBAL: section
|
|
||||||
BString DNS_DOMAIN = "\n\tDNS_DOMAIN = ";
|
|
||||||
DNS_DOMAIN << fParentWindow->fDomain->Text();
|
|
||||||
BString HOSTNAME = "\n\tHOSTNAME = ";
|
|
||||||
HOSTNAME << fParentWindow->fHost->Text();
|
|
||||||
BString USERNAME = "\n\tUSERNAME = ";
|
|
||||||
USERNAME << fParentWindow->flogin_info_S[0];
|
|
||||||
BString PROTOCOLS = "\n\tPROTOCOLS = ";//where to get that info ??
|
|
||||||
BString PASSWORD = "\n\tPASSWORD = ";
|
|
||||||
PASSWORD << fParentWindow->flogin_info_S[1];
|
|
||||||
BString FTP_ENABLED = "\n\tFTP_ENABLED = ";
|
|
||||||
if (fParentWindow->fFTPServer->Value() == 0)
|
|
||||||
FTP_ENABLED << 0;
|
|
||||||
else FTP_ENABLED << 1;
|
|
||||||
BString IP_FORWARD = "\n\tIP_FORWARD = ";
|
|
||||||
if (fParentWindow->fIPForwarding->Value() == 0)
|
|
||||||
IP_FORWARD << 0;
|
|
||||||
else IP_FORWARD << 1;
|
|
||||||
BString DNS_ENABLED = "\n\tDNS_ENABLED = ";//where to get that info ??
|
|
||||||
BString TELNETD_ENABLED = "\n\tTELNETD_ENABLED = ";
|
|
||||||
if (fParentWindow->fTelnetServer->Value() == 0)
|
|
||||||
TELNETD_ENABLED << 0;
|
|
||||||
else TELNETD_ENABLED << 1;
|
|
||||||
BString DNS_PRIMARY = "\n\tDNS_PRIMARY = ";
|
|
||||||
DNS_PRIMARY << fParentWindow->fPrimaryDNS->Text();
|
|
||||||
BString DNS_SECONDARY = "\n\tDNS_SECONDARY = ";
|
|
||||||
DNS_SECONDARY << fParentWindow->fSecondaryDNS->Text();
|
|
||||||
BString ROUTER = "\n\tROUTER = ";//where to get that info ??
|
|
||||||
BString VERSION = "\n\tVERSION = ";//where to get that info ??
|
|
||||||
BString INTERFACES = "\n\tINTERFACES = ";//Unused but kept for background compatibility
|
|
||||||
|
|
||||||
// Now let's see how many interfaces there are
|
|
||||||
int32 numb = fParentWindow->fInterfacesList->CountItems();
|
|
||||||
|
|
||||||
// Each interface has 8 fields
|
|
||||||
BString fields[numb][8];
|
|
||||||
|
|
||||||
for(int i=0;i<numb;i++){ //Let's fill the fields
|
|
||||||
fields[i][0] = "\n\tDEVICECONFIG = "; //where to get that info ??
|
|
||||||
fields[i][1] = "\n\tDEVICELINK = "; //where to get that info ??
|
|
||||||
fields[i][2] = "\n\tDEVICETYPE = "; //where to get that info ??
|
|
||||||
fields[i][3] = "\n\tIPADDRESS = ";
|
|
||||||
fields[i][4] = "\n\tNETMASK = ";
|
|
||||||
fields[i][5] = "\n\tPRETTYNAME = ";
|
|
||||||
fields[i][6] = "\n\tENABLED = ";
|
|
||||||
fields[i][7] = "\n\tDHCP = ";
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i=0;i<numb;i++){ //Now let's put the data
|
|
||||||
NetListItem *item = dynamic_cast <NetListItem *> (fParentWindow->fInterfacesList->ItemAt(i));
|
|
||||||
|
|
||||||
fields[i][3] << item->fIPADDRESS;
|
|
||||||
fields[i][4] << item->fNETMASK;
|
|
||||||
fields[i][5] << item->fPRETTYNAME;
|
|
||||||
fields[i][6] << item->fENABLED;
|
|
||||||
fields[i][7] << item->fDHCP;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now let's write all this stuff
|
|
||||||
BString path;
|
|
||||||
path = "/boot/home/config/settings/network";
|
|
||||||
|
|
||||||
// This SaveBackup() function is used for backups(so a network.<name> file)
|
|
||||||
// and for the "Save" button which uses the network file as the backup file.
|
|
||||||
if (bak_name != NULL)
|
|
||||||
path << "." << bak_name;
|
|
||||||
else {
|
|
||||||
BEntry entry(path.String());
|
|
||||||
entry.Remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
FILE *bak_file = fopen(path.String(),"w");
|
|
||||||
fprintf(bak_file,"GLOBAL:"); //The "GLOBAL" part
|
|
||||||
fprintf(bak_file,DNS_DOMAIN.String());
|
|
||||||
fprintf(bak_file,HOSTNAME.String());
|
|
||||||
fprintf(bak_file,USERNAME.String());
|
|
||||||
fprintf(bak_file,PROTOCOLS.String());
|
|
||||||
fprintf(bak_file,PASSWORD.String());
|
|
||||||
fprintf(bak_file,FTP_ENABLED.String());
|
|
||||||
fprintf(bak_file,IP_FORWARD.String());
|
|
||||||
fprintf(bak_file,DNS_ENABLED.String());
|
|
||||||
fprintf(bak_file,TELNETD_ENABLED.String());
|
|
||||||
fprintf(bak_file,DNS_PRIMARY.String());
|
|
||||||
fprintf(bak_file,DNS_SECONDARY.String());
|
|
||||||
fprintf(bak_file,ROUTER.String());
|
|
||||||
fprintf(bak_file,VERSION.String());
|
|
||||||
fprintf(bak_file,INTERFACES.String());
|
|
||||||
|
|
||||||
for (int i=0;i<numb;i++) {
|
|
||||||
|
|
||||||
// The interfacexx parts
|
|
||||||
BString interfacex = "\ninterface";
|
|
||||||
interfacex << i << ":";
|
|
||||||
fprintf(bak_file,interfacex.String());
|
|
||||||
for (int j=0;j<8;j++)
|
|
||||||
fprintf(bak_file,fields[i][j].String());
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(bak_file);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#ifndef BACKUP_WIN_H
|
|
||||||
#define BACKUP_WIN_H
|
|
||||||
|
|
||||||
#include <Window.h>
|
|
||||||
#include <View.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <Button.h>
|
|
||||||
|
|
||||||
class NetworkWindow;
|
|
||||||
|
|
||||||
// The window that appears when you press the 'Backup' button
|
|
||||||
class BackupWin : public BWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BackupWin(const BRect &frame);
|
|
||||||
|
|
||||||
BTextControl *fName;
|
|
||||||
BButton *fCancel;
|
|
||||||
BButton *fDone;
|
|
||||||
|
|
||||||
NetworkWindow *fParentWindow;
|
|
||||||
|
|
||||||
void SaveBackup(const char *name=NULL);
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
|
||||||
|
|
||||||
static const int32 kSaveBackup_M = 'fbam' ;
|
|
||||||
static const int32 kCancel_bak_M = 'cbam' ;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,488 +0,0 @@
|
|||||||
#include "ConfigData.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
InterfaceData::InterfaceData(const char *name)
|
|
||||||
:
|
|
||||||
fConfig(""),
|
|
||||||
fPath(""),
|
|
||||||
fType("ETHERNET"),
|
|
||||||
fIPAddress("192.168.0.2"),
|
|
||||||
fNetMask("255.255.255.0"),
|
|
||||||
fGateway("192.168.0.1"),
|
|
||||||
fPrettyName(""),
|
|
||||||
fName(name),
|
|
||||||
fEnabled(true),
|
|
||||||
fDHCP(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigData::ConfigData(void)
|
|
||||||
: fDomainName(""),
|
|
||||||
fHostname(""),
|
|
||||||
fPrimaryDNS(""),
|
|
||||||
fSecondaryDNS(""),
|
|
||||||
fFTPServer(false),
|
|
||||||
fTelnetServer(false),
|
|
||||||
fUsername(""),
|
|
||||||
fPassword(""),
|
|
||||||
fProtocols(""),
|
|
||||||
fAppleTalk(false),
|
|
||||||
fIPForwarding(false),
|
|
||||||
fUseDNS(true),
|
|
||||||
fInterfaceList(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigData::~ConfigData(void)
|
|
||||||
{
|
|
||||||
EmptyInterfaces();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ConfigData::EmptyInterfaces(void)
|
|
||||||
{
|
|
||||||
for(int32 i=0; i<fInterfaceList.CountItems(); i++)
|
|
||||||
{
|
|
||||||
InterfaceData *data = (InterfaceData*) fInterfaceList.ItemAt(i);
|
|
||||||
delete data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SaveBackup(const char *filename, ConfigData &data)
|
|
||||||
{
|
|
||||||
BString filedata("GLOBAL:");
|
|
||||||
|
|
||||||
filedata << "\n\tDNS_DOMAIN = " << data.fDomainName;
|
|
||||||
filedata << "\n\tHOSTNAME = " << data.fHostname;
|
|
||||||
filedata << "\n\tUSERNAME = " << data.fUsername;
|
|
||||||
|
|
||||||
// This is currently unused. Vestigial limb, perhaps?
|
|
||||||
filedata << "\n\tPROTOCOLS = " << data.fProtocols;
|
|
||||||
filedata << "\n\tPASSWORD = " << data.fPassword;
|
|
||||||
filedata << "\n\tFTP_ENABLED = " << (data.fFTPServer ? "1" : "0");
|
|
||||||
filedata << "\n\tIP_FORWARD = " << (data.fIPForwarding ? "1" : "0");
|
|
||||||
filedata << "\n\tDNS_ENABLED = " << (data.fUseDNS ? "1" : "0");
|
|
||||||
filedata << "\n\tTELNETD_ENABLED = " << (data.fTelnetServer ? "1" : "0");
|
|
||||||
filedata << "\n\tDNS_PRIMARY = " << data.fPrimaryDNS;
|
|
||||||
filedata << "\n\tDNS_SECONDARY = " << data.fSecondaryDNS;
|
|
||||||
|
|
||||||
// Is this another vestigial limb from an older OS version?
|
|
||||||
filedata << "\n\tROUTER = " << "192.168.0.1";
|
|
||||||
|
|
||||||
// I'm assuming that this is the network settings file format
|
|
||||||
filedata << "\n\tVERSION = " << "V1.00";
|
|
||||||
|
|
||||||
// We'll add the trailing space when we add the interface names
|
|
||||||
filedata << "\n\tINTERFACES =";
|
|
||||||
|
|
||||||
// Now let's see how many interfaces there are
|
|
||||||
int32 count = data.fInterfaceList.CountItems();
|
|
||||||
|
|
||||||
// special hack if there are no available network interfaces. :)
|
|
||||||
if(count==0)
|
|
||||||
filedata << " ";
|
|
||||||
|
|
||||||
for(int32 i=0; i<count; i++)
|
|
||||||
filedata << " interface" << i;
|
|
||||||
|
|
||||||
// Now onto the interface sections
|
|
||||||
|
|
||||||
for(int32 i=0; i<count; i++) {
|
|
||||||
|
|
||||||
InterfaceData *interface = (InterfaceData*) data.fInterfaceList.ItemAt(i);
|
|
||||||
if(!interface)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
filedata << "\ninterface" << i << ":";
|
|
||||||
|
|
||||||
filedata << "\n\tDEVICECONFIG = " << interface->fConfig;
|
|
||||||
filedata << "\n\tDEVICELINK = " << interface->fPath;
|
|
||||||
filedata << "\n\tDEVICETYPE = " << interface->fType;
|
|
||||||
filedata << "\n\tIPADDRESS = " << interface->fIPAddress;
|
|
||||||
filedata << "\n\tNETMASK = " << interface->fNetMask;
|
|
||||||
filedata << "\n\tPRETTYNAME = " << interface->fPrettyName;
|
|
||||||
filedata << "\n\tENABLED = " << (interface->fEnabled ? "1" : "0");
|
|
||||||
filedata << "\n\tDHCP = " << (interface->fDHCP ? "1" : "0");
|
|
||||||
}
|
|
||||||
|
|
||||||
filedata << "\n";
|
|
||||||
|
|
||||||
// Now let's write all this stuff
|
|
||||||
BString path("/boot/home/config/settings/network");
|
|
||||||
|
|
||||||
// This SaveBackup() function is used for backups(so a network.<name> file)
|
|
||||||
// and for the "Save" button which uses the network file as the backup file.
|
|
||||||
if(filename)
|
|
||||||
path << "." << filename;
|
|
||||||
|
|
||||||
BFile file(path.String(),B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
|
||||||
if(file.InitCheck()!=B_OK)
|
|
||||||
{
|
|
||||||
printf("DEBUG: Couldn't create network settings file %s\n",path.String());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.Write(filedata.String(),filedata.Length());
|
|
||||||
|
|
||||||
file.Unset();
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t
|
|
||||||
LoadBackup(const char *pathname, ConfigData &data)
|
|
||||||
{
|
|
||||||
// The configuration is saved in the /boot/home/config/settings/network
|
|
||||||
// text file so the config is static. Maybe we could switch to dynamic by
|
|
||||||
// directly asking the net_server how things are
|
|
||||||
|
|
||||||
// This function being used when pressing "Revert" so first we need to
|
|
||||||
// empty things before setting the new values
|
|
||||||
ConfigData empty;
|
|
||||||
data.EmptyInterfaces();
|
|
||||||
data = empty;
|
|
||||||
|
|
||||||
// Read in the data from the file
|
|
||||||
|
|
||||||
BString pathstring = "/boot/home/config/settings/network";
|
|
||||||
if(pathname)
|
|
||||||
pathstring << "." << pathname;
|
|
||||||
|
|
||||||
BFile file(pathstring.String(),B_READ_ONLY);
|
|
||||||
if(file.InitCheck()!=B_OK)
|
|
||||||
return file.InitCheck();
|
|
||||||
|
|
||||||
off_t filesize;
|
|
||||||
file.GetSize(&filesize);
|
|
||||||
|
|
||||||
if(filesize < 1)
|
|
||||||
return B_ERROR;
|
|
||||||
|
|
||||||
char *filestr = new char[filesize + 1];
|
|
||||||
|
|
||||||
filestr[filesize + 1] = 0;
|
|
||||||
file.Read(filestr, filesize);
|
|
||||||
file.Unset();
|
|
||||||
|
|
||||||
char *start=NULL, *end=NULL;
|
|
||||||
|
|
||||||
// This is a little bit more flexible (and slower) implementation than may be necessary. We do use a small
|
|
||||||
// string hack to avoid unnecessary copying
|
|
||||||
start = strstr(filestr,"HOSTNAME = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strstr(start,"\n");
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
data.fHostname = start;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = strstr(filestr,"USERNAME = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
data.fUsername = start + 11;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = strstr(filestr,"HOSTNAME = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
data.fHostname = start + 11;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = strstr(filestr,"PROTOCOLS = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
data.fProtocols = start + 12;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = strstr(filestr,"PASSWORD = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
data.fPassword = start + 11;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = strstr(filestr,"FTP_ENABLED = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
start += 14;
|
|
||||||
data.fFTPServer = (strcmp(start,"1")==0)?true:false;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = strstr(filestr,"IP_FORWARD = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
start += 13;
|
|
||||||
data.fIPForwarding = (strcmp(start,"1")==0)?true:false;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = strstr(filestr,"DNS_ENABLED = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
start += 14;
|
|
||||||
data.fUseDNS = (strcmp(start,"1")==0)?true:false;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = strstr(filestr,"TELNETD_ENABLED = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
start += 18;
|
|
||||||
data.fTelnetServer = (strcmp(start,"1")==0)?true:false;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = strstr(filestr,"DNS_DOMAIN = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
data.fDomainName = start + 13;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = strstr(filestr,"DNS_PRIMARY = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
data.fPrimaryDNS = start + 14;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = strstr(filestr,"DNS_SECONDARY = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
data.fSecondaryDNS = start + 16;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: What should we do with the ROUTER setting if there are more then one card and both
|
|
||||||
// specify settings?
|
|
||||||
|
|
||||||
/*
|
|
||||||
start = strstr(filestr,"ROUTER = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
data.fGateway = start + 9;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = strstr(filestr,"VERSION = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
data.fVersion = start + 9;
|
|
||||||
*end='\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
start = strstr(filestr,"INTERFACES = ");
|
|
||||||
if(start) {
|
|
||||||
|
|
||||||
end = strchr(start,'\n');
|
|
||||||
if(end) {
|
|
||||||
|
|
||||||
*end='\0';
|
|
||||||
BString interfaces = start + 13;
|
|
||||||
*end='\n';
|
|
||||||
|
|
||||||
// Now that we have them, lets find the names of all the interfaces present
|
|
||||||
int32 startpos=0,endpos=0;
|
|
||||||
while(endpos>=0)
|
|
||||||
{
|
|
||||||
endpos = interfaces.FindFirst(" ",startpos);
|
|
||||||
|
|
||||||
BString name = interfaces.String() + startpos;
|
|
||||||
|
|
||||||
if(endpos>=0)
|
|
||||||
name.Truncate(endpos);
|
|
||||||
|
|
||||||
data.fInterfaceList.AddItem(new InterfaceData(name.String()));
|
|
||||||
|
|
||||||
startpos = endpos+1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// OK. Now we've gotten through the GLOBAL section. All that's left is to read each interface section
|
|
||||||
for(int32 i=0; i<data.fInterfaceList.CountItems(); i++)
|
|
||||||
{
|
|
||||||
InterfaceData *idata = (InterfaceData*)data.fInterfaceList.ItemAt(i);
|
|
||||||
|
|
||||||
BString searchstr(idata->fName.String());
|
|
||||||
searchstr << ":";
|
|
||||||
|
|
||||||
char *istart = strstr(filestr,searchstr.String());
|
|
||||||
if(!istart)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
istart = strchr(istart,'\n') + 1;
|
|
||||||
|
|
||||||
BString istring = istart;
|
|
||||||
int32 istringend = istring.FindFirst("interface");
|
|
||||||
if(istringend>=0)
|
|
||||||
istring.Truncate(istringend);
|
|
||||||
|
|
||||||
// OK. At this point, we should have in istring all the data for the interface
|
|
||||||
int32 datastart=0,dataend=0;
|
|
||||||
datastart = istring.FindFirst("DEVICECONFIG = ");
|
|
||||||
if(datastart>=0)
|
|
||||||
{
|
|
||||||
idata->fConfig = istring.String() + datastart;
|
|
||||||
dataend = idata->fConfig.FindFirst("\n");
|
|
||||||
if(dataend>=0)
|
|
||||||
idata->fConfig.Truncate(dataend);
|
|
||||||
|
|
||||||
idata->fConfig = BString(idata->fConfig.String() + 15);
|
|
||||||
}
|
|
||||||
|
|
||||||
datastart = istring.FindFirst("DEVICELINK = ");
|
|
||||||
if(datastart>=0)
|
|
||||||
{
|
|
||||||
idata->fPath = istring.String() + datastart;
|
|
||||||
dataend = idata->fPath.FindFirst("\n");
|
|
||||||
if(dataend>=0)
|
|
||||||
idata->fPath.Truncate(dataend);
|
|
||||||
|
|
||||||
idata->fPath = BString(idata->fPath.String() + 13);
|
|
||||||
}
|
|
||||||
|
|
||||||
datastart = istring.FindFirst("DEVICETYPE = ");
|
|
||||||
if(datastart>=0)
|
|
||||||
{
|
|
||||||
idata->fType = istring.String() + datastart;
|
|
||||||
dataend = idata->fType.FindFirst("\n");
|
|
||||||
if(dataend>=0)
|
|
||||||
idata->fType.Truncate(dataend);
|
|
||||||
|
|
||||||
idata->fType = BString(idata->fType.String() + 13);
|
|
||||||
}
|
|
||||||
|
|
||||||
datastart = istring.FindFirst("IPADDRESS = ");
|
|
||||||
if(datastart>=0)
|
|
||||||
{
|
|
||||||
idata->fIPAddress = istring.String() + datastart;
|
|
||||||
dataend = idata->fIPAddress.FindFirst("\n");
|
|
||||||
if(dataend>=0)
|
|
||||||
idata->fIPAddress.Truncate(dataend);
|
|
||||||
|
|
||||||
idata->fIPAddress = BString(idata->fIPAddress.String() + 12);
|
|
||||||
}
|
|
||||||
|
|
||||||
datastart = istring.FindFirst("NETMASK = ");
|
|
||||||
if(datastart>=0)
|
|
||||||
{
|
|
||||||
idata->fNetMask = istring.String() + datastart;
|
|
||||||
dataend = idata->fNetMask.FindFirst("\n");
|
|
||||||
if(dataend>=0)
|
|
||||||
idata->fNetMask.Truncate(dataend);
|
|
||||||
|
|
||||||
idata->fNetMask = BString(idata->fNetMask.String() + 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
datastart = istring.FindFirst("PRETTYNAME = ");
|
|
||||||
if(datastart>=0)
|
|
||||||
{
|
|
||||||
idata->fPrettyName = istring.String() + datastart;
|
|
||||||
dataend = idata->fPrettyName.FindFirst("\n");
|
|
||||||
if(dataend>=0)
|
|
||||||
idata->fPrettyName.Truncate(dataend);
|
|
||||||
|
|
||||||
idata->fPrettyName = BString(idata->fPrettyName.String() + 13);
|
|
||||||
}
|
|
||||||
|
|
||||||
datastart = istring.FindFirst("ENABLED = ");
|
|
||||||
if(datastart>=0)
|
|
||||||
{
|
|
||||||
BString str = istring.String() + datastart;
|
|
||||||
dataend = str.FindFirst("\n");
|
|
||||||
if(dataend>=0)
|
|
||||||
str.Truncate(dataend);
|
|
||||||
|
|
||||||
idata->fEnabled = (strcmp(str.String() + 10,"1")==0);
|
|
||||||
}
|
|
||||||
|
|
||||||
datastart = istring.FindFirst("DHCP = ");
|
|
||||||
if(datastart>=0)
|
|
||||||
{
|
|
||||||
BString str = istring.String() + datastart;
|
|
||||||
dataend = str.FindFirst("\n");
|
|
||||||
if(dataend>=0)
|
|
||||||
str.Truncate(dataend);
|
|
||||||
|
|
||||||
idata->fDHCP = (strcmp(str.String() + 7,"1")==0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
#ifndef CONFIG_DATA_H
|
|
||||||
#define CONFIG_DATA_H
|
|
||||||
|
|
||||||
#include <String.h>
|
|
||||||
#include <File.h>
|
|
||||||
#include <List.h>
|
|
||||||
|
|
||||||
class InterfaceData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
InterfaceData(const char *name);
|
|
||||||
|
|
||||||
BString fConfig;
|
|
||||||
BString fPath;
|
|
||||||
BString fType;
|
|
||||||
BString fIPAddress;
|
|
||||||
BString fNetMask;
|
|
||||||
BString fGateway;
|
|
||||||
BString fPrettyName;
|
|
||||||
BString fName;
|
|
||||||
|
|
||||||
bool fEnabled;
|
|
||||||
bool fDHCP;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ConfigData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ConfigData(void);
|
|
||||||
~ConfigData(void);
|
|
||||||
void EmptyInterfaces(void);
|
|
||||||
|
|
||||||
BString fDomainName;
|
|
||||||
BString fHostname;
|
|
||||||
BString fPrimaryDNS;
|
|
||||||
BString fSecondaryDNS;
|
|
||||||
|
|
||||||
bool fFTPServer;
|
|
||||||
bool fTelnetServer;
|
|
||||||
|
|
||||||
BString fUsername;
|
|
||||||
BString fPassword;
|
|
||||||
BString fProtocols;
|
|
||||||
|
|
||||||
bool fAppleTalk;
|
|
||||||
bool fIPForwarding;
|
|
||||||
bool fUseDNS;
|
|
||||||
|
|
||||||
BList fInterfaceList;
|
|
||||||
};
|
|
||||||
|
|
||||||
void SaveBackup(const char *filename, ConfigData &data);
|
|
||||||
status_t LoadBackup(const char *pathname, ConfigData &data);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
#include <StringView.h>
|
|
||||||
#include "InterfaceWin.h"
|
|
||||||
#include "NetListView.h"
|
|
||||||
|
|
||||||
InterfaceWin::InterfaceWin(const BRect &frame, const InterfaceData &data)
|
|
||||||
: BWindow(frame,"Interface Win",B_MODAL_WINDOW,
|
|
||||||
B_NOT_ANCHORED_ON_ACTIVATE | B_NOT_RESIZABLE,B_CURRENT_WORKSPACE),
|
|
||||||
fData(data.fName.String())
|
|
||||||
{
|
|
||||||
AddShortcut('W',B_COMMAND_KEY,new BMessage(B_QUIT_REQUESTED));
|
|
||||||
AddShortcut('Q',B_COMMAND_KEY,new BMessage(B_QUIT_REQUESTED));
|
|
||||||
|
|
||||||
BRect r(Bounds());
|
|
||||||
|
|
||||||
fData=data;
|
|
||||||
BView *view=new BView(r,"Interface_View",B_FOLLOW_ALL,B_WILL_DRAW);
|
|
||||||
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
AddChild(view);
|
|
||||||
|
|
||||||
float width,height;
|
|
||||||
|
|
||||||
fName=new BStringView(BRect(5,5,6,6),"Interface_Name",data.fPrettyName.String());
|
|
||||||
fName->GetPreferredSize(&width,&height);
|
|
||||||
fName->ResizeTo(width,height);
|
|
||||||
view->AddChild(fName);
|
|
||||||
|
|
||||||
// There is a serious possibility that the name of the interface may be
|
|
||||||
// longer than the current width of the window, especially at larger font
|
|
||||||
// settings. If this is the case, we will end up resizing the window to fit it
|
|
||||||
// all
|
|
||||||
float maxwidth = MAX(width, r.right);
|
|
||||||
|
|
||||||
float ypos = 5 + height + 20;
|
|
||||||
fEnabled=new BCheckBox(BRect(5,ypos,6,ypos + 1),
|
|
||||||
"Enabled","Interface enabled",
|
|
||||||
new BMessage(kSOMETHING_HAS_CHANGED),
|
|
||||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
|
||||||
fEnabled->GetPreferredSize(&width,&height);
|
|
||||||
fEnabled->ResizeTo(width,height);
|
|
||||||
view->AddChild(fEnabled);
|
|
||||||
|
|
||||||
ypos += height + 10;
|
|
||||||
fDHCP=new BRadioButton(BRect(5,ypos,6,ypos+1),"DHCP",
|
|
||||||
"Obtain settings automatically",
|
|
||||||
new BMessage(kSOMETHING_HAS_CHANGED));
|
|
||||||
fDHCP->GetPreferredSize(&width,&height);
|
|
||||||
fDHCP->ResizeTo(width,height);
|
|
||||||
view->AddChild(fDHCP);
|
|
||||||
|
|
||||||
ypos += height + 1;
|
|
||||||
fManual=new BRadioButton(BRect(5,ypos,6,ypos+1),"Manual","Specify settings",
|
|
||||||
new BMessage(kSOMETHING_HAS_CHANGED));
|
|
||||||
fManual->GetPreferredSize(&width,&height);
|
|
||||||
fManual->ResizeTo(width,height);
|
|
||||||
view->AddChild(fManual);
|
|
||||||
|
|
||||||
ypos += height + 10;
|
|
||||||
|
|
||||||
fIPAddress=new BTextControl(BRect(10,10,6,6),"IP address","IP address:",NULL,
|
|
||||||
new BMessage(kSOMETHING_HAS_CHANGED),
|
|
||||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
|
||||||
fIPAddress->GetPreferredSize(&width,&height);
|
|
||||||
width = r.right - 15;
|
|
||||||
|
|
||||||
fNetMask=new BTextControl(BRect(10,20 + height,width - 5,15 + (height*2)),
|
|
||||||
"Subnet mask","Subnet mask:",NULL,
|
|
||||||
new BMessage(kSOMETHING_HAS_CHANGED),
|
|
||||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
|
||||||
|
|
||||||
fGateway=new BTextControl(BRect(10,30 + (height*2),width - 5,25 + (height*3)),
|
|
||||||
"Gateway","Gateway:",NULL,
|
|
||||||
new BMessage(kSOMETHING_HAS_CHANGED),
|
|
||||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
|
||||||
|
|
||||||
fBox=new BBox(BRect(5,ypos,r.right - 5, ypos + fGateway->Frame().bottom + 10),
|
|
||||||
"IP",B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
|
||||||
view->AddChild(fBox);
|
|
||||||
|
|
||||||
fBox->AddChild(fIPAddress);
|
|
||||||
fBox->AddChild(fNetMask);
|
|
||||||
fBox->AddChild(fGateway);
|
|
||||||
|
|
||||||
// We have to place the ResizeTo() call down here because in R5, these calls
|
|
||||||
// apparently don't do anything unless attached to a window. Grrr....
|
|
||||||
fIPAddress->ResizeTo(width - 15, height);
|
|
||||||
|
|
||||||
float dividersize = fIPAddress->StringWidth("Subnet mask:") + 10;
|
|
||||||
fIPAddress->SetDivider(dividersize);
|
|
||||||
fNetMask->SetDivider(dividersize);
|
|
||||||
fGateway->SetDivider(dividersize);
|
|
||||||
|
|
||||||
fIPAddress->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
|
|
||||||
fNetMask->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
|
|
||||||
fGateway->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
|
|
||||||
|
|
||||||
|
|
||||||
ypos = fBox->Frame().bottom + 10;
|
|
||||||
|
|
||||||
// TODO: Finish the Configure code
|
|
||||||
fConfig=new BButton(BRect(5,ypos,6,ypos+1),"Config","Configure", NULL);
|
|
||||||
fConfig->GetPreferredSize(&width,&height);
|
|
||||||
fConfig->ResizeTo(width,height);
|
|
||||||
view->AddChild(fConfig);
|
|
||||||
|
|
||||||
|
|
||||||
fDone=new BButton(BRect(0,0,1,1),"Done","Done", new BMessage(kDone_inter_M),
|
|
||||||
B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
|
||||||
|
|
||||||
fDone->ResizeToPreferred();
|
|
||||||
fDone->MoveTo(r.right - 5 - fDone->Bounds().right,ypos);
|
|
||||||
|
|
||||||
fCancel=new BButton(BRect(0,0,1,1),"Cancel","Cancel",
|
|
||||||
new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
|
||||||
|
|
||||||
fCancel->ResizeToPreferred();
|
|
||||||
fCancel->MoveTo(fDone->Frame().left - 10 - fCancel->Bounds().right,ypos);
|
|
||||||
view->AddChild(fCancel);
|
|
||||||
view->AddChild(fDone);
|
|
||||||
fDone->MakeDefault(true);
|
|
||||||
|
|
||||||
ypos += height + 10;
|
|
||||||
if(r.bottom < ypos || r.right < maxwidth)
|
|
||||||
ResizeTo( MAX(r.right,maxwidth), MAX(ypos, r.bottom) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void InterfaceWin::MessageReceived(BMessage *message)
|
|
||||||
{
|
|
||||||
switch(message->what) {
|
|
||||||
|
|
||||||
case kDone_inter_M: {
|
|
||||||
// TODO: Re-enable
|
|
||||||
/* if (fChanged==true){
|
|
||||||
fParentWindow->PostMessage(fParentWindow->kSOMETHING_HAS_CHANGED_M);
|
|
||||||
|
|
||||||
NetListItem *item=dynamic_cast <NetListItem *> (fParentWindow->fInterfacesList->ItemAt(fParentWindow->fInterfacesList->CurrentSelection()));
|
|
||||||
|
|
||||||
item->fIPADDRESS=fIPAddress->Text();
|
|
||||||
item->fNETMASK =fNetMask->Text();
|
|
||||||
|
|
||||||
if (fEnabled->Value()==0)
|
|
||||||
item->fENABLED =0;
|
|
||||||
else
|
|
||||||
item->fENABLED =1;
|
|
||||||
|
|
||||||
if (fDHCP->Value()==0)
|
|
||||||
item->fDHCP=0;
|
|
||||||
else
|
|
||||||
item->fDHCP=1;
|
|
||||||
}
|
|
||||||
Quit();
|
|
||||||
*/ break;
|
|
||||||
}
|
|
||||||
case kSOMETHING_HAS_CHANGED: {
|
|
||||||
|
|
||||||
fChanged=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
#ifndef INTERFACE_WIN_H
|
|
||||||
#define INTERFACE_WIN_H
|
|
||||||
|
|
||||||
#include <Window.h>
|
|
||||||
#include <RadioButton.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <Box.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
|
|
||||||
#include "ConfigData.h"
|
|
||||||
#include "NetworkWindow.h"
|
|
||||||
|
|
||||||
// This is the window that appears when you press the 'Settings' button.
|
|
||||||
class InterfaceWin : public BWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
InterfaceWin(const BRect &frame, const InterfaceData &data);
|
|
||||||
|
|
||||||
BStringView *fName;
|
|
||||||
BCheckBox *fEnabled;
|
|
||||||
BRadioButton *fDHCP;
|
|
||||||
BRadioButton *fManual;
|
|
||||||
BButton *fConfig;
|
|
||||||
BButton *fCancel;
|
|
||||||
BButton *fDone;
|
|
||||||
BBox *fBox;
|
|
||||||
BTextControl *fIPAddress;
|
|
||||||
BTextControl *fNetMask;
|
|
||||||
BTextControl *fGateway;
|
|
||||||
|
|
||||||
NetworkWindow *fParentWindow;
|
|
||||||
|
|
||||||
InterfaceData fData;
|
|
||||||
bool fChanged;
|
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
|
||||||
|
|
||||||
static const int32 kCancel_inter_M = 'caim' ;
|
|
||||||
static const int32 kDone_inter_M = 'doim' ;
|
|
||||||
static const int32 kSOMETHING_HAS_CHANGED = 'sohc' ;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
SubDir HAIKU_TOP src preferences network_old ;
|
|
||||||
|
|
||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
|
||||||
|
|
||||||
AddResources Network : Network.rdef ;
|
|
||||||
|
|
||||||
Preference Network :
|
|
||||||
BackupWindow.cpp
|
|
||||||
ConfigData.cpp
|
|
||||||
InterfaceWin.cpp
|
|
||||||
LoginInfo.cpp
|
|
||||||
NetListView.cpp
|
|
||||||
Network.cpp
|
|
||||||
NetworkWindow.cpp
|
|
||||||
;
|
|
||||||
|
|
||||||
LinkAgainst Network : be root ;
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
#include "LoginInfo.h"
|
|
||||||
#include <View.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <Alert.h>
|
|
||||||
#include "NetworkWindow.h"
|
|
||||||
|
|
||||||
LoginInfo::LoginInfo(void)
|
|
||||||
:BWindow(BRect(410,200,710,335),"Login Info",B_MODAL_WINDOW,B_NOT_ANCHORED_ON_ACTIVATE
|
|
||||||
| B_NOT_RESIZABLE,B_CURRENT_WORKSPACE)
|
|
||||||
{
|
|
||||||
fView=new BView(Bounds(),"Login_Info_View",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
|
|
||||||
fName=new BTextControl(BRect(10,10,290,30),"User_Name",
|
|
||||||
"User Name",NULL,new BMessage());
|
|
||||||
fPassword=new BTextControl(BRect(10,40,290,60),"Password",
|
|
||||||
"Password",NULL,new BMessage());
|
|
||||||
fPassword->TextView()->HideTyping(true);
|
|
||||||
fConfirm=new BTextControl(BRect(10,70,290,90),"Confirm Password",
|
|
||||||
"Confirm Password",NULL,new BMessage());
|
|
||||||
fConfirm->TextView()->HideTyping(true);
|
|
||||||
fCancel=new BButton(BRect(100,100,190,120),"Cancel","Cancel",
|
|
||||||
new BMessage(kLogin_Info_Cancel_M));
|
|
||||||
fDone=new BButton(BRect(200,100,290,120),"Done","Done",
|
|
||||||
new BMessage(kLogin_Info_Done_M));
|
|
||||||
|
|
||||||
fDone->MakeDefault(true);
|
|
||||||
fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
fView->AddChild(fName);
|
|
||||||
fView->AddChild(fPassword);
|
|
||||||
fView->AddChild(fConfirm);
|
|
||||||
fView->AddChild(fCancel);
|
|
||||||
fView->AddChild(fDone);
|
|
||||||
|
|
||||||
AddChild(fView);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoginInfo::MessageReceived(BMessage *message)
|
|
||||||
{
|
|
||||||
switch (message->what) {
|
|
||||||
|
|
||||||
case kLogin_Info_Cancel_M: {
|
|
||||||
Quit();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case kLogin_Info_Done_M: {
|
|
||||||
|
|
||||||
const char *login_info_name_S = fName->Text();
|
|
||||||
const char *login_info_password_S = fPassword ->Text();
|
|
||||||
const char *login_info_confirm_S = fConfirm ->Text();
|
|
||||||
|
|
||||||
if (strlen(login_info_name_S)>0 &&
|
|
||||||
strlen(login_info_password_S)>0 &&
|
|
||||||
strlen(login_info_confirm_S)>0 ) {
|
|
||||||
|
|
||||||
if (strcmp(login_info_password_S,login_info_confirm_S) == 0) {
|
|
||||||
|
|
||||||
fParentWindow->flogin_info_S[0] = login_info_name_S;
|
|
||||||
fParentWindow->flogin_info_S[1] = login_info_password_S;
|
|
||||||
fParentWindow->PostMessage(fParentWindow->kSOMETHING_HAS_CHANGED_M);
|
|
||||||
Quit();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
BAlert *alert = new BAlert("Login Info Alert",
|
|
||||||
"Passwords don't match. Please try again","OK");
|
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
|
||||||
alert->Go();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
BAlert *alert = new BAlert("Login Info Alert",
|
|
||||||
"You didn't fill in all the fields","Oops...", NULL, NULL,
|
|
||||||
B_WIDTH_FROM_WIDEST,B_INFO_ALERT);
|
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
|
||||||
alert->Go();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#ifndef LOGIN_INFO_H
|
|
||||||
#define LOGIN_INFO_H
|
|
||||||
|
|
||||||
#include <Window.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
class NetworkWindow;
|
|
||||||
|
|
||||||
// This is the window that appears when you press the 'Login Info' button
|
|
||||||
class LoginInfo : public BWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LoginInfo(void);
|
|
||||||
|
|
||||||
BView *fView;
|
|
||||||
BTextControl *fName;
|
|
||||||
BTextControl *fPassword;
|
|
||||||
BTextControl *fConfirm;
|
|
||||||
BButton *fCancel;
|
|
||||||
BButton *fDone;
|
|
||||||
|
|
||||||
NetworkWindow *fParentWindow;
|
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
|
||||||
|
|
||||||
static const int32 kLogin_Info_Cancel_M = 'licm';
|
|
||||||
static const int32 kLogin_Info_Done_M = 'lidn';
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
#include <Button.h>
|
|
||||||
#include "NetListView.h"
|
|
||||||
|
|
||||||
// The NetListView only exists to override the SelectionChanged() function below
|
|
||||||
NetListView::NetListView(BRect frame,const char *name) : BListView(frame, name)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Buttons are enabled or not depending on the selection in the list
|
|
||||||
// so each time you click in the list, this method is called to update the buttons
|
|
||||||
void NetListView::SelectionChanged(void)
|
|
||||||
{
|
|
||||||
int32 index = CurrentSelection();
|
|
||||||
|
|
||||||
BView *parent = Parent();
|
|
||||||
|
|
||||||
if (index >= 0) {
|
|
||||||
|
|
||||||
// There are 2 lists that are instances of this class, so we have to see in which list you are clicking
|
|
||||||
if (strcmp(parent->Name(),"Interfaces_Scroller") == 0) {
|
|
||||||
|
|
||||||
BButton *settings = dynamic_cast <BButton *> ((parent->Parent())->FindView("Settings"));
|
|
||||||
BButton *clear = dynamic_cast <BButton *> ((parent->Parent())->FindView("Clear"));
|
|
||||||
|
|
||||||
settings->SetEnabled(true);
|
|
||||||
clear->SetEnabled(true);
|
|
||||||
}
|
|
||||||
else if (strcmp(parent->Name(),"Configurations_Scroller") == 0) {
|
|
||||||
|
|
||||||
BButton *restore = dynamic_cast <BButton *> ((parent->Parent())->FindView("Restore"));
|
|
||||||
BButton *remove = dynamic_cast <BButton *> ((parent->Parent())->FindView("Delete"));
|
|
||||||
|
|
||||||
restore ->SetEnabled(true);
|
|
||||||
remove ->SetEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
// There are 2 lists that are instances of this class, so we have to see in which list you are clicking
|
|
||||||
if (strcmp(parent->Name(),"Interfaces_Scroller") == 0) {
|
|
||||||
|
|
||||||
BButton *settings=dynamic_cast <BButton *> ((parent->Parent())->FindView("Settings"));
|
|
||||||
BButton *clear=dynamic_cast <BButton *> ((parent->Parent())->FindView("Clear"));
|
|
||||||
|
|
||||||
settings->SetEnabled(false);
|
|
||||||
clear->SetEnabled(false);
|
|
||||||
}
|
|
||||||
else if (strcmp(parent->Name(),"Configurations_Scroller") == 0) {
|
|
||||||
|
|
||||||
BButton *restore=dynamic_cast <BButton *> ((parent->Parent())->FindView("Restore"));
|
|
||||||
BButton *remove=dynamic_cast <BButton *> ((parent->Parent())->FindView("Delete"));
|
|
||||||
|
|
||||||
restore->SetEnabled(false);
|
|
||||||
remove->SetEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
NetListItem::NetListItem(const InterfaceData &data)
|
|
||||||
: BStringItem(data.fPrettyName.String()),
|
|
||||||
fData(data)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#ifndef NETLISTVIEW_H
|
|
||||||
#define NETLISTVIEW_H
|
|
||||||
|
|
||||||
#include <ListView.h>
|
|
||||||
#include <ListItem.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include "ConfigData.h"
|
|
||||||
|
|
||||||
class NetListView : public BListView
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NetListView(BRect frame,const char *name);
|
|
||||||
|
|
||||||
virtual void SelectionChanged(void);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class NetListItem : public BStringItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NetListItem(const InterfaceData &data);
|
|
||||||
|
|
||||||
InterfaceData fData;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
#include <Alert.h>
|
|
||||||
#include <image.h>
|
|
||||||
#include <Font.h>
|
|
||||||
#include <Messenger.h>
|
|
||||||
#include <OS.h>
|
|
||||||
#include <Roster.h>
|
|
||||||
#include <Screen.h>
|
|
||||||
#include <ScrollView.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "Network.h"
|
|
||||||
#include "NetworkWindow.h"
|
|
||||||
|
|
||||||
class Network : public BApplication
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Network();
|
|
||||||
|
|
||||||
NetworkWindow *fwindow;
|
|
||||||
};
|
|
||||||
|
|
||||||
Network::Network() : BApplication("application/x-vnd.Haiku-Network")
|
|
||||||
{
|
|
||||||
fwindow = new NetworkWindow();
|
|
||||||
fwindow ->Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
Network app;
|
|
||||||
app.Run();
|
|
||||||
return B_NO_ERROR;
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#ifndef _NETWORK_H_
|
|
||||||
#define _NETWORK_H_
|
|
||||||
|
|
||||||
#include <Application.h>
|
|
||||||
#include <StringView.h>
|
|
||||||
#include <View.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
/*General notes:
|
|
||||||
_ Generates two warnings when compiling which you don't have to care about.
|
|
||||||
_ The way the net_server is restarted might not be very good as it takes 0.10s
|
|
||||||
contrarely to Be's original ones that takes few seconds and does many more
|
|
||||||
things that I don't know yet. Will be improved ASAP.(As soon as I know how
|
|
||||||
tings are working...)
|
|
||||||
_ Custom button actually add an interface so I changed his label to "Add"
|
|
||||||
which make it clearer.
|
|
||||||
_ Custom/Add button does nothing because of next line.
|
|
||||||
_ Don't know where to find the "interface types".
|
|
||||||
_ Clear button does nothing as I couldn't find his utility.
|
|
||||||
_ Where to find the App's icon ? Ask Creative Design Team ?
|
|
||||||
_ Is there any "OBOS header" to insert on top of each sheet?
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
|
|
||||||
resource(1, "BEOS:APP_SIG") #'MIMS' "application/x-vnd.Haiku-Network";
|
|
||||||
|
|
||||||
resource(1, "BEOS:APP_VERSION") #'APPV' array
|
|
||||||
{
|
|
||||||
$"0100000000000000000000000200000001000000523100000000000000000000"
|
|
||||||
$"0000000000000000000000000000000000000000000000000000000000000000"
|
|
||||||
$"00000000000000000000000000000000000000004F70656E42654F53204E6574"
|
|
||||||
$"776F726B20507265666C65740000000000000000000000000000000000000000"
|
|
||||||
$"0000000000000000000000000000000000000000000000000000000000000000"
|
|
||||||
$"0000000000000000000000000000000000000000000000000000000000000000"
|
|
||||||
$"0000000000000000000000000000000000000000000000000000000000000000"
|
|
||||||
$"0000000000000000000000000000000000000000000000000000000000000000"
|
|
||||||
$"0000000000000000000000000000000000000000000000000000000000000000"
|
|
||||||
$"0000000000000000000000000000000000000000000000000000000000000000"
|
|
||||||
$"00000000000000000000000000000000000000003B0700003D0700003E070000"
|
|
||||||
$"40070000420700004407000046070000480700004A0700004C0700004E070000"
|
|
||||||
$"5007000052070000530700005507000057070000590700005B0700005D070000"
|
|
||||||
$"5E0700005F070000610700006207000063070000650700006707000069070000"
|
|
||||||
$"6B0700006D0700006E0700006F07000070070000720700007307000074070000"
|
|
||||||
$"75070000760700007707000078070000790700007A0700007B0700007C070000"
|
|
||||||
$"7D0700007E0700007F0700008007000081070000820700008307000084070000"
|
|
||||||
$"8507000086070000890700008C0700008D0700008F0700009107000093070000"
|
|
||||||
$"9507000097070000990700009B0700009D0700009F070000A1070000A3070000"
|
|
||||||
$"A5070000A7070000A9070000AB070000AD070000AF070000B1070000B3070000"
|
|
||||||
$"B5070000B7070000B9070000BB070000BD070000BF070000C1070000C3070000"
|
|
||||||
$"C5070000C7070000"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(1, "BEOS:APP_FLAGS") #'APPF' $"00000000";
|
|
||||||
|
|
||||||
@@ -1,563 +0,0 @@
|
|||||||
#include "NetworkWindow.h"
|
|
||||||
#include "NetListView.h"
|
|
||||||
#include <ScrollView.h>
|
|
||||||
#include <StringView.h>
|
|
||||||
#include <Screen.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <Alert.h>
|
|
||||||
#include <Application.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <Directory.h>
|
|
||||||
#include <Entry.h>
|
|
||||||
#include <File.h>
|
|
||||||
#include <Region.h>
|
|
||||||
#include <Path.h>
|
|
||||||
|
|
||||||
#include "InterfaceWin.h"
|
|
||||||
#include "BackupWindow.h"
|
|
||||||
#include "LoginInfo.h"
|
|
||||||
|
|
||||||
//#define NETWORK_WINDOW_RIGHT 435
|
|
||||||
//#define NETWORK_WINDOW_BOTTOM 309
|
|
||||||
|
|
||||||
class RestartWindow : public BWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RestartWindow();
|
|
||||||
|
|
||||||
BView *fView;
|
|
||||||
BStringView *fRestarting;
|
|
||||||
BStringView *fWhatsHappening;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
RestartWindow::RestartWindow()
|
|
||||||
: BWindow(BRect(400,300,650,350),"Restart Networking",B_MODAL_WINDOW,B_NOT_ANCHORED_ON_ACTIVATE | B_NOT_RESIZABLE,B_CURRENT_WORKSPACE)
|
|
||||||
{
|
|
||||||
fView = new BView(Bounds(),"Restart_View",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
|
|
||||||
|
|
||||||
fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
|
|
||||||
fRestarting = new BStringView(BRect(60,5,200,25),"Restarting_Text_1",
|
|
||||||
"Restarting Networking");
|
|
||||||
fWhatsHappening = new BStringView(BRect(60,30,200,50),"Restarting_Text_2",
|
|
||||||
"Please Wait...");
|
|
||||||
|
|
||||||
BFont font(be_bold_font);
|
|
||||||
|
|
||||||
fRestarting->SetFont(&font);
|
|
||||||
fWhatsHappening->SetFont(&font);
|
|
||||||
|
|
||||||
fView->AddChild(fRestarting);
|
|
||||||
fView->AddChild(fWhatsHappening);
|
|
||||||
|
|
||||||
AddChild(fView);
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkWindow::NetworkWindow()
|
|
||||||
: BWindow(BRect(0, 0, 435, 309),"Network",
|
|
||||||
B_TITLED_WINDOW,B_NOT_ANCHORED_ON_ACTIVATE | B_NOT_ZOOMABLE | B_NOT_RESIZABLE,
|
|
||||||
B_CURRENT_WORKSPACE)
|
|
||||||
{
|
|
||||||
BScreen screen;
|
|
||||||
|
|
||||||
BRect screenframe = screen.Frame(), bounds = Bounds(), workrect(0,0,1,1);
|
|
||||||
float width,height;
|
|
||||||
float screenx, screeny;
|
|
||||||
|
|
||||||
screenx = ((screenframe.right + 1) / 2) - (bounds.right / 2) - 1;
|
|
||||||
screeny = ((screenframe.bottom + 1) / 2) - (bounds.bottom / 2) - 1;
|
|
||||||
MoveTo(screenx, screeny);
|
|
||||||
|
|
||||||
fView = new BView(bounds,"View",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
|
|
||||||
fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
AddChild(fView);
|
|
||||||
|
|
||||||
fRestart = new BButton(workrect,"Restart_Networking",
|
|
||||||
"Restart Networking",new BMessage(kRestart_Networking_M),
|
|
||||||
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
|
||||||
fRestart->GetPreferredSize(&width,&height);
|
|
||||||
fRestart->ResizeTo(width,height);
|
|
||||||
fRestart->MoveTo(10,bounds.bottom - 10 - height);
|
|
||||||
|
|
||||||
// We fake the divider line by using a BBox. We have to call ConstrainClippingRegion
|
|
||||||
// because otherwise we also see the corners drawn, which doesn't look nice
|
|
||||||
BBox *vr = new BBox(BRect(width + 18, bounds.bottom - 11 - height, width + 19,
|
|
||||||
bounds.bottom - 9),
|
|
||||||
"vertical_rule", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
|
||||||
fView->AddChild(vr);
|
|
||||||
|
|
||||||
BRegion clipreg(vr->Bounds().InsetByCopy(0,2));
|
|
||||||
vr->ConstrainClippingRegion(&clipreg);
|
|
||||||
|
|
||||||
fRevert = new BButton(BRect(width + 25,bounds.bottom - 10 - height,width + 26,
|
|
||||||
bounds.bottom - 10),
|
|
||||||
"Revert","Revert", new BMessage(kRevert_M),
|
|
||||||
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
|
||||||
fRevert->ResizeToPreferred();
|
|
||||||
fRevert->SetEnabled(false);
|
|
||||||
|
|
||||||
fSave = new BButton(workrect,"Save","Save",new BMessage(kSave_M),
|
|
||||||
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
|
||||||
fSave->GetPreferredSize(&width,&height);
|
|
||||||
fSave->ResizeTo(width,height);
|
|
||||||
fSave->MoveTo(bounds.right - 10 - width, bounds.bottom - 10 - height);
|
|
||||||
fSave->MakeDefault(true);
|
|
||||||
fSave->SetEnabled(false);
|
|
||||||
|
|
||||||
BBox *hr = new BBox(BRect(0,bounds.bottom - height - 20,bounds.right,
|
|
||||||
bounds.bottom - height - 19),
|
|
||||||
"horizontal_rule",B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
|
|
||||||
fView->AddChild(hr);
|
|
||||||
|
|
||||||
workrect = Bounds();
|
|
||||||
workrect.bottom = hr->Frame().top;
|
|
||||||
workrect.top = 10;
|
|
||||||
|
|
||||||
fTabView = new BTabView(workrect,"tab_view",B_WIDTH_FROM_WIDEST, B_FOLLOW_ALL);
|
|
||||||
fTabView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
fView->AddChild(fTabView);
|
|
||||||
bounds.bottom -= fTabView->TabHeight();
|
|
||||||
|
|
||||||
fView->AddChild(fRestart);
|
|
||||||
fView->AddChild(fRevert);
|
|
||||||
fView->AddChild(fSave);
|
|
||||||
|
|
||||||
bounds = fTabView->Bounds();
|
|
||||||
bounds.bottom -= fTabView->TabHeight();
|
|
||||||
|
|
||||||
fIdentityView = new BView(bounds,"Identity",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
|
|
||||||
fIdentityView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
|
|
||||||
fIdentity = new BTab();
|
|
||||||
fTabView->AddTab(fIdentityView,fIdentity);
|
|
||||||
|
|
||||||
// We can just pick a view to call StringWidth because we're not using anything
|
|
||||||
// except the unaltered be_plain_font. Note that for each BTextControl pair we
|
|
||||||
// just use the longer word of the two in order to save us some speed and code size
|
|
||||||
float labelwidth = fTabView->StringWidth("Domain name: ");
|
|
||||||
|
|
||||||
workrect.Set(10,20,11,21);
|
|
||||||
fDomain = new BTextControl(workrect,"Domain_Name","Domain name:"," ",
|
|
||||||
new BMessage(kSOMETHING_HAS_CHANGED_M));
|
|
||||||
|
|
||||||
// BTextControl::ResizeToPreferred() is a little strange for our purposes, so we
|
|
||||||
// get the preferred size and ignore the width that we get.
|
|
||||||
fDomain->GetPreferredSize(&width, &height);
|
|
||||||
fDomain->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
|
|
||||||
fDomain->SetDivider(labelwidth);
|
|
||||||
|
|
||||||
workrect.left = 10;
|
|
||||||
workrect.right = 11;
|
|
||||||
workrect.top = height + 30;
|
|
||||||
workrect.bottom = workrect.top + height;
|
|
||||||
|
|
||||||
fHost = new BTextControl(workrect,"Host_Name","Host name:",NULL,
|
|
||||||
new BMessage(kSOMETHING_HAS_CHANGED_M));
|
|
||||||
fHost->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
|
|
||||||
fHost->SetDivider(labelwidth);
|
|
||||||
|
|
||||||
labelwidth = fTabView->StringWidth("Secondary DNS: ");
|
|
||||||
|
|
||||||
workrect.OffsetTo((bounds.right / 2),20);
|
|
||||||
workrect.right = bounds.right - 30;
|
|
||||||
fPrimaryDNS = new BTextControl(workrect,"Primary_DNS","Primary DNS:",
|
|
||||||
NULL,new BMessage(kSOMETHING_HAS_CHANGED_M),
|
|
||||||
B_FOLLOW_TOP | B_FOLLOW_RIGHT);
|
|
||||||
fPrimaryDNS->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
|
|
||||||
fPrimaryDNS->SetDivider(labelwidth);
|
|
||||||
|
|
||||||
workrect.OffsetBy(0,height + 10);
|
|
||||||
fSecondaryDNS = new BTextControl(workrect,"Secondary_DNS","Secondary DNS:",
|
|
||||||
NULL,new BMessage(kSOMETHING_HAS_CHANGED_M),
|
|
||||||
B_FOLLOW_TOP | B_FOLLOW_RIGHT);
|
|
||||||
fSecondaryDNS->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
|
|
||||||
fSecondaryDNS->SetDivider(labelwidth);
|
|
||||||
|
|
||||||
fNames = new BBox(BRect(10,10,bounds.right - 10, (height * 2) + 50),
|
|
||||||
"Names",B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,B_WILL_DRAW |
|
|
||||||
B_FRAME_EVENTS);
|
|
||||||
fIdentityView->AddChild(fNames);
|
|
||||||
fNames->SetLabel("Names");
|
|
||||||
|
|
||||||
fNames->AddChild(fDomain);
|
|
||||||
fNames->AddChild(fHost);
|
|
||||||
fNames->AddChild(fPrimaryDNS);
|
|
||||||
fNames->AddChild(fSecondaryDNS);
|
|
||||||
|
|
||||||
// BTextControl resizing operations don't do anything under R5 unless they
|
|
||||||
// have an owner. To make things worse, BTabView does some of its BView hierarchy
|
|
||||||
// stuff in AttachedToWindow such that if you add a tab before it's attached to
|
|
||||||
// a window, it won't be visible. :( As such, we make an extra call to
|
|
||||||
// AttachedToWindow to be assured that everything works the way it is intended.
|
|
||||||
fTabView->AttachedToWindow();
|
|
||||||
fDomain->ResizeTo( (bounds.right / 2) - 25, height);
|
|
||||||
fHost->ResizeTo( (bounds.right / 2) - 25, height);
|
|
||||||
|
|
||||||
workrect.left = 10;
|
|
||||||
workrect.right = bounds.right - 10;
|
|
||||||
workrect.top = fNames->Frame().bottom + 10;
|
|
||||||
workrect.bottom = fIdentityView->Bounds().bottom - 15;
|
|
||||||
fInterfaces = new BBox(workrect,"Network_Interfaces",B_FOLLOW_ALL,
|
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS);
|
|
||||||
fInterfaces->SetLabel("Network Interfaces");
|
|
||||||
fIdentityView->AddChild(fInterfaces);
|
|
||||||
|
|
||||||
workrect = fInterfaces->Bounds().InsetByCopy(5,5);
|
|
||||||
fSettings = new BButton(BRect(0,0,1,1),"Settings","Settings" B_UTF8_ELLIPSIS,
|
|
||||||
new BMessage(kSettings_M),
|
|
||||||
B_FOLLOW_TOP | B_FOLLOW_RIGHT);
|
|
||||||
fSettings->ResizeToPreferred();
|
|
||||||
fSettings->MoveTo(workrect.right - 5 - fSettings->Bounds().Width(), 15);
|
|
||||||
fInterfaces->AddChild(fSettings);
|
|
||||||
|
|
||||||
workrect = fSettings->Frame();
|
|
||||||
workrect.OffsetBy(0,workrect.Height()+5);
|
|
||||||
|
|
||||||
fClear = new BButton(workrect,"Clear","Clear",new BMessage(kClear_M),
|
|
||||||
B_FOLLOW_TOP | B_FOLLOW_RIGHT);
|
|
||||||
fInterfaces->AddChild(fClear);
|
|
||||||
|
|
||||||
workrect.OffsetBy(0,workrect.Height()+15);
|
|
||||||
fCustom = new BButton(workrect,"Custom","Custom" B_UTF8_ELLIPSIS,new BMessage(kCustom_M),
|
|
||||||
B_FOLLOW_TOP | B_FOLLOW_RIGHT);
|
|
||||||
fInterfaces->AddChild(fCustom);
|
|
||||||
|
|
||||||
if(workrect.bottom > fInterfaces->Bounds().bottom)
|
|
||||||
ResizeBy(0,workrect.bottom - fInterfaces->Bounds().bottom + 10);
|
|
||||||
|
|
||||||
workrect.left = 10;
|
|
||||||
workrect.top = 20;
|
|
||||||
workrect.right = fCustom->Frame().left - 15 - B_V_SCROLL_BAR_WIDTH;
|
|
||||||
workrect.bottom = fCustom->Frame().bottom - 5;
|
|
||||||
|
|
||||||
fInterfacesList = new NetListView(workrect,"Interfaces_List");
|
|
||||||
BScrollView *interfaces_scroller = new BScrollView("Interfaces_Scroller",
|
|
||||||
fInterfacesList, B_FOLLOW_ALL,
|
|
||||||
0, 0, 1, B_FANCY_BORDER);
|
|
||||||
fInterfaces->AddChild(interfaces_scroller);
|
|
||||||
|
|
||||||
fServicesView = new BView(bounds,"Services",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
|
|
||||||
fServicesView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
fServices = new BTab();
|
|
||||||
fTabView->AddTab(fServicesView,fServices);
|
|
||||||
|
|
||||||
workrect.Set(10,10,11,11);
|
|
||||||
fFTPServer = new BCheckBox(workrect,"FTP_Server","FTP Server",
|
|
||||||
new BMessage(kSOMETHING_HAS_CHANGED_M));
|
|
||||||
fFTPServer->GetPreferredSize(&width,&height);
|
|
||||||
fFTPServer->ResizeTo(width,height);
|
|
||||||
fServicesView->AddChild(fFTPServer);
|
|
||||||
|
|
||||||
fTelnetServer = new BCheckBox(workrect,"Telnet_Server","Telnet Server",
|
|
||||||
new BMessage(kSOMETHING_HAS_CHANGED_M));
|
|
||||||
fTelnetServer->ResizeToPreferred();
|
|
||||||
fTelnetServer->MoveTo(10,height + 15);
|
|
||||||
fServicesView->AddChild(fTelnetServer);
|
|
||||||
|
|
||||||
fLoginInfo = new BButton(workrect,"Login_Info","Login Info" B_UTF8_ELLIPSIS,
|
|
||||||
new BMessage(kLogin_Info_M));
|
|
||||||
fLoginInfo->ResizeToPreferred();
|
|
||||||
fLoginInfo->MoveTo(10,(height * 2) + 25);
|
|
||||||
fServicesView->AddChild(fLoginInfo);
|
|
||||||
|
|
||||||
workrect = fLoginInfo->Frame();
|
|
||||||
workrect.left -= 5;
|
|
||||||
workrect.top = workrect.bottom + 10;
|
|
||||||
workrect.bottom = workrect.top + 1;
|
|
||||||
workrect.right += 70;
|
|
||||||
BBox *hr2 = new BBox(workrect,"horizontal_rule2",B_FOLLOW_LEFT | B_FOLLOW_TOP);
|
|
||||||
fServicesView->AddChild(hr2);
|
|
||||||
|
|
||||||
|
|
||||||
fAppleTalk = new BCheckBox(workrect,"Apple_Talk","Apple Talk",
|
|
||||||
new BMessage(kSOMETHING_HAS_CHANGED_M));
|
|
||||||
fAppleTalk->ResizeToPreferred();
|
|
||||||
fAppleTalk->MoveTo(10, workrect.bottom + 10);
|
|
||||||
fServicesView->AddChild(fAppleTalk);
|
|
||||||
|
|
||||||
fIPForwarding = new BCheckBox(workrect,"IP_Forwarding","IP Forwarding",
|
|
||||||
new BMessage(kSOMETHING_HAS_CHANGED_M));
|
|
||||||
fIPForwarding->ResizeToPreferred();
|
|
||||||
fIPForwarding->MoveTo(10, fAppleTalk->Frame().bottom + 5);
|
|
||||||
fServicesView->AddChild(fIPForwarding);
|
|
||||||
|
|
||||||
workrect = bounds.InsetByCopy(10,10);
|
|
||||||
workrect.bottom += 10;
|
|
||||||
workrect.left = hr2->Frame().right + 10;
|
|
||||||
fConfigurations = new BBox(workrect,"Configurations",B_FOLLOW_ALL,
|
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS);
|
|
||||||
fConfigurations->SetLabel("Configurations");
|
|
||||||
fServicesView->AddChild(fConfigurations);
|
|
||||||
|
|
||||||
workrect = fConfigurations->Bounds();
|
|
||||||
fBackup = new BButton(BRect(0,0,1,1),"Backup","Backup", new BMessage(kBackup_M));
|
|
||||||
fBackup->GetPreferredSize(&width,&height);
|
|
||||||
fBackup->ResizeTo(width,height);
|
|
||||||
fBackup->MoveTo(workrect.right - width - 10,15);
|
|
||||||
fConfigurations->AddChild(fBackup);
|
|
||||||
|
|
||||||
fRestore = new BButton(BRect(0,0,width,height),"Restore","Restore",
|
|
||||||
new BMessage(kRestore_M));
|
|
||||||
fConfigurations->AddChild(fRestore);
|
|
||||||
fRestore->MoveTo(workrect.right - width - 10, 20 + height);
|
|
||||||
fRestore->SetEnabled(false);
|
|
||||||
|
|
||||||
fRemove = new BButton(BRect(0,0,width,height),"Delete","Delete",
|
|
||||||
new BMessage(kDelete_M));
|
|
||||||
fRemove->MoveTo(workrect.right - width - 10, 25 + (height * 2));
|
|
||||||
fRemove->SetEnabled(false);
|
|
||||||
fConfigurations->AddChild(fRemove);
|
|
||||||
|
|
||||||
workrect = fConfigurations->Bounds().InsetByCopy(15,15);
|
|
||||||
workrect.top += 5;
|
|
||||||
workrect.right = fBackup->Frame().left - 10 - B_V_SCROLL_BAR_WIDTH;
|
|
||||||
fConfigurationsList = new NetListView(workrect,"Configurations_List");
|
|
||||||
BScrollView *configurations_scroller = new BScrollView("Configurations_Scroller",
|
|
||||||
fConfigurationsList,
|
|
||||||
B_FOLLOW_ALL, 0, 0, 1,
|
|
||||||
B_FANCY_BORDER);
|
|
||||||
fConfigurations->AddChild(configurations_scroller);
|
|
||||||
|
|
||||||
LoadConfigEntries();
|
|
||||||
LoadSettings();
|
|
||||||
|
|
||||||
fTabView->AttachedToWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkWindow::MessageReceived(BMessage *message)
|
|
||||||
{
|
|
||||||
switch (message->what) {
|
|
||||||
case kRestart_Networking_M: {
|
|
||||||
RestartWindow *restartWindow = new RestartWindow();
|
|
||||||
restartWindow->Show();
|
|
||||||
|
|
||||||
BMessenger messenger("application/x-vnd.Be-NETS");
|
|
||||||
if (messenger.IsValid() == true)
|
|
||||||
messenger.SendMessage(B_QUIT_REQUESTED);
|
|
||||||
|
|
||||||
const char **arg_v;
|
|
||||||
int32 argc;
|
|
||||||
thread_id thread;
|
|
||||||
status_t return_value;
|
|
||||||
|
|
||||||
argc = 1;
|
|
||||||
arg_v = (const char **)malloc(sizeof(char *) * (argc + 1));
|
|
||||||
|
|
||||||
arg_v[0] = strdup("/boot/beos/system/servers/net_server");
|
|
||||||
arg_v[1] = NULL;
|
|
||||||
|
|
||||||
thread = load_image(argc,arg_v,(const char **)environ);
|
|
||||||
|
|
||||||
while (--argc >= 0)
|
|
||||||
free((void *)arg_v[argc]);
|
|
||||||
free (arg_v);
|
|
||||||
|
|
||||||
return_value = resume_thread(thread);
|
|
||||||
|
|
||||||
restartWindow->Quit();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kRevert_M: {
|
|
||||||
LoadSettings();
|
|
||||||
fRevert->SetEnabled(false);
|
|
||||||
fSave->SetEnabled(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kSave_M: {
|
|
||||||
SaveBackup(NULL,fData);
|
|
||||||
fRevert->SetEnabled(false);
|
|
||||||
fSave->SetEnabled(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kSettings_M: {
|
|
||||||
BRect r(Frame());
|
|
||||||
r.right = r.left + 325;
|
|
||||||
r.bottom = r.top + 225;
|
|
||||||
|
|
||||||
NetListItem *selection = dynamic_cast <NetListItem *> (fInterfacesList->ItemAt(fInterfacesList->CurrentSelection()));
|
|
||||||
if(!selection)
|
|
||||||
break;
|
|
||||||
|
|
||||||
InterfaceWin *win = new InterfaceWin(r,selection->fData);
|
|
||||||
r=win->Frame();
|
|
||||||
win->MoveBy((Frame().Width()-r.Width())/2,
|
|
||||||
(Frame().Height()-r.Height())/2);
|
|
||||||
|
|
||||||
win->fParentWindow = dynamic_cast <NetworkWindow *> (fView->Window());
|
|
||||||
|
|
||||||
if (selection->fData.fEnabled)
|
|
||||||
win->fEnabled->SetValue(1);
|
|
||||||
|
|
||||||
if (selection->fData.fDHCP)
|
|
||||||
win->fDHCP->SetValue(1);
|
|
||||||
else
|
|
||||||
win->fManual->SetValue(1);
|
|
||||||
|
|
||||||
win->fName->SetText(selection->fData.fPrettyName.String());
|
|
||||||
win->fIPAddress->SetText(selection->fData.fIPAddress.String());
|
|
||||||
win->fNetMask->SetText(selection->fData.fNetMask.String());
|
|
||||||
|
|
||||||
win->fChanged = false;
|
|
||||||
|
|
||||||
win->fIPAddress->SetTarget(win);
|
|
||||||
win->fNetMask->SetTarget(win);
|
|
||||||
win->fGateway->SetTarget(win);
|
|
||||||
|
|
||||||
win->Show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kClear_M: {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kCustom_M: {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kLogin_Info_M: {
|
|
||||||
LoginInfo *login_info_pop = new LoginInfo();
|
|
||||||
login_info_pop->fParentWindow = dynamic_cast <NetworkWindow *> (fView->Window());
|
|
||||||
login_info_pop->fName->SetText(fusername.String());
|
|
||||||
login_info_pop->fName->MakeFocus();
|
|
||||||
login_info_pop->Show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kBackup_M: {
|
|
||||||
BRect r(Frame());
|
|
||||||
r.right = r.left + 260;
|
|
||||||
r.bottom = r.top + 77;
|
|
||||||
r.OffsetBy( (Frame().Width()-260)/2, (Frame().Height()-77)/2);
|
|
||||||
BackupWin *backup_pop = new BackupWin(r);
|
|
||||||
backup_pop->fParentWindow = dynamic_cast <NetworkWindow *> (fView->Window());
|
|
||||||
backup_pop->Show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kRestore_M: {
|
|
||||||
BStringItem *string_item = dynamic_cast <BStringItem *> (fConfigurationsList->ItemAt(fConfigurationsList->CurrentSelection()));
|
|
||||||
LoadSettings(string_item->Text());
|
|
||||||
PostMessage(kSOMETHING_HAS_CHANGED_M);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kDelete_M: {
|
|
||||||
DeleteConfigFile();
|
|
||||||
LoadConfigEntries();
|
|
||||||
fConfigurationsList->SelectionChanged();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kSOMETHING_HAS_CHANGED_M: {
|
|
||||||
fRevert->SetEnabled(true);
|
|
||||||
fSave->SetEnabled(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
NetworkWindow::QuitRequested(void)
|
|
||||||
{
|
|
||||||
if (fSave->IsEnabled() == true) {
|
|
||||||
BAlert *alert = new BAlert("Save Info Alert", "Save changes before "
|
|
||||||
quitting?", "Don't Save", "Cancel", "Save");
|
|
||||||
alert->SetShortcut(1, B_ESCAPE);
|
|
||||||
int32 result = alert->Go();
|
|
||||||
|
|
||||||
switch (result) {
|
|
||||||
case 0: {
|
|
||||||
// Don't Save
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:{
|
|
||||||
// Cancel
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2:{
|
|
||||||
// Save
|
|
||||||
SaveBackup(NULL,fData);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkWindow::DeleteConfigFile()
|
|
||||||
{
|
|
||||||
BAlert *alert = new BAlert("Alert", "Really delete networking configuration?",
|
|
||||||
"Delete", "Cancel");
|
|
||||||
alert->SetShortcut(1, B_ESCAPE);
|
|
||||||
int32 result = alert->Go();
|
|
||||||
|
|
||||||
if (result == 0) {
|
|
||||||
BStringItem *item = dynamic_cast <BStringItem *> (fConfigurationsList->ItemAt(fConfigurationsList->CurrentSelection()));
|
|
||||||
|
|
||||||
BString path;
|
|
||||||
path = "/boot/home/config/settings/network.";
|
|
||||||
path << item->Text();
|
|
||||||
|
|
||||||
BEntry entry(path.String());
|
|
||||||
entry.Remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
NetworkWindow::LoadConfigEntries()
|
|
||||||
{
|
|
||||||
fConfigurationsList->MakeEmpty();
|
|
||||||
|
|
||||||
BDirectory settings("/boot/home/config/settings/");
|
|
||||||
BEntry entry;
|
|
||||||
|
|
||||||
if (settings.InitCheck() == B_OK) {
|
|
||||||
while (settings.GetNextEntry(&entry) == B_OK) {
|
|
||||||
// All the config files start with "network." so we only compare the
|
|
||||||
// first 8 characters
|
|
||||||
char buffer[9];
|
|
||||||
entry.GetName(buffer);
|
|
||||||
buffer[8]='\0';
|
|
||||||
|
|
||||||
if (strcmp(buffer,"network.") == 0) {
|
|
||||||
BString string;
|
|
||||||
char name[B_FILE_NAME_LENGTH];
|
|
||||||
entry.GetName(name);
|
|
||||||
string << name;
|
|
||||||
string = string.Remove(0,8);
|
|
||||||
|
|
||||||
BStringItem *item = new BStringItem(string.String());
|
|
||||||
fConfigurationsList->AddItem(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
NetworkWindow::LoadSettings(const char *filename)
|
|
||||||
{
|
|
||||||
if(LoadBackup(filename,fData)!=B_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Lock();
|
|
||||||
for(int32 i=0; i<fData.fInterfaceList.CountItems(); i++) {
|
|
||||||
InterfaceData *idata = (InterfaceData*)fData.fInterfaceList.ItemAt(i);
|
|
||||||
fInterfacesList->AddItem(new NetListItem(*idata));
|
|
||||||
}
|
|
||||||
fInterfacesList->Select(0L);
|
|
||||||
|
|
||||||
fDomain->SetText(fData.fDomainName.String());
|
|
||||||
fHost->SetText(fData.fHostname.String());
|
|
||||||
fPrimaryDNS->SetText(fData.fPrimaryDNS.String());
|
|
||||||
fSecondaryDNS->SetText(fData.fSecondaryDNS.String());
|
|
||||||
|
|
||||||
if(fData.fFTPServer)
|
|
||||||
fFTPServer->SetValue(B_CONTROL_ON);
|
|
||||||
if(fData.fIPForwarding)
|
|
||||||
fIPForwarding->SetValue(B_CONTROL_ON);
|
|
||||||
if(fData.fTelnetServer)
|
|
||||||
fTelnetServer->SetValue(B_CONTROL_ON);
|
|
||||||
|
|
||||||
Unlock();
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
#ifndef NETWORK_WINDOW_H
|
|
||||||
#define NETWORK_WINDOW_H
|
|
||||||
|
|
||||||
#include <Window.h>
|
|
||||||
#include <View.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <TabView.h>
|
|
||||||
#include <Box.h>
|
|
||||||
#include <CheckBox.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include "ConfigData.h"
|
|
||||||
|
|
||||||
class NetListView;
|
|
||||||
|
|
||||||
class NetworkWindow : public BWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NetworkWindow();
|
|
||||||
|
|
||||||
BView *fView;
|
|
||||||
BTabView *fTabView;
|
|
||||||
|
|
||||||
BButton *fRestart;
|
|
||||||
BButton *fRevert;
|
|
||||||
BButton *fSave;
|
|
||||||
|
|
||||||
BTab *fIdentity;
|
|
||||||
BView *fIdentityView;
|
|
||||||
|
|
||||||
BBox *fNames;
|
|
||||||
BTextControl *fDomain;
|
|
||||||
BTextControl *fHost;
|
|
||||||
BTextControl *fPrimaryDNS;
|
|
||||||
BTextControl *fSecondaryDNS;
|
|
||||||
|
|
||||||
BBox *fInterfaces;
|
|
||||||
NetListView *fInterfacesList;
|
|
||||||
BButton *fSettings;
|
|
||||||
BButton *fClear;
|
|
||||||
BButton *fCustom;
|
|
||||||
|
|
||||||
BTab *fServices;
|
|
||||||
BView *fServicesView;
|
|
||||||
BCheckBox *fFTPServer;
|
|
||||||
BCheckBox *fTelnetServer;
|
|
||||||
BCheckBox *fAppleTalk;
|
|
||||||
BCheckBox *fIPForwarding;
|
|
||||||
BButton *fLoginInfo;
|
|
||||||
|
|
||||||
BBox *fConfigurations;
|
|
||||||
NetListView *fConfigurationsList;
|
|
||||||
BButton *fBackup;
|
|
||||||
BButton *fRestore;
|
|
||||||
BButton *fRemove;
|
|
||||||
|
|
||||||
// Messages
|
|
||||||
static const int32 kRestart_Networking_M = 'ranm' ;
|
|
||||||
static const int32 kRevert_M = 'revm' ;
|
|
||||||
static const int32 kSave_M = 'savm' ;
|
|
||||||
static const int32 kSettings_M = 'setm' ;
|
|
||||||
static const int32 kClear_M = 'clem' ;
|
|
||||||
static const int32 kCustom_M = 'cusm' ;
|
|
||||||
static const int32 kLogin_Info_M = 'logm' ;
|
|
||||||
static const int32 kBackup_M = 'bakm' ;
|
|
||||||
static const int32 kRestore_M = 'resm' ;
|
|
||||||
static const int32 kDelete_M = 'delm' ;
|
|
||||||
|
|
||||||
static const int32 kSOMETHING_HAS_CHANGED_M = 'shcm' ;
|
|
||||||
|
|
||||||
/*
|
|
||||||
As this window is the 'main' one and that at startup it gathers up the
|
|
||||||
info with the LoadSettings() method, some data are kept here and will be passed
|
|
||||||
to who needs it.
|
|
||||||
*/
|
|
||||||
BString fusername;
|
|
||||||
BString flogin_info_S[2];
|
|
||||||
|
|
||||||
virtual bool QuitRequested();
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
|
||||||
|
|
||||||
//All these are defined in funcs.cpp
|
|
||||||
void DeleteConfigFile();
|
|
||||||
void LoadConfigEntries();
|
|
||||||
void LoadSettings(const char *bakname = NULL);
|
|
||||||
|
|
||||||
// Gets all the infos of the interfaces at startup, display and store them
|
|
||||||
// or get them from a backup file.
|
|
||||||
ConfigData fData;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user