1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4. use Purple;
  5.  
  6. our %PLUGIN_INFO = (
  7. perl_api_version => 2,
  8. name => "Google Talk SMS",
  9. version => "0.2",
  10. summary => "Enables Google Talk's SMS feature, which is normally restricted to official clients.",
  11. 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.",
  12. author => "Ryan Barrett <pidgin\@ryanb.org>",
  13. url => "http://snarfed.org/space/google_talk_sms+pidgin+plugin",
  14. load => "plugin_load",
  15. unload => "plugin_unload"
  16. );
  17.  
  18. sub plugin_init {
  19. return %PLUGIN_INFO;
  20. }
  21.  
  22. sub plugin_load {
  23. my $plugin = shift;
  24. my $jabber = Purple::Find::prpl("prpl-jabber");
  25. Purple::Signal::connect($jabber, "jabber-sending-xmlnode", $plugin,
  26. \&jabber_sending_xmlnode_cb, "unused userdata");
  27. }
  28.  
  29. sub plugin_unload {
  30. my $plugin = shift;
  31. }
  32.  
  33. sub jabber_sending_xmlnode_cb {
  34. my ($connection, $xmlnode, $userdata) = @_;
  35.  
  36. my $c = $xmlnode->get_child("c");
  37. if (not defined($c)) {
  38. return;
  39. }
  40.  
  41. my $ext = $c->get_attrib("ext");
  42. if (not defined($c)) {
  43. $ext = "";
  44. }
  45. $c->set_attrib("ext", $ext . " sms-v1");
  46.  
  47. $_[1] = $xmlnode;
  48. }
  49.