Mon, 12 Sep 2016 08:55:35 -0500
gg: Protect against issues when closing while connecting
Since the GIOStream is cancelled when data is freed, any cancelled
callbacks are called after such data is freed. This patch guards against
cancelled calls by safely returning without accessing any freed data if
the connection has been cancelled (aka closed).
Futhermore, if GG tries to connect and is quickly disconnected,
ggp_tcpsocket_close() is never called. As far as I can tell, it's an
existing bug, but PurpleSockets both work differently when closing and
are closed by the connection if any leak. So the issue wasn't a major
problem. This patch lessens the issue by guarding against it, but it
should be fixed at some point.
|
22376
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
1 | /* finch |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
2 | * |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
3 | * 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
|
4 | * 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
|
5 | * source distribution. |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
6 | * |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
7 | * 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
|
8 | * 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
|
9 | * 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
|
10 | * (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
|
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 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
|
13 | * 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
|
14 | * 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
|
15 | * 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
|
16 | * |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
17 | * 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
|
18 | * 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
|
19 | * 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
|
20 | */ |
|
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
|
21 | #include <internal.h> |
|
22808
90e87c8db26b
Include finch.h instead of internal.h
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22491
diff
changeset
|
22 | #include "finch.h" |
|
22376
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
23 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
24 | #include <gnt.h> |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
25 | #include <gntbox.h> |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
26 | #include <gntbutton.h> |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
27 | #include <gntentry.h> |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
28 | #include <gntlabel.h> |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
29 | #include <gnttextview.h> |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
30 | #include <gnttree.h> |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
31 | #include <gntwindow.h> |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
32 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
33 | #include "account.h" |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
34 | #include "debug.h" |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
35 | #include "log.h" |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
36 | #include "notify.h" |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
37 | #include "request.h" |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
38 | #include "util.h" |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
39 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
40 | #include "gntlog.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 | 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
|
43 | 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
|
44 | 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
|
45 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
46 | 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
|
47 | 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
|
48 | char *username; |
|
22376
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
49 | PurpleAccount *account; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
50 | PurpleContact *contact; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
51 | }; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
52 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
53 | 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
|
54 | { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
55 | 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
|
56 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
57 | if (viewer->contact != NULL) |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
58 | 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
|
59 | |
|
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
|
60 | 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
|
61 | 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
|
62 | 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
|
63 | } |
|
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 | |
|
26528
3820f77c89fa
Fix Finch warnings when building on 64-bit
Paul Aurich <darkrain42@pidgin.im>
parents:
25889
diff
changeset
|
65 | 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
|
66 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
67 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
68 | 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
|
69 | { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
70 | 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
|
71 | int ret; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
72 | char *normal; |
|
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 | a = y; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
75 | b = z; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
76 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
77 | if (a->contact != NULL) { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
78 | if (b->contact != NULL) |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
79 | 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
|
80 | else |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
81 | return FALSE; |
|
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 | if (b->contact != NULL) |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
84 | return FALSE; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
85 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
86 | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
24951
diff
changeset
|
87 | 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
|
88 | 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
|
89 | 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
|
90 | !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
|
91 | 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
|
92 | } 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
|
93 | 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
|
94 | } |
|
22376
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
95 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
96 | return ret; |
|
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 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
99 | 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
|
100 | { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
101 | if (log->tm) |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
102 | 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
|
103 | else |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
104 | 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
|
105 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
106 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
107 | 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
|
108 | { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
109 | 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
|
110 | GList *logs; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
111 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
112 | if (!(*search_term)) { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
113 | /* reset the tree */ |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
114 | 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
|
115 | g_free(lv->search); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
116 | lv->search = NULL; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
117 | populate_log_tree(lv); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
118 | return; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
119 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
120 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
121 | 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
|
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 | g_free(lv->search); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
126 | 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
|
127 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
128 | 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
|
129 | 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
|
130 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
131 | 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
|
132 | 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
|
133 | 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
|
134 | PurpleLog *log = logs->data; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
135 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
136 | 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
|
137 | log, |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
138 | 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
|
139 | NULL); |
|
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 | g_free(read); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
142 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
143 | |
|
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 | |
|
22938
dc1dac52d4ff
Always top-align the logs in the log-viewer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22808
diff
changeset
|
146 | 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
|
147 | { |
|
22376
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
148 | FinchLogViewer *lv = syslog_viewer; |
|
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 | if (ht != NULL) { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
151 | 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
|
152 | 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
|
153 | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
24951
diff
changeset
|
154 | 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
|
155 | g_free(ht); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
156 | } else |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
157 | syslog_viewer = NULL; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
158 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
159 | 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
|
160 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
161 | 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
|
162 | 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
|
163 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
164 | g_free(lv->search); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
165 | g_free(lv); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
166 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
167 | gnt_widget_destroy(w); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
168 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
169 | |
|
22938
dc1dac52d4ff
Always top-align the logs in the log-viewer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22808
diff
changeset
|
170 | 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
|
171 | { |
|
22376
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
172 | 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
|
173 | PurpleLog *log = NULL; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
174 | PurpleLogReadFlags flags; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
175 | 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
|
176 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
177 | 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
|
178 | return; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
179 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
180 | log = (PurpleLog *)new; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
181 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
182 | if (log == NULL) |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
183 | return; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
184 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
185 | 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
|
186 | char *title; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
187 | 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
|
188 | 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
|
189 | 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
|
190 | else |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
191 | 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
|
192 | 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
|
193 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
194 | 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
|
195 | g_free(title); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
196 | } |
|
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 | 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
|
199 | 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
|
200 | 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
|
201 | 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
|
202 | g_free(newline); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
203 | } else { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
204 | 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
|
205 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
206 | viewer->flags = flags; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
207 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
208 | 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
|
209 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
210 | 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
|
211 | 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
|
212 | g_free(read); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
213 | g_free(strip); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
214 | } |
|
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 | /* 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
|
217 | * 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
|
218 | * "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
|
219 | * |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
220 | * 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
|
221 | */ |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
222 | 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
|
223 | /* 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
|
224 | 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
|
225 | { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
226 | const char *pmonth; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
227 | char *month = NULL; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
228 | 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
|
229 | GList *logs = lv->logs; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
230 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
231 | while (logs != NULL) { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
232 | PurpleLog *log = logs->data; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
233 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
234 | 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
|
235 | 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
|
236 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
237 | 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
|
238 | month = g_strdup(pmonth); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
239 | /* top level */ |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
240 | 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
|
241 | month, |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
242 | 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
|
243 | NULL); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
244 | 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
|
245 | |
|
33777
bd4fb691871f
Fix compile error from 0d4e3eb3b383
Mark Doliner <mark@kingant.net>
parents:
33776
diff
changeset
|
246 | 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
|
247 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
248 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
249 | /* sub */ |
|
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 | log, |
|
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), log_get_date(log)), |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
253 | month); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
254 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
255 | logs = logs->next; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
256 | } |
|
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 | 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
|
260 | 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
|
261 | { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
262 | FinchLogViewer *lv; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
263 | char *text; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
264 | GntWidget *vbox, *hbox; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
265 | GntWidget *size_label; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
266 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
267 | if (logs == NULL) |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
268 | { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
269 | /* No logs were found. */ |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
270 | 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
|
271 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
272 | if (ht == NULL) { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
273 | 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
|
274 | 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
|
275 | } else { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
276 | 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
|
277 | 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
|
278 | 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
|
279 | } 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
|
280 | 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
|
281 | 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
|
282 | } |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
24951
diff
changeset
|
283 | 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
|
284 | g_free(ht); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
285 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
286 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33777
diff
changeset
|
287 | 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
|
288 | return NULL; |
|
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 | 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
|
292 | lv->logs = logs; |
|
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 | if (ht != NULL) |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
295 | 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
|
296 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
297 | /* Window ***********/ |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
298 | 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
|
299 | 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
|
300 | 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
|
301 | 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
|
302 | 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
|
303 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
304 | 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
|
305 | 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
|
306 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
307 | /* Label ************/ |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
308 | text = g_strdup_printf("%s", title); |
|
23152
b720e4052b1c
Show the title text in bold.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22938
diff
changeset
|
309 | 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
|
310 | g_free(text); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
311 | 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
|
312 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
313 | 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
|
314 | 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
|
315 | /* List *************/ |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
316 | 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
|
317 | 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
|
318 | populate_log_tree(lv); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
319 | 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
|
320 | 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
|
321 | lv); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
322 | 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
|
323 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
324 | /* Viewer ************/ |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
325 | 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
|
326 | 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
|
327 | 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
|
328 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
329 | 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
|
330 | 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
|
331 | /* Log size ************/ |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
332 | if (log_size) { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
333 | 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
|
334 | 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
|
335 | 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
|
336 | 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
|
337 | g_free(sz_txt); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
338 | g_free(text); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
339 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
340 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
341 | /* Search box **********/ |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
342 | 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
|
343 | 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
|
344 | 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
|
345 | 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
|
346 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
347 | 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
|
348 | 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
|
349 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
350 | 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
|
351 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
352 | return lv; |
|
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 | |
|
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
|
355 | 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
|
356 | 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
|
357 | { |
|
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
|
358 | /* 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
|
359 | 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
|
360 | 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
|
361 | *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
|
362 | } |
|
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 | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
24951
diff
changeset
|
364 | 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
|
365 | { |
|
22376
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
366 | 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
|
367 | 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
|
368 | 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
|
369 | 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
|
370 | 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
|
371 | int size = 0; |
|
22376
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
372 | |
|
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
|
373 | 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
|
374 | 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
|
375 | 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
|
376 | } |
|
22376
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
377 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
378 | 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
|
379 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
380 | 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
|
381 | 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
|
382 | ht->account = account; |
|
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 | if (log_viewers == NULL) { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
385 | 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
|
386 | } 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
|
387 | 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
|
388 | 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
|
389 | g_free(ht); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
390 | return; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
391 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
392 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
393 | 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
|
394 | PurpleChat *chat; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
395 | |
|
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 | 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
|
397 | if (chat != NULL) |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
398 | 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
|
399 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
400 | 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
|
401 | } else { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
402 | PurpleBuddy *buddy; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
403 | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
24951
diff
changeset
|
404 | if (username) { |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
405 | 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
|
406 | 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
|
407 | 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
|
408 | 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
|
409 | } 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
|
410 | 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
|
411 | } |
|
22376
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
412 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
413 | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
24951
diff
changeset
|
414 | 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
|
415 | 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
|
416 | 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
|
417 | } 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
|
418 | /* 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
|
419 | 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
|
420 | 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
|
421 | 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
|
422 | 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
|
423 | 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
|
424 | } |
|
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 | |
|
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 | 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
|
427 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
428 | g_free(title); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
429 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
430 | |
|
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
|
431 | 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
|
432 | { |
|
22376
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
433 | 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
|
434 | PurpleBlistNode *child; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
435 | FinchLogViewer *lv = NULL; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
436 | GList *logs = NULL; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
437 | const char *name = NULL; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
438 | char *title; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
439 | 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
|
440 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
441 | 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
|
442 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
443 | 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
|
444 | 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
|
445 | ht->contact = contact; |
|
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 | if (log_viewers == NULL) { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
448 | 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
|
449 | } 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
|
450 | 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
|
451 | g_free(ht); |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
452 | return; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
453 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
454 | |
|
22491
06d2ee82aa58
Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents:
22376
diff
changeset
|
455 | 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
|
456 | 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
|
457 | 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
|
458 | PurpleAccount *account; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33777
diff
changeset
|
459 | 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
|
460 | continue; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
461 | |
|
24951
d0837696fd3a
Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23431
diff
changeset
|
462 | 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
|
463 | 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
|
464 | 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
|
465 | 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
|
466 | 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
|
467 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
468 | 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
|
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 | 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
|
471 | if (!name) |
|
06d2ee82aa58
Fix showing a contact's log, and don't access struct internals
Richard Nelson <wabz@pidgin.im>
parents:
22376
diff
changeset
|
472 | 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
|
473 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
474 | /* 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
|
475 | * 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
|
476 | * 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
|
477 | 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
|
478 | child = purple_blist_node_get_first_child((PurpleBlistNode*)contact); |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33777
diff
changeset
|
479 | if (child != NULL && 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
|
480 | 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
|
481 | if (name == NULL) |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
482 | name = ""; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
483 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
484 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
485 | 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
|
486 | 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
|
487 | g_free(title); |
|
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 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
490 | void finch_syslog_show() |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
491 | { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
492 | GList *accounts = NULL; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
493 | GList *logs = NULL; |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
494 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
495 | if (syslog_viewer != NULL) { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
496 | 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
|
497 | return; |
|
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 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
500 | 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
|
501 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
502 | 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
|
503 | 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
|
504 | continue; |
|
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 | 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
|
507 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
508 | 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
|
509 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
510 | 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
|
511 | } |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
512 | |
|
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 | * GNT LOG SUBSYSTEM ******************************************************* |
|
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 | void * |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
518 | 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
|
519 | { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
520 | static int handle; |
|
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 | return &handle; |
|
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 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
525 | 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
|
526 | { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
527 | 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
|
528 | |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
529 | 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
|
530 | purple_marshal_VOID__POINTER_POINTER, |
|
34826
aabc888fd461
Refactored finch to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
531 | G_TYPE_NONE, 2, |
|
aabc888fd461
Refactored finch to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
532 | G_TYPE_POINTER, /* (FinchLogViewer *) */ |
|
aabc888fd461
Refactored finch to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
533 | PURPLE_TYPE_LOG); |
|
22376
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
534 | } |
|
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 | void |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
537 | finch_log_uninit(void) |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
538 | { |
|
25a17b6b69c2
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
539 | 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
|
540 | } |