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