Merge lp:~wyuka/zeitgeist-datasources/purple into lp:zeitgeist-datasources/0.8

Proposed by Tirtha Chatterjee
Status: Needs review
Proposed branch: lp:~wyuka/zeitgeist-datasources/purple
Merge into: lp:zeitgeist-datasources/0.8
Diff against target: 857 lines (+821/-1)
3 files modified
configure.ac (+21/-1)
purple/Makefile.am (+35/-0)
purple/zeitgeist_dataprovider.c (+765/-0)
To merge this branch: bzr merge lp:~wyuka/zeitgeist-datasources/purple
Reviewer Review Type Date Requested Status
Michal Hruby (community) code Needs Fixing
Manish Sinha (मनीष सिन्हा) license Needs Fixing
Review via email: mp+65605@code.launchpad.net

Commit message

Added a datasource for libpurple

Description of the change

Added a datasource for libpurple, the library used by Pidgin and Adium.

To post a comment you must log in.
Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

In purple/zeitgeist_dataprovider.c

> Zeitgeist dataprovider for XChat is free software;

Should be purple instead of XChat

> Zeitgeist dataprovider for XChat is distributed in the hope that

Should be again purple.

review: Needs Fixing (license)
Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

This would take some time as we need to make sure that the ontology are proper and does correspond to telepathy's data-source ontology perfectly to avoid any issues

Revision history for this message
Michal Hruby (mhr3) wrote :

First of all, I really don't think logging every sent and received url is a good idea, I'd get rid of all of that. (anyway if the user clicks on the url, it'll be logged by the browser dataproviders). @manish: objections?

Second, signed-on/off are not too interesting either imo, at very least they shouldn't be USER_ACTIVITY.

Let's get to something more specific (line numbers as seen in LP's diff):
681 727: libzg has method (zeitgeist_interpretation_for_mimetype) which turns mime-type into Interpretation, use that please.
...,686,...: storage parameter for ZeitgeistSubject is often wrong, local files are never "net".

Other than that there are a couple of leaks:
619: account_uri
671, 717: file
672, 718: parent

I'm no purple plugin expert, but I'd say you should disconnect the signals in the unload method.

review: Needs Fixing (code)
Revision history for this message
Michal Hruby (mhr3) wrote :

Oh and all instances g_file_get_uri leak as well.

Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

@Michal

I see there is anyway not harm in logging all the sent and received URLs. The use-case can be "I sent you the URL of _some_random_person_ facebook profile, didn't you see it". Logging the URL might help in this case

Unmerged revisions

152. By Tirtha Chatterjee

