NNTPGrab Core library

NNTPGrab Core library

Synopsis

#define             NNTPGRAB_API_VERSION
NntpgrabCore *      nntpgrab_core_new                   (void);
void                nntpgrab_core_destroy               (NntpgrabCore *obj);
NGList *            nntpgrab_core_config_get_avail_servers
                                                        (NntpgrabCore *obj);
void                nntpgrab_core_config_free_avail_servers
                                                        (NntpgrabCore *obj,
                                                         NGList *servers);
ngboolean           nntpgrab_core_config_get_server_info
                                                        (NntpgrabCore *obj,
                                                         const char *servername,
                                                         NGConfigServer *server);
ngboolean           nntpgrab_core_config_add_server     (NntpgrabCore *obj,
                                                         NGConfigServer new_server,
                                                         char **errmsg);
ngboolean           nntpgrab_core_config_del_server     (NntpgrabCore *obj,
                                                         const char *servername,
                                                         char **errmsg);
ngboolean           nntpgrab_core_config_edit_server    (NntpgrabCore *obj,
                                                         const char *servername,
                                                         NGConfigServer server,
                                                         char **errmsg);
NGConfigOpts        nntpgrab_core_config_get_opts       (NntpgrabCore *obj);
void                nntpgrab_core_config_set_opts       (NntpgrabCore *obj,
                                                         NGConfigOpts opts);
ngboolean           nntpgrab_core_schedular_start       (NntpgrabCore *obj);
ngboolean           nntpgrab_core_schedular_stop        (NntpgrabCore *obj,
                                                         ngboolean wait);
NGSchedularState    nntpgrab_core_schedular_get_state   (NntpgrabCore *obj);
ngboolean           nntpgrab_core_schedular_add_task_to_queue
                                                        (NntpgrabCore *obj,
                                                         const char *collection_name,
                                                         const char *subject,
                                                         const char *poster,
                                                         time_t stamp,
                                                         nguint64 file_size,
                                                         NGList *groups,
                                                         NGList *parts,
                                                         char **errmsg);
ngboolean           nntpgrab_core_schedular_del_task_from_queue
                                                        (NntpgrabCore *obj,
                                                         const char *collection_name,
                                                         const char *subject,
                                                         char **errmsg);
ngboolean           nntpgrab_core_schedular_restart_task
                                                        (NntpgrabCore *obj,
                                                         const char *collection_name,
                                                         const char *subject,
                                                         char **errmsg);
ngboolean           nntpgrab_core_schedular_save_queue  (NntpgrabCore *obj,
                                                         char **errmsg);
void                nntpgrab_core_schedular_foreach_task
                                                        (NntpgrabCore *obj,
                                                         ForeachCollectionFunc collection_func,
                                                         ForeachFileFunc file_func,
                                                         ForeachGroupFunc group_func,
                                                         void *user_data);
ngboolean           nntpgrab_core_schedular_move_task   (NntpgrabCore *obj,
                                                         const char *collection_name_src,
                                                         const char *subject_src,
                                                         const char *collection_name_dest,
                                                         int position_dest);
ngboolean           nntpgrab_core_schedular_move_collection
                                                        (NntpgrabCore *obj,
                                                         const char *collection_name,
                                                         int new_position);
ngboolean           nntpgrab_core_schedular_mark_task_optional
                                                        (NntpgrabCore *obj,
                                                         const char *collection_name,
                                                         const char *subject,
                                                         ngboolean is_optional);
NGList *            nntpgrab_core_plugins_get_avail_plugins
                                                        (NntpgrabCore *obj);
void                nntpgrab_core_plugins_free_avail_plugins
                                                        (NntpgrabCore *obj,
                                                         NGList *plugins);
ngboolean           nntpgrab_core_plugins_get_plugin_info
                                                        (NntpgrabCore *obj,
                                                         const char *plugin_name,
                                                         NNTPGrabPluginInfo *plugin_info);
