Merge lp:~air-dex/reyn-tweets/qt5port into lp:reyn-tweets
- qt5port
- Merge into trunk
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 |
Related bugs: | |
Related blueprints: |
Bump the Qt version to Qt 5
(Essential)
|
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.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ReynTweets.pro' |
2 | --- ReynTweets.pro 2013-02-15 23:30:42 +0000 |
3 | +++ ReynTweets.pro 2013-08-20 00:10:09 +0000 |
4 | @@ -1,514 +1,160 @@ |
5 | -#-----------------------------------# |
6 | -# ReynTweets.pro # |
7 | -# Reyn Tweets' Qt .pro project file # |
8 | -# Auteur : Romain Ducher # |
9 | -#-----------------------------------# |
10 | - |
11 | -#-----------------------------------------------------------------------------# |
12 | -# # |
13 | -# Copyright 2011 Romain Ducher # |
14 | -# # |
15 | -# This file is part of Reyn Tweets. # |
16 | -# # |
17 | -# Reyn Tweets is free software: you can redistribute it and/or modify # |
18 | -# it under the terms of the GNU Lesser General Public License as published by # |
19 | -# the Free Software Foundation, either version 3 of the License, or # |
20 | -# (at your option) any later version. # |
21 | -# # |
22 | -# Reyn Tweets is distributed in the hope that it will be useful, # |
23 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
24 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
25 | -# GNU Lesser General Public License for more details. # |
26 | -# # |
27 | -# You should have received a copy of the GNU Lesser General Public License # |
28 | -# along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. # |
29 | -# # |
30 | -#-----------------------------------------------------------------------------# |
31 | - |
32 | -#-------------------------------------------------------------# |
33 | -# This file was known as ReynTweets.pri between r232 and r355 # |
34 | -#-------------------------------------------------------------# |
35 | - |
36 | - |
37 | -#----------------------# |
38 | -# Common configuration # |
39 | -#----------------------# |
40 | - |
41 | -QT += core gui network webkit declarative xml |
42 | - |
43 | -TARGET = ReynTweets |
44 | -TEMPLATE = app |
45 | - |
46 | - |
47 | -#--------------# |
48 | -# Source files # |
49 | -#--------------# |
50 | - |
51 | -# NB : the QML Application Viewer is here in a .pri : |
52 | -# ui/qmlapplicationviewer.pri |
53 | - |
54 | -SOURCES += \ |
55 | - tools/utils.cpp \ |
56 | - tools/reyntweetsdatetime.cpp \ |
57 | - tools/parsers/htmlparser.cpp \ |
58 | - tools/parsers/jsonparser.cpp \ |
59 | - tools/parsers/oauthparser.cpp \ |
60 | - tools/parsers/xmlparser.cpp \ |
61 | - connection/model/managers/oauthmanager.cpp \ |
62 | - connection/model/managers/twitlongermanager.cpp \ |
63 | - connection/twittercommunicators/twittercommunicator.cpp \ |
64 | - connection/requests/twitlonger/twitlongerurls.cpp \ |
65 | - connection/requests/twitter/twitterurls.cpp \ |
66 | - connection/model/resultwrapper.cpp \ |
67 | - connection/requests/genericrequester.cpp \ |
68 | - connection/requests/twitter/twitterrequester.cpp \ |
69 | - connection/requests/twitter/accounts/verifycredentialsrequester.cpp \ |
70 | - connection/requests/twitter/favorites/favoriterequester.cpp \ |
71 | - connection/requests/twitter/favorites/favoritestimelinerequester.cpp \ |
72 | - connection/requests/twitter/oauth/oauthrequester.cpp \ |
73 | - connection/requests/twitter/oauth/requesttokenrequester.cpp \ |
74 | - connection/requests/twitter/oauth/authorizerequester.cpp \ |
75 | - connection/requests/twitter/oauth/postauthorizerequester.cpp \ |
76 | - connection/requests/twitter/oauth/accesstokenrequester.cpp \ |
77 | - connection/requests/twitter/searches/searchrequester.cpp \ |
78 | - connection/requests/twitter/timelines/hometimelinerequester.cpp \ |
79 | - connection/requests/twitter/timelines/mentionstimelinerequester.cpp \ |
80 | - connection/requests/twitter/tweets/destroytweetrequester.cpp \ |
81 | - connection/requests/twitter/tweets/posttweetrequester.cpp \ |
82 | - connection/requests/twitter/tweets/retweetrequester.cpp \ |
83 | - connection/requests/twitter/tweets/showtweetrequester.cpp \ |
84 | - connection/requests/twitter/users/showuserrequester.cpp \ |
85 | - connection/requests/twitlonger/twitlongerrequester.cpp \ |
86 | - connection/requests/twitlonger/posttotwitlongerrequester.cpp \ |
87 | - connection/requests/twitlonger/sendidtotwitlongerrequester.cpp \ |
88 | - connection/model/requestinfos.cpp \ |
89 | - connection/model/requestermanager.cpp \ |
90 | - connection/calls/genericcalls.cpp \ |
91 | - connection/calls/reyntwittercalls.cpp \ |
92 | - connection/calls/twitlongercalls.cpp \ |
93 | - model/reyntweetslistable.cpp \ |
94 | - model/reyntweetsmappable.cpp \ |
95 | - model/tweets/tweetentity.cpp \ |
96 | - model/tweets/indexbounds.cpp \ |
97 | - model/tweets/mediasize.cpp \ |
98 | - model/tweets/mediasizes.cpp \ |
99 | - model/tweets/media.cpp \ |
100 | - model/tweets/medialist.cpp \ |
101 | - model/tweets/urlentity.cpp \ |
102 | - model/tweets/urlentitylist.cpp \ |
103 | - model/tweets/usermention.cpp \ |
104 | - model/tweets/usermentionlist.cpp \ |
105 | - model/tweets/hashtag.cpp \ |
106 | - model/tweets/hashtaglist.cpp \ |
107 | - model/tweets/tweetentities.cpp \ |
108 | - model/users/userinfos.cpp \ |
109 | - model/tweets/retweetinfos.cpp \ |
110 | - model/tweets/tweet.cpp \ |
111 | - model/timelines/timeline.cpp \ |
112 | - model/users/user.cpp \ |
113 | - model/configuration/reyntweetsappconfiguration.cpp \ |
114 | - model/configuration/useraccount.cpp \ |
115 | - model/configuration/reyntweetsuserconfiguration.cpp \ |
116 | - logic/processes/processwrapper.cpp \ |
117 | - tools/processutils.cpp \ |
118 | - logic/processes/genericprocess.cpp \ |
119 | - logic/processes/singletwittercallprocess.cpp \ |
120 | - logic/processes/retweetprocess.cpp \ |
121 | - logic/processes/oauthprocess.cpp \ |
122 | - logic/processes/allowprocess.cpp \ |
123 | - logic/processes/deletetweetprocess.cpp \ |
124 | - logic/processes/favoriteprocess.cpp \ |
125 | - logic/processes/gettweetprocess.cpp \ |
126 | - logic/processes/launchingprocess.cpp \ |
127 | - logic/processes/loadinghometimelineprocess.cpp \ |
128 | - logic/processes/loadmentionstimelineprocess.cpp \ |
129 | - logic/processes/posttweetprocess.cpp \ |
130 | - logic/processes/postviatwitlongerprocess.cpp \ |
131 | - logic/processes/processmanager.cpp \ |
132 | - logic/reyncore.cpp \ |
133 | - logic/controls/genericcontrol.cpp \ |
134 | - logic/controls/allowcontrol.cpp \ |
135 | - logic/controls/launchingcontrol.cpp \ |
136 | - logic/controls/logincontrol.cpp \ |
137 | - logic/controls/reyncontrol.cpp \ |
138 | - logic/controls/settingscontrol.cpp \ |
139 | - logic/controls/timelinecontrol.cpp \ |
140 | - logic/controls/tweetcontrol.cpp \ |
141 | - logic/controls/writetweetcontrol.cpp \ |
142 | - main.cpp \ |
143 | - logic/coreresult.cpp |
144 | - |
145 | - |
146 | -HEADERS += \ |
147 | - tools/qmldebug.hpp \ |
148 | - tools/utils.hpp \ |
149 | - tools/reyntweetsdatetime.hpp \ |
150 | - tools/parsers/genericparser.hpp \ |
151 | - tools/parsers/htmlparser.hpp \ |
152 | - tools/parsers/jsonparser.hpp \ |
153 | - tools/parsers/oauthparser.hpp \ |
154 | - tools/parsers/xmlparser.hpp \ |
155 | - connection/model/managers/oauthmanager.hpp \ |
156 | - connection/model/managers/twitlongermanager.hpp \ |
157 | - connection/model/requesttype.hpp \ |
158 | - connection/model/headersmap.hpp \ |
159 | - connection/twittercommunicators/twittercommunicator.hpp \ |
160 | - connection/model/errortypes.hpp \ |
161 | - connection/model/responseinfos.hpp \ |
162 | - connection/requests/twitlonger/twitlongerurls.hpp \ |
163 | - connection/requests/twitter/twitterurls.hpp \ |
164 | - connection/model/requestresult.hpp \ |
165 | - connection/model/resultwrapper.hpp \ |
166 | - connection/model/identificationway.hpp \ |
167 | - connection/requests/genericrequester.hpp \ |
168 | - connection/requests/twitter/twitterrequester.hpp \ |
169 | - connection/requests/twitter/accounts/verifycredentialsrequester.hpp \ |
170 | - connection/requests/twitter/favorites/favoriterequester.hpp \ |
171 | - connection/requests/twitter/favorites/favoritestimelinerequester.hpp \ |
172 | - connection/requests/twitter/oauth/oauthrequester.hpp \ |
173 | - connection/requests/twitter/oauth/requesttokenrequester.hpp \ |
174 | - connection/requests/twitter/oauth/authorizerequester.hpp \ |
175 | - connection/requests/twitter/oauth/postauthorizerequester.hpp \ |
176 | - connection/requests/twitter/oauth/accesstokenrequester.hpp \ |
177 | - connection/requests/twitter/searches/searchrequester.hpp \ |
178 | - connection/requests/twitter/timelines/hometimelinerequester.hpp \ |
179 | - connection/requests/twitter/timelines/mentionstimelinerequester.hpp \ |
180 | - connection/requests/twitter/tweets/destroytweetrequester.hpp \ |
181 | - connection/requests/twitter/tweets/posttweetrequester.hpp \ |
182 | - connection/requests/twitter/tweets/retweetrequester.hpp \ |
183 | - connection/requests/twitter/tweets/showtweetrequester.hpp \ |
184 | - connection/requests/twitter/users/showuserrequester.hpp \ |
185 | - connection/requests/twitter/twitterrequests.hpp \ |
186 | - connection/requests/twitlonger/twitlongerrequester.hpp \ |
187 | - connection/requests/twitlonger/posttotwitlongerrequester.hpp \ |
188 | - connection/requests/twitlonger/sendidtotwitlongerrequester.hpp \ |
189 | - connection/requests/twitlonger/twitlongerrequests.hpp \ |
190 | - connection/model/requestinfos.hpp \ |
191 | - connection/model/requestermanager.hpp \ |
192 | - connection/calls/genericcalls.hpp \ |
193 | - connection/calls/reyntwittercalls.hpp \ |
194 | - connection/calls/twitlongercalls.hpp \ |
195 | - model/reyntweetsserializable.hpp \ |
196 | - model/reyntweetslistable.hpp \ |
197 | - model/reyntweetslistable.tpp \ |
198 | - model/reyntweetsmappable.hpp \ |
199 | - model/tweets/tweetentity.hpp \ |
200 | - model/tweets/indexbounds.hpp \ |
201 | - model/tweets/mediasize.hpp \ |
202 | - model/tweets/mediasizes.hpp \ |
203 | - model/tweets/urlentity.hpp \ |
204 | - model/tweets/urlentitylist.hpp \ |
205 | - model/tweets/media.hpp \ |
206 | - model/tweets/medialist.hpp \ |
207 | - model/tweets/usermention.hpp \ |
208 | - model/tweets/usermentionlist.hpp \ |
209 | - model/tweets/hashtag.hpp \ |
210 | - model/tweets/hashtaglist.hpp \ |
211 | - model/tweets/tweetentities.hpp \ |
212 | - model/users/userinfos.hpp \ |
213 | - model/tweets/retweetinfos.hpp \ |
214 | - model/tweets/tweet.hpp \ |
215 | - model/timelines/timeline.hpp \ |
216 | - model/users/user.hpp \ |
217 | - model/configuration/reyntweetsappconfiguration.hpp \ |
218 | - model/configuration/useraccount.hpp \ |
219 | - model/configuration/reyntweetsuserconfiguration.hpp \ |
220 | - logic/coreresult.hpp \ |
221 | - logic/processes/processresult.hpp \ |
222 | - logic/processes/processwrapper.hpp \ |
223 | - tools/processutils.hpp \ |
224 | - logic/processes/genericprocess.hpp \ |
225 | - logic/processes/singletwittercallprocess.hpp \ |
226 | - logic/processes/oauthprocess.hpp \ |
227 | - logic/processes/allowprocess.hpp \ |
228 | - logic/processes/deletetweetprocess.hpp \ |
229 | - logic/processes/favoriteprocess.hpp \ |
230 | - logic/processes/gettweetprocess.hpp \ |
231 | - logic/processes/launchingprocess.hpp \ |
232 | - logic/processes/loadinghometimelineprocess.hpp \ |
233 | - logic/processes/loadmentionstimelineprocess.hpp \ |
234 | - logic/processes/posttweetprocess.hpp \ |
235 | - logic/processes/postviatwitlongerprocess.hpp \ |
236 | - logic/processes/retweetprocess.hpp \ |
237 | - logic/processes/processes.hpp \ |
238 | - logic/processes/processinfos.hpp \ |
239 | - logic/processes/processmanager.hpp \ |
240 | - logic/reyncore.hpp \ |
241 | - logic/controls/genericcontrol.hpp \ |
242 | - logic/controls/allowcontrol.hpp \ |
243 | - logic/controls/launchingcontrol.hpp \ |
244 | - logic/controls/logincontrol.hpp \ |
245 | - logic/controls/reyncontrol.hpp \ |
246 | - logic/controls/settingscontrol.hpp \ |
247 | - logic/controls/timelinecontrol.hpp \ |
248 | - logic/controls/tweetcontrol.hpp \ |
249 | - logic/controls/writetweetcontrol.hpp \ |
250 | - logic/controls/controls.hpp |
251 | - |
252 | - |
253 | -OTHER_FILES = \ |
254 | - conf/ReynTweets.conf \ |
255 | - conf/ReynTweetsEmpty.conf \ |
256 | - conf/ReynTweetsSettings.conf \ |
257 | - i18n/reyntweets_en.ts \ |
258 | - i18n/reyntweets_fr.ts \ |
259 | - resources/Logo Reyn Tweets.svg \ |
260 | - resources/Logo Reyn Tweets.png \ |
261 | - ui/qml/tools.js \ |
262 | - ui/qml/twitter-text-js-wrapper.js \ |
263 | - ui/qml/twitter-text-1.4.16.js \ |
264 | - Doxyfile.txt \ |
265 | - .bzrignore \ |
266 | - ReynTweets.rc |
267 | - |
268 | - |
269 | -#---------------------------------------# |
270 | -# Directories for mocs and object files # |
271 | -#---------------------------------------# |
272 | - |
273 | -MOC_DIR = mocs |
274 | -OBJECTS_DIR = obj |
275 | - |
276 | - |
277 | -#----------------------# |
278 | -# Icon for the program # |
279 | -#----------------------# |
280 | -win32 { |
281 | - RC_FILE = ReynTweets.rc |
282 | -} |
283 | - |
284 | -# TODO : Linux, Symbian |
285 | - |
286 | - |
287 | -#--------------# |
288 | -# Translations # |
289 | -#--------------# |
290 | - |
291 | -TRANSLATIONS = reyntweets_en.ts reyntweets_fr.ts |
292 | - |
293 | - |
294 | -#-------------------------------------# |
295 | -# Extra targets - General definitions # |
296 | -#-------------------------------------# |
297 | - |
298 | -# SEPARATOR : Separator in path systems |
299 | -# RMDIR_CMD : Command to delete directories |
300 | -# RMFILE_CMD : Command to delete files |
301 | -# COPY_CMD : Command to copy files |
302 | - |
303 | -win32 { |
304 | - # Leave an empty line because of the backslash at the end of the variable |
305 | - SEPARATOR = \\ |
306 | - |
307 | - RMDIR_CMD = rd /s /q |
308 | - RMFILE_CMD = del /s /q |
309 | - COPY_CMD = copy /y |
310 | -} |
311 | - |
312 | -linux-g++ { |
313 | - SEPARATOR = / |
314 | - RMDIR_CMD = rm -rfv |
315 | - RMFILE_CMD = rm -rfv |
316 | - COPY_CMD = cp -v |
317 | -} |
318 | - |
319 | - |
320 | -#-----------------------# |
321 | -# Documentation targets # |
322 | -#-----------------------# |
323 | - |
324 | -win32 { |
325 | - DOXYGEN_CMD = C:\\Program Files\\doxygen\\bin\\doxygen.exe |
326 | -} |
327 | - |
328 | -linux-g++ { |
329 | - DOXYGEN_CMD = /usr/bin/doxygen |
330 | -} |
331 | - |
332 | -# Create doc |
333 | -doc.target = doc |
334 | -doc.commands = $${DOXYGEN_CMD} $${PWD}Doxyfile.txt |
335 | - |
336 | -# Clean doc |
337 | -cleandoc.target = cleandoc |
338 | -cleandoc.commands = $${RMDIR_CMD} ..$${SEPARATOR}doc$${SEPARATOR}html |
339 | - |
340 | -# Extra targets |
341 | -QMAKE_EXTRA_TARGETS += doc cleandoc |
342 | - |
343 | - |
344 | -#---------------------# |
345 | -# Translation targets # |
346 | -#---------------------# |
347 | - |
348 | -# Folder containing translations |
349 | -TR_FOLDER = $${PWD}i18n$${SEPARATOR} |
350 | - |
351 | -# lupdate |
352 | -LUPDATE_FR = lupdate -noobsolete $${PWD} -ts $${TR_FOLDER}reyntweets_fr.ts |
353 | -LUPDATE_EN = lupdate -noobsolete $${PWD} -ts $${TR_FOLDER}reyntweets_en.ts |
354 | - |
355 | -trupdate.target = trupdate |
356 | -win32 { |
357 | - trupdate.commands = ($${LUPDATE_FR}) & ($${LUPDATE_EN}) |
358 | -} |
359 | -linux-g++ { |
360 | - trupdate.commands = $${LUPDATE_FR} ; $${LUPDATE_EN} |
361 | -} |
362 | - |
363 | -# lrelease |
364 | -LRELEASE_FR = lrelease $${TR_FOLDER}reyntweets_fr.ts |
365 | -LRELEASE_EN = lrelease $${TR_FOLDER}reyntweets_en.ts |
366 | - |
367 | -trrelease.target = trrelease |
368 | -win32 { |
369 | - trrelease.commands = ($${LRELEASE_FR}) & ($${LRELEASE_EN}) |
370 | -} |
371 | -linux-g++ { |
372 | - trrelease.commands = $${LRELEASE_FR} ; $${LRELEASE_EN} |
373 | -} |
374 | - |
375 | -# Deploy .qm files in build directories |
376 | -trdeploy.target = trdeploy |
377 | -trdeploy.commands = $${COPY_CMD} $${TR_FOLDER}*.qm . |
378 | - |
379 | -# Delete .qm files |
380 | -trclean.target = trclean |
381 | -trclean.commands = $${RMFILE_CMD} $${TR_FOLDER}*.qm |
382 | - |
383 | -# Extra targets |
384 | -QMAKE_EXTRA_TARGETS += trupdate trrelease trdeploy trclean |
385 | - |
386 | - |
387 | -#------------------------# |
388 | -# Folders with QML files # |
389 | -#------------------------# |
390 | - |
391 | -# QML files |
392 | -qml_files.source = ui/qml |
393 | -qml_files.target = ui |
394 | - |
395 | -# Resources |
396 | -resource.source = resources |
397 | -resource.target = . |
398 | - |
399 | -# Configuration files |
400 | -# Uncomment this folder in DEPLOYMENTFOLDERS if you want the configuration to |
401 | -# be reset each time the application is launched |
402 | -conf_files.source = conf |
403 | -conf_files.target = . |
404 | - |
405 | -DEPLOYMENTFOLDERS = qml_files \ |
406 | - resource \ |
407 | - conf_files |
408 | - |
409 | - |
410 | -#-------# |
411 | -# QJSON # |
412 | -#-------# |
413 | - |
414 | -# QJSON (http://qjson.sourceforge.net/) is an open source parser for JSON |
415 | -# written in Qt (LGPLv2.1 license). It is compatible with Windows, Mac, Linux, |
416 | -# Symbian and MeeGo. |
417 | -# QJSON_PATH is the location of QJSON in the system. |
418 | - |
419 | -win32 { |
420 | - QJSON_PATH = C:\\Libs\\qjson |
421 | - LIB_QJSON = qjson0 |
422 | -} |
423 | - |
424 | -linux-g++ { |
425 | - QJSON_PATH = /home/ducher/Libs/qjson |
426 | - LIB_QJSON = qjson |
427 | -} |
428 | - |
429 | -INCLUDEPATH += $${QJSON_PATH}$${SEPARATOR}include |
430 | -LIBS += -L$${QJSON_PATH}$${SEPARATOR}lib -l$${LIB_QJSON} |
431 | - |
432 | -symbian { |
433 | -# QJSON_PATH = # TODO |
434 | -# INCLUDEPATH += c:\Libs\Qjson\include |
435 | -# LIBS += -Lc:\Libs\Qjson\lib -lqjson |
436 | -} |
437 | - |
438 | - |
439 | -#---------------------------# |
440 | -# Qt Components for Desktop # |
441 | -#---------------------------# |
442 | - |
443 | -# Qt Components for Desktop (http://qt.gitorious.org/qt-components/desktop) |
444 | -# is a library with QML Components for desktop. It is under LGPL license (v2.1). |
445 | -# QMLCOMP_DESKTOP_PATH is the location of Qt Components for Desktop in the system. |
446 | - |
447 | -win32 { |
448 | -# QMLCOMP_DESKTOP_PATH = C:\\Libs\\QtComponentsForDesktop |
449 | -# INCLUDEPATH += $${QMLCOMP_DESKTOP_PATH}\\include |
450 | -# debug { |
451 | -# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\debug -lstyleplugin |
452 | -# } |
453 | -# release { |
454 | -# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\release -lstyleplugin |
455 | -# } |
456 | -# |
457 | -} |
458 | - |
459 | -linux { |
460 | -# QMLCOMP_DESKTOP_PATH = C:\\Libs\\QtComponentsForDesktop |
461 | -# INCLUDEPATH += $${QMLCOMP_DESKTOP_PATH}\\include |
462 | -# debug { |
463 | -# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\debug -lstyleplugin |
464 | -# } |
465 | -# release { |
466 | -# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\release -lstyleplugin |
467 | -# } |
468 | -# |
469 | -} |
470 | - |
471 | - |
472 | -#-------------------------------# |
473 | -# Symbian special configuration # |
474 | -#-------------------------------# |
475 | - |
476 | -CONFIG += mobility |
477 | -MOBILITY = |
478 | - |
479 | -# Add dependency to Symbian components |
480 | -CONFIG += qt-components |
481 | - |
482 | -symbian { |
483 | - |
484 | -TARGET.UID3 = 0xE541D97B |
485 | -#TARGET.EPOCSTACKSIZE = 0x14000 |
486 | -#TARGET.EPOCHEAPSIZE = 0x020000 0x800000 |
487 | - |
488 | -# Allow network access on Symbian |
489 | -TARGET.CAPABILITY += NetworkServices |
490 | - |
491 | -# Smart Installer package's UID |
492 | -# This UID is from the protected range and therefore the package will |
493 | -# fail to install if self-signed. By default qmake uses the unprotected |
494 | -# range value if unprotected UID is defined for the application and |
495 | -# 0x2002CCCF value if protected UID is given to the application |
496 | -#DEPLOYMENT.installer_header = 0x2002CCCF |
497 | - |
498 | -} |
499 | - |
500 | - |
501 | -#--------------# |
502 | -# Miscanellous # |
503 | -#--------------# |
504 | - |
505 | -# Additional import path used to resolve QML modules in Creator's code model |
506 | -QML_IMPORT_PATH = |
507 | - |
508 | -# If your application uses the Qt Mobility libraries, uncomment the following |
509 | -# lines and add the respective components to the MOBILITY variable. |
510 | -# CONFIG += mobility |
511 | -# MOBILITY += |
512 | - |
513 | -# Speed up launching on MeeGo/Harmattan when using applauncherd daemon |
514 | -# CONFIG += qdeclarative-boostable |
515 | - |
516 | -# Please do not modify the following two lines. Required for deployment. |
517 | -include(ui/qmlapplicationviewer.pri) |
518 | -qtcAddDeployment() |
519 | +#-----------------------------------# |
520 | +# ReynTweets.pro # |
521 | +# Reyn Tweets' Qt .pro project file # |
522 | +# Auteur : Romain Ducher # |
523 | +#-----------------------------------# |
524 | + |
525 | +#-----------------------------------------------------------------------------# |
526 | +# # |
527 | +# Copyright 2011 Romain Ducher # |
528 | +# # |
529 | +# This file is part of Reyn Tweets. # |
530 | +# # |
531 | +# Reyn Tweets is free software: you can redistribute it and/or modify # |
532 | +# it under the terms of the GNU Lesser General Public License as published by # |
533 | +# the Free Software Foundation, either version 3 of the License, or # |
534 | +# (at your option) any later version. # |
535 | +# # |
536 | +# Reyn Tweets is distributed in the hope that it will be useful, # |
537 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
538 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
539 | +# GNU Lesser General Public License for more details. # |
540 | +# # |
541 | +# You should have received a copy of the GNU Lesser General Public License # |
542 | +# along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. # |
543 | +# # |
544 | +#-----------------------------------------------------------------------------# |
545 | + |
546 | +#-------------------------------------------------------------# |
547 | +# This file was known as ReynTweets.pri between r232 and r355 # |
548 | +#-------------------------------------------------------------# |
549 | + |
550 | + |
551 | +#----------------------# |
552 | +# Common configuration # |
553 | +#----------------------# |
554 | + |
555 | +QT += core gui network webkitwidgets declarative xml |
556 | + |
557 | +TARGET = ReynTweets |
558 | +TEMPLATE = app |
559 | + |
560 | + |
561 | +#--------------# |
562 | +# Source files # |
563 | +#--------------# |
564 | + |
565 | +# connection (libRT) |
566 | +include(connection/libRT.pri) |
567 | + |
568 | +# logic |
569 | +include(logic/logic.pri) |
570 | + |
571 | +# UI (with the QML Application Viewer) |
572 | +include(ui/reyntweetsui.pri) |
573 | + |
574 | +SOURCES += \ |
575 | + main.cpp |
576 | + |
577 | +HEADERS += \ |
578 | + |
579 | +OTHER_FILES = \ |
580 | + .bzrignore \ |
581 | + connection/libRT.pri \ |
582 | + logic/logic.pri \ |
583 | + ui/reyntweetsui.pri \ |
584 | + conf/configuration.pri \ |
585 | + doc/documentation.pri \ |
586 | + i18n/translation.pri \ |
587 | + resources/resources.pri |
588 | + |
589 | +#---------------------------------------# |
590 | +# Directories for mocs and object files # |
591 | +#---------------------------------------# |
592 | + |
593 | +MOC_DIR = mocs |
594 | +OBJECTS_DIR = obj |
595 | + |
596 | + |
597 | +#-------------------------------------# |
598 | +# Extra targets - General definitions # |
599 | +#-------------------------------------# |
600 | + |
601 | +# RMDIR_CMD : Command to delete directories |
602 | +# RMFILE_CMD : Command to delete files |
603 | +# COPY_CMD : Command to copy files |
604 | + |
605 | +win32 { |
606 | + RMDIR_CMD = rd /s /q |
607 | + RMFILE_CMD = del /s /q |
608 | + COPY_CMD = copy /y |
609 | +} |
610 | + |
611 | +linux-g++ { |
612 | + RMDIR_CMD = rm -rfv |
613 | + RMFILE_CMD = rm -rfv |
614 | + COPY_CMD = cp -v |
615 | +} |
616 | + |
617 | + |
618 | +#--------------------------# |
619 | +# Non coding project parts # |
620 | +#--------------------------# |
621 | + |
622 | +# Configuration files |
623 | +include(conf/configuration.pri) |
624 | + |
625 | +# Documentation targets |
626 | +include(doc/documentation.pri) |
627 | + |
628 | +# Translations targets |
629 | +include(i18n/translation.pri) |
630 | + |
631 | +# (Graphical) resources |
632 | +include(resources/resources.pri) |
633 | + |
634 | + |
635 | +#---------------------------# |
636 | +# Qt Components for Desktop # |
637 | +#---------------------------# |
638 | + |
639 | +# Qt Components for Desktop (http://qt.gitorious.org/qt-components/desktop) |
640 | +# is a library with QML Components for desktop. It is under LGPL license (v2.1). |
641 | +# QMLCOMP_DESKTOP_PATH is the location of Qt Components for Desktop in the system. |
642 | + |
643 | +win32 { |
644 | +# QMLCOMP_DESKTOP_PATH = C:\\Libs\\QtComponentsForDesktop |
645 | +# INCLUDEPATH += $${QMLCOMP_DESKTOP_PATH}\\include |
646 | +# debug { |
647 | +# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\debug -lstyleplugin |
648 | +# } |
649 | +# release { |
650 | +# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\release -lstyleplugin |
651 | +# } |
652 | +# |
653 | +} |
654 | + |
655 | +linux { |
656 | +# QMLCOMP_DESKTOP_PATH = C:\\Libs\\QtComponentsForDesktop |
657 | +# INCLUDEPATH += $${QMLCOMP_DESKTOP_PATH}\\include |
658 | +# debug { |
659 | +# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\debug -lstyleplugin |
660 | +# } |
661 | +# release { |
662 | +# LIBS += -L$${QMLCOMP_DESKTOP_PATH}\\build\\release -lstyleplugin |
663 | +# } |
664 | +# |
665 | +} |
666 | + |
667 | + |
668 | +#--------------# |
669 | +# Miscanellous # |
670 | +#--------------# |
671 | + |
672 | +# If your application uses the Qt Mobility libraries, uncomment the following |
673 | +# lines and add the respective components to the MOBILITY variable. |
674 | +# CONFIG += mobility |
675 | +# MOBILITY += |
676 | + |
677 | +# Required for deployment. DO NOT MODIFY. |
678 | +qtcAddDeployment() |
679 | |
680 | === modified file 'conf/ReynTweets.conf' |
681 | Binary files conf/ReynTweets.conf 2012-05-23 23:43:29 +0000 and conf/ReynTweets.conf 2013-08-20 00:10:09 +0000 differ |
682 | === modified file 'conf/ReynTweetsEmpty.conf' |
683 | Binary files conf/ReynTweetsEmpty.conf 2012-05-23 23:43:29 +0000 and conf/ReynTweetsEmpty.conf 2013-08-20 00:10:09 +0000 differ |
684 | === modified file 'conf/ReynTweetsSettings.conf' |
685 | --- conf/ReynTweetsSettings.conf 2013-02-15 23:18:12 +0000 |
686 | +++ conf/ReynTweetsSettings.conf 2013-08-20 00:10:09 +0000 |
687 | @@ -1,1 +1,1 @@ |
688 | -{ "callback_url" : "http://twitter.com", "consumer_key" : "V1VsVU16RkZOR0U0TjI5Q1ZGZHFlVVJsVW5jPQ==", "consumer_secret" : "ZHprM2VuVjBVRXBuTmtaNmRGWmxlVE5YTmtWaWNHNTJOMHgyTVdadE5FVlVXR3BzYnpaRmVWUXc=", "pocket_api_key" : "WkdrMFZEQlBNVEpuTVRSaE1YQTBOekZtWkRCYVZ6bDRPV0Z3T0VWaE16ST0=", "twitlonger_api_key" : "VVV0WmMwNTBNMmhOYjI1VFozVnVSQT09", "twitlonger_application_name" : "reyntweets" } |
689 | +{ "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" } } |
690 | |
691 | === added file 'conf/configuration.pri' |
692 | --- conf/configuration.pri 1970-01-01 00:00:00 +0000 |
693 | +++ conf/configuration.pri 2013-08-20 00:10:09 +0000 |
694 | @@ -0,0 +1,42 @@ |
695 | +#-----------------------------------------# |
696 | +# configuration.pri # |
697 | +# .pri sub project file for configuration # |
698 | +# Author : Romain Ducher # |
699 | +#-----------------------------------------# |
700 | + |
701 | +#-----------------------------------------------------------------------------# |
702 | +# # |
703 | +# Copyright 2013 Romain Ducher # |
704 | +# # |
705 | +# This file is part of Reyn Tweets. # |
706 | +# # |
707 | +# Reyn Tweets is free software: you can redistribute it and/or modify # |
708 | +# it under the terms of the GNU Lesser General Public License as published by # |
709 | +# the Free Software Foundation, either version 3 of the License, or # |
710 | +# (at your option) any later version. # |
711 | +# # |
712 | +# Reyn Tweets is distributed in the hope that it will be useful, # |
713 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
714 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
715 | +# GNU Lesser General Public License for more details. # |
716 | +# # |
717 | +# You should have received a copy of the GNU Lesser General Public License # |
718 | +# along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. # |
719 | +# # |
720 | +#-----------------------------------------------------------------------------# |
721 | + |
722 | +OTHER_FILES = \ |
723 | + conf/ReynTweets.conf \ |
724 | + conf/ReynTweetsEmpty.conf \ |
725 | + conf/ReynTweetsSettings.conf |
726 | + |
727 | + |
728 | +#-------------------------------# |
729 | +# Deploying configuration files # |
730 | +#-------------------------------# |
731 | +# Uncomment this folder in DEPLOYMENTFOLDERS if you want the configuration to |
732 | +# be reset each time the application is launched |
733 | +conf_files.source = conf |
734 | +conf_files.target = . |
735 | + |
736 | +DEPLOYMENTFOLDERS += conf_files |
737 | |
738 | === removed directory 'connection/calls' |
739 | === added directory 'connection/common' |
740 | === added directory 'connection/common/authenticators' |
741 | === added file 'connection/common/authenticators/apikeyauthenticator.cpp' |
742 | --- connection/common/authenticators/apikeyauthenticator.cpp 1970-01-01 00:00:00 +0000 |
743 | +++ connection/common/authenticators/apikeyauthenticator.cpp 2013-08-20 00:10:09 +0000 |
744 | @@ -0,0 +1,43 @@ |
745 | +/// @file apikeyauthenticator.cpp |
746 | +/// @brief Implementation of APIKeyAuthenticator |
747 | +/// @author Romain Ducher |
748 | +/// |
749 | +/// @section LICENSE |
750 | +/// |
751 | +/// Copyright 2013 Romain Ducher |
752 | +/// |
753 | +/// This file is part of Reyn Tweets. |
754 | +/// |
755 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
756 | +/// it under the terms of the GNU Lesser General Public License as published by |
757 | +/// the Free Software Foundation, either version 3 of the License, or |
758 | +/// (at your option) any later version. |
759 | +/// |
760 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
761 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
762 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
763 | +/// GNU Lesser General Public License for more details. |
764 | +/// |
765 | +/// You should have received a copy of the GNU Lesser General Public License |
766 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
767 | + |
768 | +#include "apikeyauthenticator.hpp" |
769 | +#include "../utils/librtconstants.hpp" |
770 | + |
771 | +// Constructor |
772 | +APIKeyAuthenticator::APIKeyAuthenticator(): |
773 | + apiKey(LibRT::FAKE_TOKEN) |
774 | +{} |
775 | + |
776 | +// Destructor |
777 | +APIKeyAuthenticator::~APIKeyAuthenticator() {} |
778 | + |
779 | +// Getting the API Key |
780 | +QByteArray APIKeyAuthenticator::getAPIKey() { |
781 | + return apiKey; |
782 | +} |
783 | + |
784 | +// Setting the API Key |
785 | +void APIKeyAuthenticator::setAPIKey(QByteArray newAPIKey) { |
786 | + apiKey = newAPIKey; |
787 | +} |
788 | |
789 | === added file 'connection/common/authenticators/apikeyauthenticator.hpp' |
790 | --- connection/common/authenticators/apikeyauthenticator.hpp 1970-01-01 00:00:00 +0000 |
791 | +++ connection/common/authenticators/apikeyauthenticator.hpp 2013-08-20 00:10:09 +0000 |
792 | @@ -0,0 +1,57 @@ |
793 | +/// @file apikeyauthenticator.hpp |
794 | +/// @brief Header of APIKeyAuthenticator |
795 | +/// @author Romain Ducher |
796 | +/// |
797 | +/// @section LICENSE |
798 | +/// |
799 | +/// Copyright 2013 Romain Ducher |
800 | +/// |
801 | +/// This file is part of Reyn Tweets. |
802 | +/// |
803 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
804 | +/// it under the terms of the GNU Lesser General Public License as published by |
805 | +/// the Free Software Foundation, either version 3 of the License, or |
806 | +/// (at your option) any later version. |
807 | +/// |
808 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
809 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
810 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
811 | +/// GNU Lesser General Public License for more details. |
812 | +/// |
813 | +/// You should have received a copy of the GNU Lesser General Public License |
814 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
815 | + |
816 | +#ifndef APIKEYAUTHENTICATOR_HPP |
817 | +#define APIKEYAUTHENTICATOR_HPP |
818 | + |
819 | +#include <QByteArray> |
820 | + |
821 | +/// @class APIKeyAuthenticator |
822 | +/// @brief Base class for Authentication managers with needs a simple API key. |
823 | +class APIKeyAuthenticator |
824 | +{ |
825 | + public: |
826 | + /// @fn APIKeyAuthenticator(); |
827 | + /// @brief Constructor |
828 | + APIKeyAuthenticator(); |
829 | + |
830 | + /// @fn ~APIKeyAuthenticator(); |
831 | + /// @brief Destructor |
832 | + ~APIKeyAuthenticator(); |
833 | + |
834 | + /// @fn QByteArray getAPIKey(); |
835 | + /// @brief Getting the API key |
836 | + /// @return apiKey |
837 | + QByteArray getAPIKey(); |
838 | + |
839 | + /// @fn void setAPIKey(QByteArray newAPIKey); |
840 | + /// @brief Setting the API key |
841 | + /// @param newAPIKey New value for apiKey |
842 | + void setAPIKey(QByteArray newAPIKey); |
843 | + |
844 | + protected: |
845 | + /// @brief API Key of the application on TwitLonger |
846 | + QByteArray apiKey; |
847 | +}; |
848 | + |
849 | +#endif // APIKEYAUTHENTICATOR_HPP |
850 | |
851 | === added file 'connection/common/authenticators/basicauthenticators.hpp' |
852 | --- connection/common/authenticators/basicauthenticators.hpp 1970-01-01 00:00:00 +0000 |
853 | +++ connection/common/authenticators/basicauthenticators.hpp 2013-08-20 00:10:09 +0000 |
854 | @@ -0,0 +1,47 @@ |
855 | +/// @file basicauthenticators.hpp |
856 | +/// @brief Typedefs of BasicAuthenticator and TokenPair |
857 | +/// @author Romain Ducher |
858 | +/// |
859 | +/// @section LICENSE |
860 | +/// |
861 | +/// Copyright 2013 Romain Ducher |
862 | +/// |
863 | +/// This file is part of Reyn Tweets. |
864 | +/// |
865 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
866 | +/// it under the terms of the GNU Lesser General Public License as published by |
867 | +/// the Free Software Foundation, either version 3 of the License, or |
868 | +/// (at your option) any later version. |
869 | +/// |
870 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
871 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
872 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
873 | +/// GNU Lesser General Public License for more details. |
874 | +/// |
875 | +/// You should have received a copy of the GNU Lesser General Public License |
876 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
877 | + |
878 | +#ifndef BASICAUTHENTICATORS_HPP |
879 | +#define BASICAUTHENTICATORS_HPP |
880 | + |
881 | +#include <QByteArray> |
882 | +#include <QPair> |
883 | +#include <QString> |
884 | + |
885 | +/// @typedef QPair <QString, QByteArray> BasicAuthenticator; |
886 | +/// @brief QPair for classic authentications with a login and a pasword :<ul> |
887 | +/// <li>first : the login.</li> |
888 | +/// <li>secret : the password.</li></ul> |
889 | +/// @see TokenPair |
890 | +typedef QPair<QString, QByteArray> BasicAuthenticator; |
891 | + |
892 | +/// @typedef QPair<QByteArray, QByteArray> TokenPair; |
893 | +/// @brief A token pair. |
894 | +/// |
895 | +/// A token pair is a QPair whose field are:<ul> |
896 | +/// <li>first : the public key (token).</li> |
897 | +/// <li>secret : the private key (secret).</li> |
898 | +/// </ul> |
899 | +typedef QPair<QByteArray, QByteArray> TokenPair; |
900 | + |
901 | +#endif // BASICAUTHENTICATORS_HPP |
902 | |
903 | === added directory 'connection/common/authenticators/oauth' |
904 | === added file 'connection/common/authenticators/oauth/oauth10aauthenticator.cpp' |
905 | --- connection/common/authenticators/oauth/oauth10aauthenticator.cpp 1970-01-01 00:00:00 +0000 |
906 | +++ connection/common/authenticators/oauth/oauth10aauthenticator.cpp 2013-08-20 00:10:09 +0000 |
907 | @@ -0,0 +1,300 @@ |
908 | +/// @file oauth10aauthenticator.cpp |
909 | +/// @brief Implementation of OAuth10aAuthenticator |
910 | +/// @author Romain Ducher |
911 | +/// |
912 | +/// @section LICENSE |
913 | +/// |
914 | +/// Copyright 2013 Romain Ducher |
915 | +/// |
916 | +/// This file is part of Reyn Tweets. |
917 | +/// |
918 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
919 | +/// it under the terms of the GNU Lesser General Public License as published by |
920 | +/// the Free Software Foundation, either version 3 of the License, or |
921 | +/// (at your option) any later version. |
922 | +/// |
923 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
924 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
925 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
926 | +/// GNU Lesser General Public License for more details. |
927 | +/// |
928 | +/// You should have received a copy of the GNU Lesser General Public License |
929 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
930 | + |
931 | +#include "oauth10aauthenticator.hpp" |
932 | + |
933 | +#include <QUrl> |
934 | +#include "oauthutils.hpp" |
935 | +#include "../../utils/connectionutils.hpp" |
936 | +#include "../../utils/librtconstants.hpp" |
937 | + |
938 | +// Constructor |
939 | +OAuth10aAuthenticator::OAuth10aAuthenticator(QString signatureAlgorithm) : |
940 | + OAuthAuthenticator("1.0"), |
941 | + callbackUrl(LibRT::FAKE_URL), |
942 | + oauthTokens(), |
943 | + oauthSignatureMethod(signatureAlgorithm), |
944 | + oauthVerifier(LibRT::FAKE_TOKEN) |
945 | +{} |
946 | + |
947 | +// Destructor |
948 | +OAuth10aAuthenticator::~OAuth10aAuthenticator() {} |
949 | + |
950 | + |
951 | +///////////////////// |
952 | +// Getters on data // |
953 | +///////////////////// |
954 | + |
955 | +// Callback URL |
956 | +QString OAuth10aAuthenticator::getCallbackUrl() { |
957 | + return callbackUrl; |
958 | +} |
959 | + |
960 | +void OAuth10aAuthenticator::setCallbackUrl(QString newURL) { |
961 | + callbackUrl = newURL; |
962 | +} |
963 | + |
964 | +// OAuth Token |
965 | +QByteArray OAuth10aAuthenticator::getOAuthToken() { |
966 | + return oauthTokens.first; |
967 | +} |
968 | + |
969 | +void OAuth10aAuthenticator::setOAuthToken(QByteArray authToken) { |
970 | + oauthTokens.first = authToken; |
971 | +} |
972 | + |
973 | +// OAuth secret |
974 | +void OAuth10aAuthenticator::setOAuthSecret(QByteArray authSecret) { |
975 | + oauthTokens.second = authSecret; |
976 | +} |
977 | + |
978 | +// OAuth verifier |
979 | +QByteArray OAuth10aAuthenticator::getVerifier() { |
980 | + return oauthVerifier; |
981 | +} |
982 | + |
983 | +void OAuth10aAuthenticator::setVerifier(QByteArray verifier) { |
984 | + oauthVerifier = verifier; |
985 | +} |
986 | + |
987 | +//////////////////////////// |
988 | +// Utilities for requests // |
989 | +//////////////////////////// |
990 | + |
991 | +// Resetting tokens |
992 | +void OAuth10aAuthenticator::resetTokens() { |
993 | + oauthTokens.first = LibRT::FAKE_TOKEN; |
994 | + oauthTokens.second = LibRT::FAKE_TOKEN; |
995 | + oauthVerifier = LibRT::FAKE_TOKEN; |
996 | +} |
997 | + |
998 | +// Getting the "Authorization" header |
999 | +QByteArray OAuth10aAuthenticator::getAuthorizationHeader(LibRT::HTTPRequestType type, |
1000 | + QString baseURL, |
1001 | + ArgsMap getDatas, |
1002 | + ArgsMap postDatas, |
1003 | + bool oauthTokenNeeded, |
1004 | + bool callbackUrlNeeded, |
1005 | + bool oauthVerifierNeeded) |
1006 | +{ |
1007 | + QString authorizationHeader = "OAuth "; |
1008 | + QString nonce = generateNonce(); |
1009 | + QString timestamp = generateTimestamp(); |
1010 | + QByteArray signature = signDatas(type, |
1011 | + baseURL, |
1012 | + getDatas, |
1013 | + postDatas, |
1014 | + nonce, |
1015 | + timestamp, |
1016 | + oauthTokenNeeded, |
1017 | + callbackUrlNeeded, |
1018 | + oauthVerifierNeeded); |
1019 | + |
1020 | + // Building the string with all the parameters |
1021 | + QString oauthString = buildOAuthParameterString(nonce, |
1022 | + timestamp, |
1023 | + ", ", |
1024 | + oauthTokenNeeded, |
1025 | + callbackUrlNeeded, |
1026 | + oauthVerifierNeeded, |
1027 | + true, |
1028 | + true, |
1029 | + signature); |
1030 | + authorizationHeader.append(oauthString); |
1031 | + |
1032 | + return authorizationHeader.toLatin1(); |
1033 | +} |
1034 | + |
1035 | +// Signing datas |
1036 | +QByteArray OAuth10aAuthenticator::signDatas(LibRT::HTTPRequestType type, |
1037 | + QString baseURL, |
1038 | + ArgsMap getDatas, |
1039 | + ArgsMap postDatas, |
1040 | + QString nonce, |
1041 | + QString timestamp, |
1042 | + bool oauthTokenNeeded, |
1043 | + bool callbackUrlNeeded, |
1044 | + bool oauthVerifierNeeded) |
1045 | +{ |
1046 | + // Building the key |
1047 | + QByteArray key = ""; |
1048 | + |
1049 | + key.append(QUrl::toPercentEncoding(QString::fromLatin1(consumerTokens.second))); |
1050 | + key.append('&'); |
1051 | + key.append(QUrl::toPercentEncoding(QString::fromLatin1(oauthTokens.second))); |
1052 | + |
1053 | + |
1054 | + // Building that will be signed |
1055 | + |
1056 | + // OAuth parameters |
1057 | + QString oauthString = this->buildOAuthParameterString(nonce, |
1058 | + timestamp, |
1059 | + "&", |
1060 | + oauthTokenNeeded, |
1061 | + callbackUrlNeeded, |
1062 | + oauthVerifierNeeded, |
1063 | + false, |
1064 | + false); |
1065 | + |
1066 | + QString parameterString = this->buildSignatureBaseString(getDatas, |
1067 | + postDatas, |
1068 | + oauthString); |
1069 | + |
1070 | + // Building the base String |
1071 | + QByteArray toSign = ""; |
1072 | + |
1073 | + toSign.append(requestTypeToString(type).toLatin1()); |
1074 | + toSign.append('&'); |
1075 | + toSign.append(QUrl::toPercentEncoding(baseURL)); |
1076 | + toSign.append('&'); |
1077 | + toSign.append(QUrl::toPercentEncoding(parameterString)); |
1078 | + |
1079 | + return hmacSha1(key, toSign); |
1080 | +} |
1081 | + |
1082 | +// Generic method to build strings with OAuth parameters. |
1083 | +QString OAuth10aAuthenticator::buildOAuthParameterString(QString nonce, |
1084 | + QString timestamp, |
1085 | + QString separator, |
1086 | + bool oauthTokenNeeded, |
1087 | + bool callbackUrlNeeded, |
1088 | + bool oauthVerifierNeeded, |
1089 | + bool putDoubleQuotes, |
1090 | + bool signatureNeeded, |
1091 | + QByteArray signature) |
1092 | +{ |
1093 | + QString oauthParamString = ""; // Final string |
1094 | + QString formattedParamString = ""; // Temporary string containg a formatted parameter |
1095 | + |
1096 | + // oauth_callback |
1097 | + if (callbackUrlNeeded) { |
1098 | + formattedParamString = formatParam("oauth_callback", |
1099 | + callbackUrl, |
1100 | + putDoubleQuotes); |
1101 | + oauthParamString.append(formattedParamString); |
1102 | + oauthParamString.append(separator); |
1103 | + } |
1104 | + |
1105 | + // oauth_consumer_key |
1106 | + formattedParamString = formatParam("oauth_consumer_key", |
1107 | + QString::fromLatin1(consumerTokens.first), |
1108 | + putDoubleQuotes); |
1109 | + oauthParamString.append(formattedParamString); |
1110 | + oauthParamString.append(separator); |
1111 | + |
1112 | + // oauth_nonce |
1113 | + formattedParamString = formatParam("oauth_nonce", |
1114 | + nonce, |
1115 | + putDoubleQuotes); |
1116 | + oauthParamString.append(formattedParamString); |
1117 | + oauthParamString.append(separator); |
1118 | + |
1119 | + // oauth_signature |
1120 | + if (signatureNeeded) { |
1121 | + formattedParamString = formatParam("oauth_signature", |
1122 | + QString::fromLatin1(signature), |
1123 | + putDoubleQuotes); |
1124 | + oauthParamString.append(formattedParamString); |
1125 | + oauthParamString.append(separator); |
1126 | + } |
1127 | + |
1128 | + // oauth_signature_method |
1129 | + formattedParamString = formatParam("oauth_signature_method", |
1130 | + oauthSignatureMethod, |
1131 | + putDoubleQuotes); |
1132 | + oauthParamString.append(formattedParamString); |
1133 | + oauthParamString.append(separator); |
1134 | + |
1135 | + // oauth_timestamp |
1136 | + formattedParamString = formatParam("oauth_timestamp", |
1137 | + timestamp, |
1138 | + putDoubleQuotes); |
1139 | + oauthParamString.append(formattedParamString); |
1140 | + oauthParamString.append(separator); |
1141 | + |
1142 | + // oauth_token |
1143 | + if (oauthTokenNeeded) { |
1144 | + formattedParamString = formatParam("oauth_token", |
1145 | + QString::fromLatin1(oauthTokens.first), |
1146 | + putDoubleQuotes); |
1147 | + oauthParamString.append(formattedParamString); |
1148 | + oauthParamString.append(separator); |
1149 | + } |
1150 | + |
1151 | + // oauth_verifier |
1152 | + if (oauthVerifierNeeded) { |
1153 | + formattedParamString = formatParam("oauth_verifier", |
1154 | + QString::fromLatin1(oauthVerifier), |
1155 | + putDoubleQuotes); |
1156 | + oauthParamString.append(formattedParamString); |
1157 | + oauthParamString.append(separator); |
1158 | + } |
1159 | + |
1160 | + // oauth_version |
1161 | + formattedParamString = formatParam("oauth_version", |
1162 | + oauthVersion, |
1163 | + putDoubleQuotes); |
1164 | + oauthParamString.append(formattedParamString); |
1165 | + |
1166 | + return oauthParamString; |
1167 | +} |
1168 | + |
1169 | +// Method builing the base string for the OAuth Signature. |
1170 | +QString OAuth10aAuthenticator::buildSignatureBaseString(ArgsMap getDatas, |
1171 | + ArgsMap postDatas, |
1172 | + QString oauthString) |
1173 | +{ |
1174 | + QString oauthKey = "oauth_*"; |
1175 | + |
1176 | + // Building a big ArgsMap with all the parameters |
1177 | + ArgsMap allParametersMap; |
1178 | + allParametersMap.unite(getDatas); |
1179 | + allParametersMap.unite(postDatas); |
1180 | + allParametersMap.insert(oauthKey, oauthString); |
1181 | + |
1182 | + // Sorting the keys in the alphabetical order |
1183 | + QStringList allKeys(allParametersMap.keys()); |
1184 | + allKeys.sort(); |
1185 | + |
1186 | + // Building the string |
1187 | + QString signatureBaseString = ""; |
1188 | + |
1189 | + for (QStringList::iterator it = allKeys.begin(); |
1190 | + it != allKeys.end(); |
1191 | + ++it) |
1192 | + { |
1193 | + QString paramName = *it; |
1194 | + QString paramValue = allParametersMap.value(paramName); |
1195 | + QString formattedParam = (paramName == oauthKey) ? |
1196 | + paramValue // All the OAuth parameters already treated |
1197 | + : formatParam(paramName, paramValue); |
1198 | + |
1199 | + signatureBaseString.append(formattedParam); |
1200 | + signatureBaseString.append('&'); |
1201 | + } |
1202 | + |
1203 | + // Erasing the last '&' |
1204 | + signatureBaseString.chop(1); |
1205 | + |
1206 | + return signatureBaseString; |
1207 | +} |
1208 | |
1209 | === added file 'connection/common/authenticators/oauth/oauth10aauthenticator.hpp' |
1210 | --- connection/common/authenticators/oauth/oauth10aauthenticator.hpp 1970-01-01 00:00:00 +0000 |
1211 | +++ connection/common/authenticators/oauth/oauth10aauthenticator.hpp 2013-08-20 00:10:09 +0000 |
1212 | @@ -0,0 +1,237 @@ |
1213 | +/// @file oauth10aauthenticator.hpp |
1214 | +/// @brief Header of OAuth10aAuthenticator |
1215 | +/// @author Romain Ducher |
1216 | +/// |
1217 | +/// @section LICENSE |
1218 | +/// |
1219 | +/// Copyright 2013 Romain Ducher |
1220 | +/// |
1221 | +/// This file is part of Reyn Tweets. |
1222 | +/// |
1223 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
1224 | +/// it under the terms of the GNU Lesser General Public License as published by |
1225 | +/// the Free Software Foundation, either version 3 of the License, or |
1226 | +/// (at your option) any later version. |
1227 | +/// |
1228 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
1229 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1230 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1231 | +/// GNU Lesser General Public License for more details. |
1232 | +/// |
1233 | +/// You should have received a copy of the GNU Lesser General Public License |
1234 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
1235 | + |
1236 | +#ifndef OAUTH10AAUTHENTICATOR_HPP |
1237 | +#define OAUTH10AAUTHENTICATOR_HPP |
1238 | + |
1239 | +#include <QByteArray> |
1240 | +#include <QMap> |
1241 | +#include <QString> |
1242 | +#include "oauthauthenticator.hpp" |
1243 | +#include "../../httprequesttype.hpp" |
1244 | +#include "../../headersmap.hpp" |
1245 | + |
1246 | +/// @class OAuth10aAuthenticator |
1247 | +/// @brief Authenticator for stuff related to OAuth 1.0a. |
1248 | +class OAuth10aAuthenticator : public virtual OAuthAuthenticator |
1249 | +{ |
1250 | + public: |
1251 | + /// @fn OAuth10aAuthenticator(QString signatureAlgorithm = "SHA-1"); |
1252 | + /// @brief Constructor. |
1253 | + /// |
1254 | + /// Application settings (callback URL, oauth credentials) will be |
1255 | + /// filled later. |
1256 | + /// @param signatureAlgorithm Algorithm used for signing requests. |
1257 | + OAuth10aAuthenticator(QString signatureAlgorithm = "HMAC-SHA1"); |
1258 | + |
1259 | + /// @fn virtual ~OAuth10aAuthenticator(); |
1260 | + /// @brief Destructor |
1261 | + virtual ~OAuth10aAuthenticator(); |
1262 | + |
1263 | + |
1264 | + ///////////////////// |
1265 | + // Getters on data // |
1266 | + ///////////////////// |
1267 | + |
1268 | + /// @fn QString getCallbackUrl(); |
1269 | + /// @brief Getter for callbackUrl |
1270 | + /// @return The callback URL |
1271 | + QString getCallbackUrl(); |
1272 | + |
1273 | + /// @fn void setCallbackUrl(QString newURL); |
1274 | + /// @brief Setter for callbackUrl |
1275 | + /// @param newURL New value for the callback URL |
1276 | + void setCallbackUrl(QString newURL); |
1277 | + |
1278 | + /// @fn QByteArray getOAuthToken(); |
1279 | + /// @brief Getting the OAuth Token |
1280 | + /// @return The OAuth Token |
1281 | + QByteArray getOAuthToken(); |
1282 | + |
1283 | + /// @fn void setOAuthToken(QByteArray authToken); |
1284 | + /// @brief Setter on the OAuth token |
1285 | + /// @param authToken The new value of the OAuth token |
1286 | + void setOAuthToken(QByteArray authToken); |
1287 | + |
1288 | + /// @fn void setOAuthSecret(QByteArray oauthSecret); |
1289 | + /// @brief Setter on the OAuth secret |
1290 | + /// @param oauthSecret The new value of the OAuth secret |
1291 | + void setOAuthSecret(QByteArray authSecret); |
1292 | + |
1293 | + /// @fn QByteArray getVerifier(); |
1294 | + /// @brief Getter on the verifier |
1295 | + /// @return The verifier |
1296 | + QByteArray getVerifier(); |
1297 | + |
1298 | + /// @fn void setVerifier(QByteArray verifier); |
1299 | + /// @brief Setter on the verifier |
1300 | + /// @param verifier The new verifier |
1301 | + void setVerifier(QByteArray verifier); |
1302 | + |
1303 | + //////////////////////////// |
1304 | + // Utilities for requests // |
1305 | + //////////////////////////// |
1306 | + |
1307 | + /// @fn QByteArray getAuthorizationHeader(Network::HTTPRequestType type, |
1308 | + /// QString baseURL, |
1309 | + /// ArgsMap getDatas, |
1310 | + /// ArgsMap postDatas, |
1311 | + /// bool oauthTokenNeeded = true, |
1312 | + /// bool callbackUrlNeeded = false, |
1313 | + /// bool oauthVerifierNeeded = false); |
1314 | + /// @brief Getting that will be written in the "Authorization" field |
1315 | + /// of requests |
1316 | + /// @param type Request type (GET or POST) |
1317 | + /// @param baseURL URL for the request |
1318 | + /// @param getDatas GET arguments of the request |
1319 | + /// @param postDatas POST arguments of the request |
1320 | + /// @param oauthTokenNeeded Boolean indicating whether |
1321 | + /// the oauth_token is required for the header. |
1322 | + /// @param callbackUrlNeeded Boolean indicating whether |
1323 | + /// the oauth_callback is required for the header. |
1324 | + /// @param oauthVerifierNeeded Boolean indicating whether |
1325 | + /// the oauth_verifier is required for the header. |
1326 | + /// @return Value of the "Authorization" header. |
1327 | + QByteArray getAuthorizationHeader(LibRT::HTTPRequestType type, |
1328 | + QString baseURL, |
1329 | + ArgsMap getDatas, |
1330 | + ArgsMap postDatas, |
1331 | + bool oauthTokenNeeded = true, |
1332 | + bool callbackUrlNeeded = false, |
1333 | + bool oauthVerifierNeeded = false); |
1334 | + |
1335 | + /// @fn void resetTokens(); |
1336 | + /// @brief Resetting the tokens. A full new OAuth authentication process |
1337 | + /// has to be launch to get tokens and for authentication in requests |
1338 | + void resetTokens(); |
1339 | + |
1340 | + |
1341 | + protected: |
1342 | + /// @brief Callback URL of the application |
1343 | + QString callbackUrl; |
1344 | + |
1345 | + /// @brief Access tokens |
1346 | + TokenPair oauthTokens; |
1347 | + |
1348 | + /// @brief Algorithm used for signing requests |
1349 | + QString oauthSignatureMethod; |
1350 | + |
1351 | + /// @brief Verifier for authentication |
1352 | + QByteArray oauthVerifier; |
1353 | + |
1354 | + /// @fn QByteArray signDatas(Network::RequestType type, |
1355 | + /// QString baseURL, |
1356 | + /// ArgsMap getDatas, |
1357 | + /// ArgsMap postDatas, |
1358 | + /// QString nonce, |
1359 | + /// QString timestamp, |
1360 | + /// bool oauthTokenNeeded = true, |
1361 | + /// bool callbackUrlNeeded = false, |
1362 | + /// bool oauthVerifierNeeded = false); |
1363 | + /// @brief Method for signing datas. It is described |
1364 | + /// <a href="https://dev.twitter.com/docs/auth/creating-signature">here |
1365 | + /// </a>. |
1366 | + /// @param type Request type (GET or POST) |
1367 | + /// @param baseURL URL of the service, without the GET arguments. |
1368 | + /// @param getDatas GET datas to sign |
1369 | + /// @param postDatas POST datas to sign |
1370 | + /// @param nonce Nonce of the request |
1371 | + /// @param timestamp Timestamp of the request |
1372 | + /// @param oauthTokenNeeded Boolean indicating whether |
1373 | + /// the oauth_token is required. |
1374 | + /// @param callbackUrlNeeded Boolean indicating whether |
1375 | + /// the oauth_callback is required. |
1376 | + /// @param oauthVerifierNeeded Boolean indicating whether |
1377 | + /// the oauth_verifier is required. |
1378 | + /// @return The signature of the given datas |
1379 | + QByteArray signDatas(LibRT::HTTPRequestType type, |
1380 | + QString baseURL, |
1381 | + ArgsMap getDatas, |
1382 | + ArgsMap postDatas, |
1383 | + QString nonce, |
1384 | + QString timestamp, |
1385 | + bool oauthTokenNeeded = true, |
1386 | + bool callbackUrlNeeded = false, |
1387 | + bool oauthVerifierNeeded = false); |
1388 | + |
1389 | + /// @fn QString buildOAuthParameterString(QString nonce, |
1390 | + /// QString timestamp, |
1391 | + /// QString separator, |
1392 | + /// bool oauthTokenNeeded, |
1393 | + /// bool callbackUrlNeeded, |
1394 | + /// bool oauthVerifierNeeded, |
1395 | + /// bool putDoubleQuotes, |
1396 | + /// bool signatureNeeded, |
1397 | + /// QByteArray signature = ""); |
1398 | + /// @brief Generic method to build strings with OAuth parameters. |
1399 | + /// |
1400 | + /// It is used for the signature (string with the OAuth parameters) and |
1401 | + /// for the Authorization Header |
1402 | + /// @param nonce Nonce of the request |
1403 | + /// @param timestamp Timestamp of the request |
1404 | + /// @param separator Separator between parameters |
1405 | + /// @param oauthTokenNeeded Boolean indicating whether |
1406 | + /// the oauth_token is required. |
1407 | + /// @param callbackUrlNeeded Boolean indicating whether |
1408 | + /// the oauth_callback is required. |
1409 | + /// @param oauthVerifierNeeded Boolean indicating whether |
1410 | + /// the oauth_verifier is required. |
1411 | + /// @param putDoubleQuotes Boolean indicating if double quotes have to |
1412 | + /// surround the percent encoded value. |
1413 | + /// @param signatureNeeded Boolean indicating that the signature of |
1414 | + /// the request is required. |
1415 | + /// @param signature Signature of the request, if needed. |
1416 | + /// @return The string with the parameters. |
1417 | + QString buildOAuthParameterString(QString nonce, |
1418 | + QString timestamp, |
1419 | + QString separator, |
1420 | + bool oauthTokenNeeded, |
1421 | + bool callbackUrlNeeded, |
1422 | + bool oauthVerifierNeeded, |
1423 | + bool putDoubleQuotes, |
1424 | + bool signatureNeeded, |
1425 | + QByteArray signature = ""); |
1426 | + |
1427 | + /// @fn QString buildSignatureBaseString(ArgsMap getDatas, |
1428 | + /// ArgsMap postDatas, |
1429 | + /// QString oauthString); |
1430 | + /// @brief Method builing the base string for the OAuth Signature. |
1431 | + /// @param getDatas GET datas of the request |
1432 | + /// @param postDatas POST datas of the request |
1433 | + /// @param oauthString String with the OAuth parameters. |
1434 | + /// |
1435 | + /// At a certain point of the algorithm, all the parameters have to be |
1436 | + /// sorted lexicographically with their name. All the OAuth parameters |
1437 | + /// are named "<oauth_something>" and likely to be one after |
1438 | + /// another after sorting the parameters. That's why they are all |
1439 | + /// put into a "oauthString" parameter which will be inserted |
1440 | + /// at the right place. |
1441 | + /// @return The string built just like Twitter describes |
1442 | + /// <a href="https://dev.twitter.com/docs/auth/creating-signature"> |
1443 | + /// here</a>. |
1444 | + QString buildSignatureBaseString(ArgsMap getDatas, |
1445 | + ArgsMap postDatas, |
1446 | + QString oauthString); |
1447 | +}; |
1448 | + |
1449 | +#endif // OAUTH10AAUTHENTICATOR_HPP |
1450 | |
1451 | === added file 'connection/common/authenticators/oauth/oauth2authenticator.cpp' |
1452 | --- connection/common/authenticators/oauth/oauth2authenticator.cpp 1970-01-01 00:00:00 +0000 |
1453 | +++ connection/common/authenticators/oauth/oauth2authenticator.cpp 2013-08-20 00:10:09 +0000 |
1454 | @@ -0,0 +1,75 @@ |
1455 | +/// @file oauth2authenticator.cpp |
1456 | +/// @brief Implementation of OAuth2Authenticator |
1457 | +/// @author Romain Ducher |
1458 | +/// |
1459 | +/// @section LICENSE |
1460 | +/// |
1461 | +/// Copyright 2013 Romain Ducher |
1462 | +/// |
1463 | +/// This file is part of Reyn Tweets. |
1464 | +/// |
1465 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
1466 | +/// it under the terms of the GNU Lesser General Public License as published by |
1467 | +/// the Free Software Foundation, either version 3 of the License, or |
1468 | +/// (at your option) any later version. |
1469 | +/// |
1470 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
1471 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1472 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1473 | +/// GNU Lesser General Public License for more details. |
1474 | +/// |
1475 | +/// You should have received a copy of the GNU Lesser General Public License |
1476 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
1477 | + |
1478 | +#include "oauth2authenticator.hpp" |
1479 | + |
1480 | +#include <QUrl> |
1481 | +#include "../../utils/librtconstants.hpp" |
1482 | + |
1483 | +// Constructor |
1484 | +OAuth2Authenticator::OAuth2Authenticator() : |
1485 | + OAuthAuthenticator("2.0"), |
1486 | + bearerToken(LibRT::FAKE_TOKEN) |
1487 | +{} |
1488 | + |
1489 | +// Destructor |
1490 | +OAuth2Authenticator::~OAuth2Authenticator() {} |
1491 | + |
1492 | +///////////////////////////// |
1493 | +// Bearer token management // |
1494 | +///////////////////////////// |
1495 | + |
1496 | +void OAuth2Authenticator::setBearerToken(QByteArray newBearer) { |
1497 | + bearerToken = newBearer; |
1498 | +} |
1499 | + |
1500 | +void OAuth2Authenticator::resetTokens() { |
1501 | + bearerToken = LibRT::FAKE_TOKEN; |
1502 | +} |
1503 | + |
1504 | + |
1505 | +/////////////////////////////////////// |
1506 | +// OAuth 2 Authentication management // |
1507 | +/////////////////////////////////////// |
1508 | + |
1509 | +QByteArray OAuth2Authenticator::getBasicHeader() { |
1510 | + QByteArray bearerCredentials = ""; |
1511 | + |
1512 | + bearerCredentials.append(QUrl::toPercentEncoding(consumerTokens.first)) |
1513 | + .append(':') |
1514 | + .append(QUrl::toPercentEncoding(consumerTokens.second)); |
1515 | + |
1516 | + QByteArray basicHeader = "Basic "; |
1517 | + |
1518 | + basicHeader.append(bearerCredentials.toBase64()); |
1519 | + |
1520 | + return basicHeader; |
1521 | +} |
1522 | + |
1523 | +QByteArray OAuth2Authenticator::getBearerHeader() { |
1524 | + QByteArray bearerHeader = "Bearer "; |
1525 | + |
1526 | + bearerHeader.append(bearerToken.toBase64()); |
1527 | + |
1528 | + return bearerHeader; |
1529 | +} |
1530 | |
1531 | === added file 'connection/common/authenticators/oauth/oauth2authenticator.hpp' |
1532 | --- connection/common/authenticators/oauth/oauth2authenticator.hpp 1970-01-01 00:00:00 +0000 |
1533 | +++ connection/common/authenticators/oauth/oauth2authenticator.hpp 2013-08-20 00:10:09 +0000 |
1534 | @@ -0,0 +1,68 @@ |
1535 | +/// @file oauth2authenticator.hpp |
1536 | +/// @brief Header of OAuth2Authenticator |
1537 | +/// @author Romain Ducher |
1538 | +/// |
1539 | +/// @section LICENSE |
1540 | +/// |
1541 | +/// Copyright 2013 Romain Ducher |
1542 | +/// |
1543 | +/// This file is part of Reyn Tweets. |
1544 | +/// |
1545 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
1546 | +/// it under the terms of the GNU Lesser General Public License as published by |
1547 | +/// the Free Software Foundation, either version 3 of the License, or |
1548 | +/// (at your option) any later version. |
1549 | +/// |
1550 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
1551 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1552 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1553 | +/// GNU Lesser General Public License for more details. |
1554 | +/// |
1555 | +/// You should have received a copy of the GNU Lesser General Public License |
1556 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
1557 | + |
1558 | +#ifndef OAUTH2AUTHENTICATOR_HPP |
1559 | +#define OAUTH2AUTHENTICATOR_HPP |
1560 | + |
1561 | +#include "oauthauthenticator.hpp" |
1562 | + |
1563 | +/// @class OAuth2Authenticator |
1564 | +/// @brief Authenticator for stuff related to OAuth 2. |
1565 | +class OAuth2Authenticator : public virtual OAuthAuthenticator |
1566 | +{ |
1567 | + public: |
1568 | + /// @fn OAuth2Authenticator(); |
1569 | + /// @brief Constructor |
1570 | + OAuth2Authenticator(); |
1571 | + |
1572 | + /// @fn virtual ~OAuth2Authenticator(); |
1573 | + /// @brief Destructor |
1574 | + virtual ~OAuth2Authenticator(); |
1575 | + |
1576 | + /// @fn void setBearerToken(QByteArray newBearer); |
1577 | + /// @brief Setter for bearerToken |
1578 | + /// @param newBearer New value for bearerToken |
1579 | + void setBearerToken(QByteArray newBearer); |
1580 | + |
1581 | + /// @fn void resetTokens(); |
1582 | + /// @brief Resetting the tokens. A full new OAuth authentication process |
1583 | + /// has to be launch to get tokens and for authentication in requests |
1584 | + void resetTokens(); |
1585 | + |
1586 | + /// @fn QByteArray getBasicHeader(); |
1587 | + /// @brief Building the header used to retrieve or to invalidate |
1588 | + /// a Bearer Token. |
1589 | + /// @return The corresponding header |
1590 | + QByteArray getBasicHeader(); |
1591 | + |
1592 | + /// @fn QByteArray getBearerHeader(); |
1593 | + /// @brief Building the header used to authenticate requests. |
1594 | + /// @return The corresponding header |
1595 | + QByteArray getBearerHeader(); |
1596 | + |
1597 | + protected: |
1598 | + /// @brief Bearer token |
1599 | + QByteArray bearerToken; |
1600 | +}; |
1601 | + |
1602 | +#endif // OAUTH2AUTHENTICATOR_HPP |
1603 | |
1604 | === added file 'connection/common/authenticators/oauth/oauthauthenticator.cpp' |
1605 | --- connection/common/authenticators/oauth/oauthauthenticator.cpp 1970-01-01 00:00:00 +0000 |
1606 | +++ connection/common/authenticators/oauth/oauthauthenticator.cpp 2013-08-20 00:10:09 +0000 |
1607 | @@ -0,0 +1,46 @@ |
1608 | +/// @file oauthauthenticator.cpp |
1609 | +/// @brief Implementation of OAuthAuthenticator |
1610 | +/// @author Romain Ducher |
1611 | +/// |
1612 | +/// @section LICENSE |
1613 | +/// |
1614 | +/// Copyright 2013 Romain Ducher |
1615 | +/// |
1616 | +/// This file is part of Reyn Tweets. |
1617 | +/// |
1618 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
1619 | +/// it under the terms of the GNU Lesser General Public License as published by |
1620 | +/// the Free Software Foundation, either version 3 of the License, or |
1621 | +/// (at your option) any later version. |
1622 | +/// |
1623 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
1624 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1625 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1626 | +/// GNU Lesser General Public License for more details. |
1627 | +/// |
1628 | +/// You should have received a copy of the GNU Lesser General Public License |
1629 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
1630 | + |
1631 | +#include "oauthauthenticator.hpp" |
1632 | + |
1633 | +OAuthAuthenticator::OAuthAuthenticator(QString version) : |
1634 | + consumerTokens(), |
1635 | + oauthVersion(version) |
1636 | +{} |
1637 | + |
1638 | +OAuthAuthenticator::~OAuthAuthenticator() {} |
1639 | + |
1640 | + |
1641 | +///////////////////// |
1642 | +// Getters on data // |
1643 | +///////////////////// |
1644 | + |
1645 | +// Consumer key |
1646 | +void OAuthAuthenticator::setConsumerKey(QByteArray clientKey) { |
1647 | + consumerTokens.first = clientKey; |
1648 | +} |
1649 | + |
1650 | +// Consumer secret |
1651 | +void OAuthAuthenticator::setConsumerSecret(QByteArray clientSecret) { |
1652 | + consumerTokens.second = clientSecret; |
1653 | +} |
1654 | |
1655 | === added file 'connection/common/authenticators/oauth/oauthauthenticator.hpp' |
1656 | --- connection/common/authenticators/oauth/oauthauthenticator.hpp 1970-01-01 00:00:00 +0000 |
1657 | +++ connection/common/authenticators/oauth/oauthauthenticator.hpp 2013-08-20 00:10:09 +0000 |
1658 | @@ -0,0 +1,66 @@ |
1659 | +/// @file oauthauthenticator.hpp |
1660 | +/// @brief Header of OAuthAuthenticator |
1661 | +/// @author Romain Ducher |
1662 | +/// |
1663 | +/// @section LICENSE |
1664 | +/// |
1665 | +/// Copyright 2013 Romain Ducher |
1666 | +/// |
1667 | +/// This file is part of Reyn Tweets. |
1668 | +/// |
1669 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
1670 | +/// it under the terms of the GNU Lesser General Public License as published by |
1671 | +/// the Free Software Foundation, either version 3 of the License, or |
1672 | +/// (at your option) any later version. |
1673 | +/// |
1674 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
1675 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1676 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1677 | +/// GNU Lesser General Public License for more details. |
1678 | +/// |
1679 | +/// You should have received a copy of the GNU Lesser General Public License |
1680 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
1681 | + |
1682 | +#ifndef OAUTHAUTHENTICATOR_HPP |
1683 | +#define OAUTHAUTHENTICATOR_HPP |
1684 | + |
1685 | +#include "../basicauthenticators.hpp" |
1686 | + |
1687 | +/// @class OAuthAuthenticator |
1688 | +/// @brief Base class for Authentication managers related to OAuth. |
1689 | +/// |
1690 | +/// It contains the Consumer tokens pair |
1691 | +class OAuthAuthenticator { |
1692 | + public: |
1693 | + /// @fn OAuthAuthenticator(QString version = ""); |
1694 | + /// @brief Constructor |
1695 | + /// @param version Version of OAuth |
1696 | + OAuthAuthenticator(QString version = ""); |
1697 | + |
1698 | + /// @fn virtual ~OAuthAuthenticator(); |
1699 | + /// @brief Destructor |
1700 | + virtual ~OAuthAuthenticator(); |
1701 | + |
1702 | + ///////////////////// |
1703 | + // Getters on data // |
1704 | + ///////////////////// |
1705 | + |
1706 | + /// @fn void setConsumerKey(QByteArray clientKey); |
1707 | + /// @brief Setter on the consumer key |
1708 | + /// @param clientKey New consumer key |
1709 | + void setConsumerKey(QByteArray clientKey); |
1710 | + |
1711 | + /// @fn void setConsumerSecret(QByteArray clientSecret); |
1712 | + /// @brief Setter on the consumer secret |
1713 | + /// @param clientSecret New consumer secret |
1714 | + void setConsumerSecret(QByteArray clientSecret); |
1715 | + |
1716 | + protected: |
1717 | + /// @brief Consumer tokens |
1718 | + TokenPair consumerTokens; |
1719 | + |
1720 | + /// @brief Version of the OAuth protocol used for the authentication. |
1721 | + QString oauthVersion; |
1722 | +}; |
1723 | + |
1724 | +#endif // OAUTHAUTHENTICATOR_HPP |
1725 | |
1726 | === added file 'connection/common/authenticators/oauth/oauthutils.cpp' |
1727 | --- connection/common/authenticators/oauth/oauthutils.cpp 1970-01-01 00:00:00 +0000 |
1728 | +++ connection/common/authenticators/oauth/oauthutils.cpp 2013-08-20 00:10:09 +0000 |
1729 | @@ -0,0 +1,86 @@ |
1730 | +/// @file oauthutils.cpp |
1731 | +/// @brief Utilities for OAuth (implementation) |
1732 | +/// @author Romain Ducher |
1733 | +/// |
1734 | +/// @section LICENSE |
1735 | +/// |
1736 | +/// Copyright 2013 Romain Ducher |
1737 | +/// |
1738 | +/// This file is part of Reyn Tweets. |
1739 | +/// |
1740 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
1741 | +/// it under the terms of the GNU Lesser General Public License as published by |
1742 | +/// the Free Software Foundation, either version 3 of the License, or |
1743 | +/// (at your option) any later version. |
1744 | +/// |
1745 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
1746 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1747 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1748 | +/// GNU Lesser General Public License for more details. |
1749 | +/// |
1750 | +/// You should have received a copy of the GNU Lesser General Public License |
1751 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
1752 | + |
1753 | +#include "oauthutils.hpp" |
1754 | + |
1755 | +#include <QCryptographicHash> |
1756 | +#include <QDateTime> |
1757 | + |
1758 | +// Generates a nonce for a request |
1759 | +QString generateNonce() { |
1760 | + QString base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
1761 | + int baseLength = base.length(); |
1762 | + |
1763 | + QString randomString = ""; |
1764 | + int randomStringLength = 32; |
1765 | + |
1766 | + // Taking random word characters |
1767 | + for (int i = 0; i < randomStringLength; ++i) { |
1768 | + int position = qrand() % baseLength; |
1769 | + randomString.append(base.at(position)); |
1770 | + } |
1771 | + |
1772 | + QByteArray encodedNonce = randomString.toLatin1().toBase64(); |
1773 | + |
1774 | + return QString::fromLatin1(encodedNonce); |
1775 | +} |
1776 | + |
1777 | +// Generates a timestamp for a request |
1778 | +QString generateTimestamp() { |
1779 | + qint64 timestamp = QDateTime::currentMSecsSinceEpoch() / 1000; |
1780 | + return QString::number(timestamp); |
1781 | +} |
1782 | + |
1783 | +// HMAC-SHA1 algorithm for signatures. |
1784 | +QByteArray hmacSha1(QByteArray key, QByteArray baseString) { |
1785 | + int blockSize = 64; // HMAC-SHA-1 block size, defined in SHA-1 standard |
1786 | + |
1787 | + if (key.length() > blockSize) { |
1788 | + // if key is longer than block size (64), reduce key length with |
1789 | + // SHA-1 compression |
1790 | + key = QCryptographicHash::hash(key, QCryptographicHash::Sha1); |
1791 | + } |
1792 | + |
1793 | + // initialize inner padding with char "6" |
1794 | + QByteArray innerPadding(blockSize, char(0x36)); |
1795 | + // initialize outer padding with char "\" |
1796 | + QByteArray outerPadding(blockSize, char(0x5c)); |
1797 | + |
1798 | + // ascii characters 0x36 ("6") and 0x5c ("\") are selected because they have |
1799 | + // large Hamming distance (http://en.wikipedia.org/wiki/Hamming_distance) |
1800 | + |
1801 | + for (int i = 0; i < key.length(); i++) { |
1802 | + // XOR operation between every byte in key and innerpadding, of key length |
1803 | + innerPadding[i] = innerPadding[i] ^ key.at(i); |
1804 | + // XOR operation between every byte in key and outerpadding, of key length |
1805 | + outerPadding[i] = outerPadding[i] ^ key.at(i); |
1806 | + } |
1807 | + |
1808 | + // result = hash ( outerPadding CONCAT hash ( innerPadding CONCAT baseString ) ).toBase64 |
1809 | + QByteArray total = outerPadding; |
1810 | + QByteArray part = innerPadding; |
1811 | + part.append(baseString); |
1812 | + total.append(QCryptographicHash::hash(part, QCryptographicHash::Sha1)); |
1813 | + QByteArray hashed = QCryptographicHash::hash(total, QCryptographicHash::Sha1); |
1814 | + return hashed.toBase64(); |
1815 | +} |
1816 | |
1817 | === added file 'connection/common/authenticators/oauth/oauthutils.hpp' |
1818 | --- connection/common/authenticators/oauth/oauthutils.hpp 1970-01-01 00:00:00 +0000 |
1819 | +++ connection/common/authenticators/oauth/oauthutils.hpp 2013-08-20 00:10:09 +0000 |
1820 | @@ -0,0 +1,56 @@ |
1821 | +/// @file oauthutils.hpp |
1822 | +/// @brief Utilities for OAuth (header) |
1823 | +/// @author Romain Ducher |
1824 | +/// |
1825 | +/// @section LICENSE |
1826 | +/// |
1827 | +/// Copyright 2013 Romain Ducher |
1828 | +/// |
1829 | +/// This file is part of Reyn Tweets. |
1830 | +/// |
1831 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
1832 | +/// it under the terms of the GNU Lesser General Public License as published by |
1833 | +/// the Free Software Foundation, either version 3 of the License, or |
1834 | +/// (at your option) any later version. |
1835 | +/// |
1836 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
1837 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1838 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1839 | +/// GNU Lesser General Public License for more details. |
1840 | +/// |
1841 | +/// You should have received a copy of the GNU Lesser General Public License |
1842 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
1843 | + |
1844 | +#ifndef OAUTHUTILS_HPP |
1845 | +#define OAUTHUTILS_HPP |
1846 | + |
1847 | +#include <QByteArray> |
1848 | +#include <QString> |
1849 | + |
1850 | +/// @fn QString generateNonce(); |
1851 | +/// @brief Generates a nonce for a request. To generate a nonce, |
1852 | +/// a random string is generated by taking 32 times one letter in the |
1853 | +/// alphabet. The letter could be in upper case or lower case. The final |
1854 | +/// nonce is the 64 base-encoding of the random string. |
1855 | +/// @return A nonce for a request. |
1856 | +QString generateNonce(); |
1857 | + |
1858 | +/// @fn QString generateTimestamp(); |
1859 | +/// @brief Generates a timestamp for a request. The timestamp is the |
1860 | +/// number of seconds since the Unix Epoch (1/1/1970 at midnight). |
1861 | +/// @return A timestamp corresponding to the current date. |
1862 | +QString generateTimestamp(); |
1863 | + |
1864 | +/// @fn QByteArray hmacSha1(QByteArray key, QByteArray baseString); |
1865 | +/// @brief HMAC-SHA1 algorithm for signatures. |
1866 | +/// |
1867 | +/// Its implementation for Reyn Tweets was found on the |
1868 | +/// <a href="http://qt-project.org">Qt Project website</a> here : |
1869 | +/// <a href="http://qt-project.org/wiki/HMAC-SHA1"> |
1870 | +/// http://qt-project.org/wiki/HMAC-SHA1</a>. |
1871 | +/// @param key Key for signature |
1872 | +/// @param baseString String that we want to sign |
1873 | +/// @return The signature |
1874 | +QByteArray hmacSha1(QByteArray key, QByteArray baseString); |
1875 | + |
1876 | +#endif // OAUTHUTILS_HPP |
1877 | |
1878 | === added directory 'connection/common/calls' |
1879 | === renamed file 'connection/calls/genericcalls.cpp' => 'connection/common/calls/genericcalls.cpp' |
1880 | --- connection/calls/genericcalls.cpp 2012-05-19 13:58:56 +0000 |
1881 | +++ connection/common/calls/genericcalls.cpp 2013-08-20 00:10:09 +0000 |
1882 | @@ -28,13 +28,13 @@ |
1883 | |
1884 | // Protected constructor |
1885 | GenericCalls::GenericCalls(QObject * requester) : |
1886 | - QObject(), |
1887 | - requestDemander(requester) |
1888 | + QObject(), |
1889 | + requestDemander(requester) |
1890 | {} |
1891 | |
1892 | // Destructor |
1893 | GenericCalls::~GenericCalls() { |
1894 | - requestDemander = 0; |
1895 | + requestDemander = 0; |
1896 | } |
1897 | |
1898 | |
1899 | @@ -44,45 +44,34 @@ |
1900 | |
1901 | // Adding a requester to the requester manager |
1902 | void GenericCalls::addRequester(GenericRequester * requester) { |
1903 | - if (requester != 0) { |
1904 | - connect(requester, SIGNAL(requestDone()), |
1905 | - this, SLOT(endRequest())); |
1906 | - requesterManager.addRequest(requestDemander, requester); |
1907 | - } |
1908 | + if (requester != 0) { |
1909 | + connect(requester, &GenericRequester::requestDone, |
1910 | + this, &GenericCalls::endRequest); |
1911 | + requesterManager.addRequest(requestDemander, requester); |
1912 | + } |
1913 | } |
1914 | |
1915 | // Removing a requester of the requester manager |
1916 | void GenericCalls::removeRequester(GenericRequester * requester) { |
1917 | - if (requester != 0) { |
1918 | - disconnect(requester, SIGNAL(requestDone()), |
1919 | - this, SLOT(endRequest())); |
1920 | - requesterManager.removeRequest(requester->getUuid()); |
1921 | - } |
1922 | + if (requester != 0) { |
1923 | + disconnect(requester, &GenericRequester::requestDone, |
1924 | + this, &GenericCalls::endRequest); |
1925 | + requesterManager.removeRequest(requester); |
1926 | + } |
1927 | } |
1928 | |
1929 | // Slot executed when a requester has finished its work |
1930 | -void GenericCalls::endRequest() { |
1931 | - GenericRequester * requester = qobject_cast<GenericRequester *>(sender()); |
1932 | - ResultWrapper res = buildResultSender(requester); |
1933 | - removeRequester(requester); |
1934 | - emit sendResult(res); |
1935 | -} |
1936 | - |
1937 | -// Method that builds the wrapper of a result |
1938 | -ResultWrapper GenericCalls::buildResultSender(GenericRequester * endedRequest) { |
1939 | - if (endedRequest) { |
1940 | - RequestInfos & requestInfos = requesterManager.getRequestInfos(endedRequest->getUuid()); |
1941 | - return ResultWrapper(requestInfos.getAsker(), |
1942 | - requestInfos.getRequester()->getRequestResult()); |
1943 | - } else { |
1944 | - return ResultWrapper(); |
1945 | - } |
1946 | +void GenericCalls::endRequest(RequestResult requestResult) { |
1947 | + GenericRequester * requester = qobject_cast<GenericRequester *>(sender()); |
1948 | + ResultWrapper res(requesterManager.getAsker(requester), requestResult); |
1949 | + removeRequester(requester); |
1950 | + emit sendResult(res); |
1951 | } |
1952 | |
1953 | // Inline method for executing requests |
1954 | void GenericCalls::executeRequest(GenericRequester * requester) { |
1955 | - if (requester != 0) { |
1956 | - addRequester(requester); |
1957 | - requester->executeRequest(); |
1958 | - } |
1959 | + if (requester != 0) { |
1960 | + addRequester(requester); |
1961 | + requester->executeRequest(); |
1962 | + } |
1963 | } |
1964 | |
1965 | === renamed file 'connection/calls/genericcalls.hpp' => 'connection/common/calls/genericcalls.hpp' |
1966 | --- connection/calls/genericcalls.hpp 2012-09-12 22:38:35 +0000 |
1967 | +++ connection/common/calls/genericcalls.hpp 2013-08-20 00:10:09 +0000 |
1968 | @@ -26,8 +26,8 @@ |
1969 | |
1970 | #include <QObject> |
1971 | #include "../requests/genericrequester.hpp" |
1972 | -#include "../model/resultwrapper.hpp" |
1973 | -#include "../model/requestermanager.hpp" |
1974 | +#include "../resultwrapper.hpp" |
1975 | +#include "requestermanager.hpp" |
1976 | |
1977 | /// @class GenericCalls |
1978 | /// @brief Base class for all classes which manage calls to services. |
1979 | @@ -59,9 +59,10 @@ |
1980 | void sendResult(ResultWrapper res); |
1981 | |
1982 | public slots: |
1983 | - /// @fn void endRequest(); |
1984 | + /// @fn void endRequest(RequestResult requestResult); |
1985 | /// @brief Slot executed when a requester has finished its work |
1986 | - void endRequest(); |
1987 | + /// @param requestResult Result of the request. |
1988 | + void endRequest(RequestResult requestResult); |
1989 | |
1990 | protected: |
1991 | /// @brief QObject that asks for the request |
1992 | @@ -84,12 +85,6 @@ |
1993 | /// @param requester Address of the requester |
1994 | void removeRequester(GenericRequester * requester); |
1995 | |
1996 | - /// @fn ResultSender buildResultSender(GenericRequester * endedRequest); |
1997 | - /// @brief Method that builds the wrapper of a result |
1998 | - /// @param endedRequest Ended request that contaons the result |
1999 | - /// @return The wrapper of the request result |
2000 | - ResultWrapper buildResultSender(GenericRequester * endedRequest); |
2001 | - |
2002 | /// @fn void executeRequest(GenericRequester * requester); |
2003 | /// @brief Inline method for executing requests |
2004 | /// @param requester The requester |
2005 | |
2006 | === renamed file 'connection/model/requestermanager.cpp' => 'connection/common/calls/requestermanager.cpp' |
2007 | --- connection/model/requestermanager.cpp 2012-09-12 22:38:35 +0000 |
2008 | +++ connection/common/calls/requestermanager.cpp 2013-08-20 00:10:09 +0000 |
2009 | @@ -25,23 +25,37 @@ |
2010 | |
2011 | #include "requestermanager.hpp" |
2012 | |
2013 | +// Constructor |
2014 | RequesterManager::RequesterManager() : |
2015 | QMap<QUuid, RequestInfos>() |
2016 | -{ |
2017 | -} |
2018 | +{} |
2019 | |
2020 | +// Adding a request to the manager |
2021 | void RequesterManager::addRequest(QObject * asker, GenericRequester * requester) { |
2022 | if (requester != 0) { |
2023 | - insert(requester->getUuid(), RequestInfos(asker, requester)); |
2024 | - } |
2025 | -} |
2026 | - |
2027 | -void RequesterManager::removeRequest(QUuid requestUuid) { |
2028 | - GenericRequester * requester = getRequestInfos(requestUuid).getRequester(); |
2029 | - delete requester; |
2030 | - remove(requestUuid); |
2031 | -} |
2032 | - |
2033 | + RequestInfos reqinf; |
2034 | + |
2035 | + reqinf.asker = asker; |
2036 | + reqinf.requester = requester; |
2037 | + |
2038 | + insert(requester->getUuid(), reqinf); |
2039 | + } |
2040 | +} |
2041 | + |
2042 | +// Removing a request to the manager |
2043 | +void RequesterManager::removeRequest(GenericRequester * requester) { |
2044 | + if (requester) { |
2045 | + remove(requester->getUuid()); |
2046 | + delete requester; |
2047 | + } |
2048 | +} |
2049 | + |
2050 | +// Getting informations on a request |
2051 | RequestInfos & RequesterManager::getRequestInfos(QUuid requestUuid) { |
2052 | return (*this)[requestUuid]; |
2053 | } |
2054 | + |
2055 | +// Getting the QObject which asked for the request |
2056 | +QObject * RequesterManager::getAsker(GenericRequester * requester) { |
2057 | + return requester ? getRequestInfos(requester->getUuid()).asker : 0; |
2058 | +} |
2059 | |
2060 | === renamed file 'connection/model/requestermanager.hpp' => 'connection/common/calls/requestermanager.hpp' |
2061 | --- connection/model/requestermanager.hpp 2012-09-12 22:38:35 +0000 |
2062 | +++ connection/common/calls/requestermanager.hpp 2013-08-20 00:10:09 +0000 |
2063 | @@ -51,10 +51,17 @@ |
2064 | /// @param requester Entity that executing the request |
2065 | void addRequest(QObject * asker, GenericRequester * requester); |
2066 | |
2067 | - /// @fn void removeRequest(QUuid requestUuid); |
2068 | + /// @fn void removeRequest(GenericRequester * requester); |
2069 | /// @brief Removing a request from the manager |
2070 | - /// @param requestUuid UUID of the requester |
2071 | - void removeRequest(QUuid requestUuid); |
2072 | + /// @param requester Requester to remove |
2073 | + void removeRequest(GenericRequester * requester); |
2074 | + |
2075 | + /// @fn QObject * getAsker(GenericRequester * requester); |
2076 | + /// @brief Getting the QObject which asked for the request |
2077 | + /// @param requester The requester which executes the request |
2078 | + /// @return The QObject which asked for the process. It should be |
2079 | + /// a Process. |
2080 | + QObject * getAsker(GenericRequester * requester); |
2081 | }; |
2082 | |
2083 | #endif // REQUESTERMANAGER_HPP |
2084 | |
2085 | === renamed file 'connection/model/requestinfos.hpp' => 'connection/common/calls/requestinfos.hpp' |
2086 | --- connection/model/requestinfos.hpp 2012-09-12 22:38:35 +0000 |
2087 | +++ connection/common/calls/requestinfos.hpp 2013-08-20 00:10:09 +0000 |
2088 | @@ -29,38 +29,15 @@ |
2089 | #include <QObject> |
2090 | #include "../requests/genericrequester.hpp" |
2091 | |
2092 | -/// @class RequestInfos |
2093 | -/// @brief Class containing the entity which asks for the request (the "asker") |
2094 | -/// and the requester that executes the request (the "requester"). |
2095 | -class RequestInfos |
2096 | -{ |
2097 | - public: |
2098 | - /// @fn RequestInfos(QObject * requestAsker = 0, |
2099 | - /// GenericRequester * twitterRequest = 0); |
2100 | - /// @brief Constructor |
2101 | - /// @param requestAsker The asker |
2102 | - /// @param twitterRequest The requester |
2103 | - RequestInfos(QObject * requestAsker = 0, |
2104 | - GenericRequester * twitterRequest = 0); |
2105 | - |
2106 | - /// @fn ~RequestInfos(); |
2107 | - /// @brief Destructor |
2108 | - ~RequestInfos(); |
2109 | - |
2110 | - /// @fn QObject * getAsker(); |
2111 | - /// @brief Getter on the asker |
2112 | - QObject * getAsker(); |
2113 | - |
2114 | - /// @fn GenericRequester * getRequester(); |
2115 | - /// @brief Getter on the requester |
2116 | - GenericRequester * getRequester(); |
2117 | - |
2118 | - protected: |
2119 | - /// @brief Entity which asks for the request |
2120 | - QObject * asker; |
2121 | - |
2122 | - /// @brief Requester that executes the request |
2123 | - GenericRequester * requester; |
2124 | +/// @struct RequestInfos |
2125 | +/// @brief Struct containing the entity which asks for the request |
2126 | +/// (the "asker") and the requester that executes the request (the "requester"). |
2127 | +struct RequestInfos { |
2128 | + /// @brief Entity which asks for the request |
2129 | + QObject * asker; |
2130 | + |
2131 | + /// @brief Requester that executes the request |
2132 | + GenericRequester * requester; |
2133 | }; |
2134 | |
2135 | #endif // REQUESTINFOS_HPP |
2136 | |
2137 | === renamed directory 'connection/twittercommunicators' => 'connection/common/communicators' |
2138 | === modified file 'connection/common/communicators/twittercommunicator.cpp' |
2139 | --- connection/twittercommunicators/twittercommunicator.cpp 2013-02-15 23:30:42 +0000 |
2140 | +++ connection/common/communicators/twittercommunicator.cpp 2013-08-20 00:10:09 +0000 |
2141 | @@ -26,17 +26,15 @@ |
2142 | |
2143 | #include <QNetworkRequest> |
2144 | #include "twittercommunicator.hpp" |
2145 | -#include "../../tools/utils.hpp" |
2146 | +#include "../utils/connectionutils.hpp" |
2147 | + |
2148 | +//#include <QtDebug> // For debug purposes |
2149 | |
2150 | // Network manager |
2151 | -#ifdef Q_OS_WIN32 |
2152 | - QNetworkAccessManager REYN_TWEETS_NETWORK_MANAGER = QNetworkAccessManager(); |
2153 | -#endif |
2154 | -#ifdef Q_OS_LINUX |
2155 | - QNetworkAccessManager REYN_TWEETS_NETWORK_MANAGER; |
2156 | -#endif |
2157 | -#ifdef Q_OS_SYMBIAN // TODO |
2158 | -// QNetworkAccessManager REYN_TWEETS_NETWORK_MANAGER = QNetworkAccessManager(); |
2159 | +#ifdef Q_OS_WIN |
2160 | + QNetworkAccessManager LibRT::REYN_TWEETS_NETWORK_MANAGER = QNetworkAccessManager(); |
2161 | +#elif defined(Q_OS_LINUX) |
2162 | + QNetworkAccessManager LibRT::REYN_TWEETS_NETWORK_MANAGER; |
2163 | #endif |
2164 | |
2165 | ///////////// |
2166 | @@ -45,35 +43,29 @@ |
2167 | |
2168 | // Constructor |
2169 | TwitterCommunicator::TwitterCommunicator(QString &url, |
2170 | - RequestType type, |
2171 | - ArgsMap & getArgs, |
2172 | - ArgsMap & postArgs, |
2173 | - HeadersMap & headersParam) : |
2174 | - QObject(), |
2175 | - network(&REYN_TWEETS_NETWORK_MANAGER), |
2176 | - timeoutTimer(), |
2177 | - serviceURL(url), |
2178 | - requestType(type), |
2179 | - getParameters(getArgs), |
2180 | - postParameters(postArgs), |
2181 | - headers(headersParam), |
2182 | - responseBuffer(""), |
2183 | - httpResponse(), |
2184 | - errorMessage("Request not done"), |
2185 | - replyURL("") |
2186 | + LibRT::HTTPRequestType type, |
2187 | + ArgsMap & getArgs, |
2188 | + ArgsMap & postArgs, |
2189 | + HeadersMap & headersParam) : |
2190 | + QObject(), |
2191 | + timeoutTimer(), |
2192 | + serviceURL(url), |
2193 | + requestType(type), |
2194 | + getParameters(getArgs), |
2195 | + postParameters(postArgs), |
2196 | + headers(headersParam) |
2197 | { |
2198 | - // Setting the timer |
2199 | - timeoutTimer.setInterval(10*1000); // 10 seconds |
2200 | - timeoutTimer.setSingleShot(true); |
2201 | - connect(&timeoutTimer, SIGNAL(timeout()), |
2202 | - this, SLOT(timeout())); |
2203 | + // Setting the timer |
2204 | + timeoutTimer.setInterval(10*1000); // 10 seconds |
2205 | + timeoutTimer.setSingleShot(true); |
2206 | + connect(&timeoutTimer, &QTimer::timeout, |
2207 | + this, &TwitterCommunicator::timeout); |
2208 | } |
2209 | |
2210 | // Destructor |
2211 | TwitterCommunicator::~TwitterCommunicator() { |
2212 | - disconnect(&timeoutTimer, SIGNAL(timeout()), |
2213 | - this, SLOT(timeout())); |
2214 | - network = 0; |
2215 | + disconnect(&timeoutTimer, &QTimer::timeout, |
2216 | + this, &TwitterCommunicator::timeout); |
2217 | } |
2218 | |
2219 | |
2220 | @@ -83,52 +75,52 @@ |
2221 | |
2222 | // Preparing the request |
2223 | QNetworkRequest * TwitterCommunicator::prepareRequest() { |
2224 | - // GET arguments |
2225 | - QString getArgs = buildGetDatas(); |
2226 | - |
2227 | - // Adding the potential GET arguments at the end of the URL |
2228 | - if ("" != getArgs) { |
2229 | - serviceURL.append('?').append(getArgs); |
2230 | - } |
2231 | - |
2232 | - QNetworkRequest * requestToTwitter = new QNetworkRequest(serviceURL); |
2233 | - |
2234 | - // Adding the headers |
2235 | - for (HeadersMap::Iterator it = headers.begin(); |
2236 | - it != headers.end(); |
2237 | - ++it) |
2238 | - { |
2239 | - requestToTwitter->setRawHeader(it.key(), it.value()); |
2240 | - } |
2241 | - |
2242 | - // Tag of the request with the originatingObject to identify the reply |
2243 | - requestToTwitter->setOriginatingObject(this); |
2244 | - |
2245 | - return requestToTwitter; |
2246 | + // GET arguments |
2247 | + QString getArgs = buildGetDatas(); |
2248 | + |
2249 | + // Adding the potential GET arguments at the end of the URL |
2250 | + if ("" != getArgs) { |
2251 | + serviceURL.append('?').append(getArgs); |
2252 | + } |
2253 | + |
2254 | + QNetworkRequest * requestToTwitter = new QNetworkRequest(serviceURL); |
2255 | + |
2256 | + // Adding the headers |
2257 | + for (HeadersMap::Iterator it = headers.begin(); |
2258 | + it != headers.end(); |
2259 | + ++it) |
2260 | + { |
2261 | + requestToTwitter->setRawHeader(it.key(), it.value()); |
2262 | + } |
2263 | + |
2264 | + // Tag of the request with the originatingObject to identify the reply |
2265 | + requestToTwitter->setOriginatingObject(this); |
2266 | + |
2267 | + return requestToTwitter; |
2268 | } |
2269 | |
2270 | // Executing the request |
2271 | void TwitterCommunicator::executeRequest() { |
2272 | - // Preparing the request |
2273 | - QNetworkRequest * request = prepareRequest(); |
2274 | - |
2275 | - // Connection for receiving the response |
2276 | - connect(network, SIGNAL(finished(QNetworkReply*)), |
2277 | - this, SLOT(endRequest(QNetworkReply*))); |
2278 | - |
2279 | - // Executing the request |
2280 | - if (POST == requestType) { |
2281 | - // POST arguments |
2282 | - QByteArray postArgs = buildPostDatas(); |
2283 | - |
2284 | - // There is some POST arguments -> networkManager.post() |
2285 | - network->post(*request, postArgs); |
2286 | - } else { |
2287 | - // There is not any POST arguments -> networkManager.get() |
2288 | - network->get(*request); |
2289 | - } |
2290 | - |
2291 | - timeoutTimer.start(); |
2292 | + // Preparing the request |
2293 | + QNetworkRequest * request = prepareRequest(); |
2294 | + |
2295 | + // Connection for receiving the response |
2296 | + connect(&LibRT::REYN_TWEETS_NETWORK_MANAGER, &QNetworkAccessManager::finished, |
2297 | + this, &TwitterCommunicator::endRequest); |
2298 | + |
2299 | + // Executing the request |
2300 | + if (LibRT::POST == requestType) { |
2301 | + // POST arguments |
2302 | + QByteArray postArgs = buildPostDatas(); |
2303 | + |
2304 | + // There is some POST arguments -> networkManager.post() |
2305 | + LibRT::REYN_TWEETS_NETWORK_MANAGER.post(*request, postArgs); |
2306 | + } else { |
2307 | + // There is not any POST arguments -> networkManager.get() |
2308 | + LibRT::REYN_TWEETS_NETWORK_MANAGER.get(*request); |
2309 | + } |
2310 | + |
2311 | + timeoutTimer.start(); |
2312 | } |
2313 | |
2314 | |
2315 | @@ -138,85 +130,52 @@ |
2316 | |
2317 | // Treatments that have to be done at the end of the request |
2318 | void TwitterCommunicator::endRequest(QNetworkReply * response) { |
2319 | - // Treating the response |
2320 | - |
2321 | - // Is it the response of that precise request ? |
2322 | - if (!response || this != response->request().originatingObject()) { |
2323 | - // Null reply or bad sender -> No -> doing nothing |
2324 | - return; |
2325 | - } |
2326 | - |
2327 | - // That's our request. Let's do the treatments ! |
2328 | - |
2329 | - // No timeout : stop the timer. |
2330 | - timeoutTimer.stop(); |
2331 | - |
2332 | - // Unwiring |
2333 | - disconnect(network, SIGNAL(finished(QNetworkReply*)), |
2334 | - this, SLOT(endRequest(QNetworkReply*))); |
2335 | - |
2336 | - // Analysing the response |
2337 | - extractHttpStatuses(response); |
2338 | - errorMessage = response->errorString(); |
2339 | - replyURL = response->url().toString(); |
2340 | - |
2341 | - // Extracting informations |
2342 | - responseBuffer = response->readAll(); |
2343 | - response->deleteLater(); |
2344 | - |
2345 | - // responseBuffer (for debug purposes) |
2346 | - /* |
2347 | - qDebug("responseBuffer :"); |
2348 | - qDebug(responseBuffer.data()); |
2349 | - qDebug("\n"); |
2350 | - //*/ |
2351 | - |
2352 | - // Ending the request |
2353 | - emit requestDone(); |
2354 | + // Treating the response |
2355 | + |
2356 | + // Is it the response of that precise request ? |
2357 | + if (!response || this != response->request().originatingObject()) { |
2358 | + // Null reply or bad sender -> No -> doing nothing |
2359 | + return; |
2360 | + } |
2361 | + |
2362 | + // That's our request. Let's do the treatments ! |
2363 | + |
2364 | + // No timeout : stop the timer. |
2365 | + timeoutTimer.stop(); |
2366 | + |
2367 | + // Unwiring |
2368 | + disconnect(&LibRT::REYN_TWEETS_NETWORK_MANAGER, &QNetworkAccessManager::finished, |
2369 | + this, &TwitterCommunicator::endRequest); |
2370 | + |
2371 | + // Extracting informations |
2372 | + NetworkResponse netrep(response); |
2373 | + response->deleteLater(); |
2374 | + |
2375 | + /* responseBuffer (for debug purposes) |
2376 | + qDebug() << "responseBuffer :" << '\n' |
2377 | + << netrep.getResponseBody() << '\n'; |
2378 | + //*/ |
2379 | + |
2380 | + // Ending the request |
2381 | + emit requestDone(netrep); |
2382 | } |
2383 | |
2384 | // Network timeout |
2385 | void TwitterCommunicator::timeout() { |
2386 | - // It seems that no response will arrive. That's enough ! Stop it ! |
2387 | - |
2388 | - // Unwiring |
2389 | - disconnect(network, SIGNAL(finished(QNetworkReply*)), |
2390 | - this, SLOT(endRequest(QNetworkReply*))); |
2391 | - |
2392 | - // Analysing the response |
2393 | - httpResponse.code = 0; |
2394 | - httpResponse.message = ""; |
2395 | - errorMessage = "timeout"; |
2396 | - replyURL = serviceURL; |
2397 | - responseBuffer = ""; |
2398 | - |
2399 | - // Ending the request |
2400 | - emit requestDone(); |
2401 | -} |
2402 | - |
2403 | - |
2404 | -///////////// |
2405 | -// Getters // |
2406 | -///////////// |
2407 | - |
2408 | -// Getting the raw response |
2409 | -QByteArray TwitterCommunicator::getResponseBuffer() { |
2410 | - return responseBuffer; |
2411 | -} |
2412 | - |
2413 | -// Getting the HTTP response (code and reason) |
2414 | -ResponseInfos TwitterCommunicator::getHttpResponse() { |
2415 | - return httpResponse; |
2416 | -} |
2417 | - |
2418 | -// Getting the URL of the reply |
2419 | -QString TwitterCommunicator::getReplyURL() { |
2420 | - return replyURL; |
2421 | -} |
2422 | - |
2423 | -// Getter on the error massage |
2424 | -QString TwitterCommunicator::getErrorMessage() { |
2425 | - return errorMessage; |
2426 | + // It seems that no response will arrive. That's enough ! Stop it ! |
2427 | + |
2428 | + // Unwiring |
2429 | + disconnect(&LibRT::REYN_TWEETS_NETWORK_MANAGER, &QNetworkAccessManager::finished, |
2430 | + this, &TwitterCommunicator::endRequest); |
2431 | + |
2432 | + NetworkResponse response(LibRT::TIMEOUT_HTTP_CODE, |
2433 | + "timeout", |
2434 | + "", |
2435 | + "timeout", |
2436 | + serviceURL); |
2437 | + |
2438 | + // Ending the request |
2439 | + emit requestDone(response); |
2440 | } |
2441 | |
2442 | |
2443 | @@ -226,62 +185,41 @@ |
2444 | |
2445 | // Building a string that will contain all the GET arguments |
2446 | QString TwitterCommunicator::buildGetDatas() { |
2447 | - return buildDatas(getParameters); |
2448 | + return buildDatas(getParameters); |
2449 | } |
2450 | |
2451 | // Building a QByteArray that will contain all the POST arguments |
2452 | QByteArray TwitterCommunicator::buildPostDatas() { |
2453 | - QString postString = buildDatas(postParameters); |
2454 | - return QByteArray().append(postString); |
2455 | + QString postString = buildDatas(postParameters); |
2456 | + return QByteArray().append(postString); |
2457 | } |
2458 | |
2459 | // Building the string that will contain all the arguments |
2460 | // of the given ArgsMap just like in an URL. |
2461 | QString TwitterCommunicator::buildDatas(ArgsMap argsMap) { |
2462 | - QString res = ""; |
2463 | - |
2464 | - // Writing the arguments |
2465 | - for (ArgsMap::iterator argsIterator = argsMap.begin(); |
2466 | - argsIterator != argsMap.end(); |
2467 | - ++argsIterator) { |
2468 | - // Getting the value of the argument |
2469 | - QString argValue = argsIterator.value(); |
2470 | - |
2471 | - if (argValue.isEmpty()) { |
2472 | - continue; |
2473 | - } |
2474 | - |
2475 | - // Getting the name of the argument |
2476 | - QString argName = argsIterator.key(); |
2477 | - |
2478 | - // Append the argument in the argument string |
2479 | - res.append(formatParam(argName, argValue)); |
2480 | - res.append('&'); |
2481 | - } |
2482 | - |
2483 | - // Erasing the last '&' |
2484 | - res.chop(1); |
2485 | - |
2486 | - return res; |
2487 | -} |
2488 | - |
2489 | - |
2490 | -//////////////////////////////////////////// |
2491 | -// Extracting http results from the reply // |
2492 | -//////////////////////////////////////////// |
2493 | - |
2494 | -void TwitterCommunicator::extractHttpStatuses(QNetworkReply * reply) { |
2495 | - if (reply == 0) { |
2496 | - return; |
2497 | - } |
2498 | - |
2499 | - QVariant httpStatus; |
2500 | - |
2501 | - // Extract return code |
2502 | - httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); |
2503 | - httpResponse.code = httpStatus.toInt(); |
2504 | - |
2505 | - // Extract return reason |
2506 | - httpStatus = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute); |
2507 | - httpResponse.message = QString::fromAscii(httpStatus.toByteArray()); |
2508 | + QString res = ""; |
2509 | + |
2510 | + // Writing the arguments |
2511 | + for (ArgsMap::iterator argsIterator = argsMap.begin(); |
2512 | + argsIterator != argsMap.end(); |
2513 | + ++argsIterator) { |
2514 | + // Getting the value of the argument |
2515 | + QString argValue = argsIterator.value(); |
2516 | + |
2517 | + if (argValue.isEmpty()) { |
2518 | + continue; |
2519 | + } |
2520 | + |
2521 | + // Getting the name of the argument |
2522 | + QString argName = argsIterator.key(); |
2523 | + |
2524 | + // Append the argument in the argument string |
2525 | + res.append(formatParam(argName, argValue)); |
2526 | + res.append('&'); |
2527 | + } |
2528 | + |
2529 | + // Erasing the last '&' |
2530 | + res.chop(1); |
2531 | + |
2532 | + return res; |
2533 | } |
2534 | |
2535 | === modified file 'connection/common/communicators/twittercommunicator.hpp' |
2536 | --- connection/twittercommunicators/twittercommunicator.hpp 2012-09-12 22:38:35 +0000 |
2537 | +++ connection/common/communicators/twittercommunicator.hpp 2013-08-20 00:10:09 +0000 |
2538 | @@ -35,20 +35,23 @@ |
2539 | #include <QUrl> |
2540 | #include <QMap> |
2541 | #include <QTimer> |
2542 | -#include "../model/responseinfos.hpp" |
2543 | -#include "../model/headersmap.hpp" |
2544 | -#include "../model/requesttype.hpp" |
2545 | +#include "../headersmap.hpp" |
2546 | +#include "../httprequesttype.hpp" |
2547 | +#include "../networkresult.hpp" |
2548 | |
2549 | |
2550 | ///////////////////// |
2551 | // Network Manager // |
2552 | ///////////////////// |
2553 | |
2554 | -/// @brief Network manager used by all the requesters for all the request. |
2555 | -/// <strong>Including him in the TwitterCommunicator |
2556 | -/// <a href="https://code.google.com/p/reyn-tweets/issues/detail?id=36"> |
2557 | -/// could cause crashes</a></strong>. |
2558 | -extern QNetworkAccessManager REYN_TWEETS_NETWORK_MANAGER; |
2559 | + |
2560 | +namespace LibRT { |
2561 | + /// @brief Network manager used by all the requesters for all the request. |
2562 | + /// <strong>Including him in the TwitterCommunicator |
2563 | + /// <a href="https://code.google.com/p/reyn-tweets/issues/detail?id=36"> |
2564 | + /// could cause crashes</a></strong>. |
2565 | + extern QNetworkAccessManager REYN_TWEETS_NETWORK_MANAGER; |
2566 | +} |
2567 | |
2568 | |
2569 | /// @class TwitterCommunicator |
2570 | @@ -63,7 +66,7 @@ |
2571 | |
2572 | public: |
2573 | /// @fn TwitterCommunicator(QString &url, |
2574 | - /// RequestType type, |
2575 | + /// Network::HTTPRequestType type, |
2576 | /// ArgsMap &getArgs, |
2577 | /// ArgsMap &postArgs, |
2578 | /// HeadersMap &headersParam); |
2579 | @@ -74,7 +77,7 @@ |
2580 | /// @param postArgs POST arguments |
2581 | /// @param headersParam HTTP headers |
2582 | TwitterCommunicator(QString & url, |
2583 | - RequestType type, |
2584 | + LibRT::HTTPRequestType type, |
2585 | ArgsMap &getArgs, |
2586 | ArgsMap &postArgs, |
2587 | HeadersMap &headersParam); |
2588 | @@ -93,31 +96,11 @@ |
2589 | /// @brief Executing the request |
2590 | virtual void executeRequest(); |
2591 | |
2592 | - /// @fn QByteArray getResponseBuffer(); |
2593 | - /// @brief Getting the content of the response |
2594 | - /// @return The buffer containing the response |
2595 | - QByteArray getResponseBuffer(); |
2596 | - |
2597 | - /// @fn ResponseInfos getHttpResponse(); |
2598 | - /// @brief Getting the HTTP response (code and reason). |
2599 | - /// @return The description of the HTTP return code. |
2600 | - ResponseInfos getHttpResponse(); |
2601 | - |
2602 | - /// @fn QString getReplyURL(); |
2603 | - /// @brief Getting the URL of the reply. |
2604 | - /// @return replyURL |
2605 | - QString getReplyURL(); |
2606 | - |
2607 | - /// @fn QString getErrorMessage(); |
2608 | - /// @brief Getter on the error massage |
2609 | - /// @return The error message |
2610 | - QString getErrorMessage(); |
2611 | - |
2612 | |
2613 | signals: |
2614 | - /// @fn void requestDone(); |
2615 | + /// @fn void requestDone(NetworkResponse result); |
2616 | /// @brief Signal indicating the end of a request |
2617 | - void requestDone(); |
2618 | + void requestDone(NetworkResponse result); |
2619 | |
2620 | |
2621 | protected slots: |
2622 | @@ -131,9 +114,6 @@ |
2623 | void timeout(); |
2624 | |
2625 | protected: |
2626 | - /// @brief Entity managing the Network (Internet). |
2627 | - QNetworkAccessManager * network; |
2628 | - |
2629 | /// @brief Timer to avoid to wait for responses ad vitam aeternam. |
2630 | QTimer timeoutTimer; |
2631 | |
2632 | @@ -143,7 +123,7 @@ |
2633 | QString & serviceURL; |
2634 | |
2635 | /// @brief Request type |
2636 | - RequestType requestType; |
2637 | + LibRT::HTTPRequestType requestType; |
2638 | |
2639 | /// @brief GET datas |
2640 | ArgsMap & getParameters; |
2641 | @@ -155,21 +135,6 @@ |
2642 | HeadersMap & headers; |
2643 | |
2644 | |
2645 | - // Entities for response |
2646 | - |
2647 | - /// @brief Content of the response |
2648 | - QByteArray responseBuffer; |
2649 | - |
2650 | - /// @brief HTTP response code and reason |
2651 | - ResponseInfos httpResponse; |
2652 | - |
2653 | - /// @brief Error message |
2654 | - QString errorMessage; |
2655 | - |
2656 | - /// @brief URL of the reply |
2657 | - QString replyURL; |
2658 | - |
2659 | - |
2660 | private: |
2661 | /// @fn QString buildGetDatas(); |
2662 | /// @brief Building the string that will contain all the GET arguments |
2663 | @@ -193,11 +158,6 @@ |
2664 | /// @param argsMap The argument map |
2665 | /// @return A QString representation looks like val1=arg1&val2=arg2... |
2666 | QString buildDatas(ArgsMap argsMap); |
2667 | - |
2668 | - /// @fn void extractHttpStatuses(QNetworkReply * reply); |
2669 | - /// @brief Extract the HTTP return code and reason of the request |
2670 | - /// @param reply Network reply containing the statuses. |
2671 | - void extractHttpStatuses(QNetworkReply * reply); |
2672 | }; |
2673 | |
2674 | #endif // TWITTERCOMMUNICATOR_HPP |
2675 | |
2676 | === renamed file 'connection/model/headersmap.hpp' => 'connection/common/headersmap.hpp' |
2677 | === renamed file 'connection/model/requesttype.hpp' => 'connection/common/httprequesttype.hpp' |
2678 | --- connection/model/requesttype.hpp 2012-09-12 22:38:35 +0000 |
2679 | +++ connection/common/httprequesttype.hpp 2013-08-20 00:10:09 +0000 |
2680 | @@ -1,12 +1,10 @@ |
2681 | -/// @file requesttype.hpp |
2682 | -/// @brief Header of RequestType |
2683 | -/// |
2684 | -/// Revisions older than r242 were in /trunk/ReynTweets/connection |
2685 | +/// @file httprequesttype.hpp |
2686 | +/// @brief Header of LibRT::HTTPRequestType |
2687 | /// @author Romain Ducher |
2688 | /// |
2689 | /// @section LICENSE |
2690 | /// |
2691 | -/// Copyright 2011 Romain Ducher |
2692 | +/// Copyright 2011, 2013 Romain Ducher |
2693 | /// |
2694 | /// This file is part of Reyn Tweets. |
2695 | /// |
2696 | @@ -23,19 +21,21 @@ |
2697 | /// You should have received a copy of the GNU Lesser General Public License |
2698 | /// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
2699 | |
2700 | -#ifndef REQUESTTYPE_HPP |
2701 | -#define REQUESTTYPE_HPP |
2702 | +#ifndef HTTPREQUESTTYPE_HPP |
2703 | +#define HTTPREQUESTTYPE_HPP |
2704 | |
2705 | #include <QString> |
2706 | |
2707 | -/// @enum RequestType |
2708 | -/// @brief Enum indicating the type of the request |
2709 | -enum RequestType { |
2710 | - /// @brief GET requests |
2711 | - GET, |
2712 | - |
2713 | - /// @brief POST requests |
2714 | - POST |
2715 | -}; |
2716 | - |
2717 | -#endif // REQUESTTYPE_HPP |
2718 | +namespace LibRT { |
2719 | + /// @enum HTTPRequestType |
2720 | + /// @brief Enum indicating the type of the request |
2721 | + enum HTTPRequestType { |
2722 | + /// @brief GET requests |
2723 | + GET, |
2724 | + |
2725 | + /// @brief POST requests |
2726 | + POST |
2727 | + }; |
2728 | +} |
2729 | + |
2730 | +#endif // HTTPREQUESTTYPE_HPP |
2731 | |
2732 | === added file 'connection/common/networkresult.cpp' |
2733 | --- connection/common/networkresult.cpp 1970-01-01 00:00:00 +0000 |
2734 | +++ connection/common/networkresult.cpp 2013-08-20 00:10:09 +0000 |
2735 | @@ -0,0 +1,88 @@ |
2736 | +/// @file networkresult.cpp |
2737 | +/// @brief Implementation of NetworkResponse |
2738 | +/// @author Romain Ducher |
2739 | +/// |
2740 | +/// @section LICENSE |
2741 | +/// |
2742 | +/// Copyright 2011 Romain Ducher |
2743 | +/// |
2744 | +/// This file is part of Reyn Tweets. |
2745 | +/// |
2746 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
2747 | +/// it under the terms of the GNU Lesser General Public License as published by |
2748 | +/// the Free Software Foundation, either version 3 of the License, or |
2749 | +/// (at your option) any later version. |
2750 | +/// |
2751 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
2752 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
2753 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2754 | +/// GNU Lesser General Public License for more details. |
2755 | +/// |
2756 | +/// You should have received a copy of the GNU Lesser General Public License |
2757 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
2758 | + |
2759 | +#include "networkresult.hpp" |
2760 | + |
2761 | +// Constructor |
2762 | +NetworkResponse::NetworkResponse(LibRT::HTTPCode httpCode, |
2763 | + QString httpReason, |
2764 | + QByteArray response, |
2765 | + QString error, |
2766 | + QString repURL) : |
2767 | + httpResponse(httpCode, httpReason), |
2768 | + responseBody(response), |
2769 | + requestError(error), |
2770 | + replyURL(repURL) |
2771 | +{} |
2772 | + |
2773 | +// Building a NetworkResponse with the content of a QNetworkReply. |
2774 | +NetworkResponse::NetworkResponse(QNetworkReply * reply) : |
2775 | + httpResponse(extractHttpStatusesFromNetworkReply(reply)), |
2776 | + responseBody(reply ? reply->readAll() : ""), |
2777 | + requestError(reply ? reply->errorString() : "null reply"), |
2778 | + replyURL(reply ? reply->url().toString() : LibRT::FAKE_URL) |
2779 | +{} |
2780 | + |
2781 | +// Extracting the HTTP code and the HTTP reason from an HTTP reply. |
2782 | +ResponseInfos NetworkResponse::extractHttpStatusesFromNetworkReply(QNetworkReply * reply) { |
2783 | + ResponseInfos httpResponse; |
2784 | + |
2785 | + if (reply) { |
2786 | + QVariant httpStatus; |
2787 | + |
2788 | + // Extract return code |
2789 | + httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); |
2790 | + httpResponse.code = httpStatus.toInt(); |
2791 | + |
2792 | + // Extract return reason |
2793 | + httpStatus = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute); |
2794 | + httpResponse.message = QString::fromLatin1(httpStatus.toByteArray()); |
2795 | + } |
2796 | + |
2797 | + |
2798 | + return httpResponse; |
2799 | +} |
2800 | + |
2801 | +///////////// |
2802 | +// Getters // |
2803 | +///////////// |
2804 | + |
2805 | +// httpResponse |
2806 | +ResponseInfos NetworkResponse::getHttpResponse() { |
2807 | + return httpResponse; |
2808 | +} |
2809 | + |
2810 | +// responseBody |
2811 | +QByteArray NetworkResponse::getResponseBody() { |
2812 | + return responseBody; |
2813 | +} |
2814 | + |
2815 | +// requestError |
2816 | +QString NetworkResponse::getRequestError() { |
2817 | + return requestError; |
2818 | +} |
2819 | + |
2820 | +// replyURL |
2821 | +QString NetworkResponse::getReplyURL() { |
2822 | + return replyURL; |
2823 | +} |
2824 | |
2825 | === added file 'connection/common/networkresult.hpp' |
2826 | --- connection/common/networkresult.hpp 1970-01-01 00:00:00 +0000 |
2827 | +++ connection/common/networkresult.hpp 2013-08-20 00:10:09 +0000 |
2828 | @@ -0,0 +1,104 @@ |
2829 | +/// @file networkresult.hpp |
2830 | +/// @brief Header of NetworkResponse |
2831 | +/// @author Romain Ducher |
2832 | +/// |
2833 | +/// @section LICENSE |
2834 | +/// |
2835 | +/// Copyright 2011 Romain Ducher |
2836 | +/// |
2837 | +/// This file is part of Reyn Tweets. |
2838 | +/// |
2839 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
2840 | +/// it under the terms of the GNU Lesser General Public License as published by |
2841 | +/// the Free Software Foundation, either version 3 of the License, or |
2842 | +/// (at your option) any later version. |
2843 | +/// |
2844 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
2845 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
2846 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2847 | +/// GNU Lesser General Public License for more details. |
2848 | +/// |
2849 | +/// You should have received a copy of the GNU Lesser General Public License |
2850 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
2851 | + |
2852 | +#ifndef NETWORKRESPONSE_HPP |
2853 | +#define NETWORKRESPONSE_HPP |
2854 | + |
2855 | +#include <QNetworkReply> |
2856 | +#include "responseinfos.hpp" |
2857 | +#include "utils/librtconstants.hpp" |
2858 | +#include "utils/httpcode.hpp" |
2859 | + |
2860 | +/// @struct NetworkResponse |
2861 | +/// @brief Struct with relevant elements of network reply |
2862 | +class NetworkResponse { |
2863 | + public: |
2864 | + |
2865 | + /// @fn NetworkResponse(LibRT::HTTPCode httpCode = LibRT::INVALID_HTTP_CODE, |
2866 | + /// QString httpReason = "", |
2867 | + /// QByteArray response = "", |
2868 | + /// QString error = "", |
2869 | + /// QString repURL = LibRT::FAKE_URL); |
2870 | + /// @brief Full constructor |
2871 | + /// @param httpCode Value for httpResponse.code. |
2872 | + /// @param httpReason Value for httpResponse.message. |
2873 | + /// @param response Value for responseBody. |
2874 | + /// @param error Value for requestError. |
2875 | + /// @param repURL Value for replyURL. |
2876 | + NetworkResponse(LibRT::HTTPCode httpCode = LibRT::INVALID_HTTP_CODE, |
2877 | + QString httpReason = "", |
2878 | + QByteArray response = "", |
2879 | + QString error = "", |
2880 | + QString repURL = LibRT::FAKE_URL); |
2881 | + |
2882 | + /// @fn NetworkResponse(QNetworkReply * reply); |
2883 | + /// @brief Building a NetworkResponse with the content of a QNetworkReply. |
2884 | + /// @param reply the QNetworkReply |
2885 | + NetworkResponse(QNetworkReply * reply); |
2886 | + |
2887 | + |
2888 | + ///////////// |
2889 | + // Getters // |
2890 | + ///////////// |
2891 | + |
2892 | + /// @fn ResponseInfos getHttpResponse(); |
2893 | + /// @brief Getter on httpResponse. |
2894 | + /// @return httpResponse |
2895 | + ResponseInfos getHttpResponse(); |
2896 | + |
2897 | + /// @fn QByteArray getResponseBody(); |
2898 | + /// @brief Getter on responseBody. |
2899 | + /// @return responseBody |
2900 | + QByteArray getResponseBody(); |
2901 | + |
2902 | + /// @fn QString getRequestError(); |
2903 | + /// @brief Getter on requestError. |
2904 | + /// @return requestError |
2905 | + QString getRequestError(); |
2906 | + |
2907 | + /// @fn QString getReplyURL(); |
2908 | + /// @brief Getter on replyURL. |
2909 | + /// @return replyURL |
2910 | + QString getReplyURL(); |
2911 | + |
2912 | + protected: |
2913 | + /// @brief HTTP rsponse code and reason |
2914 | + ResponseInfos httpResponse; |
2915 | + |
2916 | + /// @brief Content of the response |
2917 | + QByteArray responseBody; |
2918 | + |
2919 | + /// @brief Error which happened in the request |
2920 | + QString requestError; |
2921 | + |
2922 | + /// @brief Reply URL |
2923 | + QString replyURL; |
2924 | + |
2925 | + /// @fn ResponseInfos extractHttpStatusesFromNetworkReply(QNetworkReply reply); |
2926 | + /// @brief Extracting the HTTP code and the HTTP reason from an HTTP reply. |
2927 | + /// @param reply The QNetworkReply containing the reply of the HTTP request. |
2928 | + /// @return A ResponseInfos with the code and the reason. |
2929 | + ResponseInfos extractHttpStatusesFromNetworkReply(QNetworkReply * reply); |
2930 | +}; |
2931 | + |
2932 | +#endif // NETWORKRESPONSE_HPP |
2933 | |
2934 | === renamed file 'connection/model/errortypes.hpp' => 'connection/common/networkresulttype.hpp' |
2935 | --- connection/model/errortypes.hpp 2012-09-12 22:38:35 +0000 |
2936 | +++ connection/common/networkresulttype.hpp 2013-08-20 00:10:09 +0000 |
2937 | @@ -1,10 +1,10 @@ |
2938 | -/// @file errortypes.hpp |
2939 | -/// @brief Header containing the ErrorType enum |
2940 | +/// @file networkresulttype.hpp |
2941 | +/// @brief Header containing the LibRT::NetworkResultType enum |
2942 | /// @author Romain Ducher |
2943 | /// |
2944 | /// @section LICENSE |
2945 | /// |
2946 | -/// Copyright 2011 Romain Ducher |
2947 | +/// Copyright 2011, 2012 Romain Ducher |
2948 | /// |
2949 | /// This file is part of Reyn Tweets. |
2950 | /// |
2951 | @@ -24,37 +24,42 @@ |
2952 | #ifndef ERRORTYPES_HPP |
2953 | #define ERRORTYPES_HPP |
2954 | |
2955 | -/// @enum ErrorType |
2956 | -/// @brief Enumeration which indicates if something bad happened during the |
2957 | -/// request. It can takes three values depending on what happened. See the |
2958 | -/// enum values for more details. |
2959 | -enum ErrorType { |
2960 | - /// @brief Code indicating that there was no error. |
2961 | - NO_ERROR, |
2962 | - |
2963 | - /// @brief Code for an invalid request result. |
2964 | - INVALID_RESULT, |
2965 | - |
2966 | - /// @brief Code indicating that there were an error while calling the |
2967 | - /// Twitter API. |
2968 | - API_CALL, |
2969 | - |
2970 | - /// @brief Code indicating that the service (ex. Twitter) has returned errors. |
2971 | - SERVICE_ERRORS, |
2972 | - |
2973 | - /// @brief Code indicating that there was an error while parsing results |
2974 | - /// with <a href="http://qjson.sourceforge.net">QJson</a>. |
2975 | - QJSON_PARSING, |
2976 | - |
2977 | - /// @brief Code indicating that there was an error while parsing results |
2978 | - /// under the form <code>arg1=val1&arg2=val2&...&argN=valN</code>. |
2979 | - OAUTH_PARSING, |
2980 | - |
2981 | - /// @brief Code indicating that there was an error while parsing HTML. |
2982 | - HTML_PARSING, |
2983 | - |
2984 | - /// @brief Code indicating that there was an error while parsing XML. |
2985 | - XML_PARSING |
2986 | -}; |
2987 | +/// @namespace LibRT |
2988 | +/// @brief General namespace for stuff related to libRT (connection part of Reyn Tweets) |
2989 | +namespace LibRT { |
2990 | + /// @enum NetworkResultType |
2991 | + /// @brief Enumeration which indicates if something bad happened during the |
2992 | + /// request. It can takes three values depending on what happened. See the |
2993 | + /// enum values for more details. |
2994 | + enum NetworkResultType { |
2995 | + /// @brief There was no error. |
2996 | + NO_REQUEST_ERROR, |
2997 | + |
2998 | + /// @brief Code for an invalid request result. |
2999 | + INVALID_RESULT, |
3000 | + |
3001 | + /// @brief There were an error while calling the API. |
3002 | + API_CALL, |
3003 | + |
3004 | + /// @brief The service (ex. Twitter) has returned errors. |
3005 | + SERVICE_ERRORS, |
3006 | + |
3007 | + /// @brief There was an error while parsing JSON. |
3008 | + JSON_PARSING, |
3009 | + |
3010 | + /// @brief There was an error while parsing results under the form |
3011 | + /// <code>arg1=val1&arg2=val2&...&argN=valN</code>. |
3012 | + OAUTH_PARSING, |
3013 | + |
3014 | + /// @brief There was an error while parsing HTML. |
3015 | + HTML_PARSING, |
3016 | + |
3017 | + /// @brief There was an error while parsing XML. |
3018 | + XML_PARSING, |
3019 | + |
3020 | + /// @brief There is not any parsing. |
3021 | + NO_PARSING |
3022 | + }; |
3023 | +} |
3024 | |
3025 | #endif // ERRORTYPES_HPP |
3026 | |
3027 | === renamed file 'connection/model/requestresult.hpp' => 'connection/common/requestresult.hpp' |
3028 | --- connection/model/requestresult.hpp 2012-09-12 22:38:35 +0000 |
3029 | +++ connection/common/requestresult.hpp 2013-08-20 00:10:09 +0000 |
3030 | @@ -27,16 +27,17 @@ |
3031 | #define REQUESTRESULT_HPP |
3032 | |
3033 | #include <QVariant> |
3034 | -#include "errortypes.hpp" |
3035 | +#include "networkresulttype.hpp" |
3036 | #include "responseinfos.hpp" |
3037 | +#include "utils/httpcode.hpp" |
3038 | |
3039 | /// @struct RequestResult |
3040 | /// @brief Results of a request |
3041 | struct RequestResult { |
3042 | /// @brief Code indicating whether an error occured during the request. |
3043 | - ErrorType resultType; |
3044 | + LibRT::NetworkResultType resultType; |
3045 | |
3046 | - /// @brief Results of the request parsed by QJson. |
3047 | + /// @brief Parsed results. |
3048 | QVariant parsedResult; |
3049 | |
3050 | /// @brief HTTP response (code and reason) |
3051 | @@ -57,13 +58,20 @@ |
3052 | /// @fn RequestResult(); |
3053 | /// @brief Constructor |
3054 | RequestResult() : |
3055 | - resultType(INVALID_RESULT), |
3056 | + resultType(LibRT::INVALID_RESULT), |
3057 | parsedResult(), |
3058 | httpResponse(), |
3059 | serviceErrors(), |
3060 | parsingErrors(), |
3061 | errorMessage("") |
3062 | {} |
3063 | + |
3064 | + /// @fn LibRT::HTTPCode getHTTPCode(); |
3065 | + /// @brief HTTP response code (shortcut) |
3066 | + /// @return The HTTP response code as a LibRT::HTTPCode. |
3067 | + LibRT::HTTPCode getHTTPCode() { |
3068 | + return LibRT::HTTPCode(httpResponse.code); |
3069 | + } |
3070 | }; |
3071 | |
3072 | #endif // REQUESTRESULT_HPP |
3073 | |
3074 | === added directory 'connection/common/requests' |
3075 | === renamed file 'connection/requests/genericrequester.cpp' => 'connection/common/requests/genericrequester.cpp' |
3076 | --- connection/requests/genericrequester.cpp 2012-06-06 23:26:13 +0000 |
3077 | +++ connection/common/requests/genericrequester.cpp 2013-08-20 00:10:09 +0000 |
3078 | @@ -22,12 +22,13 @@ |
3079 | /// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
3080 | |
3081 | #include "genericrequester.hpp" |
3082 | -#include "../../tools/parsers/jsonparser.hpp" |
3083 | +#include "../utils/parsers/jsonparser.hpp" |
3084 | +#include "../utils/librtconstants.hpp" |
3085 | |
3086 | // Constructor. It just calls the parent constructor. |
3087 | -GenericRequester::GenericRequester(RequestType type, |
3088 | +GenericRequester::GenericRequester(LibRT::HTTPRequestType type, |
3089 | QString url, |
3090 | - ErrorType parseError) : |
3091 | + LibRT::NetworkResultType parseError) : |
3092 | QObject(), |
3093 | uuid(QUuid::createUuid()), |
3094 | requestURL(url), |
3095 | @@ -36,8 +37,7 @@ |
3096 | postParameters(), |
3097 | headers(), |
3098 | weblink(requestURL, requestType, getParameters, postParameters, headers), |
3099 | - parsingErrorType(parseError), |
3100 | - requestResult() |
3101 | + parsingErrorType(parseError) |
3102 | {} |
3103 | |
3104 | |
3105 | @@ -49,18 +49,13 @@ |
3106 | // Getters // |
3107 | ///////////// |
3108 | |
3109 | -// Getting parsed results |
3110 | -RequestResult GenericRequester::getRequestResult() { |
3111 | - return requestResult; |
3112 | -} |
3113 | - |
3114 | // Getter on the requester's UUID |
3115 | QUuid GenericRequester::getUuid() { |
3116 | return uuid; |
3117 | } |
3118 | |
3119 | // Setting parsingErrorType |
3120 | -void GenericRequester::setParsingErrorType(ErrorType parseErrorType) { |
3121 | +void GenericRequester::setParsingErrorType(LibRT::NetworkResultType parseErrorType) { |
3122 | parsingErrorType = parseErrorType; |
3123 | } |
3124 | |
3125 | @@ -72,17 +67,11 @@ |
3126 | // Building GET Parameters |
3127 | void GenericRequester::buildGETParameters() {} |
3128 | |
3129 | -// Bbuilding POST Parameters |
3130 | +// Building POST Parameters |
3131 | void GenericRequester::buildPOSTParameters() {} |
3132 | |
3133 | -// Bbuilding HTTP Headers |
3134 | -void GenericRequester::buildHTTPHeaders() { |
3135 | - // Be careful for update with medias |
3136 | - #ifndef Q_OS_SYMBIAN |
3137 | - // Needed for Qt 4.8.x (Windows and Linux) and Symbian version is 4.7.4. |
3138 | - headers.insert("Content-Type", "application/x-www-form-urlencoded"); |
3139 | - #endif |
3140 | -} |
3141 | +// Building HTTP Headers |
3142 | +void GenericRequester::buildHTTPHeaders() {} |
3143 | |
3144 | // Executing the request |
3145 | void GenericRequester::executeRequest() { |
3146 | @@ -91,8 +80,8 @@ |
3147 | buildHTTPHeaders(); |
3148 | |
3149 | // Request time ! |
3150 | - connect(&weblink, SIGNAL(requestDone()), |
3151 | - this, SLOT(treatResults())); |
3152 | + connect(&weblink, &TwitterCommunicator::requestDone, |
3153 | + this, &GenericRequester::treatResults); |
3154 | |
3155 | weblink.executeRequest(); |
3156 | } |
3157 | @@ -103,36 +92,55 @@ |
3158 | ////////////////////////// |
3159 | |
3160 | // Slot executed when the Twitter Communicator has just finished its work. |
3161 | -void GenericRequester::treatResults() { |
3162 | - disconnect(&weblink, SIGNAL(requestDone()), |
3163 | - this, SLOT(treatResults())); |
3164 | +void GenericRequester::treatResults(NetworkResponse netResponse) { |
3165 | + disconnect(&weblink, &TwitterCommunicator::requestDone, |
3166 | + this, &GenericRequester::treatResults); |
3167 | + |
3168 | + RequestResult requestResult; |
3169 | |
3170 | // Looking the HTTP request |
3171 | - requestResult.httpResponse = weblink.getHttpResponse(); |
3172 | - requestResult.errorMessage = weblink.getErrorMessage(); |
3173 | - |
3174 | - int httpReturnCode = weblink.getHttpResponse().code; |
3175 | - |
3176 | - if (httpReturnCode == 0) { |
3177 | - // No response => API_CALL |
3178 | - requestResult.resultType = API_CALL; |
3179 | - } else { |
3180 | - // A response to parse |
3181 | - bool parseOK; |
3182 | - QVariantMap parseErrorMap; |
3183 | - requestResult.parsedResult = this->parseResult(parseOK, parseErrorMap); |
3184 | - requestResult.resultType = parseOK ? NO_ERROR : parsingErrorType; |
3185 | - requestResult.parsingErrors.code = parseErrorMap.value("lineError").toInt(); |
3186 | - requestResult.parsingErrors.message = parseErrorMap.value("errorMsg").toString(); |
3187 | - |
3188 | - if (!parseOK) { |
3189 | - // Giving the response just in case the user would like to do sthg with it. |
3190 | - requestResult.parsedResult = QVariant::fromValue(weblink.getResponseBuffer()); |
3191 | - } else { |
3192 | - this->treatParsedResult(); |
3193 | - } |
3194 | + ResponseInfos netHTTPRep = netResponse.getHttpResponse(); |
3195 | + requestResult.httpResponse = netHTTPRep; |
3196 | + requestResult.errorMessage = netResponse.getRequestError(); |
3197 | + |
3198 | + switch (netHTTPRep.code) { |
3199 | + case LibRT::INVALID_HTTP_CODE: |
3200 | + // Invalid response => INVALID_RESULT |
3201 | + requestResult.resultType = LibRT::INVALID_RESULT; |
3202 | + break; |
3203 | + |
3204 | + case LibRT::TIMEOUT_HTTP_CODE: |
3205 | + // No response (because of timeout) => API_CALL |
3206 | + requestResult.resultType = LibRT::API_CALL; |
3207 | + break; |
3208 | + |
3209 | + default: { |
3210 | + // Parsing the response and filling requestResult |
3211 | + bool parseOK; |
3212 | + QVariantMap parseErrorMap; |
3213 | + requestResult.parsedResult = this->parseResult(netResponse, |
3214 | + parseOK, |
3215 | + parseErrorMap); |
3216 | + requestResult.parsingErrors.code = parseErrorMap.value("lineError").toInt(); |
3217 | + requestResult.parsingErrors.message = parseErrorMap.value("errorMsg").toString(); |
3218 | + |
3219 | + if (parseOK) { |
3220 | + // Other treatments related to the service |
3221 | + requestResult.serviceErrors = this->treatServiceErrors(requestResult.parsedResult, |
3222 | + netResponse); |
3223 | + // Updating the NetworkResultType with service errors |
3224 | + requestResult.resultType = requestResult.serviceErrors.isEmpty() ? |
3225 | + LibRT::NO_REQUEST_ERROR |
3226 | + : LibRT::SERVICE_ERRORS; |
3227 | + } else { |
3228 | + requestResult.resultType = parsingErrorType; |
3229 | + |
3230 | + // Giving the response just in case the user would like to do sthg with it. |
3231 | + requestResult.parsedResult = QVariant::fromValue(netResponse.getResponseBody()); |
3232 | + } |
3233 | + } break; |
3234 | } |
3235 | |
3236 | - // Telling the ReynTwitterCalls that the request is finished |
3237 | - emit requestDone(); |
3238 | + // Telling the Calls that the request is finished |
3239 | + emit requestDone(requestResult); |
3240 | } |
3241 | |
3242 | === renamed file 'connection/requests/genericrequester.hpp' => 'connection/common/requests/genericrequester.hpp' |
3243 | --- connection/requests/genericrequester.hpp 2012-09-12 23:18:26 +0000 |
3244 | +++ connection/common/requests/genericrequester.hpp 2013-08-20 00:10:09 +0000 |
3245 | @@ -27,8 +27,9 @@ |
3246 | #include <QObject> |
3247 | #include <QUuid> |
3248 | #include <QVariant> |
3249 | -#include "../model/requestresult.hpp" |
3250 | -#include "../twittercommunicators/twittercommunicator.hpp" |
3251 | +#include "../requestresult.hpp" |
3252 | +#include "../communicators/twittercommunicator.hpp" |
3253 | +#include "../networkresult.hpp" |
3254 | |
3255 | /// @class GenericRequester |
3256 | /// @brief Base class for all the requesters. |
3257 | @@ -37,19 +38,19 @@ |
3258 | Q_OBJECT |
3259 | |
3260 | public: |
3261 | - /// @fn GenericRequester(RequestType type, |
3262 | + /// @fn GenericRequester(Network::HTTPRequestType type, |
3263 | /// QString url, |
3264 | - /// ErrorType parseError = QJSON_PARSING); |
3265 | + /// LibRT::NetworkResultType parseError = Network::JSON_PARSING); |
3266 | /// @brief Constructor |
3267 | /// @param type Type of the request (GET ou POST). |
3268 | /// @param url URL called by the requester |
3269 | /// @param parseError Error type if an error occurs while parsing. Most |
3270 | - /// of the time, this value is set to QJSON_PARSING because results are |
3271 | - /// QJson stream parsed with QJson. However, OAuth requesters use their |
3272 | + /// of the time, this value is set to JSON_PARSING because results are |
3273 | + /// written in JSON. However, OAuth requesters use their |
3274 | /// own parsing process so they need a special value called OAUTH_PARSING. |
3275 | - GenericRequester(RequestType type, |
3276 | + GenericRequester(LibRT::HTTPRequestType type, |
3277 | QString url, |
3278 | - ErrorType parseError = QJSON_PARSING); |
3279 | + LibRT::NetworkResultType parseError = LibRT::JSON_PARSING); |
3280 | |
3281 | /// @fn virtual ~GenericRequester(); |
3282 | /// @brief Destructor. |
3283 | @@ -66,11 +67,6 @@ |
3284 | /// from the other ones. |
3285 | virtual void executeRequest(); |
3286 | |
3287 | - /// @fn RequestResult getRequestResult(); |
3288 | - /// @brief Getting parsed results |
3289 | - /// @return Parsed results in a QVariant object. |
3290 | - RequestResult getRequestResult(); |
3291 | - |
3292 | protected: |
3293 | /// @brief UUID of the request |
3294 | QUuid uuid; |
3295 | @@ -79,7 +75,7 @@ |
3296 | QString requestURL; |
3297 | |
3298 | /// @brief Request type |
3299 | - RequestType requestType; |
3300 | + LibRT::HTTPRequestType requestType; |
3301 | |
3302 | /// @brief GET parameters that will be passed to the Communicator. |
3303 | ArgsMap getParameters; |
3304 | @@ -98,8 +94,8 @@ |
3305 | /// @brief HTTP headers that will be passed to the Communicator. |
3306 | HeadersMap headers; |
3307 | |
3308 | - /// @fn virtual void buildPOSTParameters(); |
3309 | - /// @brief Virtual method building postParameters |
3310 | + /// @fn virtual void buildHTTPHeaders(); |
3311 | + /// @brief Virtual method building headers |
3312 | virtual void buildHTTPHeaders(); |
3313 | |
3314 | /// @brief Pointer on the Twitter Communicator that will purely execute |
3315 | @@ -107,13 +103,13 @@ |
3316 | TwitterCommunicator weblink; |
3317 | |
3318 | /// @brief Type of parsing error |
3319 | - ErrorType parsingErrorType; |
3320 | + LibRT::NetworkResultType parsingErrorType; |
3321 | |
3322 | - /// @fn void setParsingErrorType(ErrorType parseErrorType); |
3323 | + /// @fn void setParsingErrorType(LibRT::NetworkResultType parseErrorType); |
3324 | /// @brief Setting parsingErrorType in classes which inherits from |
3325 | /// GenericRequesters. |
3326 | /// @param parseErrorType New value for parsingErrorType |
3327 | - void setParsingErrorType(ErrorType parseErrorType); |
3328 | + void setParsingErrorType(LibRT::NetworkResultType parseErrorType); |
3329 | |
3330 | |
3331 | ////////////////////////// |
3332 | @@ -121,35 +117,44 @@ |
3333 | ////////////////////////// |
3334 | |
3335 | public slots: |
3336 | - /// @fn void treatResults(); |
3337 | + /// @fn void treatResults(NetworkResponse netResponse); |
3338 | /// @brief Slot that is executed when the Twitter Communicator has just |
3339 | /// finished its work. |
3340 | - void treatResults(); |
3341 | + /// @param netResponse Struct with response elements |
3342 | + void treatResults(NetworkResponse netResponse); |
3343 | |
3344 | protected: |
3345 | - /// @brief Result of the request. |
3346 | - RequestResult requestResult; |
3347 | - |
3348 | - /// @fn virtual QVariant parseResult(bool & parseOK, |
3349 | + /// @fn virtual QVariant parseResult(NetworkResponse results, |
3350 | + /// bool & parseOK, |
3351 | /// QVariantMap & parsingErrors) = 0; |
3352 | /// @brief Method that will parse the raw results of the request. |
3353 | + /// @param results Results to parse. Most of the time the method only |
3354 | + /// uses the responseBody field. |
3355 | /// @param parseOK Boolean whose value will be set to true if there was |
3356 | /// no problem while parsing, false otherwise. |
3357 | /// @param parsingErrors QVariantMap that may contain information about |
3358 | /// errors that may occur while parsing. |
3359 | /// @return Parsed results |
3360 | - virtual QVariant parseResult(bool & parseOK, |
3361 | + virtual QVariant parseResult(NetworkResponse results, |
3362 | + bool & parseOK, |
3363 | QVariantMap & parsingErrors) = 0; |
3364 | |
3365 | - /// @fn virtual void treatParsedResult() = 0; |
3366 | + /// @fn virtual QList<ResponseInfos> treatServiceErrors(QVariant parsedResults, |
3367 | + /// NetworkResponse netResponse) = 0; |
3368 | /// @brief Treating parsed results |
3369 | - virtual void treatParsedResult() = 0; |
3370 | + /// @param parsedResults Parsed results to analyse in order to retrieve |
3371 | + /// service errors. |
3372 | + /// @param netResponse Other network response elements, if needed. |
3373 | + /// @return The list of service errors |
3374 | + virtual QList<ResponseInfos> treatServiceErrors(QVariant parsedResults, |
3375 | + NetworkResponse netResponse) = 0; |
3376 | |
3377 | signals: |
3378 | - /// @fn void requestDone(); |
3379 | + /// @fn void requestDone(RequestResult requestResult); |
3380 | /// @brief Signal sent when the results of the request received by |
3381 | /// the Twitter Communicator have been treated. |
3382 | - void requestDone(); |
3383 | + /// @param requestResult Result of the request. |
3384 | + void requestDone(RequestResult requestResult); |
3385 | }; |
3386 | |
3387 | #endif // GENERICREQUESTER_HPP |
3388 | |
3389 | === renamed file 'connection/model/identificationway.hpp' => 'connection/common/requests/identificationway.hpp' |
3390 | --- connection/model/identificationway.hpp 2012-09-12 22:38:35 +0000 |
3391 | +++ connection/common/requests/identificationway.hpp 2013-08-20 00:10:09 +0000 |
3392 | @@ -1,5 +1,5 @@ |
3393 | /// @file identificationway.hpp |
3394 | -/// @brief Header of IdentificationWay |
3395 | +/// @brief Header of LibRT::IdentificationWay |
3396 | /// @author Romain Ducher |
3397 | /// |
3398 | /// @section LICENSE |
3399 | @@ -24,14 +24,16 @@ |
3400 | #ifndef IDENTIFICATIONWAY_HPP |
3401 | #define IDENTIFICATIONWAY_HPP |
3402 | |
3403 | -/// @enum IdentificationWay |
3404 | -/// @brief How the user is identified in a request ? |
3405 | -enum IdentificationWay { |
3406 | - /// @brief With an ID. |
3407 | - ID, |
3408 | +namespace LibRT { |
3409 | + /// @enum IdentificationWay |
3410 | + /// @brief How the user is identified in a request ? |
3411 | + enum IdentificationWay { |
3412 | + /// @brief With an ID. |
3413 | + ID, |
3414 | |
3415 | - /// @brief With a screen name |
3416 | - SCREEN_NAME |
3417 | -}; |
3418 | + /// @brief With a screen name |
3419 | + SCREEN_NAME |
3420 | + }; |
3421 | +} |
3422 | |
3423 | #endif // IDENTIFICATIONWAY_HPP |
3424 | |
3425 | === renamed file 'connection/model/responseinfos.hpp' => 'connection/common/responseinfos.hpp' |
3426 | --- connection/model/responseinfos.hpp 2012-09-12 22:38:35 +0000 |
3427 | +++ connection/common/responseinfos.hpp 2013-08-20 00:10:09 +0000 |
3428 | @@ -29,18 +29,27 @@ |
3429 | /// @struct ResponseInfos |
3430 | /// @brief Struct with an integer (field "code") and its meaning (field "message"). |
3431 | /// |
3432 | -/// When used to store QJSON parsing errors, "message" is the error message and |
3433 | -/// "code" the number of the line where the error occurs. |
3434 | +/// When used to store JSON parsing errors, "message" is the error message and |
3435 | +/// "code" the offset. |
3436 | struct ResponseInfos { |
3437 | /// @brief Code |
3438 | int code; |
3439 | |
3440 | /// @brief Decription of the code |
3441 | QString message; |
3442 | - |
3443 | +/* |
3444 | /// @fn ResponseInfos(); |
3445 | /// @brief Constructor |
3446 | ResponseInfos() : code(-1), message("") {} |
3447 | +//*/ |
3448 | + /// @fn ResponseInfos(int codeNum = -1, QString msg = ""); |
3449 | + /// @brief Full constructor |
3450 | + /// @param codeNum Value for code |
3451 | + /// @param msg Value for message |
3452 | + ResponseInfos(int codeNum = -1, QString msg = "") : |
3453 | + code(codeNum), |
3454 | + message(msg) |
3455 | + {} |
3456 | }; |
3457 | |
3458 | #endif // RESPONSEINFOS_HPP |
3459 | |
3460 | === renamed file 'connection/model/resultwrapper.cpp' => 'connection/common/resultwrapper.cpp' |
3461 | --- connection/model/resultwrapper.cpp 2012-09-12 22:38:35 +0000 |
3462 | +++ connection/common/resultwrapper.cpp 2013-08-20 00:10:09 +0000 |
3463 | @@ -1,5 +1,5 @@ |
3464 | /// @file resultwrapper.cpp |
3465 | -/// @brief Implementation of ResultSender |
3466 | +/// @brief Implementation of ResultWrapper |
3467 | /// |
3468 | /// Revisions older than r242 were in /trunk/ReynTweets/connection |
3469 | /// @author Romain Ducher |
3470 | |
3471 | === renamed file 'connection/model/resultwrapper.hpp' => 'connection/common/resultwrapper.hpp' |
3472 | === added directory 'connection/common/utils' |
3473 | === renamed file 'tools/utils.cpp' => 'connection/common/utils/connectionutils.cpp' |
3474 | --- tools/utils.cpp 2012-05-04 02:46:20 +0000 |
3475 | +++ connection/common/utils/connectionutils.cpp 2013-08-20 00:10:09 +0000 |
3476 | @@ -1,5 +1,5 @@ |
3477 | -/// @file utils.cpp |
3478 | -/// @brief Implementation of the useful methods declared in utils.hpp. |
3479 | +/// @file connectionutils.cpp |
3480 | +/// @brief Implementation of the useful methods declared in connectionutils.hpp. |
3481 | /// |
3482 | /// Revisions older than r120 are in the folder /trunk/ReynTweets/connection/. |
3483 | /// @author Romain Ducher |
3484 | @@ -23,23 +23,24 @@ |
3485 | /// You should have received a copy of the GNU Lesser General Public License |
3486 | /// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
3487 | |
3488 | +#include "connectionutils.hpp" |
3489 | #include <QCryptographicHash> |
3490 | -#include <QJson/QObjectHelper> |
3491 | -#include <QJson/Parser> |
3492 | -#include <QJson/Serializer> |
3493 | +#include <QVariant> |
3494 | +#include <QMapIterator> |
3495 | +#include <QMetaProperty> |
3496 | +#include <QJsonDocument> |
3497 | #include <QUrl> |
3498 | -#include "utils.hpp" |
3499 | |
3500 | /////////////////////// |
3501 | // String convertion // |
3502 | /////////////////////// |
3503 | |
3504 | // Converting a RequestType into a QString |
3505 | -QString requestTypeToString(RequestType type) { |
3506 | +QString requestTypeToString(LibRT::HTTPRequestType type) { |
3507 | switch (type) { |
3508 | - case GET: |
3509 | + case LibRT::GET: |
3510 | return "GET"; |
3511 | - case POST: |
3512 | + case LibRT::POST: |
3513 | return "POST"; |
3514 | default: |
3515 | return ""; |
3516 | @@ -63,84 +64,13 @@ |
3517 | } |
3518 | |
3519 | |
3520 | -//////////////////// |
3521 | -// JSON Streaming // |
3522 | -//////////////////// |
3523 | - |
3524 | -// Output stream operator for serialization |
3525 | -QDataStream & jsonStreamingOut(QDataStream & out, |
3526 | - const QObject & objectToStream, |
3527 | - const QStringList & blacklist) |
3528 | -{ |
3529 | - // Converting the object into a JSON file |
3530 | - QVariantMap accountMap = QJson::QObjectHelper::qobject2qvariant(&objectToStream, blacklist); |
3531 | - QJson::Serializer serializer; |
3532 | - QByteArray jsonedAccount = serializer.serialize(accountMap); |
3533 | - |
3534 | - // Putting it in the stream |
3535 | - out << jsonedAccount; |
3536 | - |
3537 | - return out; |
3538 | -} |
3539 | - |
3540 | -// Input stream operator for serialization |
3541 | -QDataStream & jsonStreamingIn(QDataStream & in, QObject & objectToStream) { |
3542 | - QByteArray jsonedAccount = ""; |
3543 | - in >> jsonedAccount; |
3544 | - |
3545 | - QJson::Parser parser; |
3546 | - bool parseOK; |
3547 | - QVariant accountVariant = parser.parse(jsonedAccount, &parseOK); |
3548 | - |
3549 | - if (parseOK) { |
3550 | - QJson::QObjectHelper::qvariant2qobject(accountVariant.toMap(), &objectToStream); |
3551 | - } |
3552 | - |
3553 | - return in; |
3554 | -} |
3555 | - |
3556 | - |
3557 | ////////////////// |
3558 | // Miscanellous // |
3559 | ////////////////// |
3560 | |
3561 | -// HMAC-SHA1 algorithm for signatures. |
3562 | -QString hmacSha1(QByteArray key, QByteArray baseString) { |
3563 | - int blockSize = 64; // HMAC-SHA-1 block size, defined in SHA-1 standard |
3564 | - |
3565 | - if (key.length() > blockSize) { |
3566 | - // if key is longer than block size (64), reduce key length with |
3567 | - // SHA-1 compression |
3568 | - key = QCryptographicHash::hash(key, QCryptographicHash::Sha1); |
3569 | - } |
3570 | - |
3571 | - // initialize inner padding with char "6" |
3572 | - QByteArray innerPadding(blockSize, char(0x36)); |
3573 | - // initialize outer padding with char "\" |
3574 | - QByteArray outerPadding(blockSize, char(0x5c)); |
3575 | - |
3576 | - // ascii characters 0x36 ("6") and 0x5c ("\") are selected because they have |
3577 | - // large Hamming distance (http://en.wikipedia.org/wiki/Hamming_distance) |
3578 | - |
3579 | - for (int i = 0; i < key.length(); i++) { |
3580 | - // XOR operation between every byte in key and innerpadding, of key length |
3581 | - innerPadding[i] = innerPadding[i] ^ key.at(i); |
3582 | - // XOR operation between every byte in key and outerpadding, of key length |
3583 | - outerPadding[i] = outerPadding[i] ^ key.at(i); |
3584 | - } |
3585 | - |
3586 | - // result = hash ( outerPadding CONCAT hash ( innerPadding CONCAT baseString ) ).toBase64 |
3587 | - QByteArray total = outerPadding; |
3588 | - QByteArray part = innerPadding; |
3589 | - part.append(baseString); |
3590 | - total.append(QCryptographicHash::hash(part, QCryptographicHash::Sha1)); |
3591 | - QByteArray hashed = QCryptographicHash::hash(total, QCryptographicHash::Sha1); |
3592 | - return hashed.toBase64(); |
3593 | -} |
3594 | - |
3595 | // Exclusive OR |
3596 | bool ouBien(bool a, bool b) { |
3597 | - return (a && !b) || (!a && b); |
3598 | + return (a && !b) || (!a && b); |
3599 | } |
3600 | |
3601 | // Formatting parameters in the Authorization header |
3602 | |
3603 | === renamed file 'tools/utils.hpp' => 'connection/common/utils/connectionutils.hpp' |
3604 | --- tools/utils.hpp 2012-09-12 22:38:35 +0000 |
3605 | +++ connection/common/utils/connectionutils.hpp 2013-08-20 00:10:09 +0000 |
3606 | @@ -1,4 +1,4 @@ |
3607 | -/// @file utils.hpp |
3608 | +/// @file connectionutils.hpp |
3609 | /// @brief Header with useful methods |
3610 | /// |
3611 | /// Revisions older than r120 are in the folder /trunk/ReynTweets/connection/ |
3612 | @@ -23,24 +23,24 @@ |
3613 | /// You should have received a copy of the GNU Lesser General Public License |
3614 | /// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
3615 | |
3616 | -#ifndef UTILS_HPP |
3617 | -#define UTILS_HPP |
3618 | +#ifndef CONNECTIONUTILS_HPP |
3619 | +#define CONNECTIONUTILS_HPP |
3620 | |
3621 | #include <QByteArray> |
3622 | #include <QColor> |
3623 | #include <QDataStream> |
3624 | #include <QString> |
3625 | -#include "../connection/model/requesttype.hpp" |
3626 | +#include "../httprequesttype.hpp" |
3627 | |
3628 | /////////////////////// |
3629 | // String convertion // |
3630 | /////////////////////// |
3631 | |
3632 | -/// @fn QString requestTypeToString(RequestType type) |
3633 | +/// @fn QString requestTypeToString(Network::HTTPRequestType type) |
3634 | /// @brief Converting a RequestType into a QString |
3635 | /// @param type The RequestType |
3636 | /// @return The corresponding QString |
3637 | -QString requestTypeToString(RequestType type); |
3638 | +QString requestTypeToString(LibRT::HTTPRequestType type); |
3639 | |
3640 | /// @fn QString boolInString(bool b); |
3641 | /// @brief Converting a bool into a QString |
3642 | @@ -48,62 +48,16 @@ |
3643 | /// @return The corresponding QString |
3644 | QString boolInString(bool b); |
3645 | |
3646 | -/// @fn QColor string2color(QString coloredString); |
3647 | -/// @brief Converting a String into a QColor. |
3648 | -/// |
3649 | -/// This function was written because of Twitter which forgets the '#' |
3650 | -/// character before the hexadecimal code under the form 'RRGGBB'. |
3651 | -/// @param coloredString The string with the RRGGBB format. |
3652 | -/// @return The corresponding color : ‡RRGGBB |
3653 | -QColor string2color(QString coloredString); |
3654 | - |
3655 | - |
3656 | -//////////////////// |
3657 | -// JSON Streaming // |
3658 | -//////////////////// |
3659 | - |
3660 | -/// @fn QDataStream & jsonStreamingOut(QDataStream & out, |
3661 | -/// const QObject & objectToStream, |
3662 | -/// const QStringList & blacklist = |
3663 | -/// QStringList(QString(QLatin1String("objectName")))); |
3664 | -/// @brief Output stream operator for JSON serialization |
3665 | -/// @param out The output stream |
3666 | -/// @param objectToStream Object to put in the stream |
3667 | -/// @param blacklist Properties to ignore while conserting the QObject into |
3668 | -/// a QVariant before serializing. |
3669 | -/// @return The stream with the object |
3670 | -QDataStream & jsonStreamingOut(QDataStream & out, |
3671 | - const QObject & objectToStream, |
3672 | - const QStringList & blacklist = QStringList(QString(QLatin1String("objectName")))); |
3673 | - |
3674 | -/// @fn QDataStream & jsonStreamingIn(QDataStream & in, QObject & objectToStream); |
3675 | -/// @brief Input stream operator for JSON serialization |
3676 | -/// @param in The input stream |
3677 | -/// @param objectToStream Object to put in the stream |
3678 | -/// @return The stream with the object |
3679 | -QDataStream & jsonStreamingIn(QDataStream & in, QObject & objectToStream); |
3680 | - |
3681 | |
3682 | ////////////////// |
3683 | // Miscanellous // |
3684 | ////////////////// |
3685 | |
3686 | -/// @fn QString hmacSha1(QByteArray key, QByteArray baseString); |
3687 | -/// @brief HMAC-SHA1 algorithm for signatures. |
3688 | -/// |
3689 | -/// Its implementation for Reyn Tweets was found on the |
3690 | -/// <a href="http://developer.qt.nokia.com/">Qt Developer Network</a> here : |
3691 | -/// <a href="http://developer.qt.nokia.com/wiki/HMAC-SHA1"> |
3692 | -/// http://developer.qt.nokia.com/wiki/HMAC-SHA1</a>. |
3693 | -/// @param key Key for signature |
3694 | -/// @param baseString String that we want to sign |
3695 | -/// @return The signature |
3696 | -QString hmacSha1(QByteArray key, QByteArray baseString); |
3697 | - |
3698 | /// @fn bool ouBien(bool a, bool b); |
3699 | /// @brief Logical XOR : <code>a XOR b == a && !b || !a && b</code> |
3700 | /// @param a 1st bool |
3701 | /// @param b 2nd bool |
3702 | +/// @returns a XOR b |
3703 | bool ouBien(bool a, bool b); |
3704 | |
3705 | /// @fn QString formatParam(QString name, QString value, bool putDoubleQuotes = false); |
3706 | @@ -124,4 +78,4 @@ |
3707 | /// @return The formatted parameters |
3708 | QString formatParam(QString name, QString value, bool putDoubleQuotes = false); |
3709 | |
3710 | -#endif // UTILS_HPP |
3711 | +#endif // CONNECTIONUTILS_HPP |
3712 | |
3713 | === added file 'connection/common/utils/httpcode.hpp' |
3714 | --- connection/common/utils/httpcode.hpp 1970-01-01 00:00:00 +0000 |
3715 | +++ connection/common/utils/httpcode.hpp 2013-08-20 00:10:09 +0000 |
3716 | @@ -0,0 +1,286 @@ |
3717 | +/// @file httpcode.hpp |
3718 | +/// @brief Header for the LibRT::HTTPCode enum. |
3719 | +/// @author Romain Ducher |
3720 | +/// |
3721 | +/// @section LICENSE |
3722 | +/// |
3723 | +/// Copyright 2013 Romain Ducher |
3724 | +/// |
3725 | +/// This file is part of Reyn Tweets. |
3726 | +/// |
3727 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
3728 | +/// it under the terms of the GNU Lesser General Public License as published by |
3729 | +/// the Free Software Foundation, either version 3 of the License, or |
3730 | +/// (at your option) any later version. |
3731 | +/// |
3732 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
3733 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
3734 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3735 | +/// GNU Lesser General Public License for more details. |
3736 | +/// |
3737 | +/// You should have received a copy of the GNU Lesser General Public License |
3738 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
3739 | + |
3740 | +#ifndef HTTPCODE_HPP |
3741 | +#define HTTPCODE_HPP |
3742 | + |
3743 | +namespace LibRT { |
3744 | + |
3745 | + /// @enum HTTPCode |
3746 | + /// @brief Enum with the HTTP codes. |
3747 | + /// |
3748 | + /// It contains all the official HTTP return codes as defined by the |
3749 | + /// <a href="http://tools.ietf.org/html/rfc2616">RFC 2616</a> + two other |
3750 | + /// custom codes, LibRT::INVALID_HTTP_CODE (for fake values) and |
3751 | + /// LibRT::TIMEOUT_HTTP_CODE (for timeouts). |
3752 | + enum HTTPCode { |
3753 | + /// @brief Invalid HTTP response code |
3754 | + INVALID_HTTP_CODE = -1, |
3755 | + |
3756 | + /// @brief HTTP response code for timeouts |
3757 | + TIMEOUT_HTTP_CODE = 0, |
3758 | + |
3759 | + /// @brief 100 HTTP return code. |
3760 | + CONTINUE = 100, |
3761 | + |
3762 | + /// @brief 101 HTTP return code. |
3763 | + SWITCHING_PROTOCOLS = 101, |
3764 | + |
3765 | + /// @brief 102 HTTP return code. |
3766 | + PROCESSING = 102, |
3767 | + |
3768 | + /// @brief 118 HTTP return code. |
3769 | + CONNECTION_TIMED_OUT = 118, |
3770 | + |
3771 | + /// @brief 200 HTTP return code. |
3772 | + OK = 200, |
3773 | + |
3774 | + /// @brief 201 HTTP return code. |
3775 | + CREATED = 201, |
3776 | + |
3777 | + /// @brief 202 HTTP return code. |
3778 | + ACCEPTED = 202, |
3779 | + |
3780 | + /// @brief 203 HTTP return code. |
3781 | + NON_AUTHORITATIVE_INFORMATION = 203, |
3782 | + |
3783 | + /// @brief 204 HTTP return code. |
3784 | + NO_CONTENT = 204, |
3785 | + |
3786 | + /// @brief 205 HTTP return code. |
3787 | + RESET_CONTENT = 205, |
3788 | + |
3789 | + /// @brief 206 HTTP return code. |
3790 | + PARTIAL_CONTENT = 206, |
3791 | + |
3792 | + /// @brief 207 HTTP return code. |
3793 | + MULTI_STATUS = 207, |
3794 | + |
3795 | + /// @brief 208 HTTP return code. |
3796 | + ALREADY_REPORTED = 208, |
3797 | + |
3798 | + /// @brief 210 HTTP return code. |
3799 | + CONTENT_DIFFERENT = 210, |
3800 | + |
3801 | + /// @brief 226 HTTP return code. |
3802 | + IM_USED = 226, |
3803 | + |
3804 | + /// @brief 300 HTTP return code. |
3805 | + MULTIPLE_CHOICES = 300, |
3806 | + |
3807 | + /// @brief 301 HTTP return code. |
3808 | + MOVED_PERMANENTLY = 301, |
3809 | + |
3810 | + /// @brief 302 HTTP return code. |
3811 | + MOVED_TEMPORARILY = 302, |
3812 | + |
3813 | + /// @brief 303 HTTP return code. |
3814 | + SEE_OTHER = 303, |
3815 | + |
3816 | + /// @brief 304 HTTP return code. |
3817 | + NOT_MODIFIED = 304, |
3818 | + |
3819 | + /// @brief 305 HTTP return code. |
3820 | + USE_PROXY = 305, |
3821 | + |
3822 | + /// @brief 306 HTTP return code. |
3823 | + SWITCH_PROXY = 306, |
3824 | + |
3825 | + /// @brief 307 HTTP return code. |
3826 | + TEMPORARY_REDIRECT = 307, |
3827 | + |
3828 | + /// @brief 308 HTTP return code. |
3829 | + PERMANENT_REDIRECT = 308, |
3830 | + |
3831 | + /// @brief 310 HTTP return code. |
3832 | + TOO_MANY_REDIRECTS = 310, |
3833 | + |
3834 | + /// @brief 400 HTTP return code. |
3835 | + BAD_REQUEST = 400, |
3836 | + |
3837 | + /// @brief 401 HTTP return code. |
3838 | + UNAUTHORIZED = 401, |
3839 | + |
3840 | + /// @brief 402 HTTP return code. |
3841 | + PAYMENT_REQUIRED = 402, |
3842 | + |
3843 | + /// @brief 403 HTTP return code. |
3844 | + FORBIDDEN = 403, |
3845 | + |
3846 | + /// @brief 404 HTTP return code. |
3847 | + NOT_FOUND = 404, |
3848 | + |
3849 | + /// @brief 405 HTTP return code. |
3850 | + METHOD_NOT_ALLOWED = 405, |
3851 | + |
3852 | + /// @brief 406 HTTP return code. |
3853 | + NOT_ACCEPTABLE = 406, |
3854 | + |
3855 | + /// @brief 407 HTTP return code. |
3856 | + PROXY_AUTHENTICATION_REQUIRED = 407, |
3857 | + |
3858 | + /// @brief 408 HTTP return code. |
3859 | + REQUEST_TIMEOUT = 408, |
3860 | + |
3861 | + /// @brief 409 HTTP return code. |
3862 | + CONFLICT = 409, |
3863 | + |
3864 | + /// @brief 410 HTTP return code. |
3865 | + GONE = 410, |
3866 | + |
3867 | + /// @brief 411 HTTP return code. |
3868 | + LENGTH_REQUIRED = 411, |
3869 | + |
3870 | + /// @brief 412 HTTP return code. |
3871 | + PRECONDITION_FAILED = 412, |
3872 | + |
3873 | + /// @brief 413 HTTP return code. |
3874 | + REQUEST_ENTITY_TOO_LARGE = 413, |
3875 | + |
3876 | + /// @brief 414 HTTP return code. |
3877 | + REQUEST_URI_TOO_LONG = 414, |
3878 | + |
3879 | + /// @brief 415 HTTP return code. |
3880 | + UNSUPPORTED_MEDIA_TYPE = 415, |
3881 | + |
3882 | + /// @brief 416 HTTP return code. |
3883 | + REQUEST_RANGE_UNSATISFIABLE = 416, |
3884 | + |
3885 | + /// @brief 417 HTTP return code. |
3886 | + EXPECTATION_FAILED = 417, |
3887 | + |
3888 | + /// @brief 418 HTTP return code. |
3889 | + I_AM_A_TEAPOT = 418, |
3890 | + |
3891 | + /// @brief 419 HTTP return code. |
3892 | + AUTHENTICATION_TIMEOUT = 419, |
3893 | + |
3894 | + /// @brief 420 HTTP return code (used by Twitter). |
3895 | + ENHANCE_YOUR_CALM = 420, |
3896 | + |
3897 | + /// @brief 422 HTTP return code. |
3898 | + UNPROCESSABLLE_ENTITY = 422, |
3899 | + |
3900 | + /// @brief 423 HTTP return code. |
3901 | + LOCKED = 423, |
3902 | + |
3903 | + /// @brief 424 HTTP return code. |
3904 | + METHOD_FAILURE = 424, |
3905 | + |
3906 | + /// @brief 424 HTTP return code (WebDAV + RFC 4918). |
3907 | + FAILED_DEPENDENCY = 424, |
3908 | + |
3909 | + /// @brief 425 HTTP return code. |
3910 | + UNORDERED_COLLECTION = 425, |
3911 | + |
3912 | + /// @brief 426 HTTP return code. |
3913 | + UPGRADE_REQUIRED = 426, |
3914 | + |
3915 | + /// @brief 428 HTTP return code. |
3916 | + PRECONDITION_REQUIRED = 428, |
3917 | + |
3918 | + /// @brief 429 HTTP return code. |
3919 | + TOO_MANY_REQUESTS = 429, |
3920 | + |
3921 | + /// @brief 431 HTTP return code. |
3922 | + REQUEST_HEADER_FIELDS_TOO_LARGE = 431, |
3923 | + |
3924 | + /// @brief 444 HTTP return code. |
3925 | + NO_RESPONSE = 444, |
3926 | + |
3927 | + /// @brief 449 HTTP return code. |
3928 | + RETRY_WITH = 449, |
3929 | + |
3930 | + /// @brief 450 HTTP return code. |
3931 | + BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS = 450, |
3932 | + |
3933 | + /// @brief 451 HTTP return code. |
3934 | + UNAVAILABLE_FOR_LEGAL_REASONS = 451, |
3935 | + |
3936 | + /// @brief 456 HTTP return code. |
3937 | + UNRECOVERABLE_ERROR = 456, |
3938 | + |
3939 | + /// @brief 494 HTTP return code. |
3940 | + REQUEST_HEADER_TOO_LARGE = 494, |
3941 | + |
3942 | + /// @brief 495 HTTP return code. |
3943 | + CERT_ERROR = 495, |
3944 | + |
3945 | + /// @brief 496 HTTP return code. |
3946 | + NO_CERT = 496, |
3947 | + |
3948 | + /// @brief 497 HTTP return code. |
3949 | + HTTP_TO_HTTPS = 497, |
3950 | + |
3951 | + /// @brief 499 HTTP return code. |
3952 | + CLIENT_HAS_CLOSED_CONNECTION = 499, |
3953 | + |
3954 | + /// @brief 500 HTTP return code. |
3955 | + INTERNAL_SERVER_ERROR = 500, |
3956 | + |
3957 | + /// @brief 501 HTTP return code. |
3958 | + NOT_IMPLEMENTED = 501, |
3959 | + |
3960 | + /// @brief 502 HTTP return code. |
3961 | + BAD_GATEWAY = 502, |
3962 | + |
3963 | + /// @brief 502 HTTP return code. |
3964 | + PROXY_ERROR = 502, |
3965 | + |
3966 | + /// @brief 503 HTTP return code. |
3967 | + SERVICE_UNAVAILABLE = 503, |
3968 | + |
3969 | + /// @brief 504 HTTP return code. |
3970 | + GATEWAY_TIMEOUT = 504, |
3971 | + |
3972 | + /// @brief 505 HTTP return code. |
3973 | + HTTP_VERSION_NOT_SUPPORTED = 505, |
3974 | + |
3975 | + /// @brief 506 HTTP return code. |
3976 | + VARIANT_ALSO_NEGOCIATE = 506, |
3977 | + |
3978 | + /// @brief 507 HTTP return code. |
3979 | + INSUFFICENT_STORAGE = 507, |
3980 | + |
3981 | + /// @brief 508 HTTP return code. |
3982 | + LOOP_DETECTED = 508, |
3983 | + |
3984 | + /// @brief 509 HTTP return code. |
3985 | + BANDWITH_LIMIT_EXCEEDED = 509, |
3986 | + |
3987 | + /// @brief 510 HTTP return code. |
3988 | + NOT_EXTENDED = 510, |
3989 | + |
3990 | + /// @brief 511 HTTP return code. |
3991 | + NETWORK_AUTHENTICATION_REQUIRED = 511, |
3992 | + |
3993 | + /// @brief 598 HTTP return code. |
3994 | + NETWORK_READ_TIMEOUT_ERROR = 598, |
3995 | + |
3996 | + /// @brief 599 HTTP return code. |
3997 | + NETWORK_CONNECT_TIMEOUT_ERROR = 599 |
3998 | + }; |
3999 | + |
4000 | +} |
4001 | + |
4002 | +#endif // HTTPCODE_HPP |
4003 | |
4004 | === added file 'connection/common/utils/librtconstants.cpp' |
4005 | --- connection/common/utils/librtconstants.cpp 1970-01-01 00:00:00 +0000 |
4006 | +++ connection/common/utils/librtconstants.cpp 2013-08-20 00:10:09 +0000 |
4007 | @@ -0,0 +1,48 @@ |
4008 | +/// @file librtconstants.cpp |
4009 | +/// @brief Implementation for libRT constants. |
4010 | +/// @author Romain Ducher |
4011 | +/// |
4012 | +/// @section LICENSE |
4013 | +/// |
4014 | +/// Copyright 2013 Romain Ducher |
4015 | +/// |
4016 | +/// This file is part of Reyn Tweets. |
4017 | +/// |
4018 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
4019 | +/// it under the terms of the GNU Lesser General Public License as published by |
4020 | +/// the Free Software Foundation, either version 3 of the License, or |
4021 | +/// (at your option) any later version. |
4022 | +/// |
4023 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
4024 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
4025 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4026 | +/// GNU Lesser General Public License for more details. |
4027 | +/// |
4028 | +/// You should have received a copy of the GNU Lesser General Public License |
4029 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
4030 | + |
4031 | +#include "librtconstants.hpp" |
4032 | + |
4033 | +// Fake tweet ID |
4034 | +const qlonglong LibRT::FAKE_ID = -1; |
4035 | + |
4036 | +/// @brief Generic fake value for ID represented by a string (empty string) |
4037 | +const QString LibRT::FAKE_STRING_ID = ""; |
4038 | + |
4039 | +// Fake longitude |
4040 | +const float LibRT::FAKE_LONGITUDE = 181; |
4041 | + |
4042 | +// Fake latitude |
4043 | +const float LibRT::FAKE_LATITUDE = 91; |
4044 | + |
4045 | +// Maximum longitude |
4046 | +const float LibRT::MAX_LONGITUDE = 180; |
4047 | + |
4048 | +// Maximum latitude |
4049 | +const float LibRT::MAX_LATITUDE = 90; |
4050 | + |
4051 | +// Fake value for a token (empty string) |
4052 | +const QByteArray LibRT::FAKE_TOKEN = ""; |
4053 | + |
4054 | +// Fake value for an URL (empty string) |
4055 | +const QString LibRT::FAKE_URL = ""; |
4056 | |
4057 | === added file 'connection/common/utils/librtconstants.hpp' |
4058 | --- connection/common/utils/librtconstants.hpp 1970-01-01 00:00:00 +0000 |
4059 | +++ connection/common/utils/librtconstants.hpp 2013-08-20 00:10:09 +0000 |
4060 | @@ -0,0 +1,57 @@ |
4061 | +/// @file librtconstants.hpp |
4062 | +/// @brief Header for libRT constants. |
4063 | +/// @author Romain Ducher |
4064 | +/// |
4065 | +/// @section LICENSE |
4066 | +/// |
4067 | +/// Copyright 2013 Romain Ducher |
4068 | +/// |
4069 | +/// This file is part of Reyn Tweets. |
4070 | +/// |
4071 | +/// Reyn Tweets is free software: you can redistribute it and/or modify |
4072 | +/// it under the terms of the GNU Lesser General Public License as published by |
4073 | +/// the Free Software Foundation, either version 3 of the License, or |
4074 | +/// (at your option) any later version. |
4075 | +/// |
4076 | +/// Reyn Tweets is distributed in the hope that it will be useful, |
4077 | +/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
4078 | +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4079 | +/// GNU Lesser General Public License for more details. |
4080 | +/// |
4081 | +/// You should have received a copy of the GNU Lesser General Public License |
4082 | +/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
4083 | + |
4084 | +#ifndef LIBRTCONSTANTS_HPP |
4085 | +#define LIBRTCONSTANTS_HPP |
4086 | + |
4087 | +#include <QString> |
4088 | + |
4089 | +namespace LibRT { |
4090 | + /// @brief Generic fake ID. |
4091 | + extern const qlonglong FAKE_ID; |
4092 | + |
4093 | + /// @brief Generic fake value for ID represented by a string (empty string) |
4094 | + extern const QString FAKE_STRING_ID; |
4095 | + |
4096 | + /// @brief Fake longitude |
4097 | + extern const float FAKE_LONGITUDE; |
4098 | + |
4099 | + /// @brief Fake latitude |
4100 | + extern const float FAKE_LATITUDE; |
4101 | + |
4102 | + /// @brief Maximum absolute value for a longitude (180 since a valid |
4103 | + /// longitude is between -180 and +180). |
4104 | + extern const float MAX_LONGITUDE; |
4105 | + |
4106 | + /// @brief Maximum absolute value for a latitude (180 since a valid |
4107 | + /// latitude is between -90 and +90). |
4108 | + extern const float MAX_LATITUDE; |
4109 | + |
4110 | + /// @brief Fake value for a token (empty string) |
4111 | + extern const QByteArray FAKE_TOKEN; |
4112 | + |
4113 | + /// @brief Fake value for an URL (empty string) |
4114 | + extern const QString FAKE_URL; |
4115 | +} |
4116 | + |
4117 | +#endif // LIBRTCONSTANTS_HPP |
4118 | |
4119 | === renamed directory 'tools/parsers' => 'connection/common/utils/parsers' |
4120 | === modified file 'connection/common/utils/parsers/genericparser.hpp' |
4121 | --- tools/parsers/genericparser.hpp 2012-05-19 15:39:56 +0000 |
4122 | +++ connection/common/utils/parsers/genericparser.hpp 2013-08-20 00:10:09 +0000 |
4123 | @@ -32,13 +32,13 @@ |
4124 | /// @class GenericParser |
4125 | /// @brief Base class for all the parsers. |
4126 | /// @param T Type of parsed results |
4127 | -template <class T> |
4128 | +template <typename T> |
4129 | class GenericParser |
4130 | { |
4131 | public: |
4132 | /// @fn virtual QVariantMap parse(QByteArray data, |
4133 | - /// bool & parseOK, |
4134 | - /// QString & parseError, |
4135 | + /// bool * parseOK = 0, |
4136 | + /// QString * parseError = 0, |
4137 | /// int * lineError = 0, |
4138 | /// int * columnError = 0) = 0; |
4139 | /// @brief Method for parsing results |
4140 | @@ -48,8 +48,8 @@ |
4141 | /// @param lineError Line of the error |
4142 | /// @param columnError Column of the error |
4143 | virtual T parse(QByteArray data, |
4144 | - bool & parseOK, |
4145 | - QString & parseError, |
4146 | + bool * parseOK = 0, |
4147 | + QString * parseError = 0, |
4148 | int * lineError = 0, |
4149 | int * columnError = 0) = 0; |
4150 | }; |
4151 | |
4152 | === modified file 'connection/common/utils/parsers/htmlparser.cpp' |
4153 | --- tools/parsers/htmlparser.cpp 2012-05-19 15:39:56 +0000 |
4154 | +++ connection/common/utils/parsers/htmlparser.cpp 2013-08-20 00:10:09 +0000 |
4155 | @@ -23,27 +23,33 @@ |
4156 | /// You should have received a copy of the GNU Lesser General Public License |
4157 | /// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
4158 | |
4159 | +#include "htmlparser.hpp" |
4160 | #include <QWebFrame> |
4161 | #include <QWebPage> |
4162 | -#include "htmlparser.hpp" |
4163 | |
4164 | // Parsing results |
4165 | QWebElement HTMLParser::parse(QByteArray data, |
4166 | - bool & parseOK, |
4167 | - QString & parseError, |
4168 | + bool * parseOK, |
4169 | + QString * parseError, |
4170 | int *, int *) |
4171 | { |
4172 | QWebPage webPage; |
4173 | QWebFrame * frame = webPage.mainFrame(); |
4174 | |
4175 | + if (parseOK) { |
4176 | + *parseOK = frame != 0; |
4177 | + } |
4178 | + |
4179 | if (frame) { |
4180 | frame->setHtml(QString::fromUtf8(data.data())); |
4181 | - parseOK = true; |
4182 | - parseError = ""; |
4183 | + if (parseError) { |
4184 | + *parseError = ""; |
4185 | + } |
4186 | return frame->documentElement(); |
4187 | } else { |
4188 | - parseOK = false; |
4189 | - parseError = QObject::trUtf8("No HTML parser available.").append('\n'); |
4190 | + if (parseError) { |
4191 | + *parseError = QObject::trUtf8("No HTML parser available."); |
4192 | + } |
4193 | return QWebElement(); |
4194 | } |
4195 | } |
4196 | |
4197 | === modified file 'connection/common/utils/parsers/htmlparser.hpp' |
4198 | --- tools/parsers/htmlparser.hpp 2012-05-19 15:39:56 +0000 |
4199 | +++ connection/common/utils/parsers/htmlparser.hpp 2013-08-20 00:10:09 +0000 |
4200 | @@ -35,8 +35,8 @@ |
4201 | { |
4202 | public: |
4203 | /// @fn QWebElement parse(QByteArray data, |
4204 | - /// bool & parseOK, |
4205 | - /// QString & parseError, |
4206 | + /// bool * parseOK = 0, |
4207 | + /// QString * parseError = 0, |
4208 | /// int * lineError = 0, |
4209 | /// int * columnError = 0); |
4210 | /// @brief Method for parsing results |
4211 | @@ -46,8 +46,8 @@ |
4212 | /// @param lineError Line of the error. Unused |
4213 | /// @param columnError Column of the error. Unused |
4214 | QWebElement parse(QByteArray data, |
4215 | - bool & parseOK, |
4216 | - QString & parseError, |
4217 | + bool * parseOK = 0, |
4218 | + QString * parseError = 0, |
4219 | int * lineError = 0, |
4220 | int * columnError = 0); |
4221 | }; |
4222 | |
4223 | === modified file 'connection/common/utils/parsers/jsonparser.cpp' |
4224 | --- tools/parsers/jsonparser.cpp 2012-05-19 15:39:56 +0000 |
4225 | +++ connection/common/utils/parsers/jsonparser.cpp 2013-08-20 00:10:09 +0000 |
4226 | @@ -1,12 +1,13 @@ |
4227 | /// @file jsonparser.cpp |
4228 | /// @brief Implementation of JSONParser |
4229 | /// |
4230 | -/// Revisions older than r120 are in the folder /trunk/ReynTweets/connection/parsers. |
4231 | +/// Revisions older than r120 (SVN) are in the folder |
4232 | +/// /trunk/ReynTweets/connection/parsers. |
4233 | /// @author Romain Ducher |
4234 | /// |
4235 | /// @section LICENSE |
4236 | /// |
4237 | -/// Copyright 2011 Romain Ducher |
4238 | +/// Copyright 2011, 2013 Romain Ducher |
4239 | /// |
4240 | /// This file is part of Reyn Tweets. |
4241 | /// |
4242 | @@ -23,26 +24,36 @@ |
4243 | /// You should have received a copy of the GNU Lesser General Public License |
4244 | /// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
4245 | |
4246 | -#include <QJson/Parser> |
4247 | #include "jsonparser.hpp" |
4248 | +#include <QJsonDocument> |
4249 | |
4250 | // Parsing method |
4251 | -QVariantMap JSONParser::parse(QByteArray data, |
4252 | - bool & parseOK, |
4253 | - QString & parseError, |
4254 | - int * lineError, |
4255 | - int *) |
4256 | +QJsonValue JSONParser::parse(QByteArray data, |
4257 | + bool *parseOK, |
4258 | + QString *parseError, |
4259 | + int * lineError, |
4260 | + int *) |
4261 | { |
4262 | - // Parsing with QJson |
4263 | - QJson::Parser parser; |
4264 | - QVariant result = parser.parse(data, &parseOK); |
4265 | - |
4266 | - if (!parseOK) { |
4267 | - parseError = parser.errorString(); |
4268 | - if (lineError) { |
4269 | - *lineError = parser.errorLine(); |
4270 | - } |
4271 | - } |
4272 | - |
4273 | - return result.toMap(); |
4274 | + QJsonParseError jsonParseError; |
4275 | + |
4276 | + // Ensure that datas are encoded with UTF-8 |
4277 | + QString utf8data = QString::fromLatin1(data); |
4278 | + QJsonDocument jsonDoc = QJsonDocument::fromJson(utf8data.toUtf8(), |
4279 | + &jsonParseError); |
4280 | + |
4281 | + if (parseOK) { |
4282 | + *parseOK = jsonParseError.error == QJsonParseError::NoError; |
4283 | + } |
4284 | + |
4285 | + if (parseError) { |
4286 | + *parseError = jsonParseError.errorString(); |
4287 | + } |
4288 | + |
4289 | + if (lineError) { |
4290 | + *lineError = jsonParseError.offset; |
4291 | + } |
4292 | + |
4293 | + QVariant jsonVar = jsonDoc.toVariant(); |
4294 | + |
4295 | + return QJsonValue::fromVariant(jsonVar); |
4296 | } |
4297 | |
4298 | === modified file 'connection/common/utils/parsers/jsonparser.hpp' |
4299 | --- tools/parsers/jsonparser.hpp 2012-05-20 20:29:32 +0000 |
4300 | +++ connection/common/utils/parsers/jsonparser.hpp 2013-08-20 00:10:09 +0000 |
4301 | @@ -1,7 +1,8 @@ |
4302 | /// @file jsonparser.hpp |
4303 | /// @brief Header of JSONParser |
4304 | /// |
4305 | -/// Revisions older than r120 are in the folder /trunk/ReynTweets/connection/parsers. |
4306 | +/// Revisions older than r120 (SVN) are in the folder |
4307 | +/// /trunk/ReynTweets/connection/parsers. |
4308 | /// @author Romain Ducher |
4309 | /// |
4310 | /// @section LICENSE |
4311 | @@ -26,29 +27,28 @@ |
4312 | #ifndef JSONPARSER_HPP |
4313 | #define JSONPARSER_HPP |
4314 | |
4315 | +#include <QJsonValue> |
4316 | #include "genericparser.hpp" |
4317 | |
4318 | /// @class JSONParser |
4319 | /// @brief Parser for JSON datas. |
4320 | -/// |
4321 | -/// It uses the <a href="http://qjson.sourceforge.net">QJSON</a> library to parse. |
4322 | -class JSONParser : public GenericParser<QVariantMap> |
4323 | +class JSONParser : public GenericParser<QJsonValue> |
4324 | { |
4325 | public: |
4326 | - /// @fn QVariantMap parse(QByteArray data, |
4327 | - /// bool & parseOK, |
4328 | - /// QString & parseError, |
4329 | - /// int * lineError = 0, |
4330 | - /// int * columnError = 0); |
4331 | + /// @fn QJsonValue parse(QByteArray data, |
4332 | + /// bool * parseOK = 0, |
4333 | + /// QString * parseError = 0, |
4334 | + /// int * lineError = 0, |
4335 | + /// int * columnError = 0); |
4336 | /// @brief Parsing JSON datas |
4337 | /// @param data Datas to parse |
4338 | /// @param parseOK Boolean indicating if the parcing process was successful |
4339 | /// @param parseError Error message about a parsing error |
4340 | /// @param lineError Line of the error |
4341 | /// @param columnError Column of the error. Unused |
4342 | - QVariantMap parse(QByteArray data, |
4343 | - bool & parseOK, |
4344 | - QString & parseError, |
4345 | + QJsonValue parse(QByteArray data, |
4346 | + bool * parseOK = 0, |
4347 | + QString * parseError = 0, |
4348 | int * lineError = 0, |
4349 | int * columnError = 0); |
4350 | }; |
4351 | |
4352 | === modified file 'connection/common/utils/parsers/oauthparser.cpp' |
4353 | --- tools/parsers/oauthparser.cpp 2012-05-19 15:39:56 +0000 |
4354 | +++ connection/common/utils/parsers/oauthparser.cpp 2013-08-20 00:10:09 +0000 |
4355 | @@ -23,70 +23,28 @@ |
4356 | /// You should have received a copy of the GNU Lesser General Public License |
4357 | /// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
4358 | |
4359 | +#include "oauthparser.hpp" |
4360 | #include <QList> |
4361 | -#include "oauthparser.hpp" |
4362 | +#include <QUrlQuery> |
4363 | |
4364 | // Parsing method |
4365 | QVariantMap OAuthParser::parse(QByteArray data, |
4366 | - bool & parseOK, |
4367 | - QString & parseError, |
4368 | + bool *, QString *, |
4369 | int *, int *) |
4370 | { |
4371 | QVariantMap res; |
4372 | - QString errorMsg = QObject::trUtf8("Following arguments are invalid : "); |
4373 | - parseOK = true; |
4374 | - |
4375 | - // Split the couples of arguments |
4376 | - QList<QByteArray> arguments = data.split('&'); |
4377 | - |
4378 | - foreach (QByteArray argument, arguments) { |
4379 | - QList<QByteArray> couple = argument.split('='); |
4380 | - bool validCouple = couple.length() == 2 || argument.isEmpty(); |
4381 | - |
4382 | - // Ensures that there is a name and a value |
4383 | - parseOK = parseOK && validCouple; |
4384 | - |
4385 | - if (validCouple) { |
4386 | - QString name = QString(couple.at(0)); |
4387 | - QString value = QString(couple.at(1)); |
4388 | - res.insert(name, QVariant(value)); |
4389 | - } else { |
4390 | - errorMsg.append(QObject::trUtf8("OAuth parsing : cannot parse '")); |
4391 | - errorMsg.append(argument); |
4392 | - errorMsg.append("'.\n"); |
4393 | - } |
4394 | - } |
4395 | - |
4396 | - |
4397 | - // Writing parsing errors |
4398 | - parseError = ""; |
4399 | - |
4400 | - if (!parseOK) { |
4401 | - parseError = errorMsg; |
4402 | - } |
4403 | - |
4404 | - return res; |
4405 | -} |
4406 | - |
4407 | -// Extracting one parameter from the parsed result |
4408 | -QVariant OAuthParser::extractParameter(QVariantMap & parsedMap, |
4409 | - QString parameterName, |
4410 | - bool & extractOK, |
4411 | - QString & extractError) |
4412 | -{ |
4413 | - QVariant res; |
4414 | - extractError = ""; |
4415 | - extractOK = parsedMap.contains(parameterName); |
4416 | - |
4417 | - if (extractOK) { |
4418 | - res = parsedMap.value(parameterName); |
4419 | - parsedMap.remove(parameterName); |
4420 | - } else { |
4421 | - extractError.append(QObject::trUtf8("Parameter extraction : parameter '")); |
4422 | - extractError.append(parameterName); |
4423 | - extractError.append(QObject::trUtf8("' expected.")).append('\n'); |
4424 | - } |
4425 | - |
4426 | + |
4427 | + QUrlQuery args(QString::fromLatin1(data)); |
4428 | + |
4429 | + QList<QPair<QString, QString> > listArgs = args.queryItems(); |
4430 | + |
4431 | + for (QList<QPair<QString, QString> >::iterator it = listArgs.begin(); |
4432 | + it != listArgs.end(); |
4433 | + ++it) |
4434 | + { |
4435 | + QPair<QString, QString> couple = *it; |
4436 | + res.insert(couple.first, QVariant::fromValue(couple.second)); |
4437 | + } |
4438 | return res; |
4439 | } |
4440 | |
4441 | @@ -114,18 +72,18 @@ |
4442 | } |
4443 | |
4444 | parsedMap.remove(parameterName); |
4445 | - parsedMap.insert(parameterName, QVariant(booleanValue)); |
4446 | + parsedMap.insert(parameterName, QVariant::fromValue(booleanValue)); |
4447 | } else { |
4448 | // Unexpected value. This is an error. |
4449 | rewriteError.append(QObject::trUtf8("Rewriting as bool : unexpected value '")) |
4450 | .append(result) |
4451 | .append(QObject::trUtf8("' for parameter '")) |
4452 | .append(parameterName) |
4453 | - .append("'.\n"); |
4454 | + .append("'."); |
4455 | } |
4456 | } else { |
4457 | rewriteError.append(QObject::trUtf8("Rewriting as bool : parameter '")) |
4458 | .append(parameterName) |
4459 | - .append(QObject::trUtf8("' expected.")).append('\n'); |
4460 | + .append(QObject::trUtf8("' expected.")); |
4461 | } |
4462 | } |
4463 | |
4464 | === modified file 'connection/common/utils/parsers/oauthparser.hpp' |
4465 | --- tools/parsers/oauthparser.hpp 2012-05-19 15:39:56 +0000 |
4466 | +++ connection/common/utils/parsers/oauthparser.hpp 2013-08-20 00:10:09 +0000 |
4467 | @@ -37,8 +37,8 @@ |
4468 | { |
4469 | public: |
4470 | /// @fn QVariantMap parse(QByteArray data, |
4471 | - /// bool & parseOK, |
4472 | - /// QString & parseError, |
4473 | + /// bool * parseOK = 0, |
4474 | + /// QString * parseError = 0, |
4475 | /// int * lineError = 0, |
4476 | /// int * columnError = 0); |
4477 | /// @brief Parsing datas for OAuth |
4478 | @@ -48,26 +48,11 @@ |
4479 | /// @param lineError Line of the error. Unused. |
4480 | /// @param columnError Column of the error. Unused. |
4481 | QVariantMap parse(QByteArray data, |
4482 | - bool & parseOK, |
4483 | - QString & parseError, |
4484 | + bool * parseOK = 0, |
4485 | + QString * parseError = 0, |
4486 | int * lineError = 0, |
4487 | int * columnError = 0); |
4488 | |
4489 | - /// @fn QVariant extractParameter(QVariantMap & parsedMap, |
4490 | - /// QString parameterName, |
4491 | - /// bool & extractOK, |
4492 | - /// QString & extractError); |
4493 | - /// @brief Extracting one parameter from the parsed result |
4494 | - /// @param parsedMap Parsed result |
4495 | - /// @param parameterName Name of the the parameter to extract |
4496 | - /// @param extractOK Boolean indicating if the extraction was successful |
4497 | - /// @param extractError Error message about an extraction error |
4498 | - /// @return The value of the extracted parameter |
4499 | - QVariant extractParameter(QVariantMap & parsedMap, |
4500 | - QString parameterName, |
4501 | - bool & extractOK, |
4502 | - QString & extractError); |
4503 | - |
4504 | /// @fn void rewriteAsBool(QVariantMap & parsedMap, |
4505 | /// QString parameterName, |
4506 | /// bool & rewriteOK, |
4507 | |
4508 | === modified file 'connection/common/utils/parsers/xmlparser.cpp' |
4509 | --- tools/parsers/xmlparser.cpp 2012-05-23 02:20:16 +0000 |
4510 | +++ connection/common/utils/parsers/xmlparser.cpp 2013-08-20 00:10:09 +0000 |
4511 | @@ -21,17 +21,22 @@ |
4512 | /// You should have received a copy of the GNU Lesser General Public License |
4513 | /// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
4514 | |
4515 | +#include "xmlparser.hpp" |
4516 | #include <QDomDocument> |
4517 | -#include "xmlparser.hpp" |
4518 | |
4519 | // Parsing an XML document |
4520 | QDomElement XMLParser::parse(QByteArray data, |
4521 | - bool &parseOK, |
4522 | - QString &parseError, |
4523 | - int * lineError, |
4524 | - int * columnError) |
4525 | + bool *parseOK, |
4526 | + QString *parseError, |
4527 | + int * lineError, |
4528 | + int * columnError) |
4529 | { |
4530 | QDomDocument res("XMLdoc"); |
4531 | - parseOK = res.setContent(data, &parseError, lineError, columnError); |
4532 | + |
4533 | + bool parseRes = res.setContent(data, parseError, lineError, columnError); |
4534 | + if (parseOK) { |
4535 | + *parseOK = parseRes; |
4536 | + } |
4537 | + |
4538 | return res.documentElement(); |
4539 | } |
4540 | |
4541 | === modified file 'connection/common/utils/parsers/xmlparser.hpp' |
4542 | --- tools/parsers/xmlparser.hpp 2012-05-23 02:20:16 +0000 |
4543 | +++ connection/common/utils/parsers/xmlparser.hpp 2013-08-20 00:10:09 +0000 |
4544 | @@ -33,8 +33,8 @@ |
4545 | { |
4546 | public: |
4547 | /// @fn QDomElement parse(QByteArray data, |
4548 | - /// bool & parseOK, |
4549 | - /// QString & parseError, |
4550 | + /// bool * parseOK = 0, |
4551 | + /// QString * parseError = 0, |
4552 | /// int * lineError = 0, |
4553 | /// int * columnError = 0); |
4554 | /// @brief Method for parsing results |
4555 | @@ -44,8 +44,8 @@ |
4556 | /// @param lineError Line of the error |
4557 | /// @param columnError Column of the error |
4558 | QDomElement parse(QByteArray data, |
4559 | - bool & parseOK, |
4560 | - QString & parseError, |
4561 | + bool * parseOK = 0, |
4562 | + QString * parseError = 0, |
4563 | int * lineError = 0, |
4564 | int * columnError = 0); |
4565 | }; |
4566 | |
4567 | === added file 'connection/libRT.pri' |
4568 | --- connection/libRT.pri 1970-01-01 00:00:00 +0000 |
4569 | +++ connection/libRT.pri 2013-08-20 00:10:09 +0000 |
4570 | @@ -0,0 +1,99 @@ |
4571 | +#--------------------------------------------------------# |
4572 | +# logic.pri # |
4573 | +# .pri sub project file with the connection part (libRT) # |
4574 | +# Author : Romain Ducher # |
4575 | +#--------------------------------------------------------# |
4576 | + |
4577 | +#-----------------------------------------------------------------------------# |
4578 | +# # |
4579 | +# Copyright 2013 Romain Ducher # |
4580 | +# # |
4581 | +# This file is part of Reyn Tweets. # |
4582 | +# # |
4583 | +# Reyn Tweets is free software: you can redistribute it and/or modify # |
4584 | +# it under the terms of the GNU Lesser General Public License as published by # |
4585 | +# the Free Software Foundation, either version 3 of the License, or # |
4586 | +# (at your option) any later version. # |
4587 | +# # |
4588 | +# Reyn Tweets is distributed in the hope that it will be useful, # |
4589 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
4590 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
4591 | +# GNU Lesser General Public License for more details. # |
4592 | +# # |
4593 | +# You should have received a copy of the GNU Lesser General Public License # |
4594 | +# along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. # |
4595 | +# # |
4596 | +#-----------------------------------------------------------------------------# |
4597 | + |
4598 | +#-------------------------------------------------# |
4599 | +# Core sources in libRT (used by all the services # |
4600 | +#-------------------------------------------------# |
4601 | + |
4602 | +SOURCES += \ |
4603 | + connection/common/utils/librtconstants.cpp \ |
4604 | + connection/common/utils/connectionutils.cpp \ |
4605 | + connection/common/utils/parsers/htmlparser.cpp \ |
4606 | + connection/common/utils/parsers/jsonparser.cpp \ |
4607 | + connection/common/utils/parsers/oauthparser.cpp \ |
4608 | + connection/common/utils/parsers/xmlparser.cpp \ |
4609 | + connection/common/networkresult.cpp \ |
4610 | + connection/common/authenticators/apikeyauthenticator.cpp \ |
4611 | + connection/common/authenticators/oauth/oauthutils.cpp \ |
4612 | + connection/common/authenticators/oauth/oauthauthenticator.cpp \ |
4613 | + connection/common/authenticators/oauth/oauth10aauthenticator.cpp \ |
4614 | + connection/common/authenticators/oauth/oauth2authenticator.cpp \ |
4615 | + connection/common/communicators/twittercommunicator.cpp \ |
4616 | + connection/common/resultwrapper.cpp \ |
4617 | + connection/common/requests/genericrequester.cpp \ |
4618 | + connection/common/calls/requestermanager.cpp \ |
4619 | + connection/common/calls/genericcalls.cpp |
4620 | + |
4621 | + |
4622 | +HEADERS += \ |
4623 | + connection/common/utils/httpcode.hpp \ |
4624 | + connection/common/utils/librtconstants.hpp \ |
4625 | + connection/common/utils/connectionutils.hpp \ |
4626 | + connection/common/utils/parsers/genericparser.hpp \ |
4627 | + connection/common/utils/parsers/htmlparser.hpp \ |
4628 | + connection/common/utils/parsers/jsonparser.hpp \ |
4629 | + connection/common/utils/parsers/oauthparser.hpp \ |
4630 | + connection/common/utils/parsers/xmlparser.hpp \ |
4631 | + connection/common/httprequesttype.hpp \ |
4632 | + connection/common/headersmap.hpp \ |
4633 | + connection/common/networkresult.hpp \ |
4634 | + connection/common/responseinfos.hpp \ |
4635 | + connection/common/authenticators/apikeyauthenticator.hpp \ |
4636 | + connection/common/authenticators/basicauthenticators.hpp \ |
4637 | + connection/common/authenticators/oauth/oauthutils.hpp \ |
4638 | + connection/common/authenticators/oauth/oauthauthenticator.hpp \ |
4639 | + connection/common/authenticators/oauth/oauth10aauthenticator.hpp \ |
4640 | + connection/common/authenticators/oauth/oauth2authenticator.hpp \ |
4641 | + connection/common/communicators/twittercommunicator.hpp \ |
4642 | + connection/common/networkresulttype.hpp \ |
4643 | + connection/common/requestresult.hpp \ |
4644 | + connection/common/resultwrapper.hpp \ |
4645 | + connection/common/requests/identificationway.hpp \ |
4646 | + connection/common/requests/genericrequester.hpp \ |
4647 | + connection/common/calls/requestinfos.hpp \ |
4648 | + connection/common/calls/requestermanager.hpp \ |
4649 | + connection/common/calls/genericcalls.hpp |
4650 | + |
4651 | + |
4652 | +#----------------------------------------# |
4653 | +# Third party services included in libRT # |
4654 | +#----------------------------------------# |
4655 | + |
4656 | |
4657 | +include(twitter/twitter.pri) |
4658 | + |
4659 | +# Twitlonger |
4660 | +include(twitlonger/twitlonger.pri) |
4661 | + |
4662 | + |
4663 | +#-------------# |
4664 | +# Other files # |
4665 | +#-------------# |
4666 | + |
4667 | +OTHER_FILES += \ |
4668 | + connection/twitlonger/twitlonger.pri \ |
4669 | + connection/twitter/twitter.pri |
4670 | |
4671 | === removed directory 'connection/model' |
4672 | === removed directory 'connection/model/managers' |
4673 | === removed file 'connection/model/requestinfos.cpp' |
4674 | --- connection/model/requestinfos.cpp 2012-09-12 22:38:35 +0000 |
4675 | +++ connection/model/requestinfos.cpp 1970-01-01 00:00:00 +0000 |
4676 | @@ -1,49 +0,0 @@ |
4677 | -/// @file requestinfos.cpp |
4678 | -/// @brief Implementation of RequestInfos |
4679 | -/// |
4680 | -/// Revisions older than r242 were in /trunk/ReynTweets/connection |
4681 | -/// @author Romain Ducher |
4682 | -/// |
4683 | -/// @section LICENSE |
4684 | -/// |
4685 | -/// Copyright 2012 Romain Ducher |
4686 | -/// |
4687 | -/// This file is part of Reyn Tweets. |
4688 | -/// |
4689 | -/// Reyn Tweets is free software: you can redistribute it and/or modify |
4690 | -/// it under the terms of the GNU Lesser General Public License as published by |
4691 | -/// the Free Software Foundation, either version 3 of the License, or |
4692 | -/// (at your option) any later version. |
4693 | -/// |
4694 | -/// Reyn Tweets is distributed in the hope that it will be useful, |
4695 | -/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
4696 | -/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4697 | -/// GNU Lesser General Public License for more details. |
4698 | -/// |
4699 | -/// You should have received a copy of the GNU Lesser General Public License |
4700 | -/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
4701 | - |
4702 | -#include "requestinfos.hpp" |
4703 | - |
4704 | -// Constructor |
4705 | -RequestInfos::RequestInfos(QObject * requestAsker, |
4706 | - GenericRequester * twitterRequest) : |
4707 | - asker(requestAsker), |
4708 | - requester(twitterRequest) |
4709 | -{} |
4710 | - |
4711 | -// Destructor |
4712 | -RequestInfos::~RequestInfos() { |
4713 | - asker = 0; |
4714 | - requester = 0; |
4715 | -} |
4716 | - |
4717 | -// Getter on asker |
4718 | -QObject * RequestInfos::getAsker() { |
4719 | - return asker; |
4720 | -} |
4721 | - |
4722 | -// Getter on requester |
4723 | -GenericRequester * RequestInfos::getRequester() { |
4724 | - return requester; |
4725 | -} |
4726 | |
4727 | === removed directory 'connection/requests' |
4728 | === removed file 'connection/requests/twitter/oauth/authenticaterequester.cpp' |
4729 | --- connection/requests/twitter/oauth/authenticaterequester.cpp 2012-01-07 01:10:23 +0000 |
4730 | +++ connection/requests/twitter/oauth/authenticaterequester.cpp 1970-01-01 00:00:00 +0000 |
4731 | @@ -1,130 +0,0 @@ |
4732 | -/// @file authenticaterequester.cpp |
4733 | -/// @brief Implementation of AuthenticateRequester |
4734 | -/// @author Romain Ducher |
4735 | - |
4736 | -/* |
4737 | -Copyright 2011 Romain Ducher |
4738 | - |
4739 | -This file is part of Reyn Tweets. |
4740 | - |
4741 | -Reyn Tweets is free software: you can redistribute it and/or modify |
4742 | -it under the terms of the GNU Lesser General Public License as published by |
4743 | -the Free Software Foundation, either version 3 of the License, or |
4744 | -(at your option) any later version. |
4745 | - |
4746 | -Reyn Tweets is distributed in the hope that it will be useful, |
4747 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
4748 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4749 | -GNU Lesser General Public License for more details. |
4750 | - |
4751 | -You should have received a copy of the GNU Lesser General Public License |
4752 | -along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
4753 | -*/ |
4754 | - |
4755 | -#include "authenticaterequester.hpp" |
4756 | - |
4757 | -AuthenticateRequester::AuthenticateRequester(OAuthManager & authManager, |
4758 | - QObject *requester) : |
4759 | - OAuthRequester(authManager, |
4760 | - GET, |
4761 | - TwitterURL::AUTHENTICATE_URL, |
4762 | - requester) |
4763 | -{} |
4764 | - |
4765 | -// Building GET Parameters |
4766 | -void AuthenticateRequester::buildGETParameters() { |
4767 | - getParameters.insert("oauth_token", oauthManager->getOAuthToken()); |
4768 | -} |
4769 | - |
4770 | -// Building POST Parameters |
4771 | -void AuthenticateRequester::buildPOSTParameters() {} |
4772 | - |
4773 | -// Parse the raw results of the request. |
4774 | -QVariant AuthenticateRequester::parseResult(bool & parseOK, QVariantMap & parsingErrors) { |
4775 | - /* |
4776 | - QVariantMap resultMap; // Result of the request |
4777 | - bool rightParameter; // Boolean indicating if the parameter name is right |
4778 | - QString errorMsg = "Error for parameter "; |
4779 | - QString subErrorMsg; |
4780 | - |
4781 | - // Parsing |
4782 | - QByteArray rawResponse = communicator->getResponseBuffer(); |
4783 | - QList<QByteArray> results = rawResponse.split('&'); |
4784 | - |
4785 | - QList<QByteArray> resultPair; |
4786 | - QByteArray parameterName; |
4787 | - QByteArray result; |
4788 | - |
4789 | - // Getting the request token |
4790 | - resultPair = results.at(0).split('='); |
4791 | - |
4792 | - // Ensures that the parameter name is "oauth_token" |
4793 | - parameterName = resultPair.at(0); |
4794 | - rightParameter = "oauth_token" == parameterName; |
4795 | - parseOK = rightParameter; |
4796 | - |
4797 | - if (rightParameter) { |
4798 | - result = resultPair.at(1); |
4799 | - oauthManager->setOAuthToken(QString(result)); |
4800 | - } else { |
4801 | - subErrorMsg = "'"; |
4802 | - subErrorMsg.append(parameterName); |
4803 | - subErrorMsg.append("' (supposed to be 'oauth_token'), "); |
4804 | - errorMsg.append(subErrorMsg); |
4805 | - } |
4806 | - |
4807 | - // Getting the request secret |
4808 | - resultPair = results.at(1).split('='); |
4809 | - |
4810 | - // Ensures that the parameter name is "oauth_token_secret" |
4811 | - parameterName = resultPair.at(0); |
4812 | - rightParameter = "oauth_token_secret" == parameterName; |
4813 | - parseOK = parseOK && rightParameter; |
4814 | - |
4815 | - if (rightParameter) { |
4816 | - result = resultPair.at(1); |
4817 | - oauthManager->setOAuthSecret(QString(result)); |
4818 | - } else { |
4819 | - subErrorMsg = "parameter '"; |
4820 | - subErrorMsg.append(parameterName); |
4821 | - subErrorMsg.append("' (supposed to be 'oauth_token_secret'), "); |
4822 | - errorMsg.append(subErrorMsg); |
4823 | - } |
4824 | - |
4825 | - |
4826 | - // Was the callback URL confirmed ? |
4827 | - resultPair = results.at(2).split('='); |
4828 | - |
4829 | - // Ensures that the parameter name is "oauth_callback_confirmed" |
4830 | - parameterName = resultPair.at(0); |
4831 | - rightParameter = "oauth_callback_confirmed" == parameterName; |
4832 | - parseOK = parseOK && rightParameter; |
4833 | - |
4834 | - if (rightParameter) { |
4835 | - result = resultPair.at(1); |
4836 | - bool callbackUrlConfirmed = ("true" == result) || !("false" == result); |
4837 | - resultMap.insert("oauth_callback_confirmed", QVariant(callbackUrlConfirmed)); |
4838 | - } else { |
4839 | - subErrorMsg = "parameter '"; |
4840 | - subErrorMsg.append(parameterName); |
4841 | - subErrorMsg.append("' (supposed to be 'oauth_callback_confirmed')"); |
4842 | - errorMsg.append(subErrorMsg); |
4843 | - } |
4844 | - |
4845 | - |
4846 | - // There was a problem while parsing -> fill the parsingErrors map ! |
4847 | - if (!parseOK) { |
4848 | - if (errorMsg.endsWith(", ")) { |
4849 | - errorMsg.chop(2); |
4850 | - errorMsg.append('.'); |
4851 | - } |
4852 | - |
4853 | - parsingErrors.insert("errorMsg", QVariant(errorMsg)); |
4854 | - } |
4855 | - |
4856 | - return QVariant(resultMap); |
4857 | - //*/ |
4858 | - |
4859 | - return QVariant(); |
4860 | -} |
4861 | - |
4862 | |
4863 | === removed file 'connection/requests/twitter/oauth/authenticaterequester.hpp' |
4864 | --- connection/requests/twitter/oauth/authenticaterequester.hpp 2012-01-07 01:32:25 +0000 |
4865 | +++ connection/requests/twitter/oauth/authenticaterequester.hpp 1970-01-01 00:00:00 +0000 |
4866 | @@ -1,66 +0,0 @@ |
4867 | -/// @file authenticaterequester.hpp |
4868 | -/// @brief Header of AuthenticateRequester |
4869 | -/// @author Romain Ducher |
4870 | - |
4871 | -/* |
4872 | -Copyright 2011 Romain Ducher |
4873 | - |
4874 | -This file is part of Reyn Tweets. |
4875 | - |
4876 | -Reyn Tweets is free software: you can redistribute it and/or modify |
4877 | -it under the terms of the GNU Lesser General Public License as published by |
4878 | -the Free Software Foundation, either version 3 of the License, or |
4879 | -(at your option) any later version. |
4880 | - |
4881 | -Reyn Tweets is distributed in the hope that it will be useful, |
4882 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
4883 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4884 | -GNU Lesser General Public License for more details. |
4885 | - |
4886 | -You should have received a copy of the GNU Lesser General Public License |
4887 | -along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
4888 | -*/ |
4889 | - |
4890 | -#ifndef AUTHENTICATEREQUESTER_HPP |
4891 | -#define AUTHENTICATEREQUESTER_HPP |
4892 | - |
4893 | -#include "oauthrequester.hpp" |
4894 | - |
4895 | -/// @class AuthenticateRequester |
4896 | -/// @brief Requester for OAuth authentication. |
4897 | -/// <strong>Unused for the moment.</strong> |
4898 | -class AuthenticateRequester : public OAuthRequester |
4899 | -{ |
4900 | - Q_OBJECT |
4901 | - |
4902 | - public: |
4903 | - /// @fn AuthenticateRequester(OAuthManager & authManager, |
4904 | - /// QObject * requester = 0); |
4905 | - /// @brief Constructor |
4906 | - /// @param authManager Information for OAuth. It has to be not null |
4907 | - /// @param requester QObject which asks for this search. |
4908 | - AuthenticateRequester(OAuthManager & authManager, |
4909 | - QObject * requester = 0); |
4910 | - |
4911 | - protected: |
4912 | - /// @fn void buildGETParameters(); |
4913 | - /// @brief Method building GET Parameters |
4914 | - void buildGETParameters(); |
4915 | - |
4916 | - /// @fn void buildPOSTParameters(); |
4917 | - /// @brief Method building POST Parameters |
4918 | - void buildPOSTParameters(); |
4919 | - |
4920 | - // TODO |
4921 | - /// @fn QVariant parseResult(bool & parseOK, QVariantMap & parsingErrors); |
4922 | - /// @brief Method that will parse the raw results of the request. |
4923 | - /// @param parseOK Boolean whose value will be set to true if there was |
4924 | - /// no problem while parsing, false otherwise. |
4925 | - /// @param parsingErrors QVariantMap that may contain information about |
4926 | - /// errors that may occur while parsing. |
4927 | - /// @return Parsed results |
4928 | - QVariant parseResult(bool & parseOK, QVariantMap & parsingErrors); |
4929 | - |
4930 | -}; |
4931 | - |
4932 | -#endif // AUTHENTICATEREQUESTER_HPP |
4933 | |
4934 | === removed file 'connection/requests/twitter/oauth/postauthorizerequester.cpp' |
4935 | --- connection/requests/twitter/oauth/postauthorizerequester.cpp 2012-09-12 22:38:35 +0000 |
4936 | +++ connection/requests/twitter/oauth/postauthorizerequester.cpp 1970-01-01 00:00:00 +0000 |
4937 | @@ -1,228 +0,0 @@ |
4938 | -/// @file postauthorizerequester.cpp |
4939 | -/// @brief Implementation of PostAuthorizeRequester |
4940 | -/// @author Romain Ducher |
4941 | -/// |
4942 | -/// @section LICENSE |
4943 | -/// |
4944 | -/// Copyright 2011 Romain Ducher |
4945 | -/// |
4946 | -/// This file is part of Reyn Tweets. |
4947 | -/// |
4948 | -/// Reyn Tweets is free software: you can redistribute it and/or modify |
4949 | -/// it under the terms of the GNU Lesser General Public License as published by |
4950 | -/// the Free Software Foundation, either version 3 of the License, or |
4951 | -/// (at your option) any later version. |
4952 | -/// |
4953 | -/// Reyn Tweets is distributed in the hope that it will be useful, |
4954 | -/// but WITHOUT ANY WARRANTY; without even the implied warranty of |
4955 | -/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4956 | -/// GNU Lesser General Public License for more details. |
4957 | -/// |
4958 | -/// You should have received a copy of the GNU Lesser General Public License |
4959 | -/// along with Reyn Tweets. If not, see <http://www.gnu.org/licenses/>. |
4960 | - |
4961 | -#include "postauthorizerequester.hpp" |
4962 | -#include "../../../../tools/parsers/htmlparser.hpp" |
4963 | -#include "../../../../tools/parsers/oauthparser.hpp" |
4964 | - |
4965 | -// Constructor |
4966 | -PostAuthorizeRequester::PostAuthorizeRequester(OAuthManager &authManager, |
4967 | - QString pseudo, |
4968 | - QString pwd, |
4969 | - bool deny) : |
4970 | - OAuthRequester(POST, |
4971 | - TwitterURL::AUTHORIZE_URL, |
4972 | - authManager, |
4973 | - HTML_PARSING), |
4974 | - login(pseudo), |
4975 | - password(pwd), |
4976 | - denyReynTweets(deny) |
4977 | -{} |
4978 | - |
4979 | -// Building postParameters |
4980 | -void PostAuthorizeRequester::buildPOSTParameters() { |
4981 | - postParameters.insert("authenticity_token", |
4982 | - QString::fromAscii(oauthManager.getAuthenticityToken().data())); |
4983 | - getParameters.insert("oauth_token", |
4984 | - QString::fromAscii(oauthManager.getOAuthToken().data())); |
4985 | - |
4986 | - postParameters.insert("session[username_or_email]", login); |
4987 | - postParameters.insert("session[password]", password); |
4988 | - |
4989 | - if (denyReynTweets) { |
4990 | - postParameters.insert("deny", oauthManager.getDeny()); |
4991 | - } |
4992 | -} |
4993 | - |
4994 | -// Parsing the raw results of the request. |
4995 | -QVariant PostAuthorizeRequester::parseResult(bool & parseOK, |
4996 | - QVariantMap & parsingErrors) |
4997 | -{ |
4998 | - QVariantMap parsedResults; // Map for results |
4999 | - QString errorMsg = ""; // Error message written while parsing |
5000 | - |
The diff has been truncated for viewing.
Merge OK