root / trunk / plugins / example / example.c
History | View | Annotate | Download (2.5 KB)
| 1 |
/*
|
|---|---|
| 2 |
Copyright (C) 2005-2012 Erik van Pienbroek |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU General Public License as published by |
| 6 |
the Free Software Foundation; either version 2 of the License, or |
| 7 |
(at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program; if not, write to the Free Software |
| 16 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 |
*/ |
| 18 |
|
| 19 |
#include |
| 20 |
#include "nntpgrab_plugin.h" |
| 21 |
|
| 22 |
static void file_added_cb(NGPlugin *plugin_data, const char *collection_name, const char *subject, const char *poster, time_t stamp, guint64 file_size, guint64 total_size, guint64 total_size_remaining, NGTaskState status, int numparts, GList *groups, gpointer data); |
| 23 |
|
| 24 |
void
|
| 25 |
nntpgrab_plugin_initialize(NGPlugin *plugin_data) |
| 26 |
{
|
| 27 |
ng_plugin_set_name(plugin_data, "Example");
|
| 28 |
ng_plugin_set_version(plugin_data, "1.0");
|
| 29 |
ng_plugin_set_author(plugin_data, "Erik van Pienbroek");
|
| 30 |
ng_plugin_set_url(plugin_data, "https://www.nntpgrab.nl");
|
| 31 |
ng_plugin_set_description(plugin_data, "Example plugin which prints a message in the console every time a file is added");
|
| 32 |
|
| 33 |
ng_plugin_set_required_event(plugin_data, "file_added");
|
| 34 |
} |
| 35 |
|
| 36 |
ngboolean |
| 37 |
nntpgrab_plugin_load(NGPlugin *plugin_data, char **errmsg)
|
| 38 |
{
|
| 39 |
ng_plugin_connect_event(plugin_data, "file_added", NG_PLUGIN_FUNCTION(file_added_cb), NULL); |
| 40 |
|
| 41 |
return TRUE;
|
| 42 |
} |
| 43 |
|
| 44 |
ngboolean |
| 45 |
nntpgrab_plugin_can_unload(NGPlugin *plugin_data, char **reason)
|
| 46 |
{
|
| 47 |
return TRUE;
|
| 48 |
} |
| 49 |
|
| 50 |
void
|
| 51 |
nntpgrab_plugin_unload(NGPlugin *plugin_data) |
| 52 |
{
|
| 53 |
} |
| 54 |
|
| 55 |
void
|
| 56 |
nntpgrab_plugin_destroy(NGPlugin *plugin_data) |
| 57 |
{
|
| 58 |
} |
| 59 |
|
| 60 |
int
|
| 61 |
nntpgrab_plugin_get_version(void)
|
| 62 |
{
|
| 63 |
return NNTPGRAB_PLUGIN_API_VERSION;
|
| 64 |
} |
| 65 |
|
| 66 |
NGVariant * |
| 67 |
nntpgrab_plugin_call_plugin_method(NGPlugin *plugin_data, const char *method, NGVariant *parameters, char **errmsg) |
| 68 |
{
|
| 69 |
return NULL; |
| 70 |
} |
| 71 |
|
| 72 |
static void |
| 73 |
file_added_cb(NGPlugin *plugin_data, const char *collection_name, const char *subject, const char *poster, time_t stamp, guint64 file_size, guint64 total_size, guint64 total_size_remaining, NGTaskState status, int numparts, GList *groups, gpointer data) |
| 74 |
{
|
| 75 |
printf("Example plugin - new file added: collection_name = '%s', subject = '%s'\n", collection_name, subject);
|
| 76 |
} |
NNTPGrab

