Revert "[Tizen] Add DALi Autofill implementation"
[platform/core/uifw/dali-adaptor.git] / dali / internal / network / common / socket-impl.h
1 #ifndef DALI_INTERNAL_ADAPTOR_SOCKET_IMPL_H
2 #define DALI_INTERNAL_ADAPTOR_SOCKET_IMPL_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 #include <dali/internal/network/common/socket-interface.h>
22
23 namespace Dali
24 {
25
26 namespace Internal
27 {
28
29 namespace Adaptor
30 {
31
32 /**
33  * @brief Concrete implementation of a socket under Linux.
34  *
35  * Provides automatic closing of socket on destruction.
36  */
37 class Socket : public SocketInterface
38 {
39 public:
40
41   /**
42    * @brief Constructor
43    * @param protocol network protocol
44    * @param fileDescriptor option file descriptor if the socket is already open
45    */
46   Socket( Protocol protocol , int fileDescriptor = -1 );
47
48   /**
49    * @copydoc Dali::Internal::Adaptor::SocketIsOpen()
50    */
51   virtual bool SocketIsOpen() const;
52
53   /**
54    * @copydoc Dali::Internal::Adaptor::SocketInterface::CloseSocket
55    */
56   virtual bool CloseSocket();
57
58   /**
59    * @copydoc Dali::Internal::Adaptor::SocketInterface::Bind
60    */
61   virtual bool Bind( uint16_t port ) ;
62
63   /**
64    * @copydoc Dali::Internal::Adaptor::SocketInterface::Listen
65    */
66   virtual bool Listen( int blacklog);
67
68   /**
69    * @copydoc Dali::Internal::Adaptor::SocketInterface::Accept
70    */
71   virtual SocketInterface* Accept() const ;
72
73   /**
74    * @copydoc Dali::Internal::Adaptor::SocketInterface::Select
75    */
76   virtual SelectReturn Select( );
77
78   /**
79    * @copydoc Dali::Internal::Adaptor::SocketInterface::ExitSelect
80    */
81   virtual void ExitSelect();
82
83   /**
84    * @copydoc Dali::Internal::Adaptor::SocketInterface::Recieve
85    */
86   virtual bool Read( void* buffer, unsigned int bufferSizeInBytes, unsigned int& bytesRead );
87
88   /**
89    * @copydoc Dali::Internal::Adaptor::SocketInterface::Send
90    */
91   virtual bool Write( const void* buffer, unsigned int bufferLength );
92
93   /**
94    * @copydoc Dali::Internal::Adaptor::SocketInterface::ReuseAddress
95    */
96   virtual bool ReuseAddress( bool reUse );
97
98   /**
99    * @copydoc Dali::Internal::Adaptor::SocketInterface::SetBufferSize
100    *
101    */
102   virtual bool SetBufferSize( SocketInterface::BufferType type, unsigned int bufferSizeInBytes );
103
104   /**
105    * @brief Virtual destructor
106    */
107   virtual ~Socket();
108
109 private:
110
111
112   /**
113    * @brief Helper to create the quit pipe
114    */
115   bool CreateQuitPipe();
116
117   /**
118    * @brief  Helper to delete the quit pipe
119    */
120   void DeleteQuitPipe();
121
122   int mSocketFileDescriptor; ///< file descriptor
123   int mQuitPipe[2];          ///< Pipe to inform Select to quit.
124   bool mBound:1;             ///< whether the socket is bound
125   bool mListening:1;         ///< whether the socket is being listen to
126   bool mQuitPipeCreated:1;   ///< whether the quit pipe has been created
127   bool mBlocked:1;           ///< whether the socket is blocked waiting for a connection
128 };
129
130
131
132 } // Adaptor
133
134 } // Internal
135
136 } // Dali
137
138 #endif // DALI_INTERNAL_ADAPTOR_SOCKET_IMPL_H