Statistics
| Revision:

root / trunk / base / nntpgrab_utils.h @ 1833

History | View | Annotate | Download (26.5 KB)

1
/* 
2
    Copyright (C) 2005-2010  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
#ifndef _NNTPGRAB_UTILS_H_
20
#define _NNTPGRAB_UTILS_H_
21

                
22
#include "nntpgrab_types.h"
23

                
24
#ifdef  __cplusplus
25
extern "C" {
26
#endif
27

                
28
/* These declarations are actually from GLib, but to easy the development 
29
 * of external frontends, they have been duplicated here to avoid linkage bloat */
30

                
31
#ifdef DONT_WRAP_GLIB
32
#include 
33
#define NGFileMonitor GFileMonitor
34
#else
35
typedef void NGFileMonitor;
36

                
37
/** 
38
 * ng_free:
39
 * @data:           The data which needs to be free'd
40
 *
41
 * Free data allocated by NNTPGrab functions
42
 */
43
void          ng_free(void *data);
44

                
45
/** 
46
 * ng_list_append:
47
 * list:      The list where the item needs to be added to (can be NULL to create a new list)
48
 * data:      The item which needs to be added
49
 *
50
 * Append an item to a list
51
 *
52
 * Returns:   The (possibly) new start of the list
53
 */
54
NGList       *ng_list_append  (NGList *list, void *data);
55

                
56
/** 
57
 * ng_list_prepend:
58
 * @list:      The list where the item needs to be added to (can be NULL to create a new list)
59
 * @data:      The item which needs to be added
60
 *
61
 * Insert an item to the beginning of a list
62
 *
63
 * Returns:    The (possibly) new start of the list
64
 */
65
NGList       *ng_list_prepend (NGList *list, void *data);
66

                
67
/** 
68
 * ng_list_remove:
69
 * list:      The list where the item needs to be removed from
70
 * data:      The item which needs to be removed
71
 *
72
 * Remove an item from a list
73
 * Note that if @data isn't part of the list, this function will do nothing
74
 *
75
 * Returns:   The (possibly) new start of the list
76
 */
77
NGList       *ng_list_remove  (NGList *list, void *data);
78

                
79
/** 
80
 * ng_list_length:
81
 * @list:      The list of which the length must be returned
82
 *
83
 * Retrieve the length of a list
84
 *
85
 * Returns:    The length of the list
86
 */
87
unsigned int  ng_list_length  (NGList *list);
88

                
89
/** 
90
 * ng_list_free:
91
 * @list:      The list which needs to be free'd
92
 *
93
 * Free a list
94
 * Note that this function only free's the list itself, NOT the items which were in it!
95
 */
96
void          ng_list_free    (NGList *list);
97

                
98
/** 
99
 * ng_list_previous:
100
 * @list:       The list of which the previous item needs to be retrieved
101
 * Returns:     The previous item in @list or NULL when there's no previous item
102
 */
103
#define ng_list_previous(list)           ((list) ? (((NGList *)(list))->prev) : NULL)
104

                
105
/** 
106
 * ng_list_next:
107
 * @list:       The list of which the next item needs to be retrieved
108
 * Returns:     The next item in @list or NULL when there's no next item
109
 */
110
#define ng_list_next(list)               ((list) ? (((NGList *)(list))->next) : NULL)
111

                
112
/* signals */
113
/** 
114
 * ng_signal_connect:
115
 * @instance:      The instance of an GObject, for example NNTPGrabCore or NNTPGrabAutoImport
116
 * @signal_name:   The name of the signal for which a signaler handler needs to be registered
117
 * @cb_handler:    The function which need to be called every time the given signal is emit
118
 * @data:          Data used as extra argument in the callback functions
119
 *
120
 * Register a signal handler
121
 * The file nntpgrab_core/marshall.list contains a list of known signals and callback function prototypes for the NNTPGrabCore
122
 */
