forked from goldendict/goldendict
-
Notifications
You must be signed in to change notification settings - Fork 1
/
forvo.hh
67 lines (50 loc) · 1.65 KB
/
forvo.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* This file is (c) 2008-2012 Konstantin Isakov <[email protected]>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef __FORVO_HH_INCLUDED__
#define __FORVO_HH_INCLUDED__
#include "dictionary.hh"
#include "config.hh"
#include <QNetworkAccessManager>
#include "wstring.hh"
#include <QNetworkReply>
/// Support for Forvo pronunciations, based on its API.
namespace Forvo {
using std::vector;
using std::string;
using gd::wstring;
vector< sptr< Dictionary::Class > > makeDictionaries(
Dictionary::Initializing &,
Config::Forvo const &,
QNetworkAccessManager & )
throw( std::exception );
/// Exposed here for moc
class ForvoArticleRequest: public Dictionary::DataRequest
{
Q_OBJECT
struct NetReply
{
sptr< QNetworkReply > reply;
string word;
bool finished;
NetReply( sptr< QNetworkReply > const & reply_, string const & word_ ):
reply( reply_ ), word( word_ ), finished( false )
{}
};
typedef std::list< NetReply > NetReplies;
NetReplies netReplies;
QString apiKey, languageCode;
string dictionaryId;
public:
ForvoArticleRequest( wstring const & word, vector< wstring > const & alts,
QString const & apiKey_,
QString const & languageCode_,
string const & dictionaryId_,
QNetworkAccessManager & mgr );
virtual void cancel();
private:
void addQuery( QNetworkAccessManager & mgr, wstring const & word );
private slots:
virtual void requestFinished( QNetworkReply * );
};
}
#endif