ngboolean           nntpgrab_core_plugins_load_plugin   (NntpgrabCore *obj,
                                                         const char *plugin_name,
                                                         char **errmsg);
ngboolean           nntpgrab_core_plugins_unload_plugin (NntpgrabCore *obj,
                                                         const char *plugin_name,
                                                         char **errmsg);
ngboolean           nntpgrab_core_plugins_set_persistent
                                                        (NntpgrabCore *obj,
                                                         const char *plugin_name,
                                                         ngboolean persistent);
ngboolean           nntpgrab_core_embedded_server_start (NntpgrabCore *obj,
                                                         int port,
                                                         char **errmsg);

Description

Details

NNTPGRAB_API_VERSION

#define NNTPGRAB_API_VERSION    20110718

nntpgrab_core_new ()

NntpgrabCore *      nntpgrab_core_new                   (void);

Creates a new instance of the NntpgrabCore object. This is required for all other NNTPGrab functions

Returns :

An instance of the NntpgrabCore which need to be used for other NNTPGrab functions

nntpgrab_core_destroy ()

void                nntpgrab_core_destroy               (NntpgrabCore *obj);

Cleanup the NNTPGrab Core library. After this function is called, the NntpgrabCore instance can't be used anymore

obj :

An instance of the NntpgrabCore

nntpgrab_core_config_get_avail_servers ()

NGList *            nntpgrab_core_config_get_avail_servers
                                                        (NntpgrabCore *obj);

Retrieve a list of the available usenet servers

obj :

An instance of the NntpgrabCore

Returns :

A list of all the available usenet servers. Needs to be freed using nntpgrab_config_free_avail_servers(). [transfer full][element-type utf8]

nntpgrab_core_config_free_avail_servers ()

void                nntpgrab_core_config_free_avail_servers
                                                        (NntpgrabCore *obj,
                                                         NGList *servers);

Free the list of available usenet servers

obj :

An instance of the NntpgrabCore

servers :

A list of the available usenet servers as returned from the function nntpgrab_config_get_avail_servers()

nntpgrab_core_config_get_server_info ()

ngboolean           nntpgrab_core_config_get_server_info
                                                        (NntpgrabCore *obj,
                                                         const char *servername,
                                                         NGConfigServer *server);

Get the configuration details about a specific usenet server

obj :

An instance of the NntpgrabCore

servername :

The name of the server whose details should be retrieved

server :

The address of a ConfigServer structure which will be used to fill in the configuration details. [out]

Returns :

TRUE on success (server will be filled in), FALSE if the server isn't known

nntpgrab_core_config_add_server ()

ngboolean           nntpgrab_core_config_add_server     (NntpgrabCore *obj,
                                                         NGConfigServer new_server,
                                                         char **errmsg);

Add a new usenet server to the NNTPGrab configuration

obj :

An instance of the NntpgrabCore

new_server :

A structure containing the details about the new usenet server

errmsg :

Pointer to a char*. If an errors occurs, the reason will be placed in this field. Needs to be freed using ngfree(). Can be NULL to ignore errors. [allow-none][out]

Returns :

TRUE when the server was successfully added. FALSE on failure (the reason will be placed in the errmsg field)

nntpgrab_core_config_del_server ()

ngboolean           nntpgrab_core_config_del_server     (NntpgrabCore *obj,
                                                         const char *servername,
                                                         char **errmsg);

Remove a usenet server from the NNTPGrab configuration

obj :

An instance of the NntpgrabCore

servername :

The name of the server whose entry should be removed

errmsg :

Pointer to a char*. If an errors occurs, the reason will be placed in this field. Needs to be freed using ngfree(). Can be NULL to ignore errors. [allow-none][out]

Returns :

TRUE when the server was successfully removed. FALSE on failure (the reason will be placed in the errmsg field)

nntpgrab_core_config_edit_server ()

