move code responsible for screen resize to SIGWINCH handler
[ncmpcpp.git] / src / lyrics.h
blob77891bcfad6fd04491c6828919b79bf5f4caa9cf
1 /***************************************************************************
2 * Copyright (C) 2008-2009 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #ifndef _LYRICS_H
22 #define _LYRICS_H
24 #include "ncmpcpp.h"
25 #include "mpdpp.h"
26 #include "screen.h"
28 #ifdef HAVE_CURL_CURL_H
29 # include "curl/curl.h"
30 #endif
32 class Lyrics : public Screen<Scrollpad>
34 struct Plugin
36 const char *url;
37 const char *tag_open;
38 const char *tag_close;
39 bool (*not_found)(const std::string &);
42 public:
43 Lyrics() : itsScrollBegin(0) { }
44 ~Lyrics() { }
46 virtual void Resize();
47 virtual void SwitchTo();
49 virtual std::basic_string<my_char_t> Title();
51 virtual void Update();
53 virtual void EnterPressed() { }
54 virtual void SpacePressed();
56 virtual bool allowsSelection() { return false; }
58 virtual List *GetList() { return 0; }
60 void Edit();
61 void FetchAgain();
63 static bool Reload;
65 # ifdef HAVE_CURL_CURL_H
66 static const char *GetPluginName(int offset);
68 static const unsigned DBs;
69 # endif // HAVE_CURL_CURL_H
71 protected:
72 virtual void Init();
74 private:
75 std::string itsFilenamePath;
77 static const std::string Folder;
79 # ifdef HAVE_CURL_CURL_H
80 static void *Get(void *);
82 # ifdef HAVE_PTHREAD_H
83 void Take();
84 # endif // HAVE_PTHREAD_H
86 static const Plugin *ChoosePlugin(int);
87 static bool LyricsPlugin_NotFound(const std::string &);
89 static bool Ready;
91 # ifdef HAVE_PTHREAD_H
92 static pthread_t *Downloader;
93 # endif // HAVE_PTHREAD_H
95 static const char *PluginsList[];
96 static const Plugin LyricsPlugin;
97 # endif // HAVE_CURL_CURL_H
99 size_t itsScrollBegin;
100 MPD::Song itsSong;
103 extern Lyrics *myLyrics;
105 #endif