add events logging for purple

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2011-06-04 21:51:56 +0000
3+++ configure.ac 2011-06-23 01:16:19 +0000
4@@ -65,7 +65,7 @@
5 AC_MSG_NOTICE([Requested to enable all plugins: ${all_plugins}])
6
7 # The full list of plugins
8-allowed_plugins="bzr chrome eog geany gedit vim emacs tomboy telepathy xchat rhythmbox firefox-40-libzg totem-libzg firefox-36-libzg"
9+allowed_plugins="bzr chrome eog geany purple gedit vim emacs tomboy telepathy xchat rhythmbox firefox-40-libzg totem-libzg firefox-36-libzg"
10 # currently disabled = "epiphany"
11
12 # npapi-plugin has a template Makefile.am, but don't use it directly
13@@ -180,6 +180,22 @@
14 continue
15 fi
16 ;;
17+ purple)
18+ if test "${HAVE_LIBZG}" != "yes" ; then
19+ plugin_error_or_ignore "libzeitgeist not found"
20+ continue
21+ fi
22+ if test "x$HAVE_GTK" = "xno"; then
23+ plugin_error_or_ignore "You need to install gtk development headers"
24+ continue
25+ fi
26+ PKG_CHECK_MODULES(PURPLE, purple >= 2.0.0,
27+ [HAVE_PURPLE=yes], [HAVE_PURPLE=no])
28+ if test "${HAVE_PURPLE}" != "yes" ; then
29+ plugin_error_or_ignore "libpurple headers not found"
30+ continue
31+ fi
32+ ;;
33 npapi-plugin)
34 if test "${HAVE_LIBZG}" != "yes" ; then
35 plugin_error_or_ignore "libzeitgeist not found"
36@@ -321,6 +337,10 @@
37 AC_CONFIG_FILES([geany/Makefile])
38 continue 2
39 ;;
40+ purple)
41+ AC_CONFIG_FILES([purple/Makefile])
42+ continue 2
43+ ;;
44 gedit)
45 AC_CONFIG_FILES([gedit/Makefile])
46 continue 2
47
48=== added directory 'purple'
49=== added file 'purple/Makefile.am'
50--- purple/Makefile.am 1970-01-01 00:00:00 +0000
51+++ purple/Makefile.am 2011-06-23 01:16:19 +0000
52@@ -0,0 +1,35 @@
53+purpleplugindir = $(libdir)/purple-2/
54+purpleplugin_LTLIBRARIES = zeitgeist_dataprovider.la
55+
56+zeitgeist_dataprovider_la_SOURCES = \
57+ zeitgeist_dataprovider.c
58+zeitgeist_dataprovider_la_CFLAGS = \
59+ -fPIC -Wall -std=c99 \
60+ $(ZEITGEIST_CFLAGS) \
61+ $(PURPLE_CFLAGS) \
62+ $(NULL)
63+
64+zeitgeist_dataprovider_la_LIBADD = \
65+ $(ZEITGEIST_LIBS) \
66+ $(PURPLE_LIBS) \
67+ $(NULL)
68+zeitgeist_dataprovider_la_LDFLAGS = \
69+ -module -avoid-version \
70+ $(NULL)
71+
72+# we want to allow also local install
73+PURPLE_PLUGIN_HOME_DIR = ~/.purple/plugins
74+
75+PLUGIN_FILES = zeitgeist_dataprovider.so
76+
77+local-install:
78+ mkdir -p $(PURPLE_PLUGIN_HOME_DIR)
79+ cp $(PLUGIN_FILES) $(PURPLE_PLUGIN_HOME_DIR)
80+
81+local-uninstall:
82+ for f in $(PLUGIN_FILES); \
83+ do \
84+ echo remove $$f; \
85+ rm -f $(PURPLE_PLUGIN_HOME_DIR)/$$f; \
86+ done
87+
88
89=== added file 'purple/zeitgeist_dataprovider.c'
90--- purple/zeitgeist_dataprovider.c 1970-01-01 00:00:00 +0000
91+++ purple/zeitgeist_dataprovider.c 2011-06-23 01:16:19 +0000
92@@ -0,0 +1,765 @@
93+/*
94+ * zeitgeist-dataprovider.c
95+ * This file is part of Zeitgeist dataprovider for libpurple.
96+ *
97+ * Copyright (C) 2011 - Tirtha Chatterjee <tirtha.p.chatterjee@gmail.com>
98+ *
99+ * Zeitgeist dataprovider for XChat is free software;
100+ * you can redistribute it and/or modify it under the terms of the GNU Lesser
101+ * General Public License as published by the Free Software Foundation; either
102+ * version 3 of the License, or (at your option) any later version.
103+ *
104+ * Zeitgeist dataprovider for XChat is distributed in the hope that
105+ * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
106+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
107+ * See the GNU Lesser General Public License for more details.
108+ *
109+ * You should have received a copy of the GNU Lesser General Public
110+ * License along with this library; if not, write to the Free Software
111+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
112+ */
113+
114+#define ZEITGEIST_NCO_CONTACT_GROUP "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#ContactGroup"
115+#define ZEITGEIST_NCO_CONTACT "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact"
116+
117+#define PURPLE_PLUGINS
118+
119+#define ZEITGEIST_ID "core-zeitgeist"
120+
121+#include <stdio.h>
122+
123+#include "cipher.h"
124+#include "connection.h"
125+#include "conversation.h"
126+#include "core.h"
127+#include "debug.h"
128+#include "ft.h"
129+#include "signals.h"
130+#include "version.h"
131+#include "status.h"
132+#include "sound.h"
133+
134+#include <zeitgeist.h>
135+
136+#define PNAME "Zeitgeist"
137+#define PDESC "Inform Zeitgeist about your activity"
138+#define PVERSION "0.1"
139+
140+static ZeitgeistLog *zg_log = NULL; /* Zeitgeist-daemon handle*/
141+static GSList* signed_in_accounts = NULL;
142+
143+char *
144+get_uri_for_group(PurpleGroup *group)
145+{
146+ char* uri = g_strdup_printf("group://%s",
147+ purple_escape_filename(purple_group_get_name(group)));
148+ return uri;
149+}
150+
151+char *
152+get_uri_for_buddy(PurpleBuddy *buddy)
153+{
154+ char* uri = g_strdup_printf("buddy://%s",
155+ purple_escape_filename(purple_buddy_get_name(buddy)));
156+ return uri;
157+}
158+
159+char *
160+get_uri_for_account(PurpleAccount *account)
161+{
162+ char* uri = g_strdup_printf("account://%s",
163+ purple_escape_filename(purple_normalize(account,
164+ purple_account_get_username(account))));
165+ return uri;
166+}
167+
168+char *
169+get_uri_for_conversation(PurpleConversation* conv)
170+{
171+ PurpleAccount *account = purple_conversation_get_account(conv);
172+ PurpleConversationType type = purple_conversation_get_type(conv);
173+ const char *name = purple_conversation_get_name(conv);
174+
175+ PurplePlugin *prpl;
176+ PurplePluginProtocolInfo *prpl_info;
177+ const char *prpl_name;
178+ const char *target;
179+ char *uri;
180+
181+ prpl = purple_find_prpl(purple_account_get_protocol_id(account));
182+ if (!prpl)
183+ return NULL;
184+ prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
185+ prpl_name = prpl_info->list_icon(account, NULL);
186+
187+ if (type == PURPLE_CONV_TYPE_CHAT) {
188+ char *temp = g_strdup_printf("%s.chat", purple_normalize(account, name));
189+ target = purple_escape_filename(temp);
190+ g_free(temp);
191+ } else {
192+ target = purple_escape_filename(purple_normalize(account, name));
193+ }
194+
195+ uri = g_strdup_printf("conversation://%s/%s", prpl_name,
196+ target);
197+
198+ return uri;
199+}
200+
201+static void store_urls(const char *buffer,
202+ PurpleAccount *account, const char *target, gboolean sent_or_received)
203+{
204+ GRegex *strip_tags_regex = g_regex_new("<(.*?)>", 0, 0, NULL);
205+ GRegex *url_regex = g_regex_new("((https?)|(ftp))://[\\S]+", 0, 0, NULL);
206+ GError *error = NULL;
207+ GMatchInfo *match_info;
208+ char *cur = g_regex_replace_literal(strip_tags_regex, buffer, -1, 0, "", 0, NULL);
209+ g_regex_unref(strip_tags_regex);
210+
211+ g_regex_match_full(url_regex, cur, -1, 0, 0, &match_info, &error);
212+ while (g_match_info_matches (match_info))
213+ {
214+ char *url = g_match_info_fetch (match_info, 0);
215+ const char *text = target;
216+
217+ ZeitgeistEvent *event;
218+
219+ event = zeitgeist_event_new_full (
220+ (sent_or_received ? ZEITGEIST_ZG_SEND_EVENT:
221+ ZEITGEIST_ZG_RECEIVE_EVENT),
222+ (sent_or_received ? ZEITGEIST_ZG_USER_ACTIVITY:
223+ ZEITGEIST_ZG_WORLD_ACTIVITY),
224+ "application://pidgin.desktop",
225+ zeitgeist_subject_new_full (
226+ url,
227+ ZEITGEIST_NFO_BOOKMARK,
228+ ZEITGEIST_NFO_REMOTE_DATA_OBJECT,
229+ "text/plain",
230+ url,
231+ text,
232+ "net"),
233+ NULL);
234+
235+ /*g_print("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
236+ (sent_or_received ? ZEITGEIST_ZG_SEND_EVENT:
237+ ZEITGEIST_ZG_RECEIVE_EVENT),
238+ (sent_or_received ? ZEITGEIST_ZG_USER_ACTIVITY:
239+ ZEITGEIST_ZG_WORLD_ACTIVITY),
240+ "application://pidgin.desktop",
241+ url,
242+ ZEITGEIST_NCO_BOOKMARK,
243+ ZEITGEIST_NFO_REMOTE_DATA_OBJECT,
244+ "text/plain",
245+ url,
246+ text,
247+ "net");*/
248+
249+ zeitgeist_log_insert_events_no_reply (zg_log, event, NULL);
250+
251+ g_free (url);
252+ g_match_info_next (match_info, &error);
253+ }
254+ g_match_info_free (match_info);
255+ g_regex_unref (url_regex);
256+
257+ if (error != NULL)
258+ {
259+ g_error_free (error);
260+ return;
261+ }
262+ g_free(cur);
263+}
264+
265+/**************************************************************************
266+ * Buddy List subsystem signal callbacks
267+ **************************************************************************/
268+
269+static void
270+blist_node_added_cb(PurpleBlistNode *bnode, void *data)
271+{
272+ if (PURPLE_BLIST_NODE_IS_GROUP(bnode))
273+ {
274+ const char *text = purple_group_get_name(PURPLE_GROUP(bnode));
275+ char *group_uri = get_uri_for_group(PURPLE_GROUP(bnode));
276+
277+ ZeitgeistEvent *event;
278+
279+ event = zeitgeist_event_new_full (
280+ ZEITGEIST_ZG_CREATE_EVENT,
281+ ZEITGEIST_ZG_USER_ACTIVITY,
282+ "application://pidgin.desktop",
283+ zeitgeist_subject_new_full (
284+ group_uri,
285+ ZEITGEIST_NCO_CONTACT_GROUP,
286+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
287+ "text/plain",
288+ "application://pidgin.desktop",
289+ text,
290+ "net"),
291+ NULL);
292+
293+ /*g_print("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
294+ ZEITGEIST_ZG_CREATE_EVENT,
295+ ZEITGEIST_ZG_USER_ACTIVITY,
296+ "application://pidgin.desktop",
297+ group_uri,
298+ ZEITGEIST_NCO_CONTACT,
299+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
300+ "text/plain",
301+ "application://pidgin.desktop",
302+ text,
303+ "net");*/
304+
305+ zeitgeist_log_insert_events_no_reply (zg_log, event, NULL);
306+
307+ g_free(group_uri);
308+ }
309+ else if (PURPLE_BLIST_NODE_IS_BUDDY(bnode))
310+ {
311+ const char *text = purple_buddy_get_alias(PURPLE_BUDDY(bnode));
312+ char *group_uri = get_uri_for_group(
313+ purple_buddy_get_group(PURPLE_BUDDY(bnode)));
314+ char *buddy_uri = get_uri_for_buddy(PURPLE_BUDDY(bnode));
315+
316+ ZeitgeistEvent *event;
317+
318+ event = zeitgeist_event_new_full (
319+ ZEITGEIST_ZG_CREATE_EVENT,
320+ ZEITGEIST_ZG_USER_ACTIVITY,
321+ "application://pidgin.desktop",
322+ zeitgeist_subject_new_full (
323+ buddy_uri,
324+ ZEITGEIST_NCO_CONTACT,
325+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
326+ "text/plain",
327+ group_uri,
328+ text,
329+ "net"),
330+ NULL);
331+
332+ /*g_print("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
333+ ZEITGEIST_ZG_CREATE_EVENT,
334+ ZEITGEIST_ZG_USER_ACTIVITY,
335+ "application://pidgin.desktop",
336+ buddy_uri,
337+ ZEITGEIST_NCO_CONTACT,
338+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
339+ "text/plain",
340+ group_uri,
341+ text,
342+ "net");*/
343+
344+ zeitgeist_log_insert_events_no_reply (zg_log, event, NULL);
345+
346+ g_free(group_uri);
347+ g_free(buddy_uri);
348+ }
349+ else
350+ return;
351+}
352+
353+static void
354+blist_node_removed_cb(PurpleBlistNode *bnode, void *data)
355+{
356+ if (PURPLE_BLIST_NODE_IS_GROUP(bnode))
357+ {
358+ const char *text = purple_group_get_name(PURPLE_GROUP(bnode));
359+ char *group_uri = get_uri_for_group(PURPLE_GROUP(bnode));
360+ ZeitgeistEvent *event;
361+
362+ event = zeitgeist_event_new_full (
363+ ZEITGEIST_ZG_CREATE_EVENT,
364+ ZEITGEIST_ZG_USER_ACTIVITY,
365+ "application://pidgin.desktop",
366+ zeitgeist_subject_new_full (
367+ group_uri,
368+ ZEITGEIST_NCO_CONTACT_GROUP,
369+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
370+ "text/plain",
371+ "application://pidgin.desktop",
372+ text,
373+ "net"),
374+ NULL);
375+
376+ /*g_print("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
377+ ZEITGEIST_ZG_CREATE_EVENT,
378+ ZEITGEIST_ZG_USER_ACTIVITY,
379+ "application://pidgin.desktop",
380+ group_uri,
381+ ZEITGEIST_NCO_CONTACT,
382+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
383+ "text/plain",
384+ "application://pidgin.desktop",
385+ text,
386+ "net");*/
387+
388+ zeitgeist_log_insert_events_no_reply (zg_log, event, NULL);
389+
390+ g_free(group_uri);
391+ }
392+ else if (PURPLE_BLIST_NODE_IS_BUDDY(bnode))
393+ {
394+ const char *text = purple_buddy_get_alias(PURPLE_BUDDY(bnode));
395+ char *group_uri = get_uri_for_group(
396+ purple_buddy_get_group(PURPLE_BUDDY(bnode)));
397+ char *buddy_uri = get_uri_for_buddy(PURPLE_BUDDY(bnode));
398+
399+ ZeitgeistEvent *event;
400+
401+ event = zeitgeist_event_new_full (
402+ ZEITGEIST_ZG_DELETE_EVENT,
403+ ZEITGEIST_ZG_USER_ACTIVITY,
404+ "application://pidgin.desktop",
405+ zeitgeist_subject_new_full (
406+ buddy_uri,
407+ ZEITGEIST_NCO_CONTACT,
408+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
409+ "text/plain",
410+ group_uri,
411+ text,
412+ "net"),
413+ NULL);
414+
415+ /*g_print("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
416+ ZEITGEIST_ZG_DELETE_EVENT,
417+ ZEITGEIST_ZG_USER_ACTIVITY,
418+ "application://pidgin.desktop",
419+ buddy_uri,
420+ ZEITGEIST_NCO_CONTACT,
421+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
422+ "text/plain",
423+ group_uri,
424+ text,
425+ "net");*/
426+
427+ zeitgeist_log_insert_events_no_reply (zg_log, event, NULL);
428+
429+ g_free(group_uri);
430+ g_free(buddy_uri);
431+ }
432+ else
433+ return;
434+}
435+
436+/**************************************************************************
437+ * Connection subsystem signal callbacks
438+ **************************************************************************/
439+
440+static void
441+signed_on_cb(PurpleConnection *gc, void *data) //TODO
442+{
443+ PurpleAccount* account = purple_connection_get_account(gc);
444+ char *acname = g_strdup(purple_normalize(account,
445+ purple_account_get_username(account)));
446+
447+ const char *text = acname;
448+ char *account_uri = get_uri_for_account(account);
449+
450+ ZeitgeistEvent *event;
451+
452+ event = zeitgeist_event_new_full (
453+ ZEITGEIST_ZG_ACCESS_EVENT,
454+ ZEITGEIST_ZG_USER_ACTIVITY,
455+ "application://pidgin.desktop",
456+ zeitgeist_subject_new_full (
457+ account_uri,
458+ ZEITGEIST_NCO_CONTACT,
459+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
460+ "text/plain",
461+ "application://pidgin.desktop",
462+ text,
463+ "net"),
464+ NULL);
465+
466+ /*g_print("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
467+ ZEITGEIST_ZG_ACCESS_EVENT,
468+ ZEITGEIST_ZG_USER_ACTIVITY,
469+ "application://pidgin.desktop",
470+ account_uri,
471+ ZEITGEIST_NCO_CONTACT,
472+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
473+ "text/plain",
474+ "application://pidgin.desktop",
475+ text,
476+ "net");*/
477+
478+ zeitgeist_log_insert_events_no_reply (zg_log, event, NULL);
479+
480+ g_free(account_uri);
481+ signed_in_accounts = g_slist_append(signed_in_accounts, acname);
482+ // this is to make sure that a sign off in an account can't happen
483+ // without a sign-on, looks dumb. however it happens during
484+ // connection errors. so this check.
485+}
486+
487+static void
488+signed_off_cb(PurpleConnection *gc, void *data) //TODO
489+{
490+ PurpleAccount* account = purple_connection_get_account(gc);
491+ const char *acname = purple_normalize(account,
492+ purple_account_get_username(account));
493+ char* acc;
494+ GSList* current_account = signed_in_accounts;
495+ while (current_account != NULL)
496+ {
497+ acc = current_account->data;
498+ if (g_str_equal(acname, acc))
499+ {
500+ const char *text = acname;
501+ char *account_uri = get_uri_for_account(account);
502+
503+ ZeitgeistEvent *event;
504+
505+ event = zeitgeist_event_new_full (
506+ ZEITGEIST_ZG_LEAVE_EVENT,
507+ ZEITGEIST_ZG_USER_ACTIVITY,
508+ "application://pidgin.desktop",
509+ zeitgeist_subject_new_full (
510+ account_uri,
511+ ZEITGEIST_NCO_CONTACT,
512+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
513+ "text/plain",
514+ "application://pidgin.desktop",
515+ text,
516+ "net"),
517+ NULL);
518+
519+ /*g_print("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
520+ ZEITGEIST_ZG_LEAVE_EVENT,
521+ ZEITGEIST_ZG_USER_ACTIVITY,
522+ "application://pidgin.desktop",
523+ account_uri,
524+ ZEITGEIST_NCO_CONTACT,
525+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
526+ "text/plain",
527+ "application://pidgin.desktop",
528+ text,
529+ "net");*/
530+
531+ zeitgeist_log_insert_events_no_reply (zg_log, event, NULL);
532+
533+ g_free(account_uri);
534+ g_free(acc);
535+ signed_in_accounts = g_slist_delete_link(signed_in_accounts,
536+ current_account);
537+ }
538+ else
539+ {
540+ current_account = current_account->next;
541+ }
542+ }
543+}
544+
545+/**************************************************************************
546+ * Conversation subsystem signal callbacks
547+ **************************************************************************/
548+static void
549+sent_im_msg_cb(PurpleAccount *account,
550+ const char *recipient, const char *buffer, void *data)
551+{
552+ store_urls(buffer, account, recipient, TRUE);
553+}
554+
555+static void
556+received_im_msg_cb(PurpleAccount *account, char *sender,
557+ char *buffer, PurpleConversation *conv,
558+ PurpleMessageFlags flags, void *data)
559+{
560+ store_urls(buffer, account, sender, FALSE);
561+}
562+
563+static void
564+received_chat_msg_cb(PurpleAccount *account, char *sender,
565+ char *buffer, PurpleConversation *chat,
566+ PurpleMessageFlags flags, void *data)
567+{
568+ store_urls(buffer, account, sender, FALSE);
569+}
570+
571+static void
572+conversation_created_cb(PurpleConversation *conv, void *data)
573+{
574+ char *conv_uri = get_uri_for_conversation(conv);
575+ char *account_uri = get_uri_for_account(
576+ purple_conversation_get_account(conv));
577+ const char *text = purple_conversation_get_title(conv);
578+
579+
580+ ZeitgeistEvent *event;
581+
582+ event = zeitgeist_event_new_full (
583+ ZEITGEIST_ZG_ACCESS_EVENT,
584+ ZEITGEIST_ZG_USER_ACTIVITY, //FIXME: this may be world activity
585+ //find a way to check
586+ "application://pidgin.desktop",
587+ zeitgeist_subject_new_full (
588+ conv_uri,
589+ ZEITGEIST_NMO_IMMESSAGE,
590+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
591+ "text/plain",
592+ account_uri,
593+ text,
594+ "net"),
595+ NULL);
596+
597+ /*g_print("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
598+ ZEITGEIST_ZG_ACCESS_EVENT,
599+ ZEITGEIST_ZG_USER_ACTIVITY,
600+ "application://pidgin.desktop",
601+ conv_uri,
602+ ZEITGEIST_NMO_IMMESSAGE,
603+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
604+ "text/plain",
605+ account_uri,
606+ text,
607+ "net");*/
608+
609+ zeitgeist_log_insert_events_no_reply (zg_log, event, NULL);
610+
611+ g_free(conv_uri);
612+ g_free(account_uri);
613+}
614+
615+static void
616+deleting_conversation_cb(PurpleConversation *conv, void *data)
617+{
618+ char *conv_uri = get_uri_for_conversation(conv);
619+ char *account_uri = get_uri_for_account(
620+ purple_conversation_get_account(conv));
621+ const char *text = purple_conversation_get_title(conv);
622+
623+ ZeitgeistEvent *event;
624+
625+ event = zeitgeist_event_new_full (
626+ ZEITGEIST_ZG_DELETE_EVENT,
627+ ZEITGEIST_ZG_USER_ACTIVITY,
628+ "application://pidgin.desktop",
629+ zeitgeist_subject_new_full (
630+ conv_uri,
631+ ZEITGEIST_NMO_IMMESSAGE,
632+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
633+ "text/plain",
634+ account_uri,
635+ text,
636+ "net"),
637+ NULL);
638+
639+ /*g_print("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
640+ ZEITGEIST_ZG_DELETE_EVENT,
641+ ZEITGEIST_ZG_USER_ACTIVITY,
642+ "application://pidgin.desktop",
643+ conv_uri,
644+ ZEITGEIST_NMO_IMMESSAGE,
645+ ZEITGEIST_NFO_SOFTWARE_SERVICE,
646+ "text/plain",
647+ account_uri,
648+ text,
649+ "net");*/
650+
651+ zeitgeist_log_insert_events_no_reply (zg_log, event, NULL);
652+
653+ g_free(conv_uri);
654+}
655+
656+/**************************************************************************
657+ * File transfer signal callbacks
658+ **************************************************************************/
659+
660+static void
661+ft_recv_complete_cb(PurpleXfer *xfer, gpointer data) {
662+ const char *text = purple_xfer_get_filename(xfer);
663+ char *content_type = g_content_type_guess(
664+ purple_xfer_get_local_filename(xfer),
665+ NULL, 0, NULL);
666+ char *mime_type = g_content_type_get_mime_type(content_type);
667+ if (mime_type == NULL)
668+ mime_type = g_strdup("application/octet-stream");
669+ // TODO: check if this is the best possible solution
670+ g_free(content_type);
671+ GFile *file = g_file_new_for_path(purple_xfer_get_local_filename(xfer));
672+ GFile *parent = g_file_get_parent(file);
673+ ZeitgeistEvent *event;
674+
675+ event = zeitgeist_event_new_full (
676+ ZEITGEIST_ZG_RECEIVE_EVENT,
677+ ZEITGEIST_ZG_WORLD_ACTIVITY,
678+ "application://pidgin.desktop",
679+ zeitgeist_subject_new_full (
680+ g_file_get_uri(file),
681+ ZEITGEIST_NFO_DOCUMENT, //FIXME: should check MIME types
682+ ZEITGEIST_NFO_FILE_DATA_OBJECT,
683+ mime_type,
684+ (parent? g_file_get_uri(parent) : g_file_get_uri(file)),
685+ text,
686+ "net"),
687+ NULL);
688+
689+ /*g_print("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
690+ ZEITGEIST_ZG_RECEIVE_EVENT,
691+ ZEITGEIST_ZG_WORLD_ACTIVITY,
692+ "application://pidgin.desktop",
693+ g_file_get_uri(file),
694+ ZEITGEIST_NFO_DOCUMENT,
695+ ZEITGEIST_NFO_FILE_DATA_OBJECT,
696+ mime_type,
697+ (parent? g_file_get_uri(parent) : g_file_get_uri(file)),
698+ text,
699+ "net");*/
700+
701+ zeitgeist_log_insert_events_no_reply (zg_log, event, NULL);
702+
703+ g_free(mime_type);
704+}
705+
706+static void
707+ft_send_complete_cb(PurpleXfer *xfer, gpointer data) {
708+ const char *text = purple_xfer_get_filename(xfer);
709+ char *content_type = g_content_type_guess(
710+ purple_xfer_get_local_filename(xfer),
711+ NULL, 0, NULL);
712+ char *mime_type = g_content_type_get_mime_type(content_type);
713+ if (mime_type == NULL)
714+ mime_type = g_strdup("application/octet-stream");
715+ // TODO: check if this is the best possible solution
716+ g_free(content_type);
717+ GFile *file = g_file_new_for_path(purple_xfer_get_local_filename(xfer));
718+ GFile *parent = g_file_get_parent(file);
719+ ZeitgeistEvent *event;
720+
721+ event = zeitgeist_event_new_full (
722+ ZEITGEIST_ZG_SEND_EVENT,
723+ ZEITGEIST_ZG_USER_ACTIVITY,
724+ "application://pidgin.desktop",
725+ zeitgeist_subject_new_full (
726+ g_file_get_uri(file),
727+ ZEITGEIST_NFO_DOCUMENT, //FIXME: should check MIME types
728+ ZEITGEIST_NFO_FILE_DATA_OBJECT,
729+ mime_type,
730+ (parent? g_file_get_uri(parent) : g_file_get_uri(file)),
731+ text,
732+ "net"),
733+ NULL);
734+
735+ /*g_print("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
736+ ZEITGEIST_ZG_SEND_EVENT,
737+ ZEITGEIST_ZG_USER_ACTIVITY,
738+ "application://pidgin.desktop",
739+ g_file_get_uri(file),
740+ ZEITGEIST_NFO_DOCUMENT,
741+ ZEITGEIST_NFO_FILE_DATA_OBJECT,
742+ mime_type,
743+ (parent? g_file_get_uri(parent) : g_file_get_uri(file)),
744+ text,
745+ "net");*/
746+
747+ zeitgeist_log_insert_events_no_reply (zg_log, event, NULL);
748+
749+ g_free(mime_type);
750+}
751+
752+/**************************************************************************
753+ * Plugin stuff
754+ **************************************************************************/
755+static gboolean
756+plugin_load(PurplePlugin *plugin)
757+{
758+ zg_log = zeitgeist_log_new();
759+
760+ void *blist_handle = purple_blist_get_handle();
761+ void *conn_handle = purple_connections_get_handle();
762+ void *conv_handle = purple_conversations_get_handle();
763+ void *ft_handle = purple_xfers_get_handle();
764+
765+ /* Buddy List subsystem signals */
766+ purple_signal_connect(blist_handle, "blist-node-added",
767+ plugin, PURPLE_CALLBACK(blist_node_added_cb), NULL);
768+ purple_signal_connect(blist_handle, "blist-node-removed",
769+ plugin, PURPLE_CALLBACK(blist_node_removed_cb), NULL);
770+ //purple_signal_connect(blist_handle, "blist-node-aliased",
771+ // plugin, PURPLE_CALLBACK(blist_node_aliased), NULL);
772+
773+ /* Connection subsystem signals */
774+ purple_signal_connect(conn_handle, "signed-on",
775+ plugin, PURPLE_CALLBACK(signed_on_cb), NULL);
776+ purple_signal_connect(conn_handle, "signed-off",
777+ plugin, PURPLE_CALLBACK(signed_off_cb), NULL);
778+
779+ /* Conversations subsystem signals */
780+ purple_signal_connect(conv_handle, "sent-im-msg",
781+ plugin, PURPLE_CALLBACK(sent_im_msg_cb), NULL);
782+ purple_signal_connect(conv_handle, "received-im-msg",
783+ plugin, PURPLE_CALLBACK(received_im_msg_cb), NULL);
784+ purple_signal_connect(conv_handle, "received-chat-msg",
785+ plugin, PURPLE_CALLBACK(received_chat_msg_cb), NULL);
786+ purple_signal_connect(conv_handle, "conversation-created",
787+ plugin, PURPLE_CALLBACK(conversation_created_cb), NULL);
788+ purple_signal_connect(conv_handle, "deleting-conversation",
789+ plugin, PURPLE_CALLBACK(deleting_conversation_cb), NULL);
790+
791+ /* File transfer signals */
792+ purple_signal_connect(ft_handle, "file-recv-complete",
793+ plugin, PURPLE_CALLBACK(ft_recv_complete_cb), NULL);
794+ purple_signal_connect(ft_handle, "file-send-complete",
795+ plugin, PURPLE_CALLBACK(ft_send_complete_cb), NULL);
796+
797+ return TRUE;
798+}
799+
800+static gboolean
801+plugin_unload(PurplePlugin *plugin)
802+{
803+ GSList *current_account = signed_in_accounts;
804+ char *acc;
805+ while (current_account != NULL)
806+ {
807+ acc = current_account->data;
808+ g_free(acc);
809+ current_account = current_account->next;
810+ }
811+ g_slist_free(signed_in_accounts);
812+ signed_in_accounts = NULL;
813+
814+ return TRUE;
815+}
816+
817+static PurplePluginInfo info =
818+{
819+ PURPLE_PLUGIN_MAGIC,
820+ PURPLE_MAJOR_VERSION,
821+ PURPLE_MINOR_VERSION,
822+ PURPLE_PLUGIN_STANDARD, /**< type */
823+ NULL, /**< ui_requirement */
824+ 0, /**< flags */
825+ NULL, /**< dependencies */
826+ PURPLE_PRIORITY_DEFAULT, /**< priority */
827+
828+ ZEITGEIST_ID, /**< id */
829+ PNAME, /**< name */
830+ PVERSION, /**< version */
831+ /** summary */
832+ PDESC, /** description */
833+ PDESC,
834+ "Tirtha Chatterjee <tirtha.p.chatterjee@gmail.com>", /**< author */
835+ "http://www.zeitgeist-project.com/", /**< homepage */
836+
837+ plugin_load, /**< load */
838+ plugin_unload, /**< unload */
839+ NULL, /**< destroy */
840+
841+ NULL, /**< ui_info */
842+ NULL, /**< extra_info */
843+ NULL,
844+ NULL,
845+ /* Padding */
846+ NULL,
847+ NULL,
848+ NULL,
849+ NULL
850+};
851+
852+static void
853+init_plugin(PurplePlugin *plugin)
854+{
855+}
856+
857+PURPLE_INIT_PLUGIN(zeitgeist, init_plugin, info)

Subscribers

People subscribed via source and target branches