[ekg2-commit] r3979 - in trunk: ekg plugins/logsqlite: trunk/ekg/themes.c trunk/plugins/logsqlite/logsqlite.c
SVN commit
svn w toxygen.net
Czw, 3 Kwi 2008, 22:09:06 CEST
Author: adamm
Date: 2008-04-03 22:09:05 +0200 (Thu, 03 Apr 2008)
New Revision: 3979
Modified:
trunk/ekg/themes.c
trunk/plugins/logsqlite/logsqlite.c
Log:
- added command logsqlite:laststatus
Modified: trunk/ekg/themes.c
===================================================================
--- trunk/ekg/themes.c 2008-04-03 19:33:54 UTC (rev 3978)
+++ trunk/ekg/themes.c 2008-04-03 20:09:05 UTC (rev 3979)
@@ -1852,16 +1852,26 @@
/* last */
format_add("last_list_in", "%) %Y <<%n [%1] %2 %3\n", 1);
format_add("last_list_out", "%) %G >>%n [%1] %2 %3\n", 1);
+ format_add("last_list_status", "%) %G *%n [%1] %2 is %3\n", 1);
+ format_add("last_list_status_descr", "%) %G *%n [%1] %2 is %3: %4\n", 1);
format_add("last_list_empty", _("%! No messages logged\n"), 1);
+ format_add("last_list_empty_status", _("%! No change status logged\n"), 1);
format_add("last_list_empty_nick", _("%! No messages from %T%1%n logged\n"), 1);
+ format_add("last_list_empty_nick_status", _("%! No change status by %T%1%n logged\n"), 1);
format_add("last_list_timestamp", "%d-%m-%Y %H:%M", 1);
format_add("last_list_timestamp_today", "%H:%M", 1);
format_add("last_clear_uin", _("%) Messages from %T%1%n cleared\n"), 1);
+ format_add("last_clear_uin_status", _("%) Statuses from %T%1%n cleared\n"), 1);
format_add("last_clear", _("%) All messages cleared\n"), 1);
+ format_add("last_clear_status", _("%) All statuses cleared\n"), 1);
format_add("last_begin_uin", _("%) Lastlog from %T%1%n begins\n"), 1);
+ format_add("last_begin_uin_status", _("%) Lastlog status from %T%1%n begins\n"), 1);
format_add("last_begin", _("%) Lastlog begin\n"), 1);
+ format_add("last_begin_status", _("%) Lastlog status begin\n"), 1);
format_add("last_end", _("%) Lastlog end\n"), 1);
+ format_add("last_end_status", _("%) Lastlog status end\n"), 1);
+
/* lastlog */
format_add("lastlog_title", _("%) %gLastlog [%B%2%n%g] from window: %W%T%1%n"), 1);
format_add("lastlog_title_cur", _("%) %gLastlog [%B%2%n%g] from window: %W%T%1 (*)%n"), 1);
Modified: trunk/plugins/logsqlite/logsqlite.c
===================================================================
--- trunk/plugins/logsqlite/logsqlite.c 2008-04-03 19:33:54 UTC (rev 3978)
+++ trunk/plugins/logsqlite/logsqlite.c 2008-04-03 20:09:05 UTC (rev 3979)
@@ -77,7 +77,7 @@
/*
* last log
*/
-COMMAND(logsqlite_cmd_last)
+int last(const char **params, session_t *session, int quiet, int status)
{
sqlite_t * db;
char buf[100];
@@ -113,7 +113,6 @@
}
}
-
for (i = 0; params[i]; i++) {
if (match_arg(params[i], 'n', "number", 2) && params[i + 1]) {
@@ -153,21 +152,37 @@
target_window = gotten_uid;
#ifdef HAVE_SQLITE3
- sqlite3_prepare(db, "SELECT * FROM (SELECT uid, nick, ts, body, sent FROM log_msg WHERE uid = ?1 AND body LIKE ?3 ORDER BY ts DESC LIMIT ?2) ORDER BY ts ASC", -1, &stmt, NULL);
+ if (!status)
+ sqlite3_prepare(db, "SELECT * FROM (SELECT uid, nick, ts, body, sent FROM log_msg WHERE uid = ?1 AND body LIKE ?3 ORDER BY ts DESC LIMIT ?2) ORDER BY ts ASC", -1, &stmt, NULL);
+ else
+ sqlite3_prepare(db, "SELECT * FROM (SELECT uid, nick, ts, status, desc FROM log_status WHERE uid = ?1 AND desc LIKE ?3 ORDER BY ts DESC LIMIT ?2) ORDER BY ts ASC", -1, &stmt, NULL);
+
sqlite3_bind_text(stmt, 1, gotten_uid, -1, SQLITE_STATIC);
sqlite3_bind_text(stmt, 3, sql_search, -1, SQLITE_STATIC);
#else
- sql = sqlite_mprintf("SELECT * FROM (SELECT uid, nick, ts, body, sent FROM log_msg WHERE uid = '%q' AND body LIKE '%%%q%%' ORDER BY ts DESC LIMIT %i) ORDER BY ts ASC", gotten_uid, sql_search, limit);
+ if(!status)
+ sql = sqlite_mprintf("SELECT * FROM (SELECT uid, nick, ts, body, sent FROM log_msg WHERE uid = '%q' AND body LIKE '%%%q%%' ORDER BY ts DESC LIMIT %i) ORDER BY ts ASC", gotten_uid, sql_search, limit);
+ else
+ sql = sqlite_mprintf("SELECT * FROM (SELECT uid, nick, ts, status, desc FROM log_status WHERE uid = '%q' AND desc LIKE '%%%q%%' ORDER BY ts DESC LIMIT %i) ORDER BY ts ASC", gotten_uid, sql_search, limit);
+
#endif
} else {
if (config_logsqlite_last_in_window)
target_window = "__status";
#ifdef HAVE_SQLITE3
- sqlite3_prepare(db, "SELECT * FROM (SELECT uid, nick, ts, body, sent FROM log_msg WHERE body LIKE ?3 ORDER BY ts DESC LIMIT ?2) ORDER BY ts ASC", -1, &stmt, NULL);
+ if(!status)
+ sqlite3_prepare(db, "SELECT * FROM (SELECT uid, nick, ts, body, sent FROM log_msg WHERE body LIKE ?3 ORDER BY ts DESC LIMIT ?2) ORDER BY ts ASC", -1, &stmt, NULL);
+ else
+ sqlite3_prepare(db, "SELECT * FROM (SELECT uid, nick, ts, status, desc FROM log_status WHERE desc LIKE ?3 ORDER BY ts DESC LIMIT ?2) ORDER BY ts ASC", -1, &stmt, NULL);
+
sqlite3_bind_text(stmt, 3, sql_search, -1, SQLITE_STATIC);
#else
- sql = sqlite_mprintf("SELECT * FROM (SELECT uid, nick, ts, body, sent FROM log_msg WHERE body LIKE '%%%q%%' ORDER BY ts DESC LIMIT %i) ORDER BY ts ASC", sql_search, limit);
+ if(!status)
+ sql = sqlite_mprintf("SELECT * FROM (SELECT uid, nick, ts, body, sent FROM log_msg WHERE body LIKE '%%%q%%' ORDER BY ts DESC LIMIT %i) ORDER BY ts ASC", sql_search, limit);
+ else
+ sql = sqlite_mprintf("SELECT * FROM (SELECT uid, nick, ts, status, desc FROM log_status WHERE desc LIKE '%%%q%%' ORDER BY ts DESC LIMIT %i) ORDER BY ts ASC", sql_search, limit);
+
#endif
}
@@ -182,21 +197,31 @@
#endif
if (count2 == 0) {
if (gotten_uid)
- print_window(target_window, session, config_logsqlite_last_open_window, "last_begin_uin", gotten_uid);
+ if (!status)
+ print_window(target_window, session, config_logsqlite_last_open_window, "last_begin_uin", gotten_uid);
+ else
+ print_window(target_window, session, config_logsqlite_last_open_window, "last_begin_uin_status", gotten_uid);
+
else
- print_window(target_window, session, config_logsqlite_last_open_window, "last_begin");
+ if (!status)
+ print_window(target_window, session, config_logsqlite_last_open_window, "last_begin");
+ else
+ print_window(target_window, session, config_logsqlite_last_open_window, "last_begin_status");
+
}
count2++;
tm = localtime(&ts);
strftime(buf, sizeof(buf), format_find("last_list_timestamp"), tm);
+
+ if(!status) {
#ifdef HAVE_SQLITE3
- if (sqlite3_column_int(stmt, 4) == 0)
+ if (sqlite3_column_int(stmt, 4) == 0)
#else
- if (!xstrcmp(results[4], "0"))
+ if (!xstrcmp(results[4], "0"))
#endif
- last_direction = "last_list_in";
- else
- last_direction = "last_list_out";
+ last_direction = "last_list_in";
+ else
+ last_direction = "last_list_out";
print_window(target_window, session, config_logsqlite_last_open_window, last_direction, buf,
#ifdef HAVE_SQLITE3
@@ -204,15 +229,52 @@
#else
results[1], results[3]);
#endif
+
+ } else {
+ last_direction = "last_list_status";
+#ifdef HAVE_SQLITE3
+ if(xstrlen(sqlite3_column_text(stmt, 4))) {
+#else
+ if(xstrlen(results[4])) {
+#endif
+ last_direction = "last_list_status_descr";
+
+ print_window(target_window, session, config_logsqlite_last_open_window, last_direction, buf,
+#ifdef HAVE_SQLITE3
+ sqlite3_column_text(stmt, 1), sqlite3_column_text(stmt, 3), sqlite3_column_text(stmt, 4));
+#else
+ results[1], results[3], results[4]);
+#endif
+ } else {
+ last_direction = "last_list_status";
+
+ print_window(target_window, session, config_logsqlite_last_open_window, last_direction, buf,
+#ifdef HAVE_SQLITE3
+ sqlite3_column_text(stmt, 1), sqlite3_column_text(stmt, 3));
+#else
+ results[1], results[3]);
+#endif
+
+ }
+ }
}
if (count2 == 0) {
if (nick) {
- print_window(target_window, session, config_logsqlite_last_open_window, "last_list_empty_nick", nick);
+ if (!status)
+ print_window(target_window, session, config_logsqlite_last_open_window, "last_list_empty_nick", nick);
+ else
+ print_window(target_window, session, config_logsqlite_last_open_window, "last_list_empty_nick_status", nick);
} else {
- print_window(target_window, session, config_logsqlite_last_open_window, "last_list_empty");
+ if (!status)
+ print_window(target_window, session, config_logsqlite_last_open_window, "last_list_empty");
+ else
+ print_window(target_window, session, config_logsqlite_last_open_window, "last_list_empty_status");
}
} else {
- print_window(target_window, session, config_logsqlite_last_open_window, "last_end");
+ if (!status)
+ print_window(target_window, session, config_logsqlite_last_open_window, "last_end");
+ else
+ print_window(target_window, session, config_logsqlite_last_open_window, "last_end_status");
}
xfree(keep_nick);
@@ -227,6 +289,16 @@
return 0;
}
+COMMAND(logsqlite_cmd_last)
+{
+ return last(params, session, quiet, 0);
+}
+
+COMMAND(logsqlite_cmd_laststatus)
+{
+ return last(params, session, quiet, 1);
+}
+
COMMAND(logsqlite_cmd_sync)
{
if (logsqlite_current_db && logsqlite_in_transaction)
@@ -765,6 +837,7 @@
logsqlite_setvar_default();
command_add(&logsqlite_plugin, "logsqlite:last", "puU puU puU puU puU", logsqlite_cmd_last, 0, "-n --number -s --search");
+ command_add(&logsqlite_plugin, "logsqlite:laststatus", "puU puU puU puU puU", logsqlite_cmd_laststatus, 0, "-n --number -s --search");
command_add(&logsqlite_plugin, "logsqlite:sync", NULL, logsqlite_cmd_sync, 0, 0);
query_connect_id(&logsqlite_plugin, PROTOCOL_MESSAGE_POST, logsqlite_msg_handler, NULL);
Więcej informacji o liście dyskusyjnej ekg2-commit