ngboolean           nntpgrab_core_config_edit_server    (NntpgrabCore *obj,
                                                         const char *servername,
                                                         NGConfigServer server,
                                                         char **errmsg);

Adjust the configuration details of an usenet server

obj :

An instance of the NntpgrabCore

servername :

The name of the server whose entry should be adjusted

server :

A structure containing the new configuration details of the given servername

errmsg :

Pointer to a char*. If an errors occurs, the reason will be placed in this field. Needs to be freed using ngfree(). Can be NULL to ignore errors. [allow-none][out]

Returns :

TRUE when the server was successfully adjusted. FALSE on failure (the reason will be placed in the errmsg field)

nntpgrab_core_config_get_opts ()

NGConfigOpts        nntpgrab_core_config_get_opts       (NntpgrabCore *obj);

Retrieve the general configuration options

obj :

An instance of the NntpgrabCore

Returns :

A structure containing the general configuration options

nntpgrab_core_config_set_opts ()

void                nntpgrab_core_config_set_opts       (NntpgrabCore *obj,
                                                         NGConfigOpts opts);

Adjust the general configuration options

obj :

An instance of the NntpgrabCore

opts :

A structure containing the new general configuration options

nntpgrab_core_schedular_start ()

ngboolean           nntpgrab_core_schedular_start       (NntpgrabCore *obj);

Start the NNTPGrab schedular

obj :

An instance of the NntpgrabCore

Returns :

TRUE is the schedular was successfully started, FALSE if the schedular was already running or in the 'stopping' state

nntpgrab_core_schedular_stop ()

ngboolean           nntpgrab_core_schedular_stop        (NntpgrabCore *obj,
                                                         ngboolean wait);

Stop the NNTPGrab schedular

obj :

An instance of the NntpgrabCore

wait :

Whether this function should wait until the schedular really has stopped

Returns :

TRUE is schedular was successfully stopped, FALSE if the schedular was already stopped or the in 'stopping' state

nntpgrab_core_schedular_get_state ()

NGSchedularState    nntpgrab_core_schedular_get_state   (NntpgrabCore *obj);

Retrieve the current state of the schedular

obj :

An instance of the NntpgrabCore

Returns :

The current state of the schedular

nntpgrab_core_schedular_add_task_to_queue ()

ngboolean           nntpgrab_core_schedular_add_task_to_queue
                                                        (NntpgrabCore *obj,
                                                         const char *collection_name,
                                                         const char *subject,
                                                         const char *poster,
                                                         time_t stamp,
                                                         nguint64 file_size,
                                                         NGList *groups,
                                                         NGList *parts,
                                                         char **errmsg);

Add a new task to the download queue

obj :

An instance of the NntpgrabCore

collection_name :

The name of the collection in which this task should be added. If there is no collection in the download queue with the given name, it will automatically be created

subject :

The subject of the file

poster :

The name of the poster

stamp :

The UNIX timestamp of the post date

file_size :

The size of the file

groups :

A list containing the newsgroups in which this file is posted. [element-type utf8]

parts :

A list containing the message-id's of all the individual parts belonging to this file. [element-type NNTPGrabPart]

errmsg :

Pointer to a char*. If an errors occurs, the reason will be placed in this field. Needs to be freed using ngfree(). Can be NULL to ignore errors. [allow-none][out]

Returns :

TRUE if the task was succesfully added, FALSE if an error occured (errmsg will be set)

nntpgrab_core_schedular_del_task_from_queue ()

ngboolean           nntpgrab_core_schedular_del_task_from_queue
                                                        (NntpgrabCore *obj,
                                                         const char *collection_name,
                                                         const char *subject,
                                                         char **errmsg);

Remove a task from the download queue

obj :

An instance of the NntpgrabCore

collection_name :

The name of the collection in which the task resides

subject :

The subject of the task errmsg (allow-none) (out): Pointer to a char*. If an errors occurs, the reason will be placed in this field. Needs to be freed using ngfree(). Can be NULL to ignore errors. [allow-none]

