Network: style cleanup.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2007 Haiku Inc. All rights reserved.
|
||||
* Copyright 2004-2015 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*/
|
||||
@@ -13,41 +13,41 @@
|
||||
#include "NetworkSetupWindow.h"
|
||||
|
||||
|
||||
#define SOFTWARE_EDITOR "Haiku"
|
||||
#define NAME "Network"
|
||||
#define SOFTWARE_VERSION_LABEL "1.0.0 alpha"
|
||||
|
||||
#define APPLICATION_SIGNATURE "application/x-vnd." SOFTWARE_EDITOR "-" NAME
|
||||
static const char* kSignature = "application/x-vnd.Haiku-Network";
|
||||
|
||||
|
||||
class Application : public BApplication
|
||||
{
|
||||
public:
|
||||
Application();
|
||||
class Application : public BApplication {
|
||||
public:
|
||||
Application();
|
||||
|
||||
public:
|
||||
void ReadyToRun(void);
|
||||
public:
|
||||
virtual void ReadyToRun();
|
||||
};
|
||||
|
||||
|
||||
int main()
|
||||
Application::Application()
|
||||
:
|
||||
BApplication(kSignature)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Application::ReadyToRun()
|
||||
{
|
||||
NetworkSetupWindow* window = new NetworkSetupWindow();
|
||||
window->Show();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
Application* app = new Application();
|
||||
app->Run();
|
||||
delete app;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Application::Application()
|
||||
: BApplication(APPLICATION_SIGNATURE)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Application::ReadyToRun(void)
|
||||
{
|
||||
NetworkSetupWindow* window = new NetworkSetupWindow(NAME);
|
||||
window->Show();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
/*
|
||||
* Copyright 2004-2011 Haiku Inc. All rights reserved.
|
||||
* Copyright 2004-2015 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "NetworkSetupAddOn.h"
|
||||
|
||||
#include <kernel/image.h>
|
||||
#include <storage/Resources.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -18,15 +14,15 @@ NetworkSetupAddOn::NetworkSetupAddOn(image_id image)
|
||||
:
|
||||
fIsDirty(false),
|
||||
fProfile(NULL),
|
||||
fAddonImage(image),
|
||||
fAddonResources(NULL)
|
||||
fImage(image),
|
||||
fResources(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NetworkSetupAddOn::~NetworkSetupAddOn()
|
||||
{
|
||||
delete fAddonResources;
|
||||
delete fResources;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +41,9 @@ NetworkSetupAddOn::Revert()
|
||||
|
||||
|
||||
status_t
|
||||
NetworkSetupAddOn::ProfileChanged(NetworkSetupProfile* new_profile)
|
||||
NetworkSetupAddOn::ProfileChanged(NetworkSetupProfile* newProfile)
|
||||
{
|
||||
fProfile = new_profile;
|
||||
fProfile = newProfile;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -76,7 +72,7 @@ NetworkSetupAddOn::Profile()
|
||||
image_id
|
||||
NetworkSetupAddOn::ImageId()
|
||||
{
|
||||
return fAddonImage;
|
||||
return fImage;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,17 +86,17 @@ NetworkSetupAddOn::Name()
|
||||
BResources*
|
||||
NetworkSetupAddOn::Resources()
|
||||
{
|
||||
if (!fAddonResources) {
|
||||
if (fResources == NULL) {
|
||||
image_info info;
|
||||
if (get_image_info(fAddonImage, &info) != B_OK)
|
||||
if (get_image_info(fImage, &info) != B_OK)
|
||||
return NULL;
|
||||
|
||||
BResources *resources = new BResources();
|
||||
BFile addon_file(info.name, O_RDONLY);
|
||||
if (resources->SetTo(&addon_file) == B_OK)
|
||||
fAddonResources = resources;
|
||||
BResources* resources = new BResources();
|
||||
BFile file(info.name, B_READ_ONLY);
|
||||
if (resources->SetTo(&file) == B_OK)
|
||||
fResources = resources;
|
||||
else
|
||||
delete resources;
|
||||
}
|
||||
return fAddonResources;
|
||||
return fResources;
|
||||
}
|
||||
|
||||
@@ -1,45 +1,47 @@
|
||||
/*
|
||||
* Copyright 2004-2011 Haiku Inc. All rights reserved.
|
||||
* Copyright 2004-2015 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*/
|
||||
#ifndef NETWORKSETUPADDON_H
|
||||
#define NETWORKSETUPADDON_H
|
||||
#ifndef NETWORK_SETUP_ADD_ON_H
|
||||
#define NETWORK_SETUP_ADD_ON_H
|
||||
|
||||
|
||||
#include <interface/View.h>
|
||||
#include <kernel/image.h> // for image_id
|
||||
#include <storage/Resources.h>
|
||||
#include <image.h>
|
||||
#include <Resources.h>
|
||||
#include <View.h>
|
||||
|
||||
|
||||
class NetworkSetupProfile;
|
||||
|
||||
class NetworkSetupAddOn {
|
||||
public:
|
||||
NetworkSetupAddOn(image_id addon_image);
|
||||
virtual ~NetworkSetupAddOn();
|
||||
public:
|
||||
NetworkSetupAddOn(image_id image);
|
||||
virtual ~NetworkSetupAddOn();
|
||||
|
||||
virtual BView * CreateView() = 0;
|
||||
virtual status_t Save();
|
||||
virtual status_t Revert();
|
||||
virtual BView* CreateView() = 0;
|
||||
virtual status_t Save();
|
||||
virtual status_t Revert();
|
||||
|
||||
virtual const char * Name();
|
||||
virtual status_t ProfileChanged(NetworkSetupProfile*
|
||||
new_profile);
|
||||
virtual const char* Name();
|
||||
virtual status_t ProfileChanged(NetworkSetupProfile* newProfile);
|
||||
|
||||
NetworkSetupProfile * Profile();
|
||||
bool IsDirty();
|
||||
void SetDirty(bool dirty = true);
|
||||
image_id ImageId();
|
||||
BResources* Resources();
|
||||
NetworkSetupProfile*
|
||||
Profile();
|
||||
bool IsDirty();
|
||||
void SetDirty(bool dirty = true);
|
||||
image_id ImageId();
|
||||
BResources* Resources();
|
||||
|
||||
private:
|
||||
bool fIsDirty;
|
||||
NetworkSetupProfile* fProfile;
|
||||
image_id fAddonImage;
|
||||
BResources* fAddonResources;
|
||||
private:
|
||||
bool fIsDirty;
|
||||
NetworkSetupProfile*
|
||||
fProfile;
|
||||
image_id fImage;
|
||||
BResources* fResources;
|
||||
};
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
#define NETWORK_SETUP_ADDON_INSTANCIATE_FUNC_NAME "get_nth_addon"
|
||||
@@ -51,5 +53,4 @@ extern NetworkSetupAddOn* get_nth_addon(image_id image, int index);
|
||||
}
|
||||
|
||||
|
||||
#endif // ifdef NETWORKSETUPADDON_H
|
||||
|
||||
#endif // NETWORKSETUPADDON_H
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
* Copyright 2004-2011 Haiku Inc. All rights reserved.
|
||||
* Copyright 2004-2015 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "NetworkSetupProfile.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
NetworkSetupProfile::NetworkSetupProfile()
|
||||
:
|
||||
@@ -77,7 +77,7 @@ NetworkSetupProfile::SetTo(const entry_ref* ref)
|
||||
|
||||
|
||||
status_t
|
||||
NetworkSetupProfile::SetTo(BEntry *entry)
|
||||
NetworkSetupProfile::SetTo(BEntry* entry)
|
||||
{
|
||||
delete fRoot;
|
||||
delete fPath;
|
||||
@@ -91,7 +91,7 @@ NetworkSetupProfile::SetTo(BEntry *entry)
|
||||
const char*
|
||||
NetworkSetupProfile::Name()
|
||||
{
|
||||
if (!fName) {
|
||||
if (fName == NULL) {
|
||||
fRoot->GetPath(fPath);
|
||||
fName = fPath->Leaf();
|
||||
}
|
||||
@@ -100,7 +100,7 @@ NetworkSetupProfile::Name()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
status_t
|
||||
NetworkSetupProfile::SetName(const char* name)
|
||||
{
|
||||
return B_OK;
|
||||
@@ -143,6 +143,8 @@ NetworkSetupProfile::MakeCurrent()
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
NetworkSetupProfile*
|
||||
NetworkSetupProfile::Default()
|
||||
{
|
||||
|
||||
@@ -1,49 +1,52 @@
|
||||
/*
|
||||
* Copyright 2004-2011 Haiku Inc. All rights reserved.
|
||||
* Copyright 2004-2015 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
*/
|
||||
#ifndef NETWORK_SETUP_PROFILE_H
|
||||
#define NETWORK_SETUP_PROFILE_H
|
||||
|
||||
#ifndef NETWORKSETUPPROFILE_H
|
||||
#define NETWORKSETUPPROFILE_H
|
||||
|
||||
#include <StorageKit.h>
|
||||
|
||||
|
||||
class NetworkSetupProfile {
|
||||
public:
|
||||
NetworkSetupProfile();
|
||||
NetworkSetupProfile(const char* path);
|
||||
NetworkSetupProfile(const entry_ref* ref);
|
||||
NetworkSetupProfile(BEntry *entry);
|
||||
NetworkSetupProfile();
|
||||
NetworkSetupProfile(const char* path);
|
||||
NetworkSetupProfile(const entry_ref* ref);
|
||||
NetworkSetupProfile(BEntry* entry);
|
||||
|
||||
virtual ~NetworkSetupProfile();
|
||||
|
||||
status_t SetTo(const char* path);
|
||||
status_t SetTo(const entry_ref *ref);
|
||||
status_t SetTo(BEntry *entry);
|
||||
|
||||
bool Exists();
|
||||
|
||||
const char* Name();
|
||||
status_t SetName(const char *name);
|
||||
|
||||
|
||||
bool IsDefault();
|
||||
bool IsCurrent();
|
||||
virtual ~NetworkSetupProfile();
|
||||
|
||||
status_t MakeCurrent();
|
||||
status_t Delete();
|
||||
status_t SetTo(const char* path);
|
||||
status_t SetTo(const entry_ref* ref);
|
||||
status_t SetTo(BEntry* entry);
|
||||
|
||||
static NetworkSetupProfile* Default();
|
||||
static NetworkSetupProfile* Current();
|
||||
bool Exists();
|
||||
|
||||
const char* Name();
|
||||
status_t SetName(const char* name);
|
||||
|
||||
bool IsDefault();
|
||||
bool IsCurrent();
|
||||
|
||||
status_t MakeCurrent();
|
||||
status_t Delete();
|
||||
|
||||
static NetworkSetupProfile*
|
||||
Default();
|
||||
static NetworkSetupProfile*
|
||||
Current();
|
||||
|
||||
private:
|
||||
BEntry* fRoot;
|
||||
BPath* fPath;
|
||||
bool fIsDefault;
|
||||
bool fIsCurrent;
|
||||
const char* fName;
|
||||
BEntry* fRoot;
|
||||
BPath* fPath;
|
||||
bool fIsDefault;
|
||||
bool fIsCurrent;
|
||||
const char* fName;
|
||||
|
||||
static BDirectory* fProfilesRoot;
|
||||
static BDirectory* fProfilesRoot;
|
||||
};
|
||||
#endif // ifdef NETWORKSETUPPROFILE_H
|
||||
|
||||
|
||||
#endif // NETWORK_SETUP_PROFILE_H
|
||||
|
||||
@@ -32,12 +32,11 @@
|
||||
#define B_TRANSLATION_CONTEXT "NetworkSetupWindow"
|
||||
|
||||
|
||||
// --------------------------------------------------------------
|
||||
NetworkSetupWindow::NetworkSetupWindow(const char *title)
|
||||
NetworkSetupWindow::NetworkSetupWindow()
|
||||
:
|
||||
BWindow(BRect(100, 100, 300, 300), title, B_TITLED_WINDOW,
|
||||
BWindow(BRect(100, 100, 300, 300), B_TRANSLATE("Network"), B_TITLED_WINDOW,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
|
||||
fAddonCount(0)
|
||||
fAddOnCount(0)
|
||||
{
|
||||
// ---- Profiles section
|
||||
#if 0
|
||||
@@ -94,7 +93,7 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
|
||||
|
||||
_BuildShowTabView();
|
||||
|
||||
fAddonView = NULL;
|
||||
fAddOnView = NULL;
|
||||
|
||||
CenterOnScreen();
|
||||
}
|
||||
@@ -120,43 +119,39 @@ NetworkSetupWindow::MessageReceived(BMessage* message)
|
||||
case kMsgProfileNew:
|
||||
break;
|
||||
|
||||
case kMsgProfileSelected: {
|
||||
BPath name;
|
||||
const char *path;
|
||||
bool is_default;
|
||||
bool is_current;
|
||||
|
||||
case kMsgProfileSelected:
|
||||
{
|
||||
const char* path;
|
||||
if (message->FindString("path", &path) != B_OK)
|
||||
break;
|
||||
|
||||
name.SetTo(path);
|
||||
BPath name(path);
|
||||
bool isCurrent = strcmp(name.Leaf(), "current") == 0;
|
||||
|
||||
is_default = (strcmp(name.Leaf(), "default") == 0);
|
||||
is_current = (strcmp(name.Leaf(), "current") == 0);
|
||||
|
||||
fApplyButton->SetEnabled(!is_current);
|
||||
fApplyButton->SetEnabled(!isCurrent);
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgRevert: {
|
||||
for (int addonIndex = 0; addonIndex < fAddonCount; addonIndex++) {
|
||||
NetworkSetupAddOn* addon
|
||||
= fNetworkAddOnMap[addonIndex];
|
||||
addon->Revert();
|
||||
case kMsgRevert:
|
||||
{
|
||||
for (int index = 0; index < fAddOnCount; index++) {
|
||||
NetworkSetupAddOn* addOn = fNetworkAddOnMap[index];
|
||||
addOn->Revert();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgApply: {
|
||||
for (int addonIndex = 0; addonIndex < fAddonCount; addonIndex++) {
|
||||
NetworkSetupAddOn* addon
|
||||
= fNetworkAddOnMap[addonIndex];
|
||||
addon->Save();
|
||||
case kMsgApply:
|
||||
{
|
||||
for (int index = 0; index < fAddOnCount; index++) {
|
||||
NetworkSetupAddOn* addOn = fNetworkAddOnMap[index];
|
||||
addOn->Save();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgToggleReplicant: {
|
||||
case kMsgToggleReplicant:
|
||||
{
|
||||
_ShowReplicant(message->GetInt32("be:value", B_CONTROL_OFF)
|
||||
== B_CONTROL_ON);
|
||||
break;
|
||||
@@ -169,18 +164,15 @@ NetworkSetupWindow::MessageReceived(BMessage* message)
|
||||
|
||||
|
||||
void
|
||||
NetworkSetupWindow::_BuildProfilesMenu(BMenu* menu, int32 msg_what)
|
||||
NetworkSetupWindow::_BuildProfilesMenu(BMenu* menu, int32 what)
|
||||
{
|
||||
BMenuItem* item;
|
||||
char current_profile[256] = { 0 };
|
||||
char currentProfile[256] = { 0 };
|
||||
|
||||
menu->SetRadioMode(true);
|
||||
|
||||
BDirectory dir("/boot/system/settings/network/profiles");
|
||||
|
||||
if (dir.InitCheck() == B_OK) {
|
||||
BEntry entry;
|
||||
BMessage* msg;
|
||||
|
||||
dir.Rewind();
|
||||
while (dir.GetNextEntry(&entry) >= 0) {
|
||||
@@ -195,17 +187,17 @@ NetworkSetupWindow::_BuildProfilesMenu(BMenu* menu, int32 msg_what)
|
||||
// oh oh, sorry, wrong symlink...
|
||||
continue;
|
||||
|
||||
symlink.ReadLink(current_profile, sizeof(current_profile));
|
||||
symlink.ReadLink(currentProfile, sizeof(currentProfile));
|
||||
continue;
|
||||
};
|
||||
|
||||
if (!entry.IsDirectory())
|
||||
continue;
|
||||
|
||||
msg = new BMessage(msg_what);
|
||||
msg->AddString("path", name.Path());
|
||||
BMessage* message = new BMessage(what);
|
||||
message->AddString("path", name.Path());
|
||||
|
||||
item = new BMenuItem(name.Leaf(), msg);
|
||||
BMenuItem* item = new BMenuItem(name.Leaf(), message);
|
||||
menu->AddItem(item);
|
||||
}
|
||||
}
|
||||
@@ -216,11 +208,11 @@ NetworkSetupWindow::_BuildProfilesMenu(BMenu* menu, int32 msg_what)
|
||||
menu->AddItem(new BMenuItem(B_TRANSLATE("Manage" B_UTF8_ELLIPSIS),
|
||||
new BMessage(kMsgProfileManage)));
|
||||
|
||||
if (strlen(current_profile)) {
|
||||
item = menu->FindItem(current_profile);
|
||||
if (item) {
|
||||
BString label;
|
||||
label << item->Label();
|
||||
if (currentProfile[0] != '\0') {
|
||||
BMenuItem* item = menu->FindItem(currentProfile);
|
||||
if (item != NULL) {
|
||||
// TODO: translate
|
||||
BString label(item->Label());
|
||||
label << " (current)";
|
||||
item->SetLabel(label.String());
|
||||
item->SetMarked(true);
|
||||
@@ -233,32 +225,32 @@ void
|
||||
NetworkSetupWindow::_BuildShowTabView()
|
||||
{
|
||||
BPath path;
|
||||
BPath addon_path;
|
||||
BPath addOnPath;
|
||||
BDirectory dir;
|
||||
BEntry entry;
|
||||
|
||||
char* search_paths = getenv("ADDON_PATH");
|
||||
if (!search_paths)
|
||||
char* searchPaths = getenv("ADDON_PATH");
|
||||
if (!searchPaths)
|
||||
return;
|
||||
|
||||
search_paths = strdup(search_paths);
|
||||
char* next_path_token;
|
||||
char* search_path = strtok_r(search_paths, ":", &next_path_token);
|
||||
searchPaths = strdup(searchPaths);
|
||||
char* nextPathToken;
|
||||
char* searchPath = strtok_r(searchPaths, ":", &nextPathToken);
|
||||
|
||||
while (search_path) {
|
||||
if (strncmp(search_path, "%A/", 3) == 0) {
|
||||
while (searchPath) {
|
||||
if (strncmp(searchPath, "%A/", 3) == 0) {
|
||||
app_info ai;
|
||||
be_app->GetAppInfo(&ai);
|
||||
entry.SetTo(&ai.ref);
|
||||
entry.GetPath(&path);
|
||||
path.GetParent(&path);
|
||||
path.Append(search_path + 3);
|
||||
path.Append(searchPath + 3);
|
||||
} else {
|
||||
path.SetTo(search_path);
|
||||
path.SetTo(searchPath);
|
||||
path.Append("Network Setup");
|
||||
}
|
||||
|
||||
search_path = strtok_r(NULL, ":", &next_path_token);
|
||||
searchPath = strtok_r(NULL, ":", &nextPathToken);
|
||||
|
||||
dir.SetTo(path.Path());
|
||||
if (dir.InitCheck() != B_OK)
|
||||
@@ -269,16 +261,16 @@ NetworkSetupWindow::_BuildShowTabView()
|
||||
if (entry.IsDirectory())
|
||||
continue;
|
||||
|
||||
entry.GetPath(&addon_path);
|
||||
image_id addon_id = load_add_on(addon_path.Path());
|
||||
if (addon_id < 0) {
|
||||
printf("Failed to load %s addon: %s.\n", addon_path.Path(),
|
||||
strerror(addon_id));
|
||||
entry.GetPath(&addOnPath);
|
||||
image_id image = load_add_on(addOnPath.Path());
|
||||
if (image < 0) {
|
||||
printf("Failed to load %s addon: %s.\n", addOnPath.Path(),
|
||||
strerror(image));
|
||||
continue;
|
||||
}
|
||||
|
||||
network_setup_addon_instantiate get_nth_addon;
|
||||
status_t status = get_image_symbol(addon_id, "get_nth_addon",
|
||||
status_t status = get_image_symbol(image, "get_nth_addon",
|
||||
B_SYMBOL_TYPE_TEXT, (void **) &get_nth_addon);
|
||||
|
||||
int tabCount = 0;
|
||||
@@ -286,22 +278,21 @@ NetworkSetupWindow::_BuildShowTabView()
|
||||
if (status != B_OK) {
|
||||
// No "addon instantiate function" symbol found in this addon
|
||||
printf("No symbol \"get_nth_addon\" found in %s addon: not a "
|
||||
"network setup addon!\n", addon_path.Path());
|
||||
unload_add_on(addon_id);
|
||||
"network setup addon!\n", addOnPath.Path());
|
||||
unload_add_on(image);
|
||||
continue;
|
||||
}
|
||||
|
||||
while ((fNetworkAddOnMap[fAddonCount]
|
||||
= get_nth_addon(addon_id, tabCount)) != NULL) {
|
||||
printf("Adding Tab: %d\n", fAddonCount);
|
||||
BView* addon_view
|
||||
= fNetworkAddOnMap[fAddonCount]->CreateView();
|
||||
while ((fNetworkAddOnMap[fAddOnCount]
|
||||
= get_nth_addon(image, tabCount)) != NULL) {
|
||||
printf("Adding Tab: %d\n", fAddOnCount);
|
||||
BView* view = fNetworkAddOnMap[fAddOnCount]->CreateView();
|
||||
|
||||
// FIXME rework this: we don't want to use a tab view here,
|
||||
// instead add-ons should populate the "interfaces" list with
|
||||
// interfaces, services, etc.
|
||||
fPanel->AddTab(addon_view);
|
||||
fAddonCount++;
|
||||
fPanel->AddTab(view);
|
||||
fAddOnCount++;
|
||||
// Number of tab addons total
|
||||
tabCount++;
|
||||
// Tabs for *this* addon
|
||||
@@ -309,7 +300,7 @@ NetworkSetupWindow::_BuildShowTabView()
|
||||
}
|
||||
}
|
||||
|
||||
free(search_paths);
|
||||
free(searchPaths);
|
||||
}
|
||||
|
||||
|
||||
@@ -317,16 +308,14 @@ void
|
||||
NetworkSetupWindow::_ShowReplicant(bool show)
|
||||
{
|
||||
if (show) {
|
||||
char* argv[] = {const_cast<char *>("--deskbar"), NULL};
|
||||
const char* argv[] = {"--deskbar", NULL};
|
||||
|
||||
status_t ret = be_roster->Launch(
|
||||
"application/x-vnd.Haiku-NetworkStatus", 1, argv);
|
||||
|
||||
if (ret != B_OK) {
|
||||
status_t status = be_roster->Launch(be_app->Signature(), 1, argv);
|
||||
if (status != B_OK) {
|
||||
BString errorMessage;
|
||||
errorMessage.SetToFormat(
|
||||
B_TRANSLATE("Installing NetworkStatus in Deskbar failed: %s"),
|
||||
strerror(ret));
|
||||
strerror(status));
|
||||
BAlert* alert = new BAlert(B_TRANSLATE("launch error"),
|
||||
errorMessage, B_TRANSLATE("Ok"));
|
||||
alert->Go(NULL);
|
||||
|
||||
@@ -1,38 +1,31 @@
|
||||
/*
|
||||
* Copyright 2004-2011 Haiku Inc. All rights reserved.
|
||||
* Copyright 2004-2015 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Alexander von Gluck, <[email protected]>
|
||||
*/
|
||||
#ifndef NETWORKSETUPWINDOW_H
|
||||
#define NETWORKSETUPWINDOW_H
|
||||
#ifndef NETWORK_SETUP_WINDOW_H
|
||||
#define NETWORK_SETUP_WINDOW_H
|
||||
|
||||
|
||||
#include "NetworkSetupAddOn.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
typedef std::map<int, NetworkSetupAddOn*> NetworkAddOnMap;
|
||||
|
||||
|
||||
class NetworkSetupWindow;
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
class BTabView;
|
||||
class BButton;
|
||||
class BMenu;
|
||||
|
||||
class NetworkSetupWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
NetworkSetupWindow(const char *title);
|
||||
~NetworkSetupWindow();
|
||||
|
||||
typedef BWindow inherited;
|
||||
|
||||
class NetworkSetupWindow : public BWindow {
|
||||
public:
|
||||
static const uint32 kMsgProfileSelected = 'prof';
|
||||
static const uint32 kMsgProfileManage = 'mngp';
|
||||
static const uint32 kMsgProfileNew = 'newp';
|
||||
@@ -40,26 +33,32 @@ class NetworkSetupWindow : public BWindow
|
||||
static const uint32 kMsgRevert = 'rvrt';
|
||||
static const uint32 kMsgToggleReplicant = 'trep';
|
||||
|
||||
bool QuitRequested();
|
||||
void MessageReceived(BMessage* msg);
|
||||
public:
|
||||
NetworkSetupWindow();
|
||||
virtual ~NetworkSetupWindow();
|
||||
|
||||
private:
|
||||
void _BuildProfilesMenu(BMenu* menu, int32 msg);
|
||||
bool QuitRequested();
|
||||
void MessageReceived(BMessage* message);
|
||||
|
||||
private:
|
||||
typedef BWindow inherited;
|
||||
|
||||
void _BuildProfilesMenu(BMenu* menu, int32 what);
|
||||
void _BuildShowTabView();
|
||||
|
||||
bool _IsReplicantInstalled();
|
||||
void _ShowReplicant(bool show);
|
||||
|
||||
private:
|
||||
BButton* fRevertButton;
|
||||
BButton* fApplyButton;
|
||||
|
||||
NetworkAddOnMap fNetworkAddOnMap;
|
||||
|
||||
BTabView* fPanel;
|
||||
BView* fAddonView;
|
||||
int fAddonCount;
|
||||
BView* fAddOnView;
|
||||
int fAddOnCount;
|
||||
};
|
||||
|
||||
|
||||
#endif // ifdef NETWORKSETUPWINDOW_H
|
||||
|
||||
#endif // NETWORK_SETUP_WINDOW_H
|
||||
|
||||
Reference in New Issue
Block a user