7 * Copyright : (C) 2007 by Diogo Ferreira <diogo@underdev.org>
8 * (C) 2007 by João Oliveirinha <joliveirinha@floodbit.org>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 3
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
23 #include <beagle/beagle.h>
26 #define PLUGIN_NAME "beagleplugin"
28 static BeagleClient
*client
;
29 static const TeleportPlugin
*myself
;
30 static BeagleQuery
*beagle_query
;
33 hits_finished (BeagleQuery
*q
, BeagleFinishedResponse
*response
, gpointer p
)
39 beagle_cancel_query(void)
42 g_object_unref(beagle_query
);
43 g_log (G_LOG_DOMAIN
, G_LOG_LEVEL_DEBUG
, "%s: Last Query Canceled\n", PLUGIN_NAME
);
48 hits_added (BeagleQuery
*query
, BeagleHitsAddedResponse
*response
)
51 GSList
*actionGroup
= NULL
;
54 hits
= beagle_hits_added_response_get_hits (response
);
56 g_print("------------------------\n");
57 for (l
= hits
; l
; l
= l
->next
)
59 BeagleHit
*h
= BEAGLE_HIT (l
->data
);
60 g_print("[%s] %s\n", beagle_hit_get_mime_type(h
), beagle_hit_get_uri(h
));
62 act
= g_new (TeleportAction
, 1);
63 act
->text
= g_strdup (beagle_hit_get_uri(h
));
64 act
->mime_type
= g_strdup (beagle_hit_get_mime_type(h
));
65 act
->backend
= myself
;
68 actionGroup
= g_slist_append (actionGroup
, act
);
70 g_print("-------------------------\n");
73 teleport_trigger_query_update (actionGroup
);
77 GSList
* beagleSearch (const TeleportPlugin
*p
, const gchar
*q
)
79 BeagleQuery
*query
= beagle_query_new ();
81 beagle_query_add_text(query
, q
);
83 g_signal_connect (query
, "hits-added", G_CALLBACK(hits_added
), client
);
84 g_signal_connect (query
, "finished", G_CALLBACK(hits_finished
), NULL
);
86 beagle_client_send_request_async (client
, BEAGLE_REQUEST(query
), NULL
);
92 gboolean
beagleDoAction (TeleportAction
*act
)
98 gboolean
beagleInitPlugin (const TeleportPlugin
*p
)
105 client
= beagle_client_new (NULL
);
109 g_log (G_LOG_DOMAIN
, G_LOG_LEVEL_DEBUG
, "Failed to load %s plugin", PLUGIN_NAME
);
118 void beagleFiniPlugin (const TeleportPlugin
*p
)
120 g_object_unref (client
);
123 TeleportPluginVTable beagleVTable
= {
124 (gchar
*)PLUGIN_NAME
,
132 int teleport_get_abi ()
137 TeleportPluginVTable
* teleport_get_vtable ()
139 return &beagleVTable
;