123
void     ng_signal_connect(void *instance, const char *signal_name, NGCallback cb_handler, void *data);
124

                
125
/** 
126
 * ng_signal_handler_disconnect_by_func:
127
 * @instance:      The instance of an GObject, for example NNTPGrabCore or NNTPGrabAutoImport
128
 * @cb_handler:    The callback function which need to be unregistered
129
 * @data:          The callback data used for the given cb_handler
130
 *
131
 * Un-register a signal handler
132
 */
133
void     ng_signal_handlers_disconnect_by_func(void *instance, NGCallback cb_handler, void *data);
134

                
135
/** 
136
 * ng_signal_handlers_block_by_func:
137
 * @instance:      The instance of an GObject, for example NNTPGrabCore or NNTPGrabAutoImport
138
 * @cb_handler:    The callback function which need to be temporary blocked
139
 * @data:          The callback data used for the given cb_handler
140
 *
141
 * Temporary disable a signal handler for a given callback function
142
 */
143
void     ng_signal_handlers_block_by_func(void *instance, NGCallback cb_handler, void *data);
144

                
145
/** 
146
 * ng_signal_handlers_unlock_by_func:
147
 * @instance:      The instance of an GObject, for example NNTPGrabCore or NNTPGrabAutoImport
148
 * @cb_handler:    The callback function which need to be un-blocked
149
 * @data:          The callback data used for the given cb_handler
150
 *
151
 * Re-enable a signal handler for a given callback function
152
 */
153
void     ng_signal_handlers_unblock_by_func(void *instance, NGCallback cb_handler, void *data);
154

                
155
/** 
156
 * ng_event_handler_loop_run:
157
 *
158
 * Start the event handler loop. This function waits for incoming events and passes these on to all the registered event handlers
159
 * This function only returns as soon as the function ng_event_handler_loop_quit() is called from an event handler or another thread
160
 * This function doesn't need to be used for the GTK+ frontend as it is equivalent to gtk_main()
161
 */
162
void     ng_event_handler_loop_run(void);
163

                
164
/** 
165
 * ng_event_handler_loop_quit:
166
 *
167
 * Stop the event handler loop
168
 * This function doesn't need to be used for the GTK+ frontend as it is equivalent to gtk_main_quit()
169
 */
170
void     ng_event_handler_loop_quit(void);
171

                
172
/** 
173
 * ng_event_handler_loop_depth:
174
 *
175
 * Returns the depth of stack calls in the event handler loop
176
 * This function returns 0 when no event handler loop is running yet
177
 */
178
int      ng_event_handler_loop_depth(void);
179

                
180
/* End of GLib declarations */
181
#endif
182

                
183
/** 
184
 * NNTPGrabNZB:
185
 * @files:  (element-type NZBFile):     A list containing NZBFile's
186
 */
187
typedef struct _nzb {
188
    NGList *files;
189
} NNTPGrabNZB;
190

                
191
/** 
192
 * NZBFile:
193
 * @subject:                                    The subject of the file
194
 * @poster:                                     The poster of the file
195
 * @stamp:                                      The stamp when (the first part of) this file was posted
196
 * @filesize:                                   The size of the file in bytes
197
 * @groups:     (element-type utf8):            A list containing the names of the newsgroups in which this file is posted
198
 * @segments:   (element-type NNTPGrabPart):    A list containing information of all the parts which belong to this file
199
 */
200
typedef struct _nzb_file {
201
    char subject[256];
202
    char poster[256];
203
    time_t stamp;
204
    nguint64 filesize;
205
    NGList *groups;
206
    NGList *segments;
207
} NNTPGrabNZBFile;
208

                
209
/** 
210
 * NZBCreatorGroup:
211
 * @newsgroup:              The name of the newsgroup
212
 * @group_id:               An identifier for this group
213
 */
