diff --git a/src/tests/kits/net/preflet/Jamfile b/src/tests/kits/net/preflet/Jamfile index 1797af13d5..a22af057ad 100644 --- a/src/tests/kits/net/preflet/Jamfile +++ b/src/tests/kits/net/preflet/Jamfile @@ -3,5 +3,6 @@ SubDir OBOS_TOP src tests kits net preflet ; SimpleTest Network : Network.cpp NetworkWindow.cpp + NetworkSetupAddOn.cpp : be root ; diff --git a/src/tests/kits/net/preflet/NetworkSetupAddOn.cpp b/src/tests/kits/net/preflet/NetworkSetupAddOn.cpp new file mode 100644 index 0000000000..6c67606fda --- /dev/null +++ b/src/tests/kits/net/preflet/NetworkSetupAddOn.cpp @@ -0,0 +1,45 @@ +#include + +#include "NetworkSetupAddOn.h" + + +NetworkSetupAddOn::NetworkSetupAddOn() + : fIsDirty(false), fProfile(NULL) +{ +} + +NetworkSetupAddOn::~NetworkSetupAddOn() +{ +} + +BView * NetworkSetupAddOn::CreateView(BRect *bounds) +{ + BView *v = new BView(*bounds, "a view", B_FOLLOW_ALL, B_WILL_DRAW); + v->SetViewColor((rand() % 256), (rand() % 256), (rand() % 256)); + return v; +} + + +status_t NetworkSetupAddOn::Save() +{ + return B_OK; +} + + +status_t NetworkSetupAddOn::Revert() +{ + return B_OK; +} + + +status_t NetworkSetupAddOn::SetProfile(NetworkProfile *new_profile) +{ + fProfile = new_profile; + return B_OK; +} + +const char * NetworkSetupAddOn::Name() +{ + return "Dummy NetworkSetupAddon"; +} + diff --git a/src/tests/kits/net/preflet/NetworkSetupAddOn.h b/src/tests/kits/net/preflet/NetworkSetupAddOn.h new file mode 100644 index 0000000000..2367f5ef38 --- /dev/null +++ b/src/tests/kits/net/preflet/NetworkSetupAddOn.h @@ -0,0 +1,42 @@ +#ifndef NETWORKSETUPADDON_H +#define NETWORKSETUPADDON_H + +#include + +class NetworkProfile; + +class NetworkSetupAddOn { + public: + NetworkSetupAddOn(); + virtual ~NetworkSetupAddOn(); + + virtual BView * CreateView(BRect *bounds); + virtual status_t Save(); + virtual status_t Revert(); + + virtual const char *Name(); + + + status_t SetProfile(NetworkProfile *new_profile); + NetworkProfile * Profile(); + bool IsDirty(); + void SetDirty(bool dirty = true); + + private: + bool fIsDirty; + NetworkProfile * fProfile; +}; + +inline bool NetworkSetupAddOn::IsDirty() { return fIsDirty; }; +inline void NetworkSetupAddOn::SetDirty(bool dirty) { fIsDirty = dirty; }; +inline NetworkProfile * NetworkSetupAddOn::Profile() { return fProfile; }; + +extern "C" { + +typedef NetworkSetupAddOn * (*network_setup_addon_instantiate)(void); +NetworkSetupAddOn * get_addon(void); + +} + +#endif // ifdef NETWORKSETUPADDON_H + diff --git a/src/tests/kits/net/preflet/NetworkWindow.cpp b/src/tests/kits/net/preflet/NetworkWindow.cpp index a3d111621f..c5ec6c56ce 100644 --- a/src/tests/kits/net/preflet/NetworkWindow.cpp +++ b/src/tests/kits/net/preflet/NetworkWindow.cpp @@ -8,7 +8,8 @@ #include #include -#include +#include "BoneyardAddOn.h" +#include "NetworkSetupAddOn.h" #include "NetworkWindow.h" @@ -165,17 +166,25 @@ void NetworkWindow::MessageReceived case SHOW_MSG: { BYAddon *by; + NetworkSetupAddOn *addon; if (fShowView) fShowView->RemoveSelf(); fShowView = NULL; - if (msg->FindPointer("byaddon", (void **) &by) != B_OK) - break; + by = NULL; + addon = NULL; + if (msg->FindPointer("addon", (void **) &addon) != B_OK) { + if (msg->FindPointer("byaddon", (void **) &by) != B_OK) + break; + }; fShowRect = fPanel->Bounds(); - fShowView = by->CreateView(&fShowRect); + if (addon) + fShowView = addon->CreateView(&fShowRect); + else + fShowView = by->CreateView(&fShowRect); if (fShowView) { fPanel->AddChild(fShowView); // fShowView->SetViewColor((rand() % 256), (rand() % 256), (rand() % 256)); @@ -311,11 +320,11 @@ void NetworkWindow::BuildShowMenu path.Append(search_path + 3); } else { path.SetTo(search_path); + path.Append("boneyard"); }; search_path = strtok_r(NULL, ":", &next_path_token); - path.Append("boneyard"); printf("Looking into %s\n", path.Path()); dir.SetTo(path.Path()); @@ -336,21 +345,39 @@ void NetworkWindow::BuildShowMenu printf("Addon %s loaded.\n", addon_path.Path()); - by_instantiate_func func; + by_instantiate_func by_func; + network_setup_addon_instantiate ns_func; status_t status; - status = get_image_symbol(addon_id, "instantiate", B_SYMBOL_TYPE_TEXT, (void **) &func); - if (status != B_OK) { - // No "modules" symbol found in this addon - printf("Symbol \"instantiate\" not found in %s addon: not a module addon!\n", addon_path.Path()); - } else { - BYAddon *by = func(); + status = get_image_symbol(addon_id, "get_addon", B_SYMBOL_TYPE_TEXT, (void **) &ns_func); + if (status == B_OK) { + NetworkSetupAddOn *addon; + + addon = ns_func(); BMessage *msg = new BMessage(msg_what); msg->AddInt32("image_id", addon_id); msg->AddString("addon_path", addon_path.Path()); - msg->AddPointer("byaddon", by); - menu->AddItem(new BMenuItem(by->Name(), msg)); + msg->AddPointer("addon", addon); + menu->AddItem(new BMenuItem(addon->Name(), msg)); + continue; }; + + status = get_image_symbol(addon_id, "instantiate", B_SYMBOL_TYPE_TEXT, (void **) &by_func); + if (status == B_OK) { + BYAddon *addon; + + addon = by_func(); + BMessage *msg = new BMessage(msg_what); + msg->AddInt32("image_id", addon_id); + msg->AddString("addon_path", addon_path.Path()); + msg->AddPointer("byaddon", addon); + menu->AddItem(new BMenuItem(addon->Name(), msg)); + continue; + }; + + // No "modules" symbol found in this addon + printf("Symbol \"instantiate\" not found in %s addon: not a module addon!\n", addon_path.Path()); + unload_add_on(addon_id); }; }; diff --git a/src/tests/kits/net/preflet/StatusAddOn/StatusAddOn.cpp b/src/tests/kits/net/preflet/StatusAddOn/StatusAddOn.cpp new file mode 100644 index 0000000000..34154d59aa --- /dev/null +++ b/src/tests/kits/net/preflet/StatusAddOn/StatusAddOn.cpp @@ -0,0 +1,20 @@ +#include + +#include "NetworkSetupAddOn.h" + +class StatusAddOn : public NetworkSetupAddOn { + public: + const char * Name(); +}; + + + +const char * StatusAddOn::Name() +{ + return "Status"; +} + +NetworkSetupAddOn * get_addon() +{ + return new StatusAddOn(); +}