blob: bd008496c534ebc8e303bdbb1bd0c2b3acd5d016 [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 Mehat48765672009-05-20 15:28:43 -070022#include "PropertyCollection.h"
San Mehatdc266072009-05-06 11:16:52 -070023
24class NetworkManager {
25private:
San Mehat1441e762009-05-07 11:37:10 -070026 static NetworkManager *sInstance;
27
28private:
San Mehatdc266072009-05-06 11:16:52 -070029 ControllerCollection *mControllers;
San Mehat1441e762009-05-07 11:37:10 -070030 SocketListener *mBroadcaster;
San Mehat48765672009-05-20 15:28:43 -070031 PropertyCollection *mProperties;
San Mehatdc266072009-05-06 11:16:52 -070032
33public:
San Mehatdc266072009-05-06 11:16:52 -070034 virtual ~NetworkManager() {}
35
36 int run();
37
San Mehat1441e762009-05-07 11:37:10 -070038 int attachController(Controller *controller);
39
40 Controller *findController(const char *name);
41
San Mehat48765672009-05-20 15:28:43 -070042 const PropertyCollection &getProperties();
43 int setProperty(const char *name, char *value);
44 const char *getProperty(const char *name, char *buffer, size_t maxsize);
45
San Mehat1441e762009-05-07 11:37:10 -070046 void setBroadcaster(SocketListener *sl) { mBroadcaster = sl; }
47 SocketListener *getBroadcaster() { return mBroadcaster; }
48
49 static NetworkManager *Instance();
50
San Mehatdc266072009-05-06 11:16:52 -070051private:
San Mehatdc266072009-05-06 11:16:52 -070052 int startControllers();
53 int stopControllers();
San Mehat48765672009-05-20 15:28:43 -070054 int registerProperty(const char *name);
55 int unregisterProperty(const char *name);
56
San Mehat1441e762009-05-07 11:37:10 -070057 NetworkManager();
San Mehatdc266072009-05-06 11:16:52 -070058
59public:
60// XXX: Extract these into an interface
61 int onInterfaceCreated(Controller *c, char *name);
62 int onInterfaceDestroyed(Controller *c, char *name);
63
64};
65#endif