214
typedef struct _nzbcreator_group {
215
    char newsgroup[512];
216
    int group_id;
217
} NZBCreatorGroup;
218

                
219
typedef enum _nzbcreator_search_only_in {
220
    NZBCREATOR_SEARCH_ONLY_IN_SUBJECTS,
221
    NZBCREATOR_SEARCH_ONLY_IN_FILENAMES,
222
    NZBCREATOR_SEARCH_ONLY_IN_POSTERS
223
} NZBCreatorSearchOnlyIn;
224

                
225
/** 
226
 * NZBCreatorSearchOpts:
227
 * @query:                  The search query
228
 * @username:               The username which will be used to perform the search query (unused in NNTPGrab 0.7)
229
 * @password:               The password which will be used to perform the search query (unused in NNTPGrab 0.7)
230
 * @search_only_in:         Indicate what type of data needs to be searched
231
 * @max_age:                The maximum age of search results (in days)
232
 * @minimal_file_size:      The minimum size of files in bytes
233
 * @maximal_file_size:      The maximum size of files in bytes
234
 * @percentage_complete:    Only return results which are this percentage complete (0 to 100)
235
 * @group_to_search:        Limit searching to one specific groups (see the @group_id field from #NZBCreatorGroup)
236
 * @file_type:              Only search files of this type
237
 */
238
typedef struct _nzbcreator_search_opts {
239
    char query[64];
240
    char username[64];
241
    char password[64];
242
    NZBCreatorSearchOnlyIn search_only_in;
243
    int max_age;
244
    ngint64 minimal_file_size;
245
    ngint64 maximal_file_size;
246
    int percentage_complete;
247
    int group_to_search;
248
    NNTPFileType file_type;
249
} NZBCreatorSearchOpts;
250

                
251
/** 
252
 * NZBCreatorFile:
253
 * @file_id:                An identifier for this file
254
 * @subject:                The subject of this file
255
 * @poster:                 The poster of this file
256
 * @num_parts_found:        The number of parts which are found which belong to this file
257
 * @num_parts_expected:     The number of parts which are expected which belong to this file
258
 * @file_type:              The type of this file
259
 * @file_size:              The size of this file in bytes
260
 * @stamp:                  The stamp of the first part of this file
261
 * @complete_percentage:    The percentage which indicates how complete this file is
262
 */
263
typedef struct _nzbcreator_file {
264
    ngint64 file_id;
265
    char subject[256];
266
    char poster[256];
267
    int num_parts_found;
268
    int num_parts_expected;
269
    NNTPFileType file_type;
270
    ngint64 file_size;
271
    time_t stamp;
272
    int complete_percentage;
273
} NZBCreatorFile;
274

                
275
/** 
276
 * NZBCreatorCollection:
277
 * @collection_name:                                        The name of the collection (most frequently this is the subject of the first file in the collection)
278
 * @short_collection_name:                                  An abbreviated version of @collection_name
279
 * @newsgroup:                                              The newsgroup in which all the files from this collection are poster
280
 * @total_size:                                             The total size in bytes of this collection
281
 * @stamp:                                                  The stamp of the first part of the first file in this collection
282
 */
283
typedef struct _nzbcreator_collection {
284
    ngint64 collection_id;
285
    char collection_name[256];
286
    char short_collection_name[256];
287
    char poster[256];
288
    char newsgroup[256];
289
    ngint64 total_size;
290
    time_t stamp;
291
    int num_parts_found;
292
    int num_parts_expected;
293
    int complete_percentage;
294
    int num_regular_files;
295
    int num_par2_files;
296
    ngint64 first_file_id;
297
} NZBCreatorCollection;
298

                
299
/** 
300
 * NZBCreatorSearchResult:
301
 * @number_of_hits:                                             The number of hits which were found for the given query
302
 * @number_of_results:                                          The number of files which were found and are part of the @collections
303
 * @collections:        (element-type NZBCreatorCollection):    A list containing all returned collections
304
 */
305
typedef struct _nzbcreator_search_result {
306
    int number_of_hits;
307
    int number_of_results;
308
    NGList *collections;             // List of NZBCreatorCollection* instances
309
} NZBCreatorSearchResult;
310

                
311
/** 
312
 * nntpgrab_utils_perform_base_initialization: (skip)
313
 *
314
 * Perform the initialization of the GLib system. Needs to be called before any other NNTPGrab function in non-GLib-based frontends
315
 */