Returns :

TRUE if the task was successfully removed, FALSE if an error occured (errmsg will be set)

nntpgrab_core_schedular_restart_task ()

ngboolean           nntpgrab_core_schedular_restart_task
                                                        (NntpgrabCore *obj,
                                                         const char *collection_name,
                                                         const char *subject,
                                                         char **errmsg);

Restart a task in the download queue

obj :

An instance of the NntpgrabCore

collection_name :

The name of the collection in which the task resides

subject :

The subject of the task errmsg (allow-none) (out): Pointer to a char*. If an errors occurs, the reason will be placed in this field. Needs to be freed using ngfree(). Can be NULL to ignore errors. [allow-none]

Returns :

TRUE if the task was successfully removed, FALSE if an error occured (errmsg will be set)

nntpgrab_core_schedular_save_queue ()

ngboolean           nntpgrab_core_schedular_save_queue  (NntpgrabCore *obj,
                                                         char **errmsg);

Save any recent changes in the download queue to the disk Note that the download queue will automatically be saved every now and then by the NNTPGrab Core, but it is recommended to perform a manual save as soon as a lot of file have been added to the download queue (like directly after an NZB import)

obj :

An instance of the NntpgrabCore

errmsg :

Pointer to a char*. If an errors occurs, the reason will be placed in this field. Needs to be freed using ngfree(). Can be NULL to ignore errors. [allow-none][out]

Returns :

TRUE if the task was successfully removed, FALSE if an error occured (errmsg will be set)

nntpgrab_core_schedular_foreach_task ()

void                nntpgrab_core_schedular_foreach_task
                                                        (NntpgrabCore *obj,
                                                         ForeachCollectionFunc collection_func,
                                                         ForeachFileFunc file_func,
                                                         ForeachGroupFunc group_func,
                                                         void *user_data);

Retrieve a list of all the items in the download queue (using callback functions)

obj :

An instance of the NntpgrabCore

collection_func :

The function which should be called for every collection in the download queue. [allow-none]

file_func :

The function which should be called for every file in the download queue. [allow-none]

group_func :

The function which should be called for every group in every file in the download queue. [allow-none]

user_data :

Pointer to some data which will be made available in the callback functions. [allow-none]

nntpgrab_core_schedular_move_task ()

ngboolean           nntpgrab_core_schedular_move_task   (NntpgrabCore *obj,
                                                         const char *collection_name_src,
                                                         const char *subject_src,
                                                         const char *collection_name_dest,
                                                         int position_dest);

Move a task in the download queue

obj :

An instance of the NntpgrabCore

collection_name_src :

The name of the collection where the subject is part of

subject_src :

The name of the subject which needs to be moved

collection_name_dest :

The name of the collection where the subject needs to be moved to (if NULL, the task will stay in the same collection as it is now) position_dest The position in collection_name_dest where the task needs to be placed at. [allow-none]

Returns :

TRUE on success, FALSE if the collection_name_src or subject_src could not be found

nntpgrab_core_schedular_move_collection ()

ngboolean           nntpgrab_core_schedular_move_collection
                                                        (NntpgrabCore *obj,
                                                         const char *collection_name,
                                                         int new_position);

Move the position of a collection in the download queue

obj :

An instance of the NntpgrabCore

collection_name :

The name of the collection which needs to be moved

new_position :

The position in the download queue where the collection needs to be moved to

Returns :

TRUE on success, FALSE is the collection_name could not be found

nntpgrab_core_schedular_mark_task_optional ()

ngboolean           nntpgrab_core_schedular_mark_task_optional
                                                        (NntpgrabCore *obj,
                                                         const char *collection_name,
                                                         const char *subject,
                                                         ngboolean is_optional);

Mark a task in the download queue optional or non-optional

obj :

An instance of the NntpgrabCore

collection_name :

The name of the collection in which the task resides

subject :

The subject of the task

is_optional :

