blob: 0ac4a4dbb7caf0774a825943693025ba8a49c5e1 [file] [log] [blame]
San Mehatdc266072009-05-06 11:16:52 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef _NETWORKMANAGER_H
17#define _NETWORKMANAGER_H
18
San Mehat1441e762009-05-07 11:37:10 -070019#include <sysutils/SocketListener.h>
San Mehatdc266072009-05-06 11:16:52 -070020
San Mehat1441e762009-05-07 11:37:10 -070021#include "Controller.h"
San Mehatdc266072009-05-06 11:16:52 -070022
23class NetworkManager {
24private:
San Mehat1441e762009-05-07 11:37:10 -070025 static NetworkManager *sInstance;
26
27private:
San Mehatdc266072009-05-06 11:16:52 -070028 ControllerCollection *mControllers;
San Mehat1441e762009-05-07 11:37:10 -070029 SocketListener *mBroadcaster;
San Mehatdc266072009-05-06 11:16:52 -070030
31public:
San Mehatdc266072009-05-06 11:16:52 -070032 virtual ~NetworkManager() {}
33
34 int run();
35
San Mehat1441e762009-05-07 11:37:10 -070036 int attachController(Controller *controller);
37
38 Controller *findController(const char *name);
39
40 void setBroadcaster(SocketListener *sl) { mBroadcaster = sl; }
41 SocketListener *getBroadcaster() { return mBroadcaster; }
42
43 static NetworkManager *Instance();
44
San Mehatdc266072009-05-06 11:16:52 -070045private:
San Mehatdc266072009-05-06 11:16:52 -070046 int startControllers();
47 int stopControllers();
San Mehat1441e762009-05-07 11:37:10 -070048 NetworkManager();
San Mehatdc266072009-05-06 11:16:52 -070049
50public:
51// XXX: Extract these into an interface
52 int onInterfaceCreated(Controller *c, char *name);
53 int onInterfaceDestroyed(Controller *c, char *name);
54
55};
56#endif