Removed aliases for C-libpurple functions.
[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 cimport purple
21
22 cdef extern from *:
23     ctypedef char const_char "const char"
24
25 connection_cbs = {}
26
27 cdef extern from *:
28     ctypedef int size_t
29
30 cdef void connect_progress(connection.PurpleConnection *gc, const_char *text, \
31         size_t step, size_t step_count):
32     """
33     When an account is connecting, this operation is called to notify the UI
34     of what is happening, as well as which a step out of step_count has been
35     reached (which might be displayed as a progress bar).
36     """
37     debug.purple_debug_info("connection", "%s", "connect-progress\n")
38     if connection_cbs.has_key("connect-progress"):
39         (<object> connection_cbs["connect-progress"])(<char *> text, step, step_count)
40
41 cdef void connected(connection.PurpleConnection *gc):
42     """
43     Called when a connection is established (just before the signed-on signal).
44     """
45     debug.purple_debug_info("connection", "%s", "connected\n")
46     if connection_cbs.has_key("connected"):
47         (<object> connection_cbs["connected"])("connected: TODO")
48
49 cdef void disconnected(connection.PurpleConnection *gc):
50     """
51     Called when a connection is ended (between the signing-off and signed-off
52     signal).
53     """
54     debug.purple_debug_info("connection", "%s", "disconnected\n")
55     if connection_cbs.has_key("disconnected"):
56         (<object> connection_cbs["disconnected"])("disconnected: TODO")
57
58 cdef void notice(connection.PurpleConnection *gc, const_char *text):
59     """
60     Used to display connection-specific notices. (Pidgin's Gtk user interface
61     implements this as a no-op; purple_connection_notice(), which uses this
62     operation, is not used by any of the protocols shipped with libpurple.)
63     """
64     debug.purple_debug_info("connection", "%s", "notice\n")
65     if connection_cbs.has_key("notice"):
66         (<object> connection_cbs["notice"])("notice: TODO")
67
68 cdef void report_disconnect(connection.PurpleConnection *gc, const_char *text):
69     """
70     Called when an error causes a connection to be disconnected.
71     Called before disconnected.
72     @param text  a localized error message.
73     @see purple_connection_error
74     @deprecated in favour of
75                 PurpleConnectionUiOps.report_disconnect_reason.
76     """
77     debug.purple_debug_info("connection", "%s", "report-disconnect\n")
78     if connection_cbs.has_key("report-disconnect"):
79         (<object> connection_cbs["report-disconnect"])(<char *> text)
80
81 cdef void network_connected():
82     """
83     Called when libpurple discovers that the computer's network connection
84     is active. On Linux, this uses Network Manager if available; on Windows,
85     it uses Win32's network change notification infrastructure.
86     """
87     debug.purple_debug_info("connection", "%s", "network-connected\n")
88     if connection_cbs.has_key("network-connected"):
89         (<object> connection_cbs["network-connected"])()
90
91 cdef void network_disconnected():
92     """
93     Called when libpurple discovers that the computer's network connection
94     has gone away.
95     """
96     debug.purple_debug_info("connection", "%s", "network-disconnected\n")
97     if connection_cbs.has_key("network-disconnected"):
98         (<object> connection_cbs["network-disconnected"])()
99
100 cdef void report_disconnect_reason(connection.PurpleConnection *gc, \
101         connection.PurpleConnectionError reason, const_char *text):
102     """
103     Called when an error causes a connection to be disconnected. Called
104     before disconnected. This op is intended to replace report_disconnect.
105     If both are implemented, this will be called first; however, there's no
106     real reason to implement both.
107     @param reason  why the connection ended, if known, or
108                    PURPLE_CONNECTION_ERROR_OTHER_ERROR, if not.
109     @param text  a localized message describing the disconnection
110                  in more detail to the user.
111     @see purple_connection_error_reason
112     @since 2.3.0
113     """
114     debug.purple_debug_info("connection", "%s", "report-disconnect-reason\n")
115
116     reason_string = {
117         0: 'Network error',
118         1: 'Invalid username',
119         2: 'Authentication failed',
120         3: 'Authentication impossible',
121         4: 'No SSL support',
122         5: 'Encryption error',
123         6: 'Name in use',
124         7: 'Invalid settings',
125         8: 'Certificate not provided',
126         9: 'Certificate untrusted',
127         10: 'Certificate expired',
128         11: 'Certificate not activated',
129         12: 'Certificate hostname mismatch',
130         13: 'Certificate fingerprint mismatch',
131         14: 'Certificate self signed',
132         15: 'Certificate error (other)',
133         16: 'Other error' }[reason]
134
135     if connection_cbs.has_key("report-disconnect-reason"):
136         (<object> connection_cbs["report-disconnect-reason"])(reason_string, <char *> text)