annotate finch/gntlog.c @ 32142:6b443ffa2f8b

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