libpurple/plugins/perl/common/Purple.pm

Thu, 07 Aug 2008 01:41:44 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Thu, 07 Aug 2008 01:41:44 +0000
changeset 23980
a38cbb35eecf
parent 16529
1d0da9270ff9
child 18068
b6554e3c8224
child 33955
55aa58076485
permissions
-rw-r--r--

Some cleanup and a couple leak fixes.

15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
1 package Purple;
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 use 5.008;
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 use strict;
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 use warnings;
6588
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
6 use Carp;
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 require Exporter;
6588
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
9 use AutoLoader;
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 our @ISA = qw(Exporter);
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 # Items to export into callers namespace by default. Note: do not export
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 # names by default without a very good reason. Use EXPORT_OK instead.
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 # Do not simply export all your public functions/methods/constants.
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
17 # This allows declaration use Purple ':all';
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 # will save memory.
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 our %EXPORT_TAGS = ( 'all' => [ qw(
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 ) ] );
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 our @EXPORT = qw(
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 );
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 our $VERSION = '0.01';
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31
6588
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
32 sub AUTOLOAD {
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
33 # This AUTOLOAD is used to 'autoload' constants from the constant()
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
34 # XS function.
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
35
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
36 my $constname;
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
37 our $AUTOLOAD;
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
38 ($constname = $AUTOLOAD) =~ s/.*:://;
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
39 croak "&Purple::constant not defined" if $constname eq 'constant';
6588
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
40 my ($error, $val) = constant($constname);
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
41 if ($error) { croak $error; }
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
42 {
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
43 no strict 'refs';
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
44
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
45 *$AUTOLOAD = sub { $val };
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
46 }
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
47
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
48 goto &$AUTOLOAD;
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
49 }
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
50
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 require XSLoader;
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
52 XSLoader::load('Purple', $VERSION);
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 # Preloaded methods go here.
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 1;
6619
99d7562b5177 [gaim-migrate @ 7143]
Christian Hammond <chipx86@chipx86.com>
parents: 6601
diff changeset
57 __END__
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 =head1 NAME
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
16529
1d0da9270ff9 This is mostly moving Purple::GtkUI:: -> Pidgin:: which has the side effect of
Etan Reisner <deryni@pidgin.im>
parents: 15906
diff changeset
61 Purple - Perl extension to the libpurple instant messenger library.
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 =head1 SYNOPSIS
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
65 use Purple;
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 =head1 ABSTRACT
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68
6598
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
69 This module provides the interface for using perl scripts as plugins
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
70 in libpurple.
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 =head1 DESCRIPTION
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73
6594
7217bb99c3f5 [gaim-migrate @ 7118]
Christian Hammond <chipx86@chipx86.com>
parents: 6588
diff changeset
74 This module provides the interface for using perl scripts as plugins
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
75 in Purple. With this, developers can write perl scripts that can be
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
76 loaded in Purple as plugins. The scripts can interact with IMs, chats,
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
77 accounts, the buddy list, libpurple signals, and more.
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
79 The API for the perl interface is very similar to that of the Purple C
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
80 API, which can be viewed at http://developer.pidgin.im/doxygen/ or in
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
81 the header files in the Purple source tree.
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82
6598
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
83 =head1 FUNCTIONS
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
84
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
85 =over
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
86
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
87 =item @accounts = Purple::accounts
6598
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
88
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
89 Returns a list of all accounts, online or offline.
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
90
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
91 =item @chats = Purple::chats
6598
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
92
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
93 Returns a list of all chats currently open.
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
94
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
95 =item @connections = Purple::connections
6598
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
96
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
97 Returns a list of all active connections.
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
98
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
99 =item @conversations = Purple::conversations
6598
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
100
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
101 Returns a list of all conversations, both IM and chat, currently open.
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
102
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
103 =item @conv_windows = Purple::conv_windows
6598
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
104
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
105 Returns a list of all conversation windows currently open.
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
106
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
107 =item @ims = Purple::ims
6598
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
108
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
109 Returns a list of all instant messages currently open.
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
110
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
111 =back
13f98c3c9362 [gaim-migrate @ 7122]
Christian Hammond <chipx86@chipx86.com>
parents: 6594
diff changeset
112
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 =head1 SEE ALSO
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
115 Purple C API documentation - http://developer.pidgin.im/doxygen/
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
117 Purple website - http://pidgin.im/
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 =head1 AUTHOR
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120
6588
187c6026c574 [gaim-migrate @ 7110]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
121 Christian Hammond, E<lt>chipx86@gnupdate.orgE<gt>
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 =head1 COPYRIGHT AND LICENSE
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 Copyright 2003 by Christian Hammond
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 This library is free software; you can redistribute it and/or modify
6594
7217bb99c3f5 [gaim-migrate @ 7118]
Christian Hammond <chipx86@chipx86.com>
parents: 6588
diff changeset
128 it under the terms of the General Public License (GPL). For
7217bb99c3f5 [gaim-migrate @ 7118]
Christian Hammond <chipx86@chipx86.com>
parents: 6588
diff changeset
129 more information, see http://www.fsf.org/licenses/gpl.txt
6508
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130
57d1df1ca3a0 [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 =cut

mercurial