2004-11-21 15:56:05 +03:00
|
|
|
/*
|
2005-10-10 19:11:36 +04:00
|
|
|
* Copyright 2004-2005, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
2004-11-21 15:56:05 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2004-04-01 15:12:36 +04:00
|
|
|
|
|
|
|
#include "PPPServer.h"
|
|
|
|
#include <Application.h>
|
|
|
|
|
|
|
|
|
|
|
|
PPPServer::PPPServer()
|
2005-10-10 19:11:36 +04:00
|
|
|
: BHandler("PPPServer"),
|
|
|
|
fListener(this)
|
2004-04-01 15:12:36 +04:00
|
|
|
{
|
|
|
|
be_app->AddHandler(this);
|
2005-10-10 19:11:36 +04:00
|
|
|
|
|
|
|
fListener.WatchManager();
|
2004-04-15 20:05:40 +04:00
|
|
|
|
|
|
|
InitInterfaces();
|
2004-04-01 15:12:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PPPServer::~PPPServer()
|
|
|
|
{
|
2005-10-10 19:11:36 +04:00
|
|
|
UninitInterfaces();
|
|
|
|
|
|
|
|
fListener.StopWatchingManager();
|
|
|
|
|
2004-04-15 20:05:40 +04:00
|
|
|
be_app->RemoveHandler(this);
|
2004-04-01 15:12:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PPPServer::MessageReceived(BMessage *message)
|
|
|
|
{
|
|
|
|
switch(message->what) {
|
2004-04-15 20:05:40 +04:00
|
|
|
case PPP_REPORT_MESSAGE:
|
|
|
|
HandleReportMessage(message);
|
|
|
|
break;
|
2004-04-01 15:12:36 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
BHandler::MessageReceived(message);
|
|
|
|
}
|
|
|
|
}
|
2004-04-15 20:05:40 +04:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PPPServer::InitInterfaces()
|
|
|
|
{
|
2005-10-10 19:11:36 +04:00
|
|
|
// TODO: create one ConnectionRequestWindow per interface
|
2004-04-15 20:05:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-10 19:11:36 +04:00
|
|
|
void
|
|
|
|
PPPServer::UninitInterfaces()
|
2004-04-15 20:05:40 +04:00
|
|
|
{
|
2005-10-10 19:11:36 +04:00
|
|
|
// TODO: delete all ConnectionRequestWindows
|
2004-04-15 20:05:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PPPServer::HandleReportMessage(BMessage *message)
|
|
|
|
{
|
|
|
|
ppp_interface_id id;
|
2005-10-10 19:11:36 +04:00
|
|
|
if(message->FindInt32("interface", reinterpret_cast<int32*>(&id)) != B_OK)
|
2004-04-15 20:05:40 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
int32 type, code;
|
|
|
|
message->FindInt32("type", &type);
|
|
|
|
message->FindInt32("code", &code);
|
|
|
|
|
2005-10-10 19:11:36 +04:00
|
|
|
if(type == PPP_MANAGER_REPORT && code == PPP_REPORT_INTERFACE_CREATED)
|
|
|
|
CreateConnectionRequestWindow(id);
|
2004-04-15 20:05:40 +04:00
|
|
|
}
|
2004-11-21 15:56:05 +03:00
|
|
|
|
|
|
|
|
|
|
|
void
|
2005-10-10 19:11:36 +04:00
|
|
|
PPPServer::CreateConnectionRequestWindow(ppp_interface_id id)
|
2004-11-21 15:56:05 +03:00
|
|
|
{
|
2005-10-10 19:11:36 +04:00
|
|
|
// TODO: create window, register window as report receiver for the interface
|
|
|
|
// XXX: if a window for that ID exists then only register it as report receiver
|
2004-11-21 15:56:05 +03:00
|
|
|
}
|