| |
1 use Gaim; |
| |
2 |
| |
3 %PLUGIN_INFO = ( |
| |
4 perl_api_version => 2, |
| |
5 name => "Countdown Info Timer", |
| |
6 version => "0.1", |
| |
7 summary => "Makes a countdown in days from today.", |
| |
8 description => "Long description coming....", |
| |
9 author => "John H. Kelm <johnhkelm\@gmail.com>", |
| |
10 url => "http://gaim.sourceforge.net/", |
| |
11 |
| |
12 load => "plugin_load", |
| |
13 unload => "plugin_unload" |
| |
14 ); |
| |
15 |
| |
16 $GLOBAL_TEST_VAR = "STUFF!"; |
| |
17 |
| |
18 sub plugin_unload { |
| |
19 my $plugin = shift; |
| |
20 } |
| |
21 |
| |
22 sub plugin_init { |
| |
23 return %PLUGIN_INFO; |
| |
24 } |
| |
25 |
| |
26 |
| |
27 sub plugin_load { |
| |
28 my $plugin = shift; |
| |
29 |
| |
30 # Retrieve all the accounts |
| |
31 @accounts = Gaim::Accounts::get_all(); |
| |
32 |
| |
33 print "NUM OF ACCS: " . $accounts . "\n"; |
| |
34 # Search each account's user info for our tag |
| |
35 foreach $acc (@accounts) { |
| |
36 print "IN ACCOUNTS\n"; |
| |
37 $user_info = Gaim::Account::get_user_info($acc); |
| |
38 print "USER INFO 1: " . $user_info . "\n"; |
| |
39 # Find <countdown> and replace |
| |
40 $user_info =~ /countdown([0-9]+).([0-9]+).([0-9]+)/; |
| |
41 print "Found: " .$1 . " " . $2 . " " . $3 . "\n"; |
| |
42 $days = count_days($1, $2, $3); |
| |
43 $user_info =~ s/countdown(\d\d\d\d).(\d\d).(\d\d)/$days/; |
| |
44 print "USER INFO 2: " . $user_info . "\n"; |
| |
45 # Gaim::Account::set_user_info($acc, $user_info); |
| |
46 |
| |
47 } |
| |
48 |
| |
49 eval ' |
| |
50 use Gtk2 \'-init\'; |
| |
51 use Glib; |
| |
52 $window = Gtk2::Window->new(\'toplevel\'); |
| |
53 $window->set_border_width(10); |
| |
54 $button = Gtk2::Button->new("Hello World"); |
| |
55 $button->signal_connect(clicked => \&hello, $window); |
| |
56 |
| |
57 $window->add($button); |
| |
58 $button->show; |
| |
59 $window->show; |
| |
60 # Gtk2->main; |
| |
61 |
| |
62 0; |
| |
63 |
| |
64 '; warn $@ if $@; |
| |
65 } |
| |
66 |
| |
67 sub hello { |
| |
68 my ($widget, $window) = @_; |
| |
69 print "Called from sub hello!\n "; |
| |
70 print "Test var: " . $GLOBAL_TEST_VAR . " \n"; |
| |
71 @accounts = Gaim::Accounts::get_all(); |
| |
72 $acc = $accounts[0]; |
| |
73 $user_info = Gaim::Account::get_user_info($acc); |
| |
74 print "USER INFO from sub hello: " . $user_info . "\n"; |
| |
75 $window->destroy; |
| |
76 } |
| |
77 |
| |
78 sub count_days { |
| |
79 ($year, $month, $day) = @_; |
| |
80 |
| |
81 |
| |
82 eval ' |
| |
83 use Time::Local; |
| |
84 $future = timelocal(0,0,0,$day,$month-1,$year); |
| |
85 '; warn $@ if $@; |
| |
86 $today = time(); |
| |
87 $days = int(($future - $today)/(60*60*24)); |
| |
88 return $days; |
| |
89 } |