Merge lp:~air-dex/reyn-tweets/qt5port into lp:reyn-tweets

Proposed by air-dex
Status: Merged
Merged at revision: 545
Proposed branch: lp:~air-dex/reyn-tweets/qt5port
Merge into: lp:reyn-tweets
Diff against target: 51032 lines (+26365/-13748)
340 files modified
ReynTweets.pro (+160/-514)
conf/ReynTweetsSettings.conf (+1/-1)
conf/configuration.pri (+42/-0)
connection/common/authenticators/apikeyauthenticator.cpp (+43/-0)
connection/common/authenticators/apikeyauthenticator.hpp (+57/-0)
connection/common/authenticators/basicauthenticators.hpp (+47/-0)
connection/common/authenticators/oauth/oauth10aauthenticator.cpp (+300/-0)
connection/common/authenticators/oauth/oauth10aauthenticator.hpp (+237/-0)
connection/common/authenticators/oauth/oauth2authenticator.cpp (+75/-0)
connection/common/authenticators/oauth/oauth2authenticator.hpp (+68/-0)
connection/common/authenticators/oauth/oauthauthenticator.cpp (+46/-0)
connection/common/authenticators/oauth/oauthauthenticator.hpp (+66/-0)
connection/common/authenticators/oauth/oauthutils.cpp (+86/-0)
connection/common/authenticators/oauth/oauthutils.hpp (+56/-0)
connection/common/calls/genericcalls.cpp (+22/-33)
connection/common/calls/genericcalls.hpp (+5/-10)
connection/common/calls/requestermanager.cpp (+26/-12)
connection/common/calls/requestermanager.hpp (+10/-3)
connection/common/calls/requestinfos.hpp (+9/-32)
connection/common/communicators/twittercommunicator.cpp (+137/-199)
connection/common/communicators/twittercommunicator.hpp (+16/-56)
connection/common/httprequesttype.hpp (+18/-18)
connection/common/networkresult.cpp (+88/-0)
connection/common/networkresult.hpp (+104/-0)
connection/common/networkresulttype.hpp (+40/-35)
connection/common/requestresult.hpp (+12/-4)
connection/common/requests/genericrequester.cpp (+58/-50)
connection/common/requests/genericrequester.hpp (+35/-30)
connection/common/requests/identificationway.hpp (+11/-9)
connection/common/responseinfos.hpp (+12/-3)
connection/common/resultwrapper.cpp (+1/-1)
connection/common/utils/connectionutils.cpp (+11/-81)
connection/common/utils/connectionutils.hpp (+8/-54)
connection/common/utils/httpcode.hpp (+286/-0)
connection/common/utils/librtconstants.cpp (+48/-0)
connection/common/utils/librtconstants.hpp (+57/-0)
connection/common/utils/parsers/genericparser.hpp (+5/-5)
connection/common/utils/parsers/htmlparser.cpp (+13/-7)
connection/common/utils/parsers/htmlparser.hpp (+4/-4)
connection/common/utils/parsers/jsonparser.cpp (+31/-20)
connection/common/utils/parsers/jsonparser.hpp (+12/-12)
connection/common/utils/parsers/oauthparser.cpp (+18/-60)
connection/common/utils/parsers/oauthparser.hpp (+4/-19)
connection/common/utils/parsers/xmlparser.cpp (+11/-6)
connection/common/utils/parsers/xmlparser.hpp (+4/-4)
connection/libRT.pri (+99/-0)
connection/model/requestinfos.cpp (+0/-49)
connection/requests/twitter/oauth/authenticaterequester.cpp (+0/-130)
connection/requests/twitter/oauth/authenticaterequester.hpp (+0/-66)
connection/requests/twitter/oauth/postauthorizerequester.cpp (+0/-228)
connection/requests/twitter/oauth/postauthorizerequester.hpp (+0/-83)
connection/twitlonger/requests/posttotwitlongerrequester.cpp (+9/-6)
connection/twitlonger/requests/posttotwitlongerrequester.hpp (+8/-6)
connection/twitlonger/requests/sendidtotwitlongerrequester.cpp (+2/-2)
connection/twitlonger/requests/sendidtotwitlongerrequester.hpp (+1/-1)
connection/twitlonger/requests/twitlongerrequester.cpp (+36/-23)
connection/twitlonger/requests/twitlongerrequester.hpp (+27/-13)
connection/twitlonger/requests/twitlongerurls.cpp (+5/-4)
connection/twitlonger/requests/twitlongerurls.hpp (+4/-3)
connection/twitlonger/twitlonger.pri (+46/-0)
connection/twitlonger/twitlongerauthenticator.cpp (+8/-18)
connection/twitlonger/twitlongerauthenticator.hpp (+11/-26)
connection/twitlonger/twitlongercalls.cpp (+2/-2)
connection/twitlonger/twitlongercalls.hpp (+8/-7)
connection/twitlonger/twitlongerconstants.cpp (+35/-0)
connection/twitlonger/twitlongerconstants.hpp (+40/-0)
connection/twitter/requests/accounts/verifycredentialsrequester.cpp (+4/-4)
connection/twitter/requests/accounts/verifycredentialsrequester.hpp (+3/-3)
connection/twitter/requests/favorites/favoriterequester.cpp (+5/-5)
connection/twitter/requests/favorites/favoriterequester.hpp (+2/-2)
connection/twitter/requests/favorites/favoritestimelinerequester.cpp (+14/-14)
connection/twitter/requests/favorites/favoritestimelinerequester.hpp (+22/-22)
connection/twitter/requests/oauth/accesstokenrequester.cpp (+76/-79)
connection/twitter/requests/oauth/accesstokenrequester.hpp (+12/-4)
connection/twitter/requests/oauth/authorizerequester.cpp (+122/-103)
connection/twitter/requests/oauth/authorizerequester.hpp (+38/-4)
connection/twitter/requests/oauth/oauthrequester.cpp (+26/-15)
connection/twitter/requests/oauth/oauthrequester.hpp (+50/-30)
connection/twitter/requests/oauth/requesttokenrequester.cpp (+70/-64)
connection/twitter/requests/oauth/requesttokenrequester.hpp (+10/-4)
connection/twitter/requests/searches/searchrequester.cpp (+2/-2)
connection/twitter/requests/searches/searchrequester.hpp (+2/-2)
connection/twitter/requests/timelines/hometimelinerequester.cpp (+5/-5)
connection/twitter/requests/timelines/hometimelinerequester.hpp (+10/-10)
connection/twitter/requests/timelines/mentionstimelinerequester.cpp (+6/-6)
connection/twitter/requests/timelines/mentionstimelinerequester.hpp (+10/-10)
connection/twitter/requests/tweets/destroytweetrequester.cpp (+3/-3)
connection/twitter/requests/tweets/destroytweetrequester.hpp (+2/-2)
connection/twitter/requests/tweets/posttweetrequester.cpp (+7/-7)
connection/twitter/requests/tweets/posttweetrequester.hpp (+11/-11)
connection/twitter/requests/tweets/retweetrequester.cpp (+3/-3)
connection/twitter/requests/tweets/retweetrequester.hpp (+2/-2)
connection/twitter/requests/tweets/showtweetrequester.cpp (+3/-3)
connection/twitter/requests/tweets/showtweetrequester.hpp (+3/-3)
connection/twitter/requests/twitterrequester.cpp (+139/-122)
connection/twitter/requests/twitterrequester.hpp (+47/-43)
connection/twitter/requests/twitterrequests.hpp (+0/-1)
connection/twitter/requests/twitterurls.cpp (+21/-20)
connection/twitter/requests/twitterurls.hpp (+4/-3)
connection/twitter/requests/users/showuserrequester.cpp (+9/-9)
connection/twitter/requests/users/showuserrequester.hpp (+8/-8)
connection/twitter/reyntwittercalls.cpp (+11/-17)
connection/twitter/reyntwittercalls.hpp (+55/-58)
connection/twitter/twitter.pri (+72/-0)
connection/twitter/twitterauthenticator.cpp (+17/-353)
connection/twitter/twitterauthenticator.hpp (+21/-272)
connection/twitter/twitterconstants.cpp (+69/-0)
connection/twitter/twitterconstants.hpp (+60/-0)
doc/Doxyfile.txt (+1884/-317)
doc/documentation.pri (+58/-0)
i18n/reyntweets_en.ts (+420/-430)
i18n/reyntweets_fr.ts (+423/-431)
i18n/translation.pri (+94/-0)
logic/controls/allowcontrol.cpp (+219/-152)
logic/controls/allowcontrol.hpp (+49/-76)
logic/controls/controls.hpp (+12/-1)
logic/controls/controls.pri (+72/-0)
logic/controls/genericcontrol.cpp (+1/-1)
logic/controls/genericcontrol.hpp (+7/-7)
logic/controls/launchingcontrol.cpp (+26/-26)
logic/controls/launchingcontrol.hpp (+21/-22)
logic/controls/listhandlers/contributorshandler.cpp (+97/-0)
logic/controls/listhandlers/contributorshandler.hpp (+132/-0)
logic/controls/listhandlers/geocoordhandler.cpp (+129/-0)
logic/controls/listhandlers/geocoordhandler.hpp (+181/-0)
logic/controls/listhandlers/geocoordpolygonhandler.cpp (+99/-0)
logic/controls/listhandlers/geocoordpolygonhandler.hpp (+134/-0)
logic/controls/listhandlers/hashtagshandler.cpp (+97/-0)
logic/controls/listhandlers/hashtagshandler.hpp (+132/-0)
logic/controls/listhandlers/indexboundshandler.cpp (+129/-0)
logic/controls/listhandlers/indexboundshandler.hpp (+190/-0)
logic/controls/listhandlers/listhandler.cpp (+185/-0)
logic/controls/listhandlers/listhandler.hpp (+225/-0)
logic/controls/listhandlers/listhandler.tpp (+30/-0)
logic/controls/listhandlers/mediashandler.cpp (+97/-0)
logic/controls/listhandlers/mediashandler.hpp (+132/-0)
logic/controls/listhandlers/mentionshandler.cpp (+97/-0)
logic/controls/listhandlers/mentionshandler.hpp (+132/-0)
logic/controls/listhandlers/objectlisthandler.cpp (+72/-0)
logic/controls/listhandlers/objectlisthandler.hpp (+71/-0)
logic/controls/listhandlers/objectlisthandler.tpp (+30/-0)
logic/controls/listhandlers/timelinehandler.cpp (+138/-0)
logic/controls/listhandlers/timelinehandler.hpp (+228/-0)
logic/controls/listhandlers/urlshandler.cpp (+97/-0)
logic/controls/listhandlers/urlshandler.hpp (+131/-0)
logic/controls/logincontrol.cpp (+0/-71)
logic/controls/logincontrol.hpp (+0/-108)
logic/controls/reyncontrol.cpp (+5/-2)
logic/controls/settingscontrol.cpp (+38/-34)
logic/controls/settingscontrol.hpp (+20/-27)
logic/controls/timelinecontrol.cpp (+181/-326)
logic/controls/timelinecontrol.hpp (+16/-75)
logic/controls/tweetcontrol.cpp (+163/-151)
logic/controls/tweetcontrol.hpp (+32/-16)
logic/controls/writetweetcontrol.cpp (+52/-51)
logic/controls/writetweetcontrol.hpp (+30/-17)
logic/core/configuration/appconfiguration.cpp (+303/-0)
logic/core/configuration/appconfiguration.hpp (+290/-0)
logic/core/configuration/useraccount.cpp (+64/-50)
logic/core/configuration/useraccount.hpp (+55/-36)
logic/core/configuration/userconfiguration.cpp (+311/-0)
logic/core/configuration/userconfiguration.hpp (+256/-0)
logic/core/core.pri (+120/-0)
logic/core/coreresult.cpp (+35/-17)
logic/core/coreresult.hpp (+224/-171)
logic/core/geo/coordinates.cpp (+97/-0)
logic/core/geo/coordinates.hpp (+130/-0)
logic/core/geo/coordinatestype.cpp (+56/-0)
logic/core/geo/coordinatestype.hpp (+56/-0)
logic/core/geo/gencoord.cpp (+107/-0)
logic/core/geo/gencoord.hpp (+154/-0)
logic/core/geo/genericcoordinates.cpp (+118/-0)
logic/core/geo/genericcoordinates.hpp (+126/-0)
logic/core/geo/genericcoordinates.tpp (+33/-0)
logic/core/geo/geoboundingbox.cpp (+94/-0)
logic/core/geo/geoboundingbox.hpp (+127/-0)
logic/core/geo/geocoord.cpp (+136/-0)
logic/core/geo/geocoord.hpp (+151/-0)
logic/core/geo/geocoordlist.cpp (+61/-0)
logic/core/geo/geocoordlist.hpp (+98/-0)
logic/core/geo/geocoordpolygon.cpp (+61/-0)
logic/core/geo/geocoordpolygon.hpp (+99/-0)
logic/core/geo/twitterplace.cpp (+276/-0)
logic/core/geo/twitterplace.hpp (+454/-0)
logic/core/json/jsonarray.cpp (+165/-0)
logic/core/json/jsonarray.hpp (+125/-0)
logic/core/json/jsonarray.tpp (+33/-0)
logic/core/json/jsonarrayarray.cpp (+59/-0)
logic/core/json/jsonarrayarray.hpp (+62/-0)
logic/core/json/jsonarrayarray.tpp (+30/-0)
logic/core/json/jsonobject.cpp (+85/-0)
logic/core/json/jsonobject.hpp (+100/-0)
logic/core/json/jsonobjectarray.cpp (+59/-0)
logic/core/json/jsonobjectarray.hpp (+62/-0)
logic/core/json/jsonobjectarray.tpp (+30/-0)
logic/core/json/jsonvariantablearray.cpp (+55/-0)
logic/core/json/jsonvariantablearray.hpp (+64/-0)
logic/core/json/jsonvariantablearray.tpp (+30/-0)
logic/core/reyncore.cpp (+76/-171)
logic/core/reyncore.hpp (+97/-230)
logic/core/reyntweetsentities.hpp (+61/-0)
logic/core/timelines/timeline.cpp (+44/-43)
logic/core/timelines/timeline.hpp (+24/-84)
logic/core/tweets/hashtag.cpp (+67/-34)
logic/core/tweets/hashtag.hpp (+44/-4)
logic/core/tweets/hashtaglist.cpp (+5/-7)
logic/core/tweets/hashtaglist.hpp (+4/-5)
logic/core/tweets/indexbounds.cpp (+53/-34)
logic/core/tweets/indexbounds.hpp (+32/-22)
logic/core/tweets/media.cpp (+140/-45)
logic/core/tweets/media.hpp (+183/-21)
logic/core/tweets/medialist.cpp (+6/-8)
logic/core/tweets/medialist.hpp (+5/-7)
logic/core/tweets/mediasize.cpp (+63/-14)
logic/core/tweets/mediasize.hpp (+77/-13)
logic/core/tweets/mediasizes.cpp (+103/-68)
logic/core/tweets/mediasizes.hpp (+128/-64)
logic/core/tweets/retweetinfos.cpp (+57/-16)
logic/core/tweets/retweetinfos.hpp (+41/-3)
logic/core/tweets/tweet.cpp (+560/-267)
logic/core/tweets/tweet.hpp (+631/-232)
logic/core/tweets/tweetentities.cpp (+95/-72)
logic/core/tweets/tweetentities.hpp (+107/-57)
logic/core/tweets/tweetentity.cpp (+31/-18)
logic/core/tweets/tweetentity.hpp (+44/-20)
logic/core/tweets/urlentity.cpp (+82/-35)
logic/core/tweets/urlentity.hpp (+68/-6)
logic/core/tweets/urlentitylist.cpp (+5/-7)
logic/core/tweets/urlentitylist.hpp (+3/-5)
logic/core/tweets/usermention.cpp (+98/-44)
logic/core/tweets/usermention.hpp (+85/-8)
logic/core/tweets/usermentionlist.cpp (+5/-7)
logic/core/tweets/usermentionlist.hpp (+3/-5)
logic/core/users/contributor.cpp (+179/-0)
logic/core/users/contributor.hpp (+269/-0)
logic/core/users/contributorlist.cpp (+61/-0)
logic/core/users/contributorlist.hpp (+97/-0)
logic/core/users/user.cpp (+43/-30)
logic/core/users/user.hpp (+41/-14)
logic/core/users/userentities.cpp (+162/-0)
logic/core/users/userentities.hpp (+221/-0)
logic/core/users/userinfos.cpp (+658/-428)
logic/core/users/userinfos.hpp (+685/-281)
logic/core/variantable.hpp (+67/-0)
logic/logic.pri (+59/-0)
logic/processes/allowprocess.cpp (+0/-180)
logic/processes/allowprocess.hpp (+0/-86)
logic/processes/deletetweetprocess.cpp (+71/-75)
logic/processes/deletetweetprocess.hpp (+2/-2)
logic/processes/favoriteprocess.cpp (+1/-1)
logic/processes/genericprocess.cpp (+25/-31)
logic/processes/genericprocess.hpp (+35/-29)
logic/processes/gettweetprocess.cpp (+1/-1)
logic/processes/launchingprocess.cpp (+119/-141)
logic/processes/launchingprocess.hpp (+29/-19)
logic/processes/loadinghometimelineprocess.cpp (+1/-1)
logic/processes/loadinghometimelineprocess.hpp (+9/-8)
logic/processes/loadmentionstimelineprocess.cpp (+1/-1)
logic/processes/loadmentionstimelineprocess.hpp (+10/-9)
logic/processes/oauth/accesstokensprocess.cpp (+268/-0)
logic/processes/oauth/accesstokensprocess.hpp (+136/-0)
logic/processes/oauth/requesttokensprocess.cpp (+208/-0)
logic/processes/oauth/requesttokensprocess.hpp (+89/-0)
logic/processes/oauthprocess.cpp (+0/-410)
logic/processes/oauthprocess.hpp (+0/-148)
logic/processes/posttweetprocess.cpp (+12/-45)
logic/processes/posttweetprocess.hpp (+15/-67)
logic/processes/postviatwitlongerprocess.cpp (+98/-154)
logic/processes/postviatwitlongerprocess.hpp (+19/-85)
logic/processes/processes.hpp (+4/-2)
logic/processes/processes.pri (+77/-0)
logic/processes/processmanager.cpp (+9/-9)
logic/processes/processmanager.hpp (+10/-3)
logic/processes/processresult.hpp (+8/-16)
logic/processes/processutils.cpp (+83/-86)
logic/processes/processutils.hpp (+24/-57)
logic/processes/refreshhometimelineprocess.cpp (+65/-0)
logic/processes/refreshhometimelineprocess.hpp (+85/-0)
logic/processes/refreshmentionstimelineprocess.cpp (+67/-0)
logic/processes/refreshmentionstimelineprocess.hpp (+79/-0)
logic/processes/refreshtimelineprocess.cpp (+235/-0)
logic/processes/refreshtimelineprocess.hpp (+167/-0)
logic/processes/retweetprocess.cpp (+1/-1)
logic/processes/singletwittercallprocess.cpp (+39/-56)
logic/processes/singletwittercallprocess.hpp (+80/-102)
logic/reyntweets.cpp (+170/-0)
logic/reyntweets.hpp (+66/-0)
logic/reyntweetsutils.cpp (+110/-0)
logic/reyntweetsutils.hpp (+117/-0)
main.cpp (+24/-88)
model/configuration/reyntweetsappconfiguration.cpp (+0/-197)
model/configuration/reyntweetsappconfiguration.hpp (+0/-159)
model/configuration/reyntweetsuserconfiguration.cpp (+0/-223)
model/configuration/reyntweetsuserconfiguration.hpp (+0/-227)
model/reyntweetslistable.cpp (+0/-157)
model/reyntweetslistable.hpp (+0/-99)
model/reyntweetslistable.tpp (+0/-35)
model/reyntweetsmappable.cpp (+0/-98)
model/reyntweetsmappable.hpp (+0/-142)
model/reyntweetsserializable.hpp (+0/-49)
resources/resources.pri (+51/-0)
tools/qmldebug.hpp (+0/-53)
tools/twitter-text-1.4.16.js (+0/-1114)
ui/qml/LaunchingPane.qml (+47/-25)
ui/qml/MainPage.qml (+0/-34)
ui/qml/MainView.qml (+4/-3)
ui/qml/base_components/ActionElement.qml (+4/-3)
ui/qml/base_components/Constants.qml (+130/-26)
ui/qml/base_components/FormField.qml (+5/-5)
ui/qml/base_components/GenericActionPane.qml (+4/-4)
ui/qml/base_components/RTButton.qml (+2/-2)
ui/qml/base_components/ScrollBar.qml (+2/-1)
ui/qml/base_components/TwoButtonsActionPane.qml (+5/-5)
ui/qml/info_display/QuitPane.qml (+4/-3)
ui/qml/info_display/TransientPane.qml (+3/-3)
ui/qml/info_display/TryAgainPane.qml (+1/-1)
ui/qml/info_display/WarningTransientPane.qml (+1/-1)
ui/qml/js/jstools.js (+1/-1)
ui/qml/js/twitter-text-1.6.1.js (+1333/-0)
ui/qml/js/twitter-text-js-wrapper.js (+6/-4)
ui/qml/login/LoginComponents.qml (+15/-14)
ui/qml/login/LoginPane.qml (+177/-214)
ui/qml/main_desktop.qml (+6/-3)
ui/qml/main_symbian.qml (+0/-41)
ui/qml/mainview_panes/AboutPane.qml (+46/-25)
ui/qml/mainview_panes/AccountPane.qml (+5/-6)
ui/qml/mainview_panes/RTDesktopMenu.qml (+2/-2)
ui/qml/mainview_panes/SettingsPane.qml (+7/-8)
ui/qml/mainview_panes/TweetPane.qml (+44/-39)
ui/qml/mainview_panes/WriteTweetPane.qml (+17/-10)
ui/qml/mainview_panes/timeline_panes/HomeTimelineTab.qml (+5/-5)
ui/qml/mainview_panes/timeline_panes/MentionsTimelineTab.qml (+5/-5)
ui/qml/mainview_panes/timeline_panes/TimelinePane.qml (+29/-19)
ui/qmlapplicationviewer.cpp (+0/-198)
ui/qmlapplicationviewer.hpp (+0/-76)
ui/qmlapplicationviewer.pri (+0/-175)
ui/qtquick2applicationviewer.cpp (+101/-0)
ui/qtquick2applicationviewer.hpp (+65/-0)
ui/qtquick2applicationviewer.pri (+185/-0)
ui/reyntweetsui.pri (+59/-0)
To merge this branch: bzr merge lp:~air-dex/reyn-tweets/qt5port
Reviewer Review Type Date Requested Status
air-dex Approve
Review via email: mp+180962@code.launchpad.net

Commit message

[Qt5 bump] Merge with trunk

Description of the change

Merge the Qt5 port work with the trunk.

To post a comment you must log in.
Revision history for this message
air-dex (air-dex) wrote :

