Removed python2.5-distutils build dependency for Ubuntu Jaunty.
[python-purple] / connection_cbs.pxd
1 #
2 #  Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
3 #
4 #  This file is part of python-purple.
5 #
6 #  python-purple is free software: you can redistribute it and/or modify
7 #  it under the terms of the GNU General Public License as published by
8 #  the Free Software Foundation, either version 3 of the License, or
9 #  (at your option) any later version.
10 #
11 #  python-purple is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU General Public License for more details.
15 #
16 #  You should have received a copy of the GNU General Public License
17 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 cdef extern from *:
21     ctypedef char const_char "const char"
22
23 connection_cbs = {}
24
25 cdef extern from *:
26     ctypedef int size_t
27
28 cdef void connect_progress(connection.PurpleConnection *gc, const_char *text, \
29         size_t step, size_t step_count):
30     """
31     When an account is connecting, this operation is called to notify the UI
32     of what is happening, as well as which a step out of step_count has been
33     reached (which might be displayed as a progress bar).
34     """
35     debug.purple_debug_info("connection", "%s", "connect-progress\n")
36     if "connect-progress" in connection_cbs:
37         (<object> connection_cbs["connect-progress"]) \
38             (<char *> text, step, step_count)
39
40 cdef void connected(connection.PurpleConnection *gc):
41     """
42     Called when a connection is established (just before the signed-on signal).
43     """
44     debug.purple_debug_info("connection", "%s", "connected\n")
45     if "connected" in connection_cbs:
46         (<object> connection_cbs["connected"])("connected: TODO")
47
48 cdef void disconnected(connection.PurpleConnection *gc):
49     """
50     Called when a connection is ended (between the signing-off and signed-off
51     signal).
52     """
53     debug.purple_debug_info("connection", "%s", "disconnected\n")
54     if "disconnected" in connection_cbs:
55         (<object> connection_cbs["disconnected"])("disconnected: TODO")
56
57 cdef void notice(connection.PurpleConnection *gc, const_char *text):
58     """
59     Used to display connection-specific notices. (Pidgin's Gtk user interface
60     implements this as a no-op; purple_connection_notice(), which uses this
61     operation, is not used by any of the protocols shipped with libpurple.)
62     """
63     debug.purple_debug_info("connection", "%s", "notice\n")
64     if "notice" in connection_cbs:
65         (<object> connection_cbs["notice"])("notice: TODO")
66
67 cdef void report_disconnect(connection.PurpleConnection *gc, const_char *text):
68     """
69     Called when an error causes a connection to be disconnected.
70     Called before disconnected.
71     @param text  a localized error message.
72     @see purple_connection_error
73     @deprecated in favour of
74                 PurpleConnectionUiOps.report_disconnect_reason.
75     """
76     debug.purple_debug_info("connection", "%s", "report-disconnect\n")
77     if "report-disconnect" in connection_cbs:
78         (<object> connection_cbs["report-disconnect"])(<char *> text)
79
80 cdef void network_connected():
81     """
82     Called when libpurple discovers that the computer's network connection
83     is active. On Linux, this uses Network Manager if available; on Windows,
84     it uses Win32's network change notification infrastructure.
85     """
86     debug.purple_debug_info("connection", "%s", "network-connected\n")
87     if "network-connected" in connection_cbs:
88         (<object> connection_cbs["network-connected"])()
89
90 cdef void network_disconnected():
91     """
92     Called when libpurple discovers that the computer's network connection
93     has gone away.
94     """
95     debug.purple_debug_info("connection", "%s", "network-disconnected\n")
96     if "network-disconnected" in connection_cbs:
97         (<object> connection_cbs["network-disconnected"])()
98
99 cdef void report_disconnect_reason(connection.PurpleConnection *gc, \
100         connection.PurpleConnectionError reason, const_char *c_text):
101     """
102     Called when an error causes a connection to be disconnected. Called
103     before disconnected. This op is intended to replace report_disconnect.
104     If both are implemented, this will be called first; however, there's no
105     real reason to implement both.
106     @param reason  why the connection ended, if known, or
107                    PURPLE_CONNECTION_ERROR_OTHER_ERROR, if not.
108     @param text  a localized message describing the disconnection
109                  in more detail to the user.
110     @see purple_connection_error_reason
111     @since 2.3.0
112     """
113     debug.purple_debug_info("connection", "%s", "report-disconnect-reason\n")
114
115     reason_string = {
116         0: 'Network error',
117         1: 'Invalid username',
118         2: 'Authentication failed',
119         3: 'Authentication impossible',
120         4: 'No SSL support',
121         5: 'Encryption error',
122         6: 'Name in use',
123         7: 'Invalid settings',
124         8: 'Certificate not provided',
125         9: 'Certificate untrusted',
126         10: 'Certificate expired',
127         11: 'Certificate not activated',
128         12: 'Certificate hostname mismatch',
129         13: 'Certificate fingerprint mismatch',
130         14: 'Certificate self signed',
131         15: 'Certificate error (other)',
132         16: 'Other error' }[reason]
133
134     if c_text:
135         text = <char *> c_text
136     else:
137         text = None
138
139     if "report-disconnect-reason" in connection_cbs:
140         (<object> connection_cbs["report-disconnect-reason"]) \
141             (reason_string, <char *> text)