finch/gntlog.c

Wed, 13 May 2009 20:29:03 +0000

author
Marcus Lundblad <malu@pidgin.im>
date
Wed, 13 May 2009 20:29:03 +0000
changeset 27110
05ca719b901b
parent 26528
3820f77c89fa
child 27829
94b279f7c38c
permissions
-rw-r--r--

Support custom smileys in MUCs (when all participants support BoB and a maximum
of 10 participants are in the chat).
Always announce support for BoB, since disable custom smileys will still turn
off fetching them, and BoB can be used for other purposes further on.

22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
1 /**
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
2 * @file gntlog.c GNT Log viewer
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
3 * @ingroup finch
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
4 */
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
5
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
6 /* finch
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 * 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
9 * 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
10 * source distribution.
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
11 *
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
12 * 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
13 * 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
14 * 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
15 * (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
16 *
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
17 * 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
18 * 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
19 * 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
20 * 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
21 *
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
22 * 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
23 * 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
24 * 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
25 */
22808
90e87c8db26b Include finch.h instead of internal.h
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22491
diff changeset
26 #include "finch.h"
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
27
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
28 #include <gnt.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
29 #include <gntbox.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
30 #include <gntbutton.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
31 #include <gntentry.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
32 #include <gntlabel.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
33 #include <gnttextview.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
34 #include <gnttree.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
35 #include <gntwindow.h>
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
36
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
37 #include "account.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
38 #include "debug.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
39 #include "log.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
40 #include "notify.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
41 #include "request.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
42 #include "util.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 #include "gntlog.h"
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
45
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
46 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
47 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
48 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
49
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
50 struct log_viewer_hash_t {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
51 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
52 char *username;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
53 PurpleAccount *account;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
54 PurpleContact *contact;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
55 };
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
56
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
57 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
58 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
59 const struct log_viewer_hash_t *viewer = data;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
60
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
61 if (viewer->contact != NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
62 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
63
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 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
65 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
66 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
67 }
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
68
26528
3820f77c89fa Fix Finch warnings when building on 64-bit
Paul Aurich <darkrain42@pidgin.im>
parents: 25889
diff changeset
69 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
70 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
71
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
72 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
73 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
74 const struct log_viewer_hash_t *a, *b;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
75 int ret;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
76 char *normal;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
77
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
78 a = y;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
79 b = z;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
80
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
81 if (a->contact != NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
82 if (b->contact != NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
83 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
84 else
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
85 return FALSE;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
86 } else {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
87 if (b->contact != NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
88 return FALSE;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
89 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
90
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
91 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
92 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
93 ret = (a->account == b->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
94 !strcmp(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
95 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
96 } 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
97 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
98 }
22376
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 return ret;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
101 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
102
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
103 static const char *log_get_date(PurpleLog *log)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
104 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
105 if (log->tm)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
106 return purple_date_format_full(log->tm);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
107 else
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
108 return purple_date_format_full(localtime(&log->time));
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
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
125 if (lv->search != NULL && !strcmp(lv->search, search_term)) {
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;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
139
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
140 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
141 log,
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
142 gnt_tree_create_row(GNT_TREE(lv->tree), log_get_date(log)),
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
143 NULL);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
144 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
145 g_free(read);
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
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
22938
dc1dac52d4ff Always top-align the logs in the log-viewer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22808
diff changeset
150 static void destroy_cb(GntWidget *w, struct log_viewer_hash_t *ht)
dc1dac52d4ff Always top-align the logs in the log-viewer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22808
diff changeset
151 {
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
152 FinchLogViewer *lv = syslog_viewer;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
153
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
154 if (ht != NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
155 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
156 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
157
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
158 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
159 g_free(ht);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
160 } else
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
161 syslog_viewer = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
162
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
163 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
164
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
165 g_list_foreach(lv->logs, (GFunc)purple_log_free, NULL);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
166 g_list_free(lv->logs);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
167
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
168 g_free(lv->search);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
169 g_free(lv);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
170
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
171 gnt_widget_destroy(w);
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
22938
dc1dac52d4ff Always top-align the logs in the log-viewer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22808
diff changeset
174 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
175 {
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
176 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
177 PurpleLog *log = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
178 PurpleLogReadFlags flags;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
179 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
180
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
181 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
182 return;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
183
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
184 log = (PurpleLog *)new;
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 if (log == NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
187 return;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
188
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
189 if (log->type != PURPLE_LOG_SYSTEM) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
190 char *title;
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_CHAT)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
192 title = g_strdup_printf(_("Conversation in %s on %s"),
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
193 log->name, log_get_date(log));
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
194 else
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 with %s on %s"),
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
196 log->name, log_get_date(log));
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
197
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
198 gnt_label_set_text(GNT_LABEL(viewer->label), title);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
199 g_free(title);
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
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
202 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
203 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
204 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
205 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
206 g_free(newline);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
207 } else {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
208 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
209 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
210 viewer->flags = flags;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
211
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
212 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
213
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
214 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
215 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
216 g_free(read);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
217 g_free(strip);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
218 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
219
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
220 /* 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
221 * 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
222 * "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
223 *
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
224 * 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
225 */
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
226 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
227 /* 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
228 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
229 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
230 const char *pmonth;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
231 char *month = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
232 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
233 GList *logs = lv->logs;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
234
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
235 while (logs != NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
236 PurpleLog *log = logs->data;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
237
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
238 pmonth = purple_utf8_strftime(_("%B %Y"),
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
239 log->tm ? log->tm : localtime(&log->time));
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
240
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
241 if (strcmp(pmonth, prev_top_month) != 0) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
242 month = g_strdup(pmonth);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
243 /* top level */
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
244 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
245 month,
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
246 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
247 NULL);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
248 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
249
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
250 strncpy(prev_top_month, month, sizeof(prev_top_month));
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
251 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
252
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
253 /* sub */
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
254 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
255 log,
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
256 gnt_tree_create_row(GNT_TREE(lv->tree), log_get_date(log)),
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
257 month);
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 logs = logs->next;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
260 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
261 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
262
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
263 static FinchLogViewer *display_log_viewer(struct log_viewer_hash_t *ht, GList *logs,
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
264 const char *title, int log_size)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
265 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
266 FinchLogViewer *lv;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
267 char *text;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
268 GntWidget *vbox, *hbox;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
269 GntWidget *size_label;
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 if (logs == NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
272 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
273 /* No logs were found. */
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
274 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
275
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
276 if (ht == NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
277 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
278 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
279 } else {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
280 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
281 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
282 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
283 } 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
284 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
285 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
286 }
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
287 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
288 g_free(ht);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
289 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
290
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
291 purple_notify_info(NULL, title, _("No logs were found"), log_preferences);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
292 return NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
293 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
294
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
295 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
296 lv->logs = logs;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
297
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
298 if (ht != NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
299 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
300
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
301 /* Window ***********/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
302 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
303 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
304 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
305 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
306 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
307
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
308 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
309 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
310
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
311 /* Label ************/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
312 text = g_strdup_printf("%s", title);
23152
b720e4052b1c Show the title text in bold.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22938
diff changeset
313 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
314 g_free(text);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
315 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
316
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
317 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
318 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
319 /* List *************/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
320 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
321 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
322 populate_log_tree(lv);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
323 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
324 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
325 lv);
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(hbox), lv->tree);
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 /* Viewer ************/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
329 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
330 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
331 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
332
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
333 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
334 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
335 /* Log size ************/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
336 if (log_size) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
337 char *sz_txt = purple_str_size_to_units(log_size);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
338 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
339 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
340 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
341 g_free(sz_txt);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
342 g_free(text);
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
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
345 /* Search box **********/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
346 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
347 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
348 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
349 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
350
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
351 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
352 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
353
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
354 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
355
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
356 return lv;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
357 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
358
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
359 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
360 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
361 {
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
362 /* 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
363 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
364 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
365 *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
366 }
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
367
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
368 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
369 {
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
370 struct log_viewer_hash_t *ht;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
371 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
372 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
373 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
374 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
375 int size = 0;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
376
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
377 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
378 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
379 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
380 }
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
381
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
382 ht = g_new0(struct log_viewer_hash_t, 1);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
383
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
384 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
385 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
386 ht->account = account;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
387
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
388 if (log_viewers == NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
389 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
390 } 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
391 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
392 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
393 g_free(ht);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
394 return;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
395 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
396
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
397 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
398 PurpleChat *chat;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
399
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
400 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
401 if (chat != NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
402 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
403
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
404 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
405 } else {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
406 PurpleBuddy *buddy;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
407
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
408 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
409 buddy = purple_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
410 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
411 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
412 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
413 } 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
414 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
415 }
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
416 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
417
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 24951
diff changeset
418 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
419 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
420 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
421 } 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
422 /* 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
423 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
424 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
425 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
426 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
427 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
428 }
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
429
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
430 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
431
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
432 g_free(title);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
433 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
434
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
435 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
436 {
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
437 struct log_viewer_hash_t *ht;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
438 PurpleBlistNode *child;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
439 FinchLogViewer *lv = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
440 GList *logs = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
441 const char *name = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
442 char *title;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
443 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
444
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
445 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
446
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
447 ht = g_new0(struct log_viewer_hash_t, 1);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
448 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
449 ht->contact = contact;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
450
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
451 if (log_viewers == NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
452 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
453 } 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
454 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
455 g_free(ht);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
456 return;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
457 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
458
22491
06d2ee82aa58 Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents: 22376
diff changeset
459 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
460 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
461 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
462 PurpleAccount *account;
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
463 if (!PURPLE_BLIST_NODE_IS_BUDDY(child))
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
464 continue;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
465
24951
d0837696fd3a Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23431
diff changeset
466 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
467 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
468 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
469 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
470 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
471 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
472 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
473
22491
06d2ee82aa58 Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents: 22376
diff changeset
474 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
475 if (!name)
06d2ee82aa58 Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents: 22376
diff changeset
476 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
477
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
478 /* 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
479 * 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
480 * 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
481 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
482 child = purple_blist_node_get_first_child((PurpleBlistNode*)contact);
06d2ee82aa58 Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents: 22376
diff changeset
483 if (child != NULL && PURPLE_BLIST_NODE_IS_BUDDY(child))
06d2ee82aa58 Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents: 22376
diff changeset
484 name = purple_buddy_get_contact_alias((PurpleBuddy *)child);
22376
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
485 if (name == NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
486 name = "";
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
487 }
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 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
490 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
491 g_free(title);
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
492 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
493
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
494 void finch_syslog_show()
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
495 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
496 GList *accounts = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
497 GList *logs = NULL;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
498
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
499 if (syslog_viewer != NULL) {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
500 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
501 return;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
502 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
503
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
504 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
505
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
506 PurpleAccount *account = (PurpleAccount *)accounts->data;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
507 if(purple_find_prpl(purple_account_get_protocol_id(account)) == NULL)
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
508 continue;
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
509
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
510 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
511 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
512 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
513
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
514 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
515 }
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
516
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 * GNT LOG SUBSYSTEM *******************************************************
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
519 ****************************************************************************/
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
520
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
521 void *
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
522 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
523 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
524 static int handle;
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 return &handle;
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 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
530 {
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
531 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
532
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
533 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
534 purple_marshal_VOID__POINTER_POINTER,
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
535 NULL, 2,
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
536 purple_value_new(PURPLE_TYPE_BOXED,
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
537 "FinchLogViewer *"),
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
538 purple_value_new(PURPLE_TYPE_SUBTYPE,
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
539 PURPLE_SUBTYPE_LOG));
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
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
542 void
25a17b6b69c2 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
543 finch_log_uninit(void)
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_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
546 }

mercurial