summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-06-03 03:30:56 +0200
committerChristian Pointner <equinox@spreadspace.org>2016-06-03 03:30:56 +0200
commit5702360d5bf118789bcbe0d13b8d616642ca3f31 (patch)
treea0f6ca44c6d75c94c99a9bad7ea98fb25763042a
parentmoved to minumu32 for firmware (diff)
first prototype is working
-rw-r--r--plugin/blinkyfications.pl26
1 files changed, 21 insertions, 5 deletions
diff --git a/plugin/blinkyfications.pl b/plugin/blinkyfications.pl
index a4fd2a5..aa068d3 100644
--- a/plugin/blinkyfications.pl
+++ b/plugin/blinkyfications.pl
@@ -47,8 +47,8 @@ sub plugin_load {
# Signals/Callbacks
my $conv_handle = Purple::Conversations::get_handle();
- Purple::Signal::connect($conv_handle, "received-im-msg", $plugin, \&received_msg_cb, "im");
- Purple::Signal::connect($conv_handle, "received-chat-msg", $plugin, \&received_msg_cb, "chat");
+ Purple::Signal::connect($conv_handle, "received-im-msg", $plugin, \&received_msg_cb, $plugin);
+# Purple::Signal::connect($conv_handle, "received-chat-msg", $plugin, \&received_msg_cb, $plugin);
}
sub plugin_unload {
@@ -68,7 +68,23 @@ sub prefs_info_cb {
}
sub received_msg_cb {
- my ($account, $sender, $message, $conv, $flags, $type) = @_;
- Purple::Debug::misc("blinkyfications", "$data (" . $account->get_username() . ", $sender, $message, $flags)\n");
- return 0
+ my ($account, $sender, $message, $conv, $flags, $plugin) = @_;
+ Purple::Debug::misc("blinkyfications", $account->get_username() . ": $sender says '$message'\n");
+
+ my $device = Purple::Prefs::get_string("/plugins/core/blinkyfications/device");
+ open(my $fh, '>', $device) or return Purple::Debug::error("blinkyfications", "can't open device: " . $device .": " . $! . "\n");
+ print $fh "r";
+ close $fh;
+
+ Purple::timeout_add($plugin, 0.3, \&timeout_cb, $plugin);
+ return 0;
+}
+
+sub timeout_cb {
+ my $plugin = shift;
+
+ my $device = Purple::Prefs::get_string("/plugins/core/blinkyfications/device");
+ open(my $fh, '>', $device) or return Purple::Debug::error("blinkyfications", "can't open device: " . $device .": " . $! . "\n");
+ print $fh "0";
+ close $fh;
}