1 /* 2 * Copyright 2004-2005, Waldemar Kornewald <wkornew@gmx.net> 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include "PPPServer.h" 7 #include <Application.h> 8 9 10 PPPServer::PPPServer() 11 : BHandler("PPPServer"), 12 fListener(this) 13 { 14 be_app->AddHandler(this); 15 16 fListener.WatchManager(); 17 18 InitInterfaces(); 19 } 20 21 22 PPPServer::~PPPServer() 23 { 24 UninitInterfaces(); 25 26 fListener.StopWatchingManager(); 27 28 be_app->RemoveHandler(this); 29 } 30 31 32 void 33 PPPServer::MessageReceived(BMessage *message) 34 { 35 switch(message->what) { 36 case PPP_REPORT_MESSAGE: 37 HandleReportMessage(message); 38 break; 39 40 default: 41 BHandler::MessageReceived(message); 42 } 43 } 44 45 46 void 47 PPPServer::InitInterfaces() 48 { 49 // TODO: create one ConnectionRequestWindow per interface 50 } 51 52 53 void 54 PPPServer::UninitInterfaces() 55 { 56 // TODO: delete all ConnectionRequestWindows 57 } 58 59 60 void 61 PPPServer::HandleReportMessage(BMessage *message) 62 { 63 ppp_interface_id id; 64 if (message->FindInt32("interface", reinterpret_cast<int32*>(&id)) != B_OK) 65 return; 66 67 int32 type, code; 68 message->FindInt32("type", &type); 69 message->FindInt32("code", &code); 70 71 if (type == PPP_MANAGER_REPORT && code == PPP_REPORT_INTERFACE_CREATED) 72 CreateConnectionRequestWindow(id); 73 } 74 75 76 void 77 PPPServer::CreateConnectionRequestWindow(ppp_interface_id id) 78 { 79 // TODO: create window, register window as report receiver for the interface 80 // XXX: if a window for that ID exists then only register it as report receiver 81 } 82