diff --git a/data/gui/history_window.ui b/data/gui/history_window.ui
index d6b77b799..515c426d8 100644
--- a/data/gui/history_window.ui
+++ b/data/gui/history_window.ui
@@ -80,6 +80,21 @@
2
+
+
+
+ False
+ False
+ 3
+
+
False
@@ -104,14 +119,17 @@
False
0
+
+
+
False
diff --git a/src/common/logger.py b/src/common/logger.py
index ce2f69f6e..ee7e647f1 100644
--- a/src/common/logger.py
+++ b/src/common/logger.py
@@ -629,7 +629,8 @@ class Logger:
results = self.cur.fetchall()
return results
- def get_search_results_for_query(self, jid, query, account):
+ def get_search_results_for_query(self, jid, query, account, year=False,
+ month=False, day=False):
"""
Returns contact_name, time, kind, show, message
@@ -652,7 +653,19 @@ class Logger:
else: # user just typed something, we search in message column
where_sql, jid_tuple = self._build_contact_where(account, jid)
like_sql = '%' + query.replace("'", "''") + '%'
- self.cur.execute('''
+ if year:
+ start_of_day = self.get_unix_time_from_date(year, month, day)
+ seconds_in_a_day = 86400 # 60 * 60 * 24
+ last_second_of_day = start_of_day + seconds_in_a_day - 1
+ self.cur.execute('''
+ SELECT contact_name, time, kind, show, message, subject FROM logs
+ WHERE (%s) AND message LIKE '%s'
+ AND time BETWEEN %d AND %d
+ ORDER BY time
+ ''' % (where_sql, like_sql, start_of_day, last_second_of_day),
+ jid_tuple)
+ else:
+ self.cur.execute('''
SELECT contact_name, time, kind, show, message, subject FROM logs
WHERE (%s) AND message LIKE '%s'
ORDER BY time
diff --git a/src/history_window.py b/src/history_window.py
index 2b03acd1e..958cae331 100644
--- a/src/history_window.py
+++ b/src/history_window.py
@@ -83,6 +83,7 @@ class HistoryWindow:
self.query_combobox.set_active(0)
self.results_treeview = xml.get_object('results_treeview')
self.results_window = xml.get_object('results_scrolledwindow')
+ self.search_in_date = xml.get_object('search_in_date')
# contact_name, date, message, time
model = gtk.ListStore(str, str, str, str, str)
@@ -511,9 +512,14 @@ class HistoryWindow:
# This may leed to wrong self nick in the displayed history (Uggh!)
account = gajim.contacts.get_accounts()[0]
+ year, month, day = False, False, False
+ if self.search_in_date.get_active():
+ year, month, day = self.calendar.get_date() # integers
+ month = gtkgui_helpers.make_gtk_month_python_month(month)
+
# contact_name, time, kind, show, message, subject
results = gajim.logger.get_search_results_for_query(
- jid, text, account)
+ jid, text, account, year, month, day)
#FIXME:
# add "subject: | message: " in message column if kind is single
# also do we need show at all? (we do not search on subject)