316
void nntpgrab_utils_perform_base_initialization(void);
317

                
318
/** 
319
 * nntpgrab_utils_regex_compile:
320
 * @regex:     The (perl-compatible) regular expression which needs to be compiled
321
 *
322
 * Compile a regular expression
323
 *
324
 * Returns:    A compiled regular expression
325
 */
326
NGRegex     *nntpgrab_utils_regex_compile(const char *regex);
327

                
328
/** 
329
 * nntpgrab_utils_regex_free:
330
 * @re:        The compiled regular expression
331
 *
332
 * Free a compiled regular expression
333
 */
334
void         nntpgrab_utils_regex_free(NGRegex *re);
335

                
336
/** 
337
 * nntpgrab_utils_regex_match:
338
 * @re:        The compiled regular expression
339
 * @line:      The data which need to be matched against the compiled regular expression
340
 *
341
 * Perform a match against a compiled regular expression
342
 *
343
 * Returns:    A NULL-terminated array of matches items (needs to be free'd using nntpgrab_utils_regex_matches_free())
344
 */
345
const char **nntpgrab_utils_regex_match(NGRegex *re, const char *line);
346

                
347
/** 
348
 * nntpgrab_utils_regex_matches_free:
349
 * @param matches   The NULL-terminated array of matches as returned by the function nntpgrab_utils_regex_match()
350
 *
351
 * Free an array of matched items
352
 */
353
void         nntpgrab_utils_regex_matches_free(const char **matches);
354

                
355
/** 
356
 * nntpgrab_utils_strip_subject:
357
 * @subject                                       The subject which need to be stripped
358
 * @subject_without_partnum  (allow-none) (out):  Location for the subject without any part numbers
359
 * @file_num                 (allow-none) (out):  Location for the number of the file in the set
360
 * @total_files              (allow-none) (out):  Location for the total number of files in the set
361
 * @filename                 (allow-none) (out):  Location for the filename
362
 * @extension                (allow-none) (out):  Location for the extension of the filename (as an string)
363
 * @file_type                (allow-none) (out):  Location for the extension of the filename (as an enumeration)
364
 * @par2_startnum            (allow-none) (out):  Location for the start number of the PAR2 recovery file
365
 * @num_par2_blocks          (allow-none) (out):  Location for the number blocks in the PAR2 recovery file
366
 * @part_num                 (allow-none) (out):  Location for the part number for this subject
367
 * @total_parts              (allow-none) (out):  Location for the number of parts for this subject
368
 *
369
 * Strip a subject into useable pieces of data
370
 * All the parameters (except subject) can be NULL to ignore them
371
 * All the char* parameters need to be free'd using ng_free()
372
 *
373
 * Returns:         TRUE is the strip was successfull
374
 */
375
ngboolean        nntpgrab_utils_strip_subject(const char *subject, char **subject_without_partnum, int *file_num, int *total_files, char **filename, char **extension, NNTPFileType *file_type, int *par2_startnum, int *num_par2_blocks, int *part_num, int *total_parts);
376

                
377
/** 
378
 * nntpgrab_utils_get_file_type_of_filename:
379
 * @filename:       The filename whose file type needs to be found out
380
 *
381
 * Find out the file type of a given filename
382
 * If the file type couldn't be found out, the value NNTP_FILE_TYPE_UNKNOWN will be returned
383
 *
384
 * Returns:         The file type (as an enumeration)
385
 */
386
NNTPFileType     nntpgrab_utils_get_file_type_of_filename(const char *filename);
387

                
388
/** 
389
 * nntpgrab_utils_calculate_file_size:
390
 * @file_size:                  The file size which needs to be transformed
391
 * @file_size_str:     (out):   Pointer to the location where the result needs to be saved
392
 * @file_size_str_len:          The maximum length of the file_size_str buffer
393
 *
394
 * Transform a file size into a human readable notation
395
 */
