San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame^] | 16 | |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 17 | #ifndef _NETWORKMANAGER_H |
| 18 | #define _NETWORKMANAGER_H |
| 19 | |
San Mehat | 1441e76 | 2009-05-07 11:37:10 -0700 | [diff] [blame] | 20 | #include <sysutils/SocketListener.h> |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 21 | |
San Mehat | 1441e76 | 2009-05-07 11:37:10 -0700 | [diff] [blame] | 22 | #include "Controller.h" |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame^] | 23 | |
| 24 | #include "PropertyManager.h" |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 25 | |
San Mehat | 192331d | 2009-05-22 13:58:06 -0700 | [diff] [blame] | 26 | class InterfaceConfig; |
| 27 | |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 28 | class NetworkManager { |
| 29 | private: |
San Mehat | 1441e76 | 2009-05-07 11:37:10 -0700 | [diff] [blame] | 30 | static NetworkManager *sInstance; |
| 31 | |
| 32 | private: |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 33 | ControllerCollection *mControllers; |
San Mehat | 1441e76 | 2009-05-07 11:37:10 -0700 | [diff] [blame] | 34 | SocketListener *mBroadcaster; |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame^] | 35 | PropertyManager *mPropMngr; |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 36 | |
| 37 | public: |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame^] | 38 | virtual ~NetworkManager(); |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 39 | |
| 40 | int run(); |
| 41 | |
San Mehat | 1441e76 | 2009-05-07 11:37:10 -0700 | [diff] [blame] | 42 | int attachController(Controller *controller); |
| 43 | |
| 44 | Controller *findController(const char *name); |
| 45 | |
| 46 | void setBroadcaster(SocketListener *sl) { mBroadcaster = sl; } |
| 47 | SocketListener *getBroadcaster() { return mBroadcaster; } |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame^] | 48 | PropertyManager *getPropMngr() { return mPropMngr; } |
San Mehat | 1441e76 | 2009-05-07 11:37:10 -0700 | [diff] [blame] | 49 | |
| 50 | static NetworkManager *Instance(); |
| 51 | |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 52 | private: |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 53 | int startControllers(); |
| 54 | int stopControllers(); |
San Mehat | 4876567 | 2009-05-20 15:28:43 -0700 | [diff] [blame] | 55 | |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame^] | 56 | NetworkManager(PropertyManager *propMngr); |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 57 | |
| 58 | public: |
San Mehat | 192331d | 2009-05-22 13:58:06 -0700 | [diff] [blame] | 59 | /* |
| 60 | * Called from a controller when an interface is available/ready for use. |
| 61 | * 'cfg' contains information on how this interface should be configured. |
| 62 | */ |
| 63 | int onInterfaceStart(Controller *c, const InterfaceConfig *cfg); |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 64 | |
San Mehat | 192331d | 2009-05-22 13:58:06 -0700 | [diff] [blame] | 65 | /* |
| 66 | * Called from a controller when an interface should be shut down |
| 67 | */ |
| 68 | int onInterfaceStop(Controller *c, const char *name); |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 69 | }; |
| 70 | #endif |