1/* 2 * Copyright 2006-2015, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Axel D��rfler, axeld@pinc-software.de 7 */ 8#ifndef SERVICES_H 9#define SERVICES_H 10 11 12#include <Handler.h> 13#include <Locker.h> 14 15#include <map> 16#include <string> 17#include <sys/select.h> 18 19 20struct service; 21struct service_connection; 22typedef std::map<std::string, service*> ServiceNameMap; 23typedef std::map<int, service_connection*> ServiceSocketMap; 24 25 26class Services : public BHandler { 27public: 28 Services(const BMessage& services); 29 virtual ~Services(); 30 31 status_t InitCheck() const; 32 33 virtual void MessageReceived(BMessage* message); 34 35private: 36 void _NotifyListener(bool quit = false); 37 void _UpdateMinMaxSocket(int socket); 38 status_t _StartService(struct service& service); 39 status_t _StopService(struct service* service); 40 status_t _ToService(const BMessage& message, 41 struct service*& service); 42 void _Update(const BMessage& services); 43 status_t _LaunchService(struct service& service, 44 int socket); 45 status_t _Listener(); 46 static status_t _Listener(void* self); 47 48private: 49 thread_id fListener; 50 BLocker fLock; 51 ServiceNameMap fNameMap; 52 ServiceSocketMap fSocketMap; 53 uint32 fUpdate; 54 int fReadPipe; 55 int fWritePipe; 56 int fMinSocket; 57 int fMaxSocket; 58 fd_set fSet; 59}; 60 61 62const static uint32 kMsgUpdateServices = 'srvU'; 63 64 65#endif // SERVICES_H 66