Net::REPL::Client: Allow read/print portions to be overridden separately.
[thrasher.git] / perl / lib / Thrasher / Protocol / Purple / Vars.pm
blobe6e9088a6f0f2b5c98db0bbf6325c8fbab12e7df
1 package Thrasher::Protocol::Purple::Vars;
3 use strict;
4 use warnings;
6 use Exporter;
7 our @ISA = qw(Exporter);
8 our @ERROR_CODES = qw(
9 $ERROR_NETWORK_ERROR
10 $ERROR_INVALID_USERNAME
11 $ERROR_AUTHENTICATION_FAILED
12 $ERROR_AUTHENTICATION_IMPOSSIBLE
13 $ERROR_NO_SSL_SUPPORT
14 $ERROR_ENCRYPTION_ERROR
15 $ERROR_NAME_IN_USE
16 $ERROR_INVALID_SETTINGS
17 $ERROR_CERT_NOT_PROVIDED
18 $ERROR_CERT_UNTRUSTED
19 $ERROR_CERT_EXPIRED
20 $ERROR_CERT_NOT_ACTIVATED
21 $ERROR_CERT_HOSTNAME_MISMATCH
22 $ERROR_CERT_FINGERPRINT_MISMATCH
23 $ERROR_CERT_SELF_SIGNED
24 $ERROR_CERT_OTHER_ERROR
25 $ERROR_OTHER_ERROR
27 our @EXPORT_OK = (qw(%purple_presence %purple_presence_to_xmpp), @ERROR_CODES);
28 our %EXPORT_TAGS = (all => \@EXPORT_OK,
29 error_codes => \@ERROR_CODES);
31 # mirror server.h enum
32 our $ERROR = 0;
33 our $LOGIN = 1;
34 our $LOGOUT = 2;
35 our $SEND_MSG = 3;
36 our $RECV_MSG = 4;
37 our $PRESENCE = 5;
38 our $SUBSCR_ADD = 6;
39 our $SUBSCR_REM = 7;
40 our $BUDDY_ADD = 8;
41 our $BUDDY_REM = 9;
43 # Mirror of PurpleConnectionError from connection.h
44 our $ERROR_NETWORK_ERROR = 0;
45 our $ERROR_INVALID_USERNAME = 1;
46 our $ERROR_AUTHENTICATION_FAILED = 2;
47 our $ERROR_AUTHENTICATION_IMPOSSIBLE = 3;
48 our $ERROR_NO_SSL_SUPPORT = 4;
49 our $ERROR_ENCRYPTION_ERROR = 5;
50 our $ERROR_NAME_IN_USE = 6;
51 our $ERROR_INVALID_SETTINGS = 7;
52 our $ERROR_CERT_NOT_PROVIDED = 8;
53 our $ERROR_CERT_UNTRUSTED = 9;
54 our $ERROR_CERT_EXPIRED = 10;
55 our $ERROR_CERT_NOT_ACTIVATED = 11;
56 our $ERROR_CERT_HOSTNAME_MISMATCH = 12;
57 our $ERROR_CERT_FINGERPRINT_MISMATCH = 13;
58 our $ERROR_CERT_SELF_SIGNED = 14;
59 our $ERROR_CERT_OTHER_ERROR = 15;
60 our $ERROR_OTHER_ERROR = 16;
63 # mirror libpurple/status.h PurpleStatusPrimitive enum
64 our $PURPLE_STATUS_UNSET = 0;
65 our $PURPLE_STATUS_OFFLINE = 1;
66 our $PURPLE_STATUS_AVAILABLE = 2;
67 our $PURPLE_STATUS_UNAVAILABLE = 3;
68 our $PURPLE_STATUS_INVISIBLE = 4;
69 our $PURPLE_STATUS_AWAY = 5;
70 our $PURPLE_STATUS_EXTENDED_AWAY = 6;
71 our $PURPLE_STATUS_MOBILE = 7;
72 our $PURPLE_STATUS_TUNE = 8;
73 our $PURPLE_STATUS_NUM_PRIMITIVES = 9;
75 # mirror tlv_struct enum in server.h
76 our $JID = 1;
77 our $USERNAME = 2;
78 our $PASSWORD = 3;
79 our $MESSAGE = 4;
80 our $RECIPIENT = 5;
81 our $SENDER = 6;
82 our $STATUS = 7;
83 our $ALIAS = 8;
84 our $GROUP = 9;
85 our $ERROR_CODE= 10;
87 # TLV lookup
88 my %tlv_type = (
89 JID => $JID,
90 USERNAME => $USERNAME,
91 PASSWORD => $PASSWORD,
92 MESSAGE => $MESSAGE,
93 RECIPIENT => $RECIPIENT,
94 SENDER => $SENDER,
95 STATUS => $STATUS,
96 ALIAS => $ALIAS,
97 GROUP => $GROUP,
98 ERROR_CODE=> $ERROR_CODE,
101 # TLV reverse lookup
102 my %tlv_reverse_lookup = reverse %tlv_type;
104 # presence lookup
105 our %purple_presence = (
106 unset => $PURPLE_STATUS_UNSET,
107 offline => $PURPLE_STATUS_OFFLINE,
108 available => $PURPLE_STATUS_AVAILABLE,
109 unavailable => $PURPLE_STATUS_UNAVAILABLE,
110 invisible => $PURPLE_STATUS_INVISIBLE,
111 away => $PURPLE_STATUS_AWAY,
112 xaway => $PURPLE_STATUS_EXTENDED_AWAY,
113 mobile => $PURPLE_STATUS_MOBILE,
114 tune => $PURPLE_STATUS_TUNE,
115 num_prim => $PURPLE_STATUS_NUM_PRIMITIVES,
118 our %purple_presence_to_xmpp = (
119 $PURPLE_STATUS_OFFLINE => [ 'unavailable', '', ],
120 $PURPLE_STATUS_AVAILABLE => [ '', '', ],
121 $PURPLE_STATUS_UNAVAILABLE => [ '', 'dnd' ],
122 $PURPLE_STATUS_INVISIBLE => [ 'unavailable', '', ],
123 $PURPLE_STATUS_AWAY => [ '', 'away', ],
124 $PURPLE_STATUS_EXTENDED_AWAY => [ '', 'xa', ],
127 # action lookup
128 my %actions = (
129 'error' => $ERROR,
130 'login' => $LOGIN,
131 'logout' => $LOGOUT,
132 'send_msg' => $SEND_MSG,
133 'recv_msg' => $RECV_MSG,
134 'presence' => $PRESENCE,
135 'subscr_add' => $SUBSCR_ADD,
136 'subscr_rem' => $SUBSCR_REM,
137 'buddy_add' => $BUDDY_ADD,
138 'buddy_rem' => $BUDDY_REM,