Commit c1cabd62bcb14bce55f1beb4bfbff9e1c25a2a91

Authored by Josh Klontz
1 parent e2b99754

removed google gallery

openbr/plugins/gallery/google.cpp deleted
1 -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
2 - * Copyright 2012 The MITRE Corporation *  
3 - * *  
4 - * Licensed under the Apache License, Version 2.0 (the "License"); *  
5 - * you may not use this file except in compliance with the License. *  
6 - * You may obtain a copy of the License at *  
7 - * *  
8 - * http://www.apache.org/licenses/LICENSE-2.0 *  
9 - * *  
10 - * Unless required by applicable law or agreed to in writing, software *  
11 - * distributed under the License is distributed on an "AS IS" BASIS, *  
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *  
13 - * See the License for the specific language governing permissions and *  
14 - * limitations under the License. *  
15 - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */  
16 -  
17 -#include <QtNetwork>  
18 -  
19 -#include <openbr/plugins/openbr_internal.h>  
20 -  
21 -namespace br  
22 -{  
23 -  
24 -/*!  
25 - * \ingroup inputs  
26 - * \brief Input from a google image search.  
27 - * \author Josh Klontz \cite jklontz  
28 - */  
29 -class googleGallery : public Gallery  
30 -{  
31 - Q_OBJECT  
32 -  
33 - TemplateList readBlock(bool *done)  
34 - {  
35 - TemplateList templates;  
36 -  
37 - static const QString search = "http://images.google.com/images?q=%1&start=%2";  
38 - QString query = file.name.left(file.name.size()-7); // remove ".google"  
39 -  
40 -#ifndef BR_EMBEDDED  
41 - QNetworkAccessManager networkAccessManager;  
42 - for (int i=0; i<100; i+=20) { // Retrieve 100 images  
43 - QNetworkRequest request(search.arg(query, QString::number(i)));  
44 - QNetworkReply *reply = networkAccessManager.get(request);  
45 -  
46 - while (!reply->isFinished())  
47 - QThread::yieldCurrentThread();  
48 -  
49 - QString data(reply->readAll());  
50 - delete reply;  
51 -  
52 - QStringList words = data.split("imgurl=");  
53 - words.takeFirst(); // Remove header  
54 - foreach (const QString &word, words) {  
55 - QString url = word.left(word.indexOf("&amp"));  
56 - url = url.replace("%2520","%20");  
57 - int junk = url.indexOf('%', url.lastIndexOf('.'));  
58 - if (junk != -1) url = url.left(junk);  
59 - templates.append(File(url,query));  
60 - }  
61 - }  
62 -#endif // BR_EMBEDDED  
63 -  
64 - *done = true;  
65 - return templates;  
66 - }  
67 -  
68 - void write(const Template &)  
69 - {  
70 - qFatal("Not supported.");  
71 - }  
72 -};  
73 -  
74 -BR_REGISTER(Gallery, googleGallery)  
75 -  
76 -} // namespace br  
77 -  
78 -#include "gallery/google.moc"