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 _SUPPLICANTLISTENER_H__ |
| 17 | #define _SUPPLICANTLISTENER_H__ |
| 18 | |
| 19 | #include <pthread.h> |
| 20 | |
| 21 | #include <sysutils/SocketListener.h> |
| 22 | |
| 23 | struct wpa_ctrl; |
| 24 | class Supplicant; |
| 25 | |
| 26 | class SupplicantListener: public SocketListener { |
| 27 | private: |
| 28 | struct wpa_ctrl *mMonitor; |
| 29 | Supplicant *mSupplicant; |
| 30 | pthread_t mThread; |
| 31 | |
| 32 | public: |
| 33 | SupplicantListener(Supplicant *supplicant, struct wpa_ctrl *monitor); |
| 34 | virtual ~SupplicantListener() {} |
| 35 | int startListener(); |
| 36 | int stopListener(); |
| 37 | |
| 38 | struct wpa_ctrl *getMonitor() { return mMonitor; } |
| 39 | Supplicant *getSupplicant() { return mSupplicant; } |
| 40 | |
| 41 | protected: |
| 42 | virtual bool onDataAvailable(int socket); |
| 43 | |
| 44 | private: |
| 45 | static void *threadStart(void *obj); |
| 46 | }; |
| 47 | |
| 48 | #endif |