diff --git a/ChangeLog b/ChangeLog
index 2d1801afe..098646de5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,11 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
-ChangeLog - 2006-03-03
+ChangeLog - 2006-03-04
Version 0.1.8 (under dev!):
+ * added inactivity time, available for plugins via get_info("inactivity")
* keys alt-{home|end} to scroll top/bottom, alt-{f11-f12} to scroll
nicklist top/bottom
* added special names for plugin message handlers: weechat_pv,
diff --git a/doc/en/weechat.en.xml b/doc/en/weechat.en.xml
index af92f7d32..ca1385fbc 100644
--- a/doc/en/weechat.en.xml
+++ b/doc/en/weechat.en.xml
@@ -2339,6 +2339,12 @@ plugin->exec_command (plugin, "freenode", "#weechat", "hello");
away
"away" flag
+
+ inactivity
+
+ number of seconds since last key was pressed
+
+
weechat_dir
@@ -2379,6 +2385,16 @@ plugin->exec_command (plugin, "freenode", "#weechat", "hello");
char *version = plugin->get_info (plugin, "version", NULL);
char *nick = plugin->get_info (plugin, "nick", "freenode");
+char *inactivity = plugin->get_info (plugin, "inactivity", NULL);
+
+plugin->print (plugin, NULL, NULL,
+ "WeeChat version %s, you are %s on freenode "
+ "(inactive for %s seconds)",
+ version, nick, inactivity);
+
+free (version);
+free (nick);
+free (inactivity);
diff --git a/doc/fr/weechat.fr.xml b/doc/fr/weechat.fr.xml
index 40f728cd6..3fccda1d4 100644
--- a/doc/fr/weechat.fr.xml
+++ b/doc/fr/weechat.fr.xml
@@ -2387,6 +2387,13 @@ plugin->exec_command (plugin, "freenode", "#weechat", "bonjour");
away
drapeau "away"
+
+ inactivity
+
+ nombre de secondes écoulées depuis que la dernière
+ touche a été appuyée
+
+
weechat_dir
@@ -2427,6 +2434,16 @@ plugin->exec_command (plugin, "freenode", "#weechat", "bonjour");
char *version = plugin->get_info (plugin, "version", NULL);
char *nick = plugin->get_info (plugin, "nick", "freenode");
+char *inactivity = plugin->get_info (plugin, "inactivity", NULL);
+
+plugin->print (plugin, NULL, NULL,
+ "WeeChat version %s, vous êtes %s sur freenode "
+ "(inactif depuis %s secondes)",
+ version, nick, inactivity);
+
+free (version);
+free (nick);
+free (inactivity);
diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c
index 47356e505..225058c25 100644
--- a/src/gui/curses/gui-input.c
+++ b/src/gui/curses/gui-input.c
@@ -209,6 +209,8 @@ gui_input_read ()
gui_refresh_screen ();
continue;
}
+
+ gui_last_activity_time = time (NULL);
if (key < 32)
{
@@ -319,6 +321,7 @@ gui_main_loop ()
quit_weechat = 0;
new_time = time (NULL);
+ gui_last_activity_time = new_time;
local_time = localtime (&new_time);
old_day = local_time->tm_mday;
diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c
index 46a524000..f4ac39148 100644
--- a/src/gui/gui-common.c
+++ b/src/gui/gui-common.c
@@ -65,6 +65,9 @@ t_gui_infobar *gui_infobar; /* pointer to infobar content */
char *gui_input_clipboard = NULL; /* clipboard content */
+time_t gui_last_activity_time = 0; /* last activity time */
+ /* (key pressed) */
+
/*
* gui_window_tree_init: create first entry in windows tree
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 37001239b..2c93b48f1 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -400,6 +400,7 @@ extern char gui_key_buffer[128];
extern int gui_key_grab;
extern int gui_key_grab_count;
extern char *gui_input_clipboard;
+extern time_t gui_last_activity_time;
extern t_gui_color *gui_color[NUM_COLORS];
diff --git a/src/plugins/plugins-interface.c b/src/plugins/plugins-interface.c
index ab2d677bc..069e1b4f2 100644
--- a/src/plugins/plugins-interface.c
+++ b/src/plugins/plugins-interface.c
@@ -384,6 +384,8 @@ weechat_plugin_get_info (t_weechat_plugin *plugin, char *info, char *server)
{
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
+ time_t inactivity;
+ char *inactivity_str;
if (!plugin || !info)
return NULL;
@@ -412,6 +414,18 @@ weechat_plugin_get_info (t_weechat_plugin *plugin, char *info, char *server)
{
return strdup (WEECHAT_SHAREDIR);
}
+ else if (ascii_strcasecmp (info, "inactivity") == 0)
+ {
+ if (gui_last_activity_time == 0)
+ inactivity = 0;
+ else
+ inactivity = time (NULL) - gui_last_activity_time;
+ inactivity_str = (char *) malloc (128);
+ if (!inactivity_str)
+ return NULL;
+ snprintf (inactivity_str, 128, "%ld", inactivity);
+ return inactivity_str;
+ }
/* below are infos that need server to return value */
diff --git a/weechat/ChangeLog b/weechat/ChangeLog
index 2d1801afe..098646de5 100644
--- a/weechat/ChangeLog
+++ b/weechat/ChangeLog
@@ -1,10 +1,11 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
-ChangeLog - 2006-03-03
+ChangeLog - 2006-03-04
Version 0.1.8 (under dev!):
+ * added inactivity time, available for plugins via get_info("inactivity")
* keys alt-{home|end} to scroll top/bottom, alt-{f11-f12} to scroll
nicklist top/bottom
* added special names for plugin message handlers: weechat_pv,
diff --git a/weechat/doc/en/weechat.en.xml b/weechat/doc/en/weechat.en.xml
index af92f7d32..ca1385fbc 100644
--- a/weechat/doc/en/weechat.en.xml
+++ b/weechat/doc/en/weechat.en.xml
@@ -2339,6 +2339,12 @@ plugin->exec_command (plugin, "freenode", "#weechat", "hello");
away
"away" flag
+
+ inactivity
+
+ number of seconds since last key was pressed
+
+
weechat_dir
@@ -2379,6 +2385,16 @@ plugin->exec_command (plugin, "freenode", "#weechat", "hello");
char *version = plugin->get_info (plugin, "version", NULL);
char *nick = plugin->get_info (plugin, "nick", "freenode");
+char *inactivity = plugin->get_info (plugin, "inactivity", NULL);
+
+plugin->print (plugin, NULL, NULL,
+ "WeeChat version %s, you are %s on freenode "
+ "(inactive for %s seconds)",
+ version, nick, inactivity);
+
+free (version);
+free (nick);
+free (inactivity);
diff --git a/weechat/doc/fr/weechat.fr.xml b/weechat/doc/fr/weechat.fr.xml
index 40f728cd6..3fccda1d4 100644
--- a/weechat/doc/fr/weechat.fr.xml
+++ b/weechat/doc/fr/weechat.fr.xml
@@ -2387,6 +2387,13 @@ plugin->exec_command (plugin, "freenode", "#weechat", "bonjour");
away
drapeau "away"
+
+ inactivity
+
+ nombre de secondes écoulées depuis que la dernière
+ touche a été appuyée
+
+
weechat_dir
@@ -2427,6 +2434,16 @@ plugin->exec_command (plugin, "freenode", "#weechat", "bonjour");
char *version = plugin->get_info (plugin, "version", NULL);
char *nick = plugin->get_info (plugin, "nick", "freenode");
+char *inactivity = plugin->get_info (plugin, "inactivity", NULL);
+
+plugin->print (plugin, NULL, NULL,
+ "WeeChat version %s, vous êtes %s sur freenode "
+ "(inactif depuis %s secondes)",
+ version, nick, inactivity);
+
+free (version);
+free (nick);
+free (inactivity);
diff --git a/weechat/src/gui/curses/gui-input.c b/weechat/src/gui/curses/gui-input.c
index 47356e505..225058c25 100644
--- a/weechat/src/gui/curses/gui-input.c
+++ b/weechat/src/gui/curses/gui-input.c
@@ -209,6 +209,8 @@ gui_input_read ()
gui_refresh_screen ();
continue;
}
+
+ gui_last_activity_time = time (NULL);
if (key < 32)
{
@@ -319,6 +321,7 @@ gui_main_loop ()
quit_weechat = 0;
new_time = time (NULL);
+ gui_last_activity_time = new_time;
local_time = localtime (&new_time);
old_day = local_time->tm_mday;
diff --git a/weechat/src/gui/gui-common.c b/weechat/src/gui/gui-common.c
index 46a524000..f4ac39148 100644
--- a/weechat/src/gui/gui-common.c
+++ b/weechat/src/gui/gui-common.c
@@ -65,6 +65,9 @@ t_gui_infobar *gui_infobar; /* pointer to infobar content */
char *gui_input_clipboard = NULL; /* clipboard content */
+time_t gui_last_activity_time = 0; /* last activity time */
+ /* (key pressed) */
+
/*
* gui_window_tree_init: create first entry in windows tree
diff --git a/weechat/src/gui/gui.h b/weechat/src/gui/gui.h
index 37001239b..2c93b48f1 100644
--- a/weechat/src/gui/gui.h
+++ b/weechat/src/gui/gui.h
@@ -400,6 +400,7 @@ extern char gui_key_buffer[128];
extern int gui_key_grab;
extern int gui_key_grab_count;
extern char *gui_input_clipboard;
+extern time_t gui_last_activity_time;
extern t_gui_color *gui_color[NUM_COLORS];
diff --git a/weechat/src/plugins/plugins-interface.c b/weechat/src/plugins/plugins-interface.c
index ab2d677bc..069e1b4f2 100644
--- a/weechat/src/plugins/plugins-interface.c
+++ b/weechat/src/plugins/plugins-interface.c
@@ -384,6 +384,8 @@ weechat_plugin_get_info (t_weechat_plugin *plugin, char *info, char *server)
{
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
+ time_t inactivity;
+ char *inactivity_str;
if (!plugin || !info)
return NULL;
@@ -412,6 +414,18 @@ weechat_plugin_get_info (t_weechat_plugin *plugin, char *info, char *server)
{
return strdup (WEECHAT_SHAREDIR);
}
+ else if (ascii_strcasecmp (info, "inactivity") == 0)
+ {
+ if (gui_last_activity_time == 0)
+ inactivity = 0;
+ else
+ inactivity = time (NULL) - gui_last_activity_time;
+ inactivity_str = (char *) malloc (128);
+ if (!inactivity_str)
+ return NULL;
+ snprintf (inactivity_str, 128, "%ld", inactivity);
+ return inactivity_str;
+ }
/* below are infos that need server to return value */