nntpgrab_plugin_schedular.h

Go to the documentation of this file.
00001 /*
00002  Copyright (C) 2005-2009 Erik van Pienbroek
00003 
00004  This program is free software; you can redistribute it and/or modify
00005  it under the terms of the GNU General Public License as published by
00006  the Free Software Foundation; either version 2 of the License, or
00007  (at your option) any later version.
00008 
00009  This program is distributed in the hope that it will be useful,
00010  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00012  GNU General Public License for more details.
00013 
00014  You should have received a copy of the GNU General Public License
00015  along with this program; if not, write to the Free Software
00016  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00017 */
00018 
00019 #ifndef _NNTPGRAB_PLUGIN_SCHEDULAR_H_
00020 #define _NNTPGRAB_PLUGIN_SCHEDULAR_H_
00021 
00022 #include "nntpgrab_plugin_base.h"
00023 #include "collections.h"
00024 
00025 // These are all the functions that the plugin can call to communicate with the NNTPGrab core
00026 typedef struct _plugin_schedular_imported_funcs {
00027     int version;
00028 
00029     void (*task_added) (const NNTPCollection *collection, const NNTPFile *file);
00030     void (*task_removed) (const char *collection_name, const char *subject, guint64 total_size, guint64 total_size_remaining);
00031     void (*task_state_changed) (const char *collection_name, const char *subject, const char *real_filename, TaskState old_state, TaskState new_state);
00032     void (*collection_added) (const char *collection_name, const char *poster);
00033     void (*collection_removed) (const char *collection_name);
00034     void (*collection_modified) (const char *collection_name, const char *poster);
00035 
00036     void (*notify_schedular_state_changed) (SchedularState new_state, const char *reason);
00037 
00038     GList * (*config_get_avail_servers) (void);
00039     ConfigServer * (*config_get_server_info) (const char *servername);
00040     ConfigOpts (*config_get_opts) (void);
00041 
00042     gpointer (*nntp_connection_initialize) (const char *servername, NNTPGrabErrCode *err);
00043     void (*nntp_connection_destroy) (gpointer obj);
00044     NNTPGrabErrCode (*nntp_connection_get_part) (gpointer obj, const char *collection_name, const NNTPFile *file, const NNTPPart *part, char **reason);
00045 
00046     NNTPGrabDecoderRes (*decode_file) (const char *collection_name, NNTPFile *file, int *saved_errno, char **errmsg);
00047 
00048     void (*emit_fatal_error) (const char *errmsg);
00049     void (*emit_part_download_complete) (const char *servername, gpointer connection, const char *collection_name, const char *subject, int partnum, int size);
00050     void (*emit_part_download_failed) (const char *servername, gpointer connection, const char *collection_name, const char *subject, int partnum, int size, gboolean all_servers_tried);
00051     void (*emit_task_moved) (const char *orig_collection_name, const char *subject, const char *new_collection_name, int old_position, int new_position);
00052     void (*emit_collection_moved) (const char *collection_name, int old_position, int new_position);
00053     void (*emit_file_download_state_update) (const char *collection_name, const char *subject, int num_parts_total, int num_parts_done, int num_parts_failed, guint64 file_size, guint64 file_size_remaining, guint64 total_file_size, guint64 total_file_size_remaining);
00054 
00055     void (*perform_par2_repair) (const char *collection_name, const char *par2filename);
00056 
00057     void (*perform_unpack) (const char *collection_name, const char *filename);
00058 
00059     void (*emit_all_downloads_completed) (void);
00060 
00061     NNTPCollection *(*collection_new) (void);
00062     void (*collection_ref) (NNTPCollection *collection);
00063     void (*collection_unref) (NNTPCollection *collection);
00064     NNTPFile *(*file_new) (void);
00065     void (*file_ref) (NNTPFile *file);
00066     void (*file_unref) (NNTPFile *file);
00067 
00068     NGRegex *(*regex_compile) (const char *regex);
00069     const char **(*regex_match) (NGRegex *re, const char *text);
00070     void (*regex_matches_free) (const char **matches);
00071 } PluginSchedularImportedFuncs;
00072 
00073 // The plugin needs to exported these methods :
00074 
00083 gboolean     nntpgrab_plugin_schedular_initialize(PluginSchedularImportedFuncs funcs, char **errmsg);
00084 
00088 void         nntpgrab_plugin_schedular_destroy(void);
00089 
00096 int          nntpgrab_plugin_schedular_get_version(void);
00097 
00103 gboolean     nntpgrab_plugin_schedular_start(void);
00104 
00112 gboolean    nntpgrab_plugin_schedular_stop(const char *reason);
00113 
00121 SchedularState   nntpgrab_plugin_schedular_get_state(void);
00122 
00131 gboolean     nntpgrab_plugin_schedular_add_task_to_queue(const char *collection_name, NNTPFile *file, char **errmsg);
00132 
00142 gboolean     nntpgrab_plugin_schedular_del_task_from_queue(const char *collection_name, const char *subject, char **errmsg);
00143 
00153 gboolean     nntpgrab_plugin_schedular_restart_task(const char *collection_name, const char *subject, char **errmsg);
00154 
00161 gboolean     nntpgrab_plugin_schedular_save_queue(char **errmsg);
00162 
00169 void         nntpgrab_plugin_schedular_foreach_task(GFunc foreach_func, gpointer data);
00170 
00181 gboolean
00182 nntpgrab_plugin_schedular_move_task(const char *collection_name_src, const char *subject_src, const char *collection_name_dest, int position_dest);
00183 
00192 gboolean
00193 nntpgrab_plugin_schedular_move_collection(const char *collection_name, int new_position);
00194 
00195 #endif /* _NNTPGRAB_PLUGIN_SCHEDULAR_H_ */

Generated on Thu May 21 21:25:05 2009 for NNTPGrab by  1.5.4