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 | */ |
| 16 | #ifndef _NETWORKMANAGER_H |
| 17 | #define _NETWORKMANAGER_H |
| 18 | |
San Mehat | 1441e76 | 2009-05-07 11:37:10 -0700 | [diff] [blame^] | 19 | #include <sysutils/SocketListener.h> |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 20 | |
San Mehat | 1441e76 | 2009-05-07 11:37:10 -0700 | [diff] [blame^] | 21 | #include "Controller.h" |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 22 | |
| 23 | class NetworkManager { |
| 24 | private: |
San Mehat | 1441e76 | 2009-05-07 11:37:10 -0700 | [diff] [blame^] | 25 | static NetworkManager *sInstance; |
| 26 | |
| 27 | private: |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 28 | ControllerCollection *mControllers; |
San Mehat | 1441e76 | 2009-05-07 11:37:10 -0700 | [diff] [blame^] | 29 | SocketListener *mBroadcaster; |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 30 | |
| 31 | public: |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 32 | virtual ~NetworkManager() {} |
| 33 | |
| 34 | int run(); |
| 35 | |
San Mehat | 1441e76 | 2009-05-07 11:37:10 -0700 | [diff] [blame^] | 36 | 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 Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 45 | private: |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 46 | int startControllers(); |
| 47 | int stopControllers(); |
San Mehat | 1441e76 | 2009-05-07 11:37:10 -0700 | [diff] [blame^] | 48 | NetworkManager(); |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 49 | |
| 50 | public: |
| 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 |