TRUE if the task needs to be marked optional, FALSE is the task needs to be marked non-optional

Returns :

TRUE if the task was successfully updated, FALSE if the task wasn't found

nntpgrab_core_plugins_get_avail_plugins ()

NGList *            nntpgrab_core_plugins_get_avail_plugins
                                                        (NntpgrabCore *obj);

Retrieve a list of all the available plugins

obj :

An instance of the NntpgrabCore

Returns :

A list containing all the available plugins (const char* items). Needs to be free'd using nntpgrab_core_plugins_free_avail_plugins(). [transfer full][element-type utf8]

nntpgrab_core_plugins_free_avail_plugins ()

void                nntpgrab_core_plugins_free_avail_plugins
                                                        (NntpgrabCore *obj,
                                                         NGList *plugins);

Free a list as returned by the function nntpgrab_core_plugins_get_avail_plugins()

obj :

An instance of the NntpgrabCore

plugins :

The list of available plugins

nntpgrab_core_plugins_get_plugin_info ()

ngboolean           nntpgrab_core_plugins_get_plugin_info
                                                        (NntpgrabCore *obj,
                                                         const char *plugin_name,
                                                         NNTPGrabPluginInfo *plugin_info);

Retrieve information about a specific plugin

obj :

An instance of the NntpgrabCore

plugin_name :

The name of the plugin whose information needs to be retrieved

plugin_info :

Pointer to an NNTPGrabPluginInfo structure where the plugin information can be saved. [out]

Returns :

TRUE on success, FALSE if the given plugin_name is unknown

nntpgrab_core_plugins_load_plugin ()

ngboolean           nntpgrab_core_plugins_load_plugin   (NntpgrabCore *obj,
                                                         const char *plugin_name,
                                                         char **errmsg);

Load a plugin

obj :

An instance of the NntpgrabCore

plugin_name :

The name of the plugin which needs to be loaded

errmsg :

Pointer to a location where an error message can be saved. Needs to be free'd using ng_free(). [allow-none][out]

Returns :

TRUE on success, FALSE is the given plugin_name is unknown or an error occured while loading the plugin

nntpgrab_core_plugins_unload_plugin ()

ngboolean           nntpgrab_core_plugins_unload_plugin (NntpgrabCore *obj,
                                                         const char *plugin_name,
                                                         char **errmsg);

Unload a plugin

obj :

An instance of the NntpgrabCore

plugin_name :

The name of the plugin which needs to be unloaded

errmsg :

Pointer to a location where an error message can be saved. Needs to be free'd using ng_free(). [allow-none][out]

Returns :

TRUE on success, FALSE is the given plugin_name is unknown or an error occured while unloading the plugin

nntpgrab_core_plugins_set_persistent ()

ngboolean           nntpgrab_core_plugins_set_persistent
                                                        (NntpgrabCore *obj,
                                                         const char *plugin_name,
                                                         ngboolean persistent);

Indicate whether a plugin needs to be automatically loaded on startup Note that this API function is unused in NNTPGrab 0.6

obj :

An instance of the NntpgrabCore

plugin_name :

The name of the plugin

persistent :

Flag to indicate whether this plugin needs to be automatically loaded or not

Returns :

TRUE on success, FALSE is the given plugin_name is unknown

nntpgrab_core_embedded_server_start ()

ngboolean           nntpgrab_core_embedded_server_start (NntpgrabCore *obj,
                                                         int port,
                                                         char **errmsg);

Start the embedded server on the specified port (even if it's disabled in the configuration) Note that this API function is implemented temporary for NNTPGrab 0.6. For future versions it needs to be moved to a more generic API function

obj :

An instance of the NntpgrabCore

port :

The port on which the embedded webserver needs to listen

errmsg :

Pointer to a location where an error message can be saved. Needs to be free'd using ng_free(). [allow-none][out]

Returns :

TRUE on success, FALSE if an error occured (errmsg will be set)