396
void nntpgrab_utils_calculate_file_size(nguint64 file_size, char *file_size_str, int file_size_str_len);
397

                
398
/** 
399
 * nntpgrab_utils_calculate_estimated_time_remaining:
400
 * @bytes_received1:      The number of bytes received in now() - 10
401
 * @bytes_received2:      The number of bytes received in now() - 9
402
 * @bytes_received3:      The number of bytes received in now() - 8
403
 * @bytes_received4:      The number of bytes received in now() - 7
404
 * @bytes_received5:      The number of bytes received in now() - 6
405
 * @bytes_received6:      The number of bytes received in now() - 5
406
 * @bytes_received7:      The number of bytes received in now() - 4
407
 * @bytes_received8:      The number of bytes received in now() - 3
408
 * @bytes_received9:      The number of bytes received in now() - 2
409
 * @bytes_received10:     The number of bytes received in now() - 1
410
 * @file_size:            The file size in bytes
411
 *
412
 * Calculate the estimated time remaining to complete the given file size
413
 * The bytes_received parameters can be retrieved from the signalhandler for the signal #NNTPGrabCore::traffic-monitor-update
414
 *
415
 * Returns:               The number of seconds in which the given @file_size can be downloaded
416
 */
417
int              nntpgrab_utils_calculate_estimated_time_remaining(int bytes_received1, int bytes_received2, int bytes_received3, int bytes_received4, int bytes_received5, int bytes_received6, int bytes_received7, int bytes_received8, int bytes_received9, int bytes_received10, nguint64 file_size);
418

                
419
/** 
420
 * nntpgrab_utils_get_readable_time_remaining:
421
 * @estimated_time_remaining:         The estimated time remaining (in seconds)
422
 * @time_remaining_str:       (out):  Pointer to the location where the human readable notation (like '3 minutes and 10 seconds') can be saved
423
 * @time_remaining_str_len:           The maximum length of the time_remaining_str buffer
424
 *
425
 * Transform a estimated time remaining into a human readable value for the time remaining
426
 */
427
void             nntpgrab_utils_get_readable_time_remaining(int estimated_time_remaining, char *time_remaining_str, int time_remaining_str_len);
428

                
429
/** 
430
 * nntpgrab_utils_get_readable_finished_time:
431
 * @estimated_time_remaining:          The estimated time remaining (in seconds)
432
 * @time_remaining_str:        (out):  Pointer to the location where the human readable notation (like 'Friday February 6 2009 - 22:15') can be saved
433
 * @time_remaining_str_len:            The maximum length of the time_remaining_str buffer
434
 *
435
 * Transform a estimated time remaining into a human readable value for the expected time to finish
436
 */
437
void             nntpgrab_utils_get_readable_finished_time(int estimated_time_remaining, char *time_remaining_str, int time_remaining_str_len);
438

                
439
/** 
440
 * nntpgrab_utils_sanitize_text:
441
 * @text:      (inout):  The text which need to be sanitized
442
 * @length:              The length of the text
443
 *
444
 * Check whether the given text contains invalid UTF-8 characters and if they're found, replace them with something more sane
445
 */
446
void             nntpgrab_utils_sanitize_text(char *text, int length);
447

                
448
/** 
449
 * nntpgrab_utils_strip_nzb_extension:
450
 * @filename:   (inout):  The filename whose extension need to be stripped
451
 *
452
 * Remove the extension from a filename
453
 */
454
void             nntpgrab_utils_strip_nzb_extension(char *filename);
455

                
456
/** 
457
 * nntpgrab_utils_sanitize_collection_name:
458
 * @collection_name:  (inout):  The collection name which need to be sanitized
459
 *
460
 * Remove forbidden characters from the collection name
461
 */
462
void             nntpgrab_utils_sanitize_collection_name(char *collection_name);
463

                
464
/** 
465
 * nntpgrab_utils_extract_par2set_name_from_par2_filename:
466
 * @par2filename:             The filename of the PAR2 file which needs to be extracted
467
 * @par2set:          (out):  Pointer to a location where the result can be saved
468
 * @par2set_length:           Size of the par2set length
469
 *
470
 * Extract the name of a PAR2 set out of a PAR2 filename
471
 *
472
 * Returns:                   TRUE of success (par2set will be set), FALSE on failure
473
 */
474
ngboolean
475
nntpgrab_utils_extract_par2set_name_from_par2_filename(const char *par2filename, char *par2set, int par2set_length);
476

                
477
/** 
478
 * nntpgrab_utils_get_folder_listing:
479
 * @parent:                                              The name of the directory whose sub-folders should be retrieved. If NULL, all available drives will be returned (when the host is running Windows)
480
 * @folders:    (out) (element-type NNTPGrabFolder):     Pointer to a NGList*. The list of sub-folders will be placed in this field. This list needs to be free'd using the function nntpgrab_config_free_folder_listing()
481
 *
482
 * Retrieves a list containing all the sub-folders which are in the given folder
483
 *
484
 * Returns:            TRUE on sucess, FALSE if the given directory isn't found or readable
485
 */
486
ngboolean        nntpgrab_utils_get_folder_listing(const char *parent, NGList **folders);
487

                
488
/** 
489
 * nntpgrab_utils_free_folder_listing: (skip)
490
 * @folders:       A list containing subfolders as returned by the function nntpgrab_config_get_folder_listing()
491
 *
492
 * Free a list of sub-folders
493
 */
494
void             nntpgrab_utils_free_folder_listing(NGList *folders);
495

                
496
/** 
497
 * nntpgrab_utils_parse_nzb_file:
498
 * @contents:                         The contents of the NZB file
499
 * @errmsg:      (out) (allow-none):  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
500
 *
501
 * Parse the contents of a NZB file and put the information in a structure
502
 *
503
 * Returns:      A structure containing information about the NZB file. Needs to be free'd using the function nntpgrab_utils_nzb_file_free(). If the value NULL is returned, an error occured and errmsg will be set
504
 */
505
NNTPGrabNZB     *nntpgrab_utils_parse_nzb_file(const char *contents, char **errmsg);
506

                
507
/** 
508
 * nntpgrab_utils_nzb_file_free: (skip)
509
 * @nzbfile:       The structure containing information about the NZB file
510
 *
511
 * Free a structure containing details about a NZB file
512
 */
513
void             nntpgrab_utils_nzb_file_free(NNTPGrabNZB *nzbfile);
514

                
515
/** 
516
 * nntpgrab_utils_nzbcreator_check_api_version:
517
 * @api_okay:                          Location where the result can be saved
518
 * @errmsg:      (out) (allow-none):   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
519
 *
520
 * Verify if this version of NNTPGrab can be used to communicate with the NZBCreator service
521
 *
522
 * Returns:      TRUE when the online search server returned a valid response (use @api_okay to find out if the API version matches)
523
 */
524
ngboolean        nntpgrab_utils_nzbcreator_check_api_version(ngboolean *api_okay, char **errmsg);
525

                
526
/** 
527
 * nntpgrab_utils_nzbcreator_get_all_groups:
528
 * @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
529
 *
530
 * Retrieve a list of all the usenet groups which are indexed by the NZBCreator service
531
 *
532
 * Returns:     (element-type NZBCreatorGroup):   A list of all the indexed usenet groups. Needs to be free'd using nntpgrab_utils_nzbcreator_free_groups(). If an error occures, the value NULL will be returned and errmsg will be set
533
 */
534
NGList                  *nntpgrab_utils_nzbcreator_get_all_groups(char **errmsg);
535

                
536
/** 
537
 * nntpgrab_utils_nzbcreator_free_groups: (skip)
538
 * @groups:        A list of all the indexed usenet groups
539
 *
540
 * Free the list of usenet groups which are indexed by the NZBCreator service
541
 */
542
void                     nntpgrab_utils_nzbcreator_free_groups(NGList *groups);
543

                
544
/** 
545
 * nntpgrab_utils_nzbcreator_perform_search:
546
 * @opts:                                               A structure containing information about the requested search
547
 * @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
548
 *
549
 * Perform a search using the NZBCreator service
550
 *
551
 * Returns:   (element-type NZBCreatorSearchResults):   A structure containing the search results. Needs to be free'd using nntpgrab_utils_nzbcreator_free_result(). If an error occurs, the value NULL will be returned and errmsg will be set
552
 */
