-
Notifications
You must be signed in to change notification settings - Fork 3
/
google_talk_sms.pl
61 lines (52 loc) · 1.84 KB
/
google_talk_sms.pl
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
#!/usr/bin/perl -w
##
## File: google_talk_sms.pl
## Author: Ryan Barrett <[email protected]>
##
## This is a Perl plugin for Pidgin that works around Google Talk's
## restriction of its SMS feature to official clients by by reporting that
## Pidgin supports the 'sms-v1' XMPP capabilities (XEP-0115) extension.
##
## Details in http://snarfed.org/space/google_talk_sms+pidgin+plugin
##
## Thanks to Michael Braun's Perl plugin for XEP-0027 (encryption), which
## provided a great example of how to use pidgin's xmlnode data structure in
## Perl: https://www.zuhauseall.homeip.net/~michael/pidgin-xep0027/
use strict;
use Purple;
our %PLUGIN_INFO = (
perl_api_version => 2,
name => "Google Talk SMS",
version => "0.2",
summary => "Enables Google Talk's SMS feature, which is normally restricted to official clients.",
description => "Works around Google Talk's restriction of its SMS feature to official clients by reporting that Pidgin supports the 'sms-v1' and 'sms-v2' XMPP capabilities (XEP-0115) extension.",
author => "Ryan Barrett <pidgin\@ryanb.org>",
url => "http://snarfed.org/space/google_talk_sms+pidgin+plugin",
load => "plugin_load",
unload => "plugin_unload"
);
sub plugin_init {
return %PLUGIN_INFO;
}
sub plugin_load {
my $plugin = shift;
my $jabber = Purple::Find::prpl("prpl-jabber");
Purple::Signal::connect($jabber, "jabber-sending-xmlnode", $plugin,
\&jabber_sending_xmlnode_cb, "unused userdata");
}
sub plugin_unload {
my $plugin = shift;
}
sub jabber_sending_xmlnode_cb {
my ($connection, $xmlnode, $userdata) = @_;
my $c = $xmlnode->get_child("c");
if (not defined($c)) {
return;
}
my $ext = $c->get_attrib("ext");
if (not defined($c)) {
$ext = "";
}
$c->set_attrib("ext", $ext . " sms-v1 sms-v2");
$_[1] = $xmlnode;
}