Merge OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ReynTweets.pro'
--- ReynTweets.pro 2013-02-15 23:30:42 +0000
+++ ReynTweets.pro 2013-08-20 00:10:09 +0000
@@ -1,514 +1,160 @@
1#-----------------------------------#1#-----------------------------------#
2# ReynTweets.pro #2# ReynTweets.pro #
3# Reyn Tweets' Qt .pro project file #3# Reyn Tweets' Qt .pro project file #
4# Auteur : Romain Ducher #4# Auteur : Romain Ducher #
5#-----------------------------------#5#-----------------------------------#
66
7#-----------------------------------------------------------------------------#7#-----------------------------------------------------------------------------#
8# #8# #
9# Copyright 2011 Romain Ducher #9# Copyright 2011 Romain Ducher #
10# #10# #
11# This file is part of Reyn Tweets. #11# This file is part of Reyn Tweets. #
12# #12# #
13# Reyn Tweets is free software: you can redistribute it and/or modify #13# Reyn Tweets is free software: you can redistribute it and/or modify #
14# it under the terms of the GNU Lesser General Public License as published by #14# it under the terms of the GNU Lesser General Public License as published by #
15# the Free Software Foundation, either version 3 of the License, or #15# the Free Software Foundation, either version 3 of the License, or #
16# (at your option) any later version. #16# (at your option) any later version. #
17# #17# #
18# Reyn Tweets is distributed in the hope that it will be useful, #18# Reyn Tweets is distributed in the hope that it will be useful, #
19# but WITHOUT ANY WARRANTY; without even the implied warranty of #19# but WITHOUT ANY WARRANTY; without even the implied warranty of #
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
21# GNU Lesser General Public License for more details. #21# GNU Lesser General Public License for more details. #
22# #22# #
23# You should have received a copy of the GNU Lesser General Public License #23# You should have received a copy of the GNU Lesser General Public License #
24# along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. #24# along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. #
25# #25# #
26#-----------------------------------------------------------------------------#26#-----------------------------------------------------------------------------#
2727
28#-------------------------------------------------------------#28#-------------------------------------------------------------#
29# This file was known as ReynTweets.pri between r232 and r355 #29# This file was known as ReynTweets.pri between r232 and r355 #
30#-------------------------------------------------------------#30#-------------------------------------------------------------#
3131
3232
33#----------------------#33#----------------------#
34# Common configuration #34# Common configuration #
35#----------------------#35#----------------------#
3636
37QT += core gui network webkit declarative xml37QT += core gui network webkitwidgets declarative xml
3838
39TARGET = ReynTweets39TARGET = ReynTweets
40TEMPLATE = app40TEMPLATE = app
4141
4242
43#--------------#43#--------------#
44# Source files #44# Source files #
45#--------------#45#--------------#
4646
47# NB : the QML Application Viewer is here in a .pri :47# connection (libRT)
48# ui/qmlapplicationviewer.pri48include(connection/libRT.pri)
4949
50SOURCES += \50# logic
51 tools/utils.cpp \51include(logic/logic.pri)
52 tools/reyntweetsdatetime.cpp \52
53 tools/parsers/htmlparser.cpp \53# UI (with the QML Application Viewer)
54 tools/parsers/jsonparser.cpp \54include(ui/reyntweetsui.pri)
55 tools/parsers/oauthparser.cpp \55
56 tools/parsers/xmlparser.cpp \56SOURCES += \
57 connection/model/managers/oauthmanager.cpp \57 main.cpp
58 connection/model/managers/twitlongermanager.cpp \58
59 connection/twittercommunicators/twittercommunicator.cpp \59HEADERS += \
60 connection/requests/twitlonger/twitlongerurls.cpp \60
61 connection/requests/twitter/twitterurls.cpp \61OTHER_FILES = \
62 connection/model/resultwrapper.cpp \62 .bzrignore \
63 connection/requests/genericrequester.cpp \63 connection/libRT.pri \
64 connection/requests/twitter/twitterrequester.cpp \64 logic/logic.pri \
65 connection/requests/twitter/accounts/verifycredentialsrequester.cpp \65 ui/reyntweetsui.pri \
66 connection/requests/twitter/favorites/favoriterequester.cpp \66 conf/configuration.pri \
67 connection/requests/twitter/favorites/favoritestimelinerequester.cpp \67 doc/documentation.pri \
68 connection/requests/twitter/oauth/oauthrequester.cpp \68 i18n/translation.pri \
69 connection/requests/twitter/oauth/requesttokenrequester.cpp \69 resources/resources.pri
70 connection/requests/twitter/oauth/authorizerequester.cpp \70
71 connection/requests/twitter/oauth/postauthorizerequester.cpp \71#---------------------------------------#
72 connection/requests/twitter/oauth/accesstokenrequester.cpp \72# Directories for mocs and object files #
73 connection/requests/twitter/searches/searchrequester.cpp \73#---------------------------------------#
74 connection/requests/twitter/timelines/hometimelinerequester.cpp \74
75 connection/requests/twitter/timelines/mentionstimelinerequester.cpp \75MOC_DIR = mocs
76 connection/requests/twitter/tweets/destroytweetrequester.cpp \76OBJECTS_DIR = obj
77 connection/requests/twitter/tweets/posttweetrequester.cpp \77
78 connection/requests/twitter/tweets/retweetrequester.cpp \78
79 connection/requests/twitter/tweets/showtweetrequester.cpp \79#-------------------------------------#
80 connection/requests/twitter/users/showuserrequester.cpp \80# Extra targets - General definitions #
81 connection/requests/twitlonger/twitlongerrequester.cpp \81#-------------------------------------#
82 connection/requests/twitlonger/posttotwitlongerrequester.cpp \82
83 connection/requests/twitlonger/sendidtotwitlongerrequester.cpp \83# RMDIR_CMD : Command to delete directories
84 connection/model/requestinfos.cpp \84# RMFILE_CMD : Command to delete files
85 connection/model/requestermanager.cpp \85# COPY_CMD : Command to copy files
86 connection/calls/genericcalls.cpp \86
87 connection/calls/reyntwittercalls.cpp \87win32 {
88 connection/calls/twitlongercalls.cpp \88 RMDIR_CMD = rd /s /q
89 model/reyntweetslistable.cpp \89 RMFILE_CMD = del /s /q
90 model/reyntweetsmappable.cpp \90 COPY_CMD = copy /y
91 model/tweets/tweetentity.cpp \91}
92 model/tweets/indexbounds.cpp \92
93 model/tweets/mediasize.cpp \93linux-g++ {
94 model/tweets/mediasizes.cpp \94 RMDIR_CMD = rm -rfv
95 model/tweets/media.cpp \95 RMFILE_CMD = rm -rfv
96 model/tweets/medialist.cpp \96 COPY_CMD = cp -v
97 model/tweets/urlentity.cpp \97}
98 model/tweets/urlentitylist.cpp \98
99 model/tweets/usermention.cpp \99
100 model/tweets/usermentionlist.cpp \100#--------------------------#
101 model/tweets/hashtag.cpp \101# Non coding project parts #
102 model/tweets/hashtaglist.cpp \102#--------------------------#
103 model/tweets/tweetentities.cpp \103
104 model/users/userinfos.cpp \104# Configuration files
105 model/tweets/retweetinfos.cpp \105include(conf/configuration.pri)
106 model/tweets/tweet.cpp \106
107 model/timelines/timeline.cpp \107# Documentation targets
108 model/users/user.cpp \108include(doc/documentation.pri)
109 model/configuration/reyntweetsappconfiguration.cpp \109
110 model/configuration/useraccount.cpp \110# Translations targets
111 model/configuration/reyntweetsuserconfiguration.cpp \111include(i18n/translation.pri)
112 logic/processes/processwrapper.cpp \112
113 tools/processutils.cpp \113# (Graphical) resources
114 logic/processes/genericprocess.cpp \114include(resources/resources.pri)
115 logic/processes/singletwittercallprocess.cpp \115
116 logic/processes/retweetprocess.cpp \116
117 logic/processes/oauthprocess.cpp \117#---------------------------#
118 logic/processes/allowprocess.cpp \118# Qt Components for Desktop #
119 logic/processes/deletetweetprocess.cpp \119#---------------------------#
120 logic/processes/favoriteprocess.cpp \120
121 logic/processes/gettweetprocess.cpp \121# Qt Components for Desktop (http://qt.gitorious.org/qt-components/desktop)
122 logic/processes/launchingprocess.cpp \122# is a library with QML Components for desktop. It is under LGPL license (v2.1).
123 logic/processes/loadinghometimelineprocess.cpp \123# QMLCOMP_DESKTOP_PATH is the location of Qt Components for Desktop in the system.
124 logic/processes/loadmentionstimelineprocess.cpp \124
125 logic/processes/posttweetprocess.cpp \125win32 {
126 logic/processes/postviatwitlongerprocess.cpp \126# QMLCOMP_DESKTOP_PATH = C:\\Libs\\QtComponentsForDesktop
127 logic/processes/processmanager.cpp \127# INCLUDEPATH += $${QMLCOMP_DESKTOP_PATH}\\include
128 logic/reyncore.cpp \128# debug {
129 logic/controls/genericcontrol.cpp \129# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\debug -lstyleplugin
130 logic/controls/allowcontrol.cpp \130# }
131 logic/controls/launchingcontrol.cpp \131# release {
132 logic/controls/logincontrol.cpp \132# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\release -lstyleplugin
133 logic/controls/reyncontrol.cpp \133# }
134 logic/controls/settingscontrol.cpp \134#
135 logic/controls/timelinecontrol.cpp \135}
136 logic/controls/tweetcontrol.cpp \136
137 logic/controls/writetweetcontrol.cpp \137linux {
138 main.cpp \138# QMLCOMP_DESKTOP_PATH = C:\\Libs\\QtComponentsForDesktop
139 logic/coreresult.cpp139# INCLUDEPATH += $${QMLCOMP_DESKTOP_PATH}\\include
140140# debug {
141141# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\debug -lstyleplugin
142HEADERS += \142# }
143 tools/qmldebug.hpp \143# release {
144 tools/utils.hpp \144# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\release -lstyleplugin
145 tools/reyntweetsdatetime.hpp \145# }
146 tools/parsers/genericparser.hpp \146#
147 tools/parsers/htmlparser.hpp \147}
148 tools/parsers/jsonparser.hpp \148
149 tools/parsers/oauthparser.hpp \149
150 tools/parsers/xmlparser.hpp \150#--------------#
151 connection/model/managers/oauthmanager.hpp \151# Miscanellous #
152 connection/model/managers/twitlongermanager.hpp \152#--------------#
153 connection/model/requesttype.hpp \153
154 connection/model/headersmap.hpp \154# If your application uses the Qt Mobility libraries, uncomment the following
155 connection/twittercommunicators/twittercommunicator.hpp \155# lines and add the respective components to the MOBILITY variable.
156 connection/model/errortypes.hpp \156# CONFIG += mobility
157 connection/model/responseinfos.hpp \157# MOBILITY +=
158 connection/requests/twitlonger/twitlongerurls.hpp \158
159 connection/requests/twitter/twitterurls.hpp \159# Required for deployment. DO NOT MODIFY.
160 connection/model/requestresult.hpp \160qtcAddDeployment()
161 connection/model/resultwrapper.hpp \
162 connection/model/identificationway.hpp \
163 connection/requests/genericrequester.hpp \
164 connection/requests/twitter/twitterrequester.hpp \
165 connection/requests/twitter/accounts/verifycredentialsrequester.hpp \
166 connection/requests/twitter/favorites/favoriterequester.hpp \
167 connection/requests/twitter/favorites/favoritestimelinerequester.hpp \
168 connection/requests/twitter/oauth/oauthrequester.hpp \
169 connection/requests/twitter/oauth/requesttokenrequester.hpp \
170 connection/requests/twitter/oauth/authorizerequester.hpp \
171 connection/requests/twitter/oauth/postauthorizerequester.hpp \
172 connection/requests/twitter/oauth/accesstokenrequester.hpp \
173 connection/requests/twitter/searches/searchrequester.hpp \
174 connection/requests/twitter/timelines/hometimelinerequester.hpp \
175 connection/requests/twitter/timelines/mentionstimelinerequester.hpp \
176 connection/requests/twitter/tweets/destroytweetrequester.hpp \
177 connection/requests/twitter/tweets/posttweetrequester.hpp \
178 connection/requests/twitter/tweets/retweetrequester.hpp \
179 connection/requests/twitter/tweets/showtweetrequester.hpp \
180 connection/requests/twitter/users/showuserrequester.hpp \
181 connection/requests/twitter/twitterrequests.hpp \
182 connection/requests/twitlonger/twitlongerrequester.hpp \
183 connection/requests/twitlonger/posttotwitlongerrequester.hpp \
184 connection/requests/twitlonger/sendidtotwitlongerrequester.hpp \
185 connection/requests/twitlonger/twitlongerrequests.hpp \
186 connection/model/requestinfos.hpp \
187 connection/model/requestermanager.hpp \
188 connection/calls/genericcalls.hpp \
189 connection/calls/reyntwittercalls.hpp \
190 connection/calls/twitlongercalls.hpp \
191 model/reyntweetsserializable.hpp \
192 model/reyntweetslistable.hpp \
193 model/reyntweetslistable.tpp \
194 model/reyntweetsmappable.hpp \
195 model/tweets/tweetentity.hpp \
196 model/tweets/indexbounds.hpp \
197 model/tweets/mediasize.hpp \
198 model/tweets/mediasizes.hpp \
199 model/tweets/urlentity.hpp \
200 model/tweets/urlentitylist.hpp \
201 model/tweets/media.hpp \
202 model/tweets/medialist.hpp \
203 model/tweets/usermention.hpp \
204 model/tweets/usermentionlist.hpp \
205 model/tweets/hashtag.hpp \
206 model/tweets/hashtaglist.hpp \
207 model/tweets/tweetentities.hpp \
208 model/users/userinfos.hpp \
209 model/tweets/retweetinfos.hpp \
210 model/tweets/tweet.hpp \
211 model/timelines/timeline.hpp \
212 model/users/user.hpp \
213 model/configuration/reyntweetsappconfiguration.hpp \
214 model/configuration/useraccount.hpp \
215 model/configuration/reyntweetsuserconfiguration.hpp \
216 logic/coreresult.hpp \
217 logic/processes/processresult.hpp \
218 logic/processes/processwrapper.hpp \
219 tools/processutils.hpp \
220 logic/processes/genericprocess.hpp \
221 logic/processes/singletwittercallprocess.hpp \
222 logic/processes/oauthprocess.hpp \
223 logic/processes/allowprocess.hpp \
224 logic/processes/deletetweetprocess.hpp \
225 logic/processes/favoriteprocess.hpp \
226 logic/processes/gettweetprocess.hpp \
227 logic/processes/launchingprocess.hpp \
228 logic/processes/loadinghometimelineprocess.hpp \
229 logic/processes/loadmentionstimelineprocess.hpp \
230 logic/processes/posttweetprocess.hpp \
231 logic/processes/postviatwitlongerprocess.hpp \
232 logic/processes/retweetprocess.hpp \
233 logic/processes/processes.hpp \
234 logic/processes/processinfos.hpp \
235 logic/processes/processmanager.hpp \
236 logic/reyncore.hpp \
237 logic/controls/genericcontrol.hpp \
238 logic/controls/allowcontrol.hpp \
239 logic/controls/launchingcontrol.hpp \
240 logic/controls/logincontrol.hpp \
241 logic/controls/reyncontrol.hpp \
242 logic/controls/settingscontrol.hpp \
243 logic/controls/timelinecontrol.hpp \
244 logic/controls/tweetcontrol.hpp \
245 logic/controls/writetweetcontrol.hpp \
246 logic/controls/controls.hpp
247
248
249OTHER_FILES = \
250 conf/ReynTweets.conf \
251 conf/ReynTweetsEmpty.conf \
252 conf/ReynTweetsSettings.conf \
253 i18n/reyntweets_en.ts \
254 i18n/reyntweets_fr.ts \
255 resources/Logo Reyn Tweets.svg \
256 resources/Logo Reyn Tweets.png \
257 ui/qml/tools.js \
258 ui/qml/twitter-text-js-wrapper.js \
259 ui/qml/twitter-text-1.4.16.js \
260 Doxyfile.txt \
261 .bzrignore \
262 ReynTweets.rc
263
264
265#---------------------------------------#
266# Directories for mocs and object files #
267#---------------------------------------#
268
269MOC_DIR = mocs
270OBJECTS_DIR = obj
271
272
273#----------------------#
274# Icon for the program #
275#----------------------#
276win32 {
277 RC_FILE = ReynTweets.rc
278}
279
280# TODO : Linux, Symbian
281
282
283#--------------#
284# Translations #
285#--------------#
286
287TRANSLATIONS = reyntweets_en.ts reyntweets_fr.ts
288
289
290#-------------------------------------#
291# Extra targets - General definitions #
292#-------------------------------------#
293
294# SEPARATOR : Separator in path systems
295# RMDIR_CMD : Command to delete directories
296# RMFILE_CMD : Command to delete files
297# COPY_CMD : Command to copy files
298
299win32 {
300 # Leave an empty line because of the backslash at the end of the variable
301 SEPARATOR = \\
302
303 RMDIR_CMD = rd /s /q
304 RMFILE_CMD = del /s /q
305 COPY_CMD = copy /y
306}
307
308linux-g++ {
309 SEPARATOR = /
310 RMDIR_CMD = rm -rfv
311 RMFILE_CMD = rm -rfv
312 COPY_CMD = cp -v
313}
314
315
316#-----------------------#
317# Documentation targets #
318#-----------------------#
319
320win32 {
321 DOXYGEN_CMD = C:\\Program Files\\doxygen\\bin\\doxygen.exe
322}
323
324linux-g++ {
325 DOXYGEN_CMD = /usr/bin/doxygen
326}
327
328# Create doc
329doc.target = doc
330doc.commands = $${DOXYGEN_CMD} $${PWD}Doxyfile.txt
331
332# Clean doc
333cleandoc.target = cleandoc
334cleandoc.commands = $${RMDIR_CMD} ..$${SEPARATOR}doc$${SEPARATOR}html
335
336# Extra targets
337QMAKE_EXTRA_TARGETS += doc cleandoc
338
339
340#---------------------#
341# Translation targets #
342#---------------------#
343
344# Folder containing translations
345TR_FOLDER = $${PWD}i18n$${SEPARATOR}
346
347# lupdate
348LUPDATE_FR = lupdate -noobsolete $${PWD} -ts $${TR_FOLDER}reyntweets_fr.ts
349LUPDATE_EN = lupdate -noobsolete $${PWD} -ts $${TR_FOLDER}reyntweets_en.ts
350
351trupdate.target = trupdate
352win32 {
353 trupdate.commands = ($${LUPDATE_FR}) & ($${LUPDATE_EN})
354}
355linux-g++ {
356 trupdate.commands = $${LUPDATE_FR} ; $${LUPDATE_EN}
357}
358
359# lrelease
360LRELEASE_FR = lrelease $${TR_FOLDER}reyntweets_fr.ts
361LRELEASE_EN = lrelease $${TR_FOLDER}reyntweets_en.ts
362
363trrelease.target = trrelease
364win32 {
365 trrelease.commands = ($${LRELEASE_FR}) & ($${LRELEASE_EN})
366}
367linux-g++ {
368 trrelease.commands = $${LRELEASE_FR} ; $${LRELEASE_EN}
369}
370
371# Deploy .qm files in build directories
372trdeploy.target = trdeploy
373trdeploy.commands = $${COPY_CMD} $${TR_FOLDER}*.qm .
374
375# Delete .qm files
376trclean.target = trclean
377trclean.commands = $${RMFILE_CMD} $${TR_FOLDER}*.qm
378
379# Extra targets
380QMAKE_EXTRA_TARGETS += trupdate trrelease trdeploy trclean
381
382
383#------------------------#
384# Folders with QML files #
385#------------------------#
386
387# QML files
388qml_files.source = ui/qml
389qml_files.target = ui
390
391# Resources
392resource.source = resources
393resource.target = .
394
395# Configuration files
396# Uncomment this folder in DEPLOYMENTFOLDERS if you want the configuration to
397# be reset each time the application is launched
398conf_files.source = conf
399conf_files.target = .
400
401DEPLOYMENTFOLDERS = qml_files \
402 resource \
403 conf_files
404
405
406#-------#
407# QJSON #
408#-------#
409
410# QJSON (http://qjson.sourceforge.net/) is an open source parser for JSON
411# written in Qt (LGPLv2.1 license). It is compatible with Windows, Mac, Linux,
412# Symbian and MeeGo.
413# QJSON_PATH is the location of QJSON in the system.
414
415win32 {
416 QJSON_PATH = C:\\Libs\\qjson
417 LIB_QJSON = qjson0
418}
419
420linux-g++ {
421 QJSON_PATH = /home/ducher/Libs/qjson
422 LIB_QJSON = qjson
423}
424
425INCLUDEPATH += $${QJSON_PATH}$${SEPARATOR}include
426LIBS += -L$${QJSON_PATH}$${SEPARATOR}lib -l$${LIB_QJSON}
427
428symbian {
429# QJSON_PATH = # TODO
430# INCLUDEPATH += c:\Libs\Qjson\include
431# LIBS += -Lc:\Libs\Qjson\lib -lqjson
432}
433
434
435#---------------------------#
436# Qt Components for Desktop #
437#---------------------------#
438
439# Qt Components for Desktop (http://qt.gitorious.org/qt-components/desktop)
440# is a library with QML Components for desktop. It is under LGPL license (v2.1).
441# QMLCOMP_DESKTOP_PATH is the location of Qt Components for Desktop in the system.
442
443win32 {
444# QMLCOMP_DESKTOP_PATH = C:\\Libs\\QtComponentsForDesktop
445# INCLUDEPATH += $${QMLCOMP_DESKTOP_PATH}\\include
446# debug {
447# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\debug -lstyleplugin
448# }
449# release {
450# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\release -lstyleplugin
451# }
452#
453}
454
455linux {
456# QMLCOMP_DESKTOP_PATH = C:\\Libs\\QtComponentsForDesktop
457# INCLUDEPATH += $${QMLCOMP_DESKTOP_PATH}\\include
458# debug {
459# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\debug -lstyleplugin
460# }
461# release {
462# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\release -lstyleplugin
463# }
464#
465}
466
467
468#-------------------------------#
469# Symbian special configuration #
470#-------------------------------#
471
472CONFIG += mobility
473MOBILITY =
474
475# Add dependency to Symbian components
476CONFIG += qt-components
477
478symbian {
479
480TARGET.UID3 = 0xE541D97B
481#TARGET.EPOCSTACKSIZE = 0x14000
482#TARGET.EPOCHEAPSIZE = 0x020000 0x800000
483
484# Allow network access on Symbian
485TARGET.CAPABILITY += NetworkServices
486
487# Smart Installer package's UID
488# This UID is from the protected range and therefore the package will
489# fail to install if self-signed. By default qmake uses the unprotected
490# range value if unprotected UID is defined for the application and
491# 0x2002CCCF value if protected UID is given to the application
492#DEPLOYMENT.installer_header = 0x2002CCCF
493
494}
495
496
497#--------------#
498# Miscanellous #
499#--------------#
500
501# Additional import path used to resolve QML modules in Creator's code model
502QML_IMPORT_PATH =
503
504# If your application uses the Qt Mobility libraries, uncomment the following
505# lines and add the respective components to the MOBILITY variable.
506# CONFIG += mobility
507# MOBILITY +=
508
509# Speed up launching on MeeGo/Harmattan when using applauncherd daemon
510# CONFIG += qdeclarative-boostable
511
512# Please do not modify the following two lines. Required for deployment.
513include(ui/qmlapplicationviewer.pri)
514qtcAddDeployment()
515161
=== modified file 'conf/ReynTweets.conf'
516Binary files conf/ReynTweets.conf 2012-05-23 23:43:29 +0000 and conf/ReynTweets.conf 2013-08-20 00:10:09 +0000 differ162Binary files conf/ReynTweets.conf 2012-05-23 23:43:29 +0000 and conf/ReynTweets.conf 2013-08-20 00:10:09 +0000 differ
=== modified file 'conf/ReynTweetsEmpty.conf'
517Binary files conf/ReynTweetsEmpty.conf 2012-05-23 23:43:29 +0000 and conf/ReynTweetsEmpty.conf 2013-08-20 00:10:09 +0000 differ163Binary files conf/ReynTweetsEmpty.conf 2012-05-23 23:43:29 +0000 and conf/ReynTweetsEmpty.conf 2013-08-20 00:10:09 +0000 differ
=== modified file 'conf/ReynTweetsSettings.conf'
--- conf/ReynTweetsSettings.conf 2013-02-15 23:18:12 +0000
+++ conf/ReynTweetsSettings.conf 2013-08-20 00:10:09 +0000
@@ -1,1 +1,1 @@
1{ "callback_url" : "http://twitter.com", "consumer_key" : "V1VsVU16RkZOR0U0TjI5Q1ZGZHFlVVJsVW5jPQ==", "consumer_secret" : "ZHprM2VuVjBVRXBuTmtaNmRGWmxlVE5YTmtWaWNHNTJOMHgyTVdadE5FVlVXR3BzYnpaRmVWUXc=", "pocket_api_key" : "WkdrMFZEQlBNVEpuTVRSaE1YQTBOekZtWkRCYVZ6bDRPV0Z3T0VWaE16ST0=", "twitlonger_api_key" : "VVV0WmMwNTBNMmhOYjI1VFozVnVSQT09", "twitlonger_application_name" : "reyntweets" }1{ "callback_url" : "http://twitter.com", "consumer_key" : "WUlUMzFFNGE4N29CVFdqeURlUnc=", "consumer_secret" : "dzk3enV0UEpnNkZ6dFZleTNXNkVicG52N0x2MWZtNEVUWGpsbzZFeVQw", "pocket_api_key" : "WkdrMFZEQlBNVEpuTVRSaE1YQTBOekZtWkRCYVZ6bDRPV0Z3T0VWaE16ST0=", "twitlonger_api_key" : "UUtZc050M2hNb25TZ3VuRA==", "twitlonger_application_name" : "reyntweets", "data_dir" : { "windows" : "/AppData/Roaming/reyn-tweets", "linux" : "/.config/reyn-tweets" } }
22
=== added file 'conf/configuration.pri'
--- conf/configuration.pri 1970-01-01 00:00:00 +0000
+++ conf/configuration.pri 2013-08-20 00:10:09 +0000
@@ -0,0 +1,42 @@
1#-----------------------------------------#
2# configuration.pri #
3# .pri sub project file for configuration #
4# Author : Romain Ducher #
5#-----------------------------------------#
6
7#-----------------------------------------------------------------------------#
8# #
9# Copyright 2013 Romain Ducher #
10# #
11# This file is part of Reyn Tweets. #
12# #
13# Reyn Tweets is free software: you can redistribute it and/or modify #
14# it under the terms of the GNU Lesser General Public License as published by #
15# the Free Software Foundation, either version 3 of the License, or #
16# (at your option) any later version. #
17# #
18# Reyn Tweets is distributed in the hope that it will be useful, #
19# but WITHOUT ANY WARRANTY; without even the implied warranty of #
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
21# GNU Lesser General Public License for more details. #
22# #
23# You should have received a copy of the GNU Lesser General Public License #
24# along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. #
25# #
26#-----------------------------------------------------------------------------#
27
28OTHER_FILES = \
29 conf/ReynTweets.conf \
30 conf/ReynTweetsEmpty.conf \
31 conf/ReynTweetsSettings.conf
32
33
34#-------------------------------#
35# Deploying configuration files #
36#-------------------------------#
37# Uncomment this folder in DEPLOYMENTFOLDERS if you want the configuration to
38# be reset each time the application is launched
39conf_files.source = conf
40conf_files.target = .
41
42DEPLOYMENTFOLDERS += conf_files
043
=== removed directory 'connection/calls'
=== added directory 'connection/common'
=== added directory 'connection/common/authenticators'
=== added file 'connection/common/authenticators/apikeyauthenticator.cpp'
--- connection/common/authenticators/apikeyauthenticator.cpp 1970-01-01 00:00:00 +0000
+++ connection/common/authenticators/apikeyauthenticator.cpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,43 @@
1/// @file apikeyauthenticator.cpp
2/// @brief Implementation of APIKeyAuthenticator
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#include "apikeyauthenticator.hpp"
25#include "../utils/librtconstants.hpp"
26
27// Constructor
28APIKeyAuthenticator::APIKeyAuthenticator():
29 apiKey(LibRT::FAKE_TOKEN)
30{}
31
32// Destructor
33APIKeyAuthenticator::~APIKeyAuthenticator() {}
34
35// Getting the API Key
36QByteArray APIKeyAuthenticator::getAPIKey() {
37 return apiKey;
38}
39
40// Setting the API Key
41void APIKeyAuthenticator::setAPIKey(QByteArray newAPIKey) {
42 apiKey = newAPIKey;
43}
044
=== added file 'connection/common/authenticators/apikeyauthenticator.hpp'
--- connection/common/authenticators/apikeyauthenticator.hpp 1970-01-01 00:00:00 +0000
+++ connection/common/authenticators/apikeyauthenticator.hpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,57 @@
1/// @file apikeyauthenticator.hpp
2/// @brief Header of APIKeyAuthenticator
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef APIKEYAUTHENTICATOR_HPP
25#define APIKEYAUTHENTICATOR_HPP
26
27#include <QByteArray>
28
29/// @class APIKeyAuthenticator
30/// @brief Base class for Authentication managers with needs a simple API key.
31class APIKeyAuthenticator
32{
33 public:
34 /// @fn APIKeyAuthenticator();
35 /// @brief Constructor
36 APIKeyAuthenticator();
37
38 /// @fn ~APIKeyAuthenticator();
39 /// @brief Destructor
40 ~APIKeyAuthenticator();
41
42 /// @fn QByteArray getAPIKey();
43 /// @brief Getting the API key
44 /// @return apiKey
45 QByteArray getAPIKey();
46
47 /// @fn void setAPIKey(QByteArray newAPIKey);
48 /// @brief Setting the API key
49 /// @param newAPIKey New value for apiKey
50 void setAPIKey(QByteArray newAPIKey);
51
52 protected:
53 /// @brief API Key of the application on TwitLonger
54 QByteArray apiKey;
55};
56
57#endif // APIKEYAUTHENTICATOR_HPP
058
=== added file 'connection/common/authenticators/basicauthenticators.hpp'
--- connection/common/authenticators/basicauthenticators.hpp 1970-01-01 00:00:00 +0000
+++ connection/common/authenticators/basicauthenticators.hpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,47 @@
1/// @file basicauthenticators.hpp
2/// @brief Typedefs of BasicAuthenticator and TokenPair
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef BASICAUTHENTICATORS_HPP
25#define BASICAUTHENTICATORS_HPP
26
27#include <QByteArray>
28#include <QPair>
29#include <QString>
30
31/// @typedef QPair <QString, QByteArray> BasicAuthenticator;
32/// @brief QPair for classic authentications with a login and a pasword :<ul>
33/// <li>first : the login.</li>
34/// <li>secret : the password.</li></ul>
35/// @see TokenPair
36typedef QPair<QString, QByteArray> BasicAuthenticator;
37
38/// @typedef QPair<QByteArray, QByteArray> TokenPair;
39/// @brief A token pair.
40///
41/// A token pair is a QPair whose field are:<ul>
42/// <li>first : the public key (token).</li>
43/// <li>secret : the private key (secret).</li>
44/// </ul>
45typedef QPair<QByteArray, QByteArray> TokenPair;
46
47#endif // BASICAUTHENTICATORS_HPP
048
=== added directory 'connection/common/authenticators/oauth'
=== added file 'connection/common/authenticators/oauth/oauth10aauthenticator.cpp'
--- connection/common/authenticators/oauth/oauth10aauthenticator.cpp 1970-01-01 00:00:00 +0000
+++ connection/common/authenticators/oauth/oauth10aauthenticator.cpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,300 @@
1/// @file oauth10aauthenticator.cpp
2/// @brief Implementation of OAuth10aAuthenticator
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#include "oauth10aauthenticator.hpp"
25
26#include <QUrl>
27#include "oauthutils.hpp"
28#include "../../utils/connectionutils.hpp"
29#include "../../utils/librtconstants.hpp"
30
31// Constructor
32OAuth10aAuthenticator::OAuth10aAuthenticator(QString signatureAlgorithm) :
33 OAuthAuthenticator("1.0"),
34 callbackUrl(LibRT::FAKE_URL),
35 oauthTokens(),
36 oauthSignatureMethod(signatureAlgorithm),
37 oauthVerifier(LibRT::FAKE_TOKEN)
38{}
39
40// Destructor
41OAuth10aAuthenticator::~OAuth10aAuthenticator() {}
42
43
44/////////////////////
45// Getters on data //
46/////////////////////
47
48// Callback URL
49QString OAuth10aAuthenticator::getCallbackUrl() {
50 return callbackUrl;
51}
52
53void OAuth10aAuthenticator::setCallbackUrl(QString newURL) {
54 callbackUrl = newURL;
55}
56
57// OAuth Token
58QByteArray OAuth10aAuthenticator::getOAuthToken() {
59 return oauthTokens.first;
60}
61
62void OAuth10aAuthenticator::setOAuthToken(QByteArray authToken) {
63 oauthTokens.first = authToken;
64}
65
66// OAuth secret
67void OAuth10aAuthenticator::setOAuthSecret(QByteArray authSecret) {
68 oauthTokens.second = authSecret;
69}
70
71// OAuth verifier
72QByteArray OAuth10aAuthenticator::getVerifier() {
73 return oauthVerifier;
74}
75
76void OAuth10aAuthenticator::setVerifier(QByteArray verifier) {
77 oauthVerifier = verifier;
78}
79
80////////////////////////////
81// Utilities for requests //
82////////////////////////////
83
84// Resetting tokens
85void OAuth10aAuthenticator::resetTokens() {
86 oauthTokens.first = LibRT::FAKE_TOKEN;
87 oauthTokens.second = LibRT::FAKE_TOKEN;
88 oauthVerifier = LibRT::FAKE_TOKEN;
89}
90
91// Getting the "Authorization" header
92QByteArray OAuth10aAuthenticator::getAuthorizationHeader(LibRT::HTTPRequestType type,
93 QString baseURL,
94 ArgsMap getDatas,
95 ArgsMap postDatas,
96 bool oauthTokenNeeded,
97 bool callbackUrlNeeded,
98 bool oauthVerifierNeeded)
99{
100 QString authorizationHeader = "OAuth ";
101 QString nonce = generateNonce();
102 QString timestamp = generateTimestamp();
103 QByteArray signature = signDatas(type,
104 baseURL,
105 getDatas,
106 postDatas,
107 nonce,
108 timestamp,
109 oauthTokenNeeded,
110 callbackUrlNeeded,
111 oauthVerifierNeeded);
112
113 // Building the string with all the parameters
114 QString oauthString = buildOAuthParameterString(nonce,
115 timestamp,
116 ", ",
117 oauthTokenNeeded,
118 callbackUrlNeeded,
119 oauthVerifierNeeded,
120 true,
121 true,
122 signature);
123 authorizationHeader.append(oauthString);
124
125 return authorizationHeader.toLatin1();
126}
127
128// Signing datas
129QByteArray OAuth10aAuthenticator::signDatas(LibRT::HTTPRequestType type,
130 QString baseURL,
131 ArgsMap getDatas,
132 ArgsMap postDatas,
133 QString nonce,
134 QString timestamp,
135 bool oauthTokenNeeded,
136 bool callbackUrlNeeded,
137 bool oauthVerifierNeeded)
138{
139 // Building the key
140 QByteArray key = "";
141
142 key.append(QUrl::toPercentEncoding(QString::fromLatin1(consumerTokens.second)));
143 key.append('&');
144 key.append(QUrl::toPercentEncoding(QString::fromLatin1(oauthTokens.second)));
145
146
147 // Building that will be signed
148
149 // OAuth parameters
150 QString oauthString = this->buildOAuthParameterString(nonce,
151 timestamp,
152 "&",
153 oauthTokenNeeded,
154 callbackUrlNeeded,
155 oauthVerifierNeeded,
156 false,
157 false);
158
159 QString parameterString = this->buildSignatureBaseString(getDatas,
160 postDatas,
161 oauthString);
162
163 // Building the base String
164 QByteArray toSign = "";
165
166 toSign.append(requestTypeToString(type).toLatin1());
167 toSign.append('&');
168 toSign.append(QUrl::toPercentEncoding(baseURL));
169 toSign.append('&');
170 toSign.append(QUrl::toPercentEncoding(parameterString));
171
172 return hmacSha1(key, toSign);
173}
174
175// Generic method to build strings with OAuth parameters.
176QString OAuth10aAuthenticator::buildOAuthParameterString(QString nonce,
177 QString timestamp,
178 QString separator,
179 bool oauthTokenNeeded,
180 bool callbackUrlNeeded,
181 bool oauthVerifierNeeded,
182 bool putDoubleQuotes,
183 bool signatureNeeded,
184 QByteArray signature)
185{
186 QString oauthParamString = ""; // Final string
187 QString formattedParamString = ""; // Temporary string containg a formatted parameter
188
189 // oauth_callback
190 if (callbackUrlNeeded) {
191 formattedParamString = formatParam("oauth_callback",
192 callbackUrl,
193 putDoubleQuotes);
194 oauthParamString.append(formattedParamString);
195 oauthParamString.append(separator);
196 }
197
198 // oauth_consumer_key
199 formattedParamString = formatParam("oauth_consumer_key",
200 QString::fromLatin1(consumerTokens.first),
201 putDoubleQuotes);
202 oauthParamString.append(formattedParamString);
203 oauthParamString.append(separator);
204
205 // oauth_nonce
206 formattedParamString = formatParam("oauth_nonce",
207 nonce,
208 putDoubleQuotes);
209 oauthParamString.append(formattedParamString);
210 oauthParamString.append(separator);
211
212 // oauth_signature
213 if (signatureNeeded) {
214 formattedParamString = formatParam("oauth_signature",
215 QString::fromLatin1(signature),
216 putDoubleQuotes);
217 oauthParamString.append(formattedParamString);
218 oauthParamString.append(separator);
219 }
220
221 // oauth_signature_method
222 formattedParamString = formatParam("oauth_signature_method",
223 oauthSignatureMethod,
224 putDoubleQuotes);
225 oauthParamString.append(formattedParamString);
226 oauthParamString.append(separator);
227
228 // oauth_timestamp
229 formattedParamString = formatParam("oauth_timestamp",
230 timestamp,
231 putDoubleQuotes);
232 oauthParamString.append(formattedParamString);
233 oauthParamString.append(separator);
234
235 // oauth_token
236 if (oauthTokenNeeded) {
237 formattedParamString = formatParam("oauth_token",
238 QString::fromLatin1(oauthTokens.first),
239 putDoubleQuotes);
240 oauthParamString.append(formattedParamString);
241 oauthParamString.append(separator);
242 }
243
244 // oauth_verifier
245 if (oauthVerifierNeeded) {
246 formattedParamString = formatParam("oauth_verifier",
247 QString::fromLatin1(oauthVerifier),
248 putDoubleQuotes);
249 oauthParamString.append(formattedParamString);
250 oauthParamString.append(separator);
251 }
252
253 // oauth_version
254 formattedParamString = formatParam("oauth_version",
255 oauthVersion,
256 putDoubleQuotes);
257 oauthParamString.append(formattedParamString);
258
259 return oauthParamString;
260}
261
262// Method builing the base string for the OAuth Signature.
263QString OAuth10aAuthenticator::buildSignatureBaseString(ArgsMap getDatas,
264 ArgsMap postDatas,
265 QString oauthString)
266{
267 QString oauthKey = "oauth_*";
268
269 // Building a big ArgsMap with all the parameters
270 ArgsMap allParametersMap;
271 allParametersMap.unite(getDatas);
272 allParametersMap.unite(postDatas);
273 allParametersMap.insert(oauthKey, oauthString);
274
275 // Sorting the keys in the alphabetical order
276 QStringList allKeys(allParametersMap.keys());
277 allKeys.sort();
278
279 // Building the string
280 QString signatureBaseString = "";
281
282 for (QStringList::iterator it = allKeys.begin();
283 it != allKeys.end();
284 ++it)
285 {
286 QString paramName = *it;
287 QString paramValue = allParametersMap.value(paramName);
288 QString formattedParam = (paramName == oauthKey) ?
289 paramValue // All the OAuth parameters already treated
290 : formatParam(paramName, paramValue);
291
292 signatureBaseString.append(formattedParam);
293 signatureBaseString.append('&');
294 }
295
296 // Erasing the last '&'
297 signatureBaseString.chop(1);
298
299 return signatureBaseString;
300}
0301
=== added file 'connection/common/authenticators/oauth/oauth10aauthenticator.hpp'
--- connection/common/authenticators/oauth/oauth10aauthenticator.hpp 1970-01-01 00:00:00 +0000
+++ connection/common/authenticators/oauth/oauth10aauthenticator.hpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,237 @@
1/// @file oauth10aauthenticator.hpp
2/// @brief Header of OAuth10aAuthenticator
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef OAUTH10AAUTHENTICATOR_HPP
25#define OAUTH10AAUTHENTICATOR_HPP
26
27#include <QByteArray>
28#include <QMap>
29#include <QString>
30#include "oauthauthenticator.hpp"
31#include "../../httprequesttype.hpp"
32#include "../../headersmap.hpp"
33
34/// @class OAuth10aAuthenticator
35/// @brief Authenticator for stuff related to OAuth 1.0a.
36class OAuth10aAuthenticator : public virtual OAuthAuthenticator
37{
38 public:
39 /// @fn OAuth10aAuthenticator(QString signatureAlgorithm = "SHA-1");
40 /// @brief Constructor.
41 ///
42 /// Application settings (callback URL, oauth credentials) will be
43 /// filled later.
44 /// @param signatureAlgorithm Algorithm used for signing requests.
45 OAuth10aAuthenticator(QString signatureAlgorithm = "HMAC-SHA1");
46
47 /// @fn virtual ~OAuth10aAuthenticator();
48 /// @brief Destructor
49 virtual ~OAuth10aAuthenticator();
50
51
52 /////////////////////
53 // Getters on data //
54 /////////////////////
55
56 /// @fn QString getCallbackUrl();
57 /// @brief Getter for callbackUrl
58 /// @return The callback URL
59 QString getCallbackUrl();
60
61 /// @fn void setCallbackUrl(QString newURL);
62 /// @brief Setter for callbackUrl
63 /// @param newURL New value for the callback URL
64 void setCallbackUrl(QString newURL);
65
66 /// @fn QByteArray getOAuthToken();
67 /// @brief Getting the OAuth Token
68 /// @return The OAuth Token
69 QByteArray getOAuthToken();
70
71 /// @fn void setOAuthToken(QByteArray authToken);
72 /// @brief Setter on the OAuth token
73 /// @param authToken The new value of the OAuth token
74 void setOAuthToken(QByteArray authToken);
75
76 /// @fn void setOAuthSecret(QByteArray oauthSecret);
77 /// @brief Setter on the OAuth secret
78 /// @param oauthSecret The new value of the OAuth secret
79 void setOAuthSecret(QByteArray authSecret);
80
81 /// @fn QByteArray getVerifier();
82 /// @brief Getter on the verifier
83 /// @return The verifier
84 QByteArray getVerifier();
85
86 /// @fn void setVerifier(QByteArray verifier);
87 /// @brief Setter on the verifier
88 /// @param verifier The new verifier
89 void setVerifier(QByteArray verifier);
90
91 ////////////////////////////
92 // Utilities for requests //
93 ////////////////////////////
94
95 /// @fn QByteArray getAuthorizationHeader(Network::HTTPRequestType type,
96 /// QString baseURL,
97 /// ArgsMap getDatas,
98 /// ArgsMap postDatas,
99 /// bool oauthTokenNeeded = true,
100 /// bool callbackUrlNeeded = false,
101 /// bool oauthVerifierNeeded = false);
102 /// @brief Getting that will be written in the "Authorization" field
103 /// of requests
104 /// @param type Request type (GET or POST)
105 /// @param baseURL URL for the request
106 /// @param getDatas GET arguments of the request
107 /// @param postDatas POST arguments of the request
108 /// @param oauthTokenNeeded Boolean indicating whether
109 /// the oauth_token is required for the header.
110 /// @param callbackUrlNeeded Boolean indicating whether
111 /// the oauth_callback is required for the header.
112 /// @param oauthVerifierNeeded Boolean indicating whether
113 /// the oauth_verifier is required for the header.
114 /// @return Value of the "Authorization" header.
115 QByteArray getAuthorizationHeader(LibRT::HTTPRequestType type,
116 QString baseURL,
117 ArgsMap getDatas,
118 ArgsMap postDatas,
119 bool oauthTokenNeeded = true,
120 bool callbackUrlNeeded = false,
121 bool oauthVerifierNeeded = false);
122
123 /// @fn void resetTokens();
124 /// @brief Resetting the tokens. A full new OAuth authentication process
125 /// has to be launch to get tokens and for authentication in requests
126 void resetTokens();
127
128
129 protected:
130 /// @brief Callback URL of the application
131 QString callbackUrl;
132
133 /// @brief Access tokens
134 TokenPair oauthTokens;
135
136 /// @brief Algorithm used for signing requests
137 QString oauthSignatureMethod;
138
139 /// @brief Verifier for authentication
140 QByteArray oauthVerifier;
141
142 /// @fn QByteArray signDatas(Network::RequestType type,
143 /// QString baseURL,
144 /// ArgsMap getDatas,
145 /// ArgsMap postDatas,
146 /// QString nonce,
147 /// QString timestamp,
148 /// bool oauthTokenNeeded = true,
149 /// bool callbackUrlNeeded = false,
150 /// bool oauthVerifierNeeded = false);
151 /// @brief Method for signing datas. It is described
152 /// <a href="https://dev.twitter.com/docs/auth/creating-signature">here
153 /// </a>.
154 /// @param type Request type (GET or POST)
155 /// @param baseURL URL of the service, without the GET arguments.
156 /// @param getDatas GET datas to sign
157 /// @param postDatas POST datas to sign
158 /// @param nonce Nonce of the request
159 /// @param timestamp Timestamp of the request
160 /// @param oauthTokenNeeded Boolean indicating whether
161 /// the oauth_token is required.
162 /// @param callbackUrlNeeded Boolean indicating whether
163 /// the oauth_callback is required.
164 /// @param oauthVerifierNeeded Boolean indicating whether
165 /// the oauth_verifier is required.
166 /// @return The signature of the given datas
167 QByteArray signDatas(LibRT::HTTPRequestType type,
168 QString baseURL,
169 ArgsMap getDatas,
170 ArgsMap postDatas,
171 QString nonce,
172 QString timestamp,
173 bool oauthTokenNeeded = true,
174 bool callbackUrlNeeded = false,
175 bool oauthVerifierNeeded = false);
176
177 /// @fn QString buildOAuthParameterString(QString nonce,
178 /// QString timestamp,
179 /// QString separator,
180 /// bool oauthTokenNeeded,
181 /// bool callbackUrlNeeded,
182 /// bool oauthVerifierNeeded,
183 /// bool putDoubleQuotes,
184 /// bool signatureNeeded,
185 /// QByteArray signature = "");
186 /// @brief Generic method to build strings with OAuth parameters.
187 ///
188 /// It is used for the signature (string with the OAuth parameters) and
189 /// for the Authorization Header
190 /// @param nonce Nonce of the request
191 /// @param timestamp Timestamp of the request
192 /// @param separator Separator between parameters
193 /// @param oauthTokenNeeded Boolean indicating whether
194 /// the oauth_token is required.
195 /// @param callbackUrlNeeded Boolean indicating whether
196 /// the oauth_callback is required.
197 /// @param oauthVerifierNeeded Boolean indicating whether
198 /// the oauth_verifier is required.
199 /// @param putDoubleQuotes Boolean indicating if double quotes have to
200 /// surround the percent encoded value.
201 /// @param signatureNeeded Boolean indicating that the signature of
202 /// the request is required.
203 /// @param signature Signature of the request, if needed.
204 /// @return The string with the parameters.
205 QString buildOAuthParameterString(QString nonce,
206 QString timestamp,
207 QString separator,
208 bool oauthTokenNeeded,
209 bool callbackUrlNeeded,
210 bool oauthVerifierNeeded,
211 bool putDoubleQuotes,
212 bool signatureNeeded,
213 QByteArray signature = "");
214
215 /// @fn QString buildSignatureBaseString(ArgsMap getDatas,
216 /// ArgsMap postDatas,
217 /// QString oauthString);
218 /// @brief Method builing the base string for the OAuth Signature.
219 /// @param getDatas GET datas of the request
220 /// @param postDatas POST datas of the request
221 /// @param oauthString String with the OAuth parameters.
222 ///
223 /// At a certain point of the algorithm, all the parameters have to be
224 /// sorted lexicographically with their name. All the OAuth parameters
225 /// are named "&lt;oauth_something&gt;" and likely to be one after
226 /// another after sorting the parameters. That's why they are all
227 /// put into a "oauthString" parameter which will be inserted
228 /// at the right place.
229 /// @return The string built just like Twitter describes
230 /// <a href="https://dev.twitter.com/docs/auth/creating-signature">
231 /// here</a>.
232 QString buildSignatureBaseString(ArgsMap getDatas,
233 ArgsMap postDatas,
234 QString oauthString);
235};
236
237#endif // OAUTH10AAUTHENTICATOR_HPP
0238
=== added file 'connection/common/authenticators/oauth/oauth2authenticator.cpp'
--- connection/common/authenticators/oauth/oauth2authenticator.cpp 1970-01-01 00:00:00 +0000
+++ connection/common/authenticators/oauth/oauth2authenticator.cpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,75 @@
1/// @file oauth2authenticator.cpp
2/// @brief Implementation of OAuth2Authenticator
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#include "oauth2authenticator.hpp"
25
26#include <QUrl>
27#include "../../utils/librtconstants.hpp"
28
29// Constructor
30OAuth2Authenticator::OAuth2Authenticator() :
31 OAuthAuthenticator("2.0"),
32 bearerToken(LibRT::FAKE_TOKEN)
33{}
34
35// Destructor
36OAuth2Authenticator::~OAuth2Authenticator() {}
37
38/////////////////////////////
39// Bearer token management //
40/////////////////////////////
41
42void OAuth2Authenticator::setBearerToken(QByteArray newBearer) {
43 bearerToken = newBearer;
44}
45
46void OAuth2Authenticator::resetTokens() {
47 bearerToken = LibRT::FAKE_TOKEN;
48}
49
50
51///////////////////////////////////////
52// OAuth 2 Authentication management //
53///////////////////////////////////////
54
55QByteArray OAuth2Authenticator::getBasicHeader() {
56 QByteArray bearerCredentials = "";
57
58 bearerCredentials.append(QUrl::toPercentEncoding(consumerTokens.first))
59 .append(':')
60 .append(QUrl::toPercentEncoding(consumerTokens.second));
61
62 QByteArray basicHeader = "Basic ";
63
64 basicHeader.append(bearerCredentials.toBase64());
65
66 return basicHeader;
67}
68
69QByteArray OAuth2Authenticator::getBearerHeader() {
70 QByteArray bearerHeader = "Bearer ";
71
72 bearerHeader.append(bearerToken.toBase64());
73
74 return bearerHeader;
75}
076
=== added file 'connection/common/authenticators/oauth/oauth2authenticator.hpp'
--- connection/common/authenticators/oauth/oauth2authenticator.hpp 1970-01-01 00:00:00 +0000
+++ connection/common/authenticators/oauth/oauth2authenticator.hpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,68 @@
1/// @file oauth2authenticator.hpp
2/// @brief Header of OAuth2Authenticator
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef OAUTH2AUTHENTICATOR_HPP
25#define OAUTH2AUTHENTICATOR_HPP
26
27#include "oauthauthenticator.hpp"
28
29/// @class OAuth2Authenticator
30/// @brief Authenticator for stuff related to OAuth 2.
31class OAuth2Authenticator : public virtual OAuthAuthenticator
32{
33 public:
34 /// @fn OAuth2Authenticator();
35 /// @brief Constructor
36 OAuth2Authenticator();
37
38 /// @fn virtual ~OAuth2Authenticator();
39 /// @brief Destructor
40 virtual ~OAuth2Authenticator();
41
42 /// @fn void setBearerToken(QByteArray newBearer);
43 /// @brief Setter for bearerToken
44 /// @param newBearer New value for bearerToken
45 void setBearerToken(QByteArray newBearer);
46
47 /// @fn void resetTokens();
48 /// @brief Resetting the tokens. A full new OAuth authentication process
49 /// has to be launch to get tokens and for authentication in requests
50 void resetTokens();
51
52 /// @fn QByteArray getBasicHeader();
53 /// @brief Building the header used to retrieve or to invalidate
54 /// a Bearer Token.
55 /// @return The corresponding header
56 QByteArray getBasicHeader();
57
58 /// @fn QByteArray getBearerHeader();
59 /// @brief Building the header used to authenticate requests.
60 /// @return The corresponding header
61 QByteArray getBearerHeader();
62
63 protected:
64 /// @brief Bearer token
65 QByteArray bearerToken;
66};
67
68#endif // OAUTH2AUTHENTICATOR_HPP
069
=== added file 'connection/common/authenticators/oauth/oauthauthenticator.cpp'
--- connection/common/authenticators/oauth/oauthauthenticator.cpp 1970-01-01 00:00:00 +0000
+++ connection/common/authenticators/oauth/oauthauthenticator.cpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,46 @@
1/// @file oauthauthenticator.cpp
2/// @brief Implementation of OAuthAuthenticator
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#include "oauthauthenticator.hpp"
25
26OAuthAuthenticator::OAuthAuthenticator(QString version) :
27 consumerTokens(),
28 oauthVersion(version)
29{}
30
31OAuthAuthenticator::~OAuthAuthenticator() {}
32
33
34/////////////////////
35// Getters on data //
36/////////////////////
37
38// Consumer key
39void OAuthAuthenticator::setConsumerKey(QByteArray clientKey) {
40 consumerTokens.first = clientKey;
41}
42
43// Consumer secret
44void OAuthAuthenticator::setConsumerSecret(QByteArray clientSecret) {
45 consumerTokens.second = clientSecret;
46}
047
=== added file 'connection/common/authenticators/oauth/oauthauthenticator.hpp'
--- connection/common/authenticators/oauth/oauthauthenticator.hpp 1970-01-01 00:00:00 +0000
+++ connection/common/authenticators/oauth/oauthauthenticator.hpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,66 @@
1/// @file oauthauthenticator.hpp
2/// @brief Header of OAuthAuthenticator
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef OAUTHAUTHENTICATOR_HPP
25#define OAUTHAUTHENTICATOR_HPP
26
27#include "../basicauthenticators.hpp"
28
29/// @class OAuthAuthenticator
30/// @brief Base class for Authentication managers related to OAuth.
31///
32/// It contains the Consumer tokens pair
33class OAuthAuthenticator {
34 public:
35 /// @fn OAuthAuthenticator(QString version = "");
36 /// @brief Constructor
37 /// @param version Version of OAuth
38 OAuthAuthenticator(QString version = "");
39
40 /// @fn virtual ~OAuthAuthenticator();
41 /// @brief Destructor
42 virtual ~OAuthAuthenticator();
43
44 /////////////////////
45 // Getters on data //
46 /////////////////////
47
48 /// @fn void setConsumerKey(QByteArray clientKey);
49 /// @brief Setter on the consumer key
50 /// @param clientKey New consumer key
51 void setConsumerKey(QByteArray clientKey);
52
53 /// @fn void setConsumerSecret(QByteArray clientSecret);
54 /// @brief Setter on the consumer secret
55 /// @param clientSecret New consumer secret
56 void setConsumerSecret(QByteArray clientSecret);
57
58 protected:
59 /// @brief Consumer tokens
60 TokenPair consumerTokens;
61
62 /// @brief Version of the OAuth protocol used for the authentication.
63 QString oauthVersion;
64};
65
66#endif // OAUTHAUTHENTICATOR_HPP
067
=== added file 'connection/common/authenticators/oauth/oauthutils.cpp'
--- connection/common/authenticators/oauth/oauthutils.cpp 1970-01-01 00:00:00 +0000
+++ connection/common/authenticators/oauth/oauthutils.cpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,86 @@
1/// @file oauthutils.cpp
2/// @brief Utilities for OAuth (implementation)
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#include "oauthutils.hpp"
25
26#include <QCryptographicHash>
27#include <QDateTime>
28
29// Generates a nonce for a request
30QString generateNonce() {
31 QString base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
32 int baseLength = base.length();
33
34 QString randomString = "";
35 int randomStringLength = 32;
36
37 // Taking random word characters
38 for (int i = 0; i < randomStringLength; ++i) {
39 int position = qrand() % baseLength;
40 randomString.append(base.at(position));
41 }
42
43 QByteArray encodedNonce = randomString.toLatin1().toBase64();
44
45 return QString::fromLatin1(encodedNonce);
46}
47
48// Generates a timestamp for a request
49QString generateTimestamp() {
50 qint64 timestamp = QDateTime::currentMSecsSinceEpoch() / 1000;
51 return QString::number(timestamp);
52}
53
54// HMAC-SHA1 algorithm for signatures.
55QByteArray hmacSha1(QByteArray key, QByteArray baseString) {
56 int blockSize = 64; // HMAC-SHA-1 block size, defined in SHA-1 standard
57
58 if (key.length() > blockSize) {
59 // if key is longer than block size (64), reduce key length with
60 // SHA-1 compression
61 key = QCryptographicHash::hash(key, QCryptographicHash::Sha1);
62 }
63
64 // initialize inner padding with char "6"
65 QByteArray innerPadding(blockSize, char(0x36));
66 // initialize outer padding with char "\"
67 QByteArray outerPadding(blockSize, char(0x5c));
68
69 // ascii characters 0x36 ("6") and 0x5c ("\") are selected because they have
70 // large Hamming distance (http://en.wikipedia.org/wiki/Hamming_distance)
71
72 for (int i = 0; i < key.length(); i++) {
73 // XOR operation between every byte in key and innerpadding, of key length
74 innerPadding[i] = innerPadding[i] ^ key.at(i);
75 // XOR operation between every byte in key and outerpadding, of key length
76 outerPadding[i] = outerPadding[i] ^ key.at(i);
77 }
78
79 // result = hash ( outerPadding CONCAT hash ( innerPadding CONCAT baseString ) ).toBase64
80 QByteArray total = outerPadding;
81 QByteArray part = innerPadding;
82 part.append(baseString);
83 total.append(QCryptographicHash::hash(part, QCryptographicHash::Sha1));
84 QByteArray hashed = QCryptographicHash::hash(total, QCryptographicHash::Sha1);
85 return hashed.toBase64();
86}
087
=== added file 'connection/common/authenticators/oauth/oauthutils.hpp'
--- connection/common/authenticators/oauth/oauthutils.hpp 1970-01-01 00:00:00 +0000
+++ connection/common/authenticators/oauth/oauthutils.hpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,56 @@
1/// @file oauthutils.hpp
2/// @brief Utilities for OAuth (header)
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef OAUTHUTILS_HPP
25#define OAUTHUTILS_HPP
26
27#include <QByteArray>
28#include <QString>
29
30/// @fn QString generateNonce();
31/// @brief Generates a nonce for a request. To generate a nonce,
32/// a random string is generated by taking 32 times one letter in the
33/// alphabet. The letter could be in upper case or lower case. The final
34/// nonce is the 64 base-encoding of the random string.
35/// @return A nonce for a request.
36QString generateNonce();
37
38/// @fn QString generateTimestamp();
39/// @brief Generates a timestamp for a request. The timestamp is the
40/// number of seconds since the Unix Epoch (1/1/1970 at midnight).
41/// @return A timestamp corresponding to the current date.
42QString generateTimestamp();
43
44/// @fn QByteArray hmacSha1(QByteArray key, QByteArray baseString);
45/// @brief HMAC-SHA1 algorithm for signatures.
46///
47/// Its implementation for Reyn Tweets was found on the
48/// <a href="http://qt-project.org">Qt Project website</a> here :
49/// <a href="http://qt-project.org/wiki/HMAC-SHA1">
50/// http://qt-project.org/wiki/HMAC-SHA1</a>.
51/// @param key Key for signature
52/// @param baseString String that we want to sign
53/// @return The signature
54QByteArray hmacSha1(QByteArray key, QByteArray baseString);
55
56#endif // OAUTHUTILS_HPP
057
=== added directory 'connection/common/calls'
=== renamed file 'connection/calls/genericcalls.cpp' => 'connection/common/calls/genericcalls.cpp'
--- connection/calls/genericcalls.cpp 2012-05-19 13:58:56 +0000
+++ connection/common/calls/genericcalls.cpp 2013-08-20 00:10:09 +0000
@@ -28,13 +28,13 @@
2828
29// Protected constructor29// Protected constructor
30GenericCalls::GenericCalls(QObject * requester) :30GenericCalls::GenericCalls(QObject * requester) :
31 QObject(),31 QObject(),
32 requestDemander(requester)32 requestDemander(requester)
33{}33{}
3434
35// Destructor35// Destructor
36GenericCalls::~GenericCalls() {36GenericCalls::~GenericCalls() {
37 requestDemander = 0;37 requestDemander = 0;
38}38}
3939
4040
@@ -44,45 +44,34 @@
4444
45// Adding a requester to the requester manager45// Adding a requester to the requester manager
46void GenericCalls::addRequester(GenericRequester * requester) {46void GenericCalls::addRequester(GenericRequester * requester) {
47 if (requester != 0) {47 if (requester != 0) {
48 connect(requester, SIGNAL(requestDone()),48 connect(requester, &GenericRequester::requestDone,
49 this, SLOT(endRequest()));49 this, &GenericCalls::endRequest);
50 requesterManager.addRequest(requestDemander, requester);50 requesterManager.addRequest(requestDemander, requester);
51 }51 }
52}52}
5353
54// Removing a requester of the requester manager54// Removing a requester of the requester manager
55void GenericCalls::removeRequester(GenericRequester * requester) {55void GenericCalls::removeRequester(GenericRequester * requester) {
56 if (requester != 0) {56 if (requester != 0) {
57 disconnect(requester, SIGNAL(requestDone()),57 disconnect(requester, &GenericRequester::requestDone,
58 this, SLOT(endRequest()));58 this, &GenericCalls::endRequest);
59 requesterManager.removeRequest(requester->getUuid());59 requesterManager.removeRequest(requester);
60 }60 }
61}61}
6262
63// Slot executed when a requester has finished its work63// Slot executed when a requester has finished its work
64void GenericCalls::endRequest() {64void GenericCalls::endRequest(RequestResult requestResult) {
65 GenericRequester * requester = qobject_cast<GenericRequester *>(sender());65 GenericRequester * requester = qobject_cast<GenericRequester *>(sender());
66 ResultWrapper res = buildResultSender(requester);66 ResultWrapper res(requesterManager.getAsker(requester), requestResult);
67 removeRequester(requester);67 removeRequester(requester);
68 emit sendResult(res);68 emit sendResult(res);
69}
70
71// Method that builds the wrapper of a result
72ResultWrapper GenericCalls::buildResultSender(GenericRequester * endedRequest) {
73 if (endedRequest) {
74 RequestInfos & requestInfos = requesterManager.getRequestInfos(endedRequest->getUuid());
75 return ResultWrapper(requestInfos.getAsker(),
76 requestInfos.getRequester()->getRequestResult());
77 } else {
78 return ResultWrapper();
79 }
80}69}
8170
82// Inline method for executing requests71// Inline method for executing requests
83void GenericCalls::executeRequest(GenericRequester * requester) {72void GenericCalls::executeRequest(GenericRequester * requester) {
84 if (requester != 0) {73 if (requester != 0) {
85 addRequester(requester);74 addRequester(requester);
86 requester->executeRequest();75 requester->executeRequest();
87 }76 }
88}77}
8978
=== renamed file 'connection/calls/genericcalls.hpp' => 'connection/common/calls/genericcalls.hpp'
--- connection/calls/genericcalls.hpp 2012-09-12 22:38:35 +0000
+++ connection/common/calls/genericcalls.hpp 2013-08-20 00:10:09 +0000
@@ -26,8 +26,8 @@
2626
27#include <QObject>27#include <QObject>
28#include "../requests/genericrequester.hpp"28#include "../requests/genericrequester.hpp"
29#include "../model/resultwrapper.hpp"29#include "../resultwrapper.hpp"
30#include "../model/requestermanager.hpp"30#include "requestermanager.hpp"
3131
32/// @class GenericCalls32/// @class GenericCalls
33/// @brief Base class for all classes which manage calls to services.33/// @brief Base class for all classes which manage calls to services.
@@ -59,9 +59,10 @@
59 void sendResult(ResultWrapper res);59 void sendResult(ResultWrapper res);
6060
61 public slots:61 public slots:
62 /// @fn void endRequest();62 /// @fn void endRequest(RequestResult requestResult);
63 /// @brief Slot executed when a requester has finished its work63 /// @brief Slot executed when a requester has finished its work
64 void endRequest();64 /// @param requestResult Result of the request.
65 void endRequest(RequestResult requestResult);
6566
66 protected:67 protected:
67 /// @brief QObject that asks for the request68 /// @brief QObject that asks for the request
@@ -84,12 +85,6 @@
84 /// @param requester Address of the requester85 /// @param requester Address of the requester
85 void removeRequester(GenericRequester * requester);86 void removeRequester(GenericRequester * requester);
8687
87 /// @fn ResultSender buildResultSender(GenericRequester * endedRequest);
88 /// @brief Method that builds the wrapper of a result
89 /// @param endedRequest Ended request that contaons the result
90 /// @return The wrapper of the request result
91 ResultWrapper buildResultSender(GenericRequester * endedRequest);
92
93 /// @fn void executeRequest(GenericRequester * requester);88 /// @fn void executeRequest(GenericRequester * requester);
94 /// @brief Inline method for executing requests89 /// @brief Inline method for executing requests
95 /// @param requester The requester90 /// @param requester The requester
9691
=== renamed file 'connection/model/requestermanager.cpp' => 'connection/common/calls/requestermanager.cpp'
--- connection/model/requestermanager.cpp 2012-09-12 22:38:35 +0000
+++ connection/common/calls/requestermanager.cpp 2013-08-20 00:10:09 +0000
@@ -25,23 +25,37 @@
2525
26#include "requestermanager.hpp"26#include "requestermanager.hpp"
2727
28// Constructor
28RequesterManager::RequesterManager() :29RequesterManager::RequesterManager() :
29 QMap<QUuid, RequestInfos>()30 QMap<QUuid, RequestInfos>()
30{31{}
31}
3232
33// Adding a request to the manager
33void RequesterManager::addRequest(QObject * asker, GenericRequester * requester) {34void RequesterManager::addRequest(QObject * asker, GenericRequester * requester) {
34 if (requester != 0) {35 if (requester != 0) {
35 insert(requester->getUuid(), RequestInfos(asker, requester));36 RequestInfos reqinf;
36 }37
37}38 reqinf.asker = asker;
3839 reqinf.requester = requester;
39void RequesterManager::removeRequest(QUuid requestUuid) {40
40 GenericRequester * requester = getRequestInfos(requestUuid).getRequester();41 insert(requester->getUuid(), reqinf);
41 delete requester;42 }
42 remove(requestUuid);43}
43}44
4445// Removing a request to the manager
46void RequesterManager::removeRequest(GenericRequester * requester) {
47 if (requester) {
48 remove(requester->getUuid());
49 delete requester;
50 }
51}
52
53// Getting informations on a request
45RequestInfos & RequesterManager::getRequestInfos(QUuid requestUuid) {54RequestInfos & RequesterManager::getRequestInfos(QUuid requestUuid) {
46 return (*this)[requestUuid];55 return (*this)[requestUuid];
47}56}
57
58// Getting the QObject which asked for the request
59QObject * RequesterManager::getAsker(GenericRequester * requester) {
60 return requester ? getRequestInfos(requester->getUuid()).asker : 0;
61}
4862
=== renamed file 'connection/model/requestermanager.hpp' => 'connection/common/calls/requestermanager.hpp'
--- connection/model/requestermanager.hpp 2012-09-12 22:38:35 +0000
+++ connection/common/calls/requestermanager.hpp 2013-08-20 00:10:09 +0000
@@ -51,10 +51,17 @@
51 /// @param requester Entity that executing the request51 /// @param requester Entity that executing the request
52 void addRequest(QObject * asker, GenericRequester * requester);52 void addRequest(QObject * asker, GenericRequester * requester);
5353
54 /// @fn void removeRequest(QUuid requestUuid);54 /// @fn void removeRequest(GenericRequester * requester);
55 /// @brief Removing a request from the manager55 /// @brief Removing a request from the manager
56 /// @param requestUuid UUID of the requester56 /// @param requester Requester to remove
57 void removeRequest(QUuid requestUuid);57 void removeRequest(GenericRequester * requester);
58
59 /// @fn QObject * getAsker(GenericRequester * requester);
60 /// @brief Getting the QObject which asked for the request
61 /// @param requester The requester which executes the request
62 /// @return The QObject which asked for the process. It should be
63 /// a Process.
64 QObject * getAsker(GenericRequester * requester);
58};65};
5966
60#endif // REQUESTERMANAGER_HPP67#endif // REQUESTERMANAGER_HPP
6168
=== renamed file 'connection/model/requestinfos.hpp' => 'connection/common/calls/requestinfos.hpp'
--- connection/model/requestinfos.hpp 2012-09-12 22:38:35 +0000
+++ connection/common/calls/requestinfos.hpp 2013-08-20 00:10:09 +0000
@@ -29,38 +29,15 @@
29#include <QObject>29#include <QObject>
30#include "../requests/genericrequester.hpp"30#include "../requests/genericrequester.hpp"
3131
32/// @class RequestInfos32/// @struct RequestInfos
33/// @brief Class containing the entity which asks for the request (the "asker")33/// @brief Struct containing the entity which asks for the request
34/// and the requester that executes the request (the "requester").34/// (the "asker") and the requester that executes the request (the "requester").
35class RequestInfos35struct RequestInfos {
36{36 /// @brief Entity which asks for the request
37 public:37 QObject * asker;
38 /// @fn RequestInfos(QObject * requestAsker = 0,38
39 /// GenericRequester * twitterRequest = 0);39 /// @brief Requester that executes the request
40 /// @brief Constructor40 GenericRequester * requester;
41 /// @param requestAsker The asker
42 /// @param twitterRequest The requester
43 RequestInfos(QObject * requestAsker = 0,
44 GenericRequester * twitterRequest = 0);
45
46 /// @fn ~RequestInfos();
47 /// @brief Destructor
48 ~RequestInfos();
49
50 /// @fn QObject * getAsker();
51 /// @brief Getter on the asker
52 QObject * getAsker();
53
54 /// @fn GenericRequester * getRequester();
55 /// @brief Getter on the requester
56 GenericRequester * getRequester();
57
58 protected:
59 /// @brief Entity which asks for the request
60 QObject * asker;
61
62 /// @brief Requester that executes the request
63 GenericRequester * requester;
64};41};
6542
66#endif // REQUESTINFOS_HPP43#endif // REQUESTINFOS_HPP
6744
=== renamed directory 'connection/twittercommunicators' => 'connection/common/communicators'
=== modified file 'connection/common/communicators/twittercommunicator.cpp'
--- connection/twittercommunicators/twittercommunicator.cpp 2013-02-15 23:30:42 +0000
+++ connection/common/communicators/twittercommunicator.cpp 2013-08-20 00:10:09 +0000
@@ -26,17 +26,15 @@
2626
27#include <QNetworkRequest>27#include <QNetworkRequest>
28#include "twittercommunicator.hpp"28#include "twittercommunicator.hpp"
29#include "../../tools/utils.hpp"29#include "../utils/connectionutils.hpp"
30
31//#include <QtDebug> // For debug purposes
3032
31// Network manager33// Network manager
32#ifdef Q_OS_WIN3234#ifdef Q_OS_WIN
33 QNetworkAccessManager REYN_TWEETS_NETWORK_MANAGER = QNetworkAccessManager();35 QNetworkAccessManager LibRT::REYN_TWEETS_NETWORK_MANAGER = QNetworkAccessManager();
34#endif36#elif defined(Q_OS_LINUX)
35#ifdef Q_OS_LINUX37 QNetworkAccessManager LibRT::REYN_TWEETS_NETWORK_MANAGER;
36 QNetworkAccessManager REYN_TWEETS_NETWORK_MANAGER;
37#endif
38#ifdef Q_OS_SYMBIAN // TODO
39// QNetworkAccessManager REYN_TWEETS_NETWORK_MANAGER = QNetworkAccessManager();
40#endif38#endif
4139
42/////////////40/////////////
@@ -45,35 +43,29 @@
4543
46// Constructor44// Constructor
47TwitterCommunicator::TwitterCommunicator(QString &url,45TwitterCommunicator::TwitterCommunicator(QString &url,
48 RequestType type,46 LibRT::HTTPRequestType type,
49 ArgsMap & getArgs,47 ArgsMap & getArgs,
50 ArgsMap & postArgs,48 ArgsMap & postArgs,
51 HeadersMap & headersParam) :49 HeadersMap & headersParam) :
52 QObject(),50 QObject(),
53 network(&REYN_TWEETS_NETWORK_MANAGER),51 timeoutTimer(),
54 timeoutTimer(),52 serviceURL(url),
55 serviceURL(url),53 requestType(type),
56 requestType(type),54 getParameters(getArgs),
57 getParameters(getArgs),55 postParameters(postArgs),
58 postParameters(postArgs),56 headers(headersParam)
59 headers(headersParam),
60 responseBuffer(""),
61 httpResponse(),
62 errorMessage("Request not done"),
63 replyURL("")
64{57{
65 // Setting the timer58 // Setting the timer
66 timeoutTimer.setInterval(10*1000); // 10 seconds59 timeoutTimer.setInterval(10*1000); // 10 seconds
67 timeoutTimer.setSingleShot(true);60 timeoutTimer.setSingleShot(true);
68 connect(&timeoutTimer, SIGNAL(timeout()),61 connect(&timeoutTimer, &QTimer::timeout,
69 this, SLOT(timeout()));62 this, &TwitterCommunicator::timeout);
70}63}
7164
72// Destructor65// Destructor
73TwitterCommunicator::~TwitterCommunicator() {66TwitterCommunicator::~TwitterCommunicator() {
74 disconnect(&timeoutTimer, SIGNAL(timeout()),67 disconnect(&timeoutTimer, &QTimer::timeout,
75 this, SLOT(timeout()));68 this, &TwitterCommunicator::timeout);
76 network = 0;
77}69}
7870
7971
@@ -83,52 +75,52 @@
8375
84// Preparing the request76// Preparing the request
85QNetworkRequest * TwitterCommunicator::prepareRequest() {77QNetworkRequest * TwitterCommunicator::prepareRequest() {
86 // GET arguments78 // GET arguments
87 QString getArgs = buildGetDatas();79 QString getArgs = buildGetDatas();
8880
89 // Adding the potential GET arguments at the end of the URL81 // Adding the potential GET arguments at the end of the URL
90 if ("" != getArgs) {82 if ("" != getArgs) {
91 serviceURL.append('?').append(getArgs);83 serviceURL.append('?').append(getArgs);
92 }84 }
9385
94 QNetworkRequest * requestToTwitter = new QNetworkRequest(serviceURL);86 QNetworkRequest * requestToTwitter = new QNetworkRequest(serviceURL);
9587
96 // Adding the headers88 // Adding the headers
97 for (HeadersMap::Iterator it = headers.begin();89 for (HeadersMap::Iterator it = headers.begin();
98 it != headers.end();90 it != headers.end();
99 ++it)91 ++it)
100 {92 {
101 requestToTwitter->setRawHeader(it.key(), it.value());93 requestToTwitter->setRawHeader(it.key(), it.value());
102 }94 }
10395
104 // Tag of the request with the originatingObject to identify the reply96 // Tag of the request with the originatingObject to identify the reply
105 requestToTwitter->setOriginatingObject(this);97 requestToTwitter->setOriginatingObject(this);
10698
107 return requestToTwitter;99 return requestToTwitter;
108}100}
109101
110// Executing the request102// Executing the request
111void TwitterCommunicator::executeRequest() {103void TwitterCommunicator::executeRequest() {
112 // Preparing the request104 // Preparing the request
113 QNetworkRequest * request = prepareRequest();105 QNetworkRequest * request = prepareRequest();
114106
115 // Connection for receiving the response107 // Connection for receiving the response
116 connect(network, SIGNAL(finished(QNetworkReply*)),108 connect(&LibRT::REYN_TWEETS_NETWORK_MANAGER, &QNetworkAccessManager::finished,
117 this, SLOT(endRequest(QNetworkReply*)));109 this, &TwitterCommunicator::endRequest);
118110
119 // Executing the request111 // Executing the request
120 if (POST == requestType) {112 if (LibRT::POST == requestType) {
121 // POST arguments113 // POST arguments
122 QByteArray postArgs = buildPostDatas();114 QByteArray postArgs = buildPostDatas();
123115
124 // There is some POST arguments -> networkManager.post()116 // There is some POST arguments -> networkManager.post()
125 network->post(*request, postArgs);117 LibRT::REYN_TWEETS_NETWORK_MANAGER.post(*request, postArgs);
126 } else {118 } else {
127 // There is not any POST arguments -> networkManager.get()119 // There is not any POST arguments -> networkManager.get()
128 network->get(*request);120 LibRT::REYN_TWEETS_NETWORK_MANAGER.get(*request);
129 }121 }
130122
131 timeoutTimer.start();123 timeoutTimer.start();
132}124}
133125
134126
@@ -138,85 +130,52 @@
138130
139// Treatments that have to be done at the end of the request131// Treatments that have to be done at the end of the request
140void TwitterCommunicator::endRequest(QNetworkReply * response) {132void TwitterCommunicator::endRequest(QNetworkReply * response) {
141 // Treating the response133 // Treating the response
142134
143 // Is it the response of that precise request ?135 // Is it the response of that precise request ?
144 if (!response || this != response->request().originatingObject()) {136 if (!response || this != response->request().originatingObject()) {
145 // Null reply or bad sender -> No -> doing nothing137 // Null reply or bad sender -> No -> doing nothing
146 return;138 return;
147 }139 }
148140
149 // That's our request. Let's do the treatments !141 // That's our request. Let's do the treatments !
150142
151 // No timeout : stop the timer.143 // No timeout : stop the timer.
152 timeoutTimer.stop();144 timeoutTimer.stop();
153145
154 // Unwiring146 // Unwiring
155 disconnect(network, SIGNAL(finished(QNetworkReply*)),147 disconnect(&LibRT::REYN_TWEETS_NETWORK_MANAGER, &QNetworkAccessManager::finished,
156 this, SLOT(endRequest(QNetworkReply*)));148 this, &TwitterCommunicator::endRequest);
157149
158 // Analysing the response150 // Extracting informations
159 extractHttpStatuses(response);151 NetworkResponse netrep(response);
160 errorMessage = response->errorString();152 response->deleteLater();
161 replyURL = response->url().toString();153
162154 /* responseBuffer (for debug purposes)
163 // Extracting informations155 qDebug() << "responseBuffer :" << '\n'
164 responseBuffer = response->readAll();156 << netrep.getResponseBody() << '\n';
165 response->deleteLater();157 //*/
166158
167 // responseBuffer (for debug purposes)159 // Ending the request
168 /*160 emit requestDone(netrep);
169 qDebug("responseBuffer :");
170 qDebug(responseBuffer.data());
171 qDebug("\n");
172 //*/
173
174 // Ending the request
175 emit requestDone();
176}161}
177162
178// Network timeout163// Network timeout
179void TwitterCommunicator::timeout() {164void TwitterCommunicator::timeout() {
180 // It seems that no response will arrive. That's enough ! Stop it !165 // It seems that no response will arrive. That's enough ! Stop it !
181166
182 // Unwiring167 // Unwiring
183 disconnect(network, SIGNAL(finished(QNetworkReply*)),168 disconnect(&LibRT::REYN_TWEETS_NETWORK_MANAGER, &QNetworkAccessManager::finished,
184 this, SLOT(endRequest(QNetworkReply*)));169 this, &TwitterCommunicator::endRequest);
185170
186 // Analysing the response171 NetworkResponse response(LibRT::TIMEOUT_HTTP_CODE,
187 httpResponse.code = 0;172 "timeout",
188 httpResponse.message = "";173 "",
189 errorMessage = "timeout";174 "timeout",
190 replyURL = serviceURL;175 serviceURL);
191 responseBuffer = "";176
192177 // Ending the request
193 // Ending the request178 emit requestDone(response);
194 emit requestDone();
195}
196
197
198/////////////
199// Getters //
200/////////////
201
202// Getting the raw response
203QByteArray TwitterCommunicator::getResponseBuffer() {
204 return responseBuffer;
205}
206
207// Getting the HTTP response (code and reason)
208ResponseInfos TwitterCommunicator::getHttpResponse() {
209 return httpResponse;
210}
211
212// Getting the URL of the reply
213QString TwitterCommunicator::getReplyURL() {
214 return replyURL;
215}
216
217// Getter on the error massage
218QString TwitterCommunicator::getErrorMessage() {
219 return errorMessage;
220}179}
221180
222181
@@ -226,62 +185,41 @@
226185
227// Building a string that will contain all the GET arguments186// Building a string that will contain all the GET arguments
228QString TwitterCommunicator::buildGetDatas() {187QString TwitterCommunicator::buildGetDatas() {
229 return buildDatas(getParameters);188 return buildDatas(getParameters);
230}189}
231190
232// Building a QByteArray that will contain all the POST arguments191// Building a QByteArray that will contain all the POST arguments
233QByteArray TwitterCommunicator::buildPostDatas() {192QByteArray TwitterCommunicator::buildPostDatas() {
234 QString postString = buildDatas(postParameters);193 QString postString = buildDatas(postParameters);
235 return QByteArray().append(postString);194 return QByteArray().append(postString);
236}195}
237196
238// Building the string that will contain all the arguments197// Building the string that will contain all the arguments
239// of the given ArgsMap just like in an URL.198// of the given ArgsMap just like in an URL.
240QString TwitterCommunicator::buildDatas(ArgsMap argsMap) {199QString TwitterCommunicator::buildDatas(ArgsMap argsMap) {
241 QString res = "";200 QString res = "";
242201
243 // Writing the arguments202 // Writing the arguments
244 for (ArgsMap::iterator argsIterator = argsMap.begin();203 for (ArgsMap::iterator argsIterator = argsMap.begin();
245 argsIterator != argsMap.end();204 argsIterator != argsMap.end();
246 ++argsIterator) {205 ++argsIterator) {
247 // Getting the value of the argument206 // Getting the value of the argument
248 QString argValue = argsIterator.value();207 QString argValue = argsIterator.value();
249208
250 if (argValue.isEmpty()) {209 if (argValue.isEmpty()) {
251 continue;210 continue;
252 }211 }
253212
254 // Getting the name of the argument213 // Getting the name of the argument
255 QString argName = argsIterator.key();214 QString argName = argsIterator.key();
256215
257 // Append the argument in the argument string216 // Append the argument in the argument string
258 res.append(formatParam(argName, argValue));217 res.append(formatParam(argName, argValue));
259 res.append('&');218 res.append('&');
260 }219 }
261220
262 // Erasing the last '&'221 // Erasing the last '&'
263 res.chop(1);222 res.chop(1);
264223
265 return res;224 return res;
266}
267
268
269////////////////////////////////////////////
270// Extracting http results from the reply //
271////////////////////////////////////////////
272
273void TwitterCommunicator::extractHttpStatuses(QNetworkReply * reply) {
274 if (reply == 0) {
275 return;
276 }
277
278 QVariant httpStatus;
279
280 // Extract return code
281 httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
282 httpResponse.code = httpStatus.toInt();
283
284 // Extract return reason
285 httpStatus = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute);
286 httpResponse.message = QString::fromAscii(httpStatus.toByteArray());
287}225}
288226
=== modified file 'connection/common/communicators/twittercommunicator.hpp'
--- connection/twittercommunicators/twittercommunicator.hpp 2012-09-12 22:38:35 +0000
+++ connection/common/communicators/twittercommunicator.hpp 2013-08-20 00:10:09 +0000
@@ -35,20 +35,23 @@
35#include <QUrl>35#include <QUrl>
36#include <QMap>36#include <QMap>
37#include <QTimer>37#include <QTimer>
38#include "../model/responseinfos.hpp"38#include "../headersmap.hpp"
39#include "../model/headersmap.hpp"39#include "../httprequesttype.hpp"
40#include "../model/requesttype.hpp"40#include "../networkresult.hpp"
4141
4242
43/////////////////////43/////////////////////
44// Network Manager //44// Network Manager //
45/////////////////////45/////////////////////
4646
47/// @brief Network manager used by all the requesters for all the request.47
48/// <strong>Including him in the TwitterCommunicator48namespace LibRT {
49/// <a href="https://code.google.com/p/reyn-tweets/issues/detail?id=36">49 /// @brief Network manager used by all the requesters for all the request.
50/// could cause crashes</a></strong>.50 /// <strong>Including him in the TwitterCommunicator
51extern QNetworkAccessManager REYN_TWEETS_NETWORK_MANAGER;51 /// <a href="https://code.google.com/p/reyn-tweets/issues/detail?id=36">
52 /// could cause crashes</a></strong>.
53 extern QNetworkAccessManager REYN_TWEETS_NETWORK_MANAGER;
54}
5255
5356
54/// @class TwitterCommunicator57/// @class TwitterCommunicator
@@ -63,7 +66,7 @@
6366
64 public:67 public:
65 /// @fn TwitterCommunicator(QString &url,68 /// @fn TwitterCommunicator(QString &url,
66 /// RequestType type,69 /// Network::HTTPRequestType type,
67 /// ArgsMap &getArgs,70 /// ArgsMap &getArgs,
68 /// ArgsMap &postArgs,71 /// ArgsMap &postArgs,
69 /// HeadersMap &headersParam);72 /// HeadersMap &headersParam);
@@ -74,7 +77,7 @@
74 /// @param postArgs POST arguments77 /// @param postArgs POST arguments
75 /// @param headersParam HTTP headers78 /// @param headersParam HTTP headers
76 TwitterCommunicator(QString & url,79 TwitterCommunicator(QString & url,
77 RequestType type,80 LibRT::HTTPRequestType type,
78 ArgsMap &getArgs,81 ArgsMap &getArgs,
79 ArgsMap &postArgs,82 ArgsMap &postArgs,
80 HeadersMap &headersParam);83 HeadersMap &headersParam);
@@ -93,31 +96,11 @@
93 /// @brief Executing the request96 /// @brief Executing the request
94 virtual void executeRequest();97 virtual void executeRequest();
9598
96 /// @fn QByteArray getResponseBuffer();
97 /// @brief Getting the content of the response
98 /// @return The buffer containing the response
99 QByteArray getResponseBuffer();
100
101 /// @fn ResponseInfos getHttpResponse();
102 /// @brief Getting the HTTP response (code and reason).
103 /// @return The description of the HTTP return code.
104 ResponseInfos getHttpResponse();
105
106 /// @fn QString getReplyURL();
107 /// @brief Getting the URL of the reply.
108 /// @return replyURL
109 QString getReplyURL();
110
111 /// @fn QString getErrorMessage();
112 /// @brief Getter on the error massage
113 /// @return The error message
114 QString getErrorMessage();
115
11699
117 signals:100 signals:
118 /// @fn void requestDone();101 /// @fn void requestDone(NetworkResponse result);
119 /// @brief Signal indicating the end of a request102 /// @brief Signal indicating the end of a request
120 void requestDone();103 void requestDone(NetworkResponse result);
121104
122105
123 protected slots:106 protected slots:
@@ -131,9 +114,6 @@
131 void timeout();114 void timeout();
132115
133 protected:116 protected:
134 /// @brief Entity managing the Network (Internet).
135 QNetworkAccessManager * network;
136
137 /// @brief Timer to avoid to wait for responses ad vitam aeternam.117 /// @brief Timer to avoid to wait for responses ad vitam aeternam.
138 QTimer timeoutTimer;118 QTimer timeoutTimer;
139119
@@ -143,7 +123,7 @@
143 QString & serviceURL;123 QString & serviceURL;
144124
145 /// @brief Request type125 /// @brief Request type
146 RequestType requestType;126 LibRT::HTTPRequestType requestType;
147127
148 /// @brief GET datas128 /// @brief GET datas
149 ArgsMap & getParameters;129 ArgsMap & getParameters;
@@ -155,21 +135,6 @@
155 HeadersMap & headers;135 HeadersMap & headers;
156136
157137
158 // Entities for response
159
160 /// @brief Content of the response
161 QByteArray responseBuffer;
162
163 /// @brief HTTP response code and reason
164 ResponseInfos httpResponse;
165
166 /// @brief Error message
167 QString errorMessage;
168
169 /// @brief URL of the reply
170 QString replyURL;
171
172
173 private:138 private:
174 /// @fn QString buildGetDatas();139 /// @fn QString buildGetDatas();
175 /// @brief Building the string that will contain all the GET arguments140 /// @brief Building the string that will contain all the GET arguments
@@ -193,11 +158,6 @@
193 /// @param argsMap The argument map158 /// @param argsMap The argument map
194 /// @return A QString representation looks like val1=arg1&val2=arg2...159 /// @return A QString representation looks like val1=arg1&val2=arg2...
195 QString buildDatas(ArgsMap argsMap);160 QString buildDatas(ArgsMap argsMap);
196
197 /// @fn void extractHttpStatuses(QNetworkReply * reply);
198 /// @brief Extract the HTTP return code and reason of the request
199 /// @param reply Network reply containing the statuses.
200 void extractHttpStatuses(QNetworkReply * reply);
201};161};
202162
203#endif // TWITTERCOMMUNICATOR_HPP163#endif // TWITTERCOMMUNICATOR_HPP
204164
=== renamed file 'connection/model/headersmap.hpp' => 'connection/common/headersmap.hpp'
=== renamed file 'connection/model/requesttype.hpp' => 'connection/common/httprequesttype.hpp'
--- connection/model/requesttype.hpp 2012-09-12 22:38:35 +0000
+++ connection/common/httprequesttype.hpp 2013-08-20 00:10:09 +0000
@@ -1,12 +1,10 @@
1/// @file requesttype.hpp1/// @file httprequesttype.hpp
2/// @brief Header of RequestType2/// @brief Header of LibRT::HTTPRequestType
3///
4/// Revisions older than r242 were in /trunk/ReynTweets/connection
5/// @author Romain Ducher3/// @author Romain Ducher
6///4///
7/// @section LICENSE5/// @section LICENSE
8///6///
9/// Copyright 2011 Romain Ducher7/// Copyright 2011, 2013 Romain Ducher
10///8///
11/// This file is part of Reyn Tweets.9/// This file is part of Reyn Tweets.
12///10///
@@ -23,19 +21,21 @@
23/// You should have received a copy of the GNU Lesser General Public License21/// You should have received a copy of the GNU Lesser General Public License
24/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
2523
26#ifndef REQUESTTYPE_HPP24#ifndef HTTPREQUESTTYPE_HPP
27#define REQUESTTYPE_HPP25#define HTTPREQUESTTYPE_HPP
2826
29#include <QString>27#include <QString>
3028
31/// @enum RequestType29namespace LibRT {
32/// @brief Enum indicating the type of the request30 /// @enum HTTPRequestType
33enum RequestType {31 /// @brief Enum indicating the type of the request
34 /// @brief GET requests32 enum HTTPRequestType {
35 GET,33 /// @brief GET requests
3634 GET,
37 /// @brief POST requests35
38 POST36 /// @brief POST requests
39};37 POST
4038 };
41#endif // REQUESTTYPE_HPP39}
40
41#endif // HTTPREQUESTTYPE_HPP
4242
=== added file 'connection/common/networkresult.cpp'
--- connection/common/networkresult.cpp 1970-01-01 00:00:00 +0000
+++ connection/common/networkresult.cpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,88 @@
1/// @file networkresult.cpp
2/// @brief Implementation of NetworkResponse
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2011 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#include "networkresult.hpp"
25
26// Constructor
27NetworkResponse::NetworkResponse(LibRT::HTTPCode httpCode,
28 QString httpReason,
29 QByteArray response,
30 QString error,
31 QString repURL) :
32 httpResponse(httpCode, httpReason),
33 responseBody(response),
34 requestError(error),
35 replyURL(repURL)
36{}
37
38// Building a NetworkResponse with the content of a QNetworkReply.
39NetworkResponse::NetworkResponse(QNetworkReply * reply) :
40 httpResponse(extractHttpStatusesFromNetworkReply(reply)),
41 responseBody(reply ? reply->readAll() : ""),
42 requestError(reply ? reply->errorString() : "null reply"),
43 replyURL(reply ? reply->url().toString() : LibRT::FAKE_URL)
44{}
45
46// Extracting the HTTP code and the HTTP reason from an HTTP reply.
47ResponseInfos NetworkResponse::extractHttpStatusesFromNetworkReply(QNetworkReply * reply) {
48 ResponseInfos httpResponse;
49
50 if (reply) {
51 QVariant httpStatus;
52
53 // Extract return code
54 httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
55 httpResponse.code = httpStatus.toInt();
56
57 // Extract return reason
58 httpStatus = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute);
59 httpResponse.message = QString::fromLatin1(httpStatus.toByteArray());
60 }
61
62
63 return httpResponse;
64}
65
66/////////////
67// Getters //
68/////////////
69
70// httpResponse
71ResponseInfos NetworkResponse::getHttpResponse() {
72 return httpResponse;
73}
74
75// responseBody
76QByteArray NetworkResponse::getResponseBody() {
77 return responseBody;
78}
79
80// requestError
81QString NetworkResponse::getRequestError() {
82 return requestError;
83}
84
85// replyURL
86QString NetworkResponse::getReplyURL() {
87 return replyURL;
88}
089
=== added file 'connection/common/networkresult.hpp'
--- connection/common/networkresult.hpp 1970-01-01 00:00:00 +0000
+++ connection/common/networkresult.hpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,104 @@
1/// @file networkresult.hpp
2/// @brief Header of NetworkResponse
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2011 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef NETWORKRESPONSE_HPP
25#define NETWORKRESPONSE_HPP
26
27#include <QNetworkReply>
28#include "responseinfos.hpp"
29#include "utils/librtconstants.hpp"
30#include "utils/httpcode.hpp"
31
32/// @struct NetworkResponse
33/// @brief Struct with relevant elements of network reply
34class NetworkResponse {
35 public:
36
37 /// @fn NetworkResponse(LibRT::HTTPCode httpCode = LibRT::INVALID_HTTP_CODE,
38 /// QString httpReason = "",
39 /// QByteArray response = "",
40 /// QString error = "",
41 /// QString repURL = LibRT::FAKE_URL);
42 /// @brief Full constructor
43 /// @param httpCode Value for httpResponse.code.
44 /// @param httpReason Value for httpResponse.message.
45 /// @param response Value for responseBody.
46 /// @param error Value for requestError.
47 /// @param repURL Value for replyURL.
48 NetworkResponse(LibRT::HTTPCode httpCode = LibRT::INVALID_HTTP_CODE,
49 QString httpReason = "",
50 QByteArray response = "",
51 QString error = "",
52 QString repURL = LibRT::FAKE_URL);
53
54 /// @fn NetworkResponse(QNetworkReply * reply);
55 /// @brief Building a NetworkResponse with the content of a QNetworkReply.
56 /// @param reply the QNetworkReply
57 NetworkResponse(QNetworkReply * reply);
58
59
60 /////////////
61 // Getters //
62 /////////////
63
64 /// @fn ResponseInfos getHttpResponse();
65 /// @brief Getter on httpResponse.
66 /// @return httpResponse
67 ResponseInfos getHttpResponse();
68
69 /// @fn QByteArray getResponseBody();
70 /// @brief Getter on responseBody.
71 /// @return responseBody
72 QByteArray getResponseBody();
73
74 /// @fn QString getRequestError();
75 /// @brief Getter on requestError.
76 /// @return requestError
77 QString getRequestError();
78
79 /// @fn QString getReplyURL();
80 /// @brief Getter on replyURL.
81 /// @return replyURL
82 QString getReplyURL();
83
84 protected:
85 /// @brief HTTP rsponse code and reason
86 ResponseInfos httpResponse;
87
88 /// @brief Content of the response
89 QByteArray responseBody;
90
91 /// @brief Error which happened in the request
92 QString requestError;
93
94 /// @brief Reply URL
95 QString replyURL;
96
97 /// @fn ResponseInfos extractHttpStatusesFromNetworkReply(QNetworkReply reply);
98 /// @brief Extracting the HTTP code and the HTTP reason from an HTTP reply.
99 /// @param reply The QNetworkReply containing the reply of the HTTP request.
100 /// @return A ResponseInfos with the code and the reason.
101 ResponseInfos extractHttpStatusesFromNetworkReply(QNetworkReply * reply);
102};
103
104#endif // NETWORKRESPONSE_HPP
0105
=== renamed file 'connection/model/errortypes.hpp' => 'connection/common/networkresulttype.hpp'
--- connection/model/errortypes.hpp 2012-09-12 22:38:35 +0000
+++ connection/common/networkresulttype.hpp 2013-08-20 00:10:09 +0000
@@ -1,10 +1,10 @@
1/// @file errortypes.hpp1/// @file networkresulttype.hpp
2/// @brief Header containing the ErrorType enum2/// @brief Header containing the LibRT::NetworkResultType enum
3/// @author Romain Ducher3/// @author Romain Ducher
4///4///
5/// @section LICENSE5/// @section LICENSE
6///6///
7/// Copyright 2011 Romain Ducher7/// Copyright 2011, 2012 Romain Ducher
8///8///
9/// This file is part of Reyn Tweets.9/// This file is part of Reyn Tweets.
10///10///
@@ -24,37 +24,42 @@
24#ifndef ERRORTYPES_HPP24#ifndef ERRORTYPES_HPP
25#define ERRORTYPES_HPP25#define ERRORTYPES_HPP
2626
27/// @enum ErrorType27/// @namespace LibRT
28/// @brief Enumeration which indicates if something bad happened during the28/// @brief General namespace for stuff related to libRT (connection part of Reyn Tweets)
29/// request. It can takes three values depending on what happened. See the29namespace LibRT {
30/// enum values for more details.30 /// @enum NetworkResultType
31enum ErrorType {31 /// @brief Enumeration which indicates if something bad happened during the
32 /// @brief Code indicating that there was no error.32 /// request. It can takes three values depending on what happened. See the
33 NO_ERROR,33 /// enum values for more details.
3434 enum NetworkResultType {
35 /// @brief Code for an invalid request result.35 /// @brief There was no error.
36 INVALID_RESULT,36 NO_REQUEST_ERROR,
3737
38 /// @brief Code indicating that there were an error while calling the38 /// @brief Code for an invalid request result.
39 /// Twitter API.39 INVALID_RESULT,
40 API_CALL,40
4141 /// @brief There were an error while calling the API.
42 /// @brief Code indicating that the service (ex. Twitter) has returned errors.42 API_CALL,
43 SERVICE_ERRORS,43
4444 /// @brief The service (ex. Twitter) has returned errors.
45 /// @brief Code indicating that there was an error while parsing results45 SERVICE_ERRORS,
46 /// with <a href="http://qjson.sourceforge.net">QJson</a>.46
47 QJSON_PARSING,47 /// @brief There was an error while parsing JSON.
4848 JSON_PARSING,
49 /// @brief Code indicating that there was an error while parsing results49
50 /// under the form <code>arg1=val1&arg2=val2&...&argN=valN</code>.50 /// @brief There was an error while parsing results under the form
51 OAUTH_PARSING,51 /// <code>arg1=val1&arg2=val2&...&argN=valN</code>.
5252 OAUTH_PARSING,
53 /// @brief Code indicating that there was an error while parsing HTML.53
54 HTML_PARSING,54 /// @brief There was an error while parsing HTML.
5555 HTML_PARSING,
56 /// @brief Code indicating that there was an error while parsing XML.56
57 XML_PARSING57 /// @brief There was an error while parsing XML.
58};58 XML_PARSING,
59
60 /// @brief There is not any parsing.
61 NO_PARSING
62 };
63}
5964
60#endif // ERRORTYPES_HPP65#endif // ERRORTYPES_HPP
6166
=== renamed file 'connection/model/requestresult.hpp' => 'connection/common/requestresult.hpp'
--- connection/model/requestresult.hpp 2012-09-12 22:38:35 +0000
+++ connection/common/requestresult.hpp 2013-08-20 00:10:09 +0000
@@ -27,16 +27,17 @@
27#define REQUESTRESULT_HPP27#define REQUESTRESULT_HPP
2828
29#include <QVariant>29#include <QVariant>
30#include "errortypes.hpp"30#include "networkresulttype.hpp"
31#include "responseinfos.hpp"31#include "responseinfos.hpp"
32#include "utils/httpcode.hpp"
3233
33/// @struct RequestResult34/// @struct RequestResult
34/// @brief Results of a request35/// @brief Results of a request
35struct RequestResult {36struct RequestResult {
36 /// @brief Code indicating whether an error occured during the request.37 /// @brief Code indicating whether an error occured during the request.
37 ErrorType resultType;38 LibRT::NetworkResultType resultType;
3839
39 /// @brief Results of the request parsed by QJson.40 /// @brief Parsed results.
40 QVariant parsedResult;41 QVariant parsedResult;
4142
42 /// @brief HTTP response (code and reason)43 /// @brief HTTP response (code and reason)
@@ -57,13 +58,20 @@
57 /// @fn RequestResult();58 /// @fn RequestResult();
58 /// @brief Constructor59 /// @brief Constructor
59 RequestResult() :60 RequestResult() :
60 resultType(INVALID_RESULT),61 resultType(LibRT::INVALID_RESULT),
61 parsedResult(),62 parsedResult(),
62 httpResponse(),63 httpResponse(),
63 serviceErrors(),64 serviceErrors(),
64 parsingErrors(),65 parsingErrors(),
65 errorMessage("")66 errorMessage("")
66 {}67 {}
68
69 /// @fn LibRT::HTTPCode getHTTPCode();
70 /// @brief HTTP response code (shortcut)
71 /// @return The HTTP response code as a LibRT::HTTPCode.
72 LibRT::HTTPCode getHTTPCode() {
73 return LibRT::HTTPCode(httpResponse.code);
74 }
67};75};
6876
69#endif // REQUESTRESULT_HPP77#endif // REQUESTRESULT_HPP
7078
=== added directory 'connection/common/requests'
=== renamed file 'connection/requests/genericrequester.cpp' => 'connection/common/requests/genericrequester.cpp'
--- connection/requests/genericrequester.cpp 2012-06-06 23:26:13 +0000
+++ connection/common/requests/genericrequester.cpp 2013-08-20 00:10:09 +0000
@@ -22,12 +22,13 @@
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
2323
24#include "genericrequester.hpp"24#include "genericrequester.hpp"
25#include "../../tools/parsers/jsonparser.hpp"25#include "../utils/parsers/jsonparser.hpp"
26#include "../utils/librtconstants.hpp"
2627
27// Constructor. It just calls the parent constructor.28// Constructor. It just calls the parent constructor.
28GenericRequester::GenericRequester(RequestType type,29GenericRequester::GenericRequester(LibRT::HTTPRequestType type,
29 QString url,30 QString url,
30 ErrorType parseError) :31 LibRT::NetworkResultType parseError) :
31 QObject(),32 QObject(),
32 uuid(QUuid::createUuid()),33 uuid(QUuid::createUuid()),
33 requestURL(url),34 requestURL(url),
@@ -36,8 +37,7 @@
36 postParameters(),37 postParameters(),
37 headers(),38 headers(),
38 weblink(requestURL, requestType, getParameters, postParameters, headers),39 weblink(requestURL, requestType, getParameters, postParameters, headers),
39 parsingErrorType(parseError),40 parsingErrorType(parseError)
40 requestResult()
41{}41{}
4242
4343
@@ -49,18 +49,13 @@
49// Getters //49// Getters //
50/////////////50/////////////
5151
52// Getting parsed results
53RequestResult GenericRequester::getRequestResult() {
54 return requestResult;
55}
56
57// Getter on the requester's UUID52// Getter on the requester's UUID
58QUuid GenericRequester::getUuid() {53QUuid GenericRequester::getUuid() {
59 return uuid;54 return uuid;
60}55}
6156
62// Setting parsingErrorType57// Setting parsingErrorType
63void GenericRequester::setParsingErrorType(ErrorType parseErrorType) {58void GenericRequester::setParsingErrorType(LibRT::NetworkResultType parseErrorType) {
64 parsingErrorType = parseErrorType;59 parsingErrorType = parseErrorType;
65}60}
6661
@@ -72,17 +67,11 @@
72// Building GET Parameters67// Building GET Parameters
73void GenericRequester::buildGETParameters() {}68void GenericRequester::buildGETParameters() {}
7469
75// Bbuilding POST Parameters70// Building POST Parameters
76void GenericRequester::buildPOSTParameters() {}71void GenericRequester::buildPOSTParameters() {}
7772
78// Bbuilding HTTP Headers73// Building HTTP Headers
79void GenericRequester::buildHTTPHeaders() {74void GenericRequester::buildHTTPHeaders() {}
80 // Be careful for update with medias
81 #ifndef Q_OS_SYMBIAN
82 // Needed for Qt 4.8.x (Windows and Linux) and Symbian version is 4.7.4.
83 headers.insert("Content-Type", "application/x-www-form-urlencoded");
84 #endif
85}
8675
87// Executing the request76// Executing the request
88void GenericRequester::executeRequest() {77void GenericRequester::executeRequest() {
@@ -91,8 +80,8 @@
91 buildHTTPHeaders();80 buildHTTPHeaders();
9281
93 // Request time !82 // Request time !
94 connect(&weblink, SIGNAL(requestDone()),83 connect(&weblink, &TwitterCommunicator::requestDone,
95 this, SLOT(treatResults()));84 this, &GenericRequester::treatResults);
9685
97 weblink.executeRequest();86 weblink.executeRequest();
98}87}
@@ -103,36 +92,55 @@
103//////////////////////////92//////////////////////////
10493
105// Slot executed when the Twitter Communicator has just finished its work.94// Slot executed when the Twitter Communicator has just finished its work.
106void GenericRequester::treatResults() {95void GenericRequester::treatResults(NetworkResponse netResponse) {
107 disconnect(&weblink, SIGNAL(requestDone()),96 disconnect(&weblink, &TwitterCommunicator::requestDone,
108 this, SLOT(treatResults()));97 this, &GenericRequester::treatResults);
98
99 RequestResult requestResult;
109100
110 // Looking the HTTP request101 // Looking the HTTP request
111 requestResult.httpResponse = weblink.getHttpResponse();102 ResponseInfos netHTTPRep = netResponse.getHttpResponse();
112 requestResult.errorMessage = weblink.getErrorMessage();103 requestResult.httpResponse = netHTTPRep;
113104 requestResult.errorMessage = netResponse.getRequestError();
114 int httpReturnCode = weblink.getHttpResponse().code;105
115106 switch (netHTTPRep.code) {
116 if (httpReturnCode == 0) {107 case LibRT::INVALID_HTTP_CODE:
117 // No response => API_CALL108 // Invalid response => INVALID_RESULT
118 requestResult.resultType = API_CALL;109 requestResult.resultType = LibRT::INVALID_RESULT;
119 } else {110 break;
120 // A response to parse111
121 bool parseOK;112 case LibRT::TIMEOUT_HTTP_CODE:
122 QVariantMap parseErrorMap;113 // No response (because of timeout) => API_CALL
123 requestResult.parsedResult = this->parseResult(parseOK, parseErrorMap);114 requestResult.resultType = LibRT::API_CALL;
124 requestResult.resultType = parseOK ? NO_ERROR : parsingErrorType;115 break;
125 requestResult.parsingErrors.code = parseErrorMap.value("lineError").toInt();116
126 requestResult.parsingErrors.message = parseErrorMap.value("errorMsg").toString();117 default: {
127118 // Parsing the response and filling requestResult
128 if (!parseOK) {119 bool parseOK;
129 // Giving the response just in case the user would like to do sthg with it.120 QVariantMap parseErrorMap;
130 requestResult.parsedResult = QVariant::fromValue(weblink.getResponseBuffer());121 requestResult.parsedResult = this->parseResult(netResponse,
131 } else {122 parseOK,
132 this->treatParsedResult();123 parseErrorMap);
133 }124 requestResult.parsingErrors.code = parseErrorMap.value("lineError").toInt();
125 requestResult.parsingErrors.message = parseErrorMap.value("errorMsg").toString();
126
127 if (parseOK) {
128 // Other treatments related to the service
129 requestResult.serviceErrors = this->treatServiceErrors(requestResult.parsedResult,
130 netResponse);
131 // Updating the NetworkResultType with service errors
132 requestResult.resultType = requestResult.serviceErrors.isEmpty() ?
133 LibRT::NO_REQUEST_ERROR
134 : LibRT::SERVICE_ERRORS;
135 } else {
136 requestResult.resultType = parsingErrorType;
137
138 // Giving the response just in case the user would like to do sthg with it.
139 requestResult.parsedResult = QVariant::fromValue(netResponse.getResponseBody());
140 }
141 } break;
134 }142 }
135143
136 // Telling the ReynTwitterCalls that the request is finished144 // Telling the Calls that the request is finished
137 emit requestDone();145 emit requestDone(requestResult);
138}146}
139147
=== renamed file 'connection/requests/genericrequester.hpp' => 'connection/common/requests/genericrequester.hpp'
--- connection/requests/genericrequester.hpp 2012-09-12 23:18:26 +0000
+++ connection/common/requests/genericrequester.hpp 2013-08-20 00:10:09 +0000
@@ -27,8 +27,9 @@
27#include <QObject>27#include <QObject>
28#include <QUuid>28#include <QUuid>
29#include <QVariant>29#include <QVariant>
30#include "../model/requestresult.hpp"30#include "../requestresult.hpp"
31#include "../twittercommunicators/twittercommunicator.hpp"31#include "../communicators/twittercommunicator.hpp"
32#include "../networkresult.hpp"
3233
33/// @class GenericRequester34/// @class GenericRequester
34/// @brief Base class for all the requesters.35/// @brief Base class for all the requesters.
@@ -37,19 +38,19 @@
37 Q_OBJECT38 Q_OBJECT
3839
39 public:40 public:
40 /// @fn GenericRequester(RequestType type,41 /// @fn GenericRequester(Network::HTTPRequestType type,
41 /// QString url,42 /// QString url,
42 /// ErrorType parseError = QJSON_PARSING);43 /// LibRT::NetworkResultType parseError = Network::JSON_PARSING);
43 /// @brief Constructor44 /// @brief Constructor
44 /// @param type Type of the request (GET ou POST).45 /// @param type Type of the request (GET ou POST).
45 /// @param url URL called by the requester46 /// @param url URL called by the requester
46 /// @param parseError Error type if an error occurs while parsing. Most47 /// @param parseError Error type if an error occurs while parsing. Most
47 /// of the time, this value is set to QJSON_PARSING because results are48 /// of the time, this value is set to JSON_PARSING because results are
48 /// QJson stream parsed with QJson. However, OAuth requesters use their49 /// written in JSON. However, OAuth requesters use their
49 /// own parsing process so they need a special value called OAUTH_PARSING.50 /// own parsing process so they need a special value called OAUTH_PARSING.
50 GenericRequester(RequestType type,51 GenericRequester(LibRT::HTTPRequestType type,
51 QString url,52 QString url,
52 ErrorType parseError = QJSON_PARSING);53 LibRT::NetworkResultType parseError = LibRT::JSON_PARSING);
5354
54 /// @fn virtual ~GenericRequester();55 /// @fn virtual ~GenericRequester();
55 /// @brief Destructor.56 /// @brief Destructor.
@@ -66,11 +67,6 @@
66 /// from the other ones.67 /// from the other ones.
67 virtual void executeRequest();68 virtual void executeRequest();
6869
69 /// @fn RequestResult getRequestResult();
70 /// @brief Getting parsed results
71 /// @return Parsed results in a QVariant object.
72 RequestResult getRequestResult();
73
74 protected:70 protected:
75 /// @brief UUID of the request71 /// @brief UUID of the request
76 QUuid uuid;72 QUuid uuid;
@@ -79,7 +75,7 @@
79 QString requestURL;75 QString requestURL;
8076
81 /// @brief Request type77 /// @brief Request type
82 RequestType requestType;78 LibRT::HTTPRequestType requestType;
8379
84 /// @brief GET parameters that will be passed to the Communicator.80 /// @brief GET parameters that will be passed to the Communicator.
85 ArgsMap getParameters;81 ArgsMap getParameters;
@@ -98,8 +94,8 @@
98 /// @brief HTTP headers that will be passed to the Communicator.94 /// @brief HTTP headers that will be passed to the Communicator.
99 HeadersMap headers;95 HeadersMap headers;
10096
101 /// @fn virtual void buildPOSTParameters();97 /// @fn virtual void buildHTTPHeaders();
102 /// @brief Virtual method building postParameters98 /// @brief Virtual method building headers
103 virtual void buildHTTPHeaders();99 virtual void buildHTTPHeaders();
104100
105 /// @brief Pointer on the Twitter Communicator that will purely execute101 /// @brief Pointer on the Twitter Communicator that will purely execute
@@ -107,13 +103,13 @@
107 TwitterCommunicator weblink;103 TwitterCommunicator weblink;
108104
109 /// @brief Type of parsing error105 /// @brief Type of parsing error
110 ErrorType parsingErrorType;106 LibRT::NetworkResultType parsingErrorType;
111107
112 /// @fn void setParsingErrorType(ErrorType parseErrorType);108 /// @fn void setParsingErrorType(LibRT::NetworkResultType parseErrorType);
113 /// @brief Setting parsingErrorType in classes which inherits from109 /// @brief Setting parsingErrorType in classes which inherits from
114 /// GenericRequesters.110 /// GenericRequesters.
115 /// @param parseErrorType New value for parsingErrorType111 /// @param parseErrorType New value for parsingErrorType
116 void setParsingErrorType(ErrorType parseErrorType);112 void setParsingErrorType(LibRT::NetworkResultType parseErrorType);
117113
118114
119 //////////////////////////115 //////////////////////////
@@ -121,35 +117,44 @@
121 //////////////////////////117 //////////////////////////
122118
123 public slots:119 public slots:
124 /// @fn void treatResults();120 /// @fn void treatResults(NetworkResponse netResponse);
125 /// @brief Slot that is executed when the Twitter Communicator has just121 /// @brief Slot that is executed when the Twitter Communicator has just
126 /// finished its work.122 /// finished its work.
127 void treatResults();123 /// @param netResponse Struct with response elements
124 void treatResults(NetworkResponse netResponse);
128125
129 protected:126 protected:
130 /// @brief Result of the request.127 /// @fn virtual QVariant parseResult(NetworkResponse results,
131 RequestResult requestResult;128 /// bool & parseOK,
132
133 /// @fn virtual QVariant parseResult(bool & parseOK,
134 /// QVariantMap & parsingErrors) = 0;129 /// QVariantMap & parsingErrors) = 0;
135 /// @brief Method that will parse the raw results of the request.130 /// @brief Method that will parse the raw results of the request.
131 /// @param results Results to parse. Most of the time the method only
132 /// uses the responseBody field.
136 /// @param parseOK Boolean whose value will be set to true if there was133 /// @param parseOK Boolean whose value will be set to true if there was
137 /// no problem while parsing, false otherwise.134 /// no problem while parsing, false otherwise.
138 /// @param parsingErrors QVariantMap that may contain information about135 /// @param parsingErrors QVariantMap that may contain information about
139 /// errors that may occur while parsing.136 /// errors that may occur while parsing.
140 /// @return Parsed results137 /// @return Parsed results
141 virtual QVariant parseResult(bool & parseOK,138 virtual QVariant parseResult(NetworkResponse results,
139 bool & parseOK,
142 QVariantMap & parsingErrors) = 0;140 QVariantMap & parsingErrors) = 0;
143141
144 /// @fn virtual void treatParsedResult() = 0;142 /// @fn virtual QList<ResponseInfos> treatServiceErrors(QVariant parsedResults,
143 /// NetworkResponse netResponse) = 0;
145 /// @brief Treating parsed results144 /// @brief Treating parsed results
146 virtual void treatParsedResult() = 0;145 /// @param parsedResults Parsed results to analyse in order to retrieve
146 /// service errors.
147 /// @param netResponse Other network response elements, if needed.
148 /// @return The list of service errors
149 virtual QList<ResponseInfos> treatServiceErrors(QVariant parsedResults,
150 NetworkResponse netResponse) = 0;
147151
148 signals:152 signals:
149 /// @fn void requestDone();153 /// @fn void requestDone(RequestResult requestResult);
150 /// @brief Signal sent when the results of the request received by154 /// @brief Signal sent when the results of the request received by
151 /// the Twitter Communicator have been treated.155 /// the Twitter Communicator have been treated.
152 void requestDone();156 /// @param requestResult Result of the request.
157 void requestDone(RequestResult requestResult);
153};158};
154159
155#endif // GENERICREQUESTER_HPP160#endif // GENERICREQUESTER_HPP
156161
=== renamed file 'connection/model/identificationway.hpp' => 'connection/common/requests/identificationway.hpp'
--- connection/model/identificationway.hpp 2012-09-12 22:38:35 +0000
+++ connection/common/requests/identificationway.hpp 2013-08-20 00:10:09 +0000
@@ -1,5 +1,5 @@
1/// @file identificationway.hpp1/// @file identificationway.hpp
2/// @brief Header of IdentificationWay2/// @brief Header of LibRT::IdentificationWay
3/// @author Romain Ducher3/// @author Romain Ducher
4///4///
5/// @section LICENSE5/// @section LICENSE
@@ -24,14 +24,16 @@
24#ifndef IDENTIFICATIONWAY_HPP24#ifndef IDENTIFICATIONWAY_HPP
25#define IDENTIFICATIONWAY_HPP25#define IDENTIFICATIONWAY_HPP
2626
27/// @enum IdentificationWay27namespace LibRT {
28/// @brief How the user is identified in a request ?28 /// @enum IdentificationWay
29enum IdentificationWay {29 /// @brief How the user is identified in a request ?
30 /// @brief With an ID.30 enum IdentificationWay {
31 ID,31 /// @brief With an ID.
32 ID,
3233
33 /// @brief With a screen name34 /// @brief With a screen name
34 SCREEN_NAME35 SCREEN_NAME
35};36 };
37}
3638
37#endif // IDENTIFICATIONWAY_HPP39#endif // IDENTIFICATIONWAY_HPP
3840
=== renamed file 'connection/model/responseinfos.hpp' => 'connection/common/responseinfos.hpp'
--- connection/model/responseinfos.hpp 2012-09-12 22:38:35 +0000
+++ connection/common/responseinfos.hpp 2013-08-20 00:10:09 +0000
@@ -29,18 +29,27 @@
29/// @struct ResponseInfos29/// @struct ResponseInfos
30/// @brief Struct with an integer (field "code") and its meaning (field "message").30/// @brief Struct with an integer (field "code") and its meaning (field "message").
31///31///
32/// When used to store QJSON parsing errors, "message" is the error message and32/// When used to store JSON parsing errors, "message" is the error message and
33/// "code" the number of the line where the error occurs.33/// "code" the offset.
34struct ResponseInfos {34struct ResponseInfos {
35 /// @brief Code35 /// @brief Code
36 int code;36 int code;
3737
38 /// @brief Decription of the code38 /// @brief Decription of the code
39 QString message;39 QString message;
4040/*
41 /// @fn ResponseInfos();41 /// @fn ResponseInfos();
42 /// @brief Constructor42 /// @brief Constructor
43 ResponseInfos() : code(-1), message("") {}43 ResponseInfos() : code(-1), message("") {}
44//*/
45 /// @fn ResponseInfos(int codeNum = -1, QString msg = "");
46 /// @brief Full constructor
47 /// @param codeNum Value for code
48 /// @param msg Value for message
49 ResponseInfos(int codeNum = -1, QString msg = "") :
50 code(codeNum),
51 message(msg)
52 {}
44};53};
4554
46#endif // RESPONSEINFOS_HPP55#endif // RESPONSEINFOS_HPP
4756
=== renamed file 'connection/model/resultwrapper.cpp' => 'connection/common/resultwrapper.cpp'
--- connection/model/resultwrapper.cpp 2012-09-12 22:38:35 +0000
+++ connection/common/resultwrapper.cpp 2013-08-20 00:10:09 +0000
@@ -1,5 +1,5 @@
1/// @file resultwrapper.cpp1/// @file resultwrapper.cpp
2/// @brief Implementation of ResultSender2/// @brief Implementation of ResultWrapper
3///3///
4/// Revisions older than r242 were in /trunk/ReynTweets/connection4/// Revisions older than r242 were in /trunk/ReynTweets/connection
5/// @author Romain Ducher5/// @author Romain Ducher
66
=== renamed file 'connection/model/resultwrapper.hpp' => 'connection/common/resultwrapper.hpp'
=== added directory 'connection/common/utils'
=== renamed file 'tools/utils.cpp' => 'connection/common/utils/connectionutils.cpp'
--- tools/utils.cpp 2012-05-04 02:46:20 +0000
+++ connection/common/utils/connectionutils.cpp 2013-08-20 00:10:09 +0000
@@ -1,5 +1,5 @@
1/// @file utils.cpp1/// @file connectionutils.cpp
2/// @brief Implementation of the useful methods declared in utils.hpp.2/// @brief Implementation of the useful methods declared in connectionutils.hpp.
3///3///
4/// Revisions older than r120 are in the folder /trunk/ReynTweets/connection/.4/// Revisions older than r120 are in the folder /trunk/ReynTweets/connection/.
5/// @author Romain Ducher5/// @author Romain Ducher
@@ -23,23 +23,24 @@
23/// You should have received a copy of the GNU Lesser General Public License23/// You should have received a copy of the GNU Lesser General Public License
24/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.24/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
2525
26#include "connectionutils.hpp"
26#include <QCryptographicHash>27#include <QCryptographicHash>
27#include <QJson/QObjectHelper>28#include <QVariant>
28#include <QJson/Parser>29#include <QMapIterator>
29#include <QJson/Serializer>30#include <QMetaProperty>
31#include <QJsonDocument>
30#include <QUrl>32#include <QUrl>
31#include "utils.hpp"
3233
33///////////////////////34///////////////////////
34// String convertion //35// String convertion //
35///////////////////////36///////////////////////
3637
37// Converting a RequestType into a QString38// Converting a RequestType into a QString
38QString requestTypeToString(RequestType type) {39QString requestTypeToString(LibRT::HTTPRequestType type) {
39 switch (type) {40 switch (type) {
40 case GET:41 case LibRT::GET:
41 return "GET";42 return "GET";
42 case POST:43 case LibRT::POST:
43 return "POST";44 return "POST";
44 default:45 default:
45 return "";46 return "";
@@ -63,84 +64,13 @@
63}64}
6465
6566
66////////////////////
67// JSON Streaming //
68////////////////////
69
70// Output stream operator for serialization
71QDataStream & jsonStreamingOut(QDataStream & out,
72 const QObject & objectToStream,
73 const QStringList & blacklist)
74{
75 // Converting the object into a JSON file
76 QVariantMap accountMap = QJson::QObjectHelper::qobject2qvariant(&objectToStream, blacklist);
77 QJson::Serializer serializer;
78 QByteArray jsonedAccount = serializer.serialize(accountMap);
79
80 // Putting it in the stream
81 out << jsonedAccount;
82
83 return out;
84}
85
86// Input stream operator for serialization
87QDataStream & jsonStreamingIn(QDataStream & in, QObject & objectToStream) {
88 QByteArray jsonedAccount = "";
89 in >> jsonedAccount;
90
91 QJson::Parser parser;
92 bool parseOK;
93 QVariant accountVariant = parser.parse(jsonedAccount, &parseOK);
94
95 if (parseOK) {
96 QJson::QObjectHelper::qvariant2qobject(accountVariant.toMap(), &objectToStream);
97 }
98
99 return in;
100}
101
102
103//////////////////67//////////////////
104// Miscanellous //68// Miscanellous //
105//////////////////69//////////////////
10670
107// HMAC-SHA1 algorithm for signatures.
108QString hmacSha1(QByteArray key, QByteArray baseString) {
109 int blockSize = 64; // HMAC-SHA-1 block size, defined in SHA-1 standard
110
111 if (key.length() > blockSize) {
112 // if key is longer than block size (64), reduce key length with
113 // SHA-1 compression
114 key = QCryptographicHash::hash(key, QCryptographicHash::Sha1);
115 }
116
117 // initialize inner padding with char "6"
118 QByteArray innerPadding(blockSize, char(0x36));
119 // initialize outer padding with char "\"
120 QByteArray outerPadding(blockSize, char(0x5c));
121
122 // ascii characters 0x36 ("6") and 0x5c ("\") are selected because they have
123 // large Hamming distance (http://en.wikipedia.org/wiki/Hamming_distance)
124
125 for (int i = 0; i < key.length(); i++) {
126 // XOR operation between every byte in key and innerpadding, of key length
127 innerPadding[i] = innerPadding[i] ^ key.at(i);
128 // XOR operation between every byte in key and outerpadding, of key length
129 outerPadding[i] = outerPadding[i] ^ key.at(i);
130 }
131
132 // result = hash ( outerPadding CONCAT hash ( innerPadding CONCAT baseString ) ).toBase64
133 QByteArray total = outerPadding;
134 QByteArray part = innerPadding;
135 part.append(baseString);
136 total.append(QCryptographicHash::hash(part, QCryptographicHash::Sha1));
137 QByteArray hashed = QCryptographicHash::hash(total, QCryptographicHash::Sha1);
138 return hashed.toBase64();
139}
140
141// Exclusive OR71// Exclusive OR
142bool ouBien(bool a, bool b) {72bool ouBien(bool a, bool b) {
143 return (a && !b) || (!a && b);73 return (a && !b) || (!a && b);
144}74}
14575
146// Formatting parameters in the Authorization header76// Formatting parameters in the Authorization header
14777
=== renamed file 'tools/utils.hpp' => 'connection/common/utils/connectionutils.hpp'
--- tools/utils.hpp 2012-09-12 22:38:35 +0000
+++ connection/common/utils/connectionutils.hpp 2013-08-20 00:10:09 +0000
@@ -1,4 +1,4 @@
1/// @file utils.hpp1/// @file connectionutils.hpp
2/// @brief Header with useful methods2/// @brief Header with useful methods
3///3///
4/// Revisions older than r120 are in the folder /trunk/ReynTweets/connection/4/// Revisions older than r120 are in the folder /trunk/ReynTweets/connection/
@@ -23,24 +23,24 @@
23/// You should have received a copy of the GNU Lesser General Public License23/// You should have received a copy of the GNU Lesser General Public License
24/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.24/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
2525
26#ifndef UTILS_HPP26#ifndef CONNECTIONUTILS_HPP
27#define UTILS_HPP27#define CONNECTIONUTILS_HPP
2828
29#include <QByteArray>29#include <QByteArray>
30#include <QColor>30#include <QColor>
31#include <QDataStream>31#include <QDataStream>
32#include <QString>32#include <QString>
33#include "../connection/model/requesttype.hpp"33#include "../httprequesttype.hpp"
3434
35///////////////////////35///////////////////////
36// String convertion //36// String convertion //
37///////////////////////37///////////////////////
3838
39/// @fn QString requestTypeToString(RequestType type)39/// @fn QString requestTypeToString(Network::HTTPRequestType type)
40/// @brief Converting a RequestType into a QString40/// @brief Converting a RequestType into a QString
41/// @param type The RequestType41/// @param type The RequestType
42/// @return The corresponding QString42/// @return The corresponding QString
43QString requestTypeToString(RequestType type);43QString requestTypeToString(LibRT::HTTPRequestType type);
4444
45/// @fn QString boolInString(bool b);45/// @fn QString boolInString(bool b);
46/// @brief Converting a bool into a QString46/// @brief Converting a bool into a QString
@@ -48,62 +48,16 @@
48/// @return The corresponding QString48/// @return The corresponding QString
49QString boolInString(bool b);49QString boolInString(bool b);
5050
51/// @fn QColor string2color(QString coloredString);
52/// @brief Converting a String into a QColor.
53///
54/// This function was written because of Twitter which forgets the '#'
55/// character before the hexadecimal code under the form 'RRGGBB'.
56/// @param coloredString The string with the RRGGBB format.
57/// @return The corresponding color : &#135;RRGGBB
58QColor string2color(QString coloredString);
59
60
61////////////////////
62// JSON Streaming //
63////////////////////
64
65/// @fn QDataStream & jsonStreamingOut(QDataStream & out,
66/// const QObject & objectToStream,
67/// const QStringList & blacklist =
68/// QStringList(QString(QLatin1String("objectName"))));
69/// @brief Output stream operator for JSON serialization
70/// @param out The output stream
71/// @param objectToStream Object to put in the stream
72/// @param blacklist Properties to ignore while conserting the QObject into
73/// a QVariant before serializing.
74/// @return The stream with the object
75QDataStream & jsonStreamingOut(QDataStream & out,
76 const QObject & objectToStream,
77 const QStringList & blacklist = QStringList(QString(QLatin1String("objectName"))));
78
79/// @fn QDataStream & jsonStreamingIn(QDataStream & in, QObject & objectToStream);
80/// @brief Input stream operator for JSON serialization
81/// @param in The input stream
82/// @param objectToStream Object to put in the stream
83/// @return The stream with the object
84QDataStream & jsonStreamingIn(QDataStream & in, QObject & objectToStream);
85
8651
87//////////////////52//////////////////
88// Miscanellous //53// Miscanellous //
89//////////////////54//////////////////
9055
91/// @fn QString hmacSha1(QByteArray key, QByteArray baseString);
92/// @brief HMAC-SHA1 algorithm for signatures.
93///
94/// Its implementation for Reyn Tweets was found on the
95/// <a href="http://developer.qt.nokia.com/">Qt Developer Network</a> here :
96/// <a href="http://developer.qt.nokia.com/wiki/HMAC-SHA1">
97/// http://developer.qt.nokia.com/wiki/HMAC-SHA1</a>.
98/// @param key Key for signature
99/// @param baseString String that we want to sign
100/// @return The signature
101QString hmacSha1(QByteArray key, QByteArray baseString);
102
103/// @fn bool ouBien(bool a, bool b);56/// @fn bool ouBien(bool a, bool b);
104/// @brief Logical XOR : <code>a XOR b == a && !b || !a && b</code>57/// @brief Logical XOR : <code>a XOR b == a && !b || !a && b</code>
105/// @param a 1st bool58/// @param a 1st bool
106/// @param b 2nd bool59/// @param b 2nd bool
60/// @returns a XOR b
107bool ouBien(bool a, bool b);61bool ouBien(bool a, bool b);
10862
109/// @fn QString formatParam(QString name, QString value, bool putDoubleQuotes = false);63/// @fn QString formatParam(QString name, QString value, bool putDoubleQuotes = false);
@@ -124,4 +78,4 @@
124/// @return The formatted parameters78/// @return The formatted parameters
125QString formatParam(QString name, QString value, bool putDoubleQuotes = false);79QString formatParam(QString name, QString value, bool putDoubleQuotes = false);
12680
127#endif // UTILS_HPP81#endif // CONNECTIONUTILS_HPP
12882
=== added file 'connection/common/utils/httpcode.hpp'
--- connection/common/utils/httpcode.hpp 1970-01-01 00:00:00 +0000
+++ connection/common/utils/httpcode.hpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,286 @@
1/// @file httpcode.hpp
2/// @brief Header for the LibRT::HTTPCode enum.
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef HTTPCODE_HPP
25#define HTTPCODE_HPP
26
27namespace LibRT {
28
29 /// @enum HTTPCode
30 /// @brief Enum with the HTTP codes.
31 ///
32 /// It contains all the official HTTP return codes as defined by the
33 /// <a href="http://tools.ietf.org/html/rfc2616">RFC 2616</a> + two other
34 /// custom codes, LibRT::INVALID_HTTP_CODE (for fake values) and
35 /// LibRT::TIMEOUT_HTTP_CODE (for timeouts).
36 enum HTTPCode {
37 /// @brief Invalid HTTP response code
38 INVALID_HTTP_CODE = -1,
39
40 /// @brief HTTP response code for timeouts
41 TIMEOUT_HTTP_CODE = 0,
42
43 /// @brief 100 HTTP return code.
44 CONTINUE = 100,
45
46 /// @brief 101 HTTP return code.
47 SWITCHING_PROTOCOLS = 101,
48
49 /// @brief 102 HTTP return code.
50 PROCESSING = 102,
51
52 /// @brief 118 HTTP return code.
53 CONNECTION_TIMED_OUT = 118,
54
55 /// @brief 200 HTTP return code.
56 OK = 200,
57
58 /// @brief 201 HTTP return code.
59 CREATED = 201,
60
61 /// @brief 202 HTTP return code.
62 ACCEPTED = 202,
63
64 /// @brief 203 HTTP return code.
65 NON_AUTHORITATIVE_INFORMATION = 203,
66
67 /// @brief 204 HTTP return code.
68 NO_CONTENT = 204,
69
70 /// @brief 205 HTTP return code.
71 RESET_CONTENT = 205,
72
73 /// @brief 206 HTTP return code.
74 PARTIAL_CONTENT = 206,
75
76 /// @brief 207 HTTP return code.
77 MULTI_STATUS = 207,
78
79 /// @brief 208 HTTP return code.
80 ALREADY_REPORTED = 208,
81
82 /// @brief 210 HTTP return code.
83 CONTENT_DIFFERENT = 210,
84
85 /// @brief 226 HTTP return code.
86 IM_USED = 226,
87
88 /// @brief 300 HTTP return code.
89 MULTIPLE_CHOICES = 300,
90
91 /// @brief 301 HTTP return code.
92 MOVED_PERMANENTLY = 301,
93
94 /// @brief 302 HTTP return code.
95 MOVED_TEMPORARILY = 302,
96
97 /// @brief 303 HTTP return code.
98 SEE_OTHER = 303,
99
100 /// @brief 304 HTTP return code.
101 NOT_MODIFIED = 304,
102
103 /// @brief 305 HTTP return code.
104 USE_PROXY = 305,
105
106 /// @brief 306 HTTP return code.
107 SWITCH_PROXY = 306,
108
109 /// @brief 307 HTTP return code.
110 TEMPORARY_REDIRECT = 307,
111
112 /// @brief 308 HTTP return code.
113 PERMANENT_REDIRECT = 308,
114
115 /// @brief 310 HTTP return code.
116 TOO_MANY_REDIRECTS = 310,
117
118 /// @brief 400 HTTP return code.
119 BAD_REQUEST = 400,
120
121 /// @brief 401 HTTP return code.
122 UNAUTHORIZED = 401,
123
124 /// @brief 402 HTTP return code.
125 PAYMENT_REQUIRED = 402,
126
127 /// @brief 403 HTTP return code.
128 FORBIDDEN = 403,
129
130 /// @brief 404 HTTP return code.
131 NOT_FOUND = 404,
132
133 /// @brief 405 HTTP return code.
134 METHOD_NOT_ALLOWED = 405,
135
136 /// @brief 406 HTTP return code.
137 NOT_ACCEPTABLE = 406,
138
139 /// @brief 407 HTTP return code.
140 PROXY_AUTHENTICATION_REQUIRED = 407,
141
142 /// @brief 408 HTTP return code.
143 REQUEST_TIMEOUT = 408,
144
145 /// @brief 409 HTTP return code.
146 CONFLICT = 409,
147
148 /// @brief 410 HTTP return code.
149 GONE = 410,
150
151 /// @brief 411 HTTP return code.
152 LENGTH_REQUIRED = 411,
153
154 /// @brief 412 HTTP return code.
155 PRECONDITION_FAILED = 412,
156
157 /// @brief 413 HTTP return code.
158 REQUEST_ENTITY_TOO_LARGE = 413,
159
160 /// @brief 414 HTTP return code.
161 REQUEST_URI_TOO_LONG = 414,
162
163 /// @brief 415 HTTP return code.
164 UNSUPPORTED_MEDIA_TYPE = 415,
165
166 /// @brief 416 HTTP return code.
167 REQUEST_RANGE_UNSATISFIABLE = 416,
168
169 /// @brief 417 HTTP return code.
170 EXPECTATION_FAILED = 417,
171
172 /// @brief 418 HTTP return code.
173 I_AM_A_TEAPOT = 418,
174
175 /// @brief 419 HTTP return code.
176 AUTHENTICATION_TIMEOUT = 419,
177
178 /// @brief 420 HTTP return code (used by Twitter).
179 ENHANCE_YOUR_CALM = 420,
180
181 /// @brief 422 HTTP return code.
182 UNPROCESSABLLE_ENTITY = 422,
183
184 /// @brief 423 HTTP return code.
185 LOCKED = 423,
186
187 /// @brief 424 HTTP return code.
188 METHOD_FAILURE = 424,
189
190 /// @brief 424 HTTP return code (WebDAV + RFC 4918).
191 FAILED_DEPENDENCY = 424,
192
193 /// @brief 425 HTTP return code.
194 UNORDERED_COLLECTION = 425,
195
196 /// @brief 426 HTTP return code.
197 UPGRADE_REQUIRED = 426,
198
199 /// @brief 428 HTTP return code.
200 PRECONDITION_REQUIRED = 428,
201
202 /// @brief 429 HTTP return code.
203 TOO_MANY_REQUESTS = 429,
204
205 /// @brief 431 HTTP return code.
206 REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
207
208 /// @brief 444 HTTP return code.
209 NO_RESPONSE = 444,
210
211 /// @brief 449 HTTP return code.
212 RETRY_WITH = 449,
213
214 /// @brief 450 HTTP return code.
215 BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS = 450,
216
217 /// @brief 451 HTTP return code.
218 UNAVAILABLE_FOR_LEGAL_REASONS = 451,
219
220 /// @brief 456 HTTP return code.
221 UNRECOVERABLE_ERROR = 456,
222
223 /// @brief 494 HTTP return code.
224 REQUEST_HEADER_TOO_LARGE = 494,
225
226 /// @brief 495 HTTP return code.
227 CERT_ERROR = 495,
228
229 /// @brief 496 HTTP return code.
230 NO_CERT = 496,
231
232 /// @brief 497 HTTP return code.
233 HTTP_TO_HTTPS = 497,
234
235 /// @brief 499 HTTP return code.
236 CLIENT_HAS_CLOSED_CONNECTION = 499,
237
238 /// @brief 500 HTTP return code.
239 INTERNAL_SERVER_ERROR = 500,
240
241 /// @brief 501 HTTP return code.
242 NOT_IMPLEMENTED = 501,
243
244 /// @brief 502 HTTP return code.
245 BAD_GATEWAY = 502,
246
247 /// @brief 502 HTTP return code.
248 PROXY_ERROR = 502,
249
250 /// @brief 503 HTTP return code.
251 SERVICE_UNAVAILABLE = 503,
252
253 /// @brief 504 HTTP return code.
254 GATEWAY_TIMEOUT = 504,
255
256 /// @brief 505 HTTP return code.
257 HTTP_VERSION_NOT_SUPPORTED = 505,
258
259 /// @brief 506 HTTP return code.
260 VARIANT_ALSO_NEGOCIATE = 506,
261
262 /// @brief 507 HTTP return code.
263 INSUFFICENT_STORAGE = 507,
264
265 /// @brief 508 HTTP return code.
266 LOOP_DETECTED = 508,
267
268 /// @brief 509 HTTP return code.
269 BANDWITH_LIMIT_EXCEEDED = 509,
270
271 /// @brief 510 HTTP return code.
272 NOT_EXTENDED = 510,
273
274 /// @brief 511 HTTP return code.
275 NETWORK_AUTHENTICATION_REQUIRED = 511,
276
277 /// @brief 598 HTTP return code.
278 NETWORK_READ_TIMEOUT_ERROR = 598,
279
280 /// @brief 599 HTTP return code.
281 NETWORK_CONNECT_TIMEOUT_ERROR = 599
282 };
283
284}
285
286#endif // HTTPCODE_HPP
0287
=== added file 'connection/common/utils/librtconstants.cpp'
--- connection/common/utils/librtconstants.cpp 1970-01-01 00:00:00 +0000
+++ connection/common/utils/librtconstants.cpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,48 @@
1/// @file librtconstants.cpp
2/// @brief Implementation for libRT constants.
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#include "librtconstants.hpp"
25
26// Fake tweet ID
27const qlonglong LibRT::FAKE_ID = -1;
28
29/// @brief Generic fake value for ID represented by a string (empty string)
30const QString LibRT::FAKE_STRING_ID = "";
31
32// Fake longitude
33const float LibRT::FAKE_LONGITUDE = 181;
34
35// Fake latitude
36const float LibRT::FAKE_LATITUDE = 91;
37
38// Maximum longitude
39const float LibRT::MAX_LONGITUDE = 180;
40
41// Maximum latitude
42const float LibRT::MAX_LATITUDE = 90;
43
44// Fake value for a token (empty string)
45const QByteArray LibRT::FAKE_TOKEN = "";
46
47// Fake value for an URL (empty string)
48const QString LibRT::FAKE_URL = "";
049
=== added file 'connection/common/utils/librtconstants.hpp'
--- connection/common/utils/librtconstants.hpp 1970-01-01 00:00:00 +0000
+++ connection/common/utils/librtconstants.hpp 2013-08-20 00:10:09 +0000
@@ -0,0 +1,57 @@
1/// @file librtconstants.hpp
2/// @brief Header for libRT constants.
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2013 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef LIBRTCONSTANTS_HPP
25#define LIBRTCONSTANTS_HPP
26
27#include <QString>
28
29namespace LibRT {
30 /// @brief Generic fake ID.
31 extern const qlonglong FAKE_ID;
32
33 /// @brief Generic fake value for ID represented by a string (empty string)
34 extern const QString FAKE_STRING_ID;
35
36 /// @brief Fake longitude
37 extern const float FAKE_LONGITUDE;
38
39 /// @brief Fake latitude
40 extern const float FAKE_LATITUDE;
41
42 /// @brief Maximum absolute value for a longitude (180 since a valid
43 /// longitude is between -180 and +180).
44 extern const float MAX_LONGITUDE;
45
46 /// @brief Maximum absolute value for a latitude (180 since a valid
47 /// latitude is between -90 and +90).
48 extern const float MAX_LATITUDE;
49
50 /// @brief Fake value for a token (empty string)
51 extern const QByteArray FAKE_TOKEN;
52
53 /// @brief Fake value for an URL (empty string)
54 extern const QString FAKE_URL;
55}
56
57#endif // LIBRTCONSTANTS_HPP
058
=== renamed directory 'tools/parsers' => 'connection/common/utils/parsers'
=== modified file 'connection/common/utils/parsers/genericparser.hpp'
--- tools/parsers/genericparser.hpp 2012-05-19 15:39:56 +0000
+++ connection/common/utils/parsers/genericparser.hpp 2013-08-20 00:10:09 +0000
@@ -32,13 +32,13 @@
32/// @class GenericParser32/// @class GenericParser
33/// @brief Base class for all the parsers.33/// @brief Base class for all the parsers.
34/// @param T Type of parsed results34/// @param T Type of parsed results
35template <class T>35template <typename T>
36class GenericParser36class GenericParser
37{37{
38 public:38 public:
39 /// @fn virtual QVariantMap parse(QByteArray data,39 /// @fn virtual QVariantMap parse(QByteArray data,
40 /// bool & parseOK,40 /// bool * parseOK = 0,
41 /// QString & parseError,41 /// QString * parseError = 0,
42 /// int * lineError = 0,42 /// int * lineError = 0,
43 /// int * columnError = 0) = 0;43 /// int * columnError = 0) = 0;
44 /// @brief Method for parsing results44 /// @brief Method for parsing results
@@ -48,8 +48,8 @@
48 /// @param lineError Line of the error48 /// @param lineError Line of the error
49 /// @param columnError Column of the error49 /// @param columnError Column of the error
50 virtual T parse(QByteArray data,50 virtual T parse(QByteArray data,
51 bool & parseOK,51 bool * parseOK = 0,
52 QString & parseError,52 QString * parseError = 0,
53 int * lineError = 0,53 int * lineError = 0,
54 int * columnError = 0) = 0;54 int * columnError = 0) = 0;
55};55};
5656
=== modified file 'connection/common/utils/parsers/htmlparser.cpp'
--- tools/parsers/htmlparser.cpp 2012-05-19 15:39:56 +0000
+++ connection/common/utils/parsers/htmlparser.cpp 2013-08-20 00:10:09 +0000
@@ -23,27 +23,33 @@
23/// You should have received a copy of the GNU Lesser General Public License23/// You should have received a copy of the GNU Lesser General Public License
24/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.24/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
2525
26#include "htmlparser.hpp"
26#include <QWebFrame>27#include <QWebFrame>
27#include <QWebPage>28#include <QWebPage>
28#include "htmlparser.hpp"
2929
30// Parsing results30// Parsing results
31QWebElement HTMLParser::parse(QByteArray data,31QWebElement HTMLParser::parse(QByteArray data,
32 bool & parseOK,32 bool * parseOK,
33 QString & parseError,33 QString * parseError,
34 int *, int *)34 int *, int *)
35{35{
36 QWebPage webPage;36 QWebPage webPage;
37 QWebFrame * frame = webPage.mainFrame();37 QWebFrame * frame = webPage.mainFrame();
3838
39 if (parseOK) {
40 *parseOK = frame != 0;
41 }
42
39 if (frame) {43 if (frame) {
40 frame->setHtml(QString::fromUtf8(data.data()));44 frame->setHtml(QString::fromUtf8(data.data()));
41 parseOK = true;45 if (parseError) {
42 parseError = "";46 *parseError = "";
47 }
43 return frame->documentElement();48 return frame->documentElement();
44 } else {49 } else {
45 parseOK = false;50 if (parseError) {
46 parseError = QObject::trUtf8("No HTML parser available.").append('\n');51 *parseError = QObject::trUtf8("No HTML parser available.");
52 }
47 return QWebElement();53 return QWebElement();
48 }54 }
49}55}
5056
=== modified file 'connection/common/utils/parsers/htmlparser.hpp'
--- tools/parsers/htmlparser.hpp 2012-05-19 15:39:56 +0000
+++ connection/common/utils/parsers/htmlparser.hpp 2013-08-20 00:10:09 +0000
@@ -35,8 +35,8 @@
35{35{
36 public:36 public:
37 /// @fn QWebElement parse(QByteArray data,37 /// @fn QWebElement parse(QByteArray data,
38 /// bool & parseOK,38 /// bool * parseOK = 0,
39 /// QString & parseError,39 /// QString * parseError = 0,
40 /// int * lineError = 0,40 /// int * lineError = 0,
41 /// int * columnError = 0);41 /// int * columnError = 0);
42 /// @brief Method for parsing results42 /// @brief Method for parsing results
@@ -46,8 +46,8 @@
46 /// @param lineError Line of the error. Unused46 /// @param lineError Line of the error. Unused
47 /// @param columnError Column of the error. Unused47 /// @param columnError Column of the error. Unused
48 QWebElement parse(QByteArray data,48 QWebElement parse(QByteArray data,
49 bool & parseOK,49 bool * parseOK = 0,
50 QString & parseError,50 QString * parseError = 0,
51 int * lineError = 0,51 int * lineError = 0,
52 int * columnError = 0);52 int * columnError = 0);
53};53};
5454
=== modified file 'connection/common/utils/parsers/jsonparser.cpp'
--- tools/parsers/jsonparser.cpp 2012-05-19 15:39:56 +0000
+++ connection/common/utils/parsers/jsonparser.cpp 2013-08-20 00:10:09 +0000
@@ -1,12 +1,13 @@
1/// @file jsonparser.cpp1/// @file jsonparser.cpp
2/// @brief Implementation of JSONParser2/// @brief Implementation of JSONParser
3///3///
4/// Revisions older than r120 are in the folder /trunk/ReynTweets/connection/parsers.4/// Revisions older than r120 (SVN) are in the folder
5/// /trunk/ReynTweets/connection/parsers.
5/// @author Romain Ducher6/// @author Romain Ducher
6///7///
7/// @section LICENSE8/// @section LICENSE
8///9///
9/// Copyright 2011 Romain Ducher10/// Copyright 2011, 2013 Romain Ducher
10///11///
11/// This file is part of Reyn Tweets.12/// This file is part of Reyn Tweets.
12///13///
@@ -23,26 +24,36 @@
23/// You should have received a copy of the GNU Lesser General Public License24/// You should have received a copy of the GNU Lesser General Public License
24/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.25/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
2526
26#include <QJson/Parser>
27#include "jsonparser.hpp"27#include "jsonparser.hpp"
28#include <QJsonDocument>
2829
29// Parsing method30// Parsing method
30QVariantMap JSONParser::parse(QByteArray data,31QJsonValue JSONParser::parse(QByteArray data,
31 bool & parseOK,32 bool *parseOK,
32 QString & parseError,33 QString *parseError,
33 int * lineError,34 int * lineError,
34 int *)35 int *)
35{36{
36 // Parsing with QJson37 QJsonParseError jsonParseError;
37 QJson::Parser parser;38
38 QVariant result = parser.parse(data, &parseOK);39 // Ensure that datas are encoded with UTF-8
3940 QString utf8data = QString::fromLatin1(data);
40 if (!parseOK) {41 QJsonDocument jsonDoc = QJsonDocument::fromJson(utf8data.toUtf8(),
41 parseError = parser.errorString();42 &jsonParseError);
42 if (lineError) {43
43 *lineError = parser.errorLine();44 if (parseOK) {
44 }45 *parseOK = jsonParseError.error == QJsonParseError::NoError;
45 }46 }
4647
47 return result.toMap();48 if (parseError) {
49 *parseError = jsonParseError.errorString();
50 }
51
52 if (lineError) {
53 *lineError = jsonParseError.offset;
54 }
55
56 QVariant jsonVar = jsonDoc.toVariant();
57
58 return QJsonValue::fromVariant(jsonVar);
48}59}
4960
=== modified file 'connection/common/utils/parsers/jsonparser.hpp'
--- tools/parsers/jsonparser.hpp 2012-05-20 20:29:32 +0000
+++ connection/common/utils/parsers/jsonparser.hpp 2013-08-20 00:10:09 +0000
@@ -1,7 +1,8 @@
1/// @file jsonparser.hpp1/// @file jsonparser.hpp
2/// @brief Header of JSONParser2/// @brief Header of JSONParser
3///3///
4/// Revisions older than r120 are in the folder /trunk/ReynTweets/connection/parsers.4/// Revisions older than r120 (SVN) are in the folder
5/// /trunk/ReynTweets/connection/parsers.
5/// @author Romain Ducher6/// @author Romain Ducher
6///7///
7/// @section LICENSE8/// @section LICENSE
@@ -26,29 +27,28 @@
26#ifndef JSONPARSER_HPP27#ifndef JSONPARSER_HPP
27#define JSONPARSER_HPP28#define JSONPARSER_HPP
2829
30#include <QJsonValue>
29#include "genericparser.hpp"31#include "genericparser.hpp"
3032
31/// @class JSONParser33/// @class JSONParser
32/// @brief Parser for JSON datas.34/// @brief Parser for JSON datas.
33///35class JSONParser : public GenericParser<QJsonValue>
34/// It uses the <a href="http://qjson.sourceforge.net">QJSON</a> library to parse.
35class JSONParser : public GenericParser<QVariantMap>
36{36{
37 public:37 public:
38 /// @fn QVariantMap parse(QByteArray data,38 /// @fn QJsonValue parse(QByteArray data,
39 /// bool & parseOK,39 /// bool * parseOK = 0,
40 /// QString & parseError,40 /// QString * parseError = 0,
41 /// int * lineError = 0,41 /// int * lineError = 0,
42 /// int * columnError = 0);42 /// int * columnError = 0);
43 /// @brief Parsing JSON datas43 /// @brief Parsing JSON datas
44 /// @param data Datas to parse44 /// @param data Datas to parse
45 /// @param parseOK Boolean indicating if the parcing process was successful45 /// @param parseOK Boolean indicating if the parcing process was successful
46 /// @param parseError Error message about a parsing error46 /// @param parseError Error message about a parsing error
47 /// @param lineError Line of the error47 /// @param lineError Line of the error
48 /// @param columnError Column of the error. Unused48 /// @param columnError Column of the error. Unused
49 QVariantMap parse(QByteArray data,49 QJsonValue parse(QByteArray data,
50 bool & parseOK,50 bool * parseOK = 0,
51 QString & parseError,51 QString * parseError = 0,
52 int * lineError = 0,52 int * lineError = 0,
53 int * columnError = 0);53 int * columnError = 0);
54};54};
5555
=== modified file 'connection/common/utils/parsers/oauthparser.cpp'
--- tools/parsers/oauthparser.cpp 2012-05-19 15:39:56 +0000
+++ connection/common/utils/parsers/oauthparser.cpp 2013-08-20 00:10:09 +0000
@@ -23,70 +23,28 @@
23/// You should have received a copy of the GNU Lesser General Public License23/// You should have received a copy of the GNU Lesser General Public License
24/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.24/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
2525
26#include "oauthparser.hpp"
26#include <QList>27#include <QList>
27#include "oauthparser.hpp"28#include <QUrlQuery>
2829
29// Parsing method30// Parsing method
30QVariantMap OAuthParser::parse(QByteArray data,31QVariantMap OAuthParser::parse(QByteArray data,
31 bool & parseOK,32 bool *, QString *,
32 QString & parseError,
33 int *, int *)33 int *, int *)
34{34{
35 QVariantMap res;35 QVariantMap res;
36 QString errorMsg = QObject::trUtf8("Following arguments are invalid : ");36
37 parseOK = true;37 QUrlQuery args(QString::fromLatin1(data));
3838
39 // Split the couples of arguments39 QList<QPair<QString, QString> > listArgs = args.queryItems();
40 QList<QByteArray> arguments = data.split('&');40
4141 for (QList<QPair<QString, QString> >::iterator it = listArgs.begin();
42 foreach (QByteArray argument, arguments) {42 it != listArgs.end();
43 QList<QByteArray> couple = argument.split('=');43 ++it)
44 bool validCouple = couple.length() == 2 || argument.isEmpty();44 {
4545 QPair<QString, QString> couple = *it;
46 // Ensures that there is a name and a value46 res.insert(couple.first, QVariant::fromValue(couple.second));
47 parseOK = parseOK && validCouple;47 }
48
49 if (validCouple) {
50 QString name = QString(couple.at(0));
51 QString value = QString(couple.at(1));
52 res.insert(name, QVariant(value));
53 } else {
54 errorMsg.append(QObject::trUtf8("OAuth parsing : cannot parse '"));
55 errorMsg.append(argument);
56 errorMsg.append("'.\n");
57 }
58 }
59
60
61 // Writing parsing errors
62 parseError = "";
63
64 if (!parseOK) {
65 parseError = errorMsg;
66 }
67
68 return res;
69}
70
71// Extracting one parameter from the parsed result
72QVariant OAuthParser::extractParameter(QVariantMap & parsedMap,
73 QString parameterName,
74 bool & extractOK,
75 QString & extractError)
76{
77 QVariant res;
78 extractError = "";
79 extractOK = parsedMap.contains(parameterName);
80
81 if (extractOK) {
82 res = parsedMap.value(parameterName);
83 parsedMap.remove(parameterName);
84 } else {
85 extractError.append(QObject::trUtf8("Parameter extraction : parameter '"));
86 extractError.append(parameterName);
87 extractError.append(QObject::trUtf8("' expected.")).append('\n');
88 }
89
90 return res;48 return res;
91}49}
9250
@@ -114,18 +72,18 @@
114 }72 }
11573
116 parsedMap.remove(parameterName);74 parsedMap.remove(parameterName);
117 parsedMap.insert(parameterName, QVariant(booleanValue));75 parsedMap.insert(parameterName, QVariant::fromValue(booleanValue));
118 } else {76 } else {
119 // Unexpected value. This is an error.77 // Unexpected value. This is an error.
120 rewriteError.append(QObject::trUtf8("Rewriting as bool : unexpected value '"))78 rewriteError.append(QObject::trUtf8("Rewriting as bool : unexpected value '"))
121 .append(result)79 .append(result)
122 .append(QObject::trUtf8("' for parameter '"))80 .append(QObject::trUtf8("' for parameter '"))
123 .append(parameterName)81 .append(parameterName)
124 .append("'.\n");82 .append("'.");
125 }83 }
126 } else {84 } else {
127 rewriteError.append(QObject::trUtf8("Rewriting as bool : parameter '"))85 rewriteError.append(QObject::trUtf8("Rewriting as bool : parameter '"))
128 .append(parameterName)86 .append(parameterName)
129 .append(QObject::trUtf8("' expected.")).append('\n');87 .append(QObject::trUtf8("' expected."));
130 }88 }
131}89}
13290
=== modified file 'connection/common/utils/parsers/oauthparser.hpp'
--- tools/parsers/oauthparser.hpp 2012-05-19 15:39:56 +0000
+++ connection/common/utils/parsers/oauthparser.hpp 2013-08-20 00:10:09 +0000
@@ -37,8 +37,8 @@
37{37{
38 public:38 public:
39 /// @fn QVariantMap parse(QByteArray data,39 /// @fn QVariantMap parse(QByteArray data,
40 /// bool & parseOK,40 /// bool * parseOK = 0,
41 /// QString & parseError,41 /// QString * parseError = 0,
42 /// int * lineError = 0,42 /// int * lineError = 0,
43 /// int * columnError = 0);43 /// int * columnError = 0);
44 /// @brief Parsing datas for OAuth44 /// @brief Parsing datas for OAuth
@@ -48,26 +48,11 @@
48 /// @param lineError Line of the error. Unused.48 /// @param lineError Line of the error. Unused.
49 /// @param columnError Column of the error. Unused.49 /// @param columnError Column of the error. Unused.
50 QVariantMap parse(QByteArray data,50 QVariantMap parse(QByteArray data,
51 bool & parseOK,51 bool * parseOK = 0,
52 QString & parseError,52 QString * parseError = 0,
53 int * lineError = 0,53 int * lineError = 0,
54 int * columnError = 0);54 int * columnError = 0);
5555
56 /// @fn QVariant extractParameter(QVariantMap & parsedMap,
57 /// QString parameterName,
58 /// bool & extractOK,
59 /// QString & extractError);
60 /// @brief Extracting one parameter from the parsed result
61 /// @param parsedMap Parsed result
62 /// @param parameterName Name of the the parameter to extract
63 /// @param extractOK Boolean indicating if the extraction was successful
64 /// @param extractError Error message about an extraction error
65 /// @return The value of the extracted parameter
66 QVariant extractParameter(QVariantMap & parsedMap,
67 QString parameterName,
68 bool & extractOK,
69 QString & extractError);
70
71 /// @fn void rewriteAsBool(QVariantMap & parsedMap,56 /// @fn void rewriteAsBool(QVariantMap & parsedMap,
72 /// QString parameterName,57 /// QString parameterName,
73 /// bool & rewriteOK,58 /// bool & rewriteOK,
7459
=== modified file 'connection/common/utils/parsers/xmlparser.cpp'
--- tools/parsers/xmlparser.cpp 2012-05-23 02:20:16 +0000
+++ connection/common/utils/parsers/xmlparser.cpp 2013-08-20 00:10:09 +0000
@@ -21,17 +21,22 @@
21/// You should have received a copy of the GNU Lesser General Public License21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
2323
24#include "xmlparser.hpp"
24#include <QDomDocument>25#include <QDomDocument>
25#include "xmlparser.hpp"
2626
27// Parsing an XML document27// Parsing an XML document
28QDomElement XMLParser::parse(QByteArray data,28QDomElement XMLParser::parse(QByteArray data,
29 bool &parseOK,29 bool *parseOK,
30 QString &parseError,30 QString *parseError,
31 int * lineError,31 int * lineError,
32 int * columnError)32 int * columnError)
33{33{
34 QDomDocument res("XMLdoc");34 QDomDocument res("XMLdoc");
35 parseOK = res.setContent(data, &parseError, lineError, columnError);35
36 bool parseRes = res.setContent(data, parseError, lineError, columnError);
37 if (parseOK) {
38 *parseOK = parseRes;
39 }
40
36 return res.documentElement();41 return res.documentElement();
37}42}
3843
=== modified file 'connection/common/utils/parsers/xmlparser.hpp'
--- tools/parsers/xmlparser.hpp 2012-05-23 02:20:16 +0000
+++ connection/common/utils/parsers/xmlparser.hpp 2013-08-20 00:10:09 +0000
@@ -33,8 +33,8 @@
33{33{
34 public:34 public:
35 /// @fn QDomElement parse(QByteArray data,35 /// @fn QDomElement parse(QByteArray data,
36 /// bool & parseOK,36 /// bool * parseOK = 0,
37 /// QString & parseError,37 /// QString * parseError = 0,
38 /// int * lineError = 0,38 /// int * lineError = 0,
39 /// int * columnError = 0);39 /// int * columnError = 0);
40 /// @brief Method for parsing results40 /// @brief Method for parsing results
@@ -44,8 +44,8 @@
44 /// @param lineError Line of the error44 /// @param lineError Line of the error
45 /// @param columnError Column of the error45 /// @param columnError Column of the error
46 QDomElement parse(QByteArray data,46 QDomElement parse(QByteArray data,
47 bool & parseOK,47 bool * parseOK = 0,
48 QString & parseError,48 QString * parseError = 0,
49 int * lineError = 0,49 int * lineError = 0,
50 int * columnError = 0);50 int * columnError = 0);
51};51};
5252
=== added file 'connection/libRT.pri'
--- connection/libRT.pri 1970-01-01 00:00:00 +0000
+++ connection/libRT.pri 2013-08-20 00:10:09 +0000
@@ -0,0 +1,99 @@
1#--------------------------------------------------------#
2# logic.pri #
3# .pri sub project file with the connection part (libRT) #
4# Author : Romain Ducher #
5#--------------------------------------------------------#
6
7#-----------------------------------------------------------------------------#
8# #
9# Copyright 2013 Romain Ducher #
10# #
11# This file is part of Reyn Tweets. #
12# #
13# Reyn Tweets is free software: you can redistribute it and/or modify #
14# it under the terms of the GNU Lesser General Public License as published by #
15# the Free Software Foundation, either version 3 of the License, or #
16# (at your option) any later version. #
17# #
18# Reyn Tweets is distributed in the hope that it will be useful, #
19# but WITHOUT ANY WARRANTY; without even the implied warranty of #
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
21# GNU Lesser General Public License for more details. #
22# #
23# You should have received a copy of the GNU Lesser General Public License #
24# along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. #
25# #
26#-----------------------------------------------------------------------------#
27
28#-------------------------------------------------#
29# Core sources in libRT (used by all the services #
30#-------------------------------------------------#
31
32SOURCES += \
33 connection/common/utils/librtconstants.cpp \
34 connection/common/utils/connectionutils.cpp \
35 connection/common/utils/parsers/htmlparser.cpp \
36 connection/common/utils/parsers/jsonparser.cpp \
37 connection/common/utils/parsers/oauthparser.cpp \
38 connection/common/utils/parsers/xmlparser.cpp \
39 connection/common/networkresult.cpp \
40 connection/common/authenticators/apikeyauthenticator.cpp \
41 connection/common/authenticators/oauth/oauthutils.cpp \
42 connection/common/authenticators/oauth/oauthauthenticator.cpp \
43 connection/common/authenticators/oauth/oauth10aauthenticator.cpp \
44 connection/common/authenticators/oauth/oauth2authenticator.cpp \
45 connection/common/communicators/twittercommunicator.cpp \
46 connection/common/resultwrapper.cpp \
47 connection/common/requests/genericrequester.cpp \
48 connection/common/calls/requestermanager.cpp \
49 connection/common/calls/genericcalls.cpp
50
51
52HEADERS += \
53 connection/common/utils/httpcode.hpp \
54 connection/common/utils/librtconstants.hpp \
55 connection/common/utils/connectionutils.hpp \
56 connection/common/utils/parsers/genericparser.hpp \
57 connection/common/utils/parsers/htmlparser.hpp \
58 connection/common/utils/parsers/jsonparser.hpp \
59 connection/common/utils/parsers/oauthparser.hpp \
60 connection/common/utils/parsers/xmlparser.hpp \
61 connection/common/httprequesttype.hpp \
62 connection/common/headersmap.hpp \
63 connection/common/networkresult.hpp \
64 connection/common/responseinfos.hpp \
65 connection/common/authenticators/apikeyauthenticator.hpp \
66 connection/common/authenticators/basicauthenticators.hpp \
67 connection/common/authenticators/oauth/oauthutils.hpp \
68 connection/common/authenticators/oauth/oauthauthenticator.hpp \
69 connection/common/authenticators/oauth/oauth10aauthenticator.hpp \
70 connection/common/authenticators/oauth/oauth2authenticator.hpp \
71 connection/common/communicators/twittercommunicator.hpp \
72 connection/common/networkresulttype.hpp \
73 connection/common/requestresult.hpp \
74 connection/common/resultwrapper.hpp \
75 connection/common/requests/identificationway.hpp \
76 connection/common/requests/genericrequester.hpp \
77 connection/common/calls/requestinfos.hpp \
78 connection/common/calls/requestermanager.hpp \
79 connection/common/calls/genericcalls.hpp
80
81
82#----------------------------------------#
83# Third party services included in libRT #
84#----------------------------------------#
85
86# Twitter
87include(twitter/twitter.pri)
88
89# Twitlonger
90include(twitlonger/twitlonger.pri)
91
92
93#-------------#
94# Other files #
95#-------------#
96
97OTHER_FILES += \
98 connection/twitlonger/twitlonger.pri \
99 connection/twitter/twitter.pri
0100
=== removed directory 'connection/model'
=== removed directory 'connection/model/managers'
=== removed file 'connection/model/requestinfos.cpp'
--- connection/model/requestinfos.cpp 2012-09-12 22:38:35 +0000
+++ connection/model/requestinfos.cpp 1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
1/// @file requestinfos.cpp
2/// @brief Implementation of RequestInfos
3///
4/// Revisions older than r242 were in /trunk/ReynTweets/connection
5/// @author Romain Ducher
6///
7/// @section LICENSE
8///
9/// Copyright 2012 Romain Ducher
10///
11/// This file is part of Reyn Tweets.
12///
13/// Reyn Tweets is free software: you can redistribute it and/or modify
14/// it under the terms of the GNU Lesser General Public License as published by
15/// the Free Software Foundation, either version 3 of the License, or
16/// (at your option) any later version.
17///
18/// Reyn Tweets is distributed in the hope that it will be useful,
19/// but WITHOUT ANY WARRANTY; without even the implied warranty of
20/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21/// GNU Lesser General Public License for more details.
22///
23/// You should have received a copy of the GNU Lesser General Public License
24/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
25
26#include "requestinfos.hpp"
27
28// Constructor
29RequestInfos::RequestInfos(QObject * requestAsker,
30 GenericRequester * twitterRequest) :
31 asker(requestAsker),
32 requester(twitterRequest)
33{}
34
35// Destructor
36RequestInfos::~RequestInfos() {
37 asker = 0;
38 requester = 0;
39}
40
41// Getter on asker
42QObject * RequestInfos::getAsker() {
43 return asker;
44}
45
46// Getter on requester
47GenericRequester * RequestInfos::getRequester() {
48 return requester;
49}
500
=== removed directory 'connection/requests'
=== removed file 'connection/requests/twitter/oauth/authenticaterequester.cpp'
--- connection/requests/twitter/oauth/authenticaterequester.cpp 2012-01-07 01:10:23 +0000
+++ connection/requests/twitter/oauth/authenticaterequester.cpp 1970-01-01 00:00:00 +0000
@@ -1,130 +0,0 @@
1/// @file authenticaterequester.cpp
2/// @brief Implementation of AuthenticateRequester
3/// @author Romain Ducher
4
5/*
6Copyright 2011 Romain Ducher
7
8This file is part of Reyn Tweets.
9
10Reyn Tweets is free software: you can redistribute it and/or modify
11it under the terms of the GNU Lesser General Public License as published by
12the Free Software Foundation, either version 3 of the License, or
13(at your option) any later version.
14
15Reyn Tweets is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU Lesser General Public License for more details.
19
20You should have received a copy of the GNU Lesser General Public License
21along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
22*/
23
24#include "authenticaterequester.hpp"
25
26AuthenticateRequester::AuthenticateRequester(OAuthManager & authManager,
27 QObject *requester) :
28 OAuthRequester(authManager,
29 GET,
30 TwitterURL::AUTHENTICATE_URL,
31 requester)
32{}
33
34// Building GET Parameters
35void AuthenticateRequester::buildGETParameters() {
36 getParameters.insert("oauth_token", oauthManager->getOAuthToken());
37}
38
39// Building POST Parameters
40void AuthenticateRequester::buildPOSTParameters() {}
41
42// Parse the raw results of the request.
43QVariant AuthenticateRequester::parseResult(bool & parseOK, QVariantMap & parsingErrors) {
44 /*
45 QVariantMap resultMap; // Result of the request
46 bool rightParameter; // Boolean indicating if the parameter name is right
47 QString errorMsg = "Error for parameter ";
48 QString subErrorMsg;
49
50 // Parsing
51 QByteArray rawResponse = communicator->getResponseBuffer();
52 QList<QByteArray> results = rawResponse.split('&');
53
54 QList<QByteArray> resultPair;
55 QByteArray parameterName;
56 QByteArray result;
57
58 // Getting the request token
59 resultPair = results.at(0).split('=');
60
61 // Ensures that the parameter name is "oauth_token"
62 parameterName = resultPair.at(0);
63 rightParameter = "oauth_token" == parameterName;
64 parseOK = rightParameter;
65
66 if (rightParameter) {
67 result = resultPair.at(1);
68 oauthManager->setOAuthToken(QString(result));
69 } else {
70 subErrorMsg = "'";
71 subErrorMsg.append(parameterName);
72 subErrorMsg.append("' (supposed to be 'oauth_token'), ");
73 errorMsg.append(subErrorMsg);
74 }
75
76 // Getting the request secret
77 resultPair = results.at(1).split('=');
78
79 // Ensures that the parameter name is "oauth_token_secret"
80 parameterName = resultPair.at(0);
81 rightParameter = "oauth_token_secret" == parameterName;
82 parseOK = parseOK && rightParameter;
83
84 if (rightParameter) {
85 result = resultPair.at(1);
86 oauthManager->setOAuthSecret(QString(result));
87 } else {
88 subErrorMsg = "parameter '";
89 subErrorMsg.append(parameterName);
90 subErrorMsg.append("' (supposed to be 'oauth_token_secret'), ");
91 errorMsg.append(subErrorMsg);
92 }
93
94
95 // Was the callback URL confirmed ?
96 resultPair = results.at(2).split('=');
97
98 // Ensures that the parameter name is "oauth_callback_confirmed"
99 parameterName = resultPair.at(0);
100 rightParameter = "oauth_callback_confirmed" == parameterName;
101 parseOK = parseOK && rightParameter;
102
103 if (rightParameter) {
104 result = resultPair.at(1);
105 bool callbackUrlConfirmed = ("true" == result) || !("false" == result);
106 resultMap.insert("oauth_callback_confirmed", QVariant(callbackUrlConfirmed));
107 } else {
108 subErrorMsg = "parameter '";
109 subErrorMsg.append(parameterName);
110 subErrorMsg.append("' (supposed to be 'oauth_callback_confirmed')");
111 errorMsg.append(subErrorMsg);
112 }
113
114
115 // There was a problem while parsing -> fill the parsingErrors map !
116 if (!parseOK) {
117 if (errorMsg.endsWith(", ")) {
118 errorMsg.chop(2);
119 errorMsg.append('.');
120 }
121
122 parsingErrors.insert("errorMsg", QVariant(errorMsg));
123 }
124
125 return QVariant(resultMap);
126 //*/
127
128 return QVariant();
129}
130
1310
=== removed file 'connection/requests/twitter/oauth/authenticaterequester.hpp'
--- connection/requests/twitter/oauth/authenticaterequester.hpp 2012-01-07 01:32:25 +0000
+++ connection/requests/twitter/oauth/authenticaterequester.hpp 1970-01-01 00:00:00 +0000
@@ -1,66 +0,0 @@
1/// @file authenticaterequester.hpp
2/// @brief Header of AuthenticateRequester
3/// @author Romain Ducher
4
5/*
6Copyright 2011 Romain Ducher
7
8This file is part of Reyn Tweets.
9
10Reyn Tweets is free software: you can redistribute it and/or modify
11it under the terms of the GNU Lesser General Public License as published by
12the Free Software Foundation, either version 3 of the License, or
13(at your option) any later version.
14
15Reyn Tweets is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU Lesser General Public License for more details.
19
20You should have received a copy of the GNU Lesser General Public License
21along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
22*/
23
24#ifndef AUTHENTICATEREQUESTER_HPP
25#define AUTHENTICATEREQUESTER_HPP
26
27#include "oauthrequester.hpp"
28
29/// @class AuthenticateRequester
30/// @brief Requester for OAuth authentication.
31/// <strong>Unused for the moment.</strong>
32class AuthenticateRequester : public OAuthRequester
33{
34 Q_OBJECT
35
36 public:
37 /// @fn AuthenticateRequester(OAuthManager & authManager,
38 /// QObject * requester = 0);
39 /// @brief Constructor
40 /// @param authManager Information for OAuth. It has to be not null
41 /// @param requester QObject which asks for this search.
42 AuthenticateRequester(OAuthManager & authManager,
43 QObject * requester = 0);
44
45 protected:
46 /// @fn void buildGETParameters();
47 /// @brief Method building GET Parameters
48 void buildGETParameters();
49
50 /// @fn void buildPOSTParameters();
51 /// @brief Method building POST Parameters
52 void buildPOSTParameters();
53
54 // TODO
55 /// @fn QVariant parseResult(bool & parseOK, QVariantMap & parsingErrors);
56 /// @brief Method that will parse the raw results of the request.
57 /// @param parseOK Boolean whose value will be set to true if there was
58 /// no problem while parsing, false otherwise.
59 /// @param parsingErrors QVariantMap that may contain information about
60 /// errors that may occur while parsing.
61 /// @return Parsed results
62 QVariant parseResult(bool & parseOK, QVariantMap & parsingErrors);
63
64};
65
66#endif // AUTHENTICATEREQUESTER_HPP
670
=== removed file 'connection/requests/twitter/oauth/postauthorizerequester.cpp'
--- connection/requests/twitter/oauth/postauthorizerequester.cpp 2012-09-12 22:38:35 +0000
+++ connection/requests/twitter/oauth/postauthorizerequester.cpp 1970-01-01 00:00:00 +0000
@@ -1,228 +0,0 @@
1/// @file postauthorizerequester.cpp
2/// @brief Implementation of PostAuthorizeRequester
3/// @author Romain Ducher
4///
5/// @section LICENSE
6///
7/// Copyright 2011 Romain Ducher
8///
9/// This file is part of Reyn Tweets.
10///
11/// Reyn Tweets is free software: you can redistribute it and/or modify
12/// it under the terms of the GNU Lesser General Public License as published by
13/// the Free Software Foundation, either version 3 of the License, or
14/// (at your option) any later version.
15///
16/// Reyn Tweets is distributed in the hope that it will be useful,
17/// but WITHOUT ANY WARRANTY; without even the implied warranty of
18/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19/// GNU Lesser General Public License for more details.
20///
21/// You should have received a copy of the GNU Lesser General Public License
22/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>.
23
24#include "postauthorizerequester.hpp"
25#include "../../../../tools/parsers/htmlparser.hpp"
26#include "../../../../tools/parsers/oauthparser.hpp"
27
28// Constructor
29PostAuthorizeRequester::PostAuthorizeRequester(OAuthManager &authManager,
30 QString pseudo,
31 QString pwd,
32 bool deny) :
33 OAuthRequester(POST,
34 TwitterURL::AUTHORIZE_URL,
35 authManager,
36 HTML_PARSING),
37 login(pseudo),
38 password(pwd),
39 denyReynTweets(deny)
40{}
41
42// Building postParameters
43void PostAuthorizeRequester::buildPOSTParameters() {
44 postParameters.insert("authenticity_token",
45 QString::fromAscii(oauthManager.getAuthenticityToken().data()));
46 getParameters.insert("oauth_token",
47 QString::fromAscii(oauthManager.getOAuthToken().data()));
48
49 postParameters.insert("session[username_or_email]", login);
50 postParameters.insert("session[password]", password);
51
52 if (denyReynTweets) {
53 postParameters.insert("deny", oauthManager.getDeny());
54 }
55}
56
57// Parsing the raw results of the request.
58QVariant PostAuthorizeRequester::parseResult(bool & parseOK,
59 QVariantMap & parsingErrors)
60{
61 QVariantMap parsedResults; // Map for results
62 QString errorMsg = ""; // Error message written while parsing
63
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: