Code

added a plugin system for lyrics sources
[ncmpc.git] / src / src_lyrics.h
1 #ifndef SOURCE_LYRICS
2 #define SOURCE_LYRICS
4 #include <stdlib.h>
5 #include <glib.h>
6 #include "list_window.h"
7 #include "mpdclient.h"
8 #include <gmodule.h>
10 typedef struct _formed_text
11 {
12         GString *text;
13         GArray *lines;
14         int val;
15 } formed_text;
17 void formed_text_init(formed_text *text);
18 void add_text_line(formed_text *dest, const char *src, int len);
20 typedef struct _retrieval_spec
21 {
22         mpdclient_t *client;
23         int way;
24 } retrieval_spec;
28 static int lyrics_text_rows = -1;
29 static list_window_t *lw = NULL;
31 GTimer *dltime;
32 short int lock;
33 formed_text lyr_text;
35 guint8 result;
37 /* result is a bitset in which the success when searching 4 lyrics is logged
38 countend by position - backwards
39 0: lyrics in database
40 1: proper access  to the lyrics provider
41 2: lyrics found
42 3: exact match
43 4: lyrics downloaded
44 5: lyrics saved
45 wasting 3 bits doesn't mean being a fat memory hog like kde.... does it?
46 */
49 typedef struct src_lyr src_lyr;
51 struct src_lyr
52 {
53   char *name;
54   char *source_name;
55   char *description;
56   
57   int (*register_src_lyr) (src_lyr *source_descriptor);
58   int (*deregister_src_lyr) ();
60   int (*check_lyr) (char *artist, char *title, char *url);
61   int (*get_lyr) (char *artist, char *title);
62   int (*state_lyr) ();
64 #ifndef DISABLE_PLUGIN_SYSTEM
65   GModule *module;
66 #endif
67 };
69 typedef int (*src_lyr_plugin_register) (src_lyr *source_descriptor);
71 GArray *src_lyr_stack;
73 int init_src_lyr_stack ();
74 int init_src_lyr ();
75 int get_lyr_by_src (int priority, char *artist, char *title);
77 #endif