finch/gntlog.c

Thu, 26 Mar 2020 21:17:25 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 26 Mar 2020 21:17:25 -0500
changeset 40318
eb8436c3aae5
parent 39901
253056947264
child 40359
ca141ea93b83
permissions
-rw-r--r--

Fix some compile errors

39887
9c8f874c74a0 Clean up all of the license headers
Gary Kramlich <grim@reaperworld.com>
parents: 39824
diff changeset
1 /*
9c8f874c74a0 Clean up all of the license headers
Gary Kramlich <grim@reaperworld.com>
parents: 39824
diff changeset
2 * finch
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
3 *
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
4 * Finch is the legal property of its developers, whose names are too numerous
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
6 * source distribution.
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
7 *
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
12 *
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
17 *
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
21 */
39887
9c8f874c74a0 Clean up all of the license headers
Gary Kramlich <grim@reaperworld.com>
parents: 39824
diff changeset
22
29106
51c7b2177e42 Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents: 27829
diff changeset
23 #include <internal.h>
22808
90e87c8db26b Include finch.h instead of internal.h
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22491
diff changeset
24 #include "finch.h"
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
25
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
26 #include <gnt.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
27 #include <gntbox.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
28 #include <gntbutton.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
29 #include <gntentry.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
30 #include <gntlabel.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
31 #include <gnttextview.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
32 #include <gnttree.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
33 #include <gntwindow.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
34
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
35 #include "account.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
36 #include "debug.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
37 #include "log.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
38 #include "notify.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
39 #include "request.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
40 #include "util.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
41
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
42 #include "gntlog.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
43
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
44 static GHashTable *log_viewers = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
45 static void populate_log_tree(FinchLogViewer *lv);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
46 static FinchLogViewer *syslog_viewer = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
47
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38620
diff changeset
48 struct log_viewer_hash {
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
49 PurpleLogType type;
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
50 char *username;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
51 PurpleAccount *account;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
52 PurpleContact *contact;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
53 };
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
54
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
55 static guint log_viewer_hash(gconstpointer data)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
56 {
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38620
diff changeset
57 const struct log_viewer_hash *viewer = data;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
58
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
59 if (viewer->contact != NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
60 return g_direct_hash(viewer->contact);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
61
23431
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
62 if (viewer->account) {
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
63 return g_str_hash(viewer->username) +
23431
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
64 g_str_hash(purple_account_get_username(viewer->account));
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
65 }
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
66
26528
3820f77c89fa Fix Finch warnings when building on 64-bit
Paul Aurich <darkrain42@pidgin.im>
parents: 25889
diff changeset
67 return g_direct_hash(viewer);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
68 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
69
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
70 static gboolean log_viewer_equal(gconstpointer y, gconstpointer z)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
71 {
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38620
diff changeset
72 const struct log_viewer_hash *a, *b;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
73 int ret;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
74 char *normal;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
75
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
76 a = y;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
77 b = z;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
78
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
79 if (a->contact != NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
80 if (b->contact != NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
81 return (a->contact == b->contact);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
82 else
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
83 return FALSE;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
84 } else {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
85 if (b->contact != NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
86 return FALSE;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
87 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
88
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
89 if (a->username && b->username) {
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
90 normal = g_strdup(purple_normalize(a->account, a->username));
23431
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
91 ret = (a->account == b->account) &&
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 33777
diff changeset
92 purple_strequal(normal, purple_normalize(b->account, b->username));
23431
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
93 g_free(normal);
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
94 } else {
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
95 ret = (a == b);
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
96 }
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
97
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
98 return ret;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
99 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
100
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
101 static gchar *log_get_date(PurpleLog *log)
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
102 {
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
103 GDateTime *dt;
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
104 gchar *ret;
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
105 dt = g_date_time_to_local(log->time);
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
106 ret = g_date_time_format(dt, "%c");
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
107 g_date_time_unref(dt);
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
108 return ret;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
109 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
110
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
111 static void search_cb(GntWidget *button, FinchLogViewer *lv)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
112 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
113 const char *search_term = gnt_entry_get_text(GNT_ENTRY(lv->entry));
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
114 GList *logs;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
115
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
116 if (!(*search_term)) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
117 /* reset the tree */
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
118 gnt_tree_remove_all(GNT_TREE(lv->tree));
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
119 g_free(lv->search);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
120 lv->search = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
121 populate_log_tree(lv);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
122 return;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
123 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
124
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 33777
diff changeset
125 if (lv->search != NULL && purple_strequal(lv->search, search_term)) {
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
126 return;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
127 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
128
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
129 g_free(lv->search);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
130 lv->search = g_strdup(search_term);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
131
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
132 gnt_tree_remove_all(GNT_TREE(lv->tree));
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
133 gnt_text_view_clear(GNT_TEXT_VIEW(lv->text));
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
134
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
135 for (logs = lv->logs; logs != NULL; logs = logs->next) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
136 char *read = purple_log_read((PurpleLog*)logs->data, NULL);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
137 if (read && *read && purple_strcasestr(read, search_term)) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
138 PurpleLog *log = logs->data;
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
139 gchar *log_date = log_get_date(log);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
140
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
141 gnt_tree_add_row_last(GNT_TREE(lv->tree),
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
142 log,
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
143 gnt_tree_create_row(GNT_TREE(lv->tree), log_date),
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
144 NULL);
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
145 g_free(log_date);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
146 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
147 g_free(read);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
148 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
149
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
150 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
151
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38620
diff changeset
152 static void
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38620
diff changeset
153 destroy_cb(GntWidget *w, struct log_viewer_hash *ht)
22938
dc1dac52d4ff Always top-align the logs in the log-viewer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22808
diff changeset
154 {
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
155 FinchLogViewer *lv = syslog_viewer;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
156
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
157 if (ht != NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
158 lv = g_hash_table_lookup(log_viewers, ht);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
159 g_hash_table_remove(log_viewers, ht);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
160
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
161 g_free(ht->username);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
162 g_free(ht);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
163 } else
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
164 syslog_viewer = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
165
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
166 purple_request_close_with_handle(lv);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
167
39897
16b440d4ab36 Use g_list_free_full instead of g_list_foreach+g_list_free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39887
diff changeset
168 g_list_free_full(lv->logs, (GDestroyNotify)purple_log_free);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
169
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
170 g_free(lv->search);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
171 g_free(lv);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
172
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
173 gnt_widget_destroy(w);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
174 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
175
22938
dc1dac52d4ff Always top-align the logs in the log-viewer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22808
diff changeset
176 static void log_select_cb(GntWidget *w, gpointer old, gpointer new, FinchLogViewer *viewer)
dc1dac52d4ff Always top-align the logs in the log-viewer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22808
diff changeset
177 {
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
178 GntTree *tree = GNT_TREE(w);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
179 PurpleLog *log = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
180 PurpleLogReadFlags flags;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
181 char *read = NULL, *strip, *newline;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
182
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
183 if (!viewer->search && !gnt_tree_get_parent_key(tree, new))
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
184 return;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
185
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
186 log = (PurpleLog *)new;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
187
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
188 if (log == NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
189 return;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
190
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
191 if (log->type != PURPLE_LOG_SYSTEM) {
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
192 gchar *log_date = log_get_date(log);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
193 char *title;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
194 if (log->type == PURPLE_LOG_CHAT)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
195 title = g_strdup_printf(_("Conversation in %s on %s"),
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
196 log->name, log_date);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
197 else
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
198 title = g_strdup_printf(_("Conversation with %s on %s"),
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
199 log->name, log_date);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
200
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
201 gnt_label_set_text(GNT_LABEL(viewer->label), title);
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
202 g_free(log_date);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
203 g_free(title);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
204 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
205
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
206 read = purple_log_read(log, &flags);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
207 if (flags != PURPLE_LOG_READ_NO_NEWLINE) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
208 newline = purple_strdup_withhtml(read);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
209 strip = purple_markup_strip_html(newline);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
210 g_free(newline);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
211 } else {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
212 strip = purple_markup_strip_html(read);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
213 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
214 viewer->flags = flags;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
215
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
216 purple_signal_emit(finch_log_get_handle(), "log-displaying", viewer, log);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
217
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
218 gnt_text_view_clear(GNT_TEXT_VIEW(viewer->text));
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
219 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(viewer->text), strip, GNT_TEXT_FLAG_NORMAL);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
220 g_free(read);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
221 g_free(strip);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
222 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
223
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
224 /* I want to make this smarter, but haven't come up with a cool algorithm to do so, yet.
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
225 * I want the tree to be divided into groups like "Today," "Yesterday," "Last week,"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
226 * "August," "2002," etc. based on how many conversation took place in each subdivision.
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
227 *
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
228 * For now, I'll just make it a flat list.
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
229 */
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
230 static void populate_log_tree(FinchLogViewer *lv)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
231 /* Logs are made from trees in real life.
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
232 This is a tree made from logs */
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
233 {
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
234 gchar *pmonth;
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
235 gchar *month = NULL;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
236 char prev_top_month[30] = "";
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
237 GList *logs = lv->logs;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
238
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
239 while (logs != NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
240 PurpleLog *log = logs->data;
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
241 GDateTime *dt;
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
242 gchar *log_date;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
243
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
244 dt = g_date_time_to_local(log->time);
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
245 pmonth = g_date_time_format(dt, _("%B %Y"));
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
246
38259
c593fc9f5438 Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
247 if (!purple_strequal(pmonth, prev_top_month)) {
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
248 month = g_strdup(pmonth);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
249 /* top level */
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
250 gnt_tree_add_row_last(GNT_TREE(lv->tree),
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
251 month,
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
252 gnt_tree_create_row(GNT_TREE(lv->tree), month),
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
253 NULL);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
254 gnt_tree_set_expanded(GNT_TREE(lv->tree), month, FALSE);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
255
33777
bd4fb691871f Fix compile error from 0d4e3eb3b383
Mark Doliner <mark@kingant.net>
parents: 33776
diff changeset
256 g_strlcpy(prev_top_month, month, sizeof(prev_top_month));
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
257 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
258
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
259 /* sub */
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
260 log_date = g_date_time_format(dt, "%c");
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
261 gnt_tree_add_row_last(GNT_TREE(lv->tree),
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
262 log,
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
263 gnt_tree_create_row(GNT_TREE(lv->tree), log_date),
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
264 month);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
265
38620
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
266 g_free(log_date);
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
267 g_free(pmonth);
b02941b9fa9a Change purple_log_new to use GDateTime.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
268 g_date_time_unref(dt);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
269 logs = logs->next;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
270 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
271 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
272
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38620
diff changeset
273 static FinchLogViewer *
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38620
diff changeset
274 display_log_viewer(struct log_viewer_hash *ht, GList *logs, const char *title,
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38620
diff changeset
275 int log_size)
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
276 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
277 FinchLogViewer *lv;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
278 char *text;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
279 GntWidget *vbox, *hbox;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
280 GntWidget *size_label;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
281
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
282 if (logs == NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
283 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
284 /* No logs were found. */
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
285 const char *log_preferences = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
286
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
287 if (ht == NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
288 if (!purple_prefs_get_bool("/purple/logging/log_system"))
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
289 log_preferences = _("System events will only be logged if the \"Log all status changes to system log\" preference is enabled.");
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
290 } else {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
291 if (ht->type == PURPLE_LOG_IM) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
292 if (!purple_prefs_get_bool("/purple/logging/log_ims"))
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
293 log_preferences = _("Instant messages will only be logged if the \"Log all instant messages\" preference is enabled.");
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
294 } else if (ht->type == PURPLE_LOG_CHAT) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
295 if (!purple_prefs_get_bool("/purple/logging/log_chats"))
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
296 log_preferences = _("Chats will only be logged if the \"Log all chats\" preference is enabled.");
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
297 }
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
298 g_free(ht->username);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
299 g_free(ht);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
300 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
301
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 33777
diff changeset
302 purple_notify_info(NULL, title, _("No logs were found"), log_preferences, NULL);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
303 return NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
304 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
305
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
306 lv = g_new0(FinchLogViewer, 1);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
307 lv->logs = logs;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
308
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
309 if (ht != NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
310 g_hash_table_insert(log_viewers, ht, lv);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
311
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
312 /* Window ***********/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
313 lv->window = gnt_vwindow_new(FALSE);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
314 gnt_box_set_title(GNT_BOX(lv->window), title);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
315 gnt_box_set_toplevel(GNT_BOX(lv->window), TRUE);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
316 gnt_box_set_pad(GNT_BOX(lv->window), 0);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
317 g_signal_connect(G_OBJECT(lv->window), "destroy", G_CALLBACK(destroy_cb), ht);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
318
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
319 vbox = gnt_vbox_new(FALSE);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
320 gnt_box_add_widget(GNT_BOX(lv->window), vbox);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
321
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
322 /* Label ************/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
323 text = g_strdup_printf("%s", title);
23152
b720e4052b1c Show the title text in bold.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22938
diff changeset
324 lv->label = gnt_label_new_with_format(text, GNT_TEXT_FLAG_BOLD);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
325 g_free(text);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
326 gnt_box_add_widget(GNT_BOX(vbox), lv->label);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
327
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
328 hbox = gnt_hbox_new(FALSE);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
329 gnt_box_add_widget(GNT_BOX(vbox), hbox);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
330 /* List *************/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
331 lv->tree = gnt_tree_new();
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
332 gnt_widget_set_size(lv->tree, 30, 0);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
333 populate_log_tree(lv);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
334 g_signal_connect (G_OBJECT(lv->tree), "selection-changed",
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
335 G_CALLBACK (log_select_cb),
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
336 lv);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
337 gnt_box_add_widget(GNT_BOX(hbox), lv->tree);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
338
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
339 /* Viewer ************/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
340 lv->text = gnt_text_view_new();
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
341 gnt_box_add_widget(GNT_BOX(hbox), lv->text);
22938
dc1dac52d4ff Always top-align the logs in the log-viewer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22808
diff changeset
342 gnt_text_view_set_flag(GNT_TEXT_VIEW(lv->text), GNT_TEXT_VIEW_TOP_ALIGN);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
343
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
344 hbox = gnt_hbox_new(FALSE);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
345 gnt_box_add_widget(GNT_BOX(vbox), hbox);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
346 /* Log size ************/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
347 if (log_size) {
39824
aefdb7ab2475 Replace purple_str_size_to_units by g_format_size.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39660
diff changeset
348 char *sz_txt = g_format_size(log_size);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
349 text = g_strdup_printf("%s %s", _("Total log size:"), sz_txt);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
350 size_label = gnt_label_new(text);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
351 gnt_box_add_widget(GNT_BOX(hbox), size_label);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
352 g_free(sz_txt);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
353 g_free(text);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
354 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
355
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
356 /* Search box **********/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
357 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Scroll/Search: ")));
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
358 lv->entry = gnt_entry_new("");
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
359 gnt_box_add_widget(GNT_BOX(hbox), lv->entry);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
360 g_signal_connect(GNT_ENTRY(lv->entry), "activate", G_CALLBACK(search_cb), lv);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
361
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
362 gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(lv->text), lv->entry);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
363 gnt_text_view_attach_pager_widget(GNT_TEXT_VIEW(lv->text), lv->entry);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
364
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
365 gnt_widget_show(lv->window);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
366
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
367 return lv;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
368 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
369
23431
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
370 static void
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
371 our_logging_blows(PurpleLogSet *set, PurpleLogSet *setagain, GList **list)
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
372 {
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
373 /* The iteration happens on the first list. So we use the shorter list in front */
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
374 if (set->type != PURPLE_LOG_IM)
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
375 return;
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
376 *list = g_list_concat(purple_log_get_logs(PURPLE_LOG_IM, set->name, set->account), *list);
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
377 }
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
378
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
379 void finch_log_show(PurpleLogType type, const char *username, PurpleAccount *account)
23431
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
380 {
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38620
diff changeset
381 struct log_viewer_hash *ht;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
382 FinchLogViewer *lv = NULL;
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
383 const char *name = username;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
384 char *title;
23431
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
385 GList *logs = NULL;
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
386 int size = 0;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
387
23431
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
388 if (type != PURPLE_LOG_IM) {
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
389 g_return_if_fail(account != NULL);
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
390 g_return_if_fail(username != NULL);
23431
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
391 }
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
392
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38620
diff changeset
393 ht = g_new0(struct log_viewer_hash, 1);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
394
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
395 ht->type = type;
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
396 ht->username = g_strdup(username);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
397 ht->account = account;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
398
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
399 if (log_viewers == NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
400 log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
401 } else if ((lv = g_hash_table_lookup(log_viewers, ht))) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
402 gnt_window_present(lv->window);
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
403 g_free(ht->username);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
404 g_free(ht);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
405 return;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
406 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
407
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
408 if (type == PURPLE_LOG_CHAT) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
409 PurpleChat *chat;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
410
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
411 chat = purple_blist_find_chat(account, username);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
412 if (chat != NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
413 name = purple_chat_get_name(chat);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
414
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
415 title = g_strdup_printf(_("Conversations in %s"), name);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
416 } else {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
417 PurpleBuddy *buddy;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
418
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
419 if (username) {
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34699
diff changeset
420 buddy = purple_blist_find_buddy(account, username);
23431
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
421 if (buddy != NULL)
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
422 name = purple_buddy_get_contact_alias(buddy);
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
423 title = g_strdup_printf(_("Conversations with %s"), name);
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
424 } else {
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
425 title = g_strdup(_("All Conversations"));
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
426 }
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
427 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
428
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
429 if (username) {
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
430 logs = purple_log_get_logs(type, username, account);
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
431 size = purple_log_get_total_size(type, username, account);
23431
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
432 } else {
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
433 /* This will happen only for IMs */
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
434 GHashTable *table = purple_log_get_log_sets();
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
435 g_hash_table_foreach(table, (GHFunc)our_logging_blows, &logs);
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
436 g_hash_table_destroy(table);
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
437 logs = g_list_sort(logs, purple_log_compare);
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
438 size = 0;
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
439 }
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
440
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
441 display_log_viewer(ht, logs, title, size);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
442
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
443 g_free(title);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
444 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
445
23431
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
446 void finch_log_show_contact(PurpleContact *contact)
c50538da03fd Added "View All Logs" menu in the buddylist to display a list of all IM
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23152
diff changeset
447 {
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38620
diff changeset
448 struct log_viewer_hash *ht;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
449 PurpleBlistNode *child;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
450 FinchLogViewer *lv = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
451 GList *logs = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
452 const char *name = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
453 char *title;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
454 int total_log_size = 0;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
455
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
456 g_return_if_fail(contact != NULL);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
457
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38620
diff changeset
458 ht = g_new0(struct log_viewer_hash, 1);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
459 ht->type = PURPLE_LOG_IM;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
460 ht->contact = contact;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
461
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
462 if (log_viewers == NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
463 log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
464 } else if ((lv = g_hash_table_lookup(log_viewers, ht))) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
465 gnt_window_present(lv->window);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
466 g_free(ht);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
467 return;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
468 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
469
22491
06d2ee82aa58 Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents: 22376
diff changeset
470 for (child = purple_blist_node_get_first_child((PurpleBlistNode*)contact); child;
06d2ee82aa58 Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents: 22376
diff changeset
471 child = purple_blist_node_get_sibling_next(child)) {
24951
d0837696fd3a Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23431
diff changeset
472 const char *name;
d0837696fd3a Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23431
diff changeset
473 PurpleAccount *account;
34696
6e0d13978666 Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents: 33777
diff changeset
474 if (!PURPLE_IS_BUDDY(child))
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
475 continue;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
476
24951
d0837696fd3a Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23431
diff changeset
477 name = purple_buddy_get_name((PurpleBuddy *)child);
d0837696fd3a Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23431
diff changeset
478 account = purple_buddy_get_account((PurpleBuddy *)child);
d0837696fd3a Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23431
diff changeset
479 logs = g_list_concat(purple_log_get_logs(PURPLE_LOG_IM, name,
d0837696fd3a Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23431
diff changeset
480 account), logs);
d0837696fd3a Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23431
diff changeset
481 total_log_size += purple_log_get_total_size(PURPLE_LOG_IM, name, account);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
482 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
483 logs = g_list_sort(logs, purple_log_compare);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
484
22491
06d2ee82aa58 Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents: 22376
diff changeset
485 name = purple_contact_get_alias(contact);
06d2ee82aa58 Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents: 22376
diff changeset
486 if (!name)
06d2ee82aa58 Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents: 22376
diff changeset
487 name = purple_buddy_get_contact_alias(purple_contact_get_priority_buddy(contact));
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
488
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
489 /* This will happen if the contact doesn't have an alias,
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
490 * and none of the contact's buddies are online.
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
491 * There is probably a better way to deal with this. */
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
492 if (name == NULL) {
22491
06d2ee82aa58 Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents: 22376
diff changeset
493 child = purple_blist_node_get_first_child((PurpleBlistNode*)contact);
39901
253056947264 finch: Remove redundant checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39897
diff changeset
494 if (PURPLE_IS_BUDDY(child)) {
22491
06d2ee82aa58 Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents: 22376
diff changeset
495 name = purple_buddy_get_contact_alias((PurpleBuddy *)child);
39901
253056947264 finch: Remove redundant checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39897
diff changeset
496 }
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
497 if (name == NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
498 name = "";
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
499 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
500
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
501 title = g_strdup_printf(_("Conversations with %s"), name);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
502 display_log_viewer(ht, logs, title, total_log_size);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
503 g_free(title);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
504 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
505
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
506 void finch_syslog_show()
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
507 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
508 GList *accounts = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
509 GList *logs = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
510
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
511 if (syslog_viewer != NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
512 gnt_window_present(syslog_viewer->window);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
513 return;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
514 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
515
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
516 for(accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
517
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
518 PurpleAccount *account = (PurpleAccount *)accounts->data;
36626
18fc361b3704 Renamed purple_find_protocol_info to purple_protocols_find
Ankit Vani <a@nevitus.org>
parents: 36361
diff changeset
519 if(purple_protocols_find(purple_account_get_protocol_id(account)) == NULL)
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
520 continue;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
521
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
522 logs = g_list_concat(purple_log_get_system_logs(account), logs);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
523 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
524 logs = g_list_sort(logs, purple_log_compare);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
525
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
526 syslog_viewer = display_log_viewer(NULL, logs, _("System Log"), 0);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
527 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
528
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
529 /****************************************************************************
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
530 * GNT LOG SUBSYSTEM *******************************************************
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
531 ****************************************************************************/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
532
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
533 void *
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
534 finch_log_get_handle(void)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
535 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
536 static int handle;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
537
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
538 return &handle;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
539 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
540
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
541 void finch_log_init(void)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
542 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
543 void *handle = finch_log_get_handle();
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
544
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
545 purple_signal_register(handle, "log-displaying",
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
546 purple_marshal_VOID__POINTER_POINTER,
34826
aabc888fd461 Refactored finch to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
547 G_TYPE_NONE, 2,
aabc888fd461 Refactored finch to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
548 G_TYPE_POINTER, /* (FinchLogViewer *) */
aabc888fd461 Refactored finch to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
549 PURPLE_TYPE_LOG);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
550 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
551
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
552 void
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
553 finch_log_uninit(void)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
554 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
555 purple_signals_unregister_by_instance(finch_log_get_handle());
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
556 }

mercurial