aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ecore_con/efl_network.eo
blob: 2f95a0584f87cc266c3639e85e243e2c1d56009e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
type Ecore_Con_Dns_Cb: __undefined_type; [[Ecore connection DNS callback type]]

enum Ecore.Con.Type
{
   [[Types for an ecore_con client/server object.  A correct way to set this type is
       with an ECORE_CON_$TYPE, optionally OR'ed with an ECORE_CON_$USE if encryption is desired,
       and LOAD_CERT if the previously loaded certificate should be used.]]
   legacy: ecore_con;

   local_user = 0, [[Socket in "~/.ecore"]]
   local_system = 1, [[Socket in /tmp]]
   local_abstract = 2, [[Abstract socket]]
   remote_tcp = 3, [[Remote server using TCP]]
   remote_mcast = 4, [[Remote multicast server]]
   remote_udp = 5, [[Remote server using UDP]]
   remote_broadcasT = 6, [[Remote broadcast using UDP]]
   remote_nodelay = 7, [[Remote connection sending packets immediately]]
   remote_cork = 8, [[Remote connection sending data in large chunks
                     Note: Only available on Linux
                     @since 1.2]]
   use_ssl2 = (1 << 4), [[Use SSL2: UNSUPPORTED.]]
   use_ssl3 = (1 << 5), [[Use SSL3: UNSUPPORTED.]]
   use_tls = (1 << 6), [[Use TLS]]
   use_mixed = Ecore.Con.Type.use_tls | Ecore.Con.Type.use_ssl3, [[Use both TLS and SSL3]]
   load_cert = (1 << 7), [[Attempt to use the loaded certificate]]
   no_proxy = (1 << 8), [[Disable all types of proxy on the server
                         Note: Only functional for clients
                         @since 1.2]]
   socket_activate = (1 << 9) [[Indicate if the type is socket activated]]
}

abstract Efl.Network (Efl.Object) {
   [[Abstract base class for all EFL.Network classes]]

   legacy_prefix: ecore_con;
   eo_prefix: efl_network;
   data: null;
   methods {
      @property ip {
         [[Control the IP address of a server that has been connected to.

           The parameter is a pointer to an internal string that contains the IP
           address of the connected server in the form "XXX.YYY.ZZZ.AAA" IP
           notation. This string should not be modified or trusted to stay
           valid after deletion for the svr object. If no IP is known
           null is returned.
         ]]
         get @virtual_pure {
             legacy: null;
         }
         values {
            ip: string; [[The IP address]]
         }
      }
      @property uptime {
         [[Check how long the object has been connected

           This function is used to find out how long a client has been
           connected.
         ]]
         get @virtual_pure {
             legacy: null;
         }
         values {
            uptime: double; [[The total time, in seconds, that the object has been connected.]]
         }
      }
      @property port @virtual_pure {
         [[The port that the obj is connected to]]
         set {
             legacy: null;
         }
         get {
             legacy: null;
         }
         values {
            port: int; [[The port that obj is connected to, or -1 on error.]]
         }
      }
      @property fd {
         [[Get the fd that the server is connected to

           This function returns the fd which is used by the underlying server
           connection. It should not be tampered with unless you REALLY know
           what you are doing.

           Note: This function is only valid for servers created with
           \@ref ecore_con_server_connect.

           Warning: Seriously. Don't use this unless you know what you are doing.

           @since 1.1
         ]]
         get @virtual_pure {
             legacy: null;
         }
         values {
            fd: int; [[The fd, or -1 on failure.]]
         }
      }
      @property connected {
         [[Returns whether the client is still connected]]
         get @virtual_pure {
             legacy: null;
         }
         values {
            connected: bool; [[$true if connected, $false otherwise.]]
         }
      }
      @property timeout @virtual_pure {
         [[Control the default time after which an inactive client will be
           disconnected.

           This function is used by the server to set the default idle timeout
           on clients. If any of the clients becomes idle for a time higher
           than this value, it will be disconnected. A value of < 1 disables
           the idle timeout.

           This timeout is not affected by the one set by @.timeout.set. A
           client will be disconnected whenever the client or the server
           timeout is reached. That means, the lower timeout value  will be
           used for that client if @.timeout.set is used on it.
         ]]
         set {
             legacy: null;
         }
         get {
             legacy: null;
         }
         values {
            timeout: double; [[The timeout, in seconds, to disconnect after.]]
         }
      }
      flush @virtual_pure {
         [[Flushes all pending data to the given server.

           This function will block until all data is sent to the server.
         ]]
         legacy: null;
      }
      send @virtual_pure {
         [[Sends the given data to the given server.

           This function will send the given data to the server as soon as the
           program is back to the main loop. Thus, this function returns
           immediately (non-blocking). If the data needs to be sent now, call
           \@ref ecore_con_server_flush after this one.
         ]]
         legacy: null;

         params {
            data: const(void_ptr); [[The given data]]
            size: int; [[Length of the data, in bytes.]]
         }
         return: int; [[The number of bytes sent. 0 will be returned if there
                        is an error.]]
      }
      lookup @class {
         [[Do an asynchronous DNS lookup.

           This function performs a DNS lookup on the hostname specified by name,
           then calls done_cb with the result and the data given as parameter.
           The result will be given to the done_cb as follows:

           canonname - the canonical name of the address, ip - the resolved ip
           address, addr - a pointer to the socket address, addrlen - the length
           of the socket address, in bytes, data - the data pointer given as
           parameter.
         ]]
         params {
            name: string @nonull; [[IP address or server name to translate.]]
            done_cb: Ecore_Con_Dns_Cb; [[Callback to notify when done.]]
            data: const(void_ptr); [[User data to be given to done_cb.]]
         }
         return: bool; [[$true if the request did not fail to be set up, $false otherwise.]]
      }
   }
   events {
        data,received: Ecore.Con.Event_Data.Received; [[Data received on connection]]
        connection,upgraded; [[FIXME: what does upgrade mean here??]]
        connection,error: string; [[Error received on connection]]
   }
}

/* FIXME: Should actually be a binbuf. */
struct Ecore.Con.Event_Data.Received {
    [[Ecore connection event data received data structure]]
    data: void_ptr; [[The data that got sent.]]
    size: int; [[The length of the data sent.]]
}

/* TODO
* Add events (to all of the ecore con stuff, e.g url).
* Make server the father of the client - make sure I don't leak references.
*
* Still need to add constructor client, and most likely migrate ecore_con_eet.
*
* Split server to two classes, listener and connector (or w/e).
*
* Mark the constructing properties all around.
*/