1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2008 Shashan Singh <shashank.personal@gmail.com>
4 //
5 
6 #ifndef PANORAMIOPARSER_H
7 #define PANORAMIOPARSER_H
8 
9 #include <QScriptEngine>
10 #include <QList>
11 
12 /**
13 This is a generic class built up for parsing Json that is JavaScript Object Notification
14 FIXME: the class presently has no sanity checking mechanism, it just can't check whether the input given to it is only JSON or Javascript ; a point of potential breach for the software.
15 sanity checking would include :
16 (1)regex matching for following characters "" {} , [a-zA-Z] everything else should be discarded (but some unicode names could pose problem)
17 (2)checking for javascript constructs and eliminating them.
18 (3)some other plan that i have yet not thought upon :)
19     @author Shashank Singh
20 */
21 struct panoramioDataStructure
22 {
23     long int count;// Total number of photographs will be stored in this int
24     long int photo_id ; // Id of each photograph
25     QString photo_title; // Title of each photograph
26     QString photo_url; // Url of each photograph
27     QString photo_file_url;
28     qreal longitude;
29     qreal latitude;
30     int width;
31     int height;
32     QDate upload_date;
33     long int owner_id;
34     QString owner_name;
35     QString owner_url; // Url of the User Uplaoded
36 };
37 
38 class PanoramioParser
39 {
40 public:
41     PanoramioParser();
42 
43     ~PanoramioParser();
44 
45     panoramioDataStructure parseObjectOnPosition(const QString &content, int requiredObjectPosition);   //for parsing single object
46 
47     QList<panoramioDataStructure> parseAllObjects(const QString &content, int number);   //for parsing a list objects
48 
49 private:
50     QList <panoramioDataStructure> parsedJsonOutput;
51 
52     panoramioDataStructure dataStorage;
53 
54     QScriptEngine myEngine;
55 };
56 
57 
58 #endif
59