schedular_plugin.h

Go to the documentation of this file.
00001 #ifndef _SCHEDULAR_PLUGIN_H_
00002 #define _SCHEDULAR_PLUGIN_H_
00003 
00004 typedef struct SchedularPlugin SchedularPlugin;
00005 
00006 #define SCHEDULAR_PLUGIN_TYPE_OBJECT (schedular_plugin_get_type ())
00007 #define SCHEDULAR_PLUGIN(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SCHEDULAR_PLUGIN_TYPE_OBJECT, SchedularPlugin))
00008 #define SCHEDULAR_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCHEDULAR_PLUGIN_TYPE_OBJECT, SchedularPluginClass))
00009 #define IS_SCHEDULAR_PLUGIN(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SCHEDULAR_PLUGIN_TYPE_OBJECT))
00010 #define IS_SCHEDULAR_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCHEDULAR_PLUGIN_TYPE_OBJECT))
00011 #define SCHEDULAR_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCHEDULAR_PLUGIN_TYPE_OBJECT, SchedularPluginClass))
00012 
00013 GType schedular_plugin_get_type (void);
00014 
00015 struct SchedularPlugin
00016 {
00017     GObject parent;
00018 
00019     // The mutex is used for settings properties used by the schedular thread
00020     GStaticMutex mutex;
00021     GList *queue;           // Pointers to NNTPCollection*
00022     GList *servers;         // Pointers to ConfigServer*
00023 
00024     // These are used to keep track of all the jobs for each usenet server
00025     GAsyncQueue *task_queue[MAX_NNTP_SERVERS];  // All jobs for each usenet server are queue here
00026     GCond       *task_cond;
00027     GMutex      *task_mutex;
00028 
00029     // Keep track of which servers are of which priority
00030     gboolean     is_high_priority_server[MAX_NNTP_SERVERS];
00031     gboolean     is_normal_priority_server[MAX_NNTP_SERVERS];
00032     gboolean     is_low_priority_server[MAX_NNTP_SERVERS];
00033     gboolean     is_server_enabled[MAX_NNTP_SERVERS];
00034 
00035     // The runtime_mutex is used for the creation and destruction of the schedular thread
00036     GStaticMutex runtime_mutex;
00037     GThread *thread;
00038     gboolean abort_flag;
00039 };
00040 
00041 typedef struct _decoder_data {
00042     SchedularPlugin *schedular;
00043     const char *collection_name;
00044     NNTPFile *file;
00045 } DecoderData;
00046 
00047 typedef struct _download_data {
00048     ConfigServer *server;
00049     int           server_id;
00050     GThreadPool  *poolDecoder;
00051 } DownloadData;
00052 
00053 // schedular.c
00054 gboolean         get_next_part_to_download(SchedularPlugin *schedular, int server_id, NNTPCollection **collection, NNTPFile **file, NNTPPart **part, GThreadPool *poolDecoder);
00055 void             update_part_download_status(NNTPCollection *collection, NNTPFile *file, NNTPPart *part, int server_id, gboolean success, gboolean reset_to_zero, gboolean queue_is_being_paused, gboolean dont_retry_anymore, gpointer nntpconnection);
00056 void             stop_schedular_from_seperate_thread(const char *reason);
00057 gboolean         schedular_plugin_save_queue(char **errmsg);
00058 
00059 // decoder_thread.c
00060 void             decoder_thread_func(gpointer data, gpointer user_data);
00061 
00062 // download_thread.c
00063 void             download_thread_func(gpointer data, gpointer user_data);
00064 
00065 // imported_funcs.c
00066 void             schedular_plugin_set_imported_funcs(PluginSchedularImportedFuncs funcs);
00067 
00068 void             imported_funcs_task_added (const NNTPCollection *collection, const NNTPFile *file);
00069 void             imported_funcs_task_removed (const char *collection_name, const char *subject, guint64 total_file_size, guint64 total_file_size_remaining);
00070 void             imported_funcs_task_state_changed (const char *collection_name, const char *subject, TaskState old_state, TaskState new_state);
00071 void             imported_funcs_collection_added (const char *collection_name);
00072 void             imported_funcs_collection_removed (const char *collection_name);
00073 void             imported_funcs_notify_schedular_state_changed (SchedularState new_state, const char *reason);
00074 GList           *imported_funcs_config_get_avail_servers (void);
00075 ConfigServer    *imported_funcs_config_get_server_info (const char *servername);
00076 ConfigOpts       imported_funcs_config_get_opts (void);
00077 gpointer         imported_funcs_nntp_connection_initialize (const char *servername, NNTPGrabErrCode *err);
00078 void             imported_funcs_nntp_connection_destroy (gpointer obj);
00079 NNTPGrabErrCode  imported_funcs_nntp_connection_get_part (gpointer obj, const char *collection_name, const NNTPFile *file, const NNTPPart *part, char **reason);
00080 gboolean         imported_funcs_decode_file (const char *collection_name, const NNTPFile *file, int *saved_errno);
00081 void             imported_funcs_emit_fatal_error (const char *errmsg);
00082 void             imported_funcs_emit_part_download_complete (const char *servername, gpointer nntp_connection, const char *collection_name, const char *subject, int partnum, int size);
00083 void             imported_funcs_emit_part_download_failed (const char *servername, gpointer nntp_connection, const char *collection_name, const char *subject, int partnum, int size, gboolean all_servers_tried);
00084 void             imported_funcs_emit_task_moved (const char *orig_collection_name, const char *subject, const char *new_collection_name, int old_position, int new_position);
00085 void             imported_funcs_emit_collection_moved (const char *collection_name, int old_position, int new_position);
00086 void             imported_funcs_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);
00087 
00088 // queue.c
00089 gboolean         load_download_queue(GList **ret, char **errmsg);
00090 gboolean         save_download_queue(GList *queue, char **errmsg);
00091 void             free_download_queue(GList *queue);
00092 
00093 #endif /* _SCHEDULAR_PLUGIN_H_ */

Generated on Sun Oct 12 01:45:30 2008 for NNTPGrab by  1.5.4