Added initial Debian packaging support.
[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 connection_cbs = {}
23
24 cdef extern from *:
25     ctypedef int size_t
26
27 cdef void connect_progress (connection.PurpleConnection *gc, const_char *text,
28                             size_t step, size_t step_count):
29     debug.c_purple_debug_info("connection", "%s", "connect-progress\n")
30     try:
31         (<object>connection_cbs["connect-progress"])(<char *>text, step, step_count)
32     except KeyError:
33         pass
34
35 cdef void connected (connection.PurpleConnection *gc):
36     debug.c_purple_debug_info("connection", "%s", "connected\n")
37     try:
38         (<object>connection_cbs["connected"])("connected: TODO")
39     except KeyError:
40         pass
41
42 cdef void disconnected (connection.PurpleConnection *gc):
43     debug.c_purple_debug_info("connection", "%s", "disconnected\n")
44     try:
45         (<object>connection_cbs["disconnected"])("disconnected: TODO")
46     except KeyError:
47         pass
48
49 cdef void notice (connection.PurpleConnection *gc, const_char *text):
50     debug.c_purple_debug_info("connection", "%s", "notice\n")
51     try:
52         (<object>connection_cbs["notice"])("notice: TODO")
53     except KeyError:
54         pass
55
56 cdef void report_disconnect (connection.PurpleConnection *gc,
57                              const_char *text):
58     debug.c_purple_debug_info("connection", "%s", "report-disconnect\n")
59     try:
60         (<object>connection_cbs["report-disconnect"])(<char *>text)
61     except KeyError:
62         pass
63
64 cdef void network_connected ():
65     debug.c_purple_debug_info("connection", "%s", "network-connected\n")
66     try:
67         (<object>connection_cbs["network-connected"])("network-connected: TODO")
68     except KeyError:
69         pass
70
71 cdef void network_disconnected ():
72     debug.c_purple_debug_info("connection", "%s", "network-disconnected\n")
73     try:
74         (<object>connection_cbs["network-disconnected"])("network-disconnected: TODO")
75     except KeyError:
76         pass
77
78 cdef void report_disconnect_reason (connection.PurpleConnection *gc,
79                                     connection.PurpleConnectionError reason,
80                                     const_char *text):
81     debug.c_purple_debug_info("connection", "%s", "report-disconnect-reason\n")
82
83     reason_string = {
84         0: 'Network error',
85         1: 'Invalid username',
86         2: 'Authentication failed',
87         3: 'Authentication impossible',
88         4: 'No SSL support',
89         5: 'Encryption error',
90         6: 'Name in use',
91         7: 'Invalid settings',
92         8: 'Certificate not provided',
93         9: 'Certificate untrusted',
94         10: 'Certificate expired',
95         11: 'Certificate not activated',
96         12: 'Certificate hostname mismatch',
97         13: 'Certificate fingerprint mismatch',
98         14: 'Certificate self signed',
99         15: 'Certificate error (other)',
100         16: 'Other error' }[reason]
101
102     try:
103         (<object>connection_cbs["report-disconnect-reason"])(reason_string, <char *>text)
104     except KeyError:
105         pass