xref: /haiku/src/servers/net/PPPServer.cpp (revision 2d73faba95c911a11d8a4a2070c47d47250ed9a9)
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 
PPPServer()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 
~PPPServer()22 PPPServer::~PPPServer()
23 {
24 	UninitInterfaces();
25 
26 	fListener.StopWatchingManager();
27 
28 	be_app->RemoveHandler(this);
29 }
30 
31 
32 void
MessageReceived(BMessage * message)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
InitInterfaces()47 PPPServer::InitInterfaces()
48 {
49 	// TODO: create one ConnectionRequestWindow per interface
50 }
51 
52 
53 void
UninitInterfaces()54 PPPServer::UninitInterfaces()
55 {
56 	// TODO: delete all ConnectionRequestWindows
57 }
58 
59 
60 void
HandleReportMessage(BMessage * message)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
CreateConnectionRequestWindow(ppp_interface_id id)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