553
NZBCreatorSearchResult  *nntpgrab_utils_nzbcreator_perform_search(NZBCreatorSearchOpts opts, char **errmsg);
554

                
555
/** 
556
 * nntpgrab_utils_nzbcreator_free_result: (skip)
557
 * @result:        The NZBCreator search results
558
 *
559
 * Free the NZBCreator search results
560
 */
561
void                     nntpgrab_utils_nzbcreator_free_result(NZBCreatorSearchResult *result);
562

                
563
/** 
564
 * nntpgrab_utils_nzbcreator_retrieve_collection_details:
565
 * @collection_id:                          The id of the collection whose details need to be retrieved
566
 * @stamp:                                  The stamp belonging to the collection id
567
 * @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
568
 *
569
 * Retrieve a list of files belonging to a collection
570
 *
571
 * Returns:                                 A list containing NZBCreatorFile's. Needs to be free'd using nntpgrab_utils_nzbcreator_free_collection_details(). If an error occurs, the value NULL will be returned and errmsg will be set
572
 */
573
NGList *nntpgrab_utils_nzbcreator_retrieve_collection_details(ngint64 collection_id, time_t stamp, char **errmsg);
574

                
575
/** 
576
 * nntpgrab_utils_nzbcreator_free_collection_details: (skip)
577
 * @files:          The list of files as returned by nntpgrab_utils_nzbcreator_retrieve_collection_details()
578
 *
579
 * Free the list with collection details
580
 */
581
void nntpgrab_utils_nzbcreator_free_collection_details(NGList *files);
582

                
583
/** 
584
 * nntpgrab_utils_nzbcreator_generate_NZB:
585
 * @file_ids:  (element-type int):  A list containing file ID's of all the files which needs to be retrieved
586
 * @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
587
 *
588
 * Generate a NZB file based on a list of file ID's
589
 *
590
 * Returns:    The contents of the NZB file containing all the details of the given file_ids. Needs to be free'd using ng_free(). If an error occurs, the value NULL will be returned and errmsg will be set
591
 */
592
char                    *nntpgrab_utils_nzbcreator_generate_NZB(NGList *file_ids, char **errmsg);
593

                
594
/** 
595
 * nntpgrab_utils_monitor_directory:
596
 * @path:                         The directory which needs to be monitored for changes
597
 * @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
598
 *
599
 * Start the monitoring of a directory
600
 * The NGFileMonitor is an GObject where the event 'changed' can be caught using ng_signal_connect()
601
 *
602
 * Returns:                       An instance of a NGFileMonitor or NULL in case an error occured (errmsg will be set)
603
 */
604
NGFileMonitor   *nntpgrab_utils_monitor_directory(const char *path, char **errmsg);
605

                
606
/** 
607
 * nntpgrab_utils_cancel_directory_monitor:
608
 * @monitor:       The instance of the NGFileMonitor which needs to be stopped
609
 *
610
 * Cancel the monitoring of a directory
611
 */
612
void             nntpgrab_utils_cancel_directory_monitor(NGFileMonitor *monitor);
613

                
614
/** 
615
 * nntpgrab_utils_test_is_server_already_running:
616
 *
617
 * Find out if the NNTPGrab Server is already running on this computer
618
 *
619
 * Returns: TRUE when a running NNTPGrab Server has been detected on this computer
620
 */
621
ngboolean        nntpgrab_utils_test_is_server_already_running(void);
622

                
623
/** 
624
 * nntpgrab_utils_perform_shutdown:
625
 *
626
 * Shut down the system
627
 *
628
 * Returns: TRUE when a shutdown command has been executed successfully
629
 */
630
ngboolean        nntpgrab_utils_perform_shutdown(void);
631

                
632
#ifdef  __cplusplus
633
}
634
#endif
635

                
636
#endif /* _NNTPGRAB_UTILS_H_ */
637