diff --git a/src/prefs/dun/DUN.cpp b/src/prefs/dun/DUN.cpp index 62bcaf28af..4ae9e797cd 100644 --- a/src/prefs/dun/DUN.cpp +++ b/src/prefs/dun/DUN.cpp @@ -43,18 +43,19 @@ float FormHeightState2 = 282; BRect windowRect(FormTopDefault,FormLeftDefault,FormLeftDefault+FormWidthDefault,FormTopDefault+FormHeightDefault); - - // DUN -- constructor for DUN Class -DUN::DUN() : BApplication (APP_SIGNATURE) { - dunWindow = new DUNWindow(windowRect); +DUN::DUN() : BApplication (APP_SIGNATURE) +{ + ptrDUNWindow = new DUNWindow(windowRect); } // ------------------------------------------------------------------------------- // // DUN::MessageReceived -- handles incoming messages -void DUN::MessageReceived (BMessage *message) { - switch(message->what) { +void DUN::MessageReceived (BMessage *message) +{ + switch(message->what) + { default: BApplication::MessageReceived(message); // pass it along ... break; @@ -63,9 +64,12 @@ void DUN::MessageReceived (BMessage *message) { // ------------------------------------------------------------------------------- // // DUN Main -int main(void) { +int main(void) +{ DUN theApp; theApp.Run(); return 0; } // end + + diff --git a/src/prefs/dun/DUN.h b/src/prefs/dun/DUN.h index b1e701527b..a5bb56e564 100644 --- a/src/prefs/dun/DUN.h +++ b/src/prefs/dun/DUN.h @@ -22,7 +22,7 @@ public: DUN(); virtual void MessageReceived(BMessage *message); private: - DUNWindow* dunWindow; + DUNWindow* ptrDUNWindow; }; #endif diff --git a/src/prefs/dun/DUNWindow.cpp b/src/prefs/dun/DUNWindow.cpp index eb5e761282..fe2d8f95a2 100644 --- a/src/prefs/dun/DUNWindow.cpp +++ b/src/prefs/dun/DUNWindow.cpp @@ -2,16 +2,19 @@ DUNWindow - DialUp Networking BWindow -Authors: Sikosis (beos@gravity24hr.com) +Authors: Sikosis (phil@sikosis.com) Misza (misza@ihug.com.au) -(C) 2002-2003 OpenBeOS under MIT license +(C) 2002-2004 OpenBeOS under MIT license */ /*-----WARNING MESSY CODE AHEAD :-)------*/ + +#include #include "DUNWindow.h" #include "NewConnectionWindow.h" + // Add these to Constants file const int DUN_WINDOW_STATE_DEFAULT = 0; // default - closed const int DUN_WINDOW_STATE_ONE = 1; // 1st only @@ -28,7 +31,9 @@ float ModemFormHeightDefault = 324; BRect windowRectModem(ModemFormTopDefault,ModemFormLeftDefault,ModemFormLeftDefault+ModemFormWidthDefault,ModemFormTopDefault+ModemFormHeightDefault); // DUNWindow -- constructor for DUNWindow Class -DUNWindow::DUNWindow(BRect frame) : BWindow (frame, "OBOS Dial-up Networking", B_TITLED_WINDOW, B_NOT_RESIZABLE |B_NOT_ZOOMABLE, 0) { +DUNWindow::DUNWindow(BRect frame) : BWindow (frame, "OBOS Dial-up Networking", B_TITLED_WINDOW, + B_NOT_RESIZABLE |B_NOT_ZOOMABLE, 0) +{ InitWindow(); Show(); } @@ -356,7 +361,7 @@ void DUNWindow::MessageReceived (BMessage *message) errormsg->Go(); } break; - + case BTN_DISCONNECT: { disconnectbutton->SetEnabled(false); @@ -401,22 +406,35 @@ void DUNWindow::MessageReceived (BMessage *message) case MENU_CON_NEW: { + // open new connection window ptrNewConnectionWindow = new NewConnectionWindow(BRect(0,0,260,73)); } break; case BTN_MODEM: { + // open modem window modemWindow = new ModemWindow(windowRectModem); } break; case BTN_SETTINGS: { + // open settings window settingsWindow = new SettingsWindow(BRect(367.0, 268.0, 657.0, 500.0)); } break; - + + case ADD_NEW_CONNECTION: + { + // add and set our new connection + BString fConnectionName; + message->FindString("ConnectionName", &fConnectionName); + printf("ConnectionName = %s\n",fConnectionName.String()); + // add to dropdown + // set as current item with tick + } + break; default: { BWindow::MessageReceived(message); diff --git a/src/prefs/dun/DUNWindow.h b/src/prefs/dun/DUNWindow.h index e6780af478..b7347728f1 100644 --- a/src/prefs/dun/DUNWindow.h +++ b/src/prefs/dun/DUNWindow.h @@ -49,6 +49,10 @@ const uint32 MENU_LOC_DELETE_CURRENT = 'MLDl'; const uint32 TEST_BOX_1 = 'Tb1'; const uint32 TEST_BOX_2 = 'Tb2'; +const uint32 ADD_NEW_CONNECTION = 'adnc'; + +//const char *kConnectionName = "ConnectionName"; + struct last_active { int x;int y;}; class DUNView; diff --git a/src/prefs/dun/NewConnectionWindow.cpp b/src/prefs/dun/NewConnectionWindow.cpp index 5ca9a5cfd6..e88d6cf17a 100644 --- a/src/prefs/dun/NewConnectionWindow.cpp +++ b/src/prefs/dun/NewConnectionWindow.cpp @@ -2,9 +2,9 @@ NewConnectionWindow - DialUp Networking -Author: Sikosis (beos@gravity24hr.com) +Author: Sikosis (phil@sikosis.com) -(C) 2002 OpenBeOS under MIT license +(C)2002-2004 OpenBeOS under MIT license */ @@ -22,6 +22,7 @@ Author: Sikosis (beos@gravity24hr.com) #include #include +#include "DUNWindow.h" #include "NewConnectionWindow.h" #include "DUNView.h" @@ -101,20 +102,21 @@ void NewConnectionWindow::MessageReceived (BMessage *message) switch(message->what) { case BTN_ADD: - char tmp[256]; - sprintf(tmp,"%s",txtNewConnection->Text()); - (new BAlert("",tmp,"tmp"))->Go(); - - // need to create a new file called txtNewConnection->Text() and - // place it in the /boot/home/config/settings/DUN/DUNCONNECT directory - + { + // Send Messages to DUNWindow to Add New Connectionupdate + BWindow *ptrDUNWindow; + ptrDUNWindow = be_app->WindowAt(0); // its the first window + BMessage msg(ADD_NEW_CONNECTION); + msg.AddString("ConnectionName", txtNewConnection->Text()); + BMessenger(ptrDUNWindow).SendMessage(&msg); + // before closing we need to change the main window to state 1 - + Quit(); + } break; case BTN_CANCEL: Quit(); - //Hide(); // change later break; default: BWindow::MessageReceived(message);