From 4fafb4c7c32183baf93c42da59c9f09578273d07 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 11 Feb 2011 15:36:44 -0500 Subject: [PATCH 01/62] Import QTweetLib and add CMakeLists and export files. --- thirdparty/CMakeLists.txt | 1 + thirdparty/QTweetLib/CMakeLists.txt | 177 +++ thirdparty/QTweetLib/LICENSE | 459 +++++++ thirdparty/QTweetLib/QTweetLib.pro | 10 + thirdparty/QTweetLib/README | 12 + thirdparty/QTweetLib/examples/examples.pro | 3 + .../examples/followers/FollowerDelegate.qml | 56 + .../examples/followers/FollowersList.qml | 19 + .../examples/followers/followers.cpp | 67 + .../QTweetLib/examples/followers/followers.h | 53 + .../examples/followers/followers.pro | 25 + .../examples/followers/followers.qrc | 6 + .../QTweetLib/examples/followers/followers.ui | 42 + .../examples/followers/followerslistmodel.cpp | 113 ++ .../examples/followers/followerslistmodel.h | 56 + .../QTweetLib/examples/followers/main.cpp | 32 + .../examples/georeverse/georeverse.cpp | 106 ++ .../examples/georeverse/georeverse.h | 54 + .../examples/georeverse/georeverse.pro | 18 + .../examples/georeverse/georeverse.ui | 51 + .../QTweetLib/examples/georeverse/main.cpp | 32 + .../examples/geosearch/geosearch.cpp | 102 ++ .../QTweetLib/examples/geosearch/geosearch.h | 53 + .../examples/geosearch/geosearch.pro | 18 + .../QTweetLib/examples/geosearch/geosearch.ui | 55 + .../QTweetLib/examples/geosearch/main.cpp | 32 + thirdparty/QTweetLib/examples/search/main.cpp | 31 + .../QTweetLib/examples/search/mainwindow.cpp | 100 ++ .../QTweetLib/examples/search/mainwindow.h | 53 + .../QTweetLib/examples/search/mainwindow.ui | 64 + .../QTweetLib/examples/search/search.pro | 17 + .../QTweetLib/examples/statusupdate/main.cpp | 32 + .../examples/statusupdate/mainwindow.cpp | 117 ++ .../examples/statusupdate/mainwindow.h | 57 + .../examples/statusupdate/mainwindow.ui | 206 +++ .../examples/statusupdate/statusupdate.pro | 16 + .../QTweetLib/examples/timelines/main.cpp | 32 + .../examples/timelines/mainwindow.cpp | 224 ++++ .../QTweetLib/examples/timelines/mainwindow.h | 67 + .../examples/timelines/mainwindow.ui | 156 +++ .../examples/timelines/timelines.pro | 16 + .../QTweetLib/examples/userstream/main.cpp | 32 + .../examples/userstream/userstream.cpp | 110 ++ .../examples/userstream/userstream.h | 62 + .../examples/userstream/userstream.pro | 17 + .../examples/userstream/userstream.ui | 63 + thirdparty/QTweetLib/qjson/json_parser.cc | 1116 +++++++++++++++++ thirdparty/QTweetLib/qjson/json_parser.hh | 325 +++++ thirdparty/QTweetLib/qjson/json_parser.yy | 219 ++++ thirdparty/QTweetLib/qjson/json_scanner.cpp | 377 ++++++ thirdparty/QTweetLib/qjson/json_scanner.h | 54 + thirdparty/QTweetLib/qjson/location.hh | 145 +++ thirdparty/QTweetLib/qjson/parser.cpp | 124 ++ thirdparty/QTweetLib/qjson/parser.h | 94 ++ thirdparty/QTweetLib/qjson/parser_p.h | 56 + thirdparty/QTweetLib/qjson/parserrunnable.cpp | 68 + thirdparty/QTweetLib/qjson/parserrunnable.h | 67 + thirdparty/QTweetLib/qjson/position.hh | 142 +++ thirdparty/QTweetLib/qjson/qjson.pro | 34 + thirdparty/QTweetLib/qjson/qjson_debug.h | 33 + thirdparty/QTweetLib/qjson/qjson_export.h | 35 + thirdparty/QTweetLib/qjson/qobjecthelper.cpp | 84 ++ thirdparty/QTweetLib/qjson/qobjecthelper.h | 143 +++ thirdparty/QTweetLib/qjson/serializer.cpp | 220 ++++ thirdparty/QTweetLib/qjson/serializer.h | 81 ++ .../QTweetLib/qjson/serializerrunnable.cpp | 60 + .../QTweetLib/qjson/serializerrunnable.h | 74 ++ thirdparty/QTweetLib/qjson/src.pro | 70 ++ thirdparty/QTweetLib/qjson/stack.hh | 129 ++ thirdparty/QTweetLib/qtweetlib_export.h | 18 + thirdparty/QTweetLib/src/oauth.cpp | 340 +++++ thirdparty/QTweetLib/src/oauth.h | 64 + thirdparty/QTweetLib/src/oauthtwitter.cpp | 216 ++++ thirdparty/QTweetLib/src/oauthtwitter.h | 65 + .../src/qtweetaccountratelimitstatus.cpp | 78 ++ .../src/qtweetaccountratelimitstatus.h | 50 + .../src/qtweetaccountverifycredentials.cpp | 82 ++ .../src/qtweetaccountverifycredentials.h | 47 + thirdparty/QTweetLib/src/qtweetconvert.cpp | 521 ++++++++ thirdparty/QTweetLib/src/qtweetconvert.h | 63 + .../src/qtweetdirectmessagedestroy.cpp | 83 ++ .../src/qtweetdirectmessagedestroy.h | 46 + .../QTweetLib/src/qtweetdirectmessagenew.cpp | 129 ++ .../QTweetLib/src/qtweetdirectmessagenew.h | 50 + .../QTweetLib/src/qtweetdirectmessages.cpp | 103 ++ .../QTweetLib/src/qtweetdirectmessages.h | 51 + .../src/qtweetdirectmessagessent.cpp | 104 ++ .../QTweetLib/src/qtweetdirectmessagessent.h | 49 + thirdparty/QTweetLib/src/qtweetdmstatus.cpp | 154 +++ thirdparty/QTweetLib/src/qtweetdmstatus.h | 68 + .../QTweetLib/src/qtweetentityhashtag.cpp | 57 + .../QTweetLib/src/qtweetentityhashtag.h | 43 + thirdparty/QTweetLib/src/qtweetentityurl.cpp | 82 ++ thirdparty/QTweetLib/src/qtweetentityurl.h | 47 + .../src/qtweetentityusermentions.cpp | 81 ++ .../QTweetLib/src/qtweetentityusermentions.h | 47 + thirdparty/QTweetLib/src/qtweetfavorites.cpp | 93 ++ thirdparty/QTweetLib/src/qtweetfavorites.h | 48 + .../QTweetLib/src/qtweetfavoritescreate.cpp | 83 ++ .../QTweetLib/src/qtweetfavoritescreate.h | 46 + .../QTweetLib/src/qtweetfavoritesdestroy.cpp | 84 ++ .../QTweetLib/src/qtweetfavoritesdestroy.h | 46 + .../QTweetLib/src/qtweetfollowersid.cpp | 111 ++ thirdparty/QTweetLib/src/qtweetfollowersid.h | 54 + .../QTweetLib/src/qtweetfriendshipcreate.cpp | 135 ++ .../QTweetLib/src/qtweetfriendshipcreate.h | 50 + .../QTweetLib/src/qtweetfriendshipdestroy.cpp | 113 ++ .../QTweetLib/src/qtweetfriendshipdestroy.h | 48 + thirdparty/QTweetLib/src/qtweetfriendsid.cpp | 111 ++ thirdparty/QTweetLib/src/qtweetfriendsid.h | 54 + .../QTweetLib/src/qtweetfriendstimeline.cpp | 113 ++ .../QTweetLib/src/qtweetfriendstimeline.h | 53 + .../QTweetLib/src/qtweetgeoboundingbox.cpp | 42 + .../QTweetLib/src/qtweetgeoboundingbox.h | 56 + thirdparty/QTweetLib/src/qtweetgeocoord.cpp | 57 + thirdparty/QTweetLib/src/qtweetgeocoord.h | 48 + .../QTweetLib/src/qtweetgeoplacecreate.cpp | 96 ++ .../QTweetLib/src/qtweetgeoplacecreate.h | 52 + thirdparty/QTweetLib/src/qtweetgeoplaceid.cpp | 76 ++ thirdparty/QTweetLib/src/qtweetgeoplaceid.h | 47 + .../QTweetLib/src/qtweetgeoreversegeocode.cpp | 110 ++ .../QTweetLib/src/qtweetgeoreversegeocode.h | 51 + thirdparty/QTweetLib/src/qtweetgeosearch.cpp | 129 ++ thirdparty/QTweetLib/src/qtweetgeosearch.h | 55 + .../QTweetLib/src/qtweetgeosimilarplaces.cpp | 92 ++ .../QTweetLib/src/qtweetgeosimilarplaces.h | 55 + .../QTweetLib/src/qtweethometimeline.cpp | 109 ++ thirdparty/QTweetLib/src/qtweethometimeline.h | 50 + thirdparty/QTweetLib/src/qtweetlib_global.h | 36 + thirdparty/QTweetLib/src/qtweetlist.cpp | 170 +++ thirdparty/QTweetLib/src/qtweetlist.h | 71 ++ .../QTweetLib/src/qtweetlistaddmember.cpp | 74 ++ .../QTweetLib/src/qtweetlistaddmember.h | 49 + thirdparty/QTweetLib/src/qtweetlistcreate.cpp | 91 ++ thirdparty/QTweetLib/src/qtweetlistcreate.h | 48 + .../QTweetLib/src/qtweetlistdeletelist.cpp | 73 ++ .../QTweetLib/src/qtweetlistdeletelist.h | 45 + .../QTweetLib/src/qtweetlistdeletemember.cpp | 74 ++ .../QTweetLib/src/qtweetlistdeletemember.h | 48 + .../QTweetLib/src/qtweetlistgetlists.cpp | 83 ++ thirdparty/QTweetLib/src/qtweetlistgetlists.h | 53 + .../QTweetLib/src/qtweetlistgetmembers.cpp | 93 ++ .../QTweetLib/src/qtweetlistgetmembers.h | 54 + .../QTweetLib/src/qtweetlistmemberships.cpp | 84 ++ .../QTweetLib/src/qtweetlistmemberships.h | 52 + .../QTweetLib/src/qtweetlistshowlist.cpp | 74 ++ thirdparty/QTweetLib/src/qtweetlistshowlist.h | 46 + .../QTweetLib/src/qtweetliststatuses.cpp | 95 ++ thirdparty/QTweetLib/src/qtweetliststatuses.h | 51 + .../QTweetLib/src/qtweetlistsubscribe.cpp | 72 ++ .../QTweetLib/src/qtweetlistsubscribe.h | 46 + .../QTweetLib/src/qtweetlistsubscribers.cpp | 91 ++ .../QTweetLib/src/qtweetlistsubscribers.h | 54 + .../QTweetLib/src/qtweetlistsubscriptions.cpp | 84 ++ .../QTweetLib/src/qtweetlistsubscriptions.h | 52 + .../QTweetLib/src/qtweetlistunsubscribe.cpp | 72 ++ .../QTweetLib/src/qtweetlistunsubscribe.h | 46 + thirdparty/QTweetLib/src/qtweetlistupdate.cpp | 92 ++ thirdparty/QTweetLib/src/qtweetlistupdate.h | 48 + thirdparty/QTweetLib/src/qtweetmentions.cpp | 105 ++ thirdparty/QTweetLib/src/qtweetmentions.h | 51 + thirdparty/QTweetLib/src/qtweetnetbase.cpp | 207 +++ thirdparty/QTweetLib/src/qtweetnetbase.h | 110 ++ thirdparty/QTweetLib/src/qtweetplace.cpp | 105 ++ thirdparty/QTweetLib/src/qtweetplace.h | 71 ++ .../QTweetLib/src/qtweetretweetbyme.cpp | 99 ++ thirdparty/QTweetLib/src/qtweetretweetbyme.h | 50 + .../QTweetLib/src/qtweetretweetsofme.cpp | 98 ++ thirdparty/QTweetLib/src/qtweetretweetsofme.h | 51 + .../QTweetLib/src/qtweetretweettome.cpp | 99 ++ thirdparty/QTweetLib/src/qtweetretweettome.h | 50 + thirdparty/QTweetLib/src/qtweetsearch.cpp | 111 ++ thirdparty/QTweetLib/src/qtweetsearch.h | 54 + .../QTweetLib/src/qtweetsearchpageresults.cpp | 146 +++ .../QTweetLib/src/qtweetsearchpageresults.h | 68 + .../QTweetLib/src/qtweetsearchresult.cpp | 160 +++ thirdparty/QTweetLib/src/qtweetsearchresult.h | 63 + thirdparty/QTweetLib/src/qtweetstatus.cpp | 259 ++++ thirdparty/QTweetLib/src/qtweetstatus.h | 85 ++ .../QTweetLib/src/qtweetstatusdestroy.cpp | 89 ++ .../QTweetLib/src/qtweetstatusdestroy.h | 47 + .../QTweetLib/src/qtweetstatusretweet.cpp | 79 ++ .../QTweetLib/src/qtweetstatusretweet.h | 47 + .../QTweetLib/src/qtweetstatusretweets.cpp | 64 + .../QTweetLib/src/qtweetstatusretweets.h | 40 + thirdparty/QTweetLib/src/qtweetstatusshow.cpp | 78 ++ thirdparty/QTweetLib/src/qtweetstatusshow.h | 47 + .../QTweetLib/src/qtweetstatusupdate.cpp | 112 ++ thirdparty/QTweetLib/src/qtweetstatusupdate.h | 52 + thirdparty/QTweetLib/src/qtweetuser.cpp | 355 ++++++ thirdparty/QTweetLib/src/qtweetuser.h | 94 ++ thirdparty/QTweetLib/src/qtweetuserlookup.cpp | 97 ++ thirdparty/QTweetLib/src/qtweetuserlookup.h | 49 + thirdparty/QTweetLib/src/qtweetusersearch.cpp | 89 ++ thirdparty/QTweetLib/src/qtweetusersearch.h | 48 + thirdparty/QTweetLib/src/qtweetusershow.cpp | 99 ++ thirdparty/QTweetLib/src/qtweetusershow.h | 48 + .../src/qtweetuserstatusesfollowers.cpp | 128 ++ .../src/qtweetuserstatusesfollowers.h | 62 + .../src/qtweetuserstatusesfriends.cpp | 131 ++ .../QTweetLib/src/qtweetuserstatusesfriends.h | 62 + thirdparty/QTweetLib/src/qtweetuserstream.cpp | 238 ++++ thirdparty/QTweetLib/src/qtweetuserstream.h | 93 ++ .../QTweetLib/src/qtweetusertimeline.cpp | 111 ++ thirdparty/QTweetLib/src/qtweetusertimeline.h | 55 + thirdparty/QTweetLib/src/src.pro | 153 +++ 206 files changed, 18709 insertions(+) create mode 100644 thirdparty/QTweetLib/CMakeLists.txt create mode 100644 thirdparty/QTweetLib/LICENSE create mode 100644 thirdparty/QTweetLib/QTweetLib.pro create mode 100644 thirdparty/QTweetLib/README create mode 100644 thirdparty/QTweetLib/examples/examples.pro create mode 100644 thirdparty/QTweetLib/examples/followers/FollowerDelegate.qml create mode 100644 thirdparty/QTweetLib/examples/followers/FollowersList.qml create mode 100644 thirdparty/QTweetLib/examples/followers/followers.cpp create mode 100644 thirdparty/QTweetLib/examples/followers/followers.h create mode 100644 thirdparty/QTweetLib/examples/followers/followers.pro create mode 100644 thirdparty/QTweetLib/examples/followers/followers.qrc create mode 100644 thirdparty/QTweetLib/examples/followers/followers.ui create mode 100644 thirdparty/QTweetLib/examples/followers/followerslistmodel.cpp create mode 100644 thirdparty/QTweetLib/examples/followers/followerslistmodel.h create mode 100644 thirdparty/QTweetLib/examples/followers/main.cpp create mode 100644 thirdparty/QTweetLib/examples/georeverse/georeverse.cpp create mode 100644 thirdparty/QTweetLib/examples/georeverse/georeverse.h create mode 100644 thirdparty/QTweetLib/examples/georeverse/georeverse.pro create mode 100644 thirdparty/QTweetLib/examples/georeverse/georeverse.ui create mode 100644 thirdparty/QTweetLib/examples/georeverse/main.cpp create mode 100644 thirdparty/QTweetLib/examples/geosearch/geosearch.cpp create mode 100644 thirdparty/QTweetLib/examples/geosearch/geosearch.h create mode 100644 thirdparty/QTweetLib/examples/geosearch/geosearch.pro create mode 100644 thirdparty/QTweetLib/examples/geosearch/geosearch.ui create mode 100644 thirdparty/QTweetLib/examples/geosearch/main.cpp create mode 100644 thirdparty/QTweetLib/examples/search/main.cpp create mode 100644 thirdparty/QTweetLib/examples/search/mainwindow.cpp create mode 100644 thirdparty/QTweetLib/examples/search/mainwindow.h create mode 100644 thirdparty/QTweetLib/examples/search/mainwindow.ui create mode 100644 thirdparty/QTweetLib/examples/search/search.pro create mode 100644 thirdparty/QTweetLib/examples/statusupdate/main.cpp create mode 100644 thirdparty/QTweetLib/examples/statusupdate/mainwindow.cpp create mode 100644 thirdparty/QTweetLib/examples/statusupdate/mainwindow.h create mode 100644 thirdparty/QTweetLib/examples/statusupdate/mainwindow.ui create mode 100644 thirdparty/QTweetLib/examples/statusupdate/statusupdate.pro create mode 100644 thirdparty/QTweetLib/examples/timelines/main.cpp create mode 100644 thirdparty/QTweetLib/examples/timelines/mainwindow.cpp create mode 100644 thirdparty/QTweetLib/examples/timelines/mainwindow.h create mode 100644 thirdparty/QTweetLib/examples/timelines/mainwindow.ui create mode 100644 thirdparty/QTweetLib/examples/timelines/timelines.pro create mode 100644 thirdparty/QTweetLib/examples/userstream/main.cpp create mode 100644 thirdparty/QTweetLib/examples/userstream/userstream.cpp create mode 100644 thirdparty/QTweetLib/examples/userstream/userstream.h create mode 100644 thirdparty/QTweetLib/examples/userstream/userstream.pro create mode 100644 thirdparty/QTweetLib/examples/userstream/userstream.ui create mode 100644 thirdparty/QTweetLib/qjson/json_parser.cc create mode 100644 thirdparty/QTweetLib/qjson/json_parser.hh create mode 100644 thirdparty/QTweetLib/qjson/json_parser.yy create mode 100644 thirdparty/QTweetLib/qjson/json_scanner.cpp create mode 100644 thirdparty/QTweetLib/qjson/json_scanner.h create mode 100644 thirdparty/QTweetLib/qjson/location.hh create mode 100644 thirdparty/QTweetLib/qjson/parser.cpp create mode 100644 thirdparty/QTweetLib/qjson/parser.h create mode 100644 thirdparty/QTweetLib/qjson/parser_p.h create mode 100644 thirdparty/QTweetLib/qjson/parserrunnable.cpp create mode 100644 thirdparty/QTweetLib/qjson/parserrunnable.h create mode 100644 thirdparty/QTweetLib/qjson/position.hh create mode 100644 thirdparty/QTweetLib/qjson/qjson.pro create mode 100644 thirdparty/QTweetLib/qjson/qjson_debug.h create mode 100644 thirdparty/QTweetLib/qjson/qjson_export.h create mode 100644 thirdparty/QTweetLib/qjson/qobjecthelper.cpp create mode 100644 thirdparty/QTweetLib/qjson/qobjecthelper.h create mode 100644 thirdparty/QTweetLib/qjson/serializer.cpp create mode 100644 thirdparty/QTweetLib/qjson/serializer.h create mode 100644 thirdparty/QTweetLib/qjson/serializerrunnable.cpp create mode 100644 thirdparty/QTweetLib/qjson/serializerrunnable.h create mode 100644 thirdparty/QTweetLib/qjson/src.pro create mode 100644 thirdparty/QTweetLib/qjson/stack.hh create mode 100644 thirdparty/QTweetLib/qtweetlib_export.h create mode 100644 thirdparty/QTweetLib/src/oauth.cpp create mode 100644 thirdparty/QTweetLib/src/oauth.h create mode 100644 thirdparty/QTweetLib/src/oauthtwitter.cpp create mode 100644 thirdparty/QTweetLib/src/oauthtwitter.h create mode 100644 thirdparty/QTweetLib/src/qtweetaccountratelimitstatus.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetaccountratelimitstatus.h create mode 100644 thirdparty/QTweetLib/src/qtweetaccountverifycredentials.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetaccountverifycredentials.h create mode 100644 thirdparty/QTweetLib/src/qtweetconvert.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetconvert.h create mode 100644 thirdparty/QTweetLib/src/qtweetdirectmessagedestroy.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetdirectmessagedestroy.h create mode 100644 thirdparty/QTweetLib/src/qtweetdirectmessagenew.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetdirectmessagenew.h create mode 100644 thirdparty/QTweetLib/src/qtweetdirectmessages.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetdirectmessages.h create mode 100644 thirdparty/QTweetLib/src/qtweetdirectmessagessent.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetdirectmessagessent.h create mode 100644 thirdparty/QTweetLib/src/qtweetdmstatus.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetdmstatus.h create mode 100644 thirdparty/QTweetLib/src/qtweetentityhashtag.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetentityhashtag.h create mode 100644 thirdparty/QTweetLib/src/qtweetentityurl.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetentityurl.h create mode 100644 thirdparty/QTweetLib/src/qtweetentityusermentions.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetentityusermentions.h create mode 100644 thirdparty/QTweetLib/src/qtweetfavorites.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetfavorites.h create mode 100644 thirdparty/QTweetLib/src/qtweetfavoritescreate.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetfavoritescreate.h create mode 100644 thirdparty/QTweetLib/src/qtweetfavoritesdestroy.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetfavoritesdestroy.h create mode 100644 thirdparty/QTweetLib/src/qtweetfollowersid.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetfollowersid.h create mode 100644 thirdparty/QTweetLib/src/qtweetfriendshipcreate.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetfriendshipcreate.h create mode 100644 thirdparty/QTweetLib/src/qtweetfriendshipdestroy.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetfriendshipdestroy.h create mode 100644 thirdparty/QTweetLib/src/qtweetfriendsid.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetfriendsid.h create mode 100644 thirdparty/QTweetLib/src/qtweetfriendstimeline.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetfriendstimeline.h create mode 100644 thirdparty/QTweetLib/src/qtweetgeoboundingbox.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetgeoboundingbox.h create mode 100644 thirdparty/QTweetLib/src/qtweetgeocoord.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetgeocoord.h create mode 100644 thirdparty/QTweetLib/src/qtweetgeoplacecreate.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetgeoplacecreate.h create mode 100644 thirdparty/QTweetLib/src/qtweetgeoplaceid.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetgeoplaceid.h create mode 100644 thirdparty/QTweetLib/src/qtweetgeoreversegeocode.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetgeoreversegeocode.h create mode 100644 thirdparty/QTweetLib/src/qtweetgeosearch.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetgeosearch.h create mode 100644 thirdparty/QTweetLib/src/qtweetgeosimilarplaces.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetgeosimilarplaces.h create mode 100644 thirdparty/QTweetLib/src/qtweethometimeline.cpp create mode 100644 thirdparty/QTweetLib/src/qtweethometimeline.h create mode 100644 thirdparty/QTweetLib/src/qtweetlib_global.h create mode 100644 thirdparty/QTweetLib/src/qtweetlist.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlist.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistaddmember.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistaddmember.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistcreate.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistcreate.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistdeletelist.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistdeletelist.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistdeletemember.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistdeletemember.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistgetlists.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistgetlists.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistgetmembers.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistgetmembers.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistmemberships.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistmemberships.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistshowlist.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistshowlist.h create mode 100644 thirdparty/QTweetLib/src/qtweetliststatuses.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetliststatuses.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistsubscribe.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistsubscribe.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistsubscribers.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistsubscribers.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistsubscriptions.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistsubscriptions.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistunsubscribe.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistunsubscribe.h create mode 100644 thirdparty/QTweetLib/src/qtweetlistupdate.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetlistupdate.h create mode 100644 thirdparty/QTweetLib/src/qtweetmentions.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetmentions.h create mode 100644 thirdparty/QTweetLib/src/qtweetnetbase.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetnetbase.h create mode 100644 thirdparty/QTweetLib/src/qtweetplace.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetplace.h create mode 100644 thirdparty/QTweetLib/src/qtweetretweetbyme.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetretweetbyme.h create mode 100644 thirdparty/QTweetLib/src/qtweetretweetsofme.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetretweetsofme.h create mode 100644 thirdparty/QTweetLib/src/qtweetretweettome.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetretweettome.h create mode 100644 thirdparty/QTweetLib/src/qtweetsearch.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetsearch.h create mode 100644 thirdparty/QTweetLib/src/qtweetsearchpageresults.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetsearchpageresults.h create mode 100644 thirdparty/QTweetLib/src/qtweetsearchresult.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetsearchresult.h create mode 100644 thirdparty/QTweetLib/src/qtweetstatus.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetstatus.h create mode 100644 thirdparty/QTweetLib/src/qtweetstatusdestroy.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetstatusdestroy.h create mode 100644 thirdparty/QTweetLib/src/qtweetstatusretweet.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetstatusretweet.h create mode 100644 thirdparty/QTweetLib/src/qtweetstatusretweets.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetstatusretweets.h create mode 100644 thirdparty/QTweetLib/src/qtweetstatusshow.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetstatusshow.h create mode 100644 thirdparty/QTweetLib/src/qtweetstatusupdate.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetstatusupdate.h create mode 100644 thirdparty/QTweetLib/src/qtweetuser.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetuser.h create mode 100644 thirdparty/QTweetLib/src/qtweetuserlookup.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetuserlookup.h create mode 100644 thirdparty/QTweetLib/src/qtweetusersearch.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetusersearch.h create mode 100644 thirdparty/QTweetLib/src/qtweetusershow.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetusershow.h create mode 100644 thirdparty/QTweetLib/src/qtweetuserstatusesfollowers.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetuserstatusesfollowers.h create mode 100644 thirdparty/QTweetLib/src/qtweetuserstatusesfriends.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetuserstatusesfriends.h create mode 100644 thirdparty/QTweetLib/src/qtweetuserstream.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetuserstream.h create mode 100644 thirdparty/QTweetLib/src/qtweetusertimeline.cpp create mode 100644 thirdparty/QTweetLib/src/qtweetusertimeline.h create mode 100644 thirdparty/QTweetLib/src/src.pro diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 6fc67cd39..85a5e8dda 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory( jdns ) +add_subdirectory( QTweetLib ) diff --git a/thirdparty/QTweetLib/CMakeLists.txt b/thirdparty/QTweetLib/CMakeLists.txt new file mode 100644 index 000000000..38c738e03 --- /dev/null +++ b/thirdparty/QTweetLib/CMakeLists.txt @@ -0,0 +1,177 @@ +PROJECT(QTweetLib) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR) +SET(CMAKE_VERBOSE_MAKEFILE ON) + +SET( QT_USE_QTNETWORK TRUE ) +INCLUDE( ${QT_USE_FILE} ) + +add_definitions( ${QT_DEFINITIONS} ) +add_definitions( -DQT_SHARED ) + +if(WIN32) + set(PLATFORM_SPECIFIC_LIBS "ws2_32.dll" "advapi32.dll" ) +endif(WIN32) + +set(TOMAHAWK_QTWEETLIB_SOURCES + src/oauth.cpp + src/oauthtwitter.cpp + src/qtweetfriendstimeline.cpp + src/qtweethometimeline.cpp + src/qtweetmentions.cpp + src/qtweetnetbase.cpp + src/qtweetretweetbyme.cpp + src/qtweetretweetsofme.cpp + src/qtweetretweettome.cpp + src/qtweetstatus.cpp + src/qtweetstatusshow.cpp + src/qtweetstatusupdate.cpp + src/qtweetuser.cpp + src/qtweetusertimeline.cpp + src/qtweetstatusdestroy.cpp + src/qtweetstatusretweet.cpp + src/qtweetstatusretweets.cpp + src/qtweetusershow.cpp + src/qtweetuserlookup.cpp + src/qtweetdirectmessages.cpp + src/qtweetuserstream.cpp + src/qtweetdmstatus.cpp + src/qtweetusersearch.cpp + src/qtweetuserstatusesfriends.cpp + src/qtweetuserstatusesfollowers.cpp + src/qtweetlist.cpp + src/qtweetlistcreate.cpp + src/qtweetlistupdate.cpp + src/qtweetlistgetlists.cpp + src/qtweetlistshowlist.cpp + src/qtweetlistdeletelist.cpp + src/qtweetliststatuses.cpp + src/qtweetlistmemberships.cpp + src/qtweetlistsubscriptions.cpp + src/qtweetlistgetmembers.cpp + src/qtweetlistaddmember.cpp + src/qtweetlistdeletemember.cpp + src/qtweetlistsubscribers.cpp + src/qtweetlistsubscribe.cpp + src/qtweetlistunsubscribe.cpp + src/qtweetdirectmessagessent.cpp + src/qtweetdirectmessagenew.cpp + src/qtweetdirectmessagedestroy.cpp + src/qtweetfriendshipcreate.cpp + src/qtweetfriendshipdestroy.cpp + src/qtweetfriendsid.cpp + src/qtweetfollowersid.cpp + src/qtweetaccountverifycredentials.cpp + src/qtweetaccountratelimitstatus.cpp + src/qtweetfavorites.cpp + src/qtweetfavoritescreate.cpp + src/qtweetfavoritesdestroy.cpp + src/qtweetsearch.cpp + src/qtweetsearchresult.cpp + src/qtweetsearchpageresults.cpp + src/qtweetplace.cpp + src/qtweetgeoreversegeocode.cpp + src/qtweetgeosearch.cpp + src/qtweetgeosimilarplaces.cpp + src/qtweetgeoplaceid.cpp + src/qtweetgeoplacecreate.cpp + src/qtweetgeocoord.cpp + src/qtweetgeoboundingbox.cpp + src/qtweetconvert.cpp + src/qtweetentityurl.cpp + src/qtweetentityhashtag.cpp + src/qtweetentityusermentions.cpp +) + +set(TOMAHAWK_QTWEETLIB_HEADERS + src/oauth.h + src/oauthtwitter.h + src/qtweetfriendstimeline.h + src/qtweetlib_global.h + src/qtweethometimeline.h + src/qtweetmentions.h + src/qtweetnetbase.h + src/qtweetretweetbyme.h + src/qtweetretweetsofme.h + src/qtweetretweettome.h + src/qtweetstatus.h + src/qtweetstatusshow.h + src/qtweetstatusupdate.h + src/qtweetuser.h + src/qtweetusertimeline.h + src/qtweetstatusdestroy.h + src/qtweetstatusretweet.h + src/qtweetstatusretweets.h + src/qtweetusershow.h + src/qtweetuserlookup.h + src/qtweetdirectmessages.h + src/qtweetuserstream.h + src/qtweetdmstatus.h + src/qtweetusersearch.h + src/qtweetuserstatusesfriends.h + src/qtweetuserstatusesfollowers.h + src/qtweetlist.h + src/qtweetlistcreate.h + src/qtweetlistupdate.h + src/qtweetlistgetlists.h + src/qtweetlistshowlist.h + src/qtweetlistdeletelist.h + src/qtweetliststatuses.h + src/qtweetlistmemberships.h + src/qtweetlistsubscriptions.h + src/qtweetlistgetmembers.h + src/qtweetlistaddmember.h + src/qtweetlistdeletemember.h + src/qtweetlistsubscribers.h + src/qtweetlistsubscribe.h + src/qtweetlistunsubscribe.h + src/qtweetdirectmessagessent.h + src/qtweetdirectmessagenew.h + src/qtweetdirectmessagedestroy.h + src/qtweetfriendshipcreate.h + src/qtweetfriendshipdestroy.h + src/qtweetfriendsid.h + src/qtweetfollowersid.h + src/qtweetaccountverifycredentials.h + src/qtweetaccountratelimitstatus.h + src/qtweetfavorites.h + src/qtweetfavoritescreate.h + src/qtweetfavoritesdestroy.h + src/qtweetsearch.h + src/qtweetsearchresult.h + src/qtweetsearchpageresults.h + src/qtweetplace.h + src/qtweetgeoreversegeocode.h + src/qtweetgeosearch.h + src/qtweetgeosimilarplaces.h + src/qtweetgeoplaceid.h + src/qtweetgeoplacecreate.h + src/qtweetgeocoord.h + src/qtweetgeoboundingbox.h + src/qtweetconvert.h + src/qtweetentityurl.h + src/qtweetentityhashtag.h + src/qtweetentityusermentions.h +) + +include_directories( + . + ${QT_INCLUDE_DIR} + ${QT_INCLUDES} + src +) + +qt4_wrap_cpp( TOMAHAWK_QTWEETLIB_MOC ${TOMAHAWK_QTWEETLIB_HEADERS} ) + +ADD_LIBRARY(tomahawk_qtweetlib SHARED ${TOMAHAWK_QTWEETLIB_SOURCES} ${TOMAHAWK_QTWEETLIB_MOC}) + +target_link_libraries(tomahawk_qtweetlib + ${QT_LIBRARIES} + qjson +) + +SET_TARGET_PROPERTIES( tomahawk_qtweetlib PROPERTIES DEFINE_SYMBOL MAKE_QTWEETLIB_LIB ) + +INSTALL(TARGETS tomahawk_qtweetlib DESTINATION lib) + + diff --git a/thirdparty/QTweetLib/LICENSE b/thirdparty/QTweetLib/LICENSE new file mode 100644 index 000000000..a345e48d0 --- /dev/null +++ b/thirdparty/QTweetLib/LICENSE @@ -0,0 +1,459 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + \ No newline at end of file diff --git a/thirdparty/QTweetLib/QTweetLib.pro b/thirdparty/QTweetLib/QTweetLib.pro new file mode 100644 index 000000000..ab4b0fd3b --- /dev/null +++ b/thirdparty/QTweetLib/QTweetLib.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs +SUBDIRS = sub_qjson sub_src sub_examples + +sub_qjson.subdir = qjson + +sub_src.subdir = src +sub_src.depends = sub_qjson + +sub_examples.subdir = examples +sub_examples.depends = sub_src diff --git a/thirdparty/QTweetLib/README b/thirdparty/QTweetLib/README new file mode 100644 index 000000000..1d5b0aae9 --- /dev/null +++ b/thirdparty/QTweetLib/README @@ -0,0 +1,12 @@ +- Supports only XAuth protocol (if there is need for PIN based OAuth I will include it) +- OAuth tokens must be set in oauth.cpp line 27 and 28 to work properly +- Uses QJson library by Flavio Castelli for parsing JSON responses +- JSON parsing is done in multithreaded way using QThreadPool +- User Streams support is not completed (fetches responses correctly, JSON parsing is not full implemented) + +Requirements and dependencies: +- Qt needs to be compiled with OpenSSL support (there are two places where is used https protocol) +- You will also need xAuth privilege access to Twitter API ( see http://dev.twitter.com/pages/xauth ) +- Valid OAuth consumer tokens, put them in oauth.cpp line 27 and 28 +- If you have already access tokens ( see http://dev.twitter.com/pages/oauth_single_token ) put them directly + with OAuthTwitter::setOAuthToken() and OAuthTwitter::setOAuthTokenSecret() diff --git a/thirdparty/QTweetLib/examples/examples.pro b/thirdparty/QTweetLib/examples/examples.pro new file mode 100644 index 000000000..ae877b052 --- /dev/null +++ b/thirdparty/QTweetLib/examples/examples.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = search timelines statusupdate geosearch georeverse \ + followers userstream diff --git a/thirdparty/QTweetLib/examples/followers/FollowerDelegate.qml b/thirdparty/QTweetLib/examples/followers/FollowerDelegate.qml new file mode 100644 index 000000000..f99fa6853 --- /dev/null +++ b/thirdparty/QTweetLib/examples/followers/FollowerDelegate.qml @@ -0,0 +1,56 @@ +import Qt 4.7 + +Rectangle { + property string name: "Twitter name" + property string screenName: "Twitter screen name" + property string description: "Twitter description" + property string avatarUrl + + width: ListView.view.width - 1; + height: 100 + radius: 10 + border.width: 1 + border.color: "#000000" + + Image { + id: avatar + anchors.top: parent.top + anchors.left: parent.left + width: 48; height: 48 + anchors.leftMargin: 2 + anchors.topMargin: 2 + source: avatarUrl + } + + Text { + id: screenNameText + text: screenName + anchors.leftMargin: 2 + anchors.topMargin: 2 + anchors.left: avatar.right + anchors.top: parent.top + } + + Text { + id: nameText + text: name + anchors.leftMargin: 2 + anchors.topMargin: 2 + anchors.top: screenNameText.bottom + anchors.left: avatar.right + } + + Text { + id: descriptionText + text: description + anchors.rightMargin: 2 + anchors.leftMargin: 2 + anchors.bottomMargin: 2 + anchors.topMargin: 2 + anchors.bottom: parent.bottom + anchors.top: avatar.bottom + anchors.left: parent.left + anchors.right: parent.right + wrapMode: "WordWrap" + } +} diff --git a/thirdparty/QTweetLib/examples/followers/FollowersList.qml b/thirdparty/QTweetLib/examples/followers/FollowersList.qml new file mode 100644 index 000000000..69fc40bc0 --- /dev/null +++ b/thirdparty/QTweetLib/examples/followers/FollowersList.qml @@ -0,0 +1,19 @@ +import Qt 4.7 + +//followersListModel - external + +Item { + ListView { + id: followersListView + width: parent.width; height: parent.height + clip: true + model: followersListModel + delegate: FollowerDelegate { + id: followerDelegate + name: nameRole + screenName: screenNameRole + description: descriptionRole + avatarUrl: avatarRole + } + } +} diff --git a/thirdparty/QTweetLib/examples/followers/followers.cpp b/thirdparty/QTweetLib/examples/followers/followers.cpp new file mode 100644 index 000000000..92d5a1068 --- /dev/null +++ b/thirdparty/QTweetLib/examples/followers/followers.cpp @@ -0,0 +1,67 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "followers.h" +#include "ui_followers.h" +#include +#include +#include "followerslistmodel.h" +#include "oauthtwitter.h" + +Followers::Followers(QWidget *parent) : + QWidget(parent), + ui(new Ui::Followers) +{ + ui->setupUi(this); + + m_oauthTwitter = new OAuthTwitter(this); + m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this)); + m_oauthTwitter->setOAuthToken(""); + m_oauthTwitter->setOAuthTokenSecret(""); + + m_followersListModel = new FollowersListModel(m_oauthTwitter, this); + + ui->declarativeView->rootContext()->setContextProperty("followersListModel", m_followersListModel); + ui->declarativeView->setSource(QUrl("qrc:/FollowersList.qml")); + + connect(ui->fetchFollowersPushButton, SIGNAL(clicked()), SLOT(onFetchFollowersPushButtonClicked())); +} + +Followers::~Followers() +{ + delete ui; +} + +void Followers::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void Followers::onFetchFollowersPushButtonClicked() +{ + m_followersListModel->fetchFollowers(); +} diff --git a/thirdparty/QTweetLib/examples/followers/followers.h b/thirdparty/QTweetLib/examples/followers/followers.h new file mode 100644 index 000000000..110410139 --- /dev/null +++ b/thirdparty/QTweetLib/examples/followers/followers.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef FOLLOWERS_H +#define FOLLOWERS_H + +#include + +class OAuthTwitter; +class FollowersListModel; + +namespace Ui { + class Followers; +} + +class Followers : public QWidget +{ + Q_OBJECT + +public: + explicit Followers(QWidget *parent = 0); + ~Followers(); + +protected: + void changeEvent(QEvent *e); + +private slots: + void onFetchFollowersPushButtonClicked(); + +private: + Ui::Followers *ui; + OAuthTwitter *m_oauthTwitter; + FollowersListModel *m_followersListModel; +}; + +#endif // FOLLOWERS_H diff --git a/thirdparty/QTweetLib/examples/followers/followers.pro b/thirdparty/QTweetLib/examples/followers/followers.pro new file mode 100644 index 000000000..4d8351fa0 --- /dev/null +++ b/thirdparty/QTweetLib/examples/followers/followers.pro @@ -0,0 +1,25 @@ +QT += core gui network declarative + +TARGET = followers +TEMPLATE = app +win32:LIBS += ../../lib/QTweetLib.lib +INCLUDEPATH += ../../src + +SOURCES += \ + main.cpp \ + followers.cpp \ + followerslistmodel.cpp + +HEADERS += \ + followers.h \ + followerslistmodel.h + +FORMS += \ + followers.ui + +OTHER_FILES += \ + FollowerDelegate.qml \ + FollowersList.qml + +RESOURCES += \ + followers.qrc diff --git a/thirdparty/QTweetLib/examples/followers/followers.qrc b/thirdparty/QTweetLib/examples/followers/followers.qrc new file mode 100644 index 000000000..ef9f3bbf0 --- /dev/null +++ b/thirdparty/QTweetLib/examples/followers/followers.qrc @@ -0,0 +1,6 @@ + + + FollowerDelegate.qml + FollowersList.qml + + diff --git a/thirdparty/QTweetLib/examples/followers/followers.ui b/thirdparty/QTweetLib/examples/followers/followers.ui new file mode 100644 index 000000000..434878ee9 --- /dev/null +++ b/thirdparty/QTweetLib/examples/followers/followers.ui @@ -0,0 +1,42 @@ + + + Followers + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + QDeclarativeView::SizeRootObjectToView + + + + + + + Fetch Followers + + + + + + + + QDeclarativeView + QGraphicsView +
QtDeclarative/QDeclarativeView
+
+
+ + +
diff --git a/thirdparty/QTweetLib/examples/followers/followerslistmodel.cpp b/thirdparty/QTweetLib/examples/followers/followerslistmodel.cpp new file mode 100644 index 000000000..9be053c4f --- /dev/null +++ b/thirdparty/QTweetLib/examples/followers/followerslistmodel.cpp @@ -0,0 +1,113 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "followerslistmodel.h" +#include "oauthtwitter.h" +#include "qtweetuser.h" +#include "qtweetuserstatusesfollowers.h" + +FollowersListModel::FollowersListModel(QObject *parent) : + QAbstractListModel(parent) +{ + QHash roles; + roles[NameRole] = "nameRole"; + roles[ScreenNameRole] = "screenNameRole"; + roles[DescriptionRole] = "descriptionRole"; + roles[AvatarRole] = "avatarRole"; + setRoleNames(roles); +} + +FollowersListModel::FollowersListModel(OAuthTwitter *oauthTwitter, QObject *parent) : + QAbstractListModel(parent) +{ + QHash roles; + roles[NameRole] = "nameRole"; + roles[ScreenNameRole] = "screenNameRole"; + roles[DescriptionRole] = "descriptionRole"; + roles[AvatarRole] = "avatarRole"; + setRoleNames(roles); + + m_oauthTwitter = oauthTwitter; +} + +void FollowersListModel::setOAuthTwitter(OAuthTwitter *oauthTwitter) +{ + m_oauthTwitter = oauthTwitter; +} + +int FollowersListModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return m_users.count(); +} + +QVariant FollowersListModel::data(const QModelIndex &index, int role) const +{ + if (index.row() < 0 || index.row() > m_users.count()) + return QVariant(); + + const QTweetUser &user = m_users.at(index.row()); + + if (role == NameRole) + return user.name(); + else if (role == ScreenNameRole) + return user.screenName(); + else if (role == DescriptionRole) + return user.description(); + else if (role == AvatarRole) + return user.profileImageUrl(); + + return QVariant(); +} + +void FollowersListModel::fetchFollowers(const QString &cursor) +{ + if (cursor == "-1") { + beginResetModel(); + m_users.clear(); + endResetModel(); + } + + QTweetUserStatusesFollowers *followers = new QTweetUserStatusesFollowers; + followers->setOAuthTwitter(m_oauthTwitter); + followers->fetch(0, cursor, false); + connect(followers, SIGNAL(parsedFollowersList(QList,QString)), + this, SLOT(followersFinished(QList,QString))); + +} + +void FollowersListModel::followersFinished(const QList &followers, const QString &nextCursor) +{ + QTweetUserStatusesFollowers *users = qobject_cast(sender()); + + if (users) { + beginInsertRows(QModelIndex(), m_users.count(), m_users.count() + followers.count()); + m_users.append(followers); + endInsertRows(); + + if (nextCursor == "0") + return; + + //continue fetchingg next page + fetchFollowers(nextCursor); + + users->deleteLater(); + } +} diff --git a/thirdparty/QTweetLib/examples/followers/followerslistmodel.h b/thirdparty/QTweetLib/examples/followers/followerslistmodel.h new file mode 100644 index 000000000..eccdfa098 --- /dev/null +++ b/thirdparty/QTweetLib/examples/followers/followerslistmodel.h @@ -0,0 +1,56 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef FOLLOWERSLISTMODEL_H +#define FOLLOWERSLISTMODEL_H + +#include + +class OAuthTwitter; +class QTweetUser; + +class FollowersListModel : public QAbstractListModel +{ + Q_OBJECT +public: + enum Roles { + NameRole = Qt::UserRole + 1, + ScreenNameRole, + DescriptionRole, + AvatarRole + }; + + FollowersListModel(QObject *parent = 0); + FollowersListModel(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void setOAuthTwitter(OAuthTwitter *oauthTwitter); + int rowCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + void fetchFollowers(const QString& cursor = QString("-1")); + +private slots: + void followersFinished(const QList& followers, + const QString& nextCursor); + +private: + OAuthTwitter *m_oauthTwitter; + QList m_users; +}; + +#endif // FOLLOWERSLISTMODEL_H diff --git a/thirdparty/QTweetLib/examples/followers/main.cpp b/thirdparty/QTweetLib/examples/followers/main.cpp new file mode 100644 index 000000000..ddbc5276a --- /dev/null +++ b/thirdparty/QTweetLib/examples/followers/main.cpp @@ -0,0 +1,32 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + + +#include +#include "followers.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Followers w; + w.show(); + + return a.exec(); +} diff --git a/thirdparty/QTweetLib/examples/georeverse/georeverse.cpp b/thirdparty/QTweetLib/examples/georeverse/georeverse.cpp new file mode 100644 index 000000000..bb6b73c91 --- /dev/null +++ b/thirdparty/QTweetLib/examples/georeverse/georeverse.cpp @@ -0,0 +1,106 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include "oauthtwitter.h" +#include "qtweetplace.h" +#include "qtweetgeocoord.h" +#include "qtweetgeoreversegeocode.h" +#include "georeverse.h" +#include "ui_georeverse.h" + +GeoReverse::GeoReverse(QWidget *parent) : + QWidget(parent), + ui(new Ui::GeoReverse) +{ + ui->setupUi(this); + + m_oauthTwitter = new OAuthTwitter(this); + m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this)); + m_oauthTwitter->setOAuthToken(""); + m_oauthTwitter->setOAuthTokenSecret(""); + + QDoubleValidator *latValidator = new QDoubleValidator(ui->latitudeLineEdit); + latValidator->setNotation(QDoubleValidator::StandardNotation); + ui->latitudeLineEdit->setValidator(latValidator); + + QDoubleValidator *longValidator = new QDoubleValidator(ui->longitudeLineEdit); + longValidator->setNotation(QDoubleValidator::StandardNotation); + ui->longitudeLineEdit->setValidator(longValidator); + + connect(ui->searchPushButton, SIGNAL(clicked()), SLOT(onSearchPushButtonClicked())); +} + +GeoReverse::~GeoReverse() +{ + delete ui; +} + +void GeoReverse::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + + +void GeoReverse::onSearchPushButtonClicked() +{ + QTweetGeoReverseGeoCode *reverseGeo = new QTweetGeoReverseGeoCode(m_oauthTwitter, this); + reverseGeo->getPlaces(QTweetGeoCoord(ui->latitudeLineEdit->text().toDouble(), + ui->longitudeLineEdit->text().toDouble())); + connect(reverseGeo, SIGNAL(parsedPlaces(QList)), SLOT(reverseGeoFinished(QList))); +} + +void GeoReverse::reverseGeoFinished(const QList &places) +{ + QTweetGeoReverseGeoCode *reverseGeo = qobject_cast(sender()); + + if (reverseGeo) { + ui->tableWidget->clear(); + ui->tableWidget->setRowCount(places.count()); + ui->tableWidget->setColumnCount(4); + + int row = 0; + foreach (const QTweetPlace& place, places) { + QTableWidgetItem *fullname = new QTableWidgetItem(place.fullName()); + ui->tableWidget->setItem(row, 0, fullname); + QTableWidgetItem *placeid = new QTableWidgetItem(place.id()); + ui->tableWidget->setItem(row, 1, placeid); + + //QGeoBoundingBox bb = place.boundingBox(); + //QGeoCoordinate coord = bb.center(); + + //approximate, just shows center of the box + //QTableWidgetItem *lat = new QTableWidgetItem(QString::number(coord.latitude())); + //ui->tableWidget->setItem(row, 2, lat); + //QTableWidgetItem *longit = new QTableWidgetItem(QString::number(coord.longitude())); + //ui->tableWidget->setItem(row, 3, longit); + //++row; + } + + reverseGeo->deleteLater(); + } +} diff --git a/thirdparty/QTweetLib/examples/georeverse/georeverse.h b/thirdparty/QTweetLib/examples/georeverse/georeverse.h new file mode 100644 index 000000000..b82c7ea76 --- /dev/null +++ b/thirdparty/QTweetLib/examples/georeverse/georeverse.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef GEOREVERSE_H +#define GEOREVERSE_H + +#include + +namespace Ui { + class GeoReverse; +} + +class OAuthTwitter; +class QTweetPlace; + +class GeoReverse : public QWidget +{ + Q_OBJECT + +public: + explicit GeoReverse(QWidget *parent = 0); + ~GeoReverse(); + +protected: + void changeEvent(QEvent *e); + +private slots: + void onSearchPushButtonClicked(); + void reverseGeoFinished(const QList& places); + +private: + Ui::GeoReverse *ui; + OAuthTwitter *m_oauthTwitter; + +}; + +#endif // GEOREVERSE_H diff --git a/thirdparty/QTweetLib/examples/georeverse/georeverse.pro b/thirdparty/QTweetLib/examples/georeverse/georeverse.pro new file mode 100644 index 000000000..2fa7c6c57 --- /dev/null +++ b/thirdparty/QTweetLib/examples/georeverse/georeverse.pro @@ -0,0 +1,18 @@ +QT += core gui network + +TARGET = georeverse +TEMPLATE = app +win32:LIBS += ../../lib/QTweetLib.lib +INCLUDEPATH += ../../src +CONFIG += mobility +MOBILITY += location + +SOURCES += \ + main.cpp \ + georeverse.cpp + +HEADERS += \ + georeverse.h + +FORMS += \ + georeverse.ui diff --git a/thirdparty/QTweetLib/examples/georeverse/georeverse.ui b/thirdparty/QTweetLib/examples/georeverse/georeverse.ui new file mode 100644 index 000000000..fb5eb7bf9 --- /dev/null +++ b/thirdparty/QTweetLib/examples/georeverse/georeverse.ui @@ -0,0 +1,51 @@ + + + GeoReverse + + + + 0 + 0 + 598 + 506 + + + + Form + + + + + + + + + Latitude + + + + + + + + + + Longitude + + + + + + + + + + Reverse geosearch + + + + + + + + diff --git a/thirdparty/QTweetLib/examples/georeverse/main.cpp b/thirdparty/QTweetLib/examples/georeverse/main.cpp new file mode 100644 index 000000000..4d854224a --- /dev/null +++ b/thirdparty/QTweetLib/examples/georeverse/main.cpp @@ -0,0 +1,32 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + + +#include +#include "georeverse.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + GeoReverse w; + w.show(); + + return a.exec(); +} diff --git a/thirdparty/QTweetLib/examples/geosearch/geosearch.cpp b/thirdparty/QTweetLib/examples/geosearch/geosearch.cpp new file mode 100644 index 000000000..44053b865 --- /dev/null +++ b/thirdparty/QTweetLib/examples/geosearch/geosearch.cpp @@ -0,0 +1,102 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include "oauthtwitter.h" +#include "qtweetplace.h" +#include "qtweetgeosearch.h" +#include "geosearch.h" +#include "qtweetgeocoord.h" +#include "ui_geosearch.h" + +GeoSearch::GeoSearch(QWidget *parent) : + QWidget(parent), + ui(new Ui::GeoSearch) +{ + ui->setupUi(this); + + m_oauthTwitter = new OAuthTwitter(this); + m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this)); + m_oauthTwitter->setOAuthToken(""); + m_oauthTwitter->setOAuthTokenSecret(""); + + QDoubleValidator *latValidator = new QDoubleValidator(ui->latitudeLineEdit); + latValidator->setNotation(QDoubleValidator::StandardNotation); + ui->latitudeLineEdit->setValidator(latValidator); + + QDoubleValidator *longValidator = new QDoubleValidator(ui->longitudeLineEdit); + longValidator->setNotation(QDoubleValidator::StandardNotation); + ui->longitudeLineEdit->setValidator(longValidator); + + connect(ui->searchPushButton, SIGNAL(clicked()), SLOT(onSearchPushButtonClicked())); +} + +GeoSearch::~GeoSearch() +{ + delete ui; +} + +void GeoSearch::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void GeoSearch::onSearchPushButtonClicked() +{ + QTweetGeoSearch *geoSearch = new QTweetGeoSearch(m_oauthTwitter, this); + QTweetGeoCoord latLong; + latLong.setLatitude(ui->latitudeLineEdit->text().toDouble()); + latLong.setLongitude(ui->longitudeLineEdit->text().toDouble()); + + geoSearch->search(latLong); + connect(geoSearch, SIGNAL(parsedPlaces(QList)), SLOT(searchPlacesFinished(QList))); +} + +void GeoSearch::searchPlacesFinished(const QList &places) +{ + QTweetGeoSearch *geoSearch = qobject_cast(sender()); + + if (geoSearch) { + ui->tableWidget->clear(); + ui->tableWidget->setRowCount(places.count()); + ui->tableWidget->setColumnCount(2); + + int row = 0; + foreach (const QTweetPlace& place, places) { + QTableWidgetItem *fullname = new QTableWidgetItem(place.fullName()); + ui->tableWidget->setItem(row, 0, fullname); + QTableWidgetItem *placeid = new QTableWidgetItem(place.id()); + ui->tableWidget->setItem(row, 1, placeid); + + ++row; + } + + geoSearch->deleteLater(); + + } +} diff --git a/thirdparty/QTweetLib/examples/geosearch/geosearch.h b/thirdparty/QTweetLib/examples/geosearch/geosearch.h new file mode 100644 index 000000000..0727e9e54 --- /dev/null +++ b/thirdparty/QTweetLib/examples/geosearch/geosearch.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef GEOSEARCH_H +#define GEOSEARCH_H + +#include + +namespace Ui { + class GeoSearch; +} + +class OAuthTwitter; +class QTweetPlace; + +class GeoSearch : public QWidget +{ + Q_OBJECT + +public: + explicit GeoSearch(QWidget *parent = 0); + ~GeoSearch(); + +protected: + void changeEvent(QEvent *e); + +private slots: + void onSearchPushButtonClicked(); + void searchPlacesFinished(const QList& places); + +private: + Ui::GeoSearch *ui; + OAuthTwitter *m_oauthTwitter; +}; + +#endif // GEOSEARCH_H diff --git a/thirdparty/QTweetLib/examples/geosearch/geosearch.pro b/thirdparty/QTweetLib/examples/geosearch/geosearch.pro new file mode 100644 index 000000000..9e68ec121 --- /dev/null +++ b/thirdparty/QTweetLib/examples/geosearch/geosearch.pro @@ -0,0 +1,18 @@ +QT += core gui network + +TARGET = geosearch +TEMPLATE = app +win32:LIBS += ../../lib/QTweetLib.lib +INCLUDEPATH += ../../src +CONFIG += mobility +MOBILITY += location + +SOURCES += \ + main.cpp \ + geosearch.cpp + +HEADERS += \ + geosearch.h + +FORMS += \ + geosearch.ui diff --git a/thirdparty/QTweetLib/examples/geosearch/geosearch.ui b/thirdparty/QTweetLib/examples/geosearch/geosearch.ui new file mode 100644 index 000000000..4f4d6cab4 --- /dev/null +++ b/thirdparty/QTweetLib/examples/geosearch/geosearch.ui @@ -0,0 +1,55 @@ + + + GeoSearch + + + + 0 + 0 + 616 + 434 + + + + Form + + + + + + true + + + + + + + Latitude + + + + + + + + + + Longitude + + + + + + + + + + Search + + + + + + + + diff --git a/thirdparty/QTweetLib/examples/geosearch/main.cpp b/thirdparty/QTweetLib/examples/geosearch/main.cpp new file mode 100644 index 000000000..25f8d7eb1 --- /dev/null +++ b/thirdparty/QTweetLib/examples/geosearch/main.cpp @@ -0,0 +1,32 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + + +#include +#include "geosearch.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + GeoSearch w; + w.show(); + + return a.exec(); +} diff --git a/thirdparty/QTweetLib/examples/search/main.cpp b/thirdparty/QTweetLib/examples/search/main.cpp new file mode 100644 index 000000000..b13de9284 --- /dev/null +++ b/thirdparty/QTweetLib/examples/search/main.cpp @@ -0,0 +1,31 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/thirdparty/QTweetLib/examples/search/mainwindow.cpp b/thirdparty/QTweetLib/examples/search/mainwindow.cpp new file mode 100644 index 000000000..779792d6f --- /dev/null +++ b/thirdparty/QTweetLib/examples/search/mainwindow.cpp @@ -0,0 +1,100 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include "oauthtwitter.h" +#include "qtweetsearch.h" +#include "qtweetsearchpageresults.h" +#include "qtweetsearchresult.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + m_oauthTwitter = new OAuthTwitter(this); + m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this)); + + connect(ui->startSearchButton, SIGNAL(clicked()), this, SLOT(searchButtonClicked())); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::searchButtonClicked() +{ + QTweetSearch *twitSearch = new QTweetSearch(m_oauthTwitter, m_oauthTwitter); + twitSearch->setAuthenticationEnabled(false); + twitSearch->start(ui->queryLineEdit->text()); + connect(twitSearch, SIGNAL(parsedPageResults(QTweetSearchPageResults)), + this, SLOT(finishedSearch(QTweetSearchPageResults))); +} + +void MainWindow::finishedSearch(const QTweetSearchPageResults &results) +{ + QTweetSearch *twitSearch = qobject_cast(sender()); + + if (twitSearch) { + ui->resultsTextEdit->append("maxid: " + QString::number(results.maxid())); + ui->resultsTextEdit->append("next page: " + results.nextPage()); + ui->resultsTextEdit->append("page: " + QString::number(results.page())); + ui->resultsTextEdit->append("query: " + results.query()); + ui->resultsTextEdit->append("refresh url: " + results.refreshUrl()); + ui->resultsTextEdit->append("rpp: " + QString::number(results.resultsPerPage())); + ui->resultsTextEdit->append("sinceid: " + QString::number(results.sinceid())); + ui->resultsTextEdit->append("total: " + QString::number(results.total())); + + QList listResults = results.results(); + + ui->resultsTextEdit->append("results: \n"); + + foreach (const QTweetSearchResult& singleResult, listResults) { + ui->resultsTextEdit->append("created: " + singleResult.createdAt().toString()); + ui->resultsTextEdit->append("from user: " + singleResult.fromUser()); + ui->resultsTextEdit->append("id: " + QString::number(singleResult.id())); + ui->resultsTextEdit->append("lang: " + singleResult.lang()); + ui->resultsTextEdit->append("avatar url: " + singleResult.profileImageUrl()); + ui->resultsTextEdit->append("source: " + singleResult.source()); + ui->resultsTextEdit->append("text: " + singleResult.text()); + ui->resultsTextEdit->append("to user: " + singleResult.toUser()); + ui->resultsTextEdit->append("-------"); + } + + twitSearch->deleteLater(); + } +} + +void MainWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/thirdparty/QTweetLib/examples/search/mainwindow.h b/thirdparty/QTweetLib/examples/search/mainwindow.h new file mode 100644 index 000000000..5b953b98f --- /dev/null +++ b/thirdparty/QTweetLib/examples/search/mainwindow.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +class OAuthTwitter; +class QTweetSearchPageResults; + +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +protected: + void changeEvent(QEvent *e); + +private slots: + void searchButtonClicked(); + void finishedSearch(const QTweetSearchPageResults& results); + +private: + Ui::MainWindow *ui; + OAuthTwitter* m_oauthTwitter; +}; + +#endif // MAINWINDOW_H diff --git a/thirdparty/QTweetLib/examples/search/mainwindow.ui b/thirdparty/QTweetLib/examples/search/mainwindow.ui new file mode 100644 index 000000000..e673d6ebc --- /dev/null +++ b/thirdparty/QTweetLib/examples/search/mainwindow.ui @@ -0,0 +1,64 @@ + + + MainWindow + + + + 0 + 0 + 621 + 600 + + + + MainWindow + + + + + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + Query: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Search + + + + + + + + + + + diff --git a/thirdparty/QTweetLib/examples/search/search.pro b/thirdparty/QTweetLib/examples/search/search.pro new file mode 100644 index 000000000..2ed5e7b7a --- /dev/null +++ b/thirdparty/QTweetLib/examples/search/search.pro @@ -0,0 +1,17 @@ +QT += core gui network + +TARGET = searchexample +TEMPLATE = app +win32:LIBS += ../../lib/QTweetLib.lib +INCLUDEPATH += ../../src + +SOURCES +=\ + mainwindow.cpp \ + main.cpp + +HEADERS += \ + mainwindow.h + + +FORMS += \ + mainwindow.ui diff --git a/thirdparty/QTweetLib/examples/statusupdate/main.cpp b/thirdparty/QTweetLib/examples/statusupdate/main.cpp new file mode 100644 index 000000000..250f6aebb --- /dev/null +++ b/thirdparty/QTweetLib/examples/statusupdate/main.cpp @@ -0,0 +1,32 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + + +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/thirdparty/QTweetLib/examples/statusupdate/mainwindow.cpp b/thirdparty/QTweetLib/examples/statusupdate/mainwindow.cpp new file mode 100644 index 000000000..123ce4f6d --- /dev/null +++ b/thirdparty/QTweetLib/examples/statusupdate/mainwindow.cpp @@ -0,0 +1,117 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include "oauthtwitter.h" +#include "qtweetstatusupdate.h" +#include "qtweetstatus.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + //m_authorized = false; + + QDoubleValidator *latValidator = new QDoubleValidator(ui->latLineEdit); + latValidator->setNotation(QDoubleValidator::StandardNotation); + ui->latLineEdit->setValidator(latValidator); + + QDoubleValidator *longValidator = new QDoubleValidator(ui->longLineEdit); + longValidator->setNotation(QDoubleValidator::StandardNotation); + ui->longLineEdit->setValidator(longValidator); + + m_oauthTwitter = new OAuthTwitter(this); + m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this)); + connect(m_oauthTwitter, SIGNAL(authorizeXAuthFinished()), SLOT(xauthFinished())); + connect(m_oauthTwitter, SIGNAL(authorizeXAuthError()), SLOT(xauthError())); + + connect(ui->authPushButton, SIGNAL(clicked()), SLOT(authorizeButtonClicked())); + connect(ui->udpatePushButton, SIGNAL(clicked()), SLOT(updateButtonClicked())); + + m_authorized = true; + m_oauthTwitter->setOAuthToken("16290455-CPyk9D9hJoCghpw7zAE73IZ0g0XtbVHU7xbI5RJE2"); + m_oauthTwitter->setOAuthTokenSecret("NMCzZHio4YAB1ZrTsNP35HLHeN4Ze1GI3qT4zvMCctQ"); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void MainWindow::authorizeButtonClicked() +{ + m_oauthTwitter->authorizeXAuth(ui->userNameLineEdit->text(), ui->passwordLineEdit->text()); +} + +void MainWindow::xauthFinished() +{ + ui->statusbar->showMessage("XAuth succesfull!"); + m_authorized = true; +} + +void MainWindow::xauthError() +{ + ui->statusbar->showMessage("XAuth failed"); + m_authorized = false; +} + +void MainWindow::updateButtonClicked() +{ + if (m_authorized) { + QTweetStatusUpdate *statusUpdate = new QTweetStatusUpdate(m_oauthTwitter, this); + statusUpdate->post(ui->statusTextEdit->toPlainText(), + 0, + QTweetGeoCoord(ui->latLineEdit->text().toDouble(), ui->longLineEdit->text().toDouble()), + QString(), + true); + connect(statusUpdate, SIGNAL(postedStatus(QTweetStatus)), SLOT(postStatusFinished(QTweetStatus))); + + } else { + ui->statusbar->showMessage("You cannot post, needs autorization!"); + } +} + +void MainWindow::postStatusFinished(const QTweetStatus &status) +{ + QTweetStatusUpdate *statusUpdate = qobject_cast(sender()); + + if (statusUpdate) { + ui->statusbar->showMessage("Posted status with id " + QString::number(status.id())); + + statusUpdate->deleteLater(); + } +} diff --git a/thirdparty/QTweetLib/examples/statusupdate/mainwindow.h b/thirdparty/QTweetLib/examples/statusupdate/mainwindow.h new file mode 100644 index 000000000..addbac0d3 --- /dev/null +++ b/thirdparty/QTweetLib/examples/statusupdate/mainwindow.h @@ -0,0 +1,57 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { + class MainWindow; +} + +class OAuthTwitter; +class QTweetStatus; + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +protected: + void changeEvent(QEvent *e); + +private slots: + void authorizeButtonClicked(); + void xauthFinished(); + void xauthError(); + void updateButtonClicked(); + void postStatusFinished(const QTweetStatus& status); + +private: + Ui::MainWindow *ui; + OAuthTwitter *m_oauthTwitter; + bool m_authorized; +}; + +#endif // MAINWINDOW_H diff --git a/thirdparty/QTweetLib/examples/statusupdate/mainwindow.ui b/thirdparty/QTweetLib/examples/statusupdate/mainwindow.ui new file mode 100644 index 000000000..2104d955a --- /dev/null +++ b/thirdparty/QTweetLib/examples/statusupdate/mainwindow.ui @@ -0,0 +1,206 @@ + + + MainWindow + + + + 0 + 0 + 541 + 287 + + + + MainWindow + + + + + + + + + + + Username: + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Password: + + + + + + + QLineEdit::Password + + + + + + + + + + 70 + 16777215 + + + + Authorize + + + + + + + + + + + + + Status text: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 16777215 + 128 + + + + + + + + + + + + + + Latitude: + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Longitude: + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Update + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + diff --git a/thirdparty/QTweetLib/examples/statusupdate/statusupdate.pro b/thirdparty/QTweetLib/examples/statusupdate/statusupdate.pro new file mode 100644 index 000000000..2eb8745be --- /dev/null +++ b/thirdparty/QTweetLib/examples/statusupdate/statusupdate.pro @@ -0,0 +1,16 @@ +QT += core gui network + +TARGET = statusupdate +TEMPLATE = app +win32:LIBS += ../../lib/QTweetLib.lib +INCLUDEPATH += ../../src + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui diff --git a/thirdparty/QTweetLib/examples/timelines/main.cpp b/thirdparty/QTweetLib/examples/timelines/main.cpp new file mode 100644 index 000000000..250f6aebb --- /dev/null +++ b/thirdparty/QTweetLib/examples/timelines/main.cpp @@ -0,0 +1,32 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + + +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/thirdparty/QTweetLib/examples/timelines/mainwindow.cpp b/thirdparty/QTweetLib/examples/timelines/mainwindow.cpp new file mode 100644 index 000000000..c7b4fc6b5 --- /dev/null +++ b/thirdparty/QTweetLib/examples/timelines/mainwindow.cpp @@ -0,0 +1,224 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include "oauthtwitter.h" +#include "qtweethometimeline.h" +#include "qtweetmentions.h" +#include "qtweetusertimeline.h" +#include "qtweetdirectmessages.h" +#include "qtweetstatus.h" +#include "qtweetdmstatus.h" +#include "qtweetuser.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + m_sinceidHomeTimeline = 0; + m_sinceidMentions = 0; + m_sinceidUserTimeline = 0; + m_sinceidDirectMessages = 0; + + m_oauthTwitter = new OAuthTwitter(this); + m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this)); + connect(m_oauthTwitter, SIGNAL(authorizeXAuthFinished()), this, SLOT(xauthFinished())); + connect(m_oauthTwitter, SIGNAL(authorizeXAuthError()), this, SLOT(xauthError())); + + m_timer = new QTimer(this); + m_timer->setInterval(60000); + connect(m_timer, SIGNAL(timeout()), this, SLOT(timerTimeOut())); + + connect(ui->authorizePushButton, SIGNAL(clicked()), this, SLOT(authorizeButtonClicked())); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void MainWindow::authorizeButtonClicked() +{ + m_oauthTwitter->authorizeXAuth(ui->usernameLineEdit->text(), ui->passwordLineEdit->text()); + +} + +void MainWindow::xauthFinished() +{ + ui->statusBar->showMessage("xauth succesfull"); + m_timer->start(); + timerTimeOut(); +} + +void MainWindow::xauthError() +{ + ui->statusBar->showMessage("xauth failed"); +} + +void MainWindow::timerTimeOut() +{ + QTweetHomeTimeline *homeTimeline = new QTweetHomeTimeline(m_oauthTwitter, this); + homeTimeline->fetch(m_sinceidHomeTimeline); + connect(homeTimeline, SIGNAL(parsedStatuses(QList)), + this, SLOT(homeTimelineStatuses(QList))); + + QTweetMentions *mentions = new QTweetMentions(m_oauthTwitter, this); + mentions->fetch(m_sinceidMentions); + connect(mentions, SIGNAL(parsedStatuses(QList)), + this, SLOT(mentionsStatuses(QList))); + + QTweetUserTimeline *userTimeline = new QTweetUserTimeline(m_oauthTwitter, this); + userTimeline->fetch(0, QString(), m_sinceidUserTimeline); + connect(userTimeline, SIGNAL(parsedStatuses(QList)), + this, SLOT(userTimelineStatuses(QList))); + + QTweetDirectMessages *dmTimeline = new QTweetDirectMessages(m_oauthTwitter, this); + dmTimeline->fetch(m_sinceidDirectMessages); + connect(dmTimeline, SIGNAL(parsedDirectMessages(QList)), + this, SLOT(directMessages(QList))); +} + +void MainWindow::homeTimelineStatuses(const QList &statuses) +{ + QTweetHomeTimeline *homeTimeline = qobject_cast(sender()); + + if (homeTimeline) { + if (statuses.count()) { + //order is messed up, but this is just example + foreach (const QTweetStatus& status, statuses) { + ui->homeTimelineTextEdit->append("id: " + QString::number(status.id())); + ui->homeTimelineTextEdit->append("text: " + status.text()); + ui->homeTimelineTextEdit->append("created: " + status.createdAt().toString()); + + QTweetUser userinfo = status.user(); + + ui->homeTimelineTextEdit->append("screen name: " + userinfo.screenName()); + ui->homeTimelineTextEdit->append("user id: " + QString::number(userinfo.id())); + + //is it retweet? + QTweetStatus rtStatus = status.retweetedStatus(); + + if (rtStatus.id()) { + ui->homeTimelineTextEdit->append("retweet text: " + rtStatus.text()); + } + + ui->homeTimelineTextEdit->append("----------------------------------------"); + + } + + m_sinceidHomeTimeline = statuses.at(0).id(); + } + + homeTimeline->deleteLater(); + } +} + +void MainWindow::mentionsStatuses(const QList &statuses) +{ + QTweetMentions *mentions = qobject_cast(sender()); + + if (mentions) { + if (statuses.count()) { + foreach (const QTweetStatus& status, statuses) { + ui->mentionsTextEdit->append("id: " + QString::number(status.id())); + ui->mentionsTextEdit->append("text: " + status.text()); + ui->mentionsTextEdit->append("created: " + status.createdAt().toString()); + + QTweetUser userinfo = status.user(); + + ui->mentionsTextEdit->append("screen name: " + userinfo.screenName()); + ui->mentionsTextEdit->append("user id: " + QString::number(userinfo.id())); + + ui->mentionsTextEdit->append("----------------------------------------"); + } + + m_sinceidMentions = statuses.at(0).id(); + } + mentions->deleteLater(); + } +} + +void MainWindow::userTimelineStatuses(const QList &statuses) +{ + QTweetUserTimeline *userTimeline = qobject_cast(sender()); + + if (userTimeline) { + if (statuses.count()) { + //order is messed up, but this is just example + foreach (const QTweetStatus& status, statuses) { + ui->userTimelineTextEdit->append("id: " + QString::number(status.id())); + ui->userTimelineTextEdit->append("text: " + status.text()); + ui->userTimelineTextEdit->append("created: " + status.createdAt().toString()); + + QTweetUser userinfo = status.user(); + + ui->userTimelineTextEdit->append("screen name: " + userinfo.screenName()); + ui->userTimelineTextEdit->append("user id: " + QString::number(userinfo.id())); + + ui->userTimelineTextEdit->append("----------------------------------------"); + } + + m_sinceidUserTimeline = statuses.at(0).id(); + } + + userTimeline->deleteLater(); + } +} + +void MainWindow::directMessages(const QList &directMessages) +{ + QTweetDirectMessages *dmTimeline = qobject_cast(sender()); + + if (dmTimeline) { + if (directMessages.count()) { + foreach (const QTweetDMStatus& message, directMessages) { + ui->directMessagesTextEdit->append("id: " + QString::number(message.id())); + ui->directMessagesTextEdit->append("text: " + message.text()); + ui->directMessagesTextEdit->append("created: " + message.createdAt().toString()); + ui->directMessagesTextEdit->append("sender: " + message.senderScreenName()); + ui->directMessagesTextEdit->append("sender id: " + QString::number(message.senderId())); + + ui->directMessagesTextEdit->append("----------------------------------------"); + } + + m_sinceidDirectMessages = directMessages.at(0).id(); + } + } + + dmTimeline->deleteLater(); +} diff --git a/thirdparty/QTweetLib/examples/timelines/mainwindow.h b/thirdparty/QTweetLib/examples/timelines/mainwindow.h new file mode 100644 index 000000000..5cc7838ba --- /dev/null +++ b/thirdparty/QTweetLib/examples/timelines/mainwindow.h @@ -0,0 +1,67 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { + class MainWindow; +} + +class OAuthTwitter; +class QTimer; +class QTweetStatus; +class QTweetDMStatus; + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +protected: + void changeEvent(QEvent *e); + +private slots: + void authorizeButtonClicked(); + void xauthFinished(); + void xauthError(); + void timerTimeOut(); + void homeTimelineStatuses(const QList& statuses); + void mentionsStatuses(const QList& statuses); + void userTimelineStatuses(const QList& statuses); + void directMessages(const QList& directMessages); + +private: + Ui::MainWindow *ui; + OAuthTwitter *m_oauthTwitter; + QTimer *m_timer; + qint64 m_sinceidHomeTimeline; + qint64 m_sinceidMentions; + qint64 m_sinceidUserTimeline; + qint64 m_sinceidDirectMessages; + +}; + +#endif // MAINWINDOW_H diff --git a/thirdparty/QTweetLib/examples/timelines/mainwindow.ui b/thirdparty/QTweetLib/examples/timelines/mainwindow.ui new file mode 100644 index 000000000..d31a8d5f2 --- /dev/null +++ b/thirdparty/QTweetLib/examples/timelines/mainwindow.ui @@ -0,0 +1,156 @@ + + + MainWindow + + + + 0 + 0 + 627 + 600 + + + + MainWindow + + + + + + + 0 + + + + Home timeline + + + + + + true + + + + + + + + Mentions timeline + + + + + + true + + + + + + + + User timeline + + + + + + true + + + + + + + + Direct Messages + + + + + + true + + + + + + + + + + + + + + + Username: + + + + + + + + + + + + + + Password: + + + + + + + QLineEdit::Password + + + + + + + + + Authorize + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + 368 + 20 + + + + + + + + + + + diff --git a/thirdparty/QTweetLib/examples/timelines/timelines.pro b/thirdparty/QTweetLib/examples/timelines/timelines.pro new file mode 100644 index 000000000..e2a6718ea --- /dev/null +++ b/thirdparty/QTweetLib/examples/timelines/timelines.pro @@ -0,0 +1,16 @@ +QT += core gui network + +TARGET = timelines +TEMPLATE = app +win32:LIBS += ../../lib/QTweetLib.lib +INCLUDEPATH += ../../src + +SOURCES += \ + mainwindow.cpp \ + main.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui diff --git a/thirdparty/QTweetLib/examples/userstream/main.cpp b/thirdparty/QTweetLib/examples/userstream/main.cpp new file mode 100644 index 000000000..1ab4eccf4 --- /dev/null +++ b/thirdparty/QTweetLib/examples/userstream/main.cpp @@ -0,0 +1,32 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include "userstream.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + UserStream w; + w.show(); + + return a.exec(); +} + diff --git a/thirdparty/QTweetLib/examples/userstream/userstream.cpp b/thirdparty/QTweetLib/examples/userstream/userstream.cpp new file mode 100644 index 000000000..eecb99633 --- /dev/null +++ b/thirdparty/QTweetLib/examples/userstream/userstream.cpp @@ -0,0 +1,110 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "userstream.h" +#include "ui_userstream.h" +#include +#include +#include +#include "oauthtwitter.h" +#include "qtweetuserstream.h" +#include "qtweetstatus.h" +#include "qtweetuser.h" + +UserStream::UserStream(QWidget *parent) : + QWidget(parent), + ui(new Ui::UserStream) +{ + ui->setupUi(this); + + m_oauthTwitter = new OAuthTwitter(new QNetworkAccessManager, this); + connect(m_oauthTwitter, SIGNAL(authorizeXAuthFinished()), SLOT(onAuthorizeFinished())); + connect(m_oauthTwitter, SIGNAL(authorizeXAuthError()), SLOT(onAuthorizeError())); + + m_userStream = new QTweetUserStream(this); + m_userStream->setOAuthTwitter(m_oauthTwitter); + connect(m_userStream, SIGNAL(stream(QByteArray)), SLOT(stream(QByteArray))); + connect(m_userStream, SIGNAL(statusesStream(QTweetStatus)), SLOT(statusStream(QTweetStatus))); + + connect(ui->connectButton, SIGNAL(clicked()), SLOT(onConnectButtonClicked())); + + //for internal purposes + m_file.setFileName("logstream.txt"); + m_file.open(QIODevice::WriteOnly | QIODevice::Text); + + m_streamlogger.setDevice(&m_file); + +} + +UserStream::~UserStream() +{ + delete ui; +} + +void UserStream::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void UserStream::onConnectButtonClicked() +{ + m_oauthTwitter->authorizeXAuth(ui->usernameLineEdit->text(), ui->passwordLineEdit->text()); + ui->infoTextBrowser->append("XAuth authorization started"); + ui->connectButton->setEnabled(false); +} + +void UserStream::onAuthorizeFinished() +{ + ui->infoTextBrowser->append("XAuth authorization success."); + ui->infoTextBrowser->append("oauth token: " + m_oauthTwitter->oauthToken()); + ui->infoTextBrowser->append("oauth token secret: " + m_oauthTwitter->oauthTokenSecret()); + ui->infoTextBrowser->append("Starting user stream fetching"); + + m_userStream->startFetching(); +} + +void UserStream::onAuthorizeError() +{ + ui->infoTextBrowser->append("XAuth authorization error"); + ui->connectButton->setEnabled(true); +} + +void UserStream::stream(const QByteArray &stream) +{ + //for internal purposes + m_streamlogger << stream << "\n"; + m_streamlogger << "################################################################" << "\n"; + m_streamlogger.flush(); +} + +void UserStream::statusStream(const QTweetStatus &tweet) +{ + ui->infoTextBrowser->append("New tweet"); + ui->infoTextBrowser->append("id: " + QString::number(tweet.id())); + ui->infoTextBrowser->append("text: " + tweet.text()); + ui->infoTextBrowser->append("name: " + tweet.user().name()); +} diff --git a/thirdparty/QTweetLib/examples/userstream/userstream.h b/thirdparty/QTweetLib/examples/userstream/userstream.h new file mode 100644 index 000000000..1e462dcb9 --- /dev/null +++ b/thirdparty/QTweetLib/examples/userstream/userstream.h @@ -0,0 +1,62 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef USERSTREAM_H +#define USERSTREAM_H + +#include +#include +#include + +namespace Ui { + class UserStream; +} + +class OAuthTwitter; +class QTweetUserStream; +class QTweetStatus; + +class UserStream : public QWidget +{ + Q_OBJECT + +public: + explicit UserStream(QWidget *parent = 0); + ~UserStream(); + +protected: + void changeEvent(QEvent *e); + +private slots: + void onConnectButtonClicked(); + void onAuthorizeFinished(); + void onAuthorizeError(); + void stream(const QByteArray& stream); + void statusStream(const QTweetStatus& tweet); + +private: + Ui::UserStream *ui; + OAuthTwitter *m_oauthTwitter; + QTweetUserStream *m_userStream; + QTextStream m_streamlogger; + QFile m_file; +}; + +#endif // USERSTREAM_H diff --git a/thirdparty/QTweetLib/examples/userstream/userstream.pro b/thirdparty/QTweetLib/examples/userstream/userstream.pro new file mode 100644 index 000000000..ec24d670e --- /dev/null +++ b/thirdparty/QTweetLib/examples/userstream/userstream.pro @@ -0,0 +1,17 @@ +QT += core gui network + +TARGET = userstream +TEMPLATE = app +win32:LIBS += ../../lib/QTweetLib.lib +INCLUDEPATH += ../../src + + +SOURCES += \ + main.cpp \ + userstream.cpp + +HEADERS += \ + userstream.h + +FORMS += \ + userstream.ui diff --git a/thirdparty/QTweetLib/examples/userstream/userstream.ui b/thirdparty/QTweetLib/examples/userstream/userstream.ui new file mode 100644 index 000000000..db90f1ac6 --- /dev/null +++ b/thirdparty/QTweetLib/examples/userstream/userstream.ui @@ -0,0 +1,63 @@ + + + UserStream + + + + 0 + 0 + 418 + 529 + + + + Form + + + + + + + + + + + + + Username: + + + + + + + + + + Password: + + + + + + + QLineEdit::Password + + + + + + + + + Connect + + + + + + + + + + diff --git a/thirdparty/QTweetLib/qjson/json_parser.cc b/thirdparty/QTweetLib/qjson/json_parser.cc new file mode 100644 index 000000000..620e135a8 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/json_parser.cc @@ -0,0 +1,1116 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison LALR(1) parsers in C++ + + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + + +#include "json_parser.hh" + +/* User implementation prologue. */ + + +/* Line 317 of lalr1.cc. */ +#line 43 "json_parser.cc" + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* FIXME: INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#define YYUSE(e) ((void) (e)) + +/* A pseudo ostream that takes yydebug_ into account. */ +# define YYCDEBUG \ + for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \ + (*yycdebug_) + +/* Enable debugging if requested. */ +#if YYDEBUG + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug_) \ + { \ + *yycdebug_ << Title << ' '; \ + yy_symbol_print_ ((Type), (Value), (Location)); \ + *yycdebug_ << std::endl; \ + } \ +} while (false) + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug_) \ + yy_reduce_print_ (Rule); \ +} while (false) + +# define YY_STACK_PRINT() \ +do { \ + if (yydebug_) \ + yystack_print_ (); \ +} while (false) + +#else /* !YYDEBUG */ + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_REDUCE_PRINT(Rule) +# define YY_STACK_PRINT() + +#endif /* !YYDEBUG */ + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + +namespace yy +{ +#if YYERROR_VERBOSE + + /* Return YYSTR after stripping away unnecessary quotes and + backslashes, so that it's suitable for yyerror. The heuristic is + that double-quoting is unnecessary unless the string contains an + apostrophe, a comma, or backslash (other than backslash-backslash). + YYSTR is taken from yytname. */ + std::string + json_parser::yytnamerr_ (const char *yystr) + { + if (*yystr == '"') + { + std::string yyr = ""; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + yyr += *yyp; + break; + + case '"': + return yyr; + } + do_not_strip_quotes: ; + } + + return yystr; + } + +#endif + + /// Build a parser object. + json_parser::json_parser (QJson::ParserPrivate* driver_yyarg) + : yydebug_ (false), + yycdebug_ (&std::cerr), + driver (driver_yyarg) + { + } + + json_parser::~json_parser () + { + } + +#if YYDEBUG + /*--------------------------------. + | Print this symbol on YYOUTPUT. | + `--------------------------------*/ + + inline void + json_parser::yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, const location_type* yylocationp) + { + YYUSE (yylocationp); + YYUSE (yyvaluep); + switch (yytype) + { + default: + break; + } + } + + + void + json_parser::yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, const location_type* yylocationp) + { + *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") + << ' ' << yytname_[yytype] << " (" + << *yylocationp << ": "; + yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); + *yycdebug_ << ')'; + } +#endif /* ! YYDEBUG */ + + void + json_parser::yydestruct_ (const char* yymsg, + int yytype, semantic_type* yyvaluep, location_type* yylocationp) + { + YYUSE (yylocationp); + YYUSE (yymsg); + YYUSE (yyvaluep); + + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } + } + + void + json_parser::yypop_ (unsigned int n) + { + yystate_stack_.pop (n); + yysemantic_stack_.pop (n); + yylocation_stack_.pop (n); + } + + std::ostream& + json_parser::debug_stream () const + { + return *yycdebug_; + } + + void + json_parser::set_debug_stream (std::ostream& o) + { + yycdebug_ = &o; + } + + + json_parser::debug_level_type + json_parser::debug_level () const + { + return yydebug_; + } + + void + json_parser::set_debug_level (debug_level_type l) + { + yydebug_ = l; + } + + + int + json_parser::parse () + { + /// Look-ahead and look-ahead in internal form. + int yychar = yyempty_; + int yytoken = 0; + + /* State. */ + int yyn; + int yylen = 0; + int yystate = 0; + + /* Error handling. */ + int yynerrs_ = 0; + int yyerrstatus_ = 0; + + /// Semantic value of the look-ahead. + semantic_type yylval; + /// Location of the look-ahead. + location_type yylloc; + /// The locations where the error started and ended. + location yyerror_range[2]; + + /// $$. + semantic_type yyval; + /// @$. + location_type yyloc; + + int yyresult; + + YYCDEBUG << "Starting parse" << std::endl; + + + /* Initialize the stacks. The initial state will be pushed in + yynewstate, since the latter expects the semantical and the + location values to have been already stored, initialize these + stacks with a primary value. */ + yystate_stack_ = state_stack_type (0); + yysemantic_stack_ = semantic_stack_type (0); + yylocation_stack_ = location_stack_type (0); + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yylloc); + + /* New state. */ + yynewstate: + yystate_stack_.push (yystate); + YYCDEBUG << "Entering state " << yystate << std::endl; + goto yybackup; + + /* Backup. */ + yybackup: + + /* Try to take a decision without look-ahead. */ + yyn = yypact_[yystate]; + if (yyn == yypact_ninf_) + goto yydefault; + + /* Read a look-ahead token. */ + if (yychar == yyempty_) + { + YYCDEBUG << "Reading a token: "; + yychar = yylex (&yylval, &yylloc, driver); + } + + + /* Convert token to internal form. */ + if (yychar <= yyeof_) + { + yychar = yytoken = yyeof_; + YYCDEBUG << "Now at end of input." << std::endl; + } + else + { + yytoken = yytranslate_ (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) + goto yydefault; + + /* Reduce or error. */ + yyn = yytable_[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == yytable_ninf_) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Accept? */ + if (yyn == yyfinal_) + goto yyacceptlab; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != yyeof_) + yychar = yyempty_; + + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yylloc); + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus_) + --yyerrstatus_; + + yystate = yyn; + goto yynewstate; + + /*-----------------------------------------------------------. + | yydefault -- do the default action for the current state. | + `-----------------------------------------------------------*/ + yydefault: + yyn = yydefact_[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + /*-----------------------------. + | yyreduce -- Do a reduction. | + `-----------------------------*/ + yyreduce: + yylen = yyr2_[yyn]; + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. Otherwise, use the top of the stack. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. */ + if (yylen) + yyval = yysemantic_stack_[yylen - 1]; + else + yyval = yysemantic_stack_[0]; + + { + slice slice (yylocation_stack_, yylen); + YYLLOC_DEFAULT (yyloc, slice, yylen); + } + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 84 "json_parser.yy" + { + driver->m_result = (yysemantic_stack_[(1) - (1)]); + qjsonDebug() << "json_parser - parsing finished"; + ;} + break; + + case 3: +#line 89 "json_parser.yy" + { (yyval) = (yysemantic_stack_[(1) - (1)]); ;} + break; + + case 4: +#line 91 "json_parser.yy" + { + qCritical()<< "json_parser - syntax error found, " + << "forcing abort, Line" << (yyloc).begin.line << "Column" << (yyloc).begin.column; + YYABORT; + ;} + break; + + case 6: +#line 98 "json_parser.yy" + { (yyval) = (yysemantic_stack_[(3) - (2)]); ;} + break; + + case 7: +#line 100 "json_parser.yy" + { (yyval) = QVariant (QVariantMap()); ;} + break; + + case 8: +#line 101 "json_parser.yy" + { + QVariantMap members = (yysemantic_stack_[(2) - (2)]).toMap(); + (yysemantic_stack_[(2) - (2)]) = QVariant(); // Allow reuse of map + (yyval) = QVariant(members.unite ((yysemantic_stack_[(2) - (1)]).toMap())); + ;} + break; + + case 9: +#line 107 "json_parser.yy" + { (yyval) = QVariant (QVariantMap()); ;} + break; + + case 10: +#line 108 "json_parser.yy" + { + QVariantMap members = (yysemantic_stack_[(3) - (3)]).toMap(); + (yysemantic_stack_[(3) - (3)]) = QVariant(); // Allow reuse of map + (yyval) = QVariant(members.unite ((yysemantic_stack_[(3) - (2)]).toMap())); + ;} + break; + + case 11: +#line 114 "json_parser.yy" + { + QVariantMap pair; + pair.insert ((yysemantic_stack_[(3) - (1)]).toString(), QVariant((yysemantic_stack_[(3) - (3)]))); + (yyval) = QVariant (pair); + ;} + break; + + case 12: +#line 120 "json_parser.yy" + { (yyval) = (yysemantic_stack_[(3) - (2)]); ;} + break; + + case 13: +#line 122 "json_parser.yy" + { (yyval) = QVariant (QVariantList()); ;} + break; + + case 14: +#line 123 "json_parser.yy" + { + QVariantList members = (yysemantic_stack_[(2) - (2)]).toList(); + (yysemantic_stack_[(2) - (2)]) = QVariant(); // Allow reuse of list + members.prepend ((yysemantic_stack_[(2) - (1)])); + (yyval) = QVariant(members); + ;} + break; + + case 15: +#line 130 "json_parser.yy" + { (yyval) = QVariant (QVariantList()); ;} + break; + + case 16: +#line 131 "json_parser.yy" + { + QVariantList members = (yysemantic_stack_[(3) - (3)]).toList(); + (yysemantic_stack_[(3) - (3)]) = QVariant(); // Allow reuse of list + members.prepend ((yysemantic_stack_[(3) - (2)])); + (yyval) = QVariant(members); + ;} + break; + + case 17: +#line 138 "json_parser.yy" + { (yyval) = (yysemantic_stack_[(1) - (1)]); ;} + break; + + case 18: +#line 139 "json_parser.yy" + { (yyval) = (yysemantic_stack_[(1) - (1)]); ;} + break; + + case 19: +#line 140 "json_parser.yy" + { (yyval) = (yysemantic_stack_[(1) - (1)]); ;} + break; + + case 20: +#line 141 "json_parser.yy" + { (yyval) = (yysemantic_stack_[(1) - (1)]); ;} + break; + + case 21: +#line 142 "json_parser.yy" + { (yyval) = QVariant (true); ;} + break; + + case 22: +#line 143 "json_parser.yy" + { (yyval) = QVariant (false); ;} + break; + + case 23: +#line 144 "json_parser.yy" + { + QVariant null_variant; + (yyval) = null_variant; + ;} + break; + + case 24: +#line 149 "json_parser.yy" + { (yyval) = QVariant(QVariant::Double); (yyval).setValue( -std::numeric_limits::infinity() ); ;} + break; + + case 25: +#line 150 "json_parser.yy" + { (yyval) = QVariant(QVariant::Double); (yyval).setValue( std::numeric_limits::infinity() ); ;} + break; + + case 26: +#line 151 "json_parser.yy" + { (yyval) = QVariant(QVariant::Double); (yyval).setValue( std::numeric_limits::quiet_NaN() ); ;} + break; + + case 28: +#line 154 "json_parser.yy" + { + if ((yysemantic_stack_[(1) - (1)]).toByteArray().startsWith('-')) { + (yyval) = QVariant (QVariant::LongLong); + (yyval).setValue((yysemantic_stack_[(1) - (1)]).toLongLong()); + } + else { + (yyval) = QVariant (QVariant::ULongLong); + (yyval).setValue((yysemantic_stack_[(1) - (1)]).toULongLong()); + } + ;} + break; + + case 29: +#line 164 "json_parser.yy" + { + const QByteArray value = (yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray(); + (yyval) = QVariant(QVariant::Double); + (yyval).setValue(value.toDouble()); + ;} + break; + + case 30: +#line 169 "json_parser.yy" + { (yyval) = QVariant ((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;} + break; + + case 31: +#line 170 "json_parser.yy" + { + const QByteArray value = (yysemantic_stack_[(3) - (1)]).toByteArray() + (yysemantic_stack_[(3) - (2)]).toByteArray() + (yysemantic_stack_[(3) - (3)]).toByteArray(); + (yyval) = QVariant (value); + ;} + break; + + case 32: +#line 175 "json_parser.yy" + { (yyval) = QVariant ((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;} + break; + + case 33: +#line 176 "json_parser.yy" + { (yyval) = QVariant (QByteArray("-") + (yysemantic_stack_[(3) - (2)]).toByteArray() + (yysemantic_stack_[(3) - (3)]).toByteArray()); ;} + break; + + case 34: +#line 178 "json_parser.yy" + { (yyval) = QVariant (QByteArray("")); ;} + break; + + case 35: +#line 179 "json_parser.yy" + { + (yyval) = QVariant((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); + ;} + break; + + case 36: +#line 183 "json_parser.yy" + { + (yyval) = QVariant(QByteArray(".") + (yysemantic_stack_[(2) - (2)]).toByteArray()); + ;} + break; + + case 37: +#line 187 "json_parser.yy" + { (yyval) = QVariant((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;} + break; + + case 38: +#line 189 "json_parser.yy" + { (yyval) = (yysemantic_stack_[(3) - (2)]); ;} + break; + + case 39: +#line 191 "json_parser.yy" + { (yyval) = QVariant (QString(QLatin1String(""))); ;} + break; + + case 40: +#line 192 "json_parser.yy" + { + (yyval) = (yysemantic_stack_[(1) - (1)]); + ;} + break; + + + /* Line 675 of lalr1.cc. */ +#line 628 "json_parser.cc" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); + + yypop_ (yylen); + yylen = 0; + YY_STACK_PRINT (); + + yysemantic_stack_.push (yyval); + yylocation_stack_.push (yyloc); + + /* Shift the result of the reduction. */ + yyn = yyr1_[yyn]; + yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; + if (0 <= yystate && yystate <= yylast_ + && yycheck_[yystate] == yystate_stack_[0]) + yystate = yytable_[yystate]; + else + yystate = yydefgoto_[yyn - yyntokens_]; + goto yynewstate; + + /*------------------------------------. + | yyerrlab -- here on detecting error | + `------------------------------------*/ + yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus_) + { + ++yynerrs_; + error (yylloc, yysyntax_error_ (yystate, yytoken)); + } + + yyerror_range[0] = yylloc; + if (yyerrstatus_ == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= yyeof_) + { + /* Return failure if at end of input. */ + if (yychar == yyeof_) + YYABORT; + } + else + { + yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); + yychar = yyempty_; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + + /*---------------------------------------------------. + | yyerrorlab -- error raised explicitly by YYERROR. | + `---------------------------------------------------*/ + yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (false) + goto yyerrorlab; + + yyerror_range[0] = yylocation_stack_[yylen - 1]; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + yypop_ (yylen); + yylen = 0; + yystate = yystate_stack_[0]; + goto yyerrlab1; + + /*-------------------------------------------------------------. + | yyerrlab1 -- common code for both syntax error and YYERROR. | + `-------------------------------------------------------------*/ + yyerrlab1: + yyerrstatus_ = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact_[yystate]; + if (yyn != yypact_ninf_) + { + yyn += yyterror_; + if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) + { + yyn = yytable_[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yystate_stack_.height () == 1) + YYABORT; + + yyerror_range[0] = yylocation_stack_[0]; + yydestruct_ ("Error: popping", + yystos_[yystate], + &yysemantic_stack_[0], &yylocation_stack_[0]); + yypop_ (); + yystate = yystate_stack_[0]; + YY_STACK_PRINT (); + } + + if (yyn == yyfinal_) + goto yyacceptlab; + + yyerror_range[1] = yylloc; + // Using YYLLOC is tempting, but would change the location of + // the look-ahead. YYLOC is available though. + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); + yysemantic_stack_.push (yylval); + yylocation_stack_.push (yyloc); + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], + &yysemantic_stack_[0], &yylocation_stack_[0]); + + yystate = yyn; + goto yynewstate; + + /* Accept. */ + yyacceptlab: + yyresult = 0; + goto yyreturn; + + /* Abort. */ + yyabortlab: + yyresult = 1; + goto yyreturn; + + yyreturn: + if (yychar != yyeof_ && yychar != yyempty_) + yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); + + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + yypop_ (yylen); + while (yystate_stack_.height () != 1) + { + yydestruct_ ("Cleanup: popping", + yystos_[yystate_stack_[0]], + &yysemantic_stack_[0], + &yylocation_stack_[0]); + yypop_ (); + } + + return yyresult; + } + + // Generate an error message. + std::string + json_parser::yysyntax_error_ (int yystate, int tok) + { + std::string res; + YYUSE (yystate); +#if YYERROR_VERBOSE + int yyn = yypact_[yystate]; + if (yypact_ninf_ < yyn && yyn <= yylast_) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = yylast_ - yyn + 1; + int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; + int count = 0; + for (int x = yyxbegin; x < yyxend; ++x) + if (yycheck_[x + yyn] == x && x != yyterror_) + ++count; + + // FIXME: This method of building the message is not compatible + // with internationalization. It should work like yacc.c does it. + // That is, first build a string that looks like this: + // "syntax error, unexpected %s or %s or %s" + // Then, invoke YY_ on this string. + // Finally, use the string as a format to output + // yytname_[tok], etc. + // Until this gets fixed, this message appears in English only. + res = "syntax error, unexpected "; + res += yytnamerr_ (yytname_[tok]); + if (count < 5) + { + count = 0; + for (int x = yyxbegin; x < yyxend; ++x) + if (yycheck_[x + yyn] == x && x != yyterror_) + { + res += (!count++) ? ", expecting " : " or "; + res += yytnamerr_ (yytname_[x]); + } + } + } + else +#endif + res = YY_("syntax error"); + return res; + } + + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ + const signed char json_parser::yypact_ninf_ = -21; + const signed char + json_parser::yypact_[] = + { + 3, -21, -21, -6, 31, -10, 0, -21, -21, -21, + 6, -21, -21, 25, -21, -21, -21, -21, -21, -21, + -5, -21, 22, 19, 21, 23, 24, 0, -21, 0, + -21, -21, 13, -21, 0, 0, 29, -21, -21, -6, + -21, 31, -21, 31, -21, -21, -21, -21, -21, -21, + -21, 19, -21, 24, -21, -21 + }; + + /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE + doesn't specify something else to do. Zero means the default is an + error. */ + const unsigned char + json_parser::yydefact_[] = + { + 0, 5, 4, 7, 13, 0, 34, 21, 22, 23, + 39, 25, 26, 0, 2, 19, 20, 3, 18, 27, + 28, 17, 0, 9, 0, 0, 15, 34, 24, 34, + 32, 40, 0, 1, 34, 34, 29, 30, 6, 0, + 8, 0, 12, 0, 14, 33, 35, 38, 36, 37, + 31, 9, 11, 15, 10, 16 + }; + + /* YYPGOTO[NTERM-NUM]. */ + const signed char + json_parser::yypgoto_[] = + { + -21, -21, -21, -21, -21, -20, 4, -21, -21, -18, + -4, -21, -21, -21, -14, -21, -3, -1, -21 + }; + + /* YYDEFGOTO[NTERM-NUM]. */ + const signed char + json_parser::yydefgoto_[] = + { + -1, 13, 14, 15, 22, 40, 23, 16, 25, 44, + 17, 18, 19, 20, 30, 36, 37, 21, 32 + }; + + /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. */ + const signed char json_parser::yytable_ninf_ = -1; + const unsigned char + json_parser::yytable_[] = + { + 26, 27, 24, 1, 2, 34, 3, 35, 4, 28, + 10, 29, 5, 45, 6, 46, 7, 8, 9, 10, + 48, 49, 11, 12, 31, 33, 38, 39, 41, 42, + 47, 54, 43, 50, 3, 55, 4, 52, 24, 53, + 5, 35, 6, 51, 7, 8, 9, 10, 0, 0, + 11, 12 + }; + + /* YYCHECK. */ + const signed char + json_parser::yycheck_[] = + { + 4, 11, 3, 0, 1, 10, 3, 12, 5, 19, + 16, 11, 9, 27, 11, 29, 13, 14, 15, 16, + 34, 35, 19, 20, 18, 0, 4, 8, 7, 6, + 17, 51, 8, 36, 3, 53, 5, 41, 39, 43, + 9, 12, 11, 39, 13, 14, 15, 16, -1, -1, + 19, 20 + }; + + /* STOS_[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ + const unsigned char + json_parser::yystos_[] = + { + 0, 0, 1, 3, 5, 9, 11, 13, 14, 15, + 16, 19, 20, 22, 23, 24, 28, 31, 32, 33, + 34, 38, 25, 27, 38, 29, 31, 11, 19, 11, + 35, 18, 39, 0, 10, 12, 36, 37, 4, 8, + 26, 7, 6, 8, 30, 35, 35, 17, 35, 35, + 37, 27, 31, 31, 26, 30 + }; + +#if YYDEBUG + /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding + to YYLEX-NUM. */ + const unsigned short int + json_parser::yytoken_number_[] = + { + 0, 256, 257, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18 + }; +#endif + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ + const unsigned char + json_parser::yyr1_[] = + { + 0, 21, 22, 23, 23, 23, 24, 25, 25, 26, + 26, 27, 28, 29, 29, 30, 30, 31, 31, 31, + 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, + 33, 33, 34, 34, 35, 35, 36, 37, 38, 39, + 39 + }; + + /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ + const unsigned char + json_parser::yyr2_[] = + { + 0, 2, 1, 1, 1, 1, 3, 0, 2, 0, + 3, 3, 3, 0, 2, 0, 3, 1, 1, 1, + 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, + 2, 3, 2, 3, 0, 2, 2, 2, 3, 0, + 1 + }; + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at \a yyntokens_, nonterminals. */ + const char* + const json_parser::yytname_[] = + { + "\"end of file\"", "error", "$undefined", "\"{\"", "\"}\"", "\"[\"", + "\"]\"", "\":\"", "\",\"", "\"-\"", "\".\"", "\"digit\"", + "\"exponential\"", "\"true\"", "\"false\"", "\"null\"", + "\"open quotation mark\"", "\"close quotation mark\"", "\"string\"", + "\"Infinity\"", "\"NaN\"", "$accept", "start", "data", "object", + "members", "r_members", "pair", "array", "values", "r_values", "value", + "special_or_number", "number", "int", "digits", "fract", "exp", "string", + "string_arg", 0 + }; +#endif + +#if YYDEBUG + /* YYRHS -- A `-1'-separated list of the rules' RHS. */ + const json_parser::rhs_number_type + json_parser::yyrhs_[] = + { + 22, 0, -1, 23, -1, 31, -1, 1, -1, 0, + -1, 3, 25, 4, -1, -1, 27, 26, -1, -1, + 8, 27, 26, -1, 38, 7, 31, -1, 5, 29, + 6, -1, -1, 31, 30, -1, -1, 8, 31, 30, + -1, 38, -1, 32, -1, 24, -1, 28, -1, 13, + -1, 14, -1, 15, -1, 9, 19, -1, 19, -1, + 20, -1, 33, -1, 34, -1, 34, 36, -1, 34, + 37, -1, 34, 36, 37, -1, 11, 35, -1, 9, + 11, 35, -1, -1, 11, 35, -1, 10, 35, -1, + 12, 35, -1, 16, 39, 17, -1, -1, 18, -1 + }; + + /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ + const unsigned char + json_parser::yyprhs_[] = + { + 0, 0, 3, 5, 7, 9, 11, 15, 16, 19, + 20, 24, 28, 32, 33, 36, 37, 41, 43, 45, + 47, 49, 51, 53, 55, 58, 60, 62, 64, 66, + 69, 72, 76, 79, 83, 84, 87, 90, 93, 97, + 98 + }; + + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ + const unsigned char + json_parser::yyrline_[] = + { + 0, 84, 84, 89, 90, 96, 98, 100, 101, 107, + 108, 114, 120, 122, 123, 130, 131, 138, 139, 140, + 141, 142, 143, 144, 149, 150, 151, 152, 154, 164, + 169, 170, 175, 176, 178, 179, 183, 187, 189, 191, + 192 + }; + + // Print the state stack on the debug stream. + void + json_parser::yystack_print_ () + { + *yycdebug_ << "Stack now"; + for (state_stack_type::const_iterator i = yystate_stack_.begin (); + i != yystate_stack_.end (); ++i) + *yycdebug_ << ' ' << *i; + *yycdebug_ << std::endl; + } + + // Report on the debug stream that the rule \a yyrule is going to be reduced. + void + json_parser::yy_reduce_print_ (int yyrule) + { + unsigned int yylno = yyrline_[yyrule]; + int yynrhs = yyr2_[yyrule]; + /* Print the symbols being reduced, and their result. */ + *yycdebug_ << "Reducing stack by rule " << yyrule - 1 + << " (line " << yylno << "), "; + /* The symbols being reduced. */ + for (int yyi = 0; yyi < yynrhs; yyi++) + YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", + yyrhs_[yyprhs_[yyrule] + yyi], + &(yysemantic_stack_[(yynrhs) - (yyi + 1)]), + &(yylocation_stack_[(yynrhs) - (yyi + 1)])); + } +#endif // YYDEBUG + + /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ + json_parser::token_number_type + json_parser::yytranslate_ (int t) + { + static + const token_number_type + translate_table[] = + { + 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2 + }; + if ((unsigned int) t <= yyuser_token_number_max_) + return translate_table[t]; + else + return yyundef_token_; + } + + const int json_parser::yyeof_ = 0; + const int json_parser::yylast_ = 51; + const int json_parser::yynnts_ = 19; + const int json_parser::yyempty_ = -2; + const int json_parser::yyfinal_ = 33; + const int json_parser::yyterror_ = 1; + const int json_parser::yyerrcode_ = 256; + const int json_parser::yyntokens_ = 21; + + const unsigned int json_parser::yyuser_token_number_max_ = 257; + const json_parser::token_number_type json_parser::yyundef_token_ = 2; + +} // namespace yy + +#line 196 "json_parser.yy" + + +int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver) +{ + JSonScanner* scanner = driver->m_scanner; + yylval->clear(); + int ret = scanner->yylex(yylval, yylloc); + + qjsonDebug() << "json_parser::yylex - calling scanner yylval==|" + << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|"; + + return ret; +} + +void yy::json_parser::error (const yy::location& yyloc, + const std::string& error) +{ + /*qjsonDebug() << yyloc.begin.line; + qjsonDebug() << yyloc.begin.column; + qjsonDebug() << yyloc.end.line; + qjsonDebug() << yyloc.end.column;*/ + qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ; + driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line); +} + diff --git a/thirdparty/QTweetLib/qjson/json_parser.hh b/thirdparty/QTweetLib/qjson/json_parser.hh new file mode 100644 index 000000000..e61ca7c64 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/json_parser.hh @@ -0,0 +1,325 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison LALR(1) parsers in C++ + + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C++ LALR(1) parser skeleton written by Akim Demaille. */ + +#ifndef PARSER_HEADER_H +# define PARSER_HEADER_H + +#include +#include +#include "stack.hh" + +namespace yy +{ + class position; + class location; +} + +/* First part of user declarations. */ +#line 25 "json_parser.yy" + + #include "parser_p.h" + #include "json_scanner.h" + #include "qjson_debug.h" + + #include + #include + #include + #include + + #include + + class JSonScanner; + + namespace QJson { + class Parser; + } + + #define YYERROR_VERBOSE 1 + + +/* Line 35 of lalr1.cc. */ +#line 75 "json_parser.hh" + +#include "location.hh" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 1 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ +do { \ + if (N) \ + { \ + (Current).begin = (Rhs)[1].begin; \ + (Current).end = (Rhs)[N].end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = (Rhs)[0].end; \ + } \ +} while (false) +#endif + +namespace yy +{ + + /// A Bison parser. + class json_parser + { + public: + /// Symbol semantic values. +#ifndef YYSTYPE + typedef int semantic_type; +#else + typedef YYSTYPE semantic_type; +#endif + /// Symbol locations. + typedef location location_type; + /// Tokens. + struct token + { + /* Tokens. */ + enum yytokentype { + END = 0, + CURLY_BRACKET_OPEN = 1, + CURLY_BRACKET_CLOSE = 2, + SQUARE_BRACKET_OPEN = 3, + SQUARE_BRACKET_CLOSE = 4, + COLON = 5, + COMMA = 6, + MINUS = 7, + DOT = 8, + DIGIT = 9, + E = 10, + TRUE_VAL = 11, + FALSE_VAL = 12, + NULL_VAL = 13, + QUOTMARKOPEN = 14, + QUOTMARKCLOSE = 15, + STRING = 16, + INFINITY_VAL = 17, + NAN_VAL = 18 + }; + + }; + /// Token type. + typedef token::yytokentype token_type; + + /// Build a parser object. + json_parser (QJson::ParserPrivate* driver_yyarg); + virtual ~json_parser (); + + /// Parse. + /// \returns 0 iff parsing succeeded. + virtual int parse (); + + /// The current debugging stream. + std::ostream& debug_stream () const; + /// Set the current debugging stream. + void set_debug_stream (std::ostream &); + + /// Type for debugging levels. + typedef int debug_level_type; + /// The current debugging level. + debug_level_type debug_level () const; + /// Set the current debugging level. + void set_debug_level (debug_level_type l); + + private: + /// Report a syntax error. + /// \param loc where the syntax error is found. + /// \param msg a description of the syntax error. + virtual void error (const location_type& loc, const std::string& msg); + + /// Generate an error message. + /// \param state the state where the error occurred. + /// \param tok the look-ahead token. + virtual std::string yysyntax_error_ (int yystate, int tok); + +#if YYDEBUG + /// \brief Report a symbol value on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_value_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); + /// \brief Report a symbol on the debug stream. + /// \param yytype The token type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + virtual void yy_symbol_print_ (int yytype, + const semantic_type* yyvaluep, + const location_type* yylocationp); +#endif /* ! YYDEBUG */ + + + /// State numbers. + typedef int state_type; + /// State stack type. + typedef stack state_stack_type; + /// Semantic value stack type. + typedef stack semantic_stack_type; + /// location stack type. + typedef stack location_stack_type; + + /// The state stack. + state_stack_type yystate_stack_; + /// The semantic value stack. + semantic_stack_type yysemantic_stack_; + /// The location stack. + location_stack_type yylocation_stack_; + + /// Internal symbol numbers. + typedef unsigned char token_number_type; + /* Tables. */ + /// For a state, the index in \a yytable_ of its portion. + static const signed char yypact_[]; + static const signed char yypact_ninf_; + + /// For a state, default rule to reduce. + /// Unless\a yytable_ specifies something else to do. + /// Zero means the default is an error. + static const unsigned char yydefact_[]; + + static const signed char yypgoto_[]; + static const signed char yydefgoto_[]; + + /// What to do in a state. + /// \a yytable_[yypact_[s]]: what to do in state \a s. + /// - if positive, shift that token. + /// - if negative, reduce the rule which number is the opposite. + /// - if zero, do what YYDEFACT says. + static const unsigned char yytable_[]; + static const signed char yytable_ninf_; + + static const signed char yycheck_[]; + + /// For a state, its accessing symbol. + static const unsigned char yystos_[]; + + /// For a rule, its LHS. + static const unsigned char yyr1_[]; + /// For a rule, its RHS length. + static const unsigned char yyr2_[]; + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE + /// For a symbol, its name in clear. + static const char* const yytname_[]; +#endif + +#if YYERROR_VERBOSE + /// Convert the symbol name \a n to a form suitable for a diagnostic. + virtual std::string yytnamerr_ (const char *n); +#endif + +#if YYDEBUG + /// A type to store symbol numbers and -1. + typedef signed char rhs_number_type; + /// A `-1'-separated list of the rules' RHS. + static const rhs_number_type yyrhs_[]; + /// For each rule, the index of the first RHS symbol in \a yyrhs_. + static const unsigned char yyprhs_[]; + /// For each rule, its source line number. + static const unsigned char yyrline_[]; + /// For each scanner token number, its symbol number. + static const unsigned short int yytoken_number_[]; + /// Report on the debug stream that the rule \a r is going to be reduced. + virtual void yy_reduce_print_ (int r); + /// Print the state stack on the debug stream. + virtual void yystack_print_ (); +#endif + + /// Convert a scanner token number \a t to a symbol number. + token_number_type yytranslate_ (int t); + + /// \brief Reclaim the memory associated to a symbol. + /// \param yymsg Why this token is reclaimed. + /// \param yytype The symbol type. + /// \param yyvaluep Its semantic value. + /// \param yylocationp Its location. + inline void yydestruct_ (const char* yymsg, + int yytype, + semantic_type* yyvaluep, + location_type* yylocationp); + + /// Pop \a n symbols the three stacks. + inline void yypop_ (unsigned int n = 1); + + /* Constants. */ + static const int yyeof_; + /* LAST_ -- Last index in TABLE_. */ + static const int yylast_; + static const int yynnts_; + static const int yyempty_; + static const int yyfinal_; + static const int yyterror_; + static const int yyerrcode_; + static const int yyntokens_; + static const unsigned int yyuser_token_number_max_; + static const token_number_type yyundef_token_; + + /* Debugging. */ + int yydebug_; + std::ostream* yycdebug_; + + + /* User arguments. */ + QJson::ParserPrivate* driver; + }; +} + + +#endif /* ! defined PARSER_HEADER_H */ diff --git a/thirdparty/QTweetLib/qjson/json_parser.yy b/thirdparty/QTweetLib/qjson/json_parser.yy new file mode 100644 index 000000000..76c698a56 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/json_parser.yy @@ -0,0 +1,219 @@ +/* This file is part of QJSon + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +%skeleton "lalr1.cc" +%defines +%define "parser_class_name" "json_parser" + +%{ + #include "parser_p.h" + #include "json_scanner.h" + #include "qjson_debug.h" + + #include + #include + #include + #include + + #include + + class JSonScanner; + + namespace QJson { + class Parser; + } + + #define YYERROR_VERBOSE 1 +%} + +%parse-param { QJson::ParserPrivate* driver } +%lex-param { QJson::ParserPrivate* driver } + +%locations + +%debug +%error-verbose + +%token END 0 "end of file" + +%token CURLY_BRACKET_OPEN 1 "{" +%token CURLY_BRACKET_CLOSE 2 "}" +%token SQUARE_BRACKET_OPEN 3 "[" +%token SQUARE_BRACKET_CLOSE 4 "]" + +%token COLON 5 ":" +%token COMMA 6 "," +%token MINUS 7 "-" +%token DOT 8 "." +%token DIGIT 9 "digit" +%token E 10 "exponential" +%token TRUE_VAL 11 "true" +%token FALSE_VAL 12 "false" +%token NULL_VAL 13 "null" +%token QUOTMARKOPEN 14 "open quotation mark" +%token QUOTMARKCLOSE 15 "close quotation mark" + +%token STRING 16 "string" +%token INFINITY_VAL 17 "Infinity" +%token NAN_VAL 18 "NaN" + +// define the initial token +%start start + +%% + +// grammar rules + +start: data { + driver->m_result = $1; + qjsonDebug() << "json_parser - parsing finished"; + }; + +data: value { $$ = $1; } + | error + { + qCritical()<< "json_parser - syntax error found, " + << "forcing abort, Line" << @$.begin.line << "Column" << @$.begin.column; + YYABORT; + } + | END; + +object: CURLY_BRACKET_OPEN members CURLY_BRACKET_CLOSE { $$ = $2; }; + +members: /* empty */ { $$ = QVariant (QVariantMap()); } + | pair r_members { + QVariantMap members = $2.toMap(); + $2 = QVariant(); // Allow reuse of map + $$ = QVariant(members.unite ($1.toMap())); + }; + +r_members: /* empty */ { $$ = QVariant (QVariantMap()); } + | COMMA pair r_members { + QVariantMap members = $3.toMap(); + $3 = QVariant(); // Allow reuse of map + $$ = QVariant(members.unite ($2.toMap())); + }; + +pair: string COLON value { + QVariantMap pair; + pair.insert ($1.toString(), QVariant($3)); + $$ = QVariant (pair); + }; + +array: SQUARE_BRACKET_OPEN values SQUARE_BRACKET_CLOSE { $$ = $2; }; + +values: /* empty */ { $$ = QVariant (QVariantList()); } + | value r_values { + QVariantList members = $2.toList(); + $2 = QVariant(); // Allow reuse of list + members.prepend ($1); + $$ = QVariant(members); + }; + +r_values: /* empty */ { $$ = QVariant (QVariantList()); } + | COMMA value r_values { + QVariantList members = $3.toList(); + $3 = QVariant(); // Allow reuse of list + members.prepend ($2); + $$ = QVariant(members); + }; + +value: string { $$ = $1; } + | special_or_number { $$ = $1; } + | object { $$ = $1; } + | array { $$ = $1; } + | TRUE_VAL { $$ = QVariant (true); } + | FALSE_VAL { $$ = QVariant (false); } + | NULL_VAL { + QVariant null_variant; + $$ = null_variant; + }; + +special_or_number: MINUS INFINITY_VAL { $$ = QVariant(QVariant::Double); $$.setValue( -std::numeric_limits::infinity() ); } + | INFINITY_VAL { $$ = QVariant(QVariant::Double); $$.setValue( std::numeric_limits::infinity() ); } + | NAN_VAL { $$ = QVariant(QVariant::Double); $$.setValue( std::numeric_limits::quiet_NaN() ); } + | number; + +number: int { + if ($1.toByteArray().startsWith('-')) { + $$ = QVariant (QVariant::LongLong); + $$.setValue($1.toLongLong()); + } + else { + $$ = QVariant (QVariant::ULongLong); + $$.setValue($1.toULongLong()); + } + } + | int fract { + const QByteArray value = $1.toByteArray() + $2.toByteArray(); + $$ = QVariant(QVariant::Double); + $$.setValue(value.toDouble()); + } + | int exp { $$ = QVariant ($1.toByteArray() + $2.toByteArray()); } + | int fract exp { + const QByteArray value = $1.toByteArray() + $2.toByteArray() + $3.toByteArray(); + $$ = QVariant (value); + }; + +int: DIGIT digits { $$ = QVariant ($1.toByteArray() + $2.toByteArray()); } + | MINUS DIGIT digits { $$ = QVariant (QByteArray("-") + $2.toByteArray() + $3.toByteArray()); }; + +digits: /* empty */ { $$ = QVariant (QByteArray("")); } + | DIGIT digits { + $$ = QVariant($1.toByteArray() + $2.toByteArray()); + }; + +fract: DOT digits { + $$ = QVariant(QByteArray(".") + $2.toByteArray()); + }; + +exp: E digits { $$ = QVariant($1.toByteArray() + $2.toByteArray()); }; + +string: QUOTMARKOPEN string_arg QUOTMARKCLOSE { $$ = $2; }; + +string_arg: /*empty */ { $$ = QVariant (QString(QLatin1String(""))); } + | STRING { + $$ = $1; + }; + +%% + +int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver) +{ + JSonScanner* scanner = driver->m_scanner; + yylval->clear(); + int ret = scanner->yylex(yylval, yylloc); + + qjsonDebug() << "json_parser::yylex - calling scanner yylval==|" + << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|"; + + return ret; +} + +void yy::json_parser::error (const yy::location& yyloc, + const std::string& error) +{ + /*qjsonDebug() << yyloc.begin.line; + qjsonDebug() << yyloc.begin.column; + qjsonDebug() << yyloc.end.line; + qjsonDebug() << yyloc.end.column;*/ + qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ; + driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line); +} diff --git a/thirdparty/QTweetLib/qjson/json_scanner.cpp b/thirdparty/QTweetLib/qjson/json_scanner.cpp new file mode 100644 index 000000000..3a829d0a6 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/json_scanner.cpp @@ -0,0 +1,377 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "qjson_debug.h" +#include "json_scanner.h" +#include "json_parser.hh" + +#include + +#include +#include + +#include + +bool ishexnstring(const QString& string) { + for (int i = 0; i < string.length(); i++) { + if (isxdigit(string[i] == 0)) + return false; + } + return true; +} + +JSonScanner::JSonScanner(QIODevice* io) + : m_allowSpecialNumbers(false), + m_io (io) +{ + m_quotmarkClosed = true; + m_quotmarkCount = 0; +} + +void JSonScanner::allowSpecialNumbers(bool allow) { + m_allowSpecialNumbers = allow; +} + +static QString unescape( const QByteArray& ba, bool* ok ) { + assert( ok ); + *ok = false; + QString res; + QByteArray seg; + bool bs = false; + for ( int i = 0, size = ba.size(); i < size; ++i ) { + const char ch = ba[i]; + if ( !bs ) { + if ( ch == '\\' ) + bs = true; + else + seg += ch; + } else { + bs = false; + switch ( ch ) { + case 'b': + seg += '\b'; + break; + case 'f': + seg += '\f'; + break; + case 'n': + seg += '\n'; + break; + case 'r': + seg += '\r'; + break; + case 't': + seg += '\t'; + break; + case 'u': + { + res += QString::fromUtf8( seg ); + seg.clear(); + + if ( i > size - 5 ) { + //error + return QString(); + } + + const QString hex_digit1 = QString::fromUtf8( ba.mid( i + 1, 2 ) ); + const QString hex_digit2 = QString::fromUtf8( ba.mid( i + 3, 2 ) ); + i += 4; + + if ( !ishexnstring( hex_digit1 ) || !ishexnstring( hex_digit2 ) ) { + qCritical() << "Not an hex string:" << hex_digit1 << hex_digit2; + return QString(); + } + bool hexOk; + const ushort hex_code1 = hex_digit1.toShort( &hexOk, 16 ); + if (!hexOk) { + qCritical() << "error converting hex value to short:" << hex_digit1; + return QString(); + } + const ushort hex_code2 = hex_digit2.toShort( &hexOk, 16 ); + if (!hexOk) { + qCritical() << "error converting hex value to short:" << hex_digit2; + return QString(); + } + + res += QChar(hex_code2, hex_code1); + break; + } + case '\\': + seg += '\\'; + break; + default: + seg += ch; + break; + } + } + } + res += QString::fromUtf8( seg ); + *ok = true; + return res; +} + +int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc) +{ + char ch; + + if (!m_io->isOpen()) { + qCritical() << "JSonScanner::yylex - io device is not open"; + return -1; + } + + yylloc->step(); + + do { + bool ret; + if (m_io->atEnd()) { + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::END"; + return yy::json_parser::token::END; + } + else + ret = m_io->getChar(&ch); + + if (!ret) { + qCritical() << "JSonScanner::yylex - error reading from io device"; + return -1; + } + + qjsonDebug() << "JSonScanner::yylex - got |" << ch << "|"; + yylloc->columns(); + + if (ch == '\n' || ch == '\r') + yylloc->lines(); + } while (m_quotmarkClosed && (isspace(ch) != 0)); + + if (m_quotmarkClosed && ((ch == 't') || (ch == 'T'))) { + const QByteArray buf = m_io->peek(3).toLower(); + if (buf == "rue") { + m_io->read (3); + yylloc->columns(3); + qjsonDebug() << "JSonScanner::yylex - TRUE_VAL"; + return yy::json_parser::token::TRUE_VAL; + } + } + else if (m_quotmarkClosed && ((ch == 'n') || (ch == 'N'))) { + const QByteArray buf = m_io->peek(3).toLower(); + if (buf == "ull") { + m_io->read (3); + yylloc->columns(3); + qjsonDebug() << "JSonScanner::yylex - NULL_VAL"; + return yy::json_parser::token::NULL_VAL; + } else if (buf.startsWith("an") && m_allowSpecialNumbers) { + m_io->read(2); + yylloc->columns(2); + qjsonDebug() << "JSonScanner::yylex - NAN_VAL"; + return yy::json_parser::token::NAN_VAL; + + } + } + else if (m_quotmarkClosed && ((ch == 'f') || (ch == 'F'))) { + // check false value + const QByteArray buf = m_io->peek(4).toLower(); + if (buf.length() == 4) { + if (buf == "alse") { + m_io->read (4); + yylloc->columns(4); + qjsonDebug() << "JSonScanner::yylex - FALSE_VAL"; + return yy::json_parser::token::FALSE_VAL; + } + } + } + else if (m_quotmarkClosed && ((ch == 'e') || (ch == 'E'))) { + QByteArray ret(1, ch); + const QByteArray buf = m_io->peek(1); + if (!buf.isEmpty()) { + if ((buf[0] == '+' ) || (buf[0] == '-' )) { + ret += m_io->read (1); + yylloc->columns(); + } + } + *yylval = QVariant(QString::fromUtf8(ret)); + return yy::json_parser::token::E; + } + else if (m_allowSpecialNumbers && m_quotmarkClosed && ((ch == 'I') || (ch == 'i'))) { + QByteArray ret(1, ch); + const QByteArray buf = m_io->peek(7); + if (buf == "nfinity") { + m_io->read(7); + yylloc->columns(7); + qjsonDebug() << "JSonScanner::yylex - INFINITY_VAL"; + return yy::json_parser::token::INFINITY_VAL; + } + } + + if (ch != '"' && !m_quotmarkClosed) { + // we're inside a " " block + QByteArray raw; + raw += ch; + char prevCh = ch; + bool escape_on = (ch == '\\') ? true : false; + + while ( true ) { + char nextCh; + qint64 ret = m_io->peek(&nextCh, 1); + if (ret != 1) { + if (m_io->atEnd()) + return yy::json_parser::token::END; + else + return -1; + } else if ( !escape_on && nextCh == '\"' ) { + bool ok; + const QString str = unescape( raw, &ok ); + *yylval = ok ? str : QString(); + return ok ? yy::json_parser::token::STRING : -1; + } +#if 0 + if ( prevCh == '\\' && nextCh != '"' && nextCh != '\\' && nextCh != '/' && + nextCh != 'b' && nextCh != 'f' && nextCh != 'n' && + nextCh != 'r' && nextCh != 't' && nextCh != 'u') { + qjsonDebug() << "Just read" << nextCh; + qjsonDebug() << "JSonScanner::yylex - error decoding escaped sequence"; + return -1; + } +#endif + m_io->read(1); // consume + raw += nextCh; + prevCh = nextCh; + if (escape_on) + escape_on = false; + else + escape_on = (prevCh == '\\') ? true : false; +#if 0 + if (nextCh == '\\') { + char buf; + if (m_io->getChar (&buf)) { + yylloc->columns(); + if (((buf != '"') && (buf != '\\') && (buf != '/') && + (buf != 'b') && (buf != 'f') && (buf != 'n') && + (buf != 'r') && (buf != 't') && (buf != 'u'))) { + qjsonDebug() << "Just read" << buf; + qjsonDebug() << "JSonScanner::yylex - error decoding escaped sequence"; + return -1; + } + } else { + qCritical() << "JSonScanner::yylex - error decoding escaped sequence : io error"; + return -1; + } + } +#endif + } + } + else if (isdigit(ch) != 0 && m_quotmarkClosed) { + bool ok; + QByteArray numArray = QByteArray::fromRawData( &ch, 1 * sizeof(char) ); + qulonglong number = numArray.toULongLong(&ok); + if (!ok) { + //This shouldn't happen + qCritical() << "JSonScanner::yylex - error while converting char to ulonglong, returning -1"; + return -1; + } + if (number == 0) { + // we have to return immediately otherwise numbers like + // 2.04 will be converted to 2.4 + *yylval = QVariant(number); + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::DIGIT"; + return yy::json_parser::token::DIGIT; + } + + char nextCh; + qint64 ret = m_io->peek(&nextCh, 1); + while (ret == 1 && isdigit(nextCh)) { + m_io->read(1); //consume + yylloc->columns(1); + numArray = QByteArray::fromRawData( &nextCh, 1 * sizeof(char) ); + number = number * 10 + numArray.toULongLong(&ok); + if (!ok) { + //This shouldn't happen + qCritical() << "JSonScanner::yylex - error while converting char to ulonglong, returning -1"; + return -1; + } + ret = m_io->peek(&nextCh, 1); + } + + *yylval = QVariant(number); + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::DIGIT"; + return yy::json_parser::token::DIGIT; + } + else if (isalnum(ch) != 0) { + *yylval = QVariant(QString(QChar::fromLatin1(ch))); + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::WORD (" + << ch << ")"; + return yy::json_parser::token::STRING; + } + else if (ch == ':') { + // set yylval + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::COLON"; + return yy::json_parser::token::COLON; + } + else if (ch == '"') { + // yy::json_parser::token::QUOTMARK (") + + // set yylval + m_quotmarkCount++; + if (m_quotmarkCount %2 == 0) { + m_quotmarkClosed = true; + m_quotmarkCount = 0; + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::QUOTMARKCLOSE"; + return yy::json_parser::token::QUOTMARKCLOSE; + } + else { + m_quotmarkClosed = false; + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::QUOTMARKOPEN"; + return yy::json_parser::token::QUOTMARKOPEN; + } + } + else if (ch == ',') { + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::COMMA"; + return yy::json_parser::token::COMMA; + } + else if (ch == '.') { + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::DOT"; + return yy::json_parser::token::DOT; + } + else if (ch == '-') { + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::MINUS"; + return yy::json_parser::token::MINUS; + } + else if (ch == '[') { + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::SQUARE_BRACKET_OPEN"; + return yy::json_parser::token::SQUARE_BRACKET_OPEN; + } + else if (ch == ']') { + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::SQUARE_BRACKET_CLOSE"; + return yy::json_parser::token::SQUARE_BRACKET_CLOSE; + } + else if (ch == '{') { + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::CURLY_BRACKET_OPEN"; + return yy::json_parser::token::CURLY_BRACKET_OPEN; + } + else if (ch == '}') { + qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::CURLY_BRACKET_CLOSE"; + return yy::json_parser::token::CURLY_BRACKET_CLOSE; + } + + //unknown char! + //TODO yyerror? + qCritical() << "JSonScanner::yylex - unknown char, returning -1"; + return -1; +} + + diff --git a/thirdparty/QTweetLib/qjson/json_scanner.h b/thirdparty/QTweetLib/qjson/json_scanner.h new file mode 100644 index 000000000..b4e4392d0 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/json_scanner.h @@ -0,0 +1,54 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _JSON_SCANNER +#define _JSON_SCANNER + +#include +#include + +#include +#include + +#define YYSTYPE QVariant + +#include "parser_p.h" + +namespace yy { + class location; + int yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver); +} + +class JSonScanner +{ + public: + explicit JSonScanner(QIODevice* io); + int yylex(YYSTYPE* yylval, yy::location *yylloc); + void allowSpecialNumbers(bool allow); + + protected: + bool m_quotmarkClosed; + bool m_allowSpecialNumbers; + unsigned int m_quotmarkCount; + QIODevice* m_io; +}; + +#endif + diff --git a/thirdparty/QTweetLib/qjson/location.hh b/thirdparty/QTweetLib/qjson/location.hh new file mode 100644 index 000000000..485fd77cd --- /dev/null +++ b/thirdparty/QTweetLib/qjson/location.hh @@ -0,0 +1,145 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Locations for Bison parsers in C++ + + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file location.hh + ** Define the yy::location class. + */ + +#ifndef BISON_LOCATION_HH +# define BISON_LOCATION_HH + +# include +# include +# include "position.hh" + +namespace yy +{ + + /// Abstract a location. + class location + { + public: + + /// Construct a location. + location () + : begin (), end () + { + } + + + /// Initialization. + inline void initialize (std::string* fn) + { + begin.initialize (fn); + end = begin; + } + + /** \name Line and Column related manipulators + ** \{ */ + public: + /// Reset initial location to final location. + inline void step () + { + begin = end; + } + + /// Extend the current location to the COUNT next columns. + inline void columns (unsigned int count = 1) + { + end += count; + } + + /// Extend the current location to the COUNT next lines. + inline void lines (unsigned int count = 1) + { + end.lines (count); + } + /** \} */ + + + public: + /// Beginning of the located region. + position begin; + /// End of the located region. + position end; + }; + + /// Join two location objects to create a location. + inline const location operator+ (const location& begin, const location& end) + { + location res = begin; + res.end = end.end; + return res; + } + + /// Add two location objects. + inline const location operator+ (const location& begin, unsigned int width) + { + location res = begin; + res.columns (width); + return res; + } + + /// Add and assign a location. + inline location& operator+= (location& res, unsigned int width) + { + res.columns (width); + return res; + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param loc a reference to the location to redirect + ** + ** Avoid duplicate information. + */ + inline std::ostream& operator<< (std::ostream& ostr, const location& loc) + { + position last = loc.end - 1; + ostr << loc.begin; + if (last.filename + && (!loc.begin.filename + || *loc.begin.filename != *last.filename)) + ostr << '-' << last; + else if (loc.begin.line != last.line) + ostr << '-' << last.line << '.' << last.column; + else if (loc.begin.column != last.column) + ostr << '-' << last.column; + return ostr; + } + +} + +#endif // not BISON_LOCATION_HH diff --git a/thirdparty/QTweetLib/qjson/parser.cpp b/thirdparty/QTweetLib/qjson/parser.cpp new file mode 100644 index 000000000..061e063e9 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/parser.cpp @@ -0,0 +1,124 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "parser.h" +#include "parser_p.h" +#include "json_parser.hh" +#include "json_scanner.h" + +#include +#include +#include +#include + +using namespace QJson; + +ParserPrivate::ParserPrivate() : + m_scanner(0) + , m_negate(false) + , m_error(false) + , m_specialNumbersAllowed(false) +{ +} + +ParserPrivate::~ParserPrivate() +{ + delete m_scanner; +} + +void ParserPrivate::setError(QString errorMsg, int errorLine) { + m_error = true; + m_errorMsg = errorMsg; + m_errorLine = errorLine; +} + +Parser::Parser() : + d(new ParserPrivate) +{ +} + +Parser::~Parser() +{ + delete d; +} + +QVariant Parser::parse (QIODevice* io, bool* ok) +{ + d->m_errorMsg.clear(); + delete d->m_scanner; + d->m_scanner = 0; + + if (!io->isOpen()) { + if (!io->open(QIODevice::ReadOnly)) { + if (ok != 0) + *ok = false; + qCritical ("Error opening device"); + return QVariant(); + } + } + + if (!io->isReadable()) { + if (ok != 0) + *ok = false; + qCritical ("Device is not readable"); + io->close(); + return QVariant(); + } + + d->m_scanner = new JSonScanner (io); + d->m_scanner->allowSpecialNumbers(d->m_specialNumbersAllowed); + yy::json_parser parser(d); + parser.parse(); + + delete d->m_scanner; + d->m_scanner = 0; + + if (ok != 0) + *ok = !d->m_error; + + io->close(); + return d->m_result; +} + +QVariant Parser::parse(const QByteArray& jsonString, bool* ok) { + QBuffer buffer; + buffer.open(QBuffer::ReadWrite); + buffer.write(jsonString); + buffer.seek(0); + return parse (&buffer, ok); +} + +QString Parser::errorString() const +{ + return d->m_errorMsg; +} + +int Parser::errorLine() const +{ + return d->m_errorLine; +} + +void QJson::Parser::allowSpecialNumbers(bool allowSpecialNumbers) { + d->m_specialNumbersAllowed = allowSpecialNumbers; +} + +bool Parser::specialNumbersAllowed() const { + return d->m_specialNumbersAllowed; +} diff --git a/thirdparty/QTweetLib/qjson/parser.h b/thirdparty/QTweetLib/qjson/parser.h new file mode 100644 index 000000000..0b02f5823 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/parser.h @@ -0,0 +1,94 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_PARSER_H +#define QJSON_PARSER_H + +#include "qjson_export.h" + +class QIODevice; +class QVariant; + +namespace QJson { + + class ParserPrivate; + + /** + * @brief Main class used to convert JSON data to QVariant objects + */ + class QJSON_EXPORT Parser + { + public: + Parser(); + ~Parser(); + + /** + * Read JSON string from the I/O Device and converts it to a QVariant object + * @param io Input output device + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true. + * @returns a QVariant object generated from the JSON string + */ + QVariant parse(QIODevice* io, bool* ok = 0); + + /** + * This is a method provided for convenience. + * @param jsonData data containing the JSON object representation + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true. + * @returns a QVariant object generated from the JSON string + * @sa errorString + * @sa errorLine + */ + QVariant parse(const QByteArray& jsonData, bool* ok = 0); + + /** + * This method returns the error message + * @returns a QString object containing the error message of the last parse operation + * @sa errorLine + */ + QString errorString() const; + + /** + * This method returns line number where the error occurred + * @returns the line number where the error occurred + * @sa errorString + */ + int errorLine() const; + + /** + * Sets whether special numbers (Infinity, -Infinity, NaN) are allowed as an extension to + * the standard + * @param allowSpecialNumbers new value of whether special numbers are allowed + * @sa specialNumbersAllowed + */ + void allowSpecialNumbers(bool allowSpecialNumbers); + + /** + * @returns whether special numbers (Infinity, -Infinity, NaN) are allowed + * @sa allowSpecialNumbers + */ + bool specialNumbersAllowed() const; + + private: + Q_DISABLE_COPY(Parser) + ParserPrivate* const d; + }; +} + +#endif // QJSON_PARSER_H diff --git a/thirdparty/QTweetLib/qjson/parser_p.h b/thirdparty/QTweetLib/qjson/parser_p.h new file mode 100644 index 000000000..6ae7507f1 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/parser_p.h @@ -0,0 +1,56 @@ +/* This file is part of QJson + * + * Copyright (C) 2008 Flavio Castelli + * Copyright (C) 2009 Michael Leupold + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_PARSER_P_H +#define QJSON_PARSER_P_H + +#include "parser.h" + +#include +#include + +class JSonScanner; + +namespace yy { + class json_parser; +} + +namespace QJson { + + class ParserPrivate + { + public: + ParserPrivate(); + ~ParserPrivate(); + + void setError(QString errorMsg, int line); + + JSonScanner* m_scanner; + bool m_negate; + bool m_error; + int m_errorLine; + QString m_errorMsg; + QVariant m_result; + bool m_specialNumbersAllowed; + }; +} + +#endif // QJSON_PARSER_H diff --git a/thirdparty/QTweetLib/qjson/parserrunnable.cpp b/thirdparty/QTweetLib/qjson/parserrunnable.cpp new file mode 100644 index 000000000..d09423e4c --- /dev/null +++ b/thirdparty/QTweetLib/qjson/parserrunnable.cpp @@ -0,0 +1,68 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "parserrunnable.h" + +#include "parser.h" + +#include +#include + +using namespace QJson; + +class QJson::ParserRunnable::Private +{ + public: + QByteArray m_data; +}; + +ParserRunnable::ParserRunnable(QObject* parent) + : QObject(parent), + QRunnable(), + d(new Private) +{ + qRegisterMetaType("QVariant"); +} + +ParserRunnable::~ParserRunnable() +{ + delete d; +} + +void ParserRunnable::setData( const QByteArray& data ) { + d->m_data = data; +} + +void ParserRunnable::run() +{ + qDebug() << Q_FUNC_INFO; + + bool ok; + Parser parser; + QVariant result = parser.parse (d->m_data, &ok); + if (ok) { + qDebug() << "successfully converted json item to QVariant object"; + emit parsingFinished(result, true, QString()); + } else { + const QString errorText = tr("An error occured while parsing json: %1").arg(parser.errorString()); + qCritical() << errorText; + emit parsingFinished(QVariant(), false, errorText); + } +} diff --git a/thirdparty/QTweetLib/qjson/parserrunnable.h b/thirdparty/QTweetLib/qjson/parserrunnable.h new file mode 100644 index 000000000..822e1fdba --- /dev/null +++ b/thirdparty/QTweetLib/qjson/parserrunnable.h @@ -0,0 +1,67 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef PARSERRUNNABLE_H +#define PARSERRUNNABLE_H + +#include "qjson_export.h" + +#include +#include + +class QVariant; + +namespace QJson { + /** + * @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread + */ + class QJSON_EXPORT ParserRunnable : public QObject, public QRunnable + { + Q_OBJECT + public: + /** + * This signal is emitted when the conversion process has been completed + * @param data contains the JSON data that has to be converted + * @param parent parent of the object + **/ + explicit ParserRunnable(QObject* parent = 0); + ~ParserRunnable(); + + void setData( const QByteArray& data ); + + void run(); + + Q_SIGNALS: + /** + * This signal is emitted when the parsing process has been completed + * @param json contains the result of the parsing + * @param ok if a parsing error occurs ok is set to false, otherwise it's set to true. + * @param error_msg contains a string explaining the failure reason + **/ + void parsingFinished(const QVariant& json, bool ok, const QString& error_msg); + + private: + Q_DISABLE_COPY(ParserRunnable) + class Private; + Private* const d; + }; +} + +#endif // PARSERRUNNABLE_H diff --git a/thirdparty/QTweetLib/qjson/position.hh b/thirdparty/QTweetLib/qjson/position.hh new file mode 100644 index 000000000..27331d0d1 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/position.hh @@ -0,0 +1,142 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Positions for Bison parsers in C++ + + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/** + ** \file position.hh + ** Define the yy::position class. + */ + +#ifndef BISON_POSITION_HH +# define BISON_POSITION_HH + +# include +# include + +namespace yy +{ + /// Abstract a position. + class position + { + public: + + /// Construct a position. + position () + : filename (0), line (1), column (0) + { + } + + + /// Initialization. + inline void initialize (std::string* fn) + { + filename = fn; + line = 1; + column = 0; + } + + /** \name Line and Column related manipulators + ** \{ */ + public: + /// (line related) Advance to the COUNT next lines. + inline void lines (int count = 1) + { + column = 0; + line += count; + } + + /// (column related) Advance to the COUNT next columns. + inline void columns (int count = 1) + { + int leftmost = 0; + int current = column; + if (leftmost <= current + count) + column += count; + else + column = 0; + } + /** \} */ + + public: + /// File name to which this position refers. + std::string* filename; + /// Current line number. + unsigned int line; + /// Current column number. + unsigned int column; + }; + + /// Add and assign a position. + inline const position& + operator+= (position& res, const int width) + { + res.columns (width); + return res; + } + + /// Add two position objects. + inline const position + operator+ (const position& begin, const int width) + { + position res = begin; + return res += width; + } + + /// Add and assign a position. + inline const position& + operator-= (position& res, const int width) + { + return res += -width; + } + + /// Add two position objects. + inline const position + operator- (const position& begin, const int width) + { + return begin + -width; + } + + /** \brief Intercept output stream redirection. + ** \param ostr the destination output stream + ** \param pos a reference to the position to redirect + */ + inline std::ostream& + operator<< (std::ostream& ostr, const position& pos) + { + if (pos.filename) + ostr << *pos.filename << ':'; + return ostr << pos.line << '.' << pos.column; + } + +} +#endif // not BISON_POSITION_HH diff --git a/thirdparty/QTweetLib/qjson/qjson.pro b/thirdparty/QTweetLib/qjson/qjson.pro new file mode 100644 index 000000000..f0741cbc2 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/qjson.pro @@ -0,0 +1,34 @@ +TEMPLATE = lib +QT -= gui +TARGET = qjson +DESTDIR = ../lib +CONFIG += create_prl + +windows: { + DEFINES += QJSON_MAKEDLL +} + +HEADERS += \ + stack.hh \ + serializerrunnable.h \ + serializer.h \ + qobjecthelper.h \ + qjson_export.h \ + qjson_debug.h \ + position.hh \ + parserrunnable.h \ + parser_p.h \ + parser.h \ + location.hh \ + json_scanner.h \ + json_parser.hh \ + +SOURCES += \ + serializerrunnable.cpp \ + serializer.cpp \ + qobjecthelper.cpp \ + parserrunnable.cpp \ + parser.cpp \ + json_scanner.cpp \ + json_parser.cc \ + diff --git a/thirdparty/QTweetLib/qjson/qjson_debug.h b/thirdparty/QTweetLib/qjson/qjson_debug.h new file mode 100644 index 000000000..5ae1da3a7 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/qjson_debug.h @@ -0,0 +1,33 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Michael Leupold + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_DEBUG_H +#define QJSON_DEBUG_H + +#include + +// define qjsonDebug() +#ifdef QJSON_VERBOSE_DEBUG_OUTPUT + inline QDebug qjsonDebug() { return QDebug(QtDebugMsg); } +#else + inline QNoDebug qjsonDebug() { return QNoDebug(); } +#endif + +#endif diff --git a/thirdparty/QTweetLib/qjson/qjson_export.h b/thirdparty/QTweetLib/qjson/qjson_export.h new file mode 100644 index 000000000..c7f5325a4 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/qjson_export.h @@ -0,0 +1,35 @@ +/* This file is part of the KDE project + Copyright (C) 2009 Pino Toscano + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef QJSON_EXPORT_H +#define QJSON_EXPORT_H + +#include + +#ifndef QJSON_EXPORT +# if defined(QJSON_MAKEDLL) + /* We are building this library */ +# define QJSON_EXPORT Q_DECL_EXPORT +# else + /* We are using this library */ +# define QJSON_EXPORT Q_DECL_IMPORT +# endif +#endif + +#endif diff --git a/thirdparty/QTweetLib/qjson/qobjecthelper.cpp b/thirdparty/QTweetLib/qjson/qobjecthelper.cpp new file mode 100644 index 000000000..91c35977a --- /dev/null +++ b/thirdparty/QTweetLib/qjson/qobjecthelper.cpp @@ -0,0 +1,84 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + + +#include "qobjecthelper.h" + +#include +#include +#include + +using namespace QJson; + +class QObjectHelper::QObjectHelperPrivate { +}; + +QObjectHelper::QObjectHelper() + : d (new QObjectHelperPrivate) +{ +} + +QObjectHelper::~QObjectHelper() +{ + delete d; +} + +QVariantMap QObjectHelper::qobject2qvariant( const QObject* object, + const QStringList& ignoredProperties) +{ + QVariantMap result; + const QMetaObject *metaobject = object->metaObject(); + int count = metaobject->propertyCount(); + for (int i=0; iproperty(i); + const char *name = metaproperty.name(); + + if (ignoredProperties.contains(QLatin1String(name)) || (!metaproperty.isReadable())) + continue; + + QVariant value = object->property(name); + result[QLatin1String(name)] = value; + } + return result; +} + +void QObjectHelper::qvariant2qobject(const QVariantMap& variant, QObject* object) +{ + const QMetaObject *metaobject = object->metaObject(); + + QVariantMap::const_iterator iter; + for (iter = variant.constBegin(); iter != variant.constEnd(); iter++) { + int pIdx = metaobject->indexOfProperty( iter.key().toAscii() ); + + if ( pIdx < 0 ) { + continue; + } + + QMetaProperty metaproperty = metaobject->property( pIdx ); + QVariant::Type type = metaproperty.type(); + QVariant v( iter.value() ); + + if ( v.canConvert( type ) ) { + v.convert( type ); + metaproperty.write( object, v ); + } + } +} diff --git a/thirdparty/QTweetLib/qjson/qobjecthelper.h b/thirdparty/QTweetLib/qjson/qobjecthelper.h new file mode 100644 index 000000000..7bf6b0357 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/qobjecthelper.h @@ -0,0 +1,143 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QOBJECTHELPER_H +#define QOBJECTHELPER_H + +#include "qjson_export.h" + +#include +#include +#include + +class QObject; + +namespace QJson { + /** + * @brief Class used to convert QObject into QVariant and vivce-versa. + * During these operations only the class attributes defined as properties will + * be considered. + * + * Suppose the declaration of the Person class looks like this: + * \code + * class Person : public QObject + { + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int phoneNumber READ phoneNumber WRITE setPhoneNumber) + Q_PROPERTY(Gender gender READ gender WRITE setGender) + Q_PROPERTY(QDate dob READ dob WRITE setDob) + Q_ENUMS(Gender) + + public: + Person(QObject* parent = 0); + ~Person(); + + QString name() const; + void setName(const QString& name); + + int phoneNumber() const; + void setPhoneNumber(const int phoneNumber); + + enum Gender {Male, Female}; + void setGender(Gender gender); + Gender gender() const; + + QDate dob() const; + void setDob(const QDate& dob); + + private: + QString m_name; + int m_phoneNumber; + Gender m_gender; + QDate m_dob; + }; + \endcode + + The following code will serialize an instance of Person to JSON : + + \code + Person person; + person.setName("Flavio"); + person.setPhoneNumber(123456); + person.setGender(Person::Male); + person.setDob(QDate(1982, 7, 12)); + + QVariantMap variant = QObjectHelper::qobject2qvariant(&person); + Serializer serializer; + qDebug() << serializer.serialize( variant); + \endcode + + The generated output will be: + \code + { "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 } + \endcode + + It's also possible to initialize a QObject using the values stored inside of + a QVariantMap. + + Suppose you have the following JSON data stored into a QString: + \code + { "dob" : "1982-07-12", "gender" : 0, "name" : "Flavio", "phoneNumber" : 123456 } + \endcode + + The following code will initialize an already allocated instance of Person + using the JSON values: + \code + Parser parser; + QVariant variant = parser.parse(json); + + Person person; + QObjectHelper::qvariant2qobject(variant.toMap(), &person); + \endcode + + \sa Parser + \sa Serializer + */ + class QJSON_EXPORT QObjectHelper { + public: + QObjectHelper(); + ~QObjectHelper(); + + /** + * This method converts a QObject instance into a QVariantMap. + * + * @param object The QObject instance to be converted. + * @param ignoredProperties Properties that won't be converted. + */ + static QVariantMap qobject2qvariant( const QObject* object, + const QStringList& ignoredProperties = QStringList(QString(QLatin1String("objectName")))); + + /** + * This method converts a QVariantMap instance into a QObject + * + * @param object The QObject instance to be converted. + */ + static void qvariant2qobject(const QVariantMap& variant, QObject* object); + + private: + Q_DISABLE_COPY(QObjectHelper) + class QObjectHelperPrivate; + QObjectHelperPrivate* const d; + }; +} + +#endif // QOBJECTHELPER_H diff --git a/thirdparty/QTweetLib/qjson/serializer.cpp b/thirdparty/QTweetLib/qjson/serializer.cpp new file mode 100644 index 000000000..1f6b60320 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/serializer.cpp @@ -0,0 +1,220 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * Copyright (C) 2009 Flavio Castelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "serializer.h" + +#include +#include +#include + +#include +#include + +using namespace QJson; + +class Serializer::SerializerPrivate { + public: + SerializerPrivate() : specialNumbersAllowed(false) {} + bool specialNumbersAllowed; + QString sanitizeString( QString str ); +}; + +QString Serializer::SerializerPrivate::sanitizeString( QString str ) +{ + str.replace( QLatin1String( "\\" ), QLatin1String( "\\\\" ) ); + + // escape unicode chars + QString result; + const ushort* unicode = str.utf16(); + unsigned int i = 0; + + while ( unicode[ i ] ) { + if ( unicode[ i ] < 128 ) { + result.append( QChar( unicode[ i ] ) ); + } + else { + QString hexCode = QString::number( unicode[ i ], 16 ).rightJustified( 4, + QLatin1Char('0') ); + + result.append( QLatin1String ("\\u") ).append( hexCode ); + } + ++i; + } + str = result; + + str.replace( QLatin1String( "\"" ), QLatin1String( "\\\"" ) ); + str.replace( QLatin1String( "\b" ), QLatin1String( "\\b" ) ); + str.replace( QLatin1String( "\f" ), QLatin1String( "\\f" ) ); + str.replace( QLatin1String( "\n" ), QLatin1String( "\\n" ) ); + str.replace( QLatin1String( "\r" ), QLatin1String( "\\r" ) ); + str.replace( QLatin1String( "\t" ), QLatin1String( "\\t" ) ); + + return QString( QLatin1String( "\"%1\"" ) ).arg( str ); +} + +Serializer::Serializer() + : d( new SerializerPrivate ) +{ +} + +Serializer::~Serializer() { + delete d; +} + +void Serializer::serialize( const QVariant& v, QIODevice* io, bool* ok ) +{ + Q_ASSERT( io ); + if (!io->isOpen()) { + if (!io->open(QIODevice::WriteOnly)) { + if ( ok != 0 ) + *ok = false; + qCritical ("Error opening device"); + return; + } + } + + if (!io->isWritable()) { + if (ok != 0) + *ok = false; + qCritical ("Device is not readable"); + io->close(); + return; + } + + const QByteArray str = serialize( v ); + if ( !str.isNull() ) { + QDataStream stream( io ); + stream << str; + } else { + if ( ok ) + *ok = false; + } +} + +static QByteArray join( const QList& list, const QByteArray& sep ) { + QByteArray res; + Q_FOREACH( const QByteArray& i, list ) { + if ( !res.isEmpty() ) + res += sep; + res += i; + } + return res; +} + +QByteArray Serializer::serialize( const QVariant &v ) +{ + QByteArray str; + bool error = false; + + if ( ! v.isValid() ) { // invalid or null? + str = "null"; + } else if (( v.type() == QVariant::List ) || ( v.type() == QVariant::StringList )){ // an array or a stringlist? + const QVariantList list = v.toList(); + QList values; + Q_FOREACH( const QVariant& v, list ) + { + QByteArray serializedValue = serialize( v ); + if ( serializedValue.isNull() ) { + error = true; + break; + } + values << serializedValue; + } + str = "[ " + join( values, ", " ) + " ]"; + } else if ( v.type() == QVariant::Map ) { // variant is a map? + const QVariantMap vmap = v.toMap(); + QMapIterator it( vmap ); + str = "{ "; + QList pairs; + while ( it.hasNext() ) { + it.next(); + QByteArray serializedValue = serialize( it.value() ); + if ( serializedValue.isNull() ) { + error = true; + break; + } + pairs << d->sanitizeString( it.key() ).toUtf8() + " : " + serializedValue; + } + str += join( pairs, ", " ); + str += " }"; + } else if (( v.type() == QVariant::String ) || ( v.type() == QVariant::ByteArray )) { // a string or a byte array? + str = d->sanitizeString( v.toString() ).toUtf8(); + } else if (( v.type() == QVariant::Double) || (v.type() == QMetaType::Float)) { // a double or a float? + const double value = v.toDouble(); +#ifdef _WIN32 + const bool special = _isnan(value) || !_finite(value); +#elif defined(Q_OS_SYMBIAN) + const bool special = isnan(value) || isinf(value); +#else + const bool special = std::isnan(value) || std::isinf(value); +#endif + if (special) { + if (specialNumbersAllowed()) { +#ifdef _WIN32 + if (_isnan(value)) { +#elif defined(Q_OS_SYMBIAN) + if (isnan(value)) { +#else + if (std::isnan(value)) { +#endif + str += "NaN"; + } else { + if (value<0) { + str += "-"; + } + str += "Infinity"; + } + } else { + qCritical("Attempt to write NaN or infinity, which is not supported by json"); + error = true; + } + } else { + str = QByteArray::number( value ); + if( ! str.contains( "." ) && ! str.contains( "e" ) ) { + str += ".0"; + } + } + } else if ( v.type() == QVariant::Bool ) { // boolean value? + str = ( v.toBool() ? "true" : "false" ); + } else if ( v.type() == QVariant::ULongLong ) { // large unsigned number? + str = QByteArray::number( v.value() ); + } else if ( v.canConvert() ) { // any signed number? + str = QByteArray::number( v.value() ); + } else if ( v.canConvert() ){ // can value be converted to string? + // this will catch QDate, QDateTime, QUrl, ... + str = d->sanitizeString( v.toString() ).toUtf8(); + //TODO: catch other values like QImage, QRect, ... + } else { + error = true; + } + if ( !error ) + return str; + else + return QByteArray(); +} + +void QJson::Serializer::allowSpecialNumbers(bool allow) { + d->specialNumbersAllowed = allow; +} + +bool QJson::Serializer::specialNumbersAllowed() const { + return d->specialNumbersAllowed; +} diff --git a/thirdparty/QTweetLib/qjson/serializer.h b/thirdparty/QTweetLib/qjson/serializer.h new file mode 100644 index 000000000..a2c0fc460 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/serializer.h @@ -0,0 +1,81 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Till Adam + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef QJSON_SERIALIZER_H +#define QJSON_SERIALIZER_H + +#include "qjson_export.h" + +class QIODevice; +class QString; +class QVariant; + +namespace QJson { + /** + * @brief Main class used to convert QVariant objects to JSON data. + * + * QVariant objects are converted to a string containing the JSON data. + * If QVariant object is empty or not valid a null json object is returned. + */ + class QJSON_EXPORT Serializer { + public: + Serializer(); + ~Serializer(); + + /** + * This method generates a textual JSON representation and outputs it to the + * passed in I/O Device. + * @param variant The JSON document in its in-memory representation as generated by the + * parser. + * @param out Input output device + * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true + */ + void serialize( const QVariant& variant, QIODevice* out, bool* ok = 0 ); + + /** + * This is a method provided for convenience. It turns the passed in in-memory + * representation of the JSON document into a textual one, which is returned. + * If the returned string is empty, the document was empty. If it was null, there + * was a parsing error. + * + * @param variant The JSON document in its in-memory representation as generated by the + * parser. + */ + + QByteArray serialize( const QVariant& variant ); + + /** + * Allow or disallow writing of NaN and/or Infinity (as an extension to QJson) + */ + void allowSpecialNumbers(bool allow); + + /** + * Is Nan and/or Infinity allowed? + */ + bool specialNumbersAllowed() const; + + private: + Q_DISABLE_COPY(Serializer) + class SerializerPrivate; + SerializerPrivate* const d; + }; +} + +#endif // QJSON_SERIALIZER_H diff --git a/thirdparty/QTweetLib/qjson/serializerrunnable.cpp b/thirdparty/QTweetLib/qjson/serializerrunnable.cpp new file mode 100644 index 000000000..2e57c4517 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/serializerrunnable.cpp @@ -0,0 +1,60 @@ +#include "serializerrunnable.h" + +/* This file is part of qjson + * + * Copyright (C) 2009 Flavio Castelli + * 2009 Frank Osterfeld + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "parserrunnable.h" +#include "serializer.h" + +#include +#include + +using namespace QJson; + +class SerializerRunnable::Private +{ +public: + QVariant json; +}; + +SerializerRunnable::SerializerRunnable(QObject* parent) + : QObject(parent), + QRunnable(), + d(new Private) +{ + qRegisterMetaType("QVariant"); +} + +SerializerRunnable::~SerializerRunnable() +{ + delete d; +} + +void SerializerRunnable::setJsonObject( const QVariant& json ) +{ + d->json = json; +} + +void SerializerRunnable::run() +{ + Serializer serializer; + emit parsingFinished( Serializer().serialize( d->json ), true, QString() ); +} diff --git a/thirdparty/QTweetLib/qjson/serializerrunnable.h b/thirdparty/QTweetLib/qjson/serializerrunnable.h new file mode 100644 index 000000000..c6b5fe117 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/serializerrunnable.h @@ -0,0 +1,74 @@ +/* This file is part of qjson + * + * Copyright (C) 2009 Frank Osterfeld + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef SERIALIZERRUNNABLE_H +#define SERIALIZERRUNNABLE_H + +#include "qjson_export.h" + +#include +#include + +class QByteArray; +class QString; +class QVariant; + +namespace QJson { + /** + * @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread + */ + class QJSON_EXPORT SerializerRunnable : public QObject, public QRunnable + { + Q_OBJECT + public: + /** + * This signal is emitted when the conversion process has been completed + * @param data contains the JSON data that has to be converted + * @param parent parent of the object + **/ + explicit SerializerRunnable(QObject* parent = 0); + ~SerializerRunnable(); + + /** + * Sets the json object to serialize. + * + * @param json QVariant containing the json representation to be serialized + */ + void setJsonObject( const QVariant& json ); + + /* reimp */ void run(); + + Q_SIGNALS: + /** + * This signal is emitted when the serialization process has been completed + * @param serialized contains the result of the serialization + * @param ok if a serialization error occurs ok is set to false, otherwise it's set to true. + * @param error_msg contains a string explaining the failure reason + **/ + void parsingFinished(const QByteArray& serialized, bool ok, const QString& error_msg); + + private: + Q_DISABLE_COPY(SerializerRunnable) + class Private; + Private* const d; + }; +} + +#endif // SERIALIZERRUNNABLE_H diff --git a/thirdparty/QTweetLib/qjson/src.pro b/thirdparty/QTweetLib/qjson/src.pro new file mode 100644 index 000000000..3cba04857 --- /dev/null +++ b/thirdparty/QTweetLib/qjson/src.pro @@ -0,0 +1,70 @@ +QJSON_BASE = .. +QJSON_SRCBASE = . + +TEMPLATE = lib +QT -= gui +TARGET = qjson +DESTDIR = $$QJSON_BASE/lib +CONFIG += create_prl + +VERSION = 0.7.1 + +windows: { + DEFINES += QJSON_MAKEDLL +} + +QJSON_CPP = $$QJSON_SRCBASE +INCLUDEPATH += $$QJSON_CPP + +PRIVATE_HEADERS += \ + json_parser.hh \ + json_scanner.h \ + location.hh \ + parser_p.h \ + position.hh \ + qjson_debug.h \ + stack.hh + +PUBLIC_HEADERS += \ + parser.h \ + parserrunnable.h \ + qobjecthelper.h \ + serializer.h \ + serializerrunnable.h \ + qjson_export.h + +HEADERS += $$PRIVATE_HEADERS $$PUBLIC_HEADERS + +SOURCES += \ + json_parser.cc \ + json_scanner.cpp \ + parser.cpp \ + parserrunnable.cpp \ + qobjecthelper.cpp \ + serializer.cpp \ + serializerrunnable.cpp + +symbian: { + DEFINES += QJSON_MAKEDLL + #export public header to \epocroot\epoc32\include to be able to use them + headers.files = $$PUBLIC_HEADERS + headers.path = $$PWD + for(header, headers.files) { + {BLD_INF_RULES.prj_exports += "$$header"} + } + + TARGET.EPOCALLOWDLLDATA = 1 + # uid for the dll + #TARGET.UID3= + TARGET.CAPABILITY = ReadDeviceData WriteDeviceData + + # do not freeze api-> no libs produced. Comment when freezing! + # run "abld freeze winscw" to create def files + symbian:MMP_RULES += "EXPORTUNFROZEN" + + # add dll to the sis + QjsonDeployment.sources = $${TARGET}.dll + QjsonDeployment.path = /sys/bin + + DEPLOYMENT += QjsonDeployment +} diff --git a/thirdparty/QTweetLib/qjson/stack.hh b/thirdparty/QTweetLib/qjson/stack.hh new file mode 100644 index 000000000..754b6640c --- /dev/null +++ b/thirdparty/QTweetLib/qjson/stack.hh @@ -0,0 +1,129 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Stack handling for Bison parsers in C++ + + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef BISON_STACK_HH +# define BISON_STACK_HH + +#include + +namespace yy +{ + template > + class stack + { + public: + + // Hide our reversed order. + typedef typename S::reverse_iterator iterator; + typedef typename S::const_reverse_iterator const_iterator; + + stack () : seq_ () + { + } + + stack (unsigned int n) : seq_ (n) + { + } + + inline + T& + operator [] (unsigned int i) + { + return seq_[i]; + } + + inline + const T& + operator [] (unsigned int i) const + { + return seq_[i]; + } + + inline + void + push (const T& t) + { + seq_.push_front (t); + } + + inline + void + pop (unsigned int n = 1) + { + for (; n; --n) + seq_.pop_front (); + } + + inline + unsigned int + height () const + { + return seq_.size (); + } + + inline const_iterator begin () const { return seq_.rbegin (); } + inline const_iterator end () const { return seq_.rend (); } + + private: + + S seq_; + }; + + /// Present a slice of the top of a stack. + template > + class slice + { + public: + + slice (const S& stack, + unsigned int range) : stack_ (stack), + range_ (range) + { + } + + inline + const T& + operator [] (unsigned int i) const + { + return stack_[range_ - i]; + } + + private: + + const S& stack_; + unsigned int range_; + }; +} + +#endif // not BISON_STACK_HH diff --git a/thirdparty/QTweetLib/qtweetlib_export.h b/thirdparty/QTweetLib/qtweetlib_export.h new file mode 100644 index 000000000..ed4504dd7 --- /dev/null +++ b/thirdparty/QTweetLib/qtweetlib_export.h @@ -0,0 +1,18 @@ +#ifndef QTWEETLIB_EXPORT_H +#define QTWEETLIB_EXPORT_H + +#include + +#ifdef Q_WS_WIN +# define QTWEETLIB_MAKEDLL +# if defined(MAKE_QTWEETLIB_LIB) +# define QTWEETLIB_EXPORT Q_DECL_EXPORT +# else +# define QTWEETLIB_EXPORT Q_DECL_IMPORT +# endif +#else +# define QTWEETLIB_EXPORT Q_DECL_EXPORT +#endif + +#endif + diff --git a/thirdparty/QTweetLib/src/oauth.cpp b/thirdparty/QTweetLib/src/oauth.cpp new file mode 100644 index 000000000..28c4a91d9 --- /dev/null +++ b/thirdparty/QTweetLib/src/oauth.cpp @@ -0,0 +1,340 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include +#include "oauth.h" + +#ifndef CONSUMER_KEY + #define CONSUMER_KEY "" +#endif //CONSUMER_KEY + +#ifndef CONSUMER_SECRET + #define CONSUMER_SECRET "" +#endif //CONSUMER_SECRET + +/** + * Generates HMAC-SHA1 signature + * @param message for which to create signature + * @param key + */ +static QByteArray hmacSha1(const QByteArray& message, const QByteArray& key) +{ + QByteArray normKey; + + if (key.size() > 64) { + normKey = QCryptographicHash::hash(key, QCryptographicHash::Sha1); + } else { + normKey = key; // no need for zero padding ipad and opad are filled with zeros + } + + unsigned char* K = (unsigned char *)normKey.constData(); + + unsigned char ipad[65]; + unsigned char opad[65]; + + memset(ipad, 0, 65); + memset(opad, 0, 65); + + memcpy(ipad, K, normKey.size()); + memcpy(opad, K, normKey.size()); + + for (int i = 0; i < 64; ++i) { + ipad[i] ^= 0x36; + opad[i] ^= 0x5c; + } + + QByteArray context; + context.append((const char *)ipad, 64); + context.append(message); + + QByteArray sha1 = QCryptographicHash::hash(context, QCryptographicHash::Sha1); + + context.clear(); + context.append((const char *)opad, 64); + context.append(sha1); + + sha1.clear(); + + sha1 = QCryptographicHash::hash(context, QCryptographicHash::Sha1); + + return sha1; +} + +/** + * Generates time stamp + * @return time stamp in epoch time + */ +static QByteArray generateTimeStamp() +{ + //OAuth spec. 8 http://oauth.net/core/1.0/#nonce + QDateTime current = QDateTime::currentDateTime(); + uint seconds = current.toTime_t(); + + return QString("%1").arg(seconds).toUtf8(); +} + +/** + * Generates random 16 length string + * @return random string + */ +static QByteArray generateNonce() +{ + //OAuth spec. 8 http://oauth.net/core/1.0/#nonce + QByteArray chars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + int max = chars.size(); + + int len = 16; + + QByteArray nonce; + for(int i = 0; i < len; ++i){ + nonce.append( chars[qrand() % max] ); + } + + return nonce; +} + +/** + * Constructor + * @param parent parent QObject + */ +OAuth::OAuth(QObject *parent) + : QObject(parent), + m_oauthConsumerKey(CONSUMER_KEY), + m_oauthConsumerSecret(CONSUMER_SECRET) +{ + QDateTime current = QDateTime::currentDateTime(); + qsrand(current.toTime_t()); +} + +/** + * Constructor + * @param consumerKey oauth consumer key + * @param consumerSecret oauth consumer secret + * @param parent parent QObject + */ +OAuth::OAuth(const QByteArray &consumerKey, const QByteArray &consumerSecret, QObject *parent) + : QObject(parent), + m_oauthConsumerKey(consumerKey), + m_oauthConsumerSecret(consumerSecret) +{ + QDateTime current = QDateTime::currentDateTime(); + qsrand(current.toTime_t()); +} + +/** + * Parses oauth_token and oauth_token_secret from response of the service provider + * and sets m_oauthToken and m_oauthTokenSecret accordingly + * @param response response from service provider + */ +void OAuth::parseTokens(const QByteArray& response) +{ + //OAuth spec 5.3, 6.1.2, 6.3.2 + //use QUrl for parsing + QByteArray parseQuery("http://parse.com?"); + + QUrl parseUrl = QUrl::fromEncoded(parseQuery + response); + + m_oauthToken = parseUrl.encodedQueryItemValue("oauth_token"); + m_oauthTokenSecret = parseUrl.encodedQueryItemValue("oauth_token_secret"); +} + +/** + * Sets oauth token + * @param token OAuth token + */ +void OAuth::setOAuthToken(const QByteArray& token) +{ + m_oauthToken = token; +} + +/** + * Sets OAauth token secret + * @param tokenSecret OAuth token secret + */ +void OAuth::setOAuthTokenSecret(const QByteArray& tokenSecret) +{ + m_oauthTokenSecret = tokenSecret; +} + +/** + * Gets oauth_token + * @return OAuth token + */ +QByteArray OAuth::oauthToken() const +{ + return m_oauthToken; +} + +/** + * Gets oauth_token_secret + * @return OAuth token secret + */ +QByteArray OAuth::oauthTokenSecret() const +{ + return m_oauthTokenSecret; +} + + +/** + * Clears the oauth tokens + */ +void OAuth::clearTokens() +{ + m_oauthToken.clear(); + m_oauthTokenSecret.clear(); +} + +/** + * Generates HMAC-SHA1 signature + * @param signatureBase signature base + * @return HMAC-SHA1 signature + */ +QByteArray OAuth::generateSignatureHMACSHA1(const QByteArray& signatureBase) +{ + //OAuth spec. 9.2 http://oauth.net/core/1.0/#anchor16 + QByteArray key = m_oauthConsumerSecret + '&' + m_oauthTokenSecret; + + QByteArray result = hmacSha1(signatureBase, key); + QByteArray resultBE64 = result.toBase64(); + QByteArray resultPE = resultBE64.toPercentEncoding(); + return resultPE; +} + +/** + * Generates OAuth signature base + * @param url Url with encoded parameters + * @param method Http method + * @param timestamp timestamp + * @param nonce random string + * @return signature base + */ +QByteArray OAuth::generateSignatureBase(const QUrl& url, HttpMethod method, const QByteArray& timestamp, const QByteArray& nonce) +{ + //OAuth spec. 9.1 http://oauth.net/core/1.0/#anchor14 + + //OAuth spec. 9.1.1 + QList > urlParameters = url.encodedQueryItems(); + QList normParameters; + + QListIterator > i(urlParameters); + while(i.hasNext()){ + QPair queryItem = i.next(); + QByteArray normItem = queryItem.first + '=' + queryItem.second; + normParameters.append(normItem); + } + + //consumer key + normParameters.append(QByteArray("oauth_consumer_key=") + m_oauthConsumerKey); + + //token + if(!m_oauthToken.isEmpty()){ + normParameters.append(QByteArray("oauth_token=") + m_oauthToken); + } + + //signature method, only HMAC_SHA1 + normParameters.append(QByteArray("oauth_signature_method=HMAC-SHA1")); + //time stamp + normParameters.append(QByteArray("oauth_timestamp=") + timestamp); + //nonce + normParameters.append(QByteArray("oauth_nonce=") + nonce); + //version + normParameters.append(QByteArray("oauth_version=1.0")); + + //OAuth spec. 9.1.1.1 + qSort(normParameters); + + //OAuth spec. 9.1.1.2 + //QByteArray normString; + //QListIterator j(normParameters); + //while(j.hasNext()){ + // normString += j.next(); + // normString += '&'; + //} + //normString.chop(1); + + QByteArray normString; + QListIterator j(normParameters); + while (j.hasNext()) { + normString += j.next().toPercentEncoding(); + normString += "%26"; + } + normString.chop(3); + + //OAuth spec. 9.1.2 + QString urlScheme = url.scheme(); + QString urlPath = url.path(); + QString urlHost = url.host(); + QByteArray normUrl = urlScheme.toUtf8() + "://" + urlHost.toUtf8() + urlPath.toUtf8(); + + QByteArray httpm; + + switch (method) + { + case OAuth::GET: + httpm = "GET"; + break; + case OAuth::POST: + httpm = "POST"; + break; + case OAuth::DELETE: + httpm = "DELETE"; + break; + case OAuth::PUT: + httpm = "PUT"; + break; + } + + //OAuth spec. 9.1.3 + return httpm + '&' + normUrl.toPercentEncoding() + '&' + normString; +} + +/** + * Generates Authorization Header + * @param url url with query items embedded + * @param method type of http method + * @remarks If HttpMethod is POST put query items in url (QUrl::addEncodedQueryItem) + */ +QByteArray OAuth::generateAuthorizationHeader( const QUrl& url, HttpMethod method ) +{ + if (m_oauthToken.isEmpty() && m_oauthTokenSecret.isEmpty()) + qDebug() << "OAuth tokens are empty!"; + + QByteArray timeStamp = generateTimeStamp(); + QByteArray nonce = generateNonce(); + + QByteArray sigBase = generateSignatureBase(url, method, timeStamp, nonce); + QByteArray signature = generateSignatureHMACSHA1(sigBase); + + QByteArray header; + header += "OAuth "; + header += "oauth_consumer_key=\"" + m_oauthConsumerKey + "\","; + if(!m_oauthToken.isEmpty()) + header += "oauth_token=\"" + m_oauthToken + "\","; + header += "oauth_signature_method=\"HMAC-SHA1\","; + header += "oauth_signature=\"" + signature + "\","; + header += "oauth_timestamp=\"" + timeStamp + "\","; + header += "oauth_nonce=\"" + nonce + "\","; + header += "oauth_version=\"1.0\""; + + return header; +} diff --git a/thirdparty/QTweetLib/src/oauth.h b/thirdparty/QTweetLib/src/oauth.h new file mode 100644 index 000000000..a1cfbe71d --- /dev/null +++ b/thirdparty/QTweetLib/src/oauth.h @@ -0,0 +1,64 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef OAUTH_H +#define OAUTH_H + +#include +#include +#include "qtweetlib_global.h" + +class QByteArray; + +/** + * Base OAuth class + */ +class QTWEETLIBSHARED_EXPORT OAuth : public QObject +{ + Q_OBJECT + Q_ENUMS(HttpMethod) + Q_PROPERTY(QByteArray oauthToken READ oauthToken WRITE setOAuthToken) + Q_PROPERTY(QByteArray oauthTokenSecret READ oauthTokenSecret WRITE setOAuthTokenSecret) + +public: + OAuth(QObject *parent = 0); + OAuth(const QByteArray& consumerKey, const QByteArray& consumerSecret, QObject *parent = 0); + + enum HttpMethod {GET, POST, PUT, DELETE}; + + void parseTokens(const QByteArray& response); + QByteArray generateAuthorizationHeader(const QUrl& url, HttpMethod method); + void setOAuthToken(const QByteArray& token); + void setOAuthTokenSecret(const QByteArray& tokenSecret); + void clearTokens(); + QByteArray oauthToken() const; + QByteArray oauthTokenSecret() const; + +private: + QByteArray generateSignatureHMACSHA1(const QByteArray& signatureBase); + QByteArray generateSignatureBase(const QUrl& url, HttpMethod method, const QByteArray& timestamp, const QByteArray& nonce); + + QByteArray m_oauthToken; + QByteArray m_oauthTokenSecret; + QByteArray m_oauthConsumerSecret; + QByteArray m_oauthConsumerKey; +}; + +#endif //OAUTH_H diff --git a/thirdparty/QTweetLib/src/oauthtwitter.cpp b/thirdparty/QTweetLib/src/oauthtwitter.cpp new file mode 100644 index 000000000..b55125f8c --- /dev/null +++ b/thirdparty/QTweetLib/src/oauthtwitter.cpp @@ -0,0 +1,216 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "oauthtwitter.h" +#include +#include +#include +#include +#include +#include +#include + +#define TWITTER_REQUEST_TOKEN_URL "http://twitter.com/oauth/request_token" +#define TWITTER_ACCESS_TOKEN_URL "http://twitter.com/oauth/access_token" +#define TWITTER_AUTHORIZE_URL "http://twitter.com/oauth/authorize" +#define TWITTER_ACCESS_TOKEN_XAUTH_URL "https://api.twitter.com/oauth/access_token" + +/** + * Constructor + */ +OAuthTwitter::OAuthTwitter(QObject *parent) + : OAuth(parent), m_netManager(0) +{ +} + +/** + * Constructor + */ +OAuthTwitter::OAuthTwitter(QNetworkAccessManager *netManager, QObject *parent) : + OAuth(parent), m_netManager(netManager) +{ +} + +/** + * Sets network access manager + * @remarks Must be set to work properly + */ +void OAuthTwitter::setNetworkAccessManager(QNetworkAccessManager* netManager) +{ + m_netManager = netManager; +} + +/** + * Gets network access manager + */ +QNetworkAccessManager* OAuthTwitter::networkAccessManager() const +{ + return m_netManager; +} + +/** + * Gets oauth tokens using XAuth method (starts authorization process) + * @param username username + * @param password password + * @remarks Async, emits authorizeXAuthFinished or authorizeXAuthError when there is error + */ +void OAuthTwitter::authorizeXAuth(const QString &username, const QString &password) +{ + Q_ASSERT(m_netManager != 0); + + QUrl url(TWITTER_ACCESS_TOKEN_XAUTH_URL); + url.addQueryItem("x_auth_username", username); + url.addQueryItem("x_auth_password", password); + url.addQueryItem("x_auth_mode", "client_auth"); + + QByteArray oauthHeader = generateAuthorizationHeader(url, OAuth::POST); + + QNetworkRequest req(url); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = m_netManager->post(req, QByteArray()); + connect(reply, SIGNAL(finished()), this, SLOT(finishedAuthorization())); +} + +/** + * Called when authorization is finished + */ +void OAuthTwitter::finishedAuthorization() +{ + QNetworkReply *reply = qobject_cast(sender()); + if (reply) { + if (reply->error() == QNetworkReply::NoError) { + QByteArray response = reply->readAll(); + parseTokens(response); + + emit authorizeXAuthFinished(); + } else { + //dump error + qDebug() << "Network Error: " << reply->error(); + qDebug() << "Response error: " << reply->readAll(); + emit authorizeXAuthError(); + + } + reply->deleteLater(); + } +} + +/** + * Starts PIN based OAuth authorization + */ +void OAuthTwitter::authorizePin() +{ + Q_ASSERT(m_netManager != 0); + + QUrl url(TWITTER_REQUEST_TOKEN_URL); + + QByteArray oauthHeader = generateAuthorizationHeader(url, OAuth::POST); + + QNetworkRequest req(url); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + //enters event loop + QEventLoop q; + QTimer t; + t.setSingleShot(true); + connect(&t, SIGNAL(timeout()), &q, SLOT(quit())); + + QNetworkReply *reply = m_netManager->post(req, QByteArray()); + connect(reply, SIGNAL(finished()), &q, SLOT(quit())); + connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error())); + + t.start(5000); + q.exec(); + + if (t.isActive()) { + t.stop(); + QByteArray response = reply->readAll(); + parseTokens(response); + + reply->deleteLater(); + requestAuthorization(); + + int pin = authorizationWidget(); + if (pin) { + requestAccessToken(pin); + } + } else { + qDebug() << "Timeout"; + } +} + +/** + * Opens authorization url + * @remarks Override if you want to show another browser + */ +void OAuthTwitter::requestAuthorization() +{ + QUrl authorizeUrl(TWITTER_AUTHORIZE_URL); + authorizeUrl.addEncodedQueryItem("oauth_token", oauthToken()); + + QDesktopServices::openUrl(authorizeUrl); +} + +/** + * Gets access tokens for user entered pin number + * @param pin entered pin number + */ +void OAuthTwitter::requestAccessToken(int pin) +{ + Q_ASSERT(m_netManager != 0); + + QUrl url(TWITTER_ACCESS_TOKEN_URL); + url.addEncodedQueryItem("oauth_verifier", QByteArray::number(pin)); + + QByteArray oauthHeader = generateAuthorizationHeader(url, OAuth::POST); + + QEventLoop q; + QTimer t; + t.setSingleShot(true); + + connect(&t, SIGNAL(timeout()), &q, SLOT(quit())); + + QNetworkRequest req(url); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = m_netManager->post(req, QByteArray()); + connect(reply, SIGNAL(finished()), &q, SLOT(quit())); + connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error())); + + t.start(5000); + q.exec(); + + if(t.isActive()){ + QByteArray response = reply->readAll(); + parseTokens(response); + reply->deleteLater(); + } else { + qDebug() << "Timeout"; + } +} + +/** + * Override to show the authorization widget where users enters pin number + * @return entered pin number by the user + */ +int OAuthTwitter::authorizationWidget() +{ + return 0; +} diff --git a/thirdparty/QTweetLib/src/oauthtwitter.h b/thirdparty/QTweetLib/src/oauthtwitter.h new file mode 100644 index 000000000..c44c6c798 --- /dev/null +++ b/thirdparty/QTweetLib/src/oauthtwitter.h @@ -0,0 +1,65 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef OAUTHTWITTER_H +#define OAUTHTWITTER_H + +#include "oauth.h" + +class QNetworkAccessManager; + +/** + * OAuth Twitter authorization class + */ +class QTWEETLIBSHARED_EXPORT OAuthTwitter : public OAuth +{ + Q_OBJECT + Q_PROPERTY(QNetworkAccessManager* networkAccessManager + READ networkAccessManager + WRITE setNetworkAccessManager) +public: + OAuthTwitter(QObject *parent = 0); + OAuthTwitter(QNetworkAccessManager* netManager, QObject *parent = 0); + void setNetworkAccessManager(QNetworkAccessManager* netManager); + QNetworkAccessManager* networkAccessManager() const; + void authorizeXAuth(const QString& username, const QString& password); + void authorizePin(); + +signals: + /** Emited when XAuth authorization is finished */ + void authorizeXAuthFinished(); + /** Emited when there is error in XAuth authorization */ + // ### TODO Error detection + // Sigh, bad documentation on errors in twitter api + void authorizeXAuthError(); + +protected: + virtual int authorizationWidget(); + virtual void requestAuthorization(); + +private slots: + void finishedAuthorization(); + void requestAccessToken(int pin); + +private: + QNetworkAccessManager *m_netManager; +}; + +#endif //OAUTHTWITTER_H diff --git a/thirdparty/QTweetLib/src/qtweetaccountratelimitstatus.cpp b/thirdparty/QTweetLib/src/qtweetaccountratelimitstatus.cpp new file mode 100644 index 000000000..ff3de0a18 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetaccountratelimitstatus.cpp @@ -0,0 +1,78 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetaccountratelimitstatus.h" + +/** + * Constructor + */ +QTweetAccountRateLimitStatus::QTweetAccountRateLimitStatus(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetAccountRateLimitStatus::QTweetAccountRateLimitStatus(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts checking rate limit status + * @remarks Should be emiting rateLimitInfo signal after finishing + */ +void QTweetAccountRateLimitStatus::check() +{ + QUrl url("http://api.twitter.com/1/account/rate_limit_status.json"); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetAccountRateLimitStatus::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QVariantMap respMap = json.toMap(); + + int remainingHits = respMap["remaining_hits"].toInt(); + int resetTime = respMap["reset_time_in_seconds"].toInt(); + int hourlyLimit = respMap["hourly_limit"].toInt(); + + emit rateLimitInfo(remainingHits, resetTime, hourlyLimit); + } else { + qDebug() << "QTweetAccountRateLimitStatus parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetaccountratelimitstatus.h b/thirdparty/QTweetLib/src/qtweetaccountratelimitstatus.h new file mode 100644 index 000000000..01f646517 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetaccountratelimitstatus.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETACCOUNTRATELIMITSTATUS_H +#define QTWEETACCOUNTRATELIMITSTATUS_H + +#include "qtweetnetbase.h" + +/** + * Returns the remaining number of API requests available to the requesting user + * before the API limit is reached for the current hour. + */ +class QTweetAccountRateLimitStatus : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetAccountRateLimitStatus(QObject *parent = 0); + QTweetAccountRateLimitStatus(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void check(); + +signals: + /** Emits rate limit info + * @param remainingHits Remaining hits + * @param resetTime Reset time in seconds + * @param hourlyLimit + */ + void rateLimitInfo(int remainingHits, int resetTime, int hourlyLimit); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETACCOUNTRATELIMITSTATUS_H diff --git a/thirdparty/QTweetLib/src/qtweetaccountverifycredentials.cpp b/thirdparty/QTweetLib/src/qtweetaccountverifycredentials.cpp new file mode 100644 index 000000000..ae7e77e0a --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetaccountverifycredentials.cpp @@ -0,0 +1,82 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetaccountverifycredentials.h" +#include "qtweetuser.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetAccountVerifyCredentials::QTweetAccountVerifyCredentials(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetAccountVerifyCredentials::QTweetAccountVerifyCredentials(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Verifies credentials + * @param includeEntities when set to either true, t or 1, each tweet will include a node called "entities,". + */ +void QTweetAccountVerifyCredentials::verify(bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/account/verify_credentials.json"); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetAccountVerifyCredentials::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetUser user = QTweetConvert::variantMapToUserInfo(json.toMap()); + + emit parsedUser(user); + } else { + qDebug() << "QTweetAccountVerifyCredentials parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetaccountverifycredentials.h b/thirdparty/QTweetLib/src/qtweetaccountverifycredentials.h new file mode 100644 index 000000000..8fb86b9bc --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetaccountverifycredentials.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETACCOUNTVERIFYCREDENTIALS_H +#define QTWEETACCOUNTVERIFYCREDENTIALS_H + +#include "qtweetnetbase.h" + +/** + * Checks credentials of a authenticated user. Should emit parsedUser signal + * if authentication was successful, error if not. Use this to test if + * supplied user credentials are valid + */ +class QTWEETLIBSHARED_EXPORT QTweetAccountVerifyCredentials : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetAccountVerifyCredentials(QObject *parent = 0); + QTweetAccountVerifyCredentials(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void verify(bool includeEntities = false); + +signals: + /** Emits parsed user when credentials are valid */ + void parsedUser(const QTweetUser& user); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETACCOUNTVERIFYCREDENTIALS_H diff --git a/thirdparty/QTweetLib/src/qtweetconvert.cpp b/thirdparty/QTweetLib/src/qtweetconvert.cpp new file mode 100644 index 000000000..4fce208cc --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetconvert.cpp @@ -0,0 +1,521 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "qtweetconvert.h" +#include "qtweetstatus.h" +#include "qtweetdmstatus.h" +#include "qtweetuser.h" +#include "qtweetlist.h" +#include "qtweetplace.h" +#include "qtweetsearchresult.h" +#include "qtweetsearchpageresults.h" +#include "qtweetentityurl.h" +#include "qtweetentityhashtag.h" +#include "qtweetentityusermentions.h" + +/** + * Converts list of statuses + */ +QList QTweetConvert::variantToStatusList(const QVariant &fromParser) +{ + QList statuses; + + QList listStatus = fromParser.toList(); + + foreach (const QVariant& status, listStatus) { + QVariantMap statusMap = status.toMap(); + + QTweetStatus tweetStatus = variantMapToStatus(statusMap); + + statuses.append(tweetStatus); + } + return statuses; +} + +/** + * Converts status + */ +QTweetStatus QTweetConvert::variantMapToStatus(const QVariantMap &var) +{ + QTweetStatus status; + + status.setCreatedAt(var["created_at"].toString()); + status.setText(var["text"].toString()); + status.setId(var["id"].toLongLong()); + status.setInReplyToUserId(var["in_reply_to_user_id"].toLongLong()); + status.setInReplyToScreenName(var["in_reply_to_screen_name"].toString()); + + QVariantMap userMap = var["user"].toMap(); + QTweetUser user = variantMapToUserInfo(userMap); + + status.setUser(user); + status.setSource(var["source"].toString()); + status.setInReplyToStatusId(var["in_reply_to_status_id"].toLongLong()); + + //check if contains native retweet + if (var.contains("retweeted_status")) { + QVariantMap retweetMap = var["retweeted_status"].toMap(); + + QTweetStatus rtStatus = variantMapToStatus(retweetMap); + + status.setRetweetedStatus(rtStatus); + } + + //parse place id if it's not null + QVariant placeVar = var["place"]; + if (!placeVar.isNull()) { + QTweetPlace place = variantMapToPlace(placeVar.toMap()); + status.setPlace(place); + } + + //check if contains entities + if (var.contains("entities")) { + QVariantMap entitiesVarMap = var["entities"].toMap(); + + //url entities + QVariantList urlEntitiesVarList = entitiesVarMap["urls"].toList(); + + foreach (const QVariant& urlEntityVar, urlEntitiesVarList) { + QVariantMap urlEntityVarMap = urlEntityVar.toMap(); + QTweetEntityUrl urlEntity = variantMapToEntityUrl(urlEntityVarMap); + + status.addUrlEntity(urlEntity); + } + + //hashtag entities + QVariantList hashtagEntitiesVarList = entitiesVarMap["hashtags"].toList(); + + foreach (const QVariant& hashtagEntityVar, hashtagEntitiesVarList) { + QVariantMap hashtagEntityVarMap = hashtagEntityVar.toMap(); + QTweetEntityHashtag hashtagEntity = variantMapToEntityHashtag(hashtagEntityVarMap); + + status.addHashtagEntity(hashtagEntity); + } + + //user mentions + QVariantList userMentionsEntitiesVarList = entitiesVarMap["user_mentions"].toList(); + + foreach (const QVariant& userMentionsEntityVar, userMentionsEntitiesVarList) { + QVariantMap userMentionsEntityVarMap = userMentionsEntityVar.toMap(); + QTweetEntityUserMentions userMentionsEntity = variantMapToEntityUserMentions(userMentionsEntityVarMap); + + status.addUserMentionsEntity(userMentionsEntity); + } + } + + return status; +} + +/** + * Converts user info + */ +QTweetUser QTweetConvert::variantMapToUserInfo(const QVariantMap &var) +{ + QTweetUser userInfo; + + userInfo.setId(var["id"].toLongLong()); + + //don't fill rest of it, when user info is trimmed + if (var.contains("name")) { + + userInfo.setName(var["name"].toString()); + userInfo.setLocation(var["location"].toString()); + userInfo.setprofileImageUrl(var["profile_image_url"].toString()); + userInfo.setCreatedAt(var["created_at"].toString()); + userInfo.setFavouritesCount(var["favourites_count"].toInt()); + userInfo.setUrl(var["url"].toString()); + userInfo.setUtcOffset(var["utc_offset"].toInt()); + userInfo.setProtected(var["protected"].toBool()); + userInfo.setFollowersCount(var["followers_count"].toInt()); + userInfo.setVerified(var["verified"].toBool()); + userInfo.setGeoEnabled(var["geo_enabled"].toBool()); + userInfo.setDescription(var["description"].toString()); + userInfo.setTimezone(var["time_zone"].toString()); + userInfo.setFriendsCount(var["friends_count"].toInt()); + userInfo.setStatusesCount(var["statuses_count"].toInt()); + userInfo.setScreenName(var["screen_name"].toString()); + userInfo.setContributorsEnabled(var["contributors_enabled"].toBool()); + userInfo.setListedCount(var["listed_count"].toInt()); + userInfo.setLang(var["lang"].toString()); + + //check if contains status + if (var.contains("status")) { + QVariantMap statusMap = var["status"].toMap(); + + QTweetStatus status = variantMapToStatus(statusMap); + + userInfo.setStatus(status); + } + } + + return userInfo; +} + +/** + * Converts list of direct messages + */ +QList QTweetConvert::variantToDirectMessagesList(const QVariant& fromParser) +{ + QList directMessages; + + QList listMessages = fromParser.toList(); + + foreach (const QVariant& message, listMessages) { + QTweetDMStatus dmStatus = variantMapToDirectMessage(message.toMap()); + directMessages.append(dmStatus); + } + + return directMessages; +} + +/** + * Converts direct message + */ +QTweetDMStatus QTweetConvert::variantMapToDirectMessage(const QVariantMap& var) +{ + QTweetDMStatus directMessage; + + directMessage.setCreatedAt(var["created_at"].toString()); + directMessage.setSenderScreenName(var["sender_screen_name"].toString()); + + QVariantMap senderMap = var["sender"].toMap(); + QTweetUser sender = variantMapToUserInfo(senderMap); + + directMessage.setSender(sender); + + directMessage.setText(var["text"].toString()); + directMessage.setRecipientScreenName(var["recipient_screen_name"].toString()); + directMessage.setId(var["id"].toLongLong()); + + QVariantMap recipientMap = var["recipient"].toMap(); + QTweetUser recipient = variantMapToUserInfo(recipientMap); + + directMessage.setRecipient(recipient); + + directMessage.setRecipientId(var["recipient_id"].toLongLong()); + directMessage.setSenderId(var["sender_id"].toLongLong()); + + return directMessage; +} + +/** + * Converts tweet list + */ +QTweetList QTweetConvert::variantMapToTweetList(const QVariantMap& var) +{ + QTweetList list; + + list.setMode(var["mode"].toString()); + list.setDescription(var["description"].toString()); + list.setFollowing(var["following"].toBool()); + list.setMemberCount(var["member_count"].toInt()); + list.setFullName(var["full_name"].toString()); + list.setSubscriberCount(var["subscriber_count"].toInt()); + list.setSlug(var["slug"].toString()); + list.setName(var["name"].toString()); + list.setId(var["id"].toLongLong()); + list.setUri(var["uri"].toString()); + + if (var.contains("user")) { + QVariantMap userMap = var["user"].toMap(); + + QTweetUser user = variantMapToUserInfo(userMap); + + list.setUser(user); + } + return list; +} + +/** + * Converts list of user infos + */ +QList QTweetConvert::variantToUserInfoList(const QVariant& fromParser) +{ + QList users; + + QList listUsers = fromParser.toList(); + + foreach (const QVariant& user, listUsers) { + QTweetUser userInfo = variantMapToUserInfo(user.toMap()); + + users.append(userInfo); + } + + return users; +} + +/** + * Converts list of tweet lists + */ +QList QTweetConvert::variantToTweetLists(const QVariant& var) +{ + QList lists; + + QList varLists = var.toList(); + + foreach (const QVariant& varlist, varLists) { + QTweetList tweetlist = variantMapToTweetList(varlist.toMap()); + + lists.append(tweetlist); + } + + return lists; +} + +/** + * Converts search result + */ +QTweetSearchResult QTweetConvert::variantMapToSearchResult(const QVariantMap& var) +{ + QTweetSearchResult result; + + result.setCreatedAt(var["created_at"].toString()); + result.setFromUser(var["from_user"].toString()); + result.setId(var["id"].toLongLong()); + result.setLang(var["iso_language_code"].toString()); + result.setProfileImageUrl(var["profile_image_url"].toString()); + result.setSource(var["source"].toString()); + result.setText(var["text"].toString()); + result.setToUser(var["to_user"].toString()); + + return result; +} + +/** + * Converts page results + */ +QTweetSearchPageResults QTweetConvert::variantToSearchPageResults(const QVariant& var) +{ + QTweetSearchPageResults page; + + QVariantMap varMap = var.toMap(); + + page.setMaxId(varMap["max_id"].toLongLong()); + page.setNextPage(varMap["next_page"].toByteArray()); + page.setPage(varMap["page"].toInt()); + page.setQuery(varMap["query"].toByteArray()); + page.setRefreshUrl(varMap["refresh_url"].toByteArray()); + page.setResultsPerPage(varMap["results_per_page"].toInt()); + page.setSinceId(varMap["since_id"].toLongLong()); + page.setTotal(varMap["total"].toInt()); + + QList resultList; + QList resultVarList = varMap["results"].toList(); + + foreach (const QVariant& resultVar, resultVarList) { + QTweetSearchResult result = variantMapToSearchResult(resultVar.toMap()); + resultList.append(result); + } + + page.setResults(resultList); + + return page; +} + +/** + * Converts place + */ +QTweetPlace QTweetConvert::variantMapToPlace(const QVariantMap& var) +{ + QTweetPlace place; + + place.setName(var["name"].toString()); + place.setCountryCode(var["country_code"].toString()); + place.setCountry(var["country"].toString()); + place.setID(var["id"].toString()); + place.setFullName(var["full_name"].toString()); + + QString placeType = var["place_type"].toString(); + + if (placeType == "poi") + place.setType(QTweetPlace::Poi); + else if (placeType == "neighborhood") + place.setType(QTweetPlace::Neighborhood); + else if (placeType == "city") + place.setType(QTweetPlace::City); + else if (placeType == "admin") + place.setType(QTweetPlace::Admin); + else if (placeType == "country") + place.setType(QTweetPlace::Country); + else + place.setType(QTweetPlace::Neighborhood); //twitter default + + QVariant bbVar = var["bounding_box"]; + + if (!bbVar.isNull()) { + QVariantMap bbMap = bbVar.toMap(); + + if (bbMap["type"].toString() == "Polygon") { + QVariantList coordList = bbMap["coordinates"].toList(); + + if (coordList.count() == 1) { + QVariantList latLongList = coordList.at(0).toList(); + + if (latLongList.count() == 4) { + QTweetGeoBoundingBox box; + + QVariantList coordsBottomLeft = latLongList.at(0).toList(); + box.setBottomLeft(QTweetGeoCoord(coordsBottomLeft.at(1).toDouble(), coordsBottomLeft.at(0).toDouble())); + + QVariantList coordsBottomRight = latLongList.at(1).toList(); + box.setBottomRight(QTweetGeoCoord(coordsBottomRight.at(1).toDouble(), coordsBottomRight.at(0).toDouble())); + + QVariantList coordsTopRight = latLongList.at(2).toList(); + box.setTopRight(QTweetGeoCoord(coordsTopRight.at(1).toDouble(), coordsTopRight.at(0).toDouble())); + + QVariantList coordsTopLeft = latLongList.at(3).toList(); + box.setTopLeft(QTweetGeoCoord(coordsTopLeft.at(1).toDouble(), coordsTopLeft.at(0).toDouble())); + + place.setBoundingBox(box); + } + } + } + } + return place; +} + +//not to be used in timelines api, but in geo api, where place contains other places +//is it recursive responsive? +QTweetPlace QTweetConvert::variantMapToPlaceRecursive(const QVariantMap& var) +{ + QTweetPlace place; + + place.setName(var["name"].toString()); + place.setCountryCode(var["country_code"].toString()); + place.setCountry(var["country"].toString()); + place.setID(var["id"].toString()); + place.setFullName(var["full_name"].toString()); + + QString placeType = var["place_type"].toString(); + + if (placeType == "poi") + place.setType(QTweetPlace::Poi); + else if (placeType == "neighborhood") + place.setType(QTweetPlace::Neighborhood); + else if (placeType == "city") + place.setType(QTweetPlace::City); + else if (placeType == "admin") + place.setType(QTweetPlace::Admin); + else if (placeType == "country") + place.setType(QTweetPlace::Country); + else + place.setType(QTweetPlace::Neighborhood); //twitter default + + QVariant bbVar = var["bounding_box"]; + + if (!bbVar.isNull()) { + QVariantMap bbMap = bbVar.toMap(); + + if (bbMap["type"].toString() == "Polygon") { + QVariantList coordList = bbMap["coordinates"].toList(); + + if (coordList.count() == 1) { + QVariantList latLongList = coordList.at(0).toList(); + + if (latLongList.count() == 4) { + QTweetGeoBoundingBox box; + + QVariantList coordsBottomLeft = latLongList.at(0).toList(); + box.setBottomLeft(QTweetGeoCoord(coordsBottomLeft.at(1).toDouble(), coordsBottomLeft.at(0).toDouble())); + + QVariantList coordsBottomRight = latLongList.at(1).toList(); + box.setBottomRight(QTweetGeoCoord(coordsBottomRight.at(1).toDouble(), coordsBottomRight.at(0).toDouble())); + + QVariantList coordsTopRight = latLongList.at(2).toList(); + box.setTopRight(QTweetGeoCoord(coordsTopRight.at(1).toDouble(), coordsTopRight.at(0).toDouble())); + + QVariantList coordsTopLeft = latLongList.at(3).toList(); + box.setTopLeft(QTweetGeoCoord(coordsTopLeft.at(1).toDouble(), coordsTopLeft.at(0).toDouble())); + + place.setBoundingBox(box); + } + } + } + } + + QVariantList containedVarList = var["contained_within"].toList(); + + QList containedInPlacesList; + + if (!containedVarList.isEmpty()) { + foreach (const QVariant& containedVar, containedVarList) { + QVariantMap containedPlaceMap = containedVar.toMap(); + + QTweetPlace containedPlace = variantMapToPlaceRecursive(containedPlaceMap); + + containedInPlacesList.append(containedPlace); + } + } + + place.setContainedWithin(containedInPlacesList); + + return place; +} + +/** + * Convers list of places + */ +QList QTweetConvert::variantToPlaceList(const QVariant& fromParser) +{ + QList placeList; + + QVariantMap responseVarMap = fromParser.toMap(); + QVariantMap resultVarMap = responseVarMap["result"].toMap(); + QVariantList placesVarList = resultVarMap["places"].toList(); + + foreach (const QVariant& placeVar, placesVarList) { + QTweetPlace place = variantMapToPlaceRecursive(placeVar.toMap()); + placeList.append(place); + } + + return placeList; +} + +QTweetEntityUrl QTweetConvert::variantMapToEntityUrl(const QVariantMap &var) +{ + QString url = var["url"].toString(); + QString displayUrl = var["display_url"].toString(); + QString expandedUrl = var["expanded_url"].toString(); + + QTweetEntityUrl urlEntity; + urlEntity.setUrl(url); + urlEntity.setDisplayUrl(displayUrl); + urlEntity.setExpandedUrl(expandedUrl); + + return urlEntity; +} + +QTweetEntityHashtag QTweetConvert::variantMapToEntityHashtag(const QVariantMap &var) +{ + QTweetEntityHashtag hashtagEntity; + hashtagEntity.setText(var["text"].toString()); + + return hashtagEntity; +} + +QTweetEntityUserMentions QTweetConvert::variantMapToEntityUserMentions(const QVariantMap &var) +{ + QTweetEntityUserMentions userMentionsEntity; + userMentionsEntity.setScreenName(var["screen_name"].toString()); + userMentionsEntity.setName(var["name"].toString()); + userMentionsEntity.setUserid(var["id"].toLongLong()); + + return userMentionsEntity; +} diff --git a/thirdparty/QTweetLib/src/qtweetconvert.h b/thirdparty/QTweetLib/src/qtweetconvert.h new file mode 100644 index 000000000..0b2dcd0bb --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetconvert.h @@ -0,0 +1,63 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETCONVERT_H +#define QTWEETCONVERT_H + +#include + +class QTweetStatus; +class QTweetUser; +class QTweetDMStatus; +class QTweetList; +class QTweetSearchResult; +class QTweetSearchPageResults; +class QTweetPlace; +class QTweetEntityUrl; +class QTweetEntityHashtag; +class QTweetEntityUserMentions; + +/** + * Contains static converting functions + */ +class QTweetConvert +{ +public: + static QList variantToStatusList(const QVariant& fromParser); + static QTweetStatus variantMapToStatus(const QVariantMap& var); + static QTweetUser variantMapToUserInfo(const QVariantMap& var); + static QList variantToDirectMessagesList(const QVariant& fromParser); + static QTweetDMStatus variantMapToDirectMessage(const QVariantMap& var); + static QTweetList variantMapToTweetList(const QVariantMap& var); + static QList variantToUserInfoList(const QVariant& fromParser); + static QList variantToTweetLists(const QVariant& var); + static QTweetSearchResult variantMapToSearchResult(const QVariantMap& var); + static QTweetSearchPageResults variantToSearchPageResults(const QVariant& var); + static QTweetPlace variantMapToPlace(const QVariantMap& var); + static QTweetPlace variantMapToPlaceRecursive(const QVariantMap& var); + static QList variantToPlaceList(const QVariant& fromParser); + static QTweetEntityUrl variantMapToEntityUrl(const QVariantMap& var); + static QTweetEntityHashtag variantMapToEntityHashtag(const QVariantMap& var); + static QTweetEntityUserMentions variantMapToEntityUserMentions(const QVariantMap& var); + + +}; + +#endif // QTWEETCONVERT_H diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessagedestroy.cpp b/thirdparty/QTweetLib/src/qtweetdirectmessagedestroy.cpp new file mode 100644 index 000000000..0c00a88bf --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetdirectmessagedestroy.cpp @@ -0,0 +1,83 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetdirectmessagedestroy.h" +#include "qtweetdmstatus.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetDirectMessageDestroy::QTweetDirectMessageDestroy(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetDirectMessageDestroy::QTweetDirectMessageDestroy(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * @param id the ID of the direct message to delete. + * @param includeEntities When set to true, each tweet will include a node called "entities," + */ +void QTweetDirectMessageDestroy::destroyMessage(qint64 id, bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/direct_messages/destroy/%1.json").arg(id)); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::DELETE); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->deleteResource(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetDirectMessageDestroy::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetDMStatus dm = QTweetConvert::variantMapToDirectMessage(json.toMap()); + + emit parsedDirectMessage(dm); + } else { + qDebug() << "QTweetDirectMessageDestroy parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessagedestroy.h b/thirdparty/QTweetLib/src/qtweetdirectmessagedestroy.h new file mode 100644 index 000000000..6785a4e76 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetdirectmessagedestroy.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETDIRECTMESSAGEDESTROY_H +#define QTWEETDIRECTMESSAGEDESTROY_H + +#include "qtweetnetbase.h" + +/** + * Destroys the direct message. + * The authenticating user must be the recipient of the specified direct message. + */ +class QTWEETLIBSHARED_EXPORT QTweetDirectMessageDestroy : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetDirectMessageDestroy(QObject *parent = 0); + QTweetDirectMessageDestroy(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void destroyMessage(qint64 id, bool includeEntities = false); + +signals: + /** emits destroyed direct message */ + void parsedDirectMessage(const QTweetDMStatus& message); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETDIRECTMESSAGEDESTROY_H diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessagenew.cpp b/thirdparty/QTweetLib/src/qtweetdirectmessagenew.cpp new file mode 100644 index 000000000..fe8a190c8 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetdirectmessagenew.cpp @@ -0,0 +1,129 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetdirectmessagenew.h" +#include "qtweetdmstatus.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetDirectMessageNew::QTweetDirectMessageNew(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetDirectMessageNew::QTweetDirectMessageNew(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Sends direct message + * @param user The ID of the user who should receive the direct message. + * @param text The text of direct message + * @param includeEntities When set to true each tweet will include a node called "entities," + */ +void QTweetDirectMessageNew::post(qint64 user, + const QString &text, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/direct_messages/new.json"); + + QUrl urlQuery(url); + + urlQuery.addQueryItem("user_id", QString::number(user)); + urlQuery.addEncodedQueryItem("text", QUrl::toPercentEncoding(text)); + + if (includeEntities) + urlQuery.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath); + postBody.remove(0, 1); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +/** + * Sends direct message + * @param user The ID of the user who should receive the direct message. + * @param text The text of direct message + * @param includeEntities When set to true each tweet will include a node called "entities," + */ +void QTweetDirectMessageNew::post(const QString &screenName, const QString &text, bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/direct_messages/new.json"); + + QUrl urlQuery(url); + + urlQuery.addEncodedQueryItem("screen_name", QUrl::toPercentEncoding(screenName)); + urlQuery.addEncodedQueryItem("text", QUrl::toPercentEncoding(text)); + + if (includeEntities) + urlQuery.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath); + postBody.remove(0, 1); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetDirectMessageNew::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetDMStatus dm = QTweetConvert::variantMapToDirectMessage(json.toMap()); + + emit parsedDirectMessage(dm); + } else { + qDebug() << "QTweetDirectMessageNew parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessagenew.h b/thirdparty/QTweetLib/src/qtweetdirectmessagenew.h new file mode 100644 index 000000000..6842b0877 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetdirectmessagenew.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETDIRECTMESSAGENEW_H +#define QTWEETDIRECTMESSAGENEW_H + +#include "qtweetnetbase.h" + +/** + * Sends a new direct message to the specified user from the authenticating user. + */ +class QTWEETLIBSHARED_EXPORT QTweetDirectMessageNew : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetDirectMessageNew(QObject *parent = 0); + QTweetDirectMessageNew(OAuthTwitter *oauhtTwitter, QObject *parent = 0); + void post(qint64 user, + const QString& text, + bool includeEntities = false); + void post(const QString& screenName, + const QString& text, + bool includeEntities = false); + +signals: + /** Emits direct message who was sent */ + void parsedDirectMessage(const QTweetDMStatus& message); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETDIRECTMESSAGENEW_H diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessages.cpp b/thirdparty/QTweetLib/src/qtweetdirectmessages.cpp new file mode 100644 index 000000000..4912799c0 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetdirectmessages.cpp @@ -0,0 +1,103 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetdirectmessages.h" +#include "qtweetdmstatus.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetDirectMessages::QTweetDirectMessages(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetDirectMessages::QTweetDirectMessages(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Start fetching direct messages + * @param sinceid Fetch DM newer then sinceid + * @param maxid Fetch DM older then maxid + * @param count Number of DM to fetch (up to 200) + * @param page Page number + * @param includeEntities When true each tweet will include a node called "entities" + * @remarks Setting parameter to default value will not be put in query + */ +void QTweetDirectMessages::fetch(qint64 sinceid, + qint64 maxid, + int count, + int page, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/direct_messages.json"); + + if (sinceid != 0) + url.addQueryItem("since_id", QString::number(sinceid)); + + if (maxid != 0) + url.addQueryItem("max_id", QString::number(maxid)); + + if (count != 0) + url.addQueryItem("count", QString::number(count)); + + if (page != 0) + url.addQueryItem("page", QString::number(page)); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetDirectMessages::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList directMessages = QTweetConvert::variantToDirectMessagesList(json); + + emit parsedDirectMessages(directMessages); + } else { + qDebug() << "QTweetDirectMessages JSON parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessages.h b/thirdparty/QTweetLib/src/qtweetdirectmessages.h new file mode 100644 index 000000000..9b4917bd2 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetdirectmessages.h @@ -0,0 +1,51 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETDIRECTMESSAGES_H +#define QTWEETDIRECTMESSAGES_H + +#include "qtweetnetbase.h" + +class QTweetDMStatus; + +/** + * Class for fetching direct messages + */ +class QTWEETLIBSHARED_EXPORT QTweetDirectMessages : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetDirectMessages(QObject *parent = 0); + QTweetDirectMessages(OAuthTwitter* oauthTwitter, QObject *parent = 0); + void fetch(qint64 sinceid = 0, + qint64 maxid = 0, + int count = 0, + int page = 0, + bool includeEntities = false); + +signals: + /** Emits parsed direct messages list */ + void parsedDirectMessages(const QList& messages); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETDIRECTMESSAGES_H diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessagessent.cpp b/thirdparty/QTweetLib/src/qtweetdirectmessagessent.cpp new file mode 100644 index 000000000..06d7d70fd --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetdirectmessagessent.cpp @@ -0,0 +1,104 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetdirectmessagessent.h" +#include "qtweetdmstatus.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetDirectMessagesSent::QTweetDirectMessagesSent(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetDirectMessagesSent::QTweetDirectMessagesSent(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts fetching direct messages + * @param sinceid returns results with an ID greater than (that is, more recent than) the specified ID. + * @param maxid returns results with an ID less than (that is, older than) or equal to the specified ID. + * @param count specifies the number of records to retrieve. Must be less than or equal to 200. + * @param page specifies the page of results to retrieve. + * @param includeEntities When set to true, each tweet will include a node called "entities,". + * @remarks Setting parameters to default value will not be put in the query + */ +void QTweetDirectMessagesSent::fetch(qint64 sinceid, + qint64 maxid, + int count, + int page, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/direct_messages/sent.json"); + + if (sinceid) + url.addQueryItem("since_id", QString::number(sinceid)); + + if (maxid) + url.addQueryItem("max_id", QString::number(maxid)); + + if (count) + url.addQueryItem("count", QString::number(count)); + + if (page) + url.addQueryItem("page", QString::number(page)); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetDirectMessagesSent::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList directMessages = QTweetConvert::variantToDirectMessagesList(json); + + emit parsedDirectMessages(directMessages); + } else { + qDebug() << "QTweetDirectMessagesSent parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessagessent.h b/thirdparty/QTweetLib/src/qtweetdirectmessagessent.h new file mode 100644 index 000000000..c070d904f --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetdirectmessagessent.h @@ -0,0 +1,49 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETDIRECTMESSAGESSENT_H +#define QTWEETDIRECTMESSAGESSENT_H + +#include "qtweetnetbase.h" + +/** + * Fetches direct messages sent by the authenticating user. + */ +class QTWEETLIBSHARED_EXPORT QTweetDirectMessagesSent : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetDirectMessagesSent(QObject *parent = 0); + QTweetDirectMessagesSent(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 sinceid = 0, + qint64 maxid = 0, + int count = 0, + int page = 0, + bool includeEntities = false); + +signals: + /** Emits direct messages list */ + void parsedDirectMessages(const QList& messages); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETDIRECTMESSAGESSENT_H diff --git a/thirdparty/QTweetLib/src/qtweetdmstatus.cpp b/thirdparty/QTweetLib/src/qtweetdmstatus.cpp new file mode 100644 index 000000000..7e9a7584d --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetdmstatus.cpp @@ -0,0 +1,154 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include "qtweetuser.h" +#include "qtweetdmstatus.h" + +class QTweetDMStatusData : public QSharedData +{ +public: + QDateTime createdAt; + QString senderScreenName; + QTweetUser sender; + QString text; + QString recipientScreenName; + qint64 id; + QTweetUser recipient; + qint64 recipientId; + qint64 senderId; +}; + +QTweetDMStatus::QTweetDMStatus() : + d(new QTweetDMStatusData) +{ +} + +QTweetDMStatus::QTweetDMStatus(const QTweetDMStatus &other) : + d(other.d) +{ +} + +QTweetDMStatus& QTweetDMStatus::operator =(const QTweetDMStatus &other) +{ + if (this != &other) + d.operator =(other.d); + return *this; +} + +QTweetDMStatus::~QTweetDMStatus() +{ +} + +void QTweetDMStatus::setCreatedAt(const QString &twitterDate) +{ + d->createdAt = QTweetUser::twitterDateToQDateTime(twitterDate); +} + +void QTweetDMStatus::setCreatedAt(const QDateTime &datetime) +{ + d->createdAt = datetime; +} + +QDateTime QTweetDMStatus::createdAt() const +{ + return d->createdAt; +} + +void QTweetDMStatus::setSenderScreenName(const QString &screenName) +{ + d->senderScreenName = screenName; +} + +QString QTweetDMStatus::senderScreenName() const +{ + return d->senderScreenName; +} + +void QTweetDMStatus::setSender(const QTweetUser &sender) +{ + d->sender = sender; +} + +QTweetUser QTweetDMStatus::sender() const +{ + return d->sender; +} + +void QTweetDMStatus::setText(const QString &text) +{ + d->text = text; +} + +QString QTweetDMStatus::text() const +{ + return d->text; +} + +void QTweetDMStatus::setRecipientScreenName(const QString &screenName) +{ + d->recipientScreenName = screenName; +} + +QString QTweetDMStatus::recipientScreenName() const +{ + return d->recipientScreenName; +} + +void QTweetDMStatus::setId(qint64 id) +{ + d->id = id; +} + +qint64 QTweetDMStatus::id() const +{ + return d->id; +} + +void QTweetDMStatus::setRecipient(const QTweetUser &recipient) +{ + d->recipient = recipient; +} + +QTweetUser QTweetDMStatus::recipient() const +{ + return d->recipient; +} + +void QTweetDMStatus::setRecipientId(qint64 id) +{ + d->recipientId = id; +} + +qint64 QTweetDMStatus::recipientId() const +{ + return d->recipientId; +} + +void QTweetDMStatus::setSenderId(qint64 id) +{ + d->senderId = id; +} + +qint64 QTweetDMStatus::senderId() const +{ + return d->senderId; +} diff --git a/thirdparty/QTweetLib/src/qtweetdmstatus.h b/thirdparty/QTweetLib/src/qtweetdmstatus.h new file mode 100644 index 000000000..dea37435c --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetdmstatus.h @@ -0,0 +1,68 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETDMSTATUS_H +#define QTWEETDMSTATUS_H + +#include +#include +#include "qtweetlib_global.h" + +class QTweetUser; +class QTweetDMStatusData; + +/** + * Stores direct message info + */ +class QTWEETLIBSHARED_EXPORT QTweetDMStatus +{ +public: + QTweetDMStatus(); + QTweetDMStatus(const QTweetDMStatus& other); + QTweetDMStatus& operator=(const QTweetDMStatus& other); + ~QTweetDMStatus(); + + void setCreatedAt(const QString& twitterDate); + void setCreatedAt(const QDateTime& datetime); + QDateTime createdAt() const; + void setSenderScreenName(const QString& screenName); + QString senderScreenName() const; + void setSender(const QTweetUser& sender); + QTweetUser sender() const; + void setText(const QString& text); + QString text() const; + void setRecipientScreenName(const QString& screenName); + QString recipientScreenName() const; + void setId(qint64 id); + qint64 id() const; + void setRecipient(const QTweetUser& recipient); + QTweetUser recipient() const; + void setRecipientId(qint64 id); + qint64 recipientId() const; + void setSenderId(qint64 id); + qint64 senderId() const; + +private: + QSharedDataPointer d; +}; + +Q_DECLARE_METATYPE(QTweetDMStatus) + +#endif // QTWEETDMSTATUS_H diff --git a/thirdparty/QTweetLib/src/qtweetentityhashtag.cpp b/thirdparty/QTweetLib/src/qtweetentityhashtag.cpp new file mode 100644 index 000000000..e9b06dd52 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetentityhashtag.cpp @@ -0,0 +1,57 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "qtweetentityhashtag.h" +#include +#include + +class QTweetEntityHashtagData : public QSharedData { +public: + QString hashtag; +}; + +QTweetEntityHashtag::QTweetEntityHashtag() : data(new QTweetEntityHashtagData) +{ +} + +QTweetEntityHashtag::QTweetEntityHashtag(const QTweetEntityHashtag &rhs) : data(rhs.data) +{ +} + +QTweetEntityHashtag &QTweetEntityHashtag::operator=(const QTweetEntityHashtag &rhs) +{ + if (this != &rhs) + data.operator=(rhs.data); + return *this; +} + +QTweetEntityHashtag::~QTweetEntityHashtag() +{ +} + +void QTweetEntityHashtag::setText(const QString &text) +{ + data->hashtag = text; +} + +QString QTweetEntityHashtag::text() const +{ + return data->hashtag; +} diff --git a/thirdparty/QTweetLib/src/qtweetentityhashtag.h b/thirdparty/QTweetLib/src/qtweetentityhashtag.h new file mode 100644 index 000000000..e3c1e21d5 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetentityhashtag.h @@ -0,0 +1,43 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETENTITYHASHTAG_H +#define QTWEETENTITYHASHTAG_H + +#include + +class QTweetEntityHashtagData; + +class QTweetEntityHashtag +{ +public: + QTweetEntityHashtag(); + QTweetEntityHashtag(const QTweetEntityHashtag &); + QTweetEntityHashtag &operator=(const QTweetEntityHashtag &); + ~QTweetEntityHashtag(); + + void setText(const QString& text); + QString text() const; + +private: + QSharedDataPointer data; +}; + +#endif // QTWEETENTITYHASHTAG_H diff --git a/thirdparty/QTweetLib/src/qtweetentityurl.cpp b/thirdparty/QTweetLib/src/qtweetentityurl.cpp new file mode 100644 index 000000000..931d0d75c --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetentityurl.cpp @@ -0,0 +1,82 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "qtweetentityurl.h" +#include +#include + +class QTweetEntityUrlData : public QSharedData { +public: + QTweetEntityUrlData() : empty(false) {} + + QString displayUrl; + QString url; + QString expandedUrl; + bool empty; +}; + +QTweetEntityUrl::QTweetEntityUrl() : data(new QTweetEntityUrlData) +{ +} + +QTweetEntityUrl::QTweetEntityUrl(const QTweetEntityUrl &rhs) : data(rhs.data) +{ +} + +QTweetEntityUrl &QTweetEntityUrl::operator=(const QTweetEntityUrl &rhs) +{ + if (this != &rhs) + data.operator=(rhs.data); + return *this; +} + +QTweetEntityUrl::~QTweetEntityUrl() +{ +} + +void QTweetEntityUrl::setDisplayUrl(const QString &url) +{ + data->displayUrl = url; +} + +QString QTweetEntityUrl::displayUrl() const +{ + return data->displayUrl; +} + +void QTweetEntityUrl::setUrl(const QString &url) +{ + data->url = url; +} + +QString QTweetEntityUrl::url() const +{ + return data->url; +} + +void QTweetEntityUrl::setExpandedUrl(const QString &url) +{ + data->url = url; +} + +QString QTweetEntityUrl::expandedUrl() const +{ + return data->url; +} diff --git a/thirdparty/QTweetLib/src/qtweetentityurl.h b/thirdparty/QTweetLib/src/qtweetentityurl.h new file mode 100644 index 000000000..77e10add2 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetentityurl.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETENTITYURL_H +#define QTWEETENTITYURL_H + +#include + +class QTweetEntityUrlData; + +class QTweetEntityUrl +{ +public: + QTweetEntityUrl(); + QTweetEntityUrl(const QTweetEntityUrl &); + QTweetEntityUrl &operator=(const QTweetEntityUrl &); + ~QTweetEntityUrl(); + + void setDisplayUrl(const QString& url); + QString displayUrl() const; + void setUrl(const QString& url); + QString url() const; + void setExpandedUrl(const QString& url); + QString expandedUrl() const; + +private: + QSharedDataPointer data; +}; + +#endif // QTWEETENTITYURL_H diff --git a/thirdparty/QTweetLib/src/qtweetentityusermentions.cpp b/thirdparty/QTweetLib/src/qtweetentityusermentions.cpp new file mode 100644 index 000000000..9d69a41c4 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetentityusermentions.cpp @@ -0,0 +1,81 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "qtweetentityusermentions.h" +#include +#include + +class QTweetEntityUserMentionsData : public QSharedData { +public: + QTweetEntityUserMentionsData() : userid(0) {} + + QString screenName; + QString name; + qint64 userid; +}; + +QTweetEntityUserMentions::QTweetEntityUserMentions() : data(new QTweetEntityUserMentionsData) +{ +} + +QTweetEntityUserMentions::QTweetEntityUserMentions(const QTweetEntityUserMentions &rhs) : data(rhs.data) +{ +} + +QTweetEntityUserMentions &QTweetEntityUserMentions::operator=(const QTweetEntityUserMentions &rhs) +{ + if (this != &rhs) + data.operator=(rhs.data); + return *this; +} + +QTweetEntityUserMentions::~QTweetEntityUserMentions() +{ +} + +void QTweetEntityUserMentions::setScreenName(const QString &screenName) +{ + data->screenName = screenName; +} + +QString QTweetEntityUserMentions::screenName() const +{ + return data->screenName; +} + +void QTweetEntityUserMentions::setName(const QString &name) +{ + data->name = name; +} + +QString QTweetEntityUserMentions::name() const +{ + return data->name; +} + +void QTweetEntityUserMentions::setUserid(qint64 id) +{ + data->userid = id; +} + +qint64 QTweetEntityUserMentions::userid() const +{ + return data->userid; +} diff --git a/thirdparty/QTweetLib/src/qtweetentityusermentions.h b/thirdparty/QTweetLib/src/qtweetentityusermentions.h new file mode 100644 index 000000000..40e77ef21 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetentityusermentions.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETENTITYUSERMENTIONS_H +#define QTWEETENTITYUSERMENTIONS_H + +#include + +class QTweetEntityUserMentionsData; + +class QTweetEntityUserMentions +{ +public: + QTweetEntityUserMentions(); + QTweetEntityUserMentions(const QTweetEntityUserMentions &); + QTweetEntityUserMentions &operator=(const QTweetEntityUserMentions &); + ~QTweetEntityUserMentions(); + + void setScreenName(const QString& screenName); + QString screenName() const; + void setName(const QString& name); + QString name() const; + void setUserid(qint64 id); + qint64 userid() const; + +private: + QSharedDataPointer data; +}; + +#endif // QTWEETENTITYUSERMENTIONS_H diff --git a/thirdparty/QTweetLib/src/qtweetfavorites.cpp b/thirdparty/QTweetLib/src/qtweetfavorites.cpp new file mode 100644 index 000000000..c61f23096 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfavorites.cpp @@ -0,0 +1,93 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetfavorites.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetFavorites::QTweetFavorites(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetFavorites::QTweetFavorites(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts fetching favorites + * @param id the ID of the user for whom to request a list of favorite statuses. 0 for authenticated user + * @param page Specifies the page of results to retrieve. + * @param includeEntities When set to true, each tweet will include a node called "entities,". + */ +void QTweetFavorites::fetch(qint64 id, int page, bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url; + + if (id) { + url.setUrl(QString("http://api.twitter.com/1/favorites/%1.json").arg(id)); + } else { + url.setUrl("http://api.twitter.com/1/favorites.json"); + } + + if (page) + url.addQueryItem("page", QString::number(page)); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetFavorites::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList statuses = QTweetConvert::variantToStatusList(json); + + emit parsedFavorites(statuses); + } else { + qDebug() << "QTweetFavorites JSON parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetfavorites.h b/thirdparty/QTweetLib/src/qtweetfavorites.h new file mode 100644 index 000000000..abcd26d23 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfavorites.h @@ -0,0 +1,48 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETFAVORITES_H +#define QTWEETFAVORITES_H + +#include "qtweetnetbase.h" + +/** + * Fetches favorite statuses for the authenticating user or + * user specified by the ID parameter + */ +class QTWEETLIBSHARED_EXPORT QTweetFavorites : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetFavorites(QObject *parent = 0); + QTweetFavorites(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 id = 0, + int page = 0, + bool includeEntities = false); + +signals: + /** Emits list of favorited statuses */ + void parsedFavorites(const QList& favorites); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETFAVORITES_H diff --git a/thirdparty/QTweetLib/src/qtweetfavoritescreate.cpp b/thirdparty/QTweetLib/src/qtweetfavoritescreate.cpp new file mode 100644 index 000000000..5d4f0eca6 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfavoritescreate.cpp @@ -0,0 +1,83 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetfavoritescreate.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetFavoritesCreate::QTweetFavoritesCreate(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetFavoritesCreate::QTweetFavoritesCreate(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts creating favorited statues + * @param statusid ID of the desired status to be favorited. + * @param includeEntities When set to true, each tweet will include a node called "entities,". + */ +void QTweetFavoritesCreate::create(qint64 statusid, bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/favorites/create/%1.json").arg(statusid)); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::POST); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, QByteArray()); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetFavoritesCreate::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetStatus status = QTweetConvert::variantMapToStatus(json.toMap()); + + emit parsedStatus(status); + } else { + qDebug() << "QTweetFavoritesCreate parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetfavoritescreate.h b/thirdparty/QTweetLib/src/qtweetfavoritescreate.h new file mode 100644 index 000000000..cceecf139 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfavoritescreate.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETFAVORITESCREATE_H +#define QTWEETFAVORITESCREATE_H + +#include "qtweetnetbase.h" + +/** + * Favorites the status specified in the ID parameter as the authenticating user. + * Emits the favorite status when successful. + */ +class QTWEETLIBSHARED_EXPORT QTweetFavoritesCreate : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetFavoritesCreate(QObject *parent = 0); + QTweetFavoritesCreate(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void create(qint64 statusid, bool includeEntities = false); + +signals: + /** Emits favorited status */ + void parsedStatus(const QTweetStatus& status); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETFAVORITESCREATE_H diff --git a/thirdparty/QTweetLib/src/qtweetfavoritesdestroy.cpp b/thirdparty/QTweetLib/src/qtweetfavoritesdestroy.cpp new file mode 100644 index 000000000..6c41503e4 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfavoritesdestroy.cpp @@ -0,0 +1,84 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetfavoritesdestroy.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetFavoritesDestroy::QTweetFavoritesDestroy(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetFavoritesDestroy::QTweetFavoritesDestroy(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts unfavoriting status + * @param statusid ID of the desired status + * @param includeEntities When set to true, each tweet will include a node called "entities," + */ +void QTweetFavoritesDestroy::unfavorite(qint64 statusid, bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/favorites/destroy/%1.json").arg(statusid)); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::DELETE); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->deleteResource(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetFavoritesDestroy::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetStatus status = QTweetConvert::variantMapToStatus(json.toMap()); + + emit parsedStatus(status); + } else { + qDebug() << "QTweetFavoritesDestroy parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetfavoritesdestroy.h b/thirdparty/QTweetLib/src/qtweetfavoritesdestroy.h new file mode 100644 index 000000000..3d531f2dc --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfavoritesdestroy.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETFAVORITESDESTROY_H +#define QTWEETFAVORITESDESTROY_H + +#include "qtweetnetbase.h" + +/** + * Un-favorites the status specified in the ID parameter as the authenticating user. + * Emits the un-favorited status when successful. + */ +class QTWEETLIBSHARED_EXPORT QTweetFavoritesDestroy : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetFavoritesDestroy(QObject *parent = 0); + QTweetFavoritesDestroy(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void unfavorite(qint64 statusid, bool includeEntities = false); + +signals: + /** Emits the unfavorited status */ + void parsedStatus(const QTweetStatus& status); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETFAVORITESDESTROY_H diff --git a/thirdparty/QTweetLib/src/qtweetfollowersid.cpp b/thirdparty/QTweetLib/src/qtweetfollowersid.cpp new file mode 100644 index 000000000..5857907f1 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfollowersid.cpp @@ -0,0 +1,111 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetfollowersid.h" + +/** + * Constructor + */ +QTweetFollowersID::QTweetFollowersID(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetFollowersID::QTweetFollowersID(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts fetching one page of id's + * @param user the ID of the user for whom to return results for. + * @param cursor use from signal response nextCursor and prevCursor to allow paging back and forth + */ +void QTweetFollowersID::fetch(qint64 user, const QString &cursor) +{ + QUrl url("http://api.twitter.com/1/followers/ids.json"); + + url.addQueryItem("user_id", QString::number(user)); + url.addQueryItem("cursor", cursor); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +/** + * Starts fetching one page of id's + * @param screenName the screen name of the user for whom to return results for. + * @param cursor use from signal response nextCursor and prevCursor to allow paging back and forth + */ +void QTweetFollowersID::fetch(const QString &screenName, const QString &cursor) +{ + QUrl url("http://api.twitter.com/1/followers/ids.json"); + + url.addQueryItem("screen_name", screenName); + url.addQueryItem("cursor", cursor); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetFollowersID::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList idList; + + QVariantMap respMap = json.toMap(); + + QVariantList idVarList = respMap["ids"].toList(); + + foreach (const QVariant& idVar, idVarList) + idList.append(idVar.toLongLong()); + + QString nextCursor = respMap["next_cursor_str"].toString(); + QString prevCursor = respMap["previous_cursor_str"].toString(); + + emit parsedIDs(idList, nextCursor, prevCursor); + } else { + qDebug() << "QTweetFollowersID parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetfollowersid.h b/thirdparty/QTweetLib/src/qtweetfollowersid.h new file mode 100644 index 000000000..d6dece37b --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfollowersid.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETFOLLOWERSID_H +#define QTWEETFOLLOWERSID_H + +#include "qtweetnetbase.h" + +/** + * Returns an list of numeric IDs for every user following the specified user. + */ +class QTWEETLIBSHARED_EXPORT QTweetFollowersID : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetFollowersID(QObject *parent = 0); + QTweetFollowersID(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 user, + const QString& cursor = QString("-1")); + void fetch(const QString& screenName, + const QString& cursor = QString("-1")); + +signals: + /** + * Emits one page of ids + * @param ids List of ids following the user + * @param nextCursor Cursor for next page, "0" if there is no page + * @param prevCursor Cursor for prev page "0" if there is no page + */ + void parsedIDs(const QList& ids, + const QString& nextCursor, + const QString& prevCursor); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; +#endif // QTWEETFOLLOWERSID_H diff --git a/thirdparty/QTweetLib/src/qtweetfriendshipcreate.cpp b/thirdparty/QTweetLib/src/qtweetfriendshipcreate.cpp new file mode 100644 index 000000000..62f9fbc85 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfriendshipcreate.cpp @@ -0,0 +1,135 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetfriendshipcreate.h" +#include "qtweetuser.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetFriendshipCreate::QTweetFriendshipCreate(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetFriendshipCreate::QTweetFriendshipCreate(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Creates frienship + * @param userid id to follow + * @param follow Enable notifications for the target user. + * @param includeEntities When set to true, each tweet will include a node called "entities" + */ +void QTweetFriendshipCreate::create(qint64 userid, + bool follow, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/friendships/create.json"); + + QUrl urlQuery(url); + + urlQuery.addQueryItem("user_id", QString::number(userid)); + + if (follow) + urlQuery.addQueryItem("follow", "true"); + + if (includeEntities) + urlQuery.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath); + postBody.remove(0, 1); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +/** + * Creates frienship + * @param screenName Screen name of user to follow + * @param follow Enable notifications for the target user. + * @param includeEntities When set to true, each tweet will include a node called "entities" + */ +void QTweetFriendshipCreate::create(const QString &screenName, + bool follow, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/friendships/create.json"); + + QUrl urlQuery(url); + + urlQuery.addQueryItem("screen_name", QUrl::toPercentEncoding(screenName)); + + if (follow) + urlQuery.addQueryItem("follow", "true"); + + if (includeEntities) + urlQuery.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath); + postBody.remove(0, 1); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetFriendshipCreate::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetUser user = QTweetConvert::variantMapToUserInfo(json.toMap()); + + emit parsedUser(user); + } else { + qDebug() << "QTweetFriendshipCreate parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetfriendshipcreate.h b/thirdparty/QTweetLib/src/qtweetfriendshipcreate.h new file mode 100644 index 000000000..8340312c7 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfriendshipcreate.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETFRIENDSHIPCREATE_H +#define QTWEETFRIENDSHIPCREATE_H + +#include "qtweetnetbase.h" + +/** + * Allows the authenticating users to follow the user specified in the ID parameter. + */ +class QTWEETLIBSHARED_EXPORT QTweetFriendshipCreate : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetFriendshipCreate(QObject *parent = 0); + QTweetFriendshipCreate(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void create(qint64 userid, + bool follow = false, + bool includeEntities = false); + void create(const QString& screenName, + bool follow = false, + bool includeEntities = false); + +signals: + /** Emits the befriended user */ + void parsedUser(const QTweetUser& user); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETFRIENDSHIPCREATE_H diff --git a/thirdparty/QTweetLib/src/qtweetfriendshipdestroy.cpp b/thirdparty/QTweetLib/src/qtweetfriendshipdestroy.cpp new file mode 100644 index 000000000..1871ed0a2 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfriendshipdestroy.cpp @@ -0,0 +1,113 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetfriendshipdestroy.h" +#include "qtweetuser.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetFriendshipDestroy::QTweetFriendshipDestroy(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetFriendshipDestroy::QTweetFriendshipDestroy(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Unfollows the specified user + * @param userid user id to unfollow + * @param includeEntities when set totrue, each tweet will include a node called "entities,". + */ +void QTweetFriendshipDestroy::unfollow(qint64 userid, bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/friendships/destroy.json"); + + url.addQueryItem("user_id", QString::number(userid)); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->deleteResource(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +/** + * Unfollows the specified user + * @param screenName screen name to unfollow + * @param includeEntities when set totrue, each tweet will include a node called "entities,". + */ +void QTweetFriendshipDestroy::unfollow(const QString &screenName, bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/friendships/destroy.json"); + + url.addQueryItem("screen_name", screenName); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->deleteResource(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetFriendshipDestroy::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetUser user = QTweetConvert::variantMapToUserInfo(json.toMap()); + + emit parsedUser(user); + } else { + qDebug() << "QTweetFriendshipCreate parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetfriendshipdestroy.h b/thirdparty/QTweetLib/src/qtweetfriendshipdestroy.h new file mode 100644 index 000000000..043e1ec21 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfriendshipdestroy.h @@ -0,0 +1,48 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETFRIENDSHIPDESTROY_H +#define QTWEETFRIENDSHIPDESTROY_H + +#include "qtweetnetbase.h" + +/** + * Allows the authenticating users to unfollow the user specified in the ID parameter. + */ +class QTWEETLIBSHARED_EXPORT QTweetFriendshipDestroy : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetFriendshipDestroy(QObject *parent = 0); + QTweetFriendshipDestroy(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void unfollow(qint64 userid, + bool includeEntities = false); + void unfollow(const QString& screenName, + bool includeEntities = false); + +signals: + /** Emits unfollowed user */ + void parsedUser(const QTweetUser& user); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETFRIENDSHIPDESTROY_H diff --git a/thirdparty/QTweetLib/src/qtweetfriendsid.cpp b/thirdparty/QTweetLib/src/qtweetfriendsid.cpp new file mode 100644 index 000000000..679b7fb10 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfriendsid.cpp @@ -0,0 +1,111 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetfriendsid.h" + +/** + * Constructor + */ +QTweetFriendsID::QTweetFriendsID(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetFriendsID::QTweetFriendsID(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Start fetcing one page of id's + * @param user the ID of the user for whom to return results for. + * @param cursor use from response nextCursor and prevCursor to allow paging back and forth + */ +void QTweetFriendsID::fetch(qint64 user, const QString &cursor) +{ + QUrl url("http://api.twitter.com/1/friends/ids.json"); + + url.addQueryItem("user_id", QString::number(user)); + url.addQueryItem("cursor", cursor); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +/** + * Start fetcing one page of id's + * @param screenName the screen name of the user for whom to return results for. + * @param cursor use from response nextCursor and prevCursor to allow paging back and forth + */ +void QTweetFriendsID::fetch(const QString &screenName, const QString &cursor) +{ + QUrl url("http://api.twitter.com/1/friends/ids.json"); + + url.addQueryItem("screen_name", screenName); + url.addQueryItem("cursor", cursor); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetFriendsID::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList idList; + + QVariantMap respMap = json.toMap(); + + QVariantList idVarList = respMap["ids"].toList(); + + foreach (const QVariant& idVar, idVarList) + idList.append(idVar.toLongLong()); + + QString nextCursor = respMap["next_cursor_str"].toString(); + QString prevCursor = respMap["previous_cursor_str"].toString(); + + emit parsedIDs(idList, nextCursor, prevCursor); + } else { + qDebug() << "QTweetFriendsID parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetfriendsid.h b/thirdparty/QTweetLib/src/qtweetfriendsid.h new file mode 100644 index 000000000..2899f8f93 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfriendsid.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETFRIENDSID_H +#define QTWEETFRIENDSID_H + +#include "qtweetnetbase.h" + +/** + * Returns an list of numeric IDs for every user the specified user is following. + */ +class QTWEETLIBSHARED_EXPORT QTweetFriendsID : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetFriendsID(QObject *parent = 0); + QTweetFriendsID(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 user, + const QString& cursor = QString("-1")); + void fetch(const QString& screenName, + const QString& cursor = QString("-1")); + +signals: + /** Emits one page of ids + * @param ids list of ids user is following + * @param nextCursor cursor for next page, "0" if there is no page + * @param prevCursor cursor for prev page "0" if there is no page + */ + void parsedIDs(const QList& ids, + const QString& nextCursor, + const QString& prevCursor); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETFRIENDSID_H diff --git a/thirdparty/QTweetLib/src/qtweetfriendstimeline.cpp b/thirdparty/QTweetLib/src/qtweetfriendstimeline.cpp new file mode 100644 index 000000000..fd4e3f9e6 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfriendstimeline.cpp @@ -0,0 +1,113 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetfriendstimeline.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetFriendsTimeline::QTweetFriendsTimeline(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetFriendsTimeline::QTweetFriendsTimeline(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts fetching friends timeline + * @param sinceid fetch tweets newer then sinceid + * @param maxid fetch tweets older then maxid + * @param count number of tweet to fetch (up to 200) + * @param page page Number (starts from 1) + * @param skipUser don't show user info in timeline (only id) + * @param includeRts timeline contains native retweets if true + * @param includeEntities each tweet will include node "entities" + * @remarks Setting parameter to default value will not be put in query + */ +void QTweetFriendsTimeline::fetch(qint64 sinceid, + qint64 maxid, + int count, + int page, + bool trimUser, + bool includeRts, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled."); + return; + } + + QUrl url("http://api.twitter.com/1/statuses/friends_timeline.json"); + + if (sinceid != 0) + url.addQueryItem("since_id", QString::number(sinceid)); + + if (maxid != 0) + url.addQueryItem("max_id", QString::number(maxid)); + + if (count != 0) + url.addQueryItem("count", QString::number(count)); + + if (page != 0) + url.addQueryItem("page", QString::number(page)); + + if (trimUser) + url.addQueryItem("trim_user", "true"); + + if (includeRts) + url.addQueryItem("include_rts", "true"); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetFriendsTimeline::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList statuses = QTweetConvert::variantToStatusList(json); + + emit parsedStatuses(statuses); + } else { + qDebug() << "QTweetFriendsTimeline JSON Parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetfriendstimeline.h b/thirdparty/QTweetLib/src/qtweetfriendstimeline.h new file mode 100644 index 000000000..04e7cd293 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetfriendstimeline.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETFRIENDSTIMELINE_H +#define QTWEETFRIENDSTIMELINE_H + +#include "qtweetnetbase.h" + +class QTweetStatus; + +/** + * Class for fetching twitter friends timeline + */ +class QTWEETLIBSHARED_EXPORT QTweetFriendsTimeline : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetFriendsTimeline(QObject *parent = 0); + QTweetFriendsTimeline(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 sinceid = 0, + qint64 maxid = 0, + int count = 0, + int page = 0, + bool trimUser = false, + bool includeRts = false, + bool includeEntities = false); + +signals: + /** Emits friends timeline status list */ + void parsedStatuses(const QList& statuses); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETTERFRIENDSTIMELINE_H diff --git a/thirdparty/QTweetLib/src/qtweetgeoboundingbox.cpp b/thirdparty/QTweetLib/src/qtweetgeoboundingbox.cpp new file mode 100644 index 000000000..65142a8b8 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeoboundingbox.cpp @@ -0,0 +1,42 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "qtweetgeoboundingbox.h" + +QTweetGeoBoundingBox::QTweetGeoBoundingBox() +{ +} + +QTweetGeoBoundingBox::QTweetGeoBoundingBox(const QTweetGeoCoord &topLeft, + const QTweetGeoCoord &topRight, + const QTweetGeoCoord &bottomRight, + const QTweetGeoCoord &bottomLeft) +{ + setTopLeft(topLeft); + setTopRight(topRight); + setBottomRight(bottomRight); + setBottomLeft(bottomLeft); +} + +bool QTweetGeoBoundingBox::isValid() const +{ + return m_topLeft.isValid() & m_topRight.isValid() & + m_bottomRight.isValid() & m_bottomLeft.isValid(); +} diff --git a/thirdparty/QTweetLib/src/qtweetgeoboundingbox.h b/thirdparty/QTweetLib/src/qtweetgeoboundingbox.h new file mode 100644 index 000000000..3a3c57bd8 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeoboundingbox.h @@ -0,0 +1,56 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETGEOBOUNDINGBOX_H +#define QTWEETGEOBOUNDINGBOX_H + +#include "qtweetlib_global.h" +#include "qtweetgeocoord.h" + +/** + * Stores geo bounding box + * Doesnt' do anything fancy/calculations just stores boundind box info from twitter api + */ +class QTWEETLIBSHARED_EXPORT QTweetGeoBoundingBox +{ +public: + QTweetGeoBoundingBox(); + QTweetGeoBoundingBox(const QTweetGeoCoord& topLeft, + const QTweetGeoCoord& topRight, + const QTweetGeoCoord& bottomRight, + const QTweetGeoCoord& bottomLeft); + QTweetGeoCoord topLeft() const { return m_topLeft; } + QTweetGeoCoord topRight() const { return m_topRight; } + QTweetGeoCoord bottomRight() const { return m_bottomRight; } + QTweetGeoCoord bottomLeft() const { return m_bottomLeft; } + void setTopLeft(const QTweetGeoCoord& topLeft) { m_topLeft = topLeft; } + void setTopRight(const QTweetGeoCoord& topRight) { m_topRight = topRight; } + void setBottomRight(const QTweetGeoCoord& bottomRight) { m_bottomRight = bottomRight; } + void setBottomLeft(const QTweetGeoCoord& bottomLeft) { m_bottomLeft = bottomLeft; } + bool isValid() const; + +private: + QTweetGeoCoord m_topLeft; + QTweetGeoCoord m_topRight; + QTweetGeoCoord m_bottomRight; + QTweetGeoCoord m_bottomLeft; +}; + +#endif // QTWEETGEOBOUNDINGBOX_H diff --git a/thirdparty/QTweetLib/src/qtweetgeocoord.cpp b/thirdparty/QTweetLib/src/qtweetgeocoord.cpp new file mode 100644 index 000000000..66cab3ba8 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeocoord.cpp @@ -0,0 +1,57 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "qtweetgeocoord.h" + +QTweetGeoCoord::QTweetGeoCoord() + : m_validLatitude(false), m_validLongitude(false) +{ +} + +QTweetGeoCoord::QTweetGeoCoord(double latitude, double longitude) +{ + setLatitude(latitude); + setLongitude(longitude); +} + +bool QTweetGeoCoord::isValid() const +{ + return m_validLatitude & m_validLongitude; +} + +void QTweetGeoCoord::setLatitude(double latitude) +{ + m_latitude = latitude; + + if (m_latitude > -90.0 || m_latitude < 90.0) + m_validLatitude = true; + else + m_validLatitude = false; +} + +void QTweetGeoCoord::setLongitude(double longitude) +{ + m_longitude = longitude; + + if (m_longitude > -180.0 || m_longitude < 180.0) + m_validLongitude = true; + else + m_validLongitude = false; +} diff --git a/thirdparty/QTweetLib/src/qtweetgeocoord.h b/thirdparty/QTweetLib/src/qtweetgeocoord.h new file mode 100644 index 000000000..1e0fff824 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeocoord.h @@ -0,0 +1,48 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETGEOCOORD_H +#define QTWEETGEOCOORD_H + +#include "qtweetlib_global.h" + +/** + * Stores latitude/longitude coordinates + * Does basic checking if latitude/longitude is in valid degrees + */ +class QTWEETLIBSHARED_EXPORT QTweetGeoCoord +{ +public: + QTweetGeoCoord(); + QTweetGeoCoord(double latitude, double longitude); + bool isValid() const; + double latitude() const { return m_latitude; } + double longitude() const { return m_longitude; } + void setLatitude(double latitude); + void setLongitude(double longitude); + +private: + double m_latitude; + double m_longitude; + bool m_validLatitude; + bool m_validLongitude; +}; + +#endif // QTWEETGEOCOORD_H diff --git a/thirdparty/QTweetLib/src/qtweetgeoplacecreate.cpp b/thirdparty/QTweetLib/src/qtweetgeoplacecreate.cpp new file mode 100644 index 000000000..df4bb4b30 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeoplacecreate.cpp @@ -0,0 +1,96 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetgeoplacecreate.h" +#include "qtweetplace.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetGeoPlaceCreate::QTweetGeoPlaceCreate(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetGeoPlaceCreate::QTweetGeoPlaceCreate(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Creates place + * @param name the name a place is known as + * @param containedWithin placeid within which the new place can be found. Be close as possible with + contained place + * @param token token found in the response from QTweetGeoSimilarPlaces + * @param latLong latitude and longitude + */ +void QTweetGeoPlaceCreate::create(const QString &name, + const QString &containedWithin, + const QString &token, + const QTweetGeoCoord &latLong) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/geo/place.json"); + QUrl urlQuery(url); + + urlQuery.addEncodedQueryItem("name", QUrl::toPercentEncoding(name)); + urlQuery.addQueryItem("contained_within", containedWithin); + urlQuery.addQueryItem("token", token); + urlQuery.addQueryItem("lat", QString::number(latLong.latitude())); + urlQuery.addQueryItem("long", QString::number(latLong.longitude())); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST); + + QNetworkRequest req(url); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QByteArray statusPost = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath); + statusPost.remove(0, 1); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, statusPost); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetGeoPlaceCreate::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetPlace place = QTweetConvert::variantMapToPlaceRecursive(json.toMap()); + + emit parsedPlace(place); + } else { + qDebug() << "QTweetGeoPlaceCreate parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetgeoplacecreate.h b/thirdparty/QTweetLib/src/qtweetgeoplacecreate.h new file mode 100644 index 000000000..f503801bd --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeoplacecreate.h @@ -0,0 +1,52 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETGEOPLACECREATE_H +#define QTWEETGEOPLACECREATE_H + +#include "qtweetnetbase.h" + +class QTweetPlace; +class QTweetGeoCoord; + +/** + * Creates a new place at the given latitude and longitude + */ +class QTWEETLIBSHARED_EXPORT QTweetGeoPlaceCreate : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetGeoPlaceCreate(QObject *parent = 0); + QTweetGeoPlaceCreate(OAuthTwitter *oauthTwitter, QObject *parent = 0); + + void create(const QString& name, + const QString& containedWithin, + const QString& token, + const QTweetGeoCoord& latLong); + +signals: + /** Emits geo place */ + void parsedPlace(const QTweetPlace& place); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETGEOPLACECREATE_H diff --git a/thirdparty/QTweetLib/src/qtweetgeoplaceid.cpp b/thirdparty/QTweetLib/src/qtweetgeoplaceid.cpp new file mode 100644 index 000000000..c3cdd909f --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeoplaceid.cpp @@ -0,0 +1,76 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetgeoplaceid.h" +#include "qtweetplace.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetGeoPlaceID::QTweetGeoPlaceID(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetGeoPlaceID::QTweetGeoPlaceID(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts fetching information about place + * @param placeid a place in the world. These ID's can be retrieved from QTweetGeoReverseGeoCode + */ +void QTweetGeoPlaceID::get(const QString &placeid) +{ + QUrl url(QString("http://api.twitter.com/1/geo/id/%1.json").arg(placeid)); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetGeoPlaceID::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetPlace place = QTweetConvert::variantMapToPlaceRecursive(json.toMap()); + + emit parsedPlace(place); + } else { + qDebug() << "QTweetGeoPlaceID parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetgeoplaceid.h b/thirdparty/QTweetLib/src/qtweetgeoplaceid.h new file mode 100644 index 000000000..f25400387 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeoplaceid.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETGEOPLACEID_H +#define QTWEETGEOPLACEID_H + +#include "qtweetnetbase.h" + +class QTweetPlace; + +/** + * Fetches all the information about a known place + */ +class QTWEETLIBSHARED_EXPORT QTweetGeoPlaceID : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetGeoPlaceID(QObject *parent = 0); + QTweetGeoPlaceID(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void get(const QString& placeid); + +signals: + /** Emits the place */ + void parsedPlace(const QTweetPlace& place); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETGEOPLACEID_H diff --git a/thirdparty/QTweetLib/src/qtweetgeoreversegeocode.cpp b/thirdparty/QTweetLib/src/qtweetgeoreversegeocode.cpp new file mode 100644 index 000000000..d3844e9e3 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeoreversegeocode.cpp @@ -0,0 +1,110 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetgeoreversegeocode.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetGeoReverseGeoCode::QTweetGeoReverseGeoCode(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetGeoReverseGeoCode::QTweetGeoReverseGeoCode(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Start geo reversing + * @param latLong latitutde and longitude + * @param accuracy a hint on the "region" in which to search in meters + * @param granularity minimal granularity of place types to return + * @param maxResults hint as to the number of results to return + */ +void QTweetGeoReverseGeoCode::getPlaces(const QTweetGeoCoord& latLong, + int accuracy, + QTweetPlace::Type granularity, + int maxResults) +{ + QUrl url("http://api.twitter.com/1/geo/reverse_geocode.json"); + + url.addQueryItem("lat", QString::number(latLong.latitude())); + url.addQueryItem("long", QString::number(latLong.longitude())); + + if (accuracy != 0) + url.addQueryItem("accuracy", QString::number(accuracy)); + + switch (granularity) { + case QTweetPlace::Poi: + url.addQueryItem("granularity", "poi"); + break; + case QTweetPlace::Neighborhood: + url.addQueryItem("granularity", "neighborhood"); + break; + case QTweetPlace::City: + url.addQueryItem("granularity", "city"); + break; + case QTweetPlace::Admin: + url.addQueryItem("granularity", "admin"); + break; + case QTweetPlace::Country: + url.addQueryItem("granularity", "country"); + break; + default: + ; + } + + if (maxResults != 0) + url.addQueryItem("max_results", QString::number(maxResults)); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetGeoReverseGeoCode::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList places = QTweetConvert::variantToPlaceList(json); + + emit parsedPlaces(places); + } else { + qDebug() << "QTweetGeoReverseGeoCode parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetgeoreversegeocode.h b/thirdparty/QTweetLib/src/qtweetgeoreversegeocode.h new file mode 100644 index 000000000..b00dc7f72 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeoreversegeocode.h @@ -0,0 +1,51 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETGEOREVERSEGEOCODE_H +#define QTWEETGEOREVERSEGEOCODE_H + +#include "qtweetnetbase.h" +#include "qtweetplace.h" + +/** + * Given a latitude and a longitude, searches up to 20 places that can be used + * as placeId when updating a status + */ +class QTWEETLIBSHARED_EXPORT QTweetGeoReverseGeoCode : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetGeoReverseGeoCode(QObject *parent = 0); + QTweetGeoReverseGeoCode(OAuthTwitter *oauthTwitter, QObject *parent = 0); + + void getPlaces(const QTweetGeoCoord& latLong, + int accuracy = 0, + QTweetPlace::Type granularity = QTweetPlace::Neighborhood, + int maxResults = 0); + +signals: + /** Emits list of places */ + void parsedPlaces(const QList& places); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETGEOREVERSEGEOCODE_H diff --git a/thirdparty/QTweetLib/src/qtweetgeosearch.cpp b/thirdparty/QTweetLib/src/qtweetgeosearch.cpp new file mode 100644 index 000000000..d061e6dd3 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeosearch.cpp @@ -0,0 +1,129 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetgeosearch.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetGeoSearch::QTweetGeoSearch(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetGeoSearch::QTweetGeoSearch(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts geo searching + * @param latLong latitude and longitude + * @param query text to match against while executing a geo-based query, + * best suited for finding nearby locations by name + * @param ip ip address. Used when attempting to fix geolocation based off of the user's IP address. + * @param granularity this is the minimal granularity of place types to return + * @param accuracy hint on the "region" in which to search in meters + * @param maxResults hint as to the number of results to return + * @param containedWithin this is the placeID which you would like to restrict the search results to + */ +void QTweetGeoSearch::search(const QTweetGeoCoord &latLong, + const QString &query, + const QString &ip, + QTweetPlace::Type granularity, + int accuracy, + int maxResults, + const QString &containedWithin) +{ + QUrl url("http://api.twitter.com/1/geo/search.json"); + + if (latLong.isValid()) { + url.addQueryItem("lat", QString::number(latLong.latitude())); + url.addQueryItem("long", QString::number(latLong.longitude())); + } + + if (!query.isEmpty()) + url.addEncodedQueryItem("query", QUrl::toPercentEncoding(query)); + + if (!ip.isEmpty()) + //doesn't do ip format address checking + url.addQueryItem("ip", ip); + + switch (granularity) { + case QTweetPlace::Poi: + url.addQueryItem("granularity", "poi"); + break; + case QTweetPlace::Neighborhood: + url.addQueryItem("granularity", "neighborhood"); + break; + case QTweetPlace::City: + url.addQueryItem("granularity", "city"); + break; + case QTweetPlace::Admin: + url.addQueryItem("granularity", "admin"); + break; + case QTweetPlace::Country: + url.addQueryItem("granularity", "country"); + break; + default: + ; + } + + if (accuracy != 0) + url.addQueryItem("accuracy", QString::number(accuracy)); + + if (maxResults != 0) + url.addQueryItem("max_results", QString::number(maxResults)); + + if (!containedWithin.isEmpty()) + url.addQueryItem("contained_within", containedWithin); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetGeoSearch::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList places = QTweetConvert::variantToPlaceList(json); + + emit parsedPlaces(places); + } else { + qDebug() << "QTweetGeoSearch parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetgeosearch.h b/thirdparty/QTweetLib/src/qtweetgeosearch.h new file mode 100644 index 000000000..84ead95d6 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeosearch.h @@ -0,0 +1,55 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETGEOSEARCH_H +#define QTWEETGEOSEARCH_H + +#include "qtweetplace.h" +#include "qtweetnetbase.h" + + +/** + * Search for places that can be attached to a statuses/update + * @see http://dev.twitter.com/doc/get/geo/search + */ +class QTWEETLIBSHARED_EXPORT QTweetGeoSearch : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetGeoSearch(QObject *parent = 0); + QTweetGeoSearch(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void search(const QTweetGeoCoord& latLong = QTweetGeoCoord(), + const QString& query = QString(), + const QString& ip = QString(), + QTweetPlace::Type granularity = QTweetPlace::Neighborhood, + int accuracy = 0, + int maxResults = 0, + const QString& containedWithin = QString()); + // ### TODO Atributes, not enough documentation + +signals: + /** Emits list of places */ + void parsedPlaces(const QList& places); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETGEOSEARCH_H diff --git a/thirdparty/QTweetLib/src/qtweetgeosimilarplaces.cpp b/thirdparty/QTweetLib/src/qtweetgeosimilarplaces.cpp new file mode 100644 index 000000000..5a90b606f --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeosimilarplaces.cpp @@ -0,0 +1,92 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include +#include "qtweetplace.h" +#include "qtweetgeosimilarplaces.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetGeoSimilarPlaces::QTweetGeoSimilarPlaces(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetGeoSimilarPlaces::QTweetGeoSimilarPlaces(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Start fetching similar places + * @param latLong latitude and longitude + * @param name the name a place is known as + * @param containedWithin this is the placeID which you would like to restrict the search results to + */ +void QTweetGeoSimilarPlaces::get(const QTweetGeoCoord &latLong, const QString &name, const QString &containedWithin) +{ + QUrl url("http://api.twitter.com/1/geo/similar_places.json"); + + url.addQueryItem("lat", QString::number(latLong.latitude())); + url.addQueryItem("long",QString::number(latLong.longitude())); + url.addEncodedQueryItem("name", QUrl::toPercentEncoding(name)); + + if (!containedWithin.isEmpty()) + url.addQueryItem("contained_within", containedWithin); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetGeoSimilarPlaces::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList places = QTweetConvert::variantToPlaceList(json); + + //get token + QVariantMap respMap = json.toMap(); + QVariantMap resultMap = respMap["result"].toMap(); + + QString token = resultMap["token"].toString(); + + emit parsedPlaces(places, token); + } else { + qDebug() << "QTweetGeoSimilarPlaces parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetgeosimilarplaces.h b/thirdparty/QTweetLib/src/qtweetgeosimilarplaces.h new file mode 100644 index 000000000..058b007a6 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetgeosimilarplaces.h @@ -0,0 +1,55 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETGEOSIMILARPLACES_H +#define QTWEETGEOSIMILARPLACES_H + +#include "qtweetnetbase.h" + +class QTweetPlace; +class QTweetGeoCoord; + +/** + * Locates places near the given coordinates which are similar in name + * @see http://dev.twitter.com/doc/get/geo/similar_places + */ +class QTWEETLIBSHARED_EXPORT QTweetGeoSimilarPlaces : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetGeoSimilarPlaces(QObject *parent = 0); + QTweetGeoSimilarPlaces(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void get(const QTweetGeoCoord& latLong, + const QString& name, + const QString& containedWithin = QString()); + // ### TODO: Atributes, lack of documentation + +signals: + /** Emits places + * @param places list of places + * @param token token to create a new place + */ + void parsedPlaces(const QList& places, const QString& token); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETGEOSIMILARPLACES_H diff --git a/thirdparty/QTweetLib/src/qtweethometimeline.cpp b/thirdparty/QTweetLib/src/qtweethometimeline.cpp new file mode 100644 index 000000000..f399c608f --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweethometimeline.cpp @@ -0,0 +1,109 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweethometimeline.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +/** + * Constructor + */ +QTweetHomeTimeline::QTweetHomeTimeline(QObject *parent) : + QTweetNetBase(parent) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuthTwitter object + * @param parent parent QObject + */ +QTweetHomeTimeline::QTweetHomeTimeline(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Start fetching home timeline + * @param sinceid fetches tweets with ID greater (more recent) then sinceid + * @param maxid fetches tweets with ID less (older) then maxid + * @param count number of tweets to fetch (up to 200) + * @param page page number + * @param skipUser true to include only status authors numerical ID + * @param includeEntities true to include a node called "entities" + * @remarks Setting parameter to default value will not be put in a querys + */ +void QTweetHomeTimeline::fetch(qint64 sinceid, + qint64 maxid, + int count, + int page, + bool trimUser, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/statuses/home_timeline.json"); + + if (sinceid != 0) + url.addQueryItem("since_id", QString::number(sinceid)); + + if (maxid != 0) + url.addQueryItem("max_id", QString::number(maxid)); + + if (count != 0) + url.addQueryItem("count", QString::number(count)); + + if (page != 0) + url.addQueryItem("page", QString::number(page)); + + if (trimUser) + url.addQueryItem("trim_user", "true"); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetHomeTimeline::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList statuses = QTweetConvert::variantToStatusList(json); + + emit parsedStatuses(statuses); + } else { + qDebug() << "QTweetHomeTimeline JSON parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweethometimeline.h b/thirdparty/QTweetLib/src/qtweethometimeline.h new file mode 100644 index 000000000..50d614cb1 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweethometimeline.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETHOMETIMELINE_H +#define QTWEETHOMETIMELINE_H + +#include "qtweetnetbase.h" + +/** + * Fetches user home timeline + */ +class QTWEETLIBSHARED_EXPORT QTweetHomeTimeline : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetHomeTimeline(QObject *parent = 0); + QTweetHomeTimeline(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 sinceid = 0, + qint64 maxid = 0, + int count = 0, + int page = 0, + bool trimUser = false, + bool includeEntities = false); + +signals: + /** Emits hometimeline status list */ + void parsedStatuses(const QList& statuses); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETHOMETIMELINE_H diff --git a/thirdparty/QTweetLib/src/qtweetlib_global.h b/thirdparty/QTweetLib/src/qtweetlib_global.h new file mode 100644 index 000000000..2590a1958 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlib_global.h @@ -0,0 +1,36 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLIB_GLOBAL_H +#define QTWEETLIB_GLOBAL_H + +#include + +#ifndef QTWEETLIBSHARED_EXPORT +# if defined (QTWEETLIB_MAKEDLL) +# define QTWEETLIBSHARED_EXPORT Q_DECL_EXPORT +# else +# define QTWEETLIBSHARED_EXPORT Q_DECL_IMPORT +# endif +#endif + +#define AUTH_HEADER "Authorization" + +#endif // QTWEETLIB_GLOBAL_H diff --git a/thirdparty/QTweetLib/src/qtweetlist.cpp b/thirdparty/QTweetLib/src/qtweetlist.cpp new file mode 100644 index 000000000..fa27f33c4 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlist.cpp @@ -0,0 +1,170 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include "qtweetlist.h" +#include "qtweetuser.h" + +class QTweetListData : public QSharedData +{ +public: + QString mode; + QString description; + bool following; + int memberCount; + QString fullname; + int subscriberCount; + QString slug; + QString name; + qint64 id; + QString uri; + QTweetUser user; +}; + +QTweetList::QTweetList() : + d(new QTweetListData) +{ +} + +QTweetList::QTweetList(const QTweetList &other) : + d(other.d) +{ +} + +QTweetList& QTweetList::operator =(const QTweetList& other) +{ + if (this != &other) + d.operator =(other.d); + return *this; +} + +QTweetList::~QTweetList() +{ +} + +void QTweetList::setMode(const QString &mode) +{ + d->mode = mode; +} + +QString QTweetList::mode() const +{ + return d->mode; +} + +void QTweetList::setDescription(const QString &desc) +{ + d->description = desc; +} + +QString QTweetList::description() const +{ + return d->description; +} + +void QTweetList::setFollowing(bool following) +{ + d->following = following; +} + +bool QTweetList::following() const +{ + return d->following; +} + +void QTweetList::setMemberCount(int count) +{ + d->memberCount = count; +} + +int QTweetList::memberCount() const +{ + return d->memberCount; +} + +void QTweetList::setFullName(const QString &name) +{ + d->fullname = name; +} + +QString QTweetList::fullName() const +{ + return d->fullname; +} + +void QTweetList::setSubscriberCount(int count) +{ + d->subscriberCount = count; +} + +int QTweetList::subscriberCount() const +{ + return d->subscriberCount; +} + +void QTweetList::setSlug(const QString &slug) +{ + d->slug = slug; +} + +QString QTweetList::slug() const +{ + return d->slug; +} + +void QTweetList::setName(const QString &name) +{ + d->name = name; +} + +QString QTweetList::name() const +{ + return d->name; +} + +void QTweetList::setId(qint64 id) +{ + d->id = id; +} + +qint64 QTweetList::id() const +{ + return d->id; +} + +void QTweetList::setUri(const QString &uri) +{ + d->uri = uri; +} + +QString QTweetList::uri() const +{ + return d->uri; +} + +void QTweetList::setUser(const QTweetUser &user) +{ + d->user = user; +} + +QTweetUser QTweetList::user() const +{ + return d->user; +} diff --git a/thirdparty/QTweetLib/src/qtweetlist.h b/thirdparty/QTweetLib/src/qtweetlist.h new file mode 100644 index 000000000..51b6ca994 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlist.h @@ -0,0 +1,71 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLIST_H +#define QTWEETLIST_H + +#include +#include +#include "qtweetlib_global.h" + +class QTweetUser; +class QTweetListData; + +/** + * Stores list information + */ +class QTWEETLIBSHARED_EXPORT QTweetList +{ +public: + QTweetList(); + QTweetList(const QTweetList& other); + QTweetList& operator=(const QTweetList& other); + ~QTweetList(); + + void setMode(const QString& mode); + QString mode() const; + void setDescription(const QString& desc); + QString description() const; + void setFollowing(bool following); + bool following() const; + void setMemberCount(int count); + int memberCount() const; + void setFullName(const QString& name); + QString fullName() const; + void setSubscriberCount(int count); + int subscriberCount() const; + void setSlug(const QString& slug); + QString slug() const; + void setName(const QString& name); + QString name() const; + void setId(qint64 id); + qint64 id() const; + void setUri(const QString& uri); + QString uri() const; + void setUser(const QTweetUser& user); + QTweetUser user() const; + +private: + QSharedDataPointer d; +}; + +Q_DECLARE_METATYPE(QTweetList) + +#endif // QTWEETLIST_H diff --git a/thirdparty/QTweetLib/src/qtweetlistaddmember.cpp b/thirdparty/QTweetLib/src/qtweetlistaddmember.cpp new file mode 100644 index 000000000..fcc957d3c --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistaddmember.cpp @@ -0,0 +1,74 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetlistaddmember.h" +#include "qtweetlist.h" +#include "qtweetconvert.h" + +QTweetListAddMember::QTweetListAddMember(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListAddMember::QTweetListAddMember(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * @param user user id (owner of the list) + * @param list list id + * @param memberid user id of the list member + */ +void QTweetListAddMember::add(qint64 user, qint64 list, qint64 memberid) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/%2/members.json").arg(user).arg(list)); + + url.addQueryItem("id", QString::number(memberid)); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::POST); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, QByteArray()); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListAddMember::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetList list = QTweetConvert::variantMapToTweetList(json.toMap()); + + emit parsedList(list); + } else { + qDebug() << "QTweetListAddMember parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetlistaddmember.h b/thirdparty/QTweetLib/src/qtweetlistaddmember.h new file mode 100644 index 000000000..25337c17a --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistaddmember.h @@ -0,0 +1,49 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTADDMEMBER_H +#define QTWEETLISTADDMEMBER_H + +#include "qtweetnetbase.h" + +/** + * Add a member to a list. + * The authenticated user must own the list to be able to add members to it. + * Lists are limited to having 500 members. + */ +class QTWEETLIBSHARED_EXPORT QTweetListAddMember : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListAddMember(QObject *parent = 0); + QTweetListAddMember(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void add(qint64 user, + qint64 list, + qint64 memberid); + +signals: + /** Emits list in which user was added */ + void parsedList(const QTweetList& list); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTADDMEMBER_H diff --git a/thirdparty/QTweetLib/src/qtweetlistcreate.cpp b/thirdparty/QTweetLib/src/qtweetlistcreate.cpp new file mode 100644 index 000000000..fc403bfb6 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistcreate.cpp @@ -0,0 +1,91 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include +#include "qjson/parserrunnable.h" +#include "qtweetlistcreate.h" +#include "qtweetlist.h" +#include "qtweetconvert.h" + +QTweetListCreate::QTweetListCreate(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListCreate::QTweetListCreate(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** Creates list + * @param user user id + * @param name the name of the list + * @param mode true for public list, false for private list + * @param description the description to give the list. + */ +void QTweetListCreate::create(qint64 user, + const QString &name, + bool mode, + const QString &description) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/lists.json").arg(user)); + + QUrl urlQuery(url); + + urlQuery.addEncodedQueryItem("name", QUrl::toPercentEncoding(name)); + + if (!mode) + urlQuery.addQueryItem("mode", "private"); + + if (!description.isEmpty()) + urlQuery.addEncodedQueryItem("description", QUrl::toPercentEncoding(description)); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath); + postBody.remove(0, 1); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListCreate::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetList list = QTweetConvert::variantMapToTweetList(json.toMap()); + + emit parsedList(list); + } else { + qDebug() << "QTweetListCreate json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetlistcreate.h b/thirdparty/QTweetLib/src/qtweetlistcreate.h new file mode 100644 index 000000000..958d08cdd --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistcreate.h @@ -0,0 +1,48 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTCREATE_H +#define QTWEETLISTCREATE_H + +#include "qtweetnetbase.h" + +/** + * Creates a new list for the authenticated user. + */ +class QTWEETLIBSHARED_EXPORT QTweetListCreate : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListCreate(QObject *parent = 0); + QTweetListCreate(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void create(qint64 user, + const QString& name, + bool mode = true, + const QString& description = QString()); + +signals: + /** Emits created list */ + void parsedList(const QTweetList& list); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTCREATE_H diff --git a/thirdparty/QTweetLib/src/qtweetlistdeletelist.cpp b/thirdparty/QTweetLib/src/qtweetlistdeletelist.cpp new file mode 100644 index 000000000..43b085ab5 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistdeletelist.cpp @@ -0,0 +1,73 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetlistdeletelist.h" +#include "qtweetlist.h" +#include "qtweetconvert.h" + +QTweetListDeleteList::QTweetListDeleteList(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListDeleteList::QTweetListDeleteList(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Deletes specified list + * @param user user id + * @param list list id + */ +void QTweetListDeleteList::deleteList(qint64 user, qint64 list) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/lists/%2.json").arg(user).arg(list)); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::DELETE); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->deleteResource(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListDeleteList::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + // I hope, Twitter API return list object, did not checked + QTweetList list = QTweetConvert::variantMapToTweetList(json.toMap()); + + emit deletedList(list); + } else { + qDebug() << "QTweetListDeleteList json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetlistdeletelist.h b/thirdparty/QTweetLib/src/qtweetlistdeletelist.h new file mode 100644 index 000000000..89a80d509 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistdeletelist.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTDELETELIST_H +#define QTWEETLISTDELETELIST_H + +#include "qtweetnetbase.h" + +/** + * Deletes the specified list. Must be owned by the authenticated user. + */ +class QTWEETLIBSHARED_EXPORT QTweetListDeleteList : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListDeleteList(QObject *parent = 0); + QTweetListDeleteList(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void deleteList(qint64 user, qint64 list); + +signals: + /** Emits deleted list */ + void deletedList(const QTweetList& list); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTDELETELIST_H diff --git a/thirdparty/QTweetLib/src/qtweetlistdeletemember.cpp b/thirdparty/QTweetLib/src/qtweetlistdeletemember.cpp new file mode 100644 index 000000000..b09a45cbe --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistdeletemember.cpp @@ -0,0 +1,74 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetlistdeletemember.h" +#include "qtweetlist.h" +#include "qtweetconvert.h" + +QTweetListDeleteMember::QTweetListDeleteMember(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListDeleteMember::QTweetListDeleteMember(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * @param user user id (owner of the list + * @param list list id + * @param member user id of the list member to remove + */ +void QTweetListDeleteMember::remove(qint64 user, qint64 list, qint64 member) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/%2/members.json").arg(user).arg(list)); + + url.addQueryItem("id", QString::number(member)); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::DELETE); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->deleteResource(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListDeleteMember::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetList list = QTweetConvert::variantMapToTweetList(json.toMap()); + + emit parsedList(list); + } else { + qDebug() << "QTweetListDeleteMember parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetlistdeletemember.h b/thirdparty/QTweetLib/src/qtweetlistdeletemember.h new file mode 100644 index 000000000..52c253fdc --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistdeletemember.h @@ -0,0 +1,48 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTDELETEMEMBER_H +#define QTWEETLISTDELETEMEMBER_H + +#include "qtweetnetbase.h" + +/** + * Removes the specified member from the list. + * The authenticated user must be the list's owner to remove members from the list. + */ +class QTWEETLIBSHARED_EXPORT QTweetListDeleteMember : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListDeleteMember(QObject *parent = 0); + QTweetListDeleteMember(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void remove(qint64 user, + qint64 list, + qint64 member); + +signals: + /** Emits list where member was deleted */ + void parsedList(const QTweetList& list); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTDELETEMEMBER_H diff --git a/thirdparty/QTweetLib/src/qtweetlistgetlists.cpp b/thirdparty/QTweetLib/src/qtweetlistgetlists.cpp new file mode 100644 index 000000000..437eb314f --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistgetlists.cpp @@ -0,0 +1,83 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetlistgetlists.h" +#include "qtweetlist.h" +#include "qtweetconvert.h" + +QTweetListGetLists::QTweetListGetLists(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListGetLists::QTweetListGetLists(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** Gets the lists + * @param user user id + * @param cursor breaks the results into pages. Provide a value of "-1" to begin paging. + */ +void QTweetListGetLists::getLists(qint64 user, + const QString &cursor) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/lists.json").arg(user)); + + if (!cursor.isEmpty()) + url.addQueryItem("cursor", cursor); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListGetLists::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QVariantMap respMap = json.toMap(); + + QVariant listsVar = respMap["lists"]; + + QList lists = QTweetConvert::variantToTweetLists(listsVar); + + QString nextCursor = respMap["next_cursor_str"].toString(); + QString prevCursor = respMap["previous_cursor_str"].toString(); + + emit parsedLists(lists, nextCursor, prevCursor); + } else { + qDebug() << "QTweetListGetLists json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetlistgetlists.h b/thirdparty/QTweetLib/src/qtweetlistgetlists.h new file mode 100644 index 000000000..0909abd20 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistgetlists.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTGETLISTS_H +#define QTWEETLISTGETLISTS_H + +#include "qtweetnetbase.h" + +/** + * Gets the lists of the specified user. + * Private lists will be included if the authenticated users is the same as the user who's lists are being returned. + */ +class QTWEETLIBSHARED_EXPORT QTweetListGetLists : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListGetLists(QObject *parent = 0); + QTweetListGetLists(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void getLists(qint64 user, + const QString& cursor = QString()); + +signals: + /** Emits page of lists + * @param lists + * @param nextCursor cursor for next page, "0" if there is no next page + * @param prevCursor cursor for prev page, "0" if there is no prev page + */ + void parsedLists(const QList& lists, + const QString& nextCursor, + const QString& prevCursor); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTGETLISTS_H diff --git a/thirdparty/QTweetLib/src/qtweetlistgetmembers.cpp b/thirdparty/QTweetLib/src/qtweetlistgetmembers.cpp new file mode 100644 index 000000000..347bbd960 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistgetmembers.cpp @@ -0,0 +1,93 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetlistgetmembers.h" +#include "qtweetuser.h" +#include "qtweetconvert.h" + +QTweetListGetMembers::QTweetListGetMembers(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListGetMembers::QTweetListGetMembers(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * @param user user id + * @param list list id + * @param cursor breaks the results into pages. + This is recommended for users who are following many users. + Provide a value of -1 to begin paging. + Provide values as returned in the signal nextCursor and prevCursor to page back and forth in the list. + * @param includeEntities When set to true tweet will include a node called "entities," + */ +void QTweetListGetMembers::get(qint64 user, + qint64 list, + const QString &cursor, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/%2/members.json").arg(user).arg(list)); + + if (!cursor.isEmpty()) + url.addQueryItem("cursor", cursor); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListGetMembers::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QVariantMap respMap = json.toMap(); + + QVariant userList = respMap["users"]; + + QList users = QTweetConvert::variantToUserInfoList(userList); + + QString nextCursor = respMap["next_cursor_str"].toString(); + QString prevCursor = respMap["previous_cursor_str"].toString(); + + emit parsedUsers(users, nextCursor, prevCursor); + } else { + qDebug() << "QTweetListGetMembers json parsing error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetlistgetmembers.h b/thirdparty/QTweetLib/src/qtweetlistgetmembers.h new file mode 100644 index 000000000..59437b6b6 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistgetmembers.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTGETMEMBERS_H +#define QTWEETLISTGETMEMBERS_H + +#include "qtweetnetbase.h" + +/** + * Gets the members of the specified list. + */ +class QTWEETLIBSHARED_EXPORT QTweetListGetMembers : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListGetMembers(QObject *parent = 0); + QTweetListGetMembers(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void get(qint64 user, + qint64 list, + const QString &cursor = QString(), + bool includeEntities = false); + +signals: + /** Emits page of users + * @param users list of users + * @param nextCursor cursor for next page, "0" if there is no next page + * @param prevCursor cursor for prev page, "0" if there is no prev page + */ + void parsedUsers(const QList& users, + const QString& nextCursor, + const QString& prevCursor); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTGETMEMBERS_H diff --git a/thirdparty/QTweetLib/src/qtweetlistmemberships.cpp b/thirdparty/QTweetLib/src/qtweetlistmemberships.cpp new file mode 100644 index 000000000..0301d899d --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistmemberships.cpp @@ -0,0 +1,84 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetlistmemberships.h" +#include "qtweetlist.h" +#include "qtweetconvert.h" + +QTweetListMemberships::QTweetListMemberships(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListMemberships::QTweetListMemberships(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * @param id user ID + * @param cursor breaks the results into pages. A single page contains 20 lists. + * Provide a value of -1 to begin paging. + * Provide values as returned next_cursor and previous_cursor attributes to page back and forth + */ +void QTweetListMemberships::fetch(qint64 id, const QString &cursor) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/lists/memberships.json").arg(id)); + + if (!cursor.isEmpty()) + url.addQueryItem("cursor", cursor); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListMemberships::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QVariantMap respMap = json.toMap(); + + QVariant listsVar = respMap["lists"]; + + QList lists = QTweetConvert::variantToTweetLists(listsVar); + + QString nextCursor = respMap["next_cursor_str"].toString(); + QString prevCursor = respMap["previous_cursor_str"].toString(); + + emit parsedList(lists, nextCursor, prevCursor); + } else { + qDebug() << "QTweetListMemberships json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetlistmemberships.h b/thirdparty/QTweetLib/src/qtweetlistmemberships.h new file mode 100644 index 000000000..8f5bdf881 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistmemberships.h @@ -0,0 +1,52 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTMEMBERSHIPS_H +#define QTWEETLISTMEMBERSHIPS_H + +#include "qtweetnetbase.h" + +/** + * Fetches the lists the specified user has been added to. + */ +class QTWEETLIBSHARED_EXPORT QTweetListMemberships : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListMemberships(QObject *parent = 0); + QTweetListMemberships(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 id, + const QString& cursor = QString()); + +signals: + /** Emits page of lists + * @param lists + * @param nextCursor cursor for next page, "0" if there is no next page + * @param prevCursor cursor for prev page, "0" if there is no prev page + */ + void parsedList(const QList& lists, + const QString& nextCursor, + const QString& prevCursor); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTMEMBERSHIPS_H diff --git a/thirdparty/QTweetLib/src/qtweetlistshowlist.cpp b/thirdparty/QTweetLib/src/qtweetlistshowlist.cpp new file mode 100644 index 000000000..ff0fc7cb5 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistshowlist.cpp @@ -0,0 +1,74 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetlistshowlist.h" +#include "qtweetlist.h" +#include "qtweetconvert.h" + +QTweetListShowList::QTweetListShowList(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListShowList::QTweetListShowList(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Shows (gets) specified list + * @param id user id + * @param list list id + */ +void QTweetListShowList::show(qint64 id, qint64 list) +{ + // slug parameter? + + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/lists/%2.json").arg(id).arg(list)); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListShowList::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetList list = QTweetConvert::variantMapToTweetList(json.toMap()); + + emit parsedList(list); + } else { + qDebug() << "QTweetListShowList json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetlistshowlist.h b/thirdparty/QTweetLib/src/qtweetlistshowlist.h new file mode 100644 index 000000000..9ea67b05b --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistshowlist.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTSHOWLIST_H +#define QTWEETLISTSHOWLIST_H + +#include "qtweetnetbase.h" + +/** + * Show the specified list. + * Private lists will only be shown if the authenticated user owns the specified list. + */ +class QTWEETLIBSHARED_EXPORT QTweetListShowList : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListShowList(QObject *parent = 0); + QTweetListShowList(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void show(qint64 id, qint64 list); + +signals: + /** Emits the list */ + void parsedList(const QTweetList& list); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTSHOWLIST_H diff --git a/thirdparty/QTweetLib/src/qtweetliststatuses.cpp b/thirdparty/QTweetLib/src/qtweetliststatuses.cpp new file mode 100644 index 000000000..c61ee2520 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetliststatuses.cpp @@ -0,0 +1,95 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetliststatuses.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +QTweetListStatuses::QTweetListStatuses(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListStatuses::QTweetListStatuses(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * @param user user id + * @param list list id + * @param sinceid returns results with an ID greater than (that is, more recent than) the specified ID. + * @param maxid returns results with an ID less than (that is, older than) or equal to the specified ID. + * @param perPage specifies how many tweets per page + * @param page specifies the page of results to retrieve. + * @param includeEntities when set to true each tweet will include a node called "entities," + * @remarks Setting parameter to default value will not be put in query + */ +void QTweetListStatuses::fetch(qint64 user, + qint64 list, + qint64 sinceid, + qint64 maxid, + int perPage, + int page, + bool includeEntities) +{ + QUrl url(QString("http://api.twitter.com/1/%1/lists/%2/statuses.json").arg(user).arg(list)); + + if (sinceid != 0) + url.addQueryItem("since_id", QString::number(sinceid)); + + if (maxid != 0) + url.addQueryItem("max_id", QString::number(maxid)); + + if (perPage != 0) + url.addQueryItem("per_page", QString::number(perPage)); + + if (page != 0) + url.addQueryItem("page", QString::number(page)); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListStatuses::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList statuses = QTweetConvert::variantToStatusList(json); + + emit parsedStatuses(statuses); + } else { + qDebug() << "QTweetListStatuses json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetliststatuses.h b/thirdparty/QTweetLib/src/qtweetliststatuses.h new file mode 100644 index 000000000..c2d3a738a --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetliststatuses.h @@ -0,0 +1,51 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTSTATUSES_H +#define QTWEETLISTSTATUSES_H + +#include "qtweetnetbase.h" + +/** + * Fetches tweet timeline for members of the specified list. + */ +class QTWEETLIBSHARED_EXPORT QTweetListStatuses : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListStatuses(QObject *parent = 0); + QTweetListStatuses(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 user, + qint64 list, + qint64 sinceid = 0, + qint64 maxid = 0, + int perPage = 0, + int page = 0, + bool includeEntities = false); + +signals: + /** Emits the statuses of a specified list */ + void parsedStatuses(const QList& statuses); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTSTATUSES_H diff --git a/thirdparty/QTweetLib/src/qtweetlistsubscribe.cpp b/thirdparty/QTweetLib/src/qtweetlistsubscribe.cpp new file mode 100644 index 000000000..30b436fa8 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistsubscribe.cpp @@ -0,0 +1,72 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetlistsubscribe.h" +#include "qtweetlist.h" +#include "qtweetconvert.h" + +QTweetListSubscribe::QTweetListSubscribe(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListSubscribe::QTweetListSubscribe(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * @param user user id owner of the list + * @param list list id + */ +void QTweetListSubscribe::follow(qint64 user, qint64 list) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/%2/subscribers.json").arg(user).arg(list)); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::POST); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, QByteArray()); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListSubscribe::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetList list = QTweetConvert::variantMapToTweetList(json.toMap()); + + emit parsedList(list); + } else { + qDebug() << "QTweetListSubscribe parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetlistsubscribe.h b/thirdparty/QTweetLib/src/qtweetlistsubscribe.h new file mode 100644 index 000000000..2f9a07679 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistsubscribe.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTSUBSCRIBE_H +#define QTWEETLISTSUBSCRIBE_H + +#include "qtweetnetbase.h" + +/** + * Make the authenticated user follow the specified list. + */ +class QTWEETLIBSHARED_EXPORT QTweetListSubscribe : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListSubscribe(QObject *parent = 0); + QTweetListSubscribe(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void follow(qint64 user, + qint64 list); + +signals: + /** Emits the specified list */ + void parsedList(const QTweetList& list); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTSUBSCRIBE_H diff --git a/thirdparty/QTweetLib/src/qtweetlistsubscribers.cpp b/thirdparty/QTweetLib/src/qtweetlistsubscribers.cpp new file mode 100644 index 000000000..864cc3cff --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistsubscribers.cpp @@ -0,0 +1,91 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetlistsubscribers.h" +#include "qtweetuser.h" +#include "qtweetconvert.h" + +QTweetListSubscribers::QTweetListSubscribers(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListSubscribers::QTweetListSubscribers(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * @param user user id + * @param list list id + * @param cursor breaks the results in pages. Set to "-1" to begin paging. + * Use prevCursor and nextCursor to page back and forth + * @param includeEntities when set to true each tweet will include a node called "entities," + */ +void QTweetListSubscribers::fetch(qint64 user, + qint64 list, + const QString &cursor, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/%2/subscribers.json").arg(user).arg(list)); + + if (!cursor.isEmpty()) + url.addQueryItem("cursor", cursor); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListSubscribers::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QVariantMap respMap = json.toMap(); + + QVariant userList = respMap["users"]; + + QList users = QTweetConvert::variantToUserInfoList(userList); + + QString nextCursor = respMap["next_cursor_str"].toString(); + QString prevCursor = respMap["previous_cursor_str"].toString(); + + emit parsedUsers(users, nextCursor, prevCursor); + } else { + qDebug() << "QTweetListSubscribers json parsing error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetlistsubscribers.h b/thirdparty/QTweetLib/src/qtweetlistsubscribers.h new file mode 100644 index 000000000..ca2c09ec6 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistsubscribers.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTSUBSCRIBERS_H +#define QTWEETLISTSUBSCRIBERS_H + +#include "qtweetnetbase.h" + +/** + * Fetches the subscribers of the specified list. + */ +class QTWEETLIBSHARED_EXPORT QTweetListSubscribers : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListSubscribers(QObject *parent = 0); + QTweetListSubscribers(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 user, + qint64 list, + const QString &cursor = QString(), + bool includeEntities = false); + +signals: + /** Emits page of the subscribed users + * @param users list of users + * @param nextCursor cursor for next page, "0" if there is no next page + * @param prevCursor cursor for prev page, "0" if there is no prev page + */ + void parsedUsers(const QList& users, + const QString& nextCursor, + const QString& prevCursor); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTSUBSCRIBERS_H diff --git a/thirdparty/QTweetLib/src/qtweetlistsubscriptions.cpp b/thirdparty/QTweetLib/src/qtweetlistsubscriptions.cpp new file mode 100644 index 000000000..b72da72a1 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistsubscriptions.cpp @@ -0,0 +1,84 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetlistsubscriptions.h" +#include "qtweetlist.h" +#include "qtweetconvert.h" + +QTweetListSubscriptions::QTweetListSubscriptions(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListSubscriptions::QTweetListSubscriptions(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * @param user user ID + * @param cursor breaks the results into pages. A single page contains 20 lists. + * Provide a value of -1 to begin paging. + * Provide values as returned next_cursor and previous_cursor attributes to page back and forth + */ +void QTweetListSubscriptions::fetch(qint64 user, const QString &cursor) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/lists/subscriptions.json").arg(user)); + + if (!cursor.isEmpty()) + url.addQueryItem("cursor", cursor); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListSubscriptions::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QVariantMap respMap = json.toMap(); + + QVariant listsVar = respMap["lists"]; + + QList lists = QTweetConvert::variantToTweetLists(listsVar); + + QString nextCursor = respMap["next_cursor_str"].toString(); + QString prevCursor = respMap["previous_cursor_str"].toString(); + + emit parsedLists(lists, nextCursor, prevCursor); + } else { + qDebug() << "QTweetListSubscriptions json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetlistsubscriptions.h b/thirdparty/QTweetLib/src/qtweetlistsubscriptions.h new file mode 100644 index 000000000..2fc5db483 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistsubscriptions.h @@ -0,0 +1,52 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTSUBSCRIPTIONS_H +#define QTWEETLISTSUBSCRIPTIONS_H + +#include "qtweetnetbase.h" + +/** + * Fetch the lists the specified user follows. + */ +class QTWEETLIBSHARED_EXPORT QTweetListSubscriptions : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListSubscriptions(QObject *parent = 0); + QTweetListSubscriptions(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 user, + const QString& cursor = QString()); + +signals: + /*! Emits page of lists + * @param lists + * @param nextCursor cursor for next page, "0" if there is no next page + * @param prevCursor cursor for prev page, "0" if there is no prev page + */ + void parsedLists(const QList& lists, + const QString& nextCursor, + const QString& prevCursor); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTSUBSCRIPTIONS_H diff --git a/thirdparty/QTweetLib/src/qtweetlistunsubscribe.cpp b/thirdparty/QTweetLib/src/qtweetlistunsubscribe.cpp new file mode 100644 index 000000000..51d49bde7 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistunsubscribe.cpp @@ -0,0 +1,72 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetlistunsubscribe.h" +#include "qtweetlist.h" +#include "qtweetconvert.h" + +QTweetListUnsubscribe::QTweetListUnsubscribe(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListUnsubscribe::QTweetListUnsubscribe(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * @param user user id of the owner of the list + * @param list list id + */ +void QTweetListUnsubscribe::unsubscribe(qint64 user, qint64 list) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/%2/subscribers.json").arg(user).arg(list)); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::DELETE); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->deleteResource(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListUnsubscribe::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetList list = QTweetConvert::variantMapToTweetList(json.toMap()); + + emit parsedList(list); + } else { + qDebug() << "QTweetListUnsubscribe parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetlistunsubscribe.h b/thirdparty/QTweetLib/src/qtweetlistunsubscribe.h new file mode 100644 index 000000000..b4888184b --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistunsubscribe.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTUNSUBSCRIBE_H +#define QTWEETLISTUNSUBSCRIBE_H + +#include "qtweetnetbase.h" + +/** + * Unsubscribes the authenticated user form the specified list. + */ +class QTWEETLIBSHARED_EXPORT QTweetListUnsubscribe : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListUnsubscribe(QObject *parent = 0); + QTweetListUnsubscribe(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void unsubscribe(qint64 user, + qint64 list); + +signals: + /** Emits list from which user was unsubscribed */ + void parsedList(const QTweetList& list); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTUNSUBSCRIBE_H diff --git a/thirdparty/QTweetLib/src/qtweetlistupdate.cpp b/thirdparty/QTweetLib/src/qtweetlistupdate.cpp new file mode 100644 index 000000000..568f6ab6a --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistupdate.cpp @@ -0,0 +1,92 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetlistupdate.h" +#include "qtweetlist.h" +#include "qtweetconvert.h" + +QTweetListUpdate::QTweetListUpdate(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetListUpdate::QTweetListUpdate(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** Updates the list + * @param user user id + * @param list list id + * @param name the name of the list + * @param mode true for public, false for private + * @param description The description to give the list + */ +void QTweetListUpdate::update(qint64 user, + qint64 list, + const QString &name, + bool mode, + const QString &description) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url(QString("http://api.twitter.com/1/%1/lists/%2.json").arg(user).arg(list)); + + QUrl urlQuery(url); + + if (!name.isEmpty()) + urlQuery.addEncodedQueryItem("name", QUrl::toPercentEncoding(name)); + + if (!mode) + urlQuery.addQueryItem("mode", "private"); + + if (!description.isEmpty()) + urlQuery.addEncodedQueryItem("description", QUrl::toPercentEncoding(description)); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath); + postBody.remove(0, 1); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetListUpdate::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetList list = QTweetConvert::variantMapToTweetList(json.toMap()); + + emit parsedList(list); + } else { + qDebug() << "QTweetListUpdate json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetlistupdate.h b/thirdparty/QTweetLib/src/qtweetlistupdate.h new file mode 100644 index 000000000..9169d4007 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetlistupdate.h @@ -0,0 +1,48 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETLISTUPDATE_H +#define QTWEETLISTUPDATE_H + +#include "qtweetnetbase.h" + +/** + * Updates the specified list. + */ +class QTWEETLIBSHARED_EXPORT QTweetListUpdate : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetListUpdate(QObject *parent = 0); + QTweetListUpdate(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void update(qint64 user, + qint64 list, + const QString& name = QString(), + bool mode = true, + const QString& description = QString()); +signals: + /** Emits updated list */ + void parsedList(const QTweetList& list); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETLISTUPDATE_H diff --git a/thirdparty/QTweetLib/src/qtweetmentions.cpp b/thirdparty/QTweetLib/src/qtweetmentions.cpp new file mode 100644 index 000000000..00469bc2a --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetmentions.cpp @@ -0,0 +1,105 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetmentions.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +QTweetMentions::QTweetMentions(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetMentions::QTweetMentions(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Start fetching + * @param sinceid fetches tweets with ID greater (more recent) then sinceid + * @param maxid fetches tweets with ID less (older) then maxid + * @param count number of tweets to fetch (up to 200) + * @param page page number + * @param includeRts timeline contains native retweets if true + * @param includeEntities true to include a node called "entities" + * @remarks Put parameter to default value to not to be put in query + */ +void QTweetMentions::fetch(qint64 sinceid, + qint64 maxid, + int count, + int page, + bool trimUser, + bool includeRts, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/statuses/mentions.json"); + + if (sinceid != 0) + url.addQueryItem("since_id", QString::number(sinceid)); + + if (maxid != 0) + url.addQueryItem("max_id", QString::number(maxid)); + + if (count != 0) + url.addQueryItem("count", QString::number(count)); + + if (page != 0) + url.addQueryItem("page", QString::number(page)); + + if (trimUser) + url.addQueryItem("trim_user", "true"); + + if (includeRts) + url.addQueryItem("include_rts", "true"); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetMentions::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList statuses = QTweetConvert::variantToStatusList(json); + + emit parsedStatuses(statuses); + } else { + qDebug() << "QTweetMentions JSON parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetmentions.h b/thirdparty/QTweetLib/src/qtweetmentions.h new file mode 100644 index 000000000..7fbc97548 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetmentions.h @@ -0,0 +1,51 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETMENTIONS_H +#define QTWEETMENTIONS_H + +#include "qtweetnetbase.h" + +/** + * Fetches mentions (up to 800) + */ +class QTWEETLIBSHARED_EXPORT QTweetMentions : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetMentions(QObject *parent = 0); + QTweetMentions(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 sinceid = 0, + qint64 maxid = 0, + int count = 0, + int page = 0, + bool trimUser = false, + bool includeRts = false, + bool includeEntities = false); + +signals: + /** Emits mentions status list */ + void parsedStatuses(const QList& statuses); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETMENTIONS_H diff --git a/thirdparty/QTweetLib/src/qtweetnetbase.cpp b/thirdparty/QTweetLib/src/qtweetnetbase.cpp new file mode 100644 index 000000000..de0d62612 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetnetbase.cpp @@ -0,0 +1,207 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetnetbase.h" +#include "qtweetstatus.h" +#include "qtweetdmstatus.h" +#include "qtweetuser.h" +#include "qtweetlist.h" +#include "qtweetsearchresult.h" +#include "qtweetsearchpageresults.h" +#include "qtweetplace.h" +#include "qjson/parserrunnable.h" +#include "qjson/parser.h" + +/** + * Constructor + */ +QTweetNetBase::QTweetNetBase(QObject *parent) : + QObject(parent), m_oauthTwitter(0), m_jsonParsingEnabled(true), m_authentication(true) +{ +} + +/** + * Constructor + * @param oauthTwitter OAuth Twitter + * @param parent QObject parent + */ +QTweetNetBase::QTweetNetBase(OAuthTwitter *oauthTwitter, QObject *parent) : + QObject(parent), m_oauthTwitter(oauthTwitter), m_jsonParsingEnabled(true), m_authentication(true) +{ + +} + +/** + * Desctructor + */ +QTweetNetBase::~QTweetNetBase() +{ +} + +/** + * Sets OAuth Twitter authorization object + * @param oauthTwitter OAuth Twitter object + */ +void QTweetNetBase::setOAuthTwitter(OAuthTwitter *oauthTwitter) +{ + m_oauthTwitter = oauthTwitter; +} + +/** + * Gets OAuth Twitter authorization object + * @return OAuth Twitter object + */ +OAuthTwitter* QTweetNetBase::oauthTwitter() const +{ + return m_oauthTwitter; +} + +/** + * Gets response + */ +QByteArray QTweetNetBase::response() const +{ + return m_response; +} + +/** + * Gets last error message + */ +QString QTweetNetBase::lastErrorMessage() const +{ + return m_lastErrorMessage; +} + +/** + * Enables/disables json parsing + * @remarks When disabled only finished and error signals are emited + */ +void QTweetNetBase::setJsonParsingEnabled(bool enable) +{ + m_jsonParsingEnabled = enable; +} + +/** + * Checks if its json parsing enabled + */ +bool QTweetNetBase::isJsonParsingEnabled() const +{ + return m_jsonParsingEnabled; +} + +/** + * Enables/disables oauth authentication + * @remarks Most of classes requires authentication + */ +void QTweetNetBase::setAuthenticationEnabled(bool enable) +{ + m_authentication = enable; +} + +/** + * Checks if authentication is enabled + */ +bool QTweetNetBase::isAuthenticationEnabled() const +{ + return m_authentication; +} + +/** + * Parses json response + */ +void QTweetNetBase::parseJson(const QByteArray &jsonData) +{ + QJson::ParserRunnable *jsonParser = new QJson::ParserRunnable; + jsonParser->setData(jsonData); + + connect(jsonParser, SIGNAL(parsingFinished(QVariant,bool,QString)), + this, SLOT(parsingJsonFinished(QVariant,bool,QString))); + + QThreadPool::globalInstance()->start(jsonParser); +} + +/** + * Called after response from twitter + */ +void QTweetNetBase::reply() +{ + QNetworkReply *reply = qobject_cast(sender()); + + if (reply) { + if (reply->error() == QNetworkReply::NoError) { + m_response = reply->readAll(); + emit finished(m_response); + + if (isJsonParsingEnabled()) + parseJson(m_response); + } else { + m_response = reply->readAll(); + + //dump error + qDebug() << "Network error: " << reply->error(); + qDebug() << "Error string: " << reply->errorString(); + qDebug() << "Error response: " << m_response; + + //HTTP status code + int httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + + //try to json parse the error response + QJson::Parser parser; + bool ok; + + QVariantMap errMsgMap = parser.parse(m_response, &ok).toMap(); + if (!ok) { + m_lastErrorMessage.clear(); + } else { + //QString request = errMsgMap["request"].toString(); + m_lastErrorMessage = errMsgMap["error"].toString(); + } + + switch (httpStatus) { + case NotModified: + case BadRequest: + case Unauthorized: + case Forbidden: + case NotFound: + case NotAcceptable: + case EnhanceYourCalm: + case InternalServerError: + case BadGateway: + case ServiceUnavailable: + emit error(static_cast(httpStatus), m_lastErrorMessage); + break; + default: + emit error(UnknownError, m_lastErrorMessage); + } + } + reply->deleteLater(); + } +} + +/** + * Sets last error message + */ +void QTweetNetBase::setLastErrorMessage(const QString &errMsg) +{ + m_lastErrorMessage = errMsg; +} diff --git a/thirdparty/QTweetLib/src/qtweetnetbase.h b/thirdparty/QTweetLib/src/qtweetnetbase.h new file mode 100644 index 000000000..910193f3f --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetnetbase.h @@ -0,0 +1,110 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETNETBASE_H +#define QTWEETNETBASE_H + +#include +#include +#include +#include "oauthtwitter.h" +#include "qtweetlib_global.h" + +class QTweetStatus; +class QTweetUser; +class QTweetDMStatus; +class QTweetList; +class QTweetSearchResult; +class QTweetSearchPageResults; +class QTweetPlace; + +/** + * Base class for Twitter API classes + */ +class QTWEETLIBSHARED_EXPORT QTweetNetBase : public QObject +{ + Q_OBJECT + Q_PROPERTY(OAuthTwitter* oauthTwitter READ oauthTwitter WRITE setOAuthTwitter) + Q_PROPERTY(bool jsonParsing READ isJsonParsingEnabled WRITE setJsonParsingEnabled) + Q_PROPERTY(bool authenticaion READ isAuthenticationEnabled WRITE setAuthenticationEnabled) +public: + QTweetNetBase(QObject *parent = 0); + QTweetNetBase(OAuthTwitter *oauthTwitter, QObject *parent = 0); + virtual ~QTweetNetBase(); + + enum ErrorCode { + JsonParsingError = 1, /** JSON parsing error */ + UnknownError = 2, /** Unknown error */ + NotModified = 304, /** There was no new data to return. */ + BadRequest = 400, /** The request was invalid. This is the status code will be returned during rate limiting. */ + Unauthorized = 401, /** Authentication credentials were missing or incorrect. */ + Forbidden = 403, /** The request is understood, but it has been refused, due to update limits. */ + NotFound = 404, /** The URI requested is invalid or the resource requested, such as a user, does not exists. */ + NotAcceptable = 406, /** Returned by the Search API when an invalid format is specified in the request. */ + EnhanceYourCalm = 420, /** Returned by the Search and Trends API when you are being rate limited. */ + InternalServerError = 500, /** Something is broken in Twitter */ + BadGateway = 502, /** Twitter is down or being upgraded. */ + ServiceUnavailable = 503 /** The Twitter servers are up, but overloaded with requests. Try again later. */ + }; + + void setOAuthTwitter(OAuthTwitter* oauthTwitter); + OAuthTwitter* oauthTwitter() const; + + void setJsonParsingEnabled(bool enable); + bool isJsonParsingEnabled() const; + + void setAuthenticationEnabled(bool enable); + bool isAuthenticationEnabled() const; + + QByteArray response() const; + QString lastErrorMessage() const; + +signals: + /** + * Emited when fetching is finished + * @param response contains the response in json + */ + void finished(const QByteArray& response); + + /** Emited when there is error. You can check error message with lastErrorMessage(). + * @param code error code + * @param errorMsg error message. If it's empty then error was not standard json twitter api message. + * In that case check response. + * @remarks DOESN'T emit finished signal + */ + void error(ErrorCode code, const QString& errorMsg); + +protected slots: + virtual void parsingJsonFinished(const QVariant& json, bool ok, const QString& errorMsg) = 0; + virtual void reply(); + +protected: + void parseJson(const QByteArray& jsonData); + void setLastErrorMessage(const QString& errMsg); + +private: + OAuthTwitter *m_oauthTwitter; + QByteArray m_response; + QString m_lastErrorMessage; + bool m_jsonParsingEnabled; + bool m_authentication; +}; + +#endif // QTWEETNETBASE_H diff --git a/thirdparty/QTweetLib/src/qtweetplace.cpp b/thirdparty/QTweetLib/src/qtweetplace.cpp new file mode 100644 index 000000000..3fafd5b37 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetplace.cpp @@ -0,0 +1,105 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "qtweetplace.h" + +QTweetPlace::QTweetPlace() +{ +} + +void QTweetPlace::setName(const QString &name) +{ + m_name = name; +} + +QString QTweetPlace::name() const +{ + return m_name; +} + +void QTweetPlace::setCountry(const QString &country) +{ + m_country = country; +} + +QString QTweetPlace::country() const +{ + return m_country; +} + +void QTweetPlace::setCountryCode(const QString &code) +{ + m_countryCode = code; +} + +QString QTweetPlace::countryCode() const +{ + return m_countryCode; +} + +void QTweetPlace::setID(const QString &id) +{ + m_id = id; +} + +QString QTweetPlace::id() const +{ + return m_id; +} + +void QTweetPlace::setBoundingBox(const QTweetGeoBoundingBox &box) +{ + m_boundingBox = box; +} + +QTweetGeoBoundingBox QTweetPlace::boundingBox() const +{ + return m_boundingBox; +} + +void QTweetPlace::setContainedWithin(const QList &places) +{ + m_containedWithin = places; +} + +QList QTweetPlace::containedWithin() const +{ + return m_containedWithin; +} + +void QTweetPlace::setFullName(const QString &name) +{ + m_fullName = name; +} + +QString QTweetPlace::fullName() const +{ + return m_fullName; +} + +void QTweetPlace::setType(Type type) +{ + m_type = type; +} + +QTweetPlace::Type QTweetPlace::type() const +{ + return m_type; +} diff --git a/thirdparty/QTweetLib/src/qtweetplace.h b/thirdparty/QTweetLib/src/qtweetplace.h new file mode 100644 index 000000000..b1453fe1f --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetplace.h @@ -0,0 +1,71 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETPLACE_H +#define QTWEETPLACE_H + +#include +#include +#include +#include "qtweetgeoboundingbox.h" +#include "qtweetlib_global.h" + + +/** + * Store place info + */ +class QTWEETLIBSHARED_EXPORT QTweetPlace +{ +public: + enum Type { Poi, Neighborhood, City, Admin, Country }; + + QTweetPlace(); + void setName(const QString& name); + QString name() const; + void setCountry(const QString& country); + QString country() const; + void setCountryCode(const QString& code); + QString countryCode() const; + void setID(const QString& id); // http://api.twitter.com/1/geo/id/.json + QString id() const; + void setBoundingBox(const QTweetGeoBoundingBox& box); + QTweetGeoBoundingBox boundingBox() const; + void setContainedWithin(const QList& places); + QList containedWithin() const; + void setFullName(const QString& name); + QString fullName() const; + void setType(Type type); + Type type() const; + +private: + QString m_name; + QString m_country; + QString m_countryCode; + // ### TODO: Attributes + QString m_id; + QTweetGeoBoundingBox m_boundingBox; + QList m_containedWithin; + QString m_fullName; + Type m_type; +}; + +Q_DECLARE_METATYPE(QTweetPlace) + +#endif // QTWEETPLACE_H diff --git a/thirdparty/QTweetLib/src/qtweetretweetbyme.cpp b/thirdparty/QTweetLib/src/qtweetretweetbyme.cpp new file mode 100644 index 000000000..c5b3f2f4c --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetretweetbyme.cpp @@ -0,0 +1,99 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetretweetbyme.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +QTweetRetweetByMe::QTweetRetweetByMe(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetRetweetByMe::QTweetRetweetByMe(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Start fetching retweets by user + * @param sinceid fetches tweets with ID greater (more recent) then sinceid + * @param maxid fetches tweets with ID less (older) then maxid + * @param count number of tweets to fetch (up to 200) + * @param page page number + * @remarks Setting parameter to default value, will not be put in the query + */ +void QTweetRetweetByMe::fetch(qint64 sinceid, + qint64 maxid, + int count, + int page, + bool trimUser, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/statuses/retweeted_by_me.json"); + + if (sinceid != 0) + url.addQueryItem("since_id", QString::number(sinceid)); + + if (maxid != 0) + url.addQueryItem("max_id", QString::number(maxid)); + + if (count != 0) + url.addQueryItem("count", QString::number(count)); + + if (page != 0) + url.addQueryItem("page", QString::number(page)); + + if (trimUser) + url.addQueryItem("trim_user", "true"); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetRetweetByMe::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList statuses = QTweetConvert::variantToStatusList(json); + + emit parsedStatuses(statuses); + } else { + qDebug() << "QTweetRetweetByMe JSON parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetretweetbyme.h b/thirdparty/QTweetLib/src/qtweetretweetbyme.h new file mode 100644 index 000000000..b259aea41 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetretweetbyme.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETRETWEETBYME_H +#define QTWEETRETWEETBYME_H + +#include "qtweetnetbase.h" + +/** + * Fetches retweets posted by user + */ +class QTWEETLIBSHARED_EXPORT QTweetRetweetByMe : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetRetweetByMe(QObject *parent = 0); + QTweetRetweetByMe(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 sinceid = 0, + qint64 maxid = 0, + int count = 0, + int page = 0, + bool trimUser = false, + bool includeEntities = false); + +signals: + /** Emits retweets status list */ + void parsedStatuses(const QList& statuses); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETRETWEETBYME_H diff --git a/thirdparty/QTweetLib/src/qtweetretweetsofme.cpp b/thirdparty/QTweetLib/src/qtweetretweetsofme.cpp new file mode 100644 index 000000000..52ce871b2 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetretweetsofme.cpp @@ -0,0 +1,98 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetretweetsofme.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +QTweetRetweetsOfMe::QTweetRetweetsOfMe(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetRetweetsOfMe::QTweetRetweetsOfMe(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts fetching retweets of user + * @param sinceid fetches tweets with ID greater (more recent) then sinceid + * @param maxid fetches tweets with ID less (older) then maxid + * @param count number of tweets to fetch (up to 200) + * @param page page number + * @remarks Setting parameter to default value, will not be put in the query + */ +void QTweetRetweetsOfMe::fetch(qint64 sinceid, + qint64 maxid, + int count, + int page, + bool trimUser, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/statuses/retweets_of_me.json"); + + if (sinceid != 0) + url.addQueryItem("since_id", QString::number(sinceid)); + + if (maxid != 0) + url.addQueryItem("max_id", QString::number(maxid)); + + if (count != 0) + url.addQueryItem("count", QString::number(count)); + + if (page != 0) + url.addQueryItem("page", QString::number(page)); + + if (trimUser) + url.addQueryItem("trim_user", "true"); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetRetweetsOfMe::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList statuses = QTweetConvert::variantToStatusList(json); + + emit parsedStatuses(statuses); + } else { + qDebug() << "QTweetRetweetsOfMe JSON parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetretweetsofme.h b/thirdparty/QTweetLib/src/qtweetretweetsofme.h new file mode 100644 index 000000000..4e10d834f --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetretweetsofme.h @@ -0,0 +1,51 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETRETWEETSOFME_H +#define QTWEETRETWEETSOFME_H + +#include "qtweetnetbase.h" + +/** + * Class for fetching tweets of user that have been retweeted by others + */ +class QTWEETLIBSHARED_EXPORT QTweetRetweetsOfMe : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetRetweetsOfMe(QObject *parent = 0); + QTweetRetweetsOfMe(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 sinceid = 0, + qint64 maxid = 0, + int count = 0, + int page = 0, + bool trimUser = false, + bool includeEntities = false); + + +signals: + /** Emits retweets status list */ + void parsedStatuses(const QList& statuses); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETRETWEETSOFME_H diff --git a/thirdparty/QTweetLib/src/qtweetretweettome.cpp b/thirdparty/QTweetLib/src/qtweetretweettome.cpp new file mode 100644 index 000000000..badd255f8 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetretweettome.cpp @@ -0,0 +1,99 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetretweettome.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +QTweetRetweetToMe::QTweetRetweetToMe(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetRetweetToMe::QTweetRetweetToMe(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts fetching retweets to user + * @param sinceid Fetches tweets with ID greater (more recent) then sinceid + * @param maxid Fetches tweets with ID less (older) then maxid + * @param count Number of tweets to fetch (up to 200) + * @param page Page number + * @remarks Setting parameter to default value, will not be put in the query + */ +void QTweetRetweetToMe::fetch(qint64 sinceid, + qint64 maxid, + int count, + int page, + bool trimUser, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/statuses/retweeted_to_me.json"); + + if (sinceid != 0) + url.addQueryItem("since_id", QString::number(sinceid)); + + if (maxid != 0) + url.addQueryItem("max_id", QString::number(maxid)); + + if (count != 0) + url.addQueryItem("count", QString::number(count)); + + if (page != 0) + url.addQueryItem("page", QString::number(page)); + + if (trimUser) + url.addQueryItem("trim_user", "true"); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetRetweetToMe::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList statuses = QTweetConvert::variantToStatusList(json); + + emit parsedStatuses(statuses); + } else { + qDebug() << "QTweetRetweetToMe JSON parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetretweettome.h b/thirdparty/QTweetLib/src/qtweetretweettome.h new file mode 100644 index 000000000..65bae1d5c --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetretweettome.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETRETWEETTOME_H +#define QTWEETRETWEETTOME_H + +#include "qtweetnetbase.h" + +/** + * Class for fetching retweets posted by users that user follow + */ +class QTWEETLIBSHARED_EXPORT QTweetRetweetToMe : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetRetweetToMe(QObject *parent = 0); + QTweetRetweetToMe(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 sinceid = 0, + qint64 maxid = 0, + int count = 0, + int page = 0, + bool trimUser = false, + bool includeEntities = false); + +signals: + /** Emits retweets status list */ + void parsedStatuses(const QList& statuses); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETRETWEETTOME_H diff --git a/thirdparty/QTweetLib/src/qtweetsearch.cpp b/thirdparty/QTweetLib/src/qtweetsearch.cpp new file mode 100644 index 000000000..b59c68a7e --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetsearch.cpp @@ -0,0 +1,111 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetsearch.h" +#include "qtweetsearchpageresults.h" +#include "qtweetconvert.h" + +QTweetSearch::QTweetSearch(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetSearch::QTweetSearch(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts searching + * @param query serch query + * @param lang Restricts tweets to the given language, given by an ISO 639-1 code. + * @param rpp number of tweets to return per page, up to a max of 100. + * @param page page number (starting at 1) to return, up to a max of roughly 1500 results + * @param sinceid returns results with an ID greater than (that is, more recent than) the specified ID. + */ +void QTweetSearch::start(const QString &query, + const QString &lang, + /* const QString &locale, */ + int rpp, + int page, + qint64 sinceid) +{ + QUrl url("http://search.twitter.com/search.json"); + + url.addEncodedQueryItem("q", QUrl::toPercentEncoding(query)); + + if (!lang.isEmpty()) + url.addQueryItem("lang", lang); + + // if (!locale.isEmpty()) + // url.addQueryItem("locale", locale); + + if (rpp) + url.addQueryItem("rpp", QString::number(rpp)); + + if (page) + url.addQueryItem("page", QString::number(page)); + + if (sinceid) + url.addQueryItem("since_id", QString::number(sinceid)); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetSearch::startWithCustomQuery(const QByteArray &encodedQuery) +{ + QUrl url("http://search.twitter.com/search.json"); + + //remove ? + QByteArray query(encodedQuery); + url.setEncodedQuery(query.remove(0, 1)); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetSearch::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetSearchPageResults pageResults = QTweetConvert::variantToSearchPageResults(json); + + emit parsedPageResults(pageResults); + } else { + qDebug() << "QTweetSearch parsing error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetsearch.h b/thirdparty/QTweetLib/src/qtweetsearch.h new file mode 100644 index 000000000..f89bc8876 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetsearch.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETSEARCH_H +#define QTWEETSEARCH_H + +#include "qtweetnetbase.h" + +/** + * Gets tweets that match a specified query + */ +class QTWEETLIBSHARED_EXPORT QTweetSearch : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetSearch(QObject *parent = 0); + QTweetSearch(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void start(const QString& query, + const QString& lang = QString(), + /* const QString& locale = QString(), */ + int rpp = 0, + int page = 0, + qint64 sinceid = 0 + //geocode ### TODO + //resultType ### TODO + ); + void startWithCustomQuery(const QByteArray& encodedQuery); + +signals: + /** Emits page of search results */ + void parsedPageResults(const QTweetSearchPageResults& pageResults); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETSEARCH_H diff --git a/thirdparty/QTweetLib/src/qtweetsearchpageresults.cpp b/thirdparty/QTweetLib/src/qtweetsearchpageresults.cpp new file mode 100644 index 000000000..4725d1de2 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetsearchpageresults.cpp @@ -0,0 +1,146 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "qtweetsearchpageresults.h" +#include +#include "qtweetsearchresult.h" + +class QTweetSearchPageResultsData : public QSharedData { +public: + //float completedIn; //who cares? + qint64 maxid; + QByteArray nextPage; + int page; + QByteArray query; + QByteArray refreshUrl; + QList results; + int resultsPerPage; + qint64 sinceid; + int total; +}; + +QTweetSearchPageResults::QTweetSearchPageResults() : data(new QTweetSearchPageResultsData) +{ +} + +QTweetSearchPageResults::QTweetSearchPageResults(const QTweetSearchPageResults &rhs) : data(rhs.data) +{ +} + +QTweetSearchPageResults &QTweetSearchPageResults::operator=(const QTweetSearchPageResults &rhs) +{ + if (this != &rhs) + data.operator=(rhs.data); + return *this; +} + +QTweetSearchPageResults::~QTweetSearchPageResults() +{ +} + +void QTweetSearchPageResults::setMaxId(qint64 maxid) +{ + data->maxid = maxid; +} + +qint64 QTweetSearchPageResults::maxid() const +{ + return data->maxid; +} + +void QTweetSearchPageResults::setNextPage(const QByteArray &nextPage) +{ + data->nextPage = nextPage; +} + +QByteArray QTweetSearchPageResults::nextPage() const +{ + return data->nextPage; +} + +void QTweetSearchPageResults::setPage(int numPage) +{ + data->page = numPage; +} + +int QTweetSearchPageResults::page() const +{ + return data->page; +} + +void QTweetSearchPageResults::setQuery(const QByteArray &query) +{ + data->query = query; +} + +QByteArray QTweetSearchPageResults::query() const +{ + return data->query; +} + +void QTweetSearchPageResults::setRefreshUrl(const QByteArray &url) +{ + data->refreshUrl = url; +} + +QByteArray QTweetSearchPageResults::refreshUrl() const +{ + return data->refreshUrl; +} + +void QTweetSearchPageResults::setResults(const QList &results) +{ + data->results = results; +} + +QList QTweetSearchPageResults::results() const +{ + return data->results; +} + +void QTweetSearchPageResults::setResultsPerPage(int count) +{ + data->resultsPerPage = count; +} + +int QTweetSearchPageResults::resultsPerPage() const +{ + return data->resultsPerPage; +} + +void QTweetSearchPageResults::setSinceId(qint64 sinceid) +{ + data->sinceid = sinceid; +} + +qint64 QTweetSearchPageResults::sinceid() const +{ + return data->sinceid; +} + +void QTweetSearchPageResults::setTotal(int total) +{ + data->total = total; +} + +int QTweetSearchPageResults::total() const +{ + return data->total; +} diff --git a/thirdparty/QTweetLib/src/qtweetsearchpageresults.h b/thirdparty/QTweetLib/src/qtweetsearchpageresults.h new file mode 100644 index 000000000..5359b8929 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetsearchpageresults.h @@ -0,0 +1,68 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETSEARCHPAGERESULTS_H +#define QTWEETSEARCHPAGERESULTS_H + +#include +#include +#include +#include "qtweetlib_global.h" + +class QTweetSearchPageResultsData; +class QTweetSearchResult; + +/** + * Stores page of a search results + */ +class QTWEETLIBSHARED_EXPORT QTweetSearchPageResults +{ +public: + QTweetSearchPageResults(); + QTweetSearchPageResults(const QTweetSearchPageResults &); + QTweetSearchPageResults &operator=(const QTweetSearchPageResults &); + ~QTweetSearchPageResults(); + + void setMaxId(qint64 maxid); + qint64 maxid() const; + void setNextPage(const QByteArray& nextPage); + QByteArray nextPage() const; + void setPage(int numPage); + int page() const; + void setQuery(const QByteArray& query); + QByteArray query() const; + void setRefreshUrl(const QByteArray& url); + QByteArray refreshUrl() const; + void setResults(const QList& results); + QList results() const; + void setResultsPerPage (int count); + int resultsPerPage() const; + void setSinceId(qint64 sinceid); + qint64 sinceid() const; + void setTotal(int total); + int total() const; + +private: + QSharedDataPointer data; +}; + +Q_DECLARE_METATYPE(QTweetSearchPageResults) + +#endif // QTWEETSEARCHPAGERESULTS_H diff --git a/thirdparty/QTweetLib/src/qtweetsearchresult.cpp b/thirdparty/QTweetLib/src/qtweetsearchresult.cpp new file mode 100644 index 000000000..834af4e60 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetsearchresult.cpp @@ -0,0 +1,160 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include "qtweetsearchresult.h" +#include +#include +//#include "qtweetuser.h" + +class QTweetSearchResultData : public QSharedData { +public: + QDateTime createdAt; + QString fromUser; + //qint64 fromUserId; // USELESS. It's not same as general twitter user id + qint64 id; + QString lang; + //metadata ### TODO + //places ### TODO + QString profileImageUrl; + QString source; + QString text; + QString toUser; + //qint64 toUserId; // USELESS. It's not same general twitter user id +}; + +QTweetSearchResult::QTweetSearchResult() : data(new QTweetSearchResultData) +{ +} + +QTweetSearchResult::QTweetSearchResult(const QTweetSearchResult &rhs) : data(rhs.data) +{ +} + +QTweetSearchResult &QTweetSearchResult::operator=(const QTweetSearchResult &rhs) +{ + if (this != &rhs) + data.operator=(rhs.data); + return *this; +} + +QTweetSearchResult::~QTweetSearchResult() +{ +} + +void QTweetSearchResult::setCreatedAt(const QDateTime &dateTime) +{ + data->createdAt = dateTime; +} + +// Oh, not again. ANOTHER datetime format from twitter. +//Mon, 04 Oct 2010 12:51:42 +0000 + +void QTweetSearchResult::setCreatedAt(const QString &twitterDate) +{ + QString dateString = twitterDate.left(3) + ' ' + twitterDate.mid(8, 3) + ' ' + + twitterDate.mid(5, 2) + ' ' + twitterDate.mid(13, 4); + QString timeString = twitterDate.mid(17, 8); + + QDate date = QDate::fromString(dateString); + QTime time = QTime::fromString(timeString); + + if (date.isValid() && time.isValid()) + data->createdAt = QDateTime(date, time, Qt::UTC); + else + data->createdAt = QDateTime(); +} + +QDateTime QTweetSearchResult::createdAt() const +{ + return data->createdAt; +} + +void QTweetSearchResult::setFromUser(const QString &screenName) +{ + data->fromUser = screenName; +} + +QString QTweetSearchResult::fromUser() const +{ + return data->fromUser; +} + +void QTweetSearchResult::setId(qint64 id) +{ + data->id = id; +} + +qint64 QTweetSearchResult::id() const +{ + return data->id; +} + +void QTweetSearchResult::setLang(const QString &lang) +{ + data->lang = lang; +} + +QString QTweetSearchResult::lang() const +{ + return data->lang; +} + +void QTweetSearchResult::setProfileImageUrl(const QString &url) +{ + data->profileImageUrl = url; +} + +QString QTweetSearchResult::profileImageUrl() const +{ + return data->profileImageUrl; +} + +void QTweetSearchResult::setSource(const QString &source) +{ + data->source = source; +} + +QString QTweetSearchResult::source() const +{ + return data->source; +} + +void QTweetSearchResult::setText(const QString &text) +{ + data->text = text; +} + +QString QTweetSearchResult::text() const +{ + return data->text; +} + +void QTweetSearchResult::setToUser(const QString &screenName) +{ + data->toUser = screenName; +} + +QString QTweetSearchResult::toUser() const +{ + return data->toUser; +} + + + diff --git a/thirdparty/QTweetLib/src/qtweetsearchresult.h b/thirdparty/QTweetLib/src/qtweetsearchresult.h new file mode 100644 index 000000000..bf9a86149 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetsearchresult.h @@ -0,0 +1,63 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETSEARCHRESULT_H +#define QTWEETSEARCHRESULT_H + +#include +#include +#include "qtweetlib_global.h" + +class QTweetSearchResultData; + +/** + * Stores search result + */ +class QTWEETLIBSHARED_EXPORT QTweetSearchResult +{ +public: + QTweetSearchResult(); + QTweetSearchResult(const QTweetSearchResult &); + QTweetSearchResult &operator=(const QTweetSearchResult &); + ~QTweetSearchResult(); + + void setCreatedAt(const QString& twitterDate); + void setCreatedAt(const QDateTime& dateTime); + QDateTime createdAt() const; + void setFromUser(const QString& screenName); + QString fromUser() const; + void setId(qint64 id); + qint64 id() const; + void setLang(const QString& lang); + QString lang() const; + void setProfileImageUrl(const QString& url); + QString profileImageUrl() const; + void setSource(const QString& source); + QString source() const; + void setText(const QString& text); + QString text() const; + void setToUser(const QString& screenName); + QString toUser() const; + +private: + QSharedDataPointer data; +}; + +#endif // QTWEETSEARCHRESULT_H diff --git a/thirdparty/QTweetLib/src/qtweetstatus.cpp b/thirdparty/QTweetLib/src/qtweetstatus.cpp new file mode 100644 index 000000000..b2d7bdced --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetstatus.cpp @@ -0,0 +1,259 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include "qtweetstatus.h" +#include "qtweetuser.h" +#include "qtweetplace.h" +#include "qtweetentityurl.h" +#include "qtweetentityhashtag.h" +#include "qtweetentityusermentions.h" + +class QTweetStatusData : public QSharedData +{ +public: + QTweetStatusData() : id(0), inReplyToStatusId(0), retweetedStatus(0) {} + + QTweetStatusData(const QTweetStatusData& other) : QSharedData(other) + { + id = other.id; + text = other.text; + createdAt = other.createdAt; + inReplyToUserId = other.inReplyToUserId; + inReplyToScreenName = other.inReplyToScreenName; + inReplyToStatusId = other.inReplyToStatusId; + favorited = other.favorited; + source = other.source; + user = other.user; + place = other.place; + + if (other.retweetedStatus) { + retweetedStatus = new QTweetStatus(*other.retweetedStatus); + } else { + retweetedStatus = 0; + } + } + + ~QTweetStatusData() + { + delete retweetedStatus; + } + + qint64 id; + QString text; + QDateTime createdAt; + qint64 inReplyToUserId; + QString inReplyToScreenName; + qint64 inReplyToStatusId; + bool favorited; + QString source; + QTweetUser user; + QTweetStatus *retweetedStatus; + QTweetPlace place; + QList urlEntities; + QList hashtagEntities; + QList userMentionEntities; +}; + +QTweetStatus::QTweetStatus() : + d(new QTweetStatusData) +{ +} + +QTweetStatus::QTweetStatus(const QTweetStatus &other) : + d(other.d) +{ +} + +QTweetStatus& QTweetStatus::operator=(const QTweetStatus &rhs) +{ + if (this != &rhs) + d.operator=(rhs.d); + return *this; +} + +QTweetStatus::~QTweetStatus() +{ +} + +void QTweetStatus::setId(qint64 id) +{ + d->id = id; +} + +qint64 QTweetStatus::id() const +{ + return d->id; +} + +void QTweetStatus::setText(const QString &text) +{ + d->text = text; +} + +QString QTweetStatus::text() const +{ + return d->text; +} + +void QTweetStatus::setCreatedAt(const QString &twitterDate) +{ + d->createdAt = QTweetUser::twitterDateToQDateTime(twitterDate); +} + +void QTweetStatus::setCreatedAt(const QDateTime &dateTime) +{ + d->createdAt = dateTime; +} + +QDateTime QTweetStatus::createdAt() const +{ + return d->createdAt; +} + +void QTweetStatus::setInReplyToUserId(qint64 id) +{ + d->inReplyToUserId = id; +} + +qint64 QTweetStatus::inReplyToUserId() const +{ + return d->inReplyToUserId; +} + +void QTweetStatus::setInReplyToScreenName(const QString &screenName) +{ + d->inReplyToScreenName = screenName; +} + +QString QTweetStatus::inReplyToScreenName() const +{ + return d->inReplyToScreenName; +} + +void QTweetStatus::setInReplyToStatusId(qint64 id) +{ + d->inReplyToStatusId = id; +} + +qint64 QTweetStatus::inReplyToStatusId() const +{ + return d->inReplyToStatusId; +} + +void QTweetStatus::setFavorited(bool fav) +{ + d->favorited = fav; +} + +bool QTweetStatus::favorited() const +{ + return d->favorited; +} + +void QTweetStatus::setSource(const QString &source) +{ + d->source = source; +} + +QString QTweetStatus::source() const +{ + return d->source; +} + +void QTweetStatus::setUser(const QTweetUser &user) +{ + d->user = user; +} + +QTweetUser QTweetStatus::user() const +{ + return d->user; +} + +qint64 QTweetStatus::userid() const +{ + return d->user.id(); +} + +void QTweetStatus::setRetweetedStatus(const QTweetStatus &status) +{ + if (!d->retweetedStatus) + d->retweetedStatus = new QTweetStatus; + + *d->retweetedStatus = status; +} + +QTweetStatus QTweetStatus::retweetedStatus() const +{ + if (!d->retweetedStatus) + return QTweetStatus(); + + return *d->retweetedStatus; +} + +void QTweetStatus::setPlace(const QTweetPlace &place) +{ + d->place = place; +} + +QTweetPlace QTweetStatus::place() const +{ + return d->place; +} + +bool QTweetStatus::isRetweet() const +{ + if (d->retweetedStatus) + return true; + + return false; +} + +QList QTweetStatus::urlEntities() const +{ + return d->urlEntities; +} + +QList QTweetStatus::hashtagEntities() const +{ + return d->hashtagEntities; +} + +QList QTweetStatus::userMentionsEntities() const +{ + return d->userMentionEntities; +} + +void QTweetStatus::addUrlEntity(const QTweetEntityUrl &urlEntity) +{ + d->urlEntities.append(urlEntity); +} + +void QTweetStatus::addHashtagEntity(const QTweetEntityHashtag &hashtagEntity) +{ + d->hashtagEntities.append(hashtagEntity); +} + +void QTweetStatus::addUserMentionsEntity(const QTweetEntityUserMentions &userMentionsEntity) +{ + d->userMentionEntities.append(userMentionsEntity); +} diff --git a/thirdparty/QTweetLib/src/qtweetstatus.h b/thirdparty/QTweetLib/src/qtweetstatus.h new file mode 100644 index 000000000..bdfd79581 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetstatus.h @@ -0,0 +1,85 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETSTATUS_H +#define QTWEETSTATUS_H + +#include +#include +#include "qtweetlib_global.h" + +class QDateTime; +class QTweetUser; +class QTweetStatusData; +class QTweetPlace; +class QTweetEntityUrl; +class QTweetEntityHashtag; +class QTweetEntityUserMentions; + +/** + * Stores tweet info + */ +class QTWEETLIBSHARED_EXPORT QTweetStatus +{ +public: + QTweetStatus(); + QTweetStatus(const QTweetStatus &other); + QTweetStatus &operator=(const QTweetStatus &other); + ~QTweetStatus(); + + void setId(qint64 id); + qint64 id() const; + void setText(const QString& text); + QString text() const; + void setCreatedAt(const QString& twitterDate); + void setCreatedAt(const QDateTime& dateTime); + QDateTime createdAt() const; + void setInReplyToUserId(qint64 id); + qint64 inReplyToUserId() const; + void setInReplyToScreenName(const QString& screenName); + QString inReplyToScreenName() const; + void setInReplyToStatusId(qint64 id); + qint64 inReplyToStatusId() const; + void setFavorited(bool fav); + bool favorited() const; + void setSource(const QString& source); + QString source() const; + void setUser(const QTweetUser& user); + QTweetUser user() const; + qint64 userid() const; //usefull for getting quick userid when userinfo is trimmed + void setRetweetedStatus(const QTweetStatus& status); + QTweetStatus retweetedStatus() const; + void setPlace(const QTweetPlace& place); + QTweetPlace place() const; + bool isRetweet() const; + QList urlEntities() const; + QList hashtagEntities() const; + QList userMentionsEntities() const; + void addUrlEntity(const QTweetEntityUrl& urlEntity); + void addHashtagEntity(const QTweetEntityHashtag& hashtagEntity); + void addUserMentionsEntity(const QTweetEntityUserMentions& userMentionsEntity); + +private: + QSharedDataPointer d; +}; + +Q_DECLARE_METATYPE(QTweetStatus) + +#endif // QTWEETSTATUS_H diff --git a/thirdparty/QTweetLib/src/qtweetstatusdestroy.cpp b/thirdparty/QTweetLib/src/qtweetstatusdestroy.cpp new file mode 100644 index 000000000..60a1fcaed --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetstatusdestroy.cpp @@ -0,0 +1,89 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetstatusdestroy.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +QTweetStatusDestroy::QTweetStatusDestroy(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetStatusDestroy::QTweetStatusDestroy(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Destroys tweet with id + * @param id tweet ID + * @param trimUser trims users info + * @param includeEntities true to include node entities in response + */ +void QTweetStatusDestroy::destroy(qint64 id, + bool trimUser, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/statuses/destroy.json"); + + QUrl urlQuery(url); + + urlQuery.addQueryItem("id", QString::number(id)); + + if (trimUser) + urlQuery.addQueryItem("trim_user", "true"); + + if (includeEntities) + urlQuery.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath); + postBody.remove(0, 1); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetStatusDestroy::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetStatus status = QTweetConvert::variantMapToStatus(json.toMap()); + + emit deletedStatus(status); + } else { + qDebug() << "QTweetStatusDestroy parse error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetstatusdestroy.h b/thirdparty/QTweetLib/src/qtweetstatusdestroy.h new file mode 100644 index 000000000..aab51be97 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetstatusdestroy.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETSTATUSDESTROY_H +#define QTWEETSTATUSDESTROY_H + +#include "qtweetnetbase.h" + +/** + * Class for destroying specified tweet (user must be author of tweet) + */ +class QTWEETLIBSHARED_EXPORT QTweetStatusDestroy : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetStatusDestroy(QObject *parent = 0); + QTweetStatusDestroy(OAuthTwitter* oauthTwitter, QObject *parent = 0); + void destroy(qint64 id, + bool trimUser = false, + bool includeEntities = false); + +signals: + /** Emits deleted status */ + void deletedStatus(const QTweetStatus& status); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETSTATUSDESTROY_H diff --git a/thirdparty/QTweetLib/src/qtweetstatusretweet.cpp b/thirdparty/QTweetLib/src/qtweetstatusretweet.cpp new file mode 100644 index 000000000..9e0377b0d --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetstatusretweet.cpp @@ -0,0 +1,79 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetstatusretweet.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +QTweetStatusRetweet::QTweetStatusRetweet(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetStatusRetweet::QTweetStatusRetweet(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Retweets the tweet + * @param id tweet ID to retweet + * @param trimUser trims user info in response + * @param includeEntities true to include node entities in response + */ +void QTweetStatusRetweet::retweet(qint64 id, + bool trimUser, + bool includeEntities) +{ + QUrl url(QString("http://api.twitter.com/1/statuses/retweet/%1.json").arg(id)); + + if (trimUser) + url.addQueryItem("trim_user", "true"); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { //Oh, Twitter API docs wrong? + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::POST); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, QByteArray()); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetStatusRetweet::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetStatus status = QTweetConvert::variantMapToStatus(json.toMap()); + + emit postedRetweet(status); + } else { + qDebug() << "QTweetStatusRetweet JSON parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetstatusretweet.h b/thirdparty/QTweetLib/src/qtweetstatusretweet.h new file mode 100644 index 000000000..1138545d6 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetstatusretweet.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETSTATUSRETWEET_H +#define QTWEETSTATUSRETWEET_H + +#include "qtweetnetbase.h" + +/** + * Class for retweeting tweet + */ +class QTWEETLIBSHARED_EXPORT QTweetStatusRetweet : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetStatusRetweet(QObject *parent = 0); + QTweetStatusRetweet(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void retweet(qint64 id, + bool trimUser = false, + bool includeEntities = false); + +signals: + /** Emits retweeted tweet */ + void postedRetweet(const QTweetStatus& status); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETSTATUSRETWEET_H diff --git a/thirdparty/QTweetLib/src/qtweetstatusretweets.cpp b/thirdparty/QTweetLib/src/qtweetstatusretweets.cpp new file mode 100644 index 000000000..aab0bad1a --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetstatusretweets.cpp @@ -0,0 +1,64 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include "qtweetstatusretweets.h" + +QTweetStatusRetweets::QTweetStatusRetweets(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetStatusRetweets::QTweetStatusRetweets(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Start fetching + * @param id tweet ID + * @param count numbers of retweets to fetch + */ +void QTweetStatusRetweets::fetch(qint64 id, int count) +{ + //Q_ASSERT(oauthTwitter() != 0); + + QUrl url("http://api.twitter.com/1/statuses/retweets.json"); + + url.addQueryItem("id", QString::number(id)); + + if (count != 0) + url.addQueryItem("count", QString::number(count)); + + // ### TODO: Add trim_user parameter + // ### TODO: Add include_entities parameter + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +// ### TODO json parsing, emiting signal + diff --git a/thirdparty/QTweetLib/src/qtweetstatusretweets.h b/thirdparty/QTweetLib/src/qtweetstatusretweets.h new file mode 100644 index 000000000..022da6790 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetstatusretweets.h @@ -0,0 +1,40 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETSTATUSRETWEETS_H +#define QTWEETSTATUSRETWEETS_H + +#include "qtweetnetbase.h" + +// ### TODO + +/** + * Class to fetch up to 100 first retweets of a given tweet + */ +class QTWEETLIBSHARED_EXPORT QTweetStatusRetweets : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetStatusRetweets(QObject *parent = 0); + QTweetStatusRetweets(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 id, int count = 0); +}; + +#endif // QTWEETSTATUSRETWEETS_H diff --git a/thirdparty/QTweetLib/src/qtweetstatusshow.cpp b/thirdparty/QTweetLib/src/qtweetstatusshow.cpp new file mode 100644 index 000000000..6538595bd --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetstatusshow.cpp @@ -0,0 +1,78 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetstatusshow.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +QTweetStatusShow::QTweetStatusShow(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetStatusShow::QTweetStatusShow(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts fetching + * @param id tweet ID + * @param trimUser set to true to trim user info in response + * @param includeEntities set to true to include node entities in response + */ +void QTweetStatusShow::fetch(qint64 id, bool trimUser, bool includeEntities) +{ + QUrl url("http://api.twitter.com/1/statuses/show.json"); + + url.addQueryItem("id", QString::number(id)); + + if (trimUser) + url.addQueryItem("trim_user", "true"); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetStatusShow::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetStatus status = QTweetConvert::variantMapToStatus(json.toMap()); + + emit parsedStatus(status); + } else { + qDebug() << "QTweetStatusShow JSON parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetstatusshow.h b/thirdparty/QTweetLib/src/qtweetstatusshow.h new file mode 100644 index 000000000..79ae2c6af --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetstatusshow.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETSTATUSSHOW_H +#define QTWEETSTATUSSHOW_H + +#include "qtweetnetbase.h" + +/** + * Class for fetching single tweet + */ +class QTWEETLIBSHARED_EXPORT QTweetStatusShow : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetStatusShow(QObject *parent = 0); + QTweetStatusShow(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 id, + bool trimUser = false, + bool includeEntities = false); + +signals: + /** Emits specified tweet */ + void parsedStatus(const QTweetStatus& status); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETSTATUSSHOW_H diff --git a/thirdparty/QTweetLib/src/qtweetstatusupdate.cpp b/thirdparty/QTweetLib/src/qtweetstatusupdate.cpp new file mode 100644 index 000000000..56283fb25 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetstatusupdate.cpp @@ -0,0 +1,112 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetstatusupdate.h" +#include "qtweetstatus.h" +#include "qtweetgeocoord.h" +#include "qtweetconvert.h" + +QTweetStatusUpdate::QTweetStatusUpdate(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetStatusUpdate::QTweetStatusUpdate(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Posts a tweet + * @param status text of the status update + * @param inReplyToStatus ID of a existing tweet is in reply to + * @param latLong latitude and longitude + * @param placeid a place in the world (use reverse geocoding) + * @param displayCoordinates whether or not to put a exact coordinates a tweet has been sent from + */ +void QTweetStatusUpdate::post(const QString &status, + qint64 inReplyToStatus, + const QTweetGeoCoord& latLong, + const QString &placeid, + bool displayCoordinates, + bool trimUser, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/statuses/update.json"); + + QUrl urlQuery("http://api.twitter.com/1/statuses/update.json"); + + urlQuery.addEncodedQueryItem("status", QUrl::toPercentEncoding(status)); + + if (inReplyToStatus != 0) + urlQuery.addQueryItem("in_reply_to_status_id", QString::number(inReplyToStatus)); + + if (latLong.isValid()) { + urlQuery.addQueryItem("lat", QString::number(latLong.latitude())); + urlQuery.addQueryItem("long", QString::number(latLong.longitude())); + } + + if (!placeid.isEmpty()) + urlQuery.addQueryItem("place_id", placeid); + + if (displayCoordinates) + urlQuery.addQueryItem("display_coordinates", "true"); + + if (trimUser) + urlQuery.addQueryItem("trim_user", "true"); + + if (includeEntities) + urlQuery.addQueryItem("include_entities", "true"); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST); + QNetworkRequest req(url); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + //build status post array + QByteArray statusPost = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath); + + //remove '?' + statusPost.remove(0, 1); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, statusPost); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetStatusUpdate::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetStatus status = QTweetConvert::variantMapToStatus(json.toMap()); + + emit postedStatus(status); + } else { + qDebug() << "QTweetStatusUpdate JSON parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetstatusupdate.h b/thirdparty/QTweetLib/src/qtweetstatusupdate.h new file mode 100644 index 000000000..f8886b1f0 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetstatusupdate.h @@ -0,0 +1,52 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETSTATUSUPDATE_H +#define QTWEETSTATUSUPDATE_H + +#include "qtweetnetbase.h" +#include "qtweetgeocoord.h" + +/** + * Class for updating user status (posting tweet) + */ +class QTWEETLIBSHARED_EXPORT QTweetStatusUpdate : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetStatusUpdate(QObject *parent = 0); + QTweetStatusUpdate(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void post(const QString& status, + qint64 inReplyToStatus = 0, + const QTweetGeoCoord& latLong = QTweetGeoCoord(), + const QString& placeid = QString(), + bool displayCoordinates = false, + bool trimUser = false, + bool includeEntities = false); + +signals: + /** Emits posted status */ + void postedStatus(const QTweetStatus& status); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETSTATUSUPDATE_H diff --git a/thirdparty/QTweetLib/src/qtweetuser.cpp b/thirdparty/QTweetLib/src/qtweetuser.cpp new file mode 100644 index 000000000..919dec05f --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetuser.cpp @@ -0,0 +1,355 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include "qtweetuser.h" +#include "qtweetstatus.h" + +class QTweetUserData : public QSharedData +{ +public: + QTweetUserData() : id(0) {} + + bool contributorsEnabled; + QDateTime createdAt; + QString description; + int favoritesCount; + bool followRequestSent; + int followersCount; + int friendsCount; + bool geoEnabled; + qint64 id; + QString lang; + int listedCount; + QString location; + QString name; + //QString profileBackgroundColor; + //QString profileBackgroundImageUrl; + //bool profileBackgroundTile; + QString profileImageUrl; + //QString profileLinkColor; + //QString profileSidebarBorderColor; + //QString profileSidebarFillColor; + //QString profileTextColor; + //bool profileUseBackgroundImage; + bool accountProtected; + QString screenName; + //bool showAllInlineMedia; + int statusesCount; + QString timeZone; + QString url; + int utcOffset; + bool verified; + //avoid recursion with QTweetStatus + qint64 statusId; + QString statusText; + QDateTime statusCreatedAt; + qint64 statusInReplyToUserId; + QString statusInReplyToScreenName; + qint64 statusInReplyToStatusId; + bool statusFavorited; + QString statusSource; + //QTweetUser user + //QTweetStatus retweetedStatus; //check if there is retweeted status in user response + //bool containsRetweetStatus; + //QTweetStatus status; //should be pointer? +}; + +QTweetUser::QTweetUser() : + d(new QTweetUserData) +{ +} + +QTweetUser::QTweetUser(const QTweetUser &other) : + d(other.d) +{ +} + +QTweetUser& QTweetUser::operator =(const QTweetUser& other) +{ + if (this != &other) + d.operator =(other.d); + return *this; +} + +QTweetUser::~QTweetUser() +{ +} + +void QTweetUser::setContributorsEnabled(bool enabled) +{ + d->contributorsEnabled = enabled; +} + +bool QTweetUser::isContributorsEnabled() const +{ + return d->contributorsEnabled; +} + +void QTweetUser::setId(qint64 id) +{ + d->id = id; +} + +qint64 QTweetUser::id() const +{ + return d->id; +} + +void QTweetUser::setLang(const QString &lang) +{ + d->lang = lang; +} + +QString QTweetUser::lang() const +{ + return d->lang; +} + +void QTweetUser::setListedCount(int count) +{ + d->listedCount = count; +} + +int QTweetUser::listedCount() const +{ + return d->listedCount; +} + +void QTweetUser::setName(const QString &name) +{ + d->name = name; +} + +QString QTweetUser::name() const +{ + return d->name; +} + +//void QTweetUser::setProfileBackgroundColor(const QString &color) +//{ +// // ### TODO: prepend #? +// // ### TODO: use QColor (QGui dependancy?) instead QString +// d->profileBackgroundColor = color; +//} + +//QString QTweetUser::profileBackgroundColor() const +//{ +// return d->profileBackgroundColor; +//} + +void QTweetUser::setScreenName(const QString &screenName) +{ + d->screenName = screenName; +} + +QString QTweetUser::screenName() const +{ + return d->screenName; +} + +void QTweetUser::setLocation(const QString &location) +{ + d->location = location; +} + +QString QTweetUser::location() const +{ + return d->location; +} + +void QTweetUser::setDescription(const QString &desc) +{ + d->description = desc; +} + +QString QTweetUser::description() const +{ + return d->description; +} + +void QTweetUser::setprofileImageUrl(const QString &url) +{ + d->profileImageUrl = url; +} + +QString QTweetUser::profileImageUrl() const +{ + return d->profileImageUrl; +} + +void QTweetUser::setUrl(const QString &url) +{ + d->url = url; +} + +QString QTweetUser::url() const +{ + return d->url; +} + +void QTweetUser::setProtected(bool protected_) +{ + d->accountProtected = protected_; +} + +bool QTweetUser::isProtected() const +{ + return d->accountProtected; +} + +void QTweetUser::setFollowersCount(int count) +{ + d->followersCount = count; +} + +int QTweetUser::followersCount() const +{ + return d->followersCount; +} + +void QTweetUser::setFriendsCount(int count) +{ + d->friendsCount = count; +} + +int QTweetUser::friendsCount() const +{ + return d->friendsCount; +} + +void QTweetUser::setCreatedAt(const QString &twitterDate) +{ + d->createdAt = twitterDateToQDateTime(twitterDate); +} + +void QTweetUser::setCreatedAt(const QDateTime &datetime) +{ + d->createdAt = datetime; +} + +QDateTime QTweetUser::createdAt() const +{ + return d->createdAt; +} + +void QTweetUser::setFavouritesCount(int count) +{ + d->favoritesCount = count; +} + +int QTweetUser::favouritesCount() const +{ + return d->favoritesCount; +} + +void QTweetUser::setUtcOffset(int sec) +{ + d->utcOffset = sec; +} + +int QTweetUser::utcOffset() const +{ + return d->utcOffset; +} + +void QTweetUser::setTimezone(const QString &timezone) +{ + d->timeZone = timezone; +} + +QString QTweetUser::timezone() const +{ + return d->timeZone; +} + +void QTweetUser::setGeoEnabled(bool isGeoEnabled) +{ + d->geoEnabled = isGeoEnabled; +} + +bool QTweetUser::isGeoEnabled() const +{ + return d->geoEnabled; +} + +void QTweetUser::setVerified(bool verified) +{ + d->verified = verified; +} + +bool QTweetUser::isVerified() const +{ + return d->verified; +} + +void QTweetUser::setStatusesCount(int count) +{ + d->statusesCount = count; +} + +int QTweetUser::statusesCount() const +{ + return d->statusesCount; +} + +void QTweetUser::setStatus(const QTweetStatus &lastStatus) +{ + //d->status = lastStatus; + d->statusId = lastStatus.id(); + d->statusText = lastStatus.text(); + d->statusCreatedAt = lastStatus.createdAt(); + d->statusInReplyToScreenName = lastStatus.inReplyToScreenName(); + d->statusInReplyToStatusId = lastStatus.inReplyToStatusId(); + d->statusInReplyToUserId = lastStatus.inReplyToUserId(); + d->statusFavorited = lastStatus.favorited(); + d->statusSource = lastStatus.source(); +} + +QTweetStatus QTweetUser::status() const +{ + QTweetStatus lastStatus; + lastStatus.setId(d->statusId); + lastStatus.setText(d->statusText); + //lastStatus.setCreatedAt(); // ### TODO FIX IT! + lastStatus.setInReplyToScreenName(d->statusInReplyToScreenName); + lastStatus.setInReplyToStatusId(d->statusInReplyToStatusId); + lastStatus.setInReplyToUserId(d->statusInReplyToUserId); + lastStatus.setFavorited(d->statusFavorited); + lastStatus.setSource(d->statusSource); + + return lastStatus; +} + +QDateTime QTweetUser::twitterDateToQDateTime(const QString &twitterDate) +{ + //Twitter Date Format: 'Wed Sep 01 11:27:25 +0000 2010' UTC + QString dateString = twitterDate.left(11) + twitterDate.right(4); + QString timeString = twitterDate.mid(11, 8); + + QDate date = QDate::fromString(dateString); + QTime time = QTime::fromString(timeString); + + if (date.isValid() && time.isValid()) + return QDateTime(date, time, Qt::UTC); + else + return QDateTime(); +} diff --git a/thirdparty/QTweetLib/src/qtweetuser.h b/thirdparty/QTweetLib/src/qtweetuser.h new file mode 100644 index 000000000..86323b65d --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetuser.h @@ -0,0 +1,94 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETUSER_H +#define QTWEETUSER_H + +#include +#include +#include "qtweetlib_global.h" + +class QTweetStatus; +class QTweetUserData; + +/** + * Class for storing user info + */ +class QTWEETLIBSHARED_EXPORT QTweetUser +{ +public: + QTweetUser(); + QTweetUser(const QTweetUser& other); + QTweetUser& operator=(const QTweetUser& other); + ~QTweetUser(); + + void setContributorsEnabled(bool enabled); + bool isContributorsEnabled() const; + void setId(qint64 id); + qint64 id() const; + void setLang(const QString& lang); + QString lang() const; + void setListedCount(int count); + int listedCount() const; + void setName(const QString& name); + QString name() const; + void setScreenName(const QString& screenName); + QString screenName() const; + void setLocation(const QString& location); + QString location() const; + void setDescription(const QString& desc); + QString description() const; + void setprofileImageUrl(const QString& url); + QString profileImageUrl() const; + void setUrl(const QString& url); + QString url() const; + void setProtected(bool isProtected); + bool isProtected() const; + void setFollowersCount(int count); + int followersCount() const; + void setFriendsCount(int count); + int friendsCount() const; + void setCreatedAt(const QString& twitterDate); + void setCreatedAt(const QDateTime& datetime); + QDateTime createdAt() const; + void setFavouritesCount(int count); + int favouritesCount() const; + void setUtcOffset(int sec); + int utcOffset() const; + void setTimezone(const QString& timezone); + QString timezone() const; + void setGeoEnabled(bool isGeoEnabled); + bool isGeoEnabled() const; + void setVerified(bool verified); + bool isVerified() const; + void setStatusesCount(int count); + int statusesCount() const; + void setStatus(const QTweetStatus& lastStatus); + QTweetStatus status() const; + + static QDateTime twitterDateToQDateTime(const QString& twitterDate); + +private: + QSharedDataPointer d; +}; + +Q_DECLARE_METATYPE(QTweetUser) + +#endif // QTWEETUSER_H diff --git a/thirdparty/QTweetLib/src/qtweetuserlookup.cpp b/thirdparty/QTweetLib/src/qtweetuserlookup.cpp new file mode 100644 index 000000000..9be5b2f1a --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetuserlookup.cpp @@ -0,0 +1,97 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetuserlookup.h" +#include "qtweetuser.h" +#include "qtweetconvert.h" + +QTweetUserLookup::QTweetUserLookup(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetUserLookup::QTweetUserLookup(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts fetching + * @param useridList list of user IDs + * @param screenNameList list of screen names + */ +void QTweetUserLookup::fetch(const QList &useridList, + const QStringList &screenNameList) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/users/lookup.json"); + + if (!useridList.isEmpty()) { + QString idString; + + foreach (qint64 id, useridList) + idString += QString::number(id) + ','; + + idString.chop(1); + + url.addQueryItem("user_id", idString); + } + + if (!screenNameList.isEmpty()) { + QString scrnString; + + foreach (const QString& screenName, screenNameList) + scrnString += screenName + ','; + + scrnString.chop(1); + + url.addQueryItem("screen_name", scrnString); + } + + // ### TODO: Add include_entities parameter + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetUserLookup::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList userInfoList = QTweetConvert::variantToUserInfoList(json); + + emit parsedUserInfoList(userInfoList); + } else { + qDebug() << "QTweetUserLookup json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetuserlookup.h b/thirdparty/QTweetLib/src/qtweetuserlookup.h new file mode 100644 index 000000000..00e3a4614 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetuserlookup.h @@ -0,0 +1,49 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETUSERLOOKUP_H +#define QTWEETUSERLOOKUP_H + +#include +#include "qtweetnetbase.h" + +class QTweetUser; + +/** + * Class for fetching up to 100 users and theirs most recent status + */ +class QTWEETLIBSHARED_EXPORT QTweetUserLookup : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetUserLookup(QObject *parent = 0); + QTweetUserLookup(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(const QList& useridList = QList(), + const QStringList& screenNameList = QStringList()); + +signals: + /** Emits list of users */ + void parsedUserInfoList(const QList& userInfoList); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETUSERLOOKUP_H diff --git a/thirdparty/QTweetLib/src/qtweetusersearch.cpp b/thirdparty/QTweetLib/src/qtweetusersearch.cpp new file mode 100644 index 000000000..f9a3108a2 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetusersearch.cpp @@ -0,0 +1,89 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetusersearch.h" +#include "qtweetuser.h" +#include "qtweetconvert.h" + +QTweetUserSearch::QTweetUserSearch(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetUserSearch::QTweetUserSearch(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts a search + * @param query the search query to run against people search + * @param perPage the number of people per page to retrieve. Maxiumum of 20 allowed per page. + * @param page specifies the page of results to retrieve + * @param includeEntities when set to true each tweet will include a node called "entities". + */ +void QTweetUserSearch::search(const QString &query, + int perPage, + int page, + bool includeEntities) +{ + if (!isAuthenticationEnabled()) { + qCritical("Needs authentication to be enabled"); + return; + } + + QUrl url("http://api.twitter.com/1/users/search.json"); + + url.addQueryItem("q", query); + + if (perPage) + url.addQueryItem("per_page", QString::number(perPage)); + + if (page) + url.addQueryItem("page", QString::number(page)); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetUserSearch::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList userInfoList = QTweetConvert::variantToUserInfoList(json); + + emit parsedUserInfoList(userInfoList); + } else { + qDebug() << "QTweetUserSearch json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetusersearch.h b/thirdparty/QTweetLib/src/qtweetusersearch.h new file mode 100644 index 000000000..142db4399 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetusersearch.h @@ -0,0 +1,48 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETUSERSEARCH_H +#define QTWEETUSERSEARCH_H + +#include "qtweetnetbase.h" + +/** + * Runs a search for users + */ +class QTWEETLIBSHARED_EXPORT QTweetUserSearch : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetUserSearch(QObject *parent = 0); + QTweetUserSearch(OAuthTwitter* oauthTwitter, QObject *parent); + void search(const QString& query, + int perPage = 0, + int page = 0, + bool includeEntities = false); + +signals: + /** Emits list of users */ + void parsedUserInfoList(const QList& userInfoList); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETUSERSEARCH_H diff --git a/thirdparty/QTweetLib/src/qtweetusershow.cpp b/thirdparty/QTweetLib/src/qtweetusershow.cpp new file mode 100644 index 000000000..27c944b92 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetusershow.cpp @@ -0,0 +1,99 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetusershow.h" +#include "qtweetuser.h" +#include "qtweetconvert.h" + +QTweetUserShow::QTweetUserShow(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetUserShow::QTweetUserShow(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts fetching + * @param userid user ID + * @param includeEntities when set to true, each tweet will include a node called "entities" + */ +void QTweetUserShow::fetch(qint64 userid, bool includeEntities) +{ + QUrl url("http://api.twitter.com/1/users/show.json"); + + url.addQueryItem("user_id", QString::number(userid)); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +/** + * Starts fetching + * @param userid user ID + * @param includeEntities when set to true, each tweet will include a node called "entities" + */ +void QTweetUserShow::fetch(const QString &screenName, bool includeEntities) +{ + QUrl url("http://api.twitter.com/1/users/show.json"); + + url.addQueryItem("screen_name", screenName); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetUserShow::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QTweetUser userInfo = QTweetConvert::variantMapToUserInfo(json.toMap()); + + emit parsedUserInfo(userInfo); + } else { + qDebug() << "QTweetUserShow Json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetusershow.h b/thirdparty/QTweetLib/src/qtweetusershow.h new file mode 100644 index 000000000..9f04d2f76 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetusershow.h @@ -0,0 +1,48 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETUSERSHOW_H +#define QTWEETUSERSHOW_H + +#include "qtweetnetbase.h" + +/** + * Class for fetching extended information for given user + */ +class QTWEETLIBSHARED_EXPORT QTweetUserShow : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetUserShow(QObject *parent = 0); + QTweetUserShow(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 userid = 0, + bool includeEntities = false); + void fetch(const QString& screenName, + bool includeEntities = false); + +signals: + /** Emits user */ + void parsedUserInfo(const QTweetUser& userInfo); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETUSERSHOW_H diff --git a/thirdparty/QTweetLib/src/qtweetuserstatusesfollowers.cpp b/thirdparty/QTweetLib/src/qtweetuserstatusesfollowers.cpp new file mode 100644 index 000000000..0b0281216 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetuserstatusesfollowers.cpp @@ -0,0 +1,128 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetuserstatusesfollowers.h" +#include "qtweetuser.h" +#include "qtweetconvert.h" + +QTweetUserStatusesFollowers::QTweetUserStatusesFollowers(QObject *parent) : + QTweetNetBase(parent), m_usesCursoring(false) +{ +} + +QTweetUserStatusesFollowers::QTweetUserStatusesFollowers(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent), m_usesCursoring(false) +{ +} + +/** + * Starts fetching user followers list + * @param userid the ID of the user for whom to return results for. + * @param cursor breaks the results into pages. Provide a value of "-1" to begin paging. + * @param includeEntities when set to true, each tweet will include a node called "entities,". + */ +void QTweetUserStatusesFollowers::fetch(qint64 userid, + const QString &cursor, + bool includeEntities) +{ + QUrl url("http://api.twitter.com/1/statuses/followers.json"); + + url.addQueryItem("user_id", QString::number(userid)); + + if (!cursor.isEmpty()) { + m_usesCursoring = true; + url.addQueryItem("cursor", cursor); + } + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +/** + * Starts fetching user followers list + * @param screenName the screen name of the user for whom to return results for. + * @param cursor breaks the results into pages. Provide a value of "-1" to begin paging. + * @param includeEntities when set to true, each tweet will include a node called "entities,". + */ +void QTweetUserStatusesFollowers::fetch(const QString &screenName, + const QString &cursor, + bool includeEntities) +{ + QUrl url("http://api.twitter.com/1/statuses/followers.json"); + + url.addQueryItem("screen_name", screenName); + + if (!cursor.isEmpty()) { + m_usesCursoring = true; + url.addQueryItem("cursor", cursor); + } + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetUserStatusesFollowers::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + if (m_usesCursoring) { + QVariantMap respMap = json.toMap(); + + QVariant userListVar = respMap["users"]; + + QList userList = QTweetConvert::variantToUserInfoList(userListVar); + + QString nextCursor = respMap["next_cursor_str"].toString(); + QString prevCursor = respMap["previous_cursor_str"].toString(); + + emit parsedFollowersList(userList, nextCursor, prevCursor); + } else { + QList userList = QTweetConvert::variantToUserInfoList(json); + + emit parsedFollowersList(userList); + } + } else { + qDebug() << "QTweetUserStatusesFollowers json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetuserstatusesfollowers.h b/thirdparty/QTweetLib/src/qtweetuserstatusesfollowers.h new file mode 100644 index 000000000..dacbe77fc --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetuserstatusesfollowers.h @@ -0,0 +1,62 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETUSERSTATUSESFOLLOWERS_H +#define QTWEETUSERSTATUSESFOLLOWERS_H + +#include "qtweetnetbase.h" + +/** + * Fetches the authenticating user's followers, each with current status inline. + * They are ordered by the order in which they followed the user, 100 at a time. + * + * Use the cursor option to access older friends. + */ +class QTWEETLIBSHARED_EXPORT QTweetUserStatusesFollowers : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetUserStatusesFollowers(QObject *parent = 0); + QTweetUserStatusesFollowers(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 userid = 0, + const QString& cursor = QString(), + bool includeEntities = false); + void fetch(const QString& screenName = QString(), + const QString& cursor = QString(), + bool includeEntities = false); + +signals: + /** Emits page of followers list + * @param followersList list of friends + * @param nextCursor cursor for next page, "0" if there is no next page, empty if there is no paging + * @param prevCursor cursor for prev page, "0" if there is no prev page, empty if there is no paging + */ + void parsedFollowersList(const QList& followersList, + const QString& nextCursor = QString(), + const QString& prevCursor = QString()); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); + +private: + bool m_usesCursoring; +}; + +#endif // QTWEETUSERSTATUSESFOLLOWERS_H diff --git a/thirdparty/QTweetLib/src/qtweetuserstatusesfriends.cpp b/thirdparty/QTweetLib/src/qtweetuserstatusesfriends.cpp new file mode 100644 index 000000000..dffa9d10a --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetuserstatusesfriends.cpp @@ -0,0 +1,131 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include +#include "qjson/parserrunnable.h" +#include "qtweetuser.h" +#include "qtweetuserstatusesfriends.h" +#include "qtweetconvert.h" + +QTweetUserStatusesFriends::QTweetUserStatusesFriends(QObject *parent) : + QTweetNetBase(parent), m_usesCursoring(false) +{ +} + +QTweetUserStatusesFriends::QTweetUserStatusesFriends(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent), m_usesCursoring(false) +{ +} + +/** + * Starts fetching user friends list + * @param userid the ID of the user for whom to return results for. + * @param cursor breaks the results into pages. Provide a value of "-1" to begin paging. + * @param includeEntities when set to true, each tweet will include a node called "entities,". + */ +void QTweetUserStatusesFriends::fetch(qint64 userid, + const QString &cursor, + bool includeEntities) +{ + QUrl url("http://api.twitter.com/1/statuses/friends.json"); + + url.addQueryItem("user_id", QString::number(userid)); + + if (!cursor.isEmpty()) { + m_usesCursoring = true; + url.addQueryItem("cursor", cursor); + } + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +/** + * Starts fetching user friends list + * @param screenName the screen name of the user for whom to return results for. + * @param cursor breaks the results into pages. Provide a value of "-1" to begin paging. + * @param includeEntities when set to true, each tweet will include a node called "entities,". + */ +void QTweetUserStatusesFriends::fetch(const QString &screenName, + const QString &cursor, + bool includeEntities) +{ + QUrl url("http://api.twitter.com/1/statuses/friends.json"); + + url.addQueryItem("screen_name", screenName); + + if (!cursor.isEmpty()) { + m_usesCursoring = true; + url.addQueryItem("cursor", cursor); + } + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetUserStatusesFriends::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + if (m_usesCursoring) { + QVariantMap respMap = json.toMap(); + + QVariant userListVar = respMap["users"]; + + QList userList = QTweetConvert::variantToUserInfoList(userListVar); + + QString nextCursor = respMap["next_cursor_str"].toString(); + QString prevCursor = respMap["previous_cursor_str"].toString(); + + emit parsedFriendsList(userList, nextCursor, prevCursor); + } else { + QList userList = QTweetConvert::variantToUserInfoList(json); + + emit parsedFriendsList(userList); + } + } else { + qDebug() << "QTweetUserStatusesFriends json parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} + diff --git a/thirdparty/QTweetLib/src/qtweetuserstatusesfriends.h b/thirdparty/QTweetLib/src/qtweetuserstatusesfriends.h new file mode 100644 index 000000000..ed5eb4101 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetuserstatusesfriends.h @@ -0,0 +1,62 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETUSERSTATUSESFRIENDS_H +#define QTWEETUSERSTATUSESFRIENDS_H + +#include "qtweetnetbase.h" + +/** + * Fetches a user's friends, each with current status inline. + * They are ordered by the order in which the user followed them, most recently followed first, 100 at a time. + * + * Use the cursor option to access older friends. + */ +class QTWEETLIBSHARED_EXPORT QTweetUserStatusesFriends : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetUserStatusesFriends(QObject *parent = 0); + QTweetUserStatusesFriends(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 userid = 0, + const QString& cursor = QString(), + bool includeEntities = false); + void fetch(const QString& screenName, + const QString& cursor = QString(), + bool includeEntities = false); + +signals: + /** Emits page of friends + * @param friendsList list of friends + * @param nextCursor cursor for next page, "0" if there is no next page, empty if there is no paging + * @param prevCursor cursor for prev page, "0" if there is no prev page, empty if there is no paging + */ + void parsedFriendsList(const QList& friendsList, + const QString& nextCursor = QString(), + const QString& prevCursor = QString()); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); + +private: + bool m_usesCursoring; // ### TODO: Remove it +}; + +#endif // QTWEETUSERSTATUSESFRIENDS_H diff --git a/thirdparty/QTweetLib/src/qtweetuserstream.cpp b/thirdparty/QTweetLib/src/qtweetuserstream.cpp new file mode 100644 index 000000000..7e2526e46 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetuserstream.cpp @@ -0,0 +1,238 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include +#include +#include "oauthtwitter.h" +#include "qtweetuserstream.h" +#include "qtweetstatus.h" +#include "qtweetdmstatus.h" +#include "qtweetuser.h" +#include "qtweetconvert.h" +#include "qjson/parserrunnable.h" + +#define TWITTER_USERSTREAM_URL "https://userstream.twitter.com/2/user.json" + +/** + * Constructor + */ +QTweetUserStream::QTweetUserStream(QObject *parent) : + QObject(parent), m_oauthTwitter(0), m_reply(0), m_backofftimer(new QTimer(this)) +{ + m_backofftimer->setSingleShot(true); + connect(m_backofftimer, SIGNAL(timeout()), this, SLOT(startFetching())); +} + +/** + * Sets oauth twitter object + */ +void QTweetUserStream::setOAuthTwitter(OAuthTwitter *oauthTwitter) +{ + m_oauthTwitter = oauthTwitter; +} + +/** + * Gets oauth twitter object + */ +OAuthTwitter* QTweetUserStream::oauthTwitter() const +{ + return m_oauthTwitter; +} + +/** + * Called when there is network error + */ +void QTweetUserStream::replyError(QNetworkReply::NetworkError code) +{ + qDebug() << "Reply error: " << code; + + // ### TODO: determine network error codes, assumptions here + + if (code < 200) { + //linear backoff + if (m_backofftimer->interval() < 250) { + m_backofftimer->setInterval(250); + } else { + int nextLinInterval = m_backofftimer->interval() + 250; + + if (nextLinInterval > 16000) //cap + nextLinInterval = 16000; + + m_backofftimer->setInterval(nextLinInterval); + } + + m_backofftimer->start(); + return; + } + + if (code > 200) { + //exp. backoff + if (m_backofftimer->interval() < 10000) { + m_backofftimer->setInterval(10000); + } else { + int nextExpInterval = 2 * m_backofftimer->interval(); + + if (nextExpInterval > 240000) + nextExpInterval = 240000; + + m_backofftimer->setInterval(240000); + } + + m_backofftimer->start(); + } +} + +/** + * Starts fetching user stream + */ +void QTweetUserStream::startFetching() +{ + if (m_reply != 0) { + m_reply->abort(); + m_reply->deleteLater(); + m_reply = 0; + } + + QNetworkRequest req; + req.setUrl(QUrl(TWITTER_USERSTREAM_URL)); + + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(req.url(), OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + + m_reply = m_oauthTwitter->networkAccessManager()->get(req); + connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished())); + connect(m_reply, SIGNAL(readyRead()), this, SLOT(replyReadyRead())); + connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(replyError(QNetworkReply::NetworkError))); +} + +/** + * Called when connection is finished. Reconnects. + */ +void QTweetUserStream::replyFinished() +{ + if (!m_reply->error()) { //no error, reconnect + + //sligh delay for reconnect + m_backofftimer->setInterval(250); + m_backofftimer->start(); + m_reply->deleteLater(); + m_reply = 0; + } else { //error, delete QNetworkReply + m_reply->deleteLater(); + m_reply = 0; + } +} + +void QTweetUserStream::replyReadyRead() +{ + QByteArray response = m_reply->readAll(); + + //reset timer + m_backofftimer->setInterval(0); + + //split to response to delimited and not delimited part + int lastCarrReturn = response.lastIndexOf('\r'); + QByteArray rightNotDelimitedPart = response.mid(lastCarrReturn + 1); + QByteArray leftDelimitedPart = response.left(lastCarrReturn); + + //prepend to left previous not delimited response + leftDelimitedPart = leftDelimitedPart.prepend(m_cashedResponse); + + QList elements = leftDelimitedPart.split('\r'); + + for (int i = 0; i < elements.size(); ++i) { + if (elements.at(i) != QByteArray(1, '\n')) { + emit stream(elements.at(i)); + parseStream(elements.at(i)); + } + } + + if (rightNotDelimitedPart != QByteArray(1, '\n')) + m_cashedResponse = rightNotDelimitedPart; + else + m_cashedResponse.clear(); +} + +void QTweetUserStream::parseStream(const QByteArray& data) +{ + QJson::ParserRunnable *jsonParser = new QJson::ParserRunnable(); + jsonParser->setData(data); + connect(jsonParser, SIGNAL(parsingFinished(QVariant,bool,QString)), + this, SLOT(parsingFinished(QVariant,bool,QString))); + + QThreadPool::globalInstance()->start(jsonParser); +} + +void QTweetUserStream::parsingFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (!ok) { + qDebug() << "JSON parsing error: " << errorMsg; + return; + } + + QVariantMap result = json.toMap(); + + //find it what stream element is + if (result.contains("friends")) { //friends element + parseFriendsList(result); + } else if (result.contains("direct_message")) { //direct message element + parseDirectMessage(result); + } else if (result.contains("text")) { //status element + QTweetStatus status = QTweetConvert::variantMapToStatus(result); + emit statusesStream(status); + } else if (result.contains("delete")) { + parseDeleteStatus(result); + } +} + +void QTweetUserStream::parseFriendsList(const QVariantMap& streamObject) +{ + QList friends; + + QVariantList friendsVarList = streamObject["friends"].toList(); + + foreach (const QVariant& idVar, friendsVarList) + friends.append(idVar.toLongLong()); + + emit friendsList(friends); +} + +void QTweetUserStream::parseDirectMessage(const QVariantMap &streamObject) +{ + QVariantMap directMessageVarMap = streamObject["direct_message"].toMap(); + + QTweetDMStatus directMessage = QTweetConvert::variantMapToDirectMessage(directMessageVarMap); + + emit directMessageStream(directMessage); +} + +void QTweetUserStream::parseDeleteStatus(const QVariantMap &streamObject) +{ + QVariantMap deleteStatusVarMap = streamObject["delete"].toMap(); + QVariantMap statusVarMap = deleteStatusVarMap["status"].toMap(); + + qint64 id = statusVarMap["id"].toLongLong(); + qint64 userid = statusVarMap["user_id"].toLongLong(); + + emit deleteStatusStream(id, userid); +} diff --git a/thirdparty/QTweetLib/src/qtweetuserstream.h b/thirdparty/QTweetLib/src/qtweetuserstream.h new file mode 100644 index 000000000..c7f1e3bc6 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetuserstream.h @@ -0,0 +1,93 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETUSERSTREAM_H +#define QTWEETUSERSTREAM_H + +#include +#include +#include "qtweetlib_global.h" + +class QNetworkAccessManager; +class QNetworkReply; +class OAuthTwitter; +class QAuthenticator; +class QTimer; +class QTweetStatus; +class QTweetDMStatus; + +/** + * Class for fetching user stream + */ +class QTWEETLIBSHARED_EXPORT QTweetUserStream : public QObject +{ + Q_OBJECT +public: + QTweetUserStream(QObject *parent = 0); + void setOAuthTwitter(OAuthTwitter* oauthTwitter); + OAuthTwitter* oauthTwitter() const; + +signals: + /** + * Emits stream elements + */ + void stream(const QByteArray& ); + + /** + * Emits tweets (parsed) elements from stream + */ + void statusesStream(const QTweetStatus& status); + /** + * Emits friends list of id of authenticated user. + * Emited immediately after connecting to the user stream. + * If there is no reconnect it won't be emited again. + */ + void friendsList(const QList friends); + /** + * Emits direct message when is arrived in the stream + */ + void directMessageStream(const QTweetDMStatus& directMessage); + /** + * Emits deletion of status in the stream + */ + void deleteStatusStream(qint64 id, qint64 userid); + +public slots: + void startFetching(); + +private slots: + void replyError(QNetworkReply::NetworkError code); + void replyFinished(); + void replyReadyRead(); + void parsingFinished(const QVariant& json, bool ok, const QString& errorMsg); + +private: + void parseStream(const QByteArray& ); + void parseFriendsList(const QVariantMap& streamObject); + void parseDirectMessage(const QVariantMap& streamObject); + void parseDeleteStatus(const QVariantMap& streamObject); + + OAuthTwitter *m_oauthTwitter; + QNetworkReply *m_reply; + QTimer *m_backofftimer; + QByteArray m_cashedResponse; +}; + +#endif // QTWEETUSERSTREAM_H diff --git a/thirdparty/QTweetLib/src/qtweetusertimeline.cpp b/thirdparty/QTweetLib/src/qtweetusertimeline.cpp new file mode 100644 index 000000000..cc51ec283 --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetusertimeline.cpp @@ -0,0 +1,111 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#include +#include +#include +#include "qtweetusertimeline.h" +#include "qtweetstatus.h" +#include "qtweetconvert.h" + +QTweetUserTimeline::QTweetUserTimeline(QObject *parent) : + QTweetNetBase(parent) +{ +} + +QTweetUserTimeline::QTweetUserTimeline(OAuthTwitter *oauthTwitter, QObject *parent) : + QTweetNetBase(oauthTwitter, parent) +{ +} + +/** + * Starts fetching + * @param userid user ID + * @param screenName user screen name + * @param sinceid fetches tweets with ID greater (more recent) then sinceid + * @param maxid fetches tweets with ID less (older) then maxid + * @param count number of tweets to fetch (up to 200) + * @param page page number + * @param skipUser true to include only status authors numerical ID + * @param includeRts timeline contains native retweets if true + * @param includeEntities each tweet include node "entities" + */ +void QTweetUserTimeline::fetch(qint64 userid, + const QString &screenName, + qint64 sinceid, + qint64 maxid, + int count, + int page, + bool trimUser, + bool includeRts, + bool includeEntities) +{ + QUrl url("http://api.twitter.com/1/statuses/user_timeline.json"); + + if (userid != 0) + url.addQueryItem("user_id", QString::number(userid)); + + if (!screenName.isEmpty()) + url.addQueryItem("screen_name", screenName); + + if (sinceid != 0) + url.addQueryItem("since_id", QString::number(sinceid)); + + if (maxid != 0) + url.addQueryItem("max_id", QString::number(maxid)); + + if (count != 0) + url.addQueryItem("count", QString::number(count)); + + if (page != 0) + url.addQueryItem("page", QString::number(page)); + + if (trimUser) + url.addQueryItem("trim_user", "true"); + + if (includeRts) + url.addQueryItem("include_rts", "true"); + + if (includeEntities) + url.addQueryItem("include_entities", "true"); + + QNetworkRequest req(url); + + if (isAuthenticationEnabled()) { + QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); + req.setRawHeader(AUTH_HEADER, oauthHeader); + } + + QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); + connect(reply, SIGNAL(finished()), this, SLOT(reply())); +} + +void QTweetUserTimeline::parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg) +{ + if (ok) { + QList statuses = QTweetConvert::variantToStatusList(json); + + emit parsedStatuses(statuses); + } else { + qDebug() << "QTweetUserTimeline JSON parser error: " << errorMsg; + setLastErrorMessage(errorMsg); + emit error(JsonParsingError, errorMsg); + } +} diff --git a/thirdparty/QTweetLib/src/qtweetusertimeline.h b/thirdparty/QTweetLib/src/qtweetusertimeline.h new file mode 100644 index 000000000..5b9cd6c8c --- /dev/null +++ b/thirdparty/QTweetLib/src/qtweetusertimeline.h @@ -0,0 +1,55 @@ +/* Copyright (c) 2010, Antonie Jovanoski + * + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Contact e-mail: Antonie Jovanoski + */ + +#ifndef QTWEETUSERTIMELINE_H +#define QTWEETUSERTIMELINE_H + +#include "qtweetnetbase.h" + +class QTweetStatus; + +/** + * Class for fetching tweets posted by user or other users + */ +class QTWEETLIBSHARED_EXPORT QTweetUserTimeline : public QTweetNetBase +{ + Q_OBJECT +public: + QTweetUserTimeline(QObject *parent = 0); + QTweetUserTimeline(OAuthTwitter *oauthTwitter, QObject *parent = 0); + void fetch(qint64 userid = 0, + const QString& screenName = QString(), + qint64 sinceid = 0, + qint64 maxid = 0, + int count = 0, + int page = 0, + bool trimUser = false, + bool includeRts = false, + bool includeEntities = false); + +signals: + /** Emits user timeline status list */ + void parsedStatuses(const QList& statuses); + +protected slots: + void parsingJsonFinished(const QVariant &json, bool ok, const QString &errorMsg); +}; + +#endif // QTWEETUSERTIMELINE_H diff --git a/thirdparty/QTweetLib/src/src.pro b/thirdparty/QTweetLib/src/src.pro new file mode 100644 index 000000000..0b235756a --- /dev/null +++ b/thirdparty/QTweetLib/src/src.pro @@ -0,0 +1,153 @@ +QT += network +QT += gui + +TEMPLATE = lib +TARGET = QTweetLib +DESTDIR = ../lib +win32:LIBS += ../lib/qjson.lib +unix:LIBS += -L../lib -lqjson +CONFIG += create_prl +INCLUDEPATH += .. + +windows: { + DEFINES += QTWEETLIB_MAKEDLL +} + +HEADERS += \ + oauth.h \ + oauthtwitter.h \ + qtweetfriendstimeline.h \ + qtweetlib_global.h \ + qtweethometimeline.h \ + qtweetmentions.h \ + qtweetnetbase.h \ + qtweetretweetbyme.h \ + qtweetretweetsofme.h \ + qtweetretweettome.h \ + qtweetstatus.h \ + qtweetstatusshow.h \ + qtweetstatusupdate.h \ + qtweetuser.h \ + qtweetusertimeline.h \ + qtweetstatusdestroy.h \ + qtweetstatusretweet.h \ + qtweetstatusretweets.h \ + qtweetusershow.h \ + qtweetuserlookup.h \ + qtweetdirectmessages.h \ + qtweetuserstream.h \ + qtweetdmstatus.h \ + qtweetusersearch.h \ + qtweetuserstatusesfriends.h \ + qtweetuserstatusesfollowers.h \ + qtweetlist.h \ + qtweetlistcreate.h \ + qtweetlistupdate.h \ + qtweetlistgetlists.h \ + qtweetlistshowlist.h \ + qtweetlistdeletelist.h \ + qtweetliststatuses.h \ + qtweetlistmemberships.h \ + qtweetlistsubscriptions.h \ + qtweetlistgetmembers.h \ + qtweetlistaddmember.h \ + qtweetlistdeletemember.h \ + qtweetlistsubscribers.h \ + qtweetlistsubscribe.h \ + qtweetlistunsubscribe.h \ + qtweetdirectmessagessent.h \ + qtweetdirectmessagenew.h \ + qtweetdirectmessagedestroy.h \ + qtweetfriendshipcreate.h \ + qtweetfriendshipdestroy.h \ + qtweetfriendsid.h \ + qtweetfollowersid.h \ + qtweetaccountverifycredentials.h \ + qtweetaccountratelimitstatus.h \ + qtweetfavorites.h \ + qtweetfavoritescreate.h \ + qtweetfavoritesdestroy.h \ + qtweetsearch.h \ + qtweetsearchresult.h \ + qtweetsearchpageresults.h \ + qtweetplace.h \ + qtweetgeoreversegeocode.h \ + qtweetgeosearch.h \ + qtweetgeosimilarplaces.h \ + qtweetgeoplaceid.h \ + qtweetgeoplacecreate.h \ + qtweetgeocoord.h \ + qtweetgeoboundingbox.h \ + qtweetconvert.h \ + qtweetentityurl.h \ + qtweetentityhashtag.h \ + qtweetentityusermentions.h + +SOURCES += \ + oauth.cpp \ + oauthtwitter.cpp \ + qtweetfriendstimeline.cpp \ + qtweethometimeline.cpp \ + qtweetmentions.cpp \ + qtweetnetbase.cpp \ + qtweetretweetbyme.cpp \ + qtweetretweetsofme.cpp \ + qtweetretweettome.cpp \ + qtweetstatus.cpp \ + qtweetstatusshow.cpp \ + qtweetstatusupdate.cpp \ + qtweetuser.cpp \ + qtweetusertimeline.cpp \ + qtweetstatusdestroy.cpp \ + qtweetstatusretweet.cpp \ + qtweetstatusretweets.cpp \ + qtweetusershow.cpp \ + qtweetuserlookup.cpp \ + qtweetdirectmessages.cpp \ + qtweetuserstream.cpp \ + qtweetdmstatus.cpp \ + qtweetusersearch.cpp \ + qtweetuserstatusesfriends.cpp \ + qtweetuserstatusesfollowers.cpp \ + qtweetlist.cpp \ + qtweetlistcreate.cpp \ + qtweetlistupdate.cpp \ + qtweetlistgetlists.cpp \ + qtweetlistshowlist.cpp \ + qtweetlistdeletelist.cpp \ + qtweetliststatuses.cpp \ + qtweetlistmemberships.cpp \ + qtweetlistsubscriptions.cpp \ + qtweetlistgetmembers.cpp \ + qtweetlistaddmember.cpp \ + qtweetlistdeletemember.cpp \ + qtweetlistsubscribers.cpp \ + qtweetlistsubscribe.cpp \ + qtweetlistunsubscribe.cpp \ + qtweetdirectmessagessent.cpp \ + qtweetdirectmessagenew.cpp \ + qtweetdirectmessagedestroy.cpp \ + qtweetfriendshipcreate.cpp \ + qtweetfriendshipdestroy.cpp \ + qtweetfriendsid.cpp \ + qtweetfollowersid.cpp \ + qtweetaccountverifycredentials.cpp \ + qtweetaccountratelimitstatus.cpp \ + qtweetfavorites.cpp \ + qtweetfavoritescreate.cpp \ + qtweetfavoritesdestroy.cpp \ + qtweetsearch.cpp \ + qtweetsearchresult.cpp \ + qtweetsearchpageresults.cpp \ + qtweetplace.cpp \ + qtweetgeoreversegeocode.cpp \ + qtweetgeosearch.cpp \ + qtweetgeosimilarplaces.cpp \ + qtweetgeoplaceid.cpp \ + qtweetgeoplacecreate.cpp \ + qtweetgeocoord.cpp \ + qtweetgeoboundingbox.cpp \ + qtweetconvert.cpp \ + qtweetentityurl.cpp \ + qtweetentityhashtag.cpp \ + qtweetentityusermentions.cpp From b5b1ad16ff898cb2d390d9a755c2c0100f942b1d Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 11 Feb 2011 15:39:55 -0500 Subject: [PATCH 02/62] lowercase the dirname --- thirdparty/CMakeLists.txt | 2 +- thirdparty/{QTweetLib => qtweetlib}/CMakeLists.txt | 0 thirdparty/{QTweetLib => qtweetlib}/LICENSE | 0 thirdparty/{QTweetLib => qtweetlib}/QTweetLib.pro | 0 thirdparty/{QTweetLib => qtweetlib}/README | 0 thirdparty/{QTweetLib => qtweetlib}/examples/examples.pro | 0 .../examples/followers/FollowerDelegate.qml | 0 .../examples/followers/FollowersList.qml | 0 .../{QTweetLib => qtweetlib}/examples/followers/followers.cpp | 0 .../{QTweetLib => qtweetlib}/examples/followers/followers.h | 0 .../{QTweetLib => qtweetlib}/examples/followers/followers.pro | 0 .../{QTweetLib => qtweetlib}/examples/followers/followers.qrc | 0 .../{QTweetLib => qtweetlib}/examples/followers/followers.ui | 0 .../examples/followers/followerslistmodel.cpp | 0 .../examples/followers/followerslistmodel.h | 0 thirdparty/{QTweetLib => qtweetlib}/examples/followers/main.cpp | 0 .../{QTweetLib => qtweetlib}/examples/georeverse/georeverse.cpp | 0 .../{QTweetLib => qtweetlib}/examples/georeverse/georeverse.h | 0 .../{QTweetLib => qtweetlib}/examples/georeverse/georeverse.pro | 0 .../{QTweetLib => qtweetlib}/examples/georeverse/georeverse.ui | 0 .../{QTweetLib => qtweetlib}/examples/georeverse/main.cpp | 0 .../{QTweetLib => qtweetlib}/examples/geosearch/geosearch.cpp | 0 .../{QTweetLib => qtweetlib}/examples/geosearch/geosearch.h | 0 .../{QTweetLib => qtweetlib}/examples/geosearch/geosearch.pro | 0 .../{QTweetLib => qtweetlib}/examples/geosearch/geosearch.ui | 0 thirdparty/{QTweetLib => qtweetlib}/examples/geosearch/main.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/examples/search/main.cpp | 0 .../{QTweetLib => qtweetlib}/examples/search/mainwindow.cpp | 0 .../{QTweetLib => qtweetlib}/examples/search/mainwindow.h | 0 .../{QTweetLib => qtweetlib}/examples/search/mainwindow.ui | 0 thirdparty/{QTweetLib => qtweetlib}/examples/search/search.pro | 0 .../timelines => qtweetlib/examples/statusupdate}/main.cpp | 0 .../examples/statusupdate/mainwindow.cpp | 0 .../{QTweetLib => qtweetlib}/examples/statusupdate/mainwindow.h | 0 .../examples/statusupdate/mainwindow.ui | 0 .../examples/statusupdate/statusupdate.pro | 0 .../statusupdate => qtweetlib/examples/timelines}/main.cpp | 0 .../{QTweetLib => qtweetlib}/examples/timelines/mainwindow.cpp | 0 .../{QTweetLib => qtweetlib}/examples/timelines/mainwindow.h | 0 .../{QTweetLib => qtweetlib}/examples/timelines/mainwindow.ui | 0 .../{QTweetLib => qtweetlib}/examples/timelines/timelines.pro | 0 .../{QTweetLib => qtweetlib}/examples/userstream/main.cpp | 0 .../{QTweetLib => qtweetlib}/examples/userstream/userstream.cpp | 0 .../{QTweetLib => qtweetlib}/examples/userstream/userstream.h | 0 .../{QTweetLib => qtweetlib}/examples/userstream/userstream.pro | 0 .../{QTweetLib => qtweetlib}/examples/userstream/userstream.ui | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/json_parser.cc | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/json_parser.hh | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/json_parser.yy | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/json_scanner.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/json_scanner.h | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/location.hh | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/parser.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/parser.h | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/parser_p.h | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/parserrunnable.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/parserrunnable.h | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/position.hh | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/qjson.pro | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/qjson_debug.h | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/qjson_export.h | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/qobjecthelper.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/qobjecthelper.h | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/serializer.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/serializer.h | 0 .../{QTweetLib => qtweetlib}/qjson/serializerrunnable.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/serializerrunnable.h | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/src.pro | 0 thirdparty/{QTweetLib => qtweetlib}/qjson/stack.hh | 0 thirdparty/{QTweetLib => qtweetlib}/qtweetlib_export.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/oauth.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/oauth.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/oauthtwitter.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/oauthtwitter.h | 0 .../src/qtweetaccountratelimitstatus.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetaccountratelimitstatus.h | 0 .../src/qtweetaccountverifycredentials.cpp | 0 .../src/qtweetaccountverifycredentials.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetconvert.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetconvert.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetdirectmessagedestroy.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetdirectmessagedestroy.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetdirectmessagenew.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetdirectmessagenew.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetdirectmessages.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetdirectmessages.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetdirectmessagessent.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetdirectmessagessent.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetdmstatus.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetdmstatus.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetentityhashtag.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetentityhashtag.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetentityurl.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetentityurl.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetentityusermentions.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetentityusermentions.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetfavorites.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetfavorites.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetfavoritescreate.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetfavoritescreate.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetfavoritesdestroy.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetfavoritesdestroy.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetfollowersid.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetfollowersid.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetfriendshipcreate.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetfriendshipcreate.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetfriendshipdestroy.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetfriendshipdestroy.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetfriendsid.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetfriendsid.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetfriendstimeline.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetfriendstimeline.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetgeoboundingbox.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeoboundingbox.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeocoord.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeocoord.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetgeoplacecreate.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeoplacecreate.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeoplaceid.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeoplaceid.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetgeoreversegeocode.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetgeoreversegeocode.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeosearch.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeosearch.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetgeosimilarplaces.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetgeosimilarplaces.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweethometimeline.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweethometimeline.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlib_global.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlist.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlist.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistaddmember.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistaddmember.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistcreate.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistcreate.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetlistdeletelist.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistdeletelist.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetlistdeletemember.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetlistdeletemember.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistgetlists.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistgetlists.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetlistgetmembers.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistgetmembers.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetlistmemberships.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistmemberships.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistshowlist.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistshowlist.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetliststatuses.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetliststatuses.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistsubscribe.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistsubscribe.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetlistsubscribers.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistsubscribers.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetlistsubscriptions.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetlistsubscriptions.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetlistunsubscribe.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistunsubscribe.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistupdate.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistupdate.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetmentions.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetmentions.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetnetbase.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetnetbase.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetplace.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetplace.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetretweetbyme.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetretweetbyme.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetretweetsofme.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetretweetsofme.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetretweettome.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetretweettome.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetsearch.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetsearch.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetsearchpageresults.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetsearchpageresults.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetsearchresult.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetsearchresult.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatus.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatus.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusdestroy.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusdestroy.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusretweet.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusretweet.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetstatusretweets.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusretweets.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusshow.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusshow.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusupdate.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusupdate.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetuser.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetuser.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetuserlookup.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetuserlookup.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetusersearch.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetusersearch.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetusershow.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetusershow.h | 0 .../src/qtweetuserstatusesfollowers.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetuserstatusesfollowers.h | 0 .../{QTweetLib => qtweetlib}/src/qtweetuserstatusesfriends.cpp | 0 .../{QTweetLib => qtweetlib}/src/qtweetuserstatusesfriends.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetuserstream.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetuserstream.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetusertimeline.cpp | 0 thirdparty/{QTweetLib => qtweetlib}/src/qtweetusertimeline.h | 0 thirdparty/{QTweetLib => qtweetlib}/src/src.pro | 0 206 files changed, 1 insertion(+), 1 deletion(-) rename thirdparty/{QTweetLib => qtweetlib}/CMakeLists.txt (100%) rename thirdparty/{QTweetLib => qtweetlib}/LICENSE (100%) rename thirdparty/{QTweetLib => qtweetlib}/QTweetLib.pro (100%) rename thirdparty/{QTweetLib => qtweetlib}/README (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/examples.pro (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/followers/FollowerDelegate.qml (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/followers/FollowersList.qml (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/followers/followers.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/followers/followers.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/followers/followers.pro (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/followers/followers.qrc (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/followers/followers.ui (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/followers/followerslistmodel.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/followers/followerslistmodel.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/followers/main.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/georeverse/georeverse.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/georeverse/georeverse.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/georeverse/georeverse.pro (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/georeverse/georeverse.ui (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/georeverse/main.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/geosearch/geosearch.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/geosearch/geosearch.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/geosearch/geosearch.pro (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/geosearch/geosearch.ui (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/geosearch/main.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/search/main.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/search/mainwindow.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/search/mainwindow.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/search/mainwindow.ui (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/search/search.pro (100%) rename thirdparty/{QTweetLib/examples/timelines => qtweetlib/examples/statusupdate}/main.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/statusupdate/mainwindow.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/statusupdate/mainwindow.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/statusupdate/mainwindow.ui (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/statusupdate/statusupdate.pro (100%) rename thirdparty/{QTweetLib/examples/statusupdate => qtweetlib/examples/timelines}/main.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/timelines/mainwindow.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/timelines/mainwindow.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/timelines/mainwindow.ui (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/timelines/timelines.pro (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/userstream/main.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/userstream/userstream.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/userstream/userstream.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/userstream/userstream.pro (100%) rename thirdparty/{QTweetLib => qtweetlib}/examples/userstream/userstream.ui (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/json_parser.cc (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/json_parser.hh (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/json_parser.yy (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/json_scanner.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/json_scanner.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/location.hh (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/parser.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/parser.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/parser_p.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/parserrunnable.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/parserrunnable.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/position.hh (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/qjson.pro (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/qjson_debug.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/qjson_export.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/qobjecthelper.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/qobjecthelper.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/serializer.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/serializer.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/serializerrunnable.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/serializerrunnable.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/src.pro (100%) rename thirdparty/{QTweetLib => qtweetlib}/qjson/stack.hh (100%) rename thirdparty/{QTweetLib => qtweetlib}/qtweetlib_export.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/oauth.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/oauth.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/oauthtwitter.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/oauthtwitter.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetaccountratelimitstatus.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetaccountratelimitstatus.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetaccountverifycredentials.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetaccountverifycredentials.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetconvert.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetconvert.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetdirectmessagedestroy.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetdirectmessagedestroy.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetdirectmessagenew.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetdirectmessagenew.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetdirectmessages.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetdirectmessages.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetdirectmessagessent.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetdirectmessagessent.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetdmstatus.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetdmstatus.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetentityhashtag.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetentityhashtag.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetentityurl.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetentityurl.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetentityusermentions.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetentityusermentions.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfavorites.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfavorites.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfavoritescreate.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfavoritescreate.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfavoritesdestroy.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfavoritesdestroy.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfollowersid.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfollowersid.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfriendshipcreate.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfriendshipcreate.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfriendshipdestroy.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfriendshipdestroy.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfriendsid.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfriendsid.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfriendstimeline.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetfriendstimeline.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeoboundingbox.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeoboundingbox.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeocoord.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeocoord.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeoplacecreate.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeoplacecreate.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeoplaceid.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeoplaceid.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeoreversegeocode.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeoreversegeocode.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeosearch.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeosearch.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeosimilarplaces.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetgeosimilarplaces.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweethometimeline.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweethometimeline.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlib_global.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlist.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlist.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistaddmember.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistaddmember.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistcreate.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistcreate.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistdeletelist.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistdeletelist.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistdeletemember.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistdeletemember.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistgetlists.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistgetlists.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistgetmembers.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistgetmembers.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistmemberships.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistmemberships.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistshowlist.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistshowlist.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetliststatuses.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetliststatuses.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistsubscribe.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistsubscribe.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistsubscribers.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistsubscribers.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistsubscriptions.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistsubscriptions.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistunsubscribe.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistunsubscribe.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistupdate.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetlistupdate.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetmentions.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetmentions.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetnetbase.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetnetbase.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetplace.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetplace.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetretweetbyme.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetretweetbyme.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetretweetsofme.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetretweetsofme.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetretweettome.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetretweettome.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetsearch.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetsearch.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetsearchpageresults.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetsearchpageresults.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetsearchresult.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetsearchresult.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatus.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatus.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusdestroy.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusdestroy.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusretweet.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusretweet.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusretweets.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusretweets.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusshow.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusshow.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusupdate.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetstatusupdate.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetuser.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetuser.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetuserlookup.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetuserlookup.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetusersearch.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetusersearch.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetusershow.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetusershow.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetuserstatusesfollowers.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetuserstatusesfollowers.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetuserstatusesfriends.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetuserstatusesfriends.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetuserstream.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetuserstream.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetusertimeline.cpp (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/qtweetusertimeline.h (100%) rename thirdparty/{QTweetLib => qtweetlib}/src/src.pro (100%) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 85a5e8dda..e3e0fdc91 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -1,2 +1,2 @@ add_subdirectory( jdns ) -add_subdirectory( QTweetLib ) +add_subdirectory( qtweetlib ) diff --git a/thirdparty/QTweetLib/CMakeLists.txt b/thirdparty/qtweetlib/CMakeLists.txt similarity index 100% rename from thirdparty/QTweetLib/CMakeLists.txt rename to thirdparty/qtweetlib/CMakeLists.txt diff --git a/thirdparty/QTweetLib/LICENSE b/thirdparty/qtweetlib/LICENSE similarity index 100% rename from thirdparty/QTweetLib/LICENSE rename to thirdparty/qtweetlib/LICENSE diff --git a/thirdparty/QTweetLib/QTweetLib.pro b/thirdparty/qtweetlib/QTweetLib.pro similarity index 100% rename from thirdparty/QTweetLib/QTweetLib.pro rename to thirdparty/qtweetlib/QTweetLib.pro diff --git a/thirdparty/QTweetLib/README b/thirdparty/qtweetlib/README similarity index 100% rename from thirdparty/QTweetLib/README rename to thirdparty/qtweetlib/README diff --git a/thirdparty/QTweetLib/examples/examples.pro b/thirdparty/qtweetlib/examples/examples.pro similarity index 100% rename from thirdparty/QTweetLib/examples/examples.pro rename to thirdparty/qtweetlib/examples/examples.pro diff --git a/thirdparty/QTweetLib/examples/followers/FollowerDelegate.qml b/thirdparty/qtweetlib/examples/followers/FollowerDelegate.qml similarity index 100% rename from thirdparty/QTweetLib/examples/followers/FollowerDelegate.qml rename to thirdparty/qtweetlib/examples/followers/FollowerDelegate.qml diff --git a/thirdparty/QTweetLib/examples/followers/FollowersList.qml b/thirdparty/qtweetlib/examples/followers/FollowersList.qml similarity index 100% rename from thirdparty/QTweetLib/examples/followers/FollowersList.qml rename to thirdparty/qtweetlib/examples/followers/FollowersList.qml diff --git a/thirdparty/QTweetLib/examples/followers/followers.cpp b/thirdparty/qtweetlib/examples/followers/followers.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/followers/followers.cpp rename to thirdparty/qtweetlib/examples/followers/followers.cpp diff --git a/thirdparty/QTweetLib/examples/followers/followers.h b/thirdparty/qtweetlib/examples/followers/followers.h similarity index 100% rename from thirdparty/QTweetLib/examples/followers/followers.h rename to thirdparty/qtweetlib/examples/followers/followers.h diff --git a/thirdparty/QTweetLib/examples/followers/followers.pro b/thirdparty/qtweetlib/examples/followers/followers.pro similarity index 100% rename from thirdparty/QTweetLib/examples/followers/followers.pro rename to thirdparty/qtweetlib/examples/followers/followers.pro diff --git a/thirdparty/QTweetLib/examples/followers/followers.qrc b/thirdparty/qtweetlib/examples/followers/followers.qrc similarity index 100% rename from thirdparty/QTweetLib/examples/followers/followers.qrc rename to thirdparty/qtweetlib/examples/followers/followers.qrc diff --git a/thirdparty/QTweetLib/examples/followers/followers.ui b/thirdparty/qtweetlib/examples/followers/followers.ui similarity index 100% rename from thirdparty/QTweetLib/examples/followers/followers.ui rename to thirdparty/qtweetlib/examples/followers/followers.ui diff --git a/thirdparty/QTweetLib/examples/followers/followerslistmodel.cpp b/thirdparty/qtweetlib/examples/followers/followerslistmodel.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/followers/followerslistmodel.cpp rename to thirdparty/qtweetlib/examples/followers/followerslistmodel.cpp diff --git a/thirdparty/QTweetLib/examples/followers/followerslistmodel.h b/thirdparty/qtweetlib/examples/followers/followerslistmodel.h similarity index 100% rename from thirdparty/QTweetLib/examples/followers/followerslistmodel.h rename to thirdparty/qtweetlib/examples/followers/followerslistmodel.h diff --git a/thirdparty/QTweetLib/examples/followers/main.cpp b/thirdparty/qtweetlib/examples/followers/main.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/followers/main.cpp rename to thirdparty/qtweetlib/examples/followers/main.cpp diff --git a/thirdparty/QTweetLib/examples/georeverse/georeverse.cpp b/thirdparty/qtweetlib/examples/georeverse/georeverse.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/georeverse/georeverse.cpp rename to thirdparty/qtweetlib/examples/georeverse/georeverse.cpp diff --git a/thirdparty/QTweetLib/examples/georeverse/georeverse.h b/thirdparty/qtweetlib/examples/georeverse/georeverse.h similarity index 100% rename from thirdparty/QTweetLib/examples/georeverse/georeverse.h rename to thirdparty/qtweetlib/examples/georeverse/georeverse.h diff --git a/thirdparty/QTweetLib/examples/georeverse/georeverse.pro b/thirdparty/qtweetlib/examples/georeverse/georeverse.pro similarity index 100% rename from thirdparty/QTweetLib/examples/georeverse/georeverse.pro rename to thirdparty/qtweetlib/examples/georeverse/georeverse.pro diff --git a/thirdparty/QTweetLib/examples/georeverse/georeverse.ui b/thirdparty/qtweetlib/examples/georeverse/georeverse.ui similarity index 100% rename from thirdparty/QTweetLib/examples/georeverse/georeverse.ui rename to thirdparty/qtweetlib/examples/georeverse/georeverse.ui diff --git a/thirdparty/QTweetLib/examples/georeverse/main.cpp b/thirdparty/qtweetlib/examples/georeverse/main.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/georeverse/main.cpp rename to thirdparty/qtweetlib/examples/georeverse/main.cpp diff --git a/thirdparty/QTweetLib/examples/geosearch/geosearch.cpp b/thirdparty/qtweetlib/examples/geosearch/geosearch.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/geosearch/geosearch.cpp rename to thirdparty/qtweetlib/examples/geosearch/geosearch.cpp diff --git a/thirdparty/QTweetLib/examples/geosearch/geosearch.h b/thirdparty/qtweetlib/examples/geosearch/geosearch.h similarity index 100% rename from thirdparty/QTweetLib/examples/geosearch/geosearch.h rename to thirdparty/qtweetlib/examples/geosearch/geosearch.h diff --git a/thirdparty/QTweetLib/examples/geosearch/geosearch.pro b/thirdparty/qtweetlib/examples/geosearch/geosearch.pro similarity index 100% rename from thirdparty/QTweetLib/examples/geosearch/geosearch.pro rename to thirdparty/qtweetlib/examples/geosearch/geosearch.pro diff --git a/thirdparty/QTweetLib/examples/geosearch/geosearch.ui b/thirdparty/qtweetlib/examples/geosearch/geosearch.ui similarity index 100% rename from thirdparty/QTweetLib/examples/geosearch/geosearch.ui rename to thirdparty/qtweetlib/examples/geosearch/geosearch.ui diff --git a/thirdparty/QTweetLib/examples/geosearch/main.cpp b/thirdparty/qtweetlib/examples/geosearch/main.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/geosearch/main.cpp rename to thirdparty/qtweetlib/examples/geosearch/main.cpp diff --git a/thirdparty/QTweetLib/examples/search/main.cpp b/thirdparty/qtweetlib/examples/search/main.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/search/main.cpp rename to thirdparty/qtweetlib/examples/search/main.cpp diff --git a/thirdparty/QTweetLib/examples/search/mainwindow.cpp b/thirdparty/qtweetlib/examples/search/mainwindow.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/search/mainwindow.cpp rename to thirdparty/qtweetlib/examples/search/mainwindow.cpp diff --git a/thirdparty/QTweetLib/examples/search/mainwindow.h b/thirdparty/qtweetlib/examples/search/mainwindow.h similarity index 100% rename from thirdparty/QTweetLib/examples/search/mainwindow.h rename to thirdparty/qtweetlib/examples/search/mainwindow.h diff --git a/thirdparty/QTweetLib/examples/search/mainwindow.ui b/thirdparty/qtweetlib/examples/search/mainwindow.ui similarity index 100% rename from thirdparty/QTweetLib/examples/search/mainwindow.ui rename to thirdparty/qtweetlib/examples/search/mainwindow.ui diff --git a/thirdparty/QTweetLib/examples/search/search.pro b/thirdparty/qtweetlib/examples/search/search.pro similarity index 100% rename from thirdparty/QTweetLib/examples/search/search.pro rename to thirdparty/qtweetlib/examples/search/search.pro diff --git a/thirdparty/QTweetLib/examples/timelines/main.cpp b/thirdparty/qtweetlib/examples/statusupdate/main.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/timelines/main.cpp rename to thirdparty/qtweetlib/examples/statusupdate/main.cpp diff --git a/thirdparty/QTweetLib/examples/statusupdate/mainwindow.cpp b/thirdparty/qtweetlib/examples/statusupdate/mainwindow.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/statusupdate/mainwindow.cpp rename to thirdparty/qtweetlib/examples/statusupdate/mainwindow.cpp diff --git a/thirdparty/QTweetLib/examples/statusupdate/mainwindow.h b/thirdparty/qtweetlib/examples/statusupdate/mainwindow.h similarity index 100% rename from thirdparty/QTweetLib/examples/statusupdate/mainwindow.h rename to thirdparty/qtweetlib/examples/statusupdate/mainwindow.h diff --git a/thirdparty/QTweetLib/examples/statusupdate/mainwindow.ui b/thirdparty/qtweetlib/examples/statusupdate/mainwindow.ui similarity index 100% rename from thirdparty/QTweetLib/examples/statusupdate/mainwindow.ui rename to thirdparty/qtweetlib/examples/statusupdate/mainwindow.ui diff --git a/thirdparty/QTweetLib/examples/statusupdate/statusupdate.pro b/thirdparty/qtweetlib/examples/statusupdate/statusupdate.pro similarity index 100% rename from thirdparty/QTweetLib/examples/statusupdate/statusupdate.pro rename to thirdparty/qtweetlib/examples/statusupdate/statusupdate.pro diff --git a/thirdparty/QTweetLib/examples/statusupdate/main.cpp b/thirdparty/qtweetlib/examples/timelines/main.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/statusupdate/main.cpp rename to thirdparty/qtweetlib/examples/timelines/main.cpp diff --git a/thirdparty/QTweetLib/examples/timelines/mainwindow.cpp b/thirdparty/qtweetlib/examples/timelines/mainwindow.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/timelines/mainwindow.cpp rename to thirdparty/qtweetlib/examples/timelines/mainwindow.cpp diff --git a/thirdparty/QTweetLib/examples/timelines/mainwindow.h b/thirdparty/qtweetlib/examples/timelines/mainwindow.h similarity index 100% rename from thirdparty/QTweetLib/examples/timelines/mainwindow.h rename to thirdparty/qtweetlib/examples/timelines/mainwindow.h diff --git a/thirdparty/QTweetLib/examples/timelines/mainwindow.ui b/thirdparty/qtweetlib/examples/timelines/mainwindow.ui similarity index 100% rename from thirdparty/QTweetLib/examples/timelines/mainwindow.ui rename to thirdparty/qtweetlib/examples/timelines/mainwindow.ui diff --git a/thirdparty/QTweetLib/examples/timelines/timelines.pro b/thirdparty/qtweetlib/examples/timelines/timelines.pro similarity index 100% rename from thirdparty/QTweetLib/examples/timelines/timelines.pro rename to thirdparty/qtweetlib/examples/timelines/timelines.pro diff --git a/thirdparty/QTweetLib/examples/userstream/main.cpp b/thirdparty/qtweetlib/examples/userstream/main.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/userstream/main.cpp rename to thirdparty/qtweetlib/examples/userstream/main.cpp diff --git a/thirdparty/QTweetLib/examples/userstream/userstream.cpp b/thirdparty/qtweetlib/examples/userstream/userstream.cpp similarity index 100% rename from thirdparty/QTweetLib/examples/userstream/userstream.cpp rename to thirdparty/qtweetlib/examples/userstream/userstream.cpp diff --git a/thirdparty/QTweetLib/examples/userstream/userstream.h b/thirdparty/qtweetlib/examples/userstream/userstream.h similarity index 100% rename from thirdparty/QTweetLib/examples/userstream/userstream.h rename to thirdparty/qtweetlib/examples/userstream/userstream.h diff --git a/thirdparty/QTweetLib/examples/userstream/userstream.pro b/thirdparty/qtweetlib/examples/userstream/userstream.pro similarity index 100% rename from thirdparty/QTweetLib/examples/userstream/userstream.pro rename to thirdparty/qtweetlib/examples/userstream/userstream.pro diff --git a/thirdparty/QTweetLib/examples/userstream/userstream.ui b/thirdparty/qtweetlib/examples/userstream/userstream.ui similarity index 100% rename from thirdparty/QTweetLib/examples/userstream/userstream.ui rename to thirdparty/qtweetlib/examples/userstream/userstream.ui diff --git a/thirdparty/QTweetLib/qjson/json_parser.cc b/thirdparty/qtweetlib/qjson/json_parser.cc similarity index 100% rename from thirdparty/QTweetLib/qjson/json_parser.cc rename to thirdparty/qtweetlib/qjson/json_parser.cc diff --git a/thirdparty/QTweetLib/qjson/json_parser.hh b/thirdparty/qtweetlib/qjson/json_parser.hh similarity index 100% rename from thirdparty/QTweetLib/qjson/json_parser.hh rename to thirdparty/qtweetlib/qjson/json_parser.hh diff --git a/thirdparty/QTweetLib/qjson/json_parser.yy b/thirdparty/qtweetlib/qjson/json_parser.yy similarity index 100% rename from thirdparty/QTweetLib/qjson/json_parser.yy rename to thirdparty/qtweetlib/qjson/json_parser.yy diff --git a/thirdparty/QTweetLib/qjson/json_scanner.cpp b/thirdparty/qtweetlib/qjson/json_scanner.cpp similarity index 100% rename from thirdparty/QTweetLib/qjson/json_scanner.cpp rename to thirdparty/qtweetlib/qjson/json_scanner.cpp diff --git a/thirdparty/QTweetLib/qjson/json_scanner.h b/thirdparty/qtweetlib/qjson/json_scanner.h similarity index 100% rename from thirdparty/QTweetLib/qjson/json_scanner.h rename to thirdparty/qtweetlib/qjson/json_scanner.h diff --git a/thirdparty/QTweetLib/qjson/location.hh b/thirdparty/qtweetlib/qjson/location.hh similarity index 100% rename from thirdparty/QTweetLib/qjson/location.hh rename to thirdparty/qtweetlib/qjson/location.hh diff --git a/thirdparty/QTweetLib/qjson/parser.cpp b/thirdparty/qtweetlib/qjson/parser.cpp similarity index 100% rename from thirdparty/QTweetLib/qjson/parser.cpp rename to thirdparty/qtweetlib/qjson/parser.cpp diff --git a/thirdparty/QTweetLib/qjson/parser.h b/thirdparty/qtweetlib/qjson/parser.h similarity index 100% rename from thirdparty/QTweetLib/qjson/parser.h rename to thirdparty/qtweetlib/qjson/parser.h diff --git a/thirdparty/QTweetLib/qjson/parser_p.h b/thirdparty/qtweetlib/qjson/parser_p.h similarity index 100% rename from thirdparty/QTweetLib/qjson/parser_p.h rename to thirdparty/qtweetlib/qjson/parser_p.h diff --git a/thirdparty/QTweetLib/qjson/parserrunnable.cpp b/thirdparty/qtweetlib/qjson/parserrunnable.cpp similarity index 100% rename from thirdparty/QTweetLib/qjson/parserrunnable.cpp rename to thirdparty/qtweetlib/qjson/parserrunnable.cpp diff --git a/thirdparty/QTweetLib/qjson/parserrunnable.h b/thirdparty/qtweetlib/qjson/parserrunnable.h similarity index 100% rename from thirdparty/QTweetLib/qjson/parserrunnable.h rename to thirdparty/qtweetlib/qjson/parserrunnable.h diff --git a/thirdparty/QTweetLib/qjson/position.hh b/thirdparty/qtweetlib/qjson/position.hh similarity index 100% rename from thirdparty/QTweetLib/qjson/position.hh rename to thirdparty/qtweetlib/qjson/position.hh diff --git a/thirdparty/QTweetLib/qjson/qjson.pro b/thirdparty/qtweetlib/qjson/qjson.pro similarity index 100% rename from thirdparty/QTweetLib/qjson/qjson.pro rename to thirdparty/qtweetlib/qjson/qjson.pro diff --git a/thirdparty/QTweetLib/qjson/qjson_debug.h b/thirdparty/qtweetlib/qjson/qjson_debug.h similarity index 100% rename from thirdparty/QTweetLib/qjson/qjson_debug.h rename to thirdparty/qtweetlib/qjson/qjson_debug.h diff --git a/thirdparty/QTweetLib/qjson/qjson_export.h b/thirdparty/qtweetlib/qjson/qjson_export.h similarity index 100% rename from thirdparty/QTweetLib/qjson/qjson_export.h rename to thirdparty/qtweetlib/qjson/qjson_export.h diff --git a/thirdparty/QTweetLib/qjson/qobjecthelper.cpp b/thirdparty/qtweetlib/qjson/qobjecthelper.cpp similarity index 100% rename from thirdparty/QTweetLib/qjson/qobjecthelper.cpp rename to thirdparty/qtweetlib/qjson/qobjecthelper.cpp diff --git a/thirdparty/QTweetLib/qjson/qobjecthelper.h b/thirdparty/qtweetlib/qjson/qobjecthelper.h similarity index 100% rename from thirdparty/QTweetLib/qjson/qobjecthelper.h rename to thirdparty/qtweetlib/qjson/qobjecthelper.h diff --git a/thirdparty/QTweetLib/qjson/serializer.cpp b/thirdparty/qtweetlib/qjson/serializer.cpp similarity index 100% rename from thirdparty/QTweetLib/qjson/serializer.cpp rename to thirdparty/qtweetlib/qjson/serializer.cpp diff --git a/thirdparty/QTweetLib/qjson/serializer.h b/thirdparty/qtweetlib/qjson/serializer.h similarity index 100% rename from thirdparty/QTweetLib/qjson/serializer.h rename to thirdparty/qtweetlib/qjson/serializer.h diff --git a/thirdparty/QTweetLib/qjson/serializerrunnable.cpp b/thirdparty/qtweetlib/qjson/serializerrunnable.cpp similarity index 100% rename from thirdparty/QTweetLib/qjson/serializerrunnable.cpp rename to thirdparty/qtweetlib/qjson/serializerrunnable.cpp diff --git a/thirdparty/QTweetLib/qjson/serializerrunnable.h b/thirdparty/qtweetlib/qjson/serializerrunnable.h similarity index 100% rename from thirdparty/QTweetLib/qjson/serializerrunnable.h rename to thirdparty/qtweetlib/qjson/serializerrunnable.h diff --git a/thirdparty/QTweetLib/qjson/src.pro b/thirdparty/qtweetlib/qjson/src.pro similarity index 100% rename from thirdparty/QTweetLib/qjson/src.pro rename to thirdparty/qtweetlib/qjson/src.pro diff --git a/thirdparty/QTweetLib/qjson/stack.hh b/thirdparty/qtweetlib/qjson/stack.hh similarity index 100% rename from thirdparty/QTweetLib/qjson/stack.hh rename to thirdparty/qtweetlib/qjson/stack.hh diff --git a/thirdparty/QTweetLib/qtweetlib_export.h b/thirdparty/qtweetlib/qtweetlib_export.h similarity index 100% rename from thirdparty/QTweetLib/qtweetlib_export.h rename to thirdparty/qtweetlib/qtweetlib_export.h diff --git a/thirdparty/QTweetLib/src/oauth.cpp b/thirdparty/qtweetlib/src/oauth.cpp similarity index 100% rename from thirdparty/QTweetLib/src/oauth.cpp rename to thirdparty/qtweetlib/src/oauth.cpp diff --git a/thirdparty/QTweetLib/src/oauth.h b/thirdparty/qtweetlib/src/oauth.h similarity index 100% rename from thirdparty/QTweetLib/src/oauth.h rename to thirdparty/qtweetlib/src/oauth.h diff --git a/thirdparty/QTweetLib/src/oauthtwitter.cpp b/thirdparty/qtweetlib/src/oauthtwitter.cpp similarity index 100% rename from thirdparty/QTweetLib/src/oauthtwitter.cpp rename to thirdparty/qtweetlib/src/oauthtwitter.cpp diff --git a/thirdparty/QTweetLib/src/oauthtwitter.h b/thirdparty/qtweetlib/src/oauthtwitter.h similarity index 100% rename from thirdparty/QTweetLib/src/oauthtwitter.h rename to thirdparty/qtweetlib/src/oauthtwitter.h diff --git a/thirdparty/QTweetLib/src/qtweetaccountratelimitstatus.cpp b/thirdparty/qtweetlib/src/qtweetaccountratelimitstatus.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetaccountratelimitstatus.cpp rename to thirdparty/qtweetlib/src/qtweetaccountratelimitstatus.cpp diff --git a/thirdparty/QTweetLib/src/qtweetaccountratelimitstatus.h b/thirdparty/qtweetlib/src/qtweetaccountratelimitstatus.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetaccountratelimitstatus.h rename to thirdparty/qtweetlib/src/qtweetaccountratelimitstatus.h diff --git a/thirdparty/QTweetLib/src/qtweetaccountverifycredentials.cpp b/thirdparty/qtweetlib/src/qtweetaccountverifycredentials.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetaccountverifycredentials.cpp rename to thirdparty/qtweetlib/src/qtweetaccountverifycredentials.cpp diff --git a/thirdparty/QTweetLib/src/qtweetaccountverifycredentials.h b/thirdparty/qtweetlib/src/qtweetaccountverifycredentials.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetaccountverifycredentials.h rename to thirdparty/qtweetlib/src/qtweetaccountverifycredentials.h diff --git a/thirdparty/QTweetLib/src/qtweetconvert.cpp b/thirdparty/qtweetlib/src/qtweetconvert.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetconvert.cpp rename to thirdparty/qtweetlib/src/qtweetconvert.cpp diff --git a/thirdparty/QTweetLib/src/qtweetconvert.h b/thirdparty/qtweetlib/src/qtweetconvert.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetconvert.h rename to thirdparty/qtweetlib/src/qtweetconvert.h diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessagedestroy.cpp b/thirdparty/qtweetlib/src/qtweetdirectmessagedestroy.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetdirectmessagedestroy.cpp rename to thirdparty/qtweetlib/src/qtweetdirectmessagedestroy.cpp diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessagedestroy.h b/thirdparty/qtweetlib/src/qtweetdirectmessagedestroy.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetdirectmessagedestroy.h rename to thirdparty/qtweetlib/src/qtweetdirectmessagedestroy.h diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessagenew.cpp b/thirdparty/qtweetlib/src/qtweetdirectmessagenew.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetdirectmessagenew.cpp rename to thirdparty/qtweetlib/src/qtweetdirectmessagenew.cpp diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessagenew.h b/thirdparty/qtweetlib/src/qtweetdirectmessagenew.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetdirectmessagenew.h rename to thirdparty/qtweetlib/src/qtweetdirectmessagenew.h diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessages.cpp b/thirdparty/qtweetlib/src/qtweetdirectmessages.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetdirectmessages.cpp rename to thirdparty/qtweetlib/src/qtweetdirectmessages.cpp diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessages.h b/thirdparty/qtweetlib/src/qtweetdirectmessages.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetdirectmessages.h rename to thirdparty/qtweetlib/src/qtweetdirectmessages.h diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessagessent.cpp b/thirdparty/qtweetlib/src/qtweetdirectmessagessent.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetdirectmessagessent.cpp rename to thirdparty/qtweetlib/src/qtweetdirectmessagessent.cpp diff --git a/thirdparty/QTweetLib/src/qtweetdirectmessagessent.h b/thirdparty/qtweetlib/src/qtweetdirectmessagessent.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetdirectmessagessent.h rename to thirdparty/qtweetlib/src/qtweetdirectmessagessent.h diff --git a/thirdparty/QTweetLib/src/qtweetdmstatus.cpp b/thirdparty/qtweetlib/src/qtweetdmstatus.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetdmstatus.cpp rename to thirdparty/qtweetlib/src/qtweetdmstatus.cpp diff --git a/thirdparty/QTweetLib/src/qtweetdmstatus.h b/thirdparty/qtweetlib/src/qtweetdmstatus.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetdmstatus.h rename to thirdparty/qtweetlib/src/qtweetdmstatus.h diff --git a/thirdparty/QTweetLib/src/qtweetentityhashtag.cpp b/thirdparty/qtweetlib/src/qtweetentityhashtag.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetentityhashtag.cpp rename to thirdparty/qtweetlib/src/qtweetentityhashtag.cpp diff --git a/thirdparty/QTweetLib/src/qtweetentityhashtag.h b/thirdparty/qtweetlib/src/qtweetentityhashtag.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetentityhashtag.h rename to thirdparty/qtweetlib/src/qtweetentityhashtag.h diff --git a/thirdparty/QTweetLib/src/qtweetentityurl.cpp b/thirdparty/qtweetlib/src/qtweetentityurl.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetentityurl.cpp rename to thirdparty/qtweetlib/src/qtweetentityurl.cpp diff --git a/thirdparty/QTweetLib/src/qtweetentityurl.h b/thirdparty/qtweetlib/src/qtweetentityurl.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetentityurl.h rename to thirdparty/qtweetlib/src/qtweetentityurl.h diff --git a/thirdparty/QTweetLib/src/qtweetentityusermentions.cpp b/thirdparty/qtweetlib/src/qtweetentityusermentions.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetentityusermentions.cpp rename to thirdparty/qtweetlib/src/qtweetentityusermentions.cpp diff --git a/thirdparty/QTweetLib/src/qtweetentityusermentions.h b/thirdparty/qtweetlib/src/qtweetentityusermentions.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetentityusermentions.h rename to thirdparty/qtweetlib/src/qtweetentityusermentions.h diff --git a/thirdparty/QTweetLib/src/qtweetfavorites.cpp b/thirdparty/qtweetlib/src/qtweetfavorites.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfavorites.cpp rename to thirdparty/qtweetlib/src/qtweetfavorites.cpp diff --git a/thirdparty/QTweetLib/src/qtweetfavorites.h b/thirdparty/qtweetlib/src/qtweetfavorites.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfavorites.h rename to thirdparty/qtweetlib/src/qtweetfavorites.h diff --git a/thirdparty/QTweetLib/src/qtweetfavoritescreate.cpp b/thirdparty/qtweetlib/src/qtweetfavoritescreate.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfavoritescreate.cpp rename to thirdparty/qtweetlib/src/qtweetfavoritescreate.cpp diff --git a/thirdparty/QTweetLib/src/qtweetfavoritescreate.h b/thirdparty/qtweetlib/src/qtweetfavoritescreate.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfavoritescreate.h rename to thirdparty/qtweetlib/src/qtweetfavoritescreate.h diff --git a/thirdparty/QTweetLib/src/qtweetfavoritesdestroy.cpp b/thirdparty/qtweetlib/src/qtweetfavoritesdestroy.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfavoritesdestroy.cpp rename to thirdparty/qtweetlib/src/qtweetfavoritesdestroy.cpp diff --git a/thirdparty/QTweetLib/src/qtweetfavoritesdestroy.h b/thirdparty/qtweetlib/src/qtweetfavoritesdestroy.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfavoritesdestroy.h rename to thirdparty/qtweetlib/src/qtweetfavoritesdestroy.h diff --git a/thirdparty/QTweetLib/src/qtweetfollowersid.cpp b/thirdparty/qtweetlib/src/qtweetfollowersid.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfollowersid.cpp rename to thirdparty/qtweetlib/src/qtweetfollowersid.cpp diff --git a/thirdparty/QTweetLib/src/qtweetfollowersid.h b/thirdparty/qtweetlib/src/qtweetfollowersid.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfollowersid.h rename to thirdparty/qtweetlib/src/qtweetfollowersid.h diff --git a/thirdparty/QTweetLib/src/qtweetfriendshipcreate.cpp b/thirdparty/qtweetlib/src/qtweetfriendshipcreate.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfriendshipcreate.cpp rename to thirdparty/qtweetlib/src/qtweetfriendshipcreate.cpp diff --git a/thirdparty/QTweetLib/src/qtweetfriendshipcreate.h b/thirdparty/qtweetlib/src/qtweetfriendshipcreate.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfriendshipcreate.h rename to thirdparty/qtweetlib/src/qtweetfriendshipcreate.h diff --git a/thirdparty/QTweetLib/src/qtweetfriendshipdestroy.cpp b/thirdparty/qtweetlib/src/qtweetfriendshipdestroy.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfriendshipdestroy.cpp rename to thirdparty/qtweetlib/src/qtweetfriendshipdestroy.cpp diff --git a/thirdparty/QTweetLib/src/qtweetfriendshipdestroy.h b/thirdparty/qtweetlib/src/qtweetfriendshipdestroy.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfriendshipdestroy.h rename to thirdparty/qtweetlib/src/qtweetfriendshipdestroy.h diff --git a/thirdparty/QTweetLib/src/qtweetfriendsid.cpp b/thirdparty/qtweetlib/src/qtweetfriendsid.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfriendsid.cpp rename to thirdparty/qtweetlib/src/qtweetfriendsid.cpp diff --git a/thirdparty/QTweetLib/src/qtweetfriendsid.h b/thirdparty/qtweetlib/src/qtweetfriendsid.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfriendsid.h rename to thirdparty/qtweetlib/src/qtweetfriendsid.h diff --git a/thirdparty/QTweetLib/src/qtweetfriendstimeline.cpp b/thirdparty/qtweetlib/src/qtweetfriendstimeline.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfriendstimeline.cpp rename to thirdparty/qtweetlib/src/qtweetfriendstimeline.cpp diff --git a/thirdparty/QTweetLib/src/qtweetfriendstimeline.h b/thirdparty/qtweetlib/src/qtweetfriendstimeline.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetfriendstimeline.h rename to thirdparty/qtweetlib/src/qtweetfriendstimeline.h diff --git a/thirdparty/QTweetLib/src/qtweetgeoboundingbox.cpp b/thirdparty/qtweetlib/src/qtweetgeoboundingbox.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeoboundingbox.cpp rename to thirdparty/qtweetlib/src/qtweetgeoboundingbox.cpp diff --git a/thirdparty/QTweetLib/src/qtweetgeoboundingbox.h b/thirdparty/qtweetlib/src/qtweetgeoboundingbox.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeoboundingbox.h rename to thirdparty/qtweetlib/src/qtweetgeoboundingbox.h diff --git a/thirdparty/QTweetLib/src/qtweetgeocoord.cpp b/thirdparty/qtweetlib/src/qtweetgeocoord.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeocoord.cpp rename to thirdparty/qtweetlib/src/qtweetgeocoord.cpp diff --git a/thirdparty/QTweetLib/src/qtweetgeocoord.h b/thirdparty/qtweetlib/src/qtweetgeocoord.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeocoord.h rename to thirdparty/qtweetlib/src/qtweetgeocoord.h diff --git a/thirdparty/QTweetLib/src/qtweetgeoplacecreate.cpp b/thirdparty/qtweetlib/src/qtweetgeoplacecreate.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeoplacecreate.cpp rename to thirdparty/qtweetlib/src/qtweetgeoplacecreate.cpp diff --git a/thirdparty/QTweetLib/src/qtweetgeoplacecreate.h b/thirdparty/qtweetlib/src/qtweetgeoplacecreate.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeoplacecreate.h rename to thirdparty/qtweetlib/src/qtweetgeoplacecreate.h diff --git a/thirdparty/QTweetLib/src/qtweetgeoplaceid.cpp b/thirdparty/qtweetlib/src/qtweetgeoplaceid.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeoplaceid.cpp rename to thirdparty/qtweetlib/src/qtweetgeoplaceid.cpp diff --git a/thirdparty/QTweetLib/src/qtweetgeoplaceid.h b/thirdparty/qtweetlib/src/qtweetgeoplaceid.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeoplaceid.h rename to thirdparty/qtweetlib/src/qtweetgeoplaceid.h diff --git a/thirdparty/QTweetLib/src/qtweetgeoreversegeocode.cpp b/thirdparty/qtweetlib/src/qtweetgeoreversegeocode.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeoreversegeocode.cpp rename to thirdparty/qtweetlib/src/qtweetgeoreversegeocode.cpp diff --git a/thirdparty/QTweetLib/src/qtweetgeoreversegeocode.h b/thirdparty/qtweetlib/src/qtweetgeoreversegeocode.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeoreversegeocode.h rename to thirdparty/qtweetlib/src/qtweetgeoreversegeocode.h diff --git a/thirdparty/QTweetLib/src/qtweetgeosearch.cpp b/thirdparty/qtweetlib/src/qtweetgeosearch.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeosearch.cpp rename to thirdparty/qtweetlib/src/qtweetgeosearch.cpp diff --git a/thirdparty/QTweetLib/src/qtweetgeosearch.h b/thirdparty/qtweetlib/src/qtweetgeosearch.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeosearch.h rename to thirdparty/qtweetlib/src/qtweetgeosearch.h diff --git a/thirdparty/QTweetLib/src/qtweetgeosimilarplaces.cpp b/thirdparty/qtweetlib/src/qtweetgeosimilarplaces.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeosimilarplaces.cpp rename to thirdparty/qtweetlib/src/qtweetgeosimilarplaces.cpp diff --git a/thirdparty/QTweetLib/src/qtweetgeosimilarplaces.h b/thirdparty/qtweetlib/src/qtweetgeosimilarplaces.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetgeosimilarplaces.h rename to thirdparty/qtweetlib/src/qtweetgeosimilarplaces.h diff --git a/thirdparty/QTweetLib/src/qtweethometimeline.cpp b/thirdparty/qtweetlib/src/qtweethometimeline.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweethometimeline.cpp rename to thirdparty/qtweetlib/src/qtweethometimeline.cpp diff --git a/thirdparty/QTweetLib/src/qtweethometimeline.h b/thirdparty/qtweetlib/src/qtweethometimeline.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweethometimeline.h rename to thirdparty/qtweetlib/src/qtweethometimeline.h diff --git a/thirdparty/QTweetLib/src/qtweetlib_global.h b/thirdparty/qtweetlib/src/qtweetlib_global.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlib_global.h rename to thirdparty/qtweetlib/src/qtweetlib_global.h diff --git a/thirdparty/QTweetLib/src/qtweetlist.cpp b/thirdparty/qtweetlib/src/qtweetlist.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlist.cpp rename to thirdparty/qtweetlib/src/qtweetlist.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlist.h b/thirdparty/qtweetlib/src/qtweetlist.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlist.h rename to thirdparty/qtweetlib/src/qtweetlist.h diff --git a/thirdparty/QTweetLib/src/qtweetlistaddmember.cpp b/thirdparty/qtweetlib/src/qtweetlistaddmember.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistaddmember.cpp rename to thirdparty/qtweetlib/src/qtweetlistaddmember.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistaddmember.h b/thirdparty/qtweetlib/src/qtweetlistaddmember.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistaddmember.h rename to thirdparty/qtweetlib/src/qtweetlistaddmember.h diff --git a/thirdparty/QTweetLib/src/qtweetlistcreate.cpp b/thirdparty/qtweetlib/src/qtweetlistcreate.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistcreate.cpp rename to thirdparty/qtweetlib/src/qtweetlistcreate.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistcreate.h b/thirdparty/qtweetlib/src/qtweetlistcreate.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistcreate.h rename to thirdparty/qtweetlib/src/qtweetlistcreate.h diff --git a/thirdparty/QTweetLib/src/qtweetlistdeletelist.cpp b/thirdparty/qtweetlib/src/qtweetlistdeletelist.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistdeletelist.cpp rename to thirdparty/qtweetlib/src/qtweetlistdeletelist.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistdeletelist.h b/thirdparty/qtweetlib/src/qtweetlistdeletelist.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistdeletelist.h rename to thirdparty/qtweetlib/src/qtweetlistdeletelist.h diff --git a/thirdparty/QTweetLib/src/qtweetlistdeletemember.cpp b/thirdparty/qtweetlib/src/qtweetlistdeletemember.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistdeletemember.cpp rename to thirdparty/qtweetlib/src/qtweetlistdeletemember.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistdeletemember.h b/thirdparty/qtweetlib/src/qtweetlistdeletemember.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistdeletemember.h rename to thirdparty/qtweetlib/src/qtweetlistdeletemember.h diff --git a/thirdparty/QTweetLib/src/qtweetlistgetlists.cpp b/thirdparty/qtweetlib/src/qtweetlistgetlists.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistgetlists.cpp rename to thirdparty/qtweetlib/src/qtweetlistgetlists.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistgetlists.h b/thirdparty/qtweetlib/src/qtweetlistgetlists.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistgetlists.h rename to thirdparty/qtweetlib/src/qtweetlistgetlists.h diff --git a/thirdparty/QTweetLib/src/qtweetlistgetmembers.cpp b/thirdparty/qtweetlib/src/qtweetlistgetmembers.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistgetmembers.cpp rename to thirdparty/qtweetlib/src/qtweetlistgetmembers.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistgetmembers.h b/thirdparty/qtweetlib/src/qtweetlistgetmembers.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistgetmembers.h rename to thirdparty/qtweetlib/src/qtweetlistgetmembers.h diff --git a/thirdparty/QTweetLib/src/qtweetlistmemberships.cpp b/thirdparty/qtweetlib/src/qtweetlistmemberships.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistmemberships.cpp rename to thirdparty/qtweetlib/src/qtweetlistmemberships.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistmemberships.h b/thirdparty/qtweetlib/src/qtweetlistmemberships.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistmemberships.h rename to thirdparty/qtweetlib/src/qtweetlistmemberships.h diff --git a/thirdparty/QTweetLib/src/qtweetlistshowlist.cpp b/thirdparty/qtweetlib/src/qtweetlistshowlist.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistshowlist.cpp rename to thirdparty/qtweetlib/src/qtweetlistshowlist.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistshowlist.h b/thirdparty/qtweetlib/src/qtweetlistshowlist.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistshowlist.h rename to thirdparty/qtweetlib/src/qtweetlistshowlist.h diff --git a/thirdparty/QTweetLib/src/qtweetliststatuses.cpp b/thirdparty/qtweetlib/src/qtweetliststatuses.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetliststatuses.cpp rename to thirdparty/qtweetlib/src/qtweetliststatuses.cpp diff --git a/thirdparty/QTweetLib/src/qtweetliststatuses.h b/thirdparty/qtweetlib/src/qtweetliststatuses.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetliststatuses.h rename to thirdparty/qtweetlib/src/qtweetliststatuses.h diff --git a/thirdparty/QTweetLib/src/qtweetlistsubscribe.cpp b/thirdparty/qtweetlib/src/qtweetlistsubscribe.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistsubscribe.cpp rename to thirdparty/qtweetlib/src/qtweetlistsubscribe.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistsubscribe.h b/thirdparty/qtweetlib/src/qtweetlistsubscribe.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistsubscribe.h rename to thirdparty/qtweetlib/src/qtweetlistsubscribe.h diff --git a/thirdparty/QTweetLib/src/qtweetlistsubscribers.cpp b/thirdparty/qtweetlib/src/qtweetlistsubscribers.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistsubscribers.cpp rename to thirdparty/qtweetlib/src/qtweetlistsubscribers.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistsubscribers.h b/thirdparty/qtweetlib/src/qtweetlistsubscribers.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistsubscribers.h rename to thirdparty/qtweetlib/src/qtweetlistsubscribers.h diff --git a/thirdparty/QTweetLib/src/qtweetlistsubscriptions.cpp b/thirdparty/qtweetlib/src/qtweetlistsubscriptions.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistsubscriptions.cpp rename to thirdparty/qtweetlib/src/qtweetlistsubscriptions.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistsubscriptions.h b/thirdparty/qtweetlib/src/qtweetlistsubscriptions.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistsubscriptions.h rename to thirdparty/qtweetlib/src/qtweetlistsubscriptions.h diff --git a/thirdparty/QTweetLib/src/qtweetlistunsubscribe.cpp b/thirdparty/qtweetlib/src/qtweetlistunsubscribe.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistunsubscribe.cpp rename to thirdparty/qtweetlib/src/qtweetlistunsubscribe.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistunsubscribe.h b/thirdparty/qtweetlib/src/qtweetlistunsubscribe.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistunsubscribe.h rename to thirdparty/qtweetlib/src/qtweetlistunsubscribe.h diff --git a/thirdparty/QTweetLib/src/qtweetlistupdate.cpp b/thirdparty/qtweetlib/src/qtweetlistupdate.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistupdate.cpp rename to thirdparty/qtweetlib/src/qtweetlistupdate.cpp diff --git a/thirdparty/QTweetLib/src/qtweetlistupdate.h b/thirdparty/qtweetlib/src/qtweetlistupdate.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetlistupdate.h rename to thirdparty/qtweetlib/src/qtweetlistupdate.h diff --git a/thirdparty/QTweetLib/src/qtweetmentions.cpp b/thirdparty/qtweetlib/src/qtweetmentions.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetmentions.cpp rename to thirdparty/qtweetlib/src/qtweetmentions.cpp diff --git a/thirdparty/QTweetLib/src/qtweetmentions.h b/thirdparty/qtweetlib/src/qtweetmentions.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetmentions.h rename to thirdparty/qtweetlib/src/qtweetmentions.h diff --git a/thirdparty/QTweetLib/src/qtweetnetbase.cpp b/thirdparty/qtweetlib/src/qtweetnetbase.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetnetbase.cpp rename to thirdparty/qtweetlib/src/qtweetnetbase.cpp diff --git a/thirdparty/QTweetLib/src/qtweetnetbase.h b/thirdparty/qtweetlib/src/qtweetnetbase.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetnetbase.h rename to thirdparty/qtweetlib/src/qtweetnetbase.h diff --git a/thirdparty/QTweetLib/src/qtweetplace.cpp b/thirdparty/qtweetlib/src/qtweetplace.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetplace.cpp rename to thirdparty/qtweetlib/src/qtweetplace.cpp diff --git a/thirdparty/QTweetLib/src/qtweetplace.h b/thirdparty/qtweetlib/src/qtweetplace.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetplace.h rename to thirdparty/qtweetlib/src/qtweetplace.h diff --git a/thirdparty/QTweetLib/src/qtweetretweetbyme.cpp b/thirdparty/qtweetlib/src/qtweetretweetbyme.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetretweetbyme.cpp rename to thirdparty/qtweetlib/src/qtweetretweetbyme.cpp diff --git a/thirdparty/QTweetLib/src/qtweetretweetbyme.h b/thirdparty/qtweetlib/src/qtweetretweetbyme.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetretweetbyme.h rename to thirdparty/qtweetlib/src/qtweetretweetbyme.h diff --git a/thirdparty/QTweetLib/src/qtweetretweetsofme.cpp b/thirdparty/qtweetlib/src/qtweetretweetsofme.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetretweetsofme.cpp rename to thirdparty/qtweetlib/src/qtweetretweetsofme.cpp diff --git a/thirdparty/QTweetLib/src/qtweetretweetsofme.h b/thirdparty/qtweetlib/src/qtweetretweetsofme.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetretweetsofme.h rename to thirdparty/qtweetlib/src/qtweetretweetsofme.h diff --git a/thirdparty/QTweetLib/src/qtweetretweettome.cpp b/thirdparty/qtweetlib/src/qtweetretweettome.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetretweettome.cpp rename to thirdparty/qtweetlib/src/qtweetretweettome.cpp diff --git a/thirdparty/QTweetLib/src/qtweetretweettome.h b/thirdparty/qtweetlib/src/qtweetretweettome.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetretweettome.h rename to thirdparty/qtweetlib/src/qtweetretweettome.h diff --git a/thirdparty/QTweetLib/src/qtweetsearch.cpp b/thirdparty/qtweetlib/src/qtweetsearch.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetsearch.cpp rename to thirdparty/qtweetlib/src/qtweetsearch.cpp diff --git a/thirdparty/QTweetLib/src/qtweetsearch.h b/thirdparty/qtweetlib/src/qtweetsearch.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetsearch.h rename to thirdparty/qtweetlib/src/qtweetsearch.h diff --git a/thirdparty/QTweetLib/src/qtweetsearchpageresults.cpp b/thirdparty/qtweetlib/src/qtweetsearchpageresults.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetsearchpageresults.cpp rename to thirdparty/qtweetlib/src/qtweetsearchpageresults.cpp diff --git a/thirdparty/QTweetLib/src/qtweetsearchpageresults.h b/thirdparty/qtweetlib/src/qtweetsearchpageresults.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetsearchpageresults.h rename to thirdparty/qtweetlib/src/qtweetsearchpageresults.h diff --git a/thirdparty/QTweetLib/src/qtweetsearchresult.cpp b/thirdparty/qtweetlib/src/qtweetsearchresult.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetsearchresult.cpp rename to thirdparty/qtweetlib/src/qtweetsearchresult.cpp diff --git a/thirdparty/QTweetLib/src/qtweetsearchresult.h b/thirdparty/qtweetlib/src/qtweetsearchresult.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetsearchresult.h rename to thirdparty/qtweetlib/src/qtweetsearchresult.h diff --git a/thirdparty/QTweetLib/src/qtweetstatus.cpp b/thirdparty/qtweetlib/src/qtweetstatus.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetstatus.cpp rename to thirdparty/qtweetlib/src/qtweetstatus.cpp diff --git a/thirdparty/QTweetLib/src/qtweetstatus.h b/thirdparty/qtweetlib/src/qtweetstatus.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetstatus.h rename to thirdparty/qtweetlib/src/qtweetstatus.h diff --git a/thirdparty/QTweetLib/src/qtweetstatusdestroy.cpp b/thirdparty/qtweetlib/src/qtweetstatusdestroy.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetstatusdestroy.cpp rename to thirdparty/qtweetlib/src/qtweetstatusdestroy.cpp diff --git a/thirdparty/QTweetLib/src/qtweetstatusdestroy.h b/thirdparty/qtweetlib/src/qtweetstatusdestroy.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetstatusdestroy.h rename to thirdparty/qtweetlib/src/qtweetstatusdestroy.h diff --git a/thirdparty/QTweetLib/src/qtweetstatusretweet.cpp b/thirdparty/qtweetlib/src/qtweetstatusretweet.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetstatusretweet.cpp rename to thirdparty/qtweetlib/src/qtweetstatusretweet.cpp diff --git a/thirdparty/QTweetLib/src/qtweetstatusretweet.h b/thirdparty/qtweetlib/src/qtweetstatusretweet.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetstatusretweet.h rename to thirdparty/qtweetlib/src/qtweetstatusretweet.h diff --git a/thirdparty/QTweetLib/src/qtweetstatusretweets.cpp b/thirdparty/qtweetlib/src/qtweetstatusretweets.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetstatusretweets.cpp rename to thirdparty/qtweetlib/src/qtweetstatusretweets.cpp diff --git a/thirdparty/QTweetLib/src/qtweetstatusretweets.h b/thirdparty/qtweetlib/src/qtweetstatusretweets.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetstatusretweets.h rename to thirdparty/qtweetlib/src/qtweetstatusretweets.h diff --git a/thirdparty/QTweetLib/src/qtweetstatusshow.cpp b/thirdparty/qtweetlib/src/qtweetstatusshow.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetstatusshow.cpp rename to thirdparty/qtweetlib/src/qtweetstatusshow.cpp diff --git a/thirdparty/QTweetLib/src/qtweetstatusshow.h b/thirdparty/qtweetlib/src/qtweetstatusshow.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetstatusshow.h rename to thirdparty/qtweetlib/src/qtweetstatusshow.h diff --git a/thirdparty/QTweetLib/src/qtweetstatusupdate.cpp b/thirdparty/qtweetlib/src/qtweetstatusupdate.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetstatusupdate.cpp rename to thirdparty/qtweetlib/src/qtweetstatusupdate.cpp diff --git a/thirdparty/QTweetLib/src/qtweetstatusupdate.h b/thirdparty/qtweetlib/src/qtweetstatusupdate.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetstatusupdate.h rename to thirdparty/qtweetlib/src/qtweetstatusupdate.h diff --git a/thirdparty/QTweetLib/src/qtweetuser.cpp b/thirdparty/qtweetlib/src/qtweetuser.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetuser.cpp rename to thirdparty/qtweetlib/src/qtweetuser.cpp diff --git a/thirdparty/QTweetLib/src/qtweetuser.h b/thirdparty/qtweetlib/src/qtweetuser.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetuser.h rename to thirdparty/qtweetlib/src/qtweetuser.h diff --git a/thirdparty/QTweetLib/src/qtweetuserlookup.cpp b/thirdparty/qtweetlib/src/qtweetuserlookup.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetuserlookup.cpp rename to thirdparty/qtweetlib/src/qtweetuserlookup.cpp diff --git a/thirdparty/QTweetLib/src/qtweetuserlookup.h b/thirdparty/qtweetlib/src/qtweetuserlookup.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetuserlookup.h rename to thirdparty/qtweetlib/src/qtweetuserlookup.h diff --git a/thirdparty/QTweetLib/src/qtweetusersearch.cpp b/thirdparty/qtweetlib/src/qtweetusersearch.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetusersearch.cpp rename to thirdparty/qtweetlib/src/qtweetusersearch.cpp diff --git a/thirdparty/QTweetLib/src/qtweetusersearch.h b/thirdparty/qtweetlib/src/qtweetusersearch.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetusersearch.h rename to thirdparty/qtweetlib/src/qtweetusersearch.h diff --git a/thirdparty/QTweetLib/src/qtweetusershow.cpp b/thirdparty/qtweetlib/src/qtweetusershow.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetusershow.cpp rename to thirdparty/qtweetlib/src/qtweetusershow.cpp diff --git a/thirdparty/QTweetLib/src/qtweetusershow.h b/thirdparty/qtweetlib/src/qtweetusershow.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetusershow.h rename to thirdparty/qtweetlib/src/qtweetusershow.h diff --git a/thirdparty/QTweetLib/src/qtweetuserstatusesfollowers.cpp b/thirdparty/qtweetlib/src/qtweetuserstatusesfollowers.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetuserstatusesfollowers.cpp rename to thirdparty/qtweetlib/src/qtweetuserstatusesfollowers.cpp diff --git a/thirdparty/QTweetLib/src/qtweetuserstatusesfollowers.h b/thirdparty/qtweetlib/src/qtweetuserstatusesfollowers.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetuserstatusesfollowers.h rename to thirdparty/qtweetlib/src/qtweetuserstatusesfollowers.h diff --git a/thirdparty/QTweetLib/src/qtweetuserstatusesfriends.cpp b/thirdparty/qtweetlib/src/qtweetuserstatusesfriends.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetuserstatusesfriends.cpp rename to thirdparty/qtweetlib/src/qtweetuserstatusesfriends.cpp diff --git a/thirdparty/QTweetLib/src/qtweetuserstatusesfriends.h b/thirdparty/qtweetlib/src/qtweetuserstatusesfriends.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetuserstatusesfriends.h rename to thirdparty/qtweetlib/src/qtweetuserstatusesfriends.h diff --git a/thirdparty/QTweetLib/src/qtweetuserstream.cpp b/thirdparty/qtweetlib/src/qtweetuserstream.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetuserstream.cpp rename to thirdparty/qtweetlib/src/qtweetuserstream.cpp diff --git a/thirdparty/QTweetLib/src/qtweetuserstream.h b/thirdparty/qtweetlib/src/qtweetuserstream.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetuserstream.h rename to thirdparty/qtweetlib/src/qtweetuserstream.h diff --git a/thirdparty/QTweetLib/src/qtweetusertimeline.cpp b/thirdparty/qtweetlib/src/qtweetusertimeline.cpp similarity index 100% rename from thirdparty/QTweetLib/src/qtweetusertimeline.cpp rename to thirdparty/qtweetlib/src/qtweetusertimeline.cpp diff --git a/thirdparty/QTweetLib/src/qtweetusertimeline.h b/thirdparty/qtweetlib/src/qtweetusertimeline.h similarity index 100% rename from thirdparty/QTweetLib/src/qtweetusertimeline.h rename to thirdparty/qtweetlib/src/qtweetusertimeline.h diff --git a/thirdparty/QTweetLib/src/src.pro b/thirdparty/qtweetlib/src/src.pro similarity index 100% rename from thirdparty/QTweetLib/src/src.pro rename to thirdparty/qtweetlib/src/src.pro From e74399e701550f6acaaaeb7af33dc04e32adcf1e Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 11 Feb 2011 16:14:49 -0500 Subject: [PATCH 03/62] Just emit ready... --- src/libtomahawk/network/servent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libtomahawk/network/servent.cpp b/src/libtomahawk/network/servent.cpp index b07d6fc61..ddcaa5839 100644 --- a/src/libtomahawk/network/servent.cpp +++ b/src/libtomahawk/network/servent.cpp @@ -103,10 +103,10 @@ Servent::startListening( QHostAddress ha, bool upnp, int port ) case TomahawkSettings::DynDns: qDebug() << "External address mode set to dyndns..."; - //FIXME: ready() is never emitted here, so it will not continue... m_externalHostname = TomahawkSettings::instance()->externalHostname(); m_externalPort = TomahawkSettings::instance()->externalPort(); qDebug() << m_externalHostname << m_externalPort; + emit ready(); break; case TomahawkSettings::Upnp: From 58fcaaab93fb191fa35c7a8ab63a55e6d23db290 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 11 Feb 2011 17:35:21 -0500 Subject: [PATCH 04/62] Add dynamic dns/static host name to settings UI --- src/settingsdialog.cpp | 13 +- src/settingsdialog.ui | 422 ++++++++++++++++++++--------------------- 2 files changed, 217 insertions(+), 218 deletions(-) diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index f14d0363a..1e9bb042a 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -47,20 +47,19 @@ SettingsDialog::SettingsDialog( QWidget *parent ) ui->jabberPassword->setText( s->jabberPassword() ); ui->jabberServer->setText( s->jabberServer() ); ui->jabberPort->setValue( s->jabberPort() ); + ui->staticHostName->setText( s->externalHostname() ); ui->proxyButton->setVisible( false ); if ( ui->jabberPort->text().toInt() != 5222 || !ui->jabberServer->text().isEmpty() ) { - ui->checkBoxJabberAdvanced->setChecked( true ); + ui->checkBoxAdvanced->setChecked( true ); } else { // hide advanved settings - ui->checkBoxJabberAdvanced->setChecked( false ); - ui->jabberServer->setVisible( false ); - ui->jabberPort->setVisible( false ); - ui->labelJabberServer->setVisible( false ); - ui->labelJabberPort->setVisible( false ); + ui->checkBoxAdvanced->setChecked( false ); + ui->groupBoxJabberAdvanced->setVisible( false ); + ui->groupBoxNetworkAdvanced->setVisible( false ); } // MUSIC SCANNER @@ -117,6 +116,8 @@ SettingsDialog::~SettingsDialog() s->setJabberPassword( ui->jabberPassword->text() ); s->setJabberServer( ui->jabberServer->text() ); s->setJabberPort( ui->jabberPort->value() ); + + s->setExternalHostname( ui->staticHostName->text() ); s->setScannerPath( ui->lineEditMusicPath->text() ); diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 34b3440bf..f9f93c32e 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -7,7 +7,7 @@ 0 0 621 - 353 + 434 @@ -22,8 +22,14 @@ + + + 0 + 0 + + - 3 + 0 @@ -66,7 +72,7 @@ - + 0 0 @@ -89,7 +95,7 @@ - + 0 0 @@ -103,9 +109,9 @@ - + - + 0 0 @@ -121,147 +127,171 @@ - - - 16 + + + true - - - - - 0 - 0 - - - - - 100 - 0 - - - - Jabber Server: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - jabberServer - - - - - - - - 0 - 0 - - - - - - - - Port: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 40 - 8 - - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - - 90 - 16777215 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1 - - - 65535 - - - 5222 - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Proxy Settings... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - + + + 0 + 0 + + + + Advanced Jabber Settings + + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + Server: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + jabberServer + + + + + + + + 0 + 0 + + + + + + + + Port: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 90 + 0 + + + + + 90 + 16777215 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 1 + + + 65535 + + + 5222 + + + + + + + + + + + + + 0 + 0 + + + + Advanced Network Settings + + + + + + + + Static Host Name: + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Proxy Settings... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + @@ -271,7 +301,7 @@ 20 - 73 + 40 @@ -611,71 +641,7 @@ - checkBoxJabberAdvanced - toggled(bool) - jabberServer - setVisible(bool) - - - 489 - 117 - - - 595 - 145 - - - - - checkBoxJabberAdvanced - toggled(bool) - labelJabberServer - setVisible(bool) - - - 492 - 117 - - - 123 - 145 - - - - - checkBoxJabberAdvanced - toggled(bool) - labelJabberPort - setVisible(bool) - - - 470 - 117 - - - 123 - 173 - - - - - checkBoxJabberAdvanced - toggled(bool) - jabberPort - setVisible(bool) - - - 441 - 112 - - - 594 - 172 - - - - - checkBoxJabberAdvanced + checkBoxAdvanced toggled(bool) proxyButton setVisible(bool) @@ -690,5 +656,37 @@ + + checkBoxAdvanced + toggled(bool) + groupBoxJabberAdvanced + setVisible(bool) + + + 310 + 115 + + + 310 + 174 + + + + + checkBoxAdvanced + toggled(bool) + groupBoxNetworkAdvanced + setVisible(bool) + + + 310 + 115 + + + 310 + 262 + + + From 1ef02210d66697223365e20f60d714491779cdd4 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 11 Feb 2011 19:22:29 -0500 Subject: [PATCH 05/62] Add our swanky new Twitter OAuth credentials --- thirdparty/qtweetlib/src/oauth.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thirdparty/qtweetlib/src/oauth.cpp b/thirdparty/qtweetlib/src/oauth.cpp index 28c4a91d9..3214bb8b1 100644 --- a/thirdparty/qtweetlib/src/oauth.cpp +++ b/thirdparty/qtweetlib/src/oauth.cpp @@ -25,11 +25,11 @@ #include "oauth.h" #ifndef CONSUMER_KEY - #define CONSUMER_KEY "" + #define CONSUMER_KEY "B92heFT38GQtmnVnAzAdg" #endif //CONSUMER_KEY #ifndef CONSUMER_SECRET - #define CONSUMER_SECRET "" + #define CONSUMER_SECRET "nDJpSsXXBIFFIB2XrkwBL48h0ztsBUZ939CX1sh1U" #endif //CONSUMER_SECRET /** From 31ce7a5a2de1c54c6da7539c9a6208fa46739b72 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 11 Feb 2011 22:39:19 -0500 Subject: [PATCH 06/62] Add beginnings of twitter sip plugin --- src/CMakeLists.txt | 1 + src/sip/twitter/CMakeLists.txt | 44 ++++++++++++++++++++++ src/sip/twitter/tomahawkoauthtwitter.cpp | 12 ++++++ src/sip/twitter/tomahawkoauthtwitter.h | 21 +++++++++++ src/sip/twitter/twitter.cpp | 29 +++++++++++++++ src/sip/twitter/twitter.h | 47 ++++++++++++++++++++++++ 6 files changed, 154 insertions(+) create mode 100644 src/sip/twitter/CMakeLists.txt create mode 100644 src/sip/twitter/tomahawkoauthtwitter.cpp create mode 100644 src/sip/twitter/tomahawkoauthtwitter.h create mode 100644 src/sip/twitter/twitter.cpp create mode 100644 src/sip/twitter/twitter.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d486966e0..bb90964cd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -132,6 +132,7 @@ IF( UNIX ) ENDIF( UNIX ) ADD_SUBDIRECTORY( sip/jabber ) +ADD_SUBDIRECTORY( sip/twitter ) ADD_SUBDIRECTORY( sip/zeroconf ) kde4_add_app_icon( tomahawkSources "${CMAKE_CURRENT_SOURCE_DIR}/../data/icons/tomahawk-icon-*.png" ) diff --git a/src/sip/twitter/CMakeLists.txt b/src/sip/twitter/CMakeLists.txt new file mode 100644 index 000000000..6fd91e9d6 --- /dev/null +++ b/src/sip/twitter/CMakeLists.txt @@ -0,0 +1,44 @@ +project( tomahawk ) + +include( ${QT_USE_FILE} ) +add_definitions( ${QT_DEFINITIONS} ) +add_definitions( -DQT_PLUGIN ) +add_definitions( -DQT_SHARED ) + +set( twitterSources + # twitter.cpp + tomahawkoauthtwitter.cpp +) + +set( twitterHeaders + # twitter.h + tomahawkoauthtwitter.h +) + +include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. + ${QT_INCLUDE_DIR} + ${CMAKE_SOURCE_DIR}/thirdparty/qtweetlib/src +) + +qt4_wrap_cpp( twitterMoc ${twitterHeaders} ) +add_library( sip_twitter SHARED ${twitterSources} ${twitterMoc} ) + +IF( WIN32 ) +SET( OS_SPECIFIC_LINK_LIBRARIES + ${OS_SPECIFIC_LINK_LIBRARIES} + "winmm.dll" + "iphlpapi.a" + "${CMAKE_CURRENT_SOURCE_DIR}/../../../build/src/libtomahawk/libtomahawklib.dll" +) +ENDIF( WIN32 ) + +target_link_libraries( sip_twitter + ${QT_LIBRARIES} + ${OS_SPECIFIC_LINK_LIBRARIES} +) + +IF( APPLE ) + SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" ) +ENDIF( APPLE ) + +install( TARGETS sip_twitter DESTINATION lib ) diff --git a/src/sip/twitter/tomahawkoauthtwitter.cpp b/src/sip/twitter/tomahawkoauthtwitter.cpp new file mode 100644 index 000000000..1031f0d2f --- /dev/null +++ b/src/sip/twitter/tomahawkoauthtwitter.cpp @@ -0,0 +1,12 @@ +#include "tomahawkoauthtwitter.h" +#include + +int TomahawkOAuthTwitter::authorizationWidget() +{ + bool ok; + int i = QInputDialog::getInt(0, QString( "Twitter PIN" ), QString( "After authenticating, enter the displayed PIN number here:" ), 0, 0, 2147483647, 1, &ok); + if (ok) + return i; + + return 0; +} diff --git a/src/sip/twitter/tomahawkoauthtwitter.h b/src/sip/twitter/tomahawkoauthtwitter.h new file mode 100644 index 000000000..b40e2b87d --- /dev/null +++ b/src/sip/twitter/tomahawkoauthtwitter.h @@ -0,0 +1,21 @@ +#ifndef TOMAHAWKOAUTHTWITTER +#define TOMAHAWKOAUTHTWITTER + +#include + +class TomahawkOAuthTwitter : public OAuthTwitter +{ + Q_OBJECT + +public: + TomahawkOAuthTwitter(QObject *parent = 0) + : OAuthTwitter( parent ) + {} + + ~TomahawkOAuthTwitter() {} + +protected: + virtual int authorizationWidget(); +}; + +#endif diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp new file mode 100644 index 000000000..702c7983b --- /dev/null +++ b/src/sip/twitter/twitter.cpp @@ -0,0 +1,29 @@ +#include "zeroconf.h" + +#include + + +bool +ZeroconfPlugin::connect( bool /*startup*/ ) +{ + delete m_zeroconf; + m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this ); + QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ), + SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) ); + + m_zeroconf->advertise(); + + return true; +} + + +void +ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ) +{ + qDebug() << "Found LAN host:" << host << port << nodeid; + + if ( !Servent::instance()->connectedToSession( nodeid ) ) + Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid ); +} + +Q_EXPORT_PLUGIN2( sip, ZeroconfPlugin ) diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h new file mode 100644 index 000000000..c347608ad --- /dev/null +++ b/src/sip/twitter/twitter.h @@ -0,0 +1,47 @@ +#ifndef ZEROCONF_H +#define ZEROCONF_H + +#include "sip/SipPlugin.h" +#include "tomahawkzeroconf.h" + +#include "../sipdllmacro.h" + +class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin +{ + Q_OBJECT + Q_INTERFACES( SipPlugin ) + +public: + ZeroconfPlugin() + : m_zeroconf( 0 ) + {} + + virtual ~ZeroconfPlugin() {} + +public slots: + virtual bool connect( bool startup ); + + void disconnect() + { + } + + void sendMsg( const QString& to, const QString& msg ) + { + } + + void broadcastMsg( const QString &msg ) + { + } + + void addContact( const QString &jid, const QString& msg = QString() ) + { + } + +private slots: + void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ); + +private: + TomahawkZeroconf* m_zeroconf; +}; + +#endif From c7b99d44a0df98609b0656a2387d2773fe844079 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 11 Feb 2011 23:01:08 -0500 Subject: [PATCH 07/62] More work on oauth implementation --- src/libtomahawk/tomahawksettings.cpp | 23 +++++++++++++++ src/libtomahawk/tomahawksettings.h | 7 +++++ src/sip/twitter/tomahawkoauthtwitter.cpp | 2 +- src/sip/twitter/twitter.cpp | 37 +++++++++++++++++------- src/sip/twitter/twitter.h | 12 ++++---- 5 files changed, 64 insertions(+), 17 deletions(-) diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index cc6f4278c..4d625932f 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -378,6 +378,29 @@ TomahawkSettings::setLastFmUsername( const QString& username ) setValue( "lastfm/username", username ); } +QString +TomahawkSettings::twitterOAuthToken() const +{ + return value( "twitter/oauthtoken" ).toString(); +} + +void +TomahawkSettings::setTwitterOAuthToken( const QString& oauthtoken ) +{ + setValue( "twitter/username", oauthtoken ); +} + +QString +TomahawkSettings::twitterOAuthTokenSecret() const +{ + return value( "twitter/oauthtokensecret" ).toString(); +} + +void +TomahawkSettings::setTwitterOAuthTokenSecret( const QString& oauthtokensecret ) +{ + setValue( "twitter/oauthtokensecret", oauthtokensecret ); +} bool TomahawkSettings::scrobblingEnabled() const diff --git a/src/libtomahawk/tomahawksettings.h b/src/libtomahawk/tomahawksettings.h index 3959ec6e9..7e92afe5c 100644 --- a/src/libtomahawk/tomahawksettings.h +++ b/src/libtomahawk/tomahawksettings.h @@ -95,6 +95,13 @@ public: QByteArray lastFmSessionKey() const; void setLastFmSessionKey( const QByteArray& key ); + + /// Twitter settings + QString twitterOAuthToken() const; + void setTwitterOAuthToken( const QString& oauthtoken ); + + QString twitterOAuthTokenSecret() const; + void setTwitterOAuthTokenSecret( const QString& oauthtokensecret ); /// XMPP Component Settings QString xmppBotServer() const; diff --git a/src/sip/twitter/tomahawkoauthtwitter.cpp b/src/sip/twitter/tomahawkoauthtwitter.cpp index 1031f0d2f..e35445b41 100644 --- a/src/sip/twitter/tomahawkoauthtwitter.cpp +++ b/src/sip/twitter/tomahawkoauthtwitter.cpp @@ -4,7 +4,7 @@ int TomahawkOAuthTwitter::authorizationWidget() { bool ok; - int i = QInputDialog::getInt(0, QString( "Twitter PIN" ), QString( "After authenticating, enter the displayed PIN number here:" ), 0, 0, 2147483647, 1, &ok); + int i = QInputDialog::getInt(0, QString( "Twitter PIN" ), QString( "After authenticating on Twitter's web site,\nenter the displayed PIN number here:" ), 0, 0, 2147483647, 1, &ok); if (ok) return i; diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 702c7983b..6a1898769 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -1,29 +1,46 @@ -#include "zeroconf.h" +#include "twitter.h" + +#include #include - bool -ZeroconfPlugin::connect( bool /*startup*/ ) +TwitterPlugin::connect( bool /*startup*/ ) { - delete m_zeroconf; - m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this ); + delete m_twitterAuth; + m_twitterAuth = new TomahawkOAuthTwitter( this ); + + TomahawkSettings *settings = TomahawkSettings::instance(); + QString oauthtoken = settings->twitterOAuthToken(); + QString oauthtokensecret = settings->twitterOAuthTokenSecret(); + + if ( oauthtoken.isEmpty() || oauthtokensecret.isEmpty() ) + { + qDebug() << "Empty Twitter credentials; not connecting"; + return false; + } + + m_twitterAuth->setOAuthToken( oauthtoken ); + m_twitterAuth->setOAuthTokenSecret( oauthtokensecret ); + + /* QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ), SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) ); - - m_zeroconf->advertise(); - + */ + return true; } void -ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ) +TwitterPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ) { + /* qDebug() << "Found LAN host:" << host << port << nodeid; if ( !Servent::instance()->connectedToSession( nodeid ) ) Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid ); + */ } -Q_EXPORT_PLUGIN2( sip, ZeroconfPlugin ) +Q_EXPORT_PLUGIN2( sip, TwitterPlugin ) diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index c347608ad..e44780647 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -2,21 +2,21 @@ #define ZEROCONF_H #include "sip/SipPlugin.h" -#include "tomahawkzeroconf.h" +#include "tomahawkoauthtwitter.h" #include "../sipdllmacro.h" -class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin +class SIPDLLEXPORT TwitterPlugin : public SipPlugin { Q_OBJECT Q_INTERFACES( SipPlugin ) public: - ZeroconfPlugin() - : m_zeroconf( 0 ) + TwitterPlugin() + : m_twitterAuth( 0 ) {} - virtual ~ZeroconfPlugin() {} + virtual ~TwitterPlugin() {} public slots: virtual bool connect( bool startup ); @@ -41,7 +41,7 @@ private slots: void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ); private: - TomahawkZeroconf* m_zeroconf; + TomahawkOAuthTwitter *m_twitterAuth; }; #endif From 2e57adb218d104e29c9282e15e283735ac61e0fe Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 00:17:25 -0500 Subject: [PATCH 08/62] Twitter authentication works --- src/CMakeLists.txt | 4 ++ src/libtomahawk/CMakeLists.txt | 1 + src/libtomahawk/tomahawksettings.cpp | 2 +- src/settingsdialog.cpp | 35 ++++++++++ src/settingsdialog.h | 2 + src/settingsdialog.ui | 81 ++++++++++++++++++++++++ src/sip/twitter/tomahawkoauthtwitter.cpp | 6 ++ src/sip/twitter/tomahawkoauthtwitter.h | 8 +-- src/sip/twitter/twitter.cpp | 2 +- src/sip/twitter/twitter.h | 2 +- 10 files changed, 136 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bb90964cd..80630f77b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,6 +28,7 @@ SET( TOMAHAWK_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../include/" ) SET( tomahawkSources ${tomahawkSources} sip/SipHandler.cpp + sip/twitter/tomahawkoauthtwitter.cpp infosystem/infosystem.cpp infosystem/infoplugins/echonestplugin.cpp @@ -62,6 +63,7 @@ SET( tomahawkHeaders ${tomahawkHeaders} "${TOMAHAWK_INC_DIR}/tomahawk/infosystem.h" sip/SipHandler.h + sip/twitter/tomahawkoauthtwitter.h infosystem/infoplugins/echonestplugin.h infosystem/infoplugins/musixmatchplugin.h @@ -113,6 +115,7 @@ INCLUDE_DIRECTORIES( ../alsa-playback ../rtaudio ../qxt/qxtweb-standalone/qxtweb + ../thirdparty/qtweetlib/src /usr/include/taglib /usr/local/include/taglib @@ -168,6 +171,7 @@ TARGET_LINK_LIBRARIES( tomahawk qjson tag + tomahawk_qtweetlib ) INCLUDE( "CPack.txt" ) diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index ec1bdefc4..b741fd1c4 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -366,6 +366,7 @@ target_link_libraries( tomahawklib ogg FLAC++ tomahawk_jdns + tomahawk_qtweetlib ${CLUCENE_LIBRARY} ) diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index 4d625932f..e961b4871 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -387,7 +387,7 @@ TomahawkSettings::twitterOAuthToken() const void TomahawkSettings::setTwitterOAuthToken( const QString& oauthtoken ) { - setValue( "twitter/username", oauthtoken ); + setValue( "twitter/oauthtoken", oauthtoken ); } QString diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 1e9bb042a..a6c3225ff 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -18,6 +18,7 @@ #include "musicscanner.h" #include "tomahawksettings.h" #include "sip/SipHandler.h" +#include "sip/twitter/tomahawkoauthtwitter.h" static QString @@ -62,6 +63,17 @@ SettingsDialog::SettingsDialog( QWidget *parent ) ui->groupBoxNetworkAdvanced->setVisible( false ); } + if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() ) + { + ui->twitterStatusLabel->setText("Status: No saved credentials"); + ui->twitterAuthenticateButton->setText( "Authenticate" ); + } + else + { + ui->twitterStatusLabel->setText("Status: Credentials saved"); + ui->twitterAuthenticateButton->setText( "Re-authenticate" ); + } + // MUSIC SCANNER ui->lineEditMusicPath->setText( s->scannerPath() ); @@ -273,6 +285,29 @@ SettingsDialog::onLastFmFinished() #endif } +void +SettingsDialog::authenticateTwitter() +{ + TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this ); + twitAuth->setNetworkAccessManager( TomahawkUtils::nam() ); + twitAuth->authorizePin(); + if ( !twitAuth->oauthToken().isEmpty() && !twitAuth->oauthTokenSecret().isEmpty() ) + { + TomahawkSettings* s = TomahawkSettings::instance(); + s->setTwitterOAuthToken( twitAuth->oauthToken() ); + s->setTwitterOAuthTokenSecret( twitAuth->oauthTokenSecret() ); + ui->twitterStatusLabel->setText("Status: Credentials saved"); + ui->twitterAuthenticateButton->setText( "Re-authenticate" ); + } + else + { + TomahawkSettings* s = TomahawkSettings::instance(); + s->setTwitterOAuthToken( QString() ); + s->setTwitterOAuthTokenSecret( QString() ); + ui->twitterStatusLabel->setText("Status: No saved credentials"); + ui->twitterAuthenticateButton->setText( "Authenticate" ); + } +} ProxyDialog::ProxyDialog( QWidget *parent ) : QDialog( parent ) diff --git a/src/settingsdialog.h b/src/settingsdialog.h index f02fcd5df..dc82f03be 100644 --- a/src/settingsdialog.h +++ b/src/settingsdialog.h @@ -50,6 +50,8 @@ private slots: void testLastFmLogin(); void onLastFmFinished(); + + void authenticateTwitter(); void addScriptResolver(); void scriptSelectionChanged(); diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index f9f93c32e..4009156eb 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -412,6 +412,71 @@ + + + Twitter + + + + + + + + + 0 + 0 + + + + Authenticating with Twitter allows you to discover and play music from your Twitter friends running Tomahawk. + +This feature works best when you have set a static host name in the "Jabber" settings tab under Advanced Settings, but may work even if you do not. Please note: this discovery uses Direct Messages and will only work when both Twitter users have followed each other. Tomahawk will attempt to "clean up" after itself to keep your Direct Message inbox tidy, but may miss some. + +When you press the button your web browser will launch and take you to Twitter.com to authenticate. You must copy and paste the PIN number into the dialog box that appears. + + + true + + + + + + + + + Status: No saved credentials + + + Qt::AutoText + + + + + + + Authenticate with Twitter + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + Last.fm @@ -688,5 +753,21 @@ + + twitterAuthenticateButton + pressed() + SettingsDialog + authenticateTwitter() + + + 459 + 205 + + + 310 + 216 + + + diff --git a/src/sip/twitter/tomahawkoauthtwitter.cpp b/src/sip/twitter/tomahawkoauthtwitter.cpp index e35445b41..580ba6daf 100644 --- a/src/sip/twitter/tomahawkoauthtwitter.cpp +++ b/src/sip/twitter/tomahawkoauthtwitter.cpp @@ -1,6 +1,12 @@ #include "tomahawkoauthtwitter.h" #include +TomahawkOAuthTwitter::TomahawkOAuthTwitter( QObject* parent ) + : OAuthTwitter( parent ) +{ +} + + int TomahawkOAuthTwitter::authorizationWidget() { bool ok; diff --git a/src/sip/twitter/tomahawkoauthtwitter.h b/src/sip/twitter/tomahawkoauthtwitter.h index b40e2b87d..bef823c36 100644 --- a/src/sip/twitter/tomahawkoauthtwitter.h +++ b/src/sip/twitter/tomahawkoauthtwitter.h @@ -3,14 +3,14 @@ #include -class TomahawkOAuthTwitter : public OAuthTwitter +#include "../sipdllmacro.h" + +class SIPDLLEXPORT TomahawkOAuthTwitter : public OAuthTwitter { Q_OBJECT public: - TomahawkOAuthTwitter(QObject *parent = 0) - : OAuthTwitter( parent ) - {} + TomahawkOAuthTwitter( QObject *parent = 0 ); ~TomahawkOAuthTwitter() {} diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 6a1898769..20dd60057 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -8,7 +8,7 @@ bool TwitterPlugin::connect( bool /*startup*/ ) { delete m_twitterAuth; - m_twitterAuth = new TomahawkOAuthTwitter( this ); + m_twitterAuth = new OAuthTwitter( this ); TomahawkSettings *settings = TomahawkSettings::instance(); QString oauthtoken = settings->twitterOAuthToken(); diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index e44780647..bede2e4e3 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -41,7 +41,7 @@ private slots: void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ); private: - TomahawkOAuthTwitter *m_twitterAuth; + OAuthTwitter *m_twitterAuth; }; #endif From 9a69fb34c324aa97c17d9dbbe9bb2682f812e87c Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 01:46:59 -0500 Subject: [PATCH 09/62] Tomahawk can now send a Got Tomahawk? tweet for you (also PoC of the authentication verification and status posting bits) --- src/libtomahawk/CMakeLists.txt | 1 + src/settingsdialog.cpp | 52 ++++++++++++++++++++++++++ src/settingsdialog.h | 6 +++ src/settingsdialog.ui | 47 ++++++++++++++++++++++- src/sip/twitter/tomahawkoauthtwitter.h | 2 +- 5 files changed, 106 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index b741fd1c4..d98199beb 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -302,6 +302,7 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. ../../thirdparty/jdns ../../thirdparty/jdns/jdns ../../thirdparty/jdns/jdnsshared + ../../thirdparty/qtweetlib/src playlist ) diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index a6c3225ff..22ca85469 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -19,6 +19,8 @@ #include "tomahawksettings.h" #include "sip/SipHandler.h" #include "sip/twitter/tomahawkoauthtwitter.h" +#include +#include static QString @@ -67,11 +69,13 @@ SettingsDialog::SettingsDialog( QWidget *parent ) { ui->twitterStatusLabel->setText("Status: No saved credentials"); ui->twitterAuthenticateButton->setText( "Authenticate" ); + ui->twitterInstructionsBox->setVisible( false ); } else { ui->twitterStatusLabel->setText("Status: Credentials saved"); ui->twitterAuthenticateButton->setText( "Re-authenticate" ); + ui->twitterInstructionsBox->setVisible( true ); } // MUSIC SCANNER @@ -298,6 +302,7 @@ SettingsDialog::authenticateTwitter() s->setTwitterOAuthTokenSecret( twitAuth->oauthTokenSecret() ); ui->twitterStatusLabel->setText("Status: Credentials saved"); ui->twitterAuthenticateButton->setText( "Re-authenticate" ); + ui->twitterInstructionsBox->setVisible( true ); } else { @@ -306,9 +311,56 @@ SettingsDialog::authenticateTwitter() s->setTwitterOAuthTokenSecret( QString() ); ui->twitterStatusLabel->setText("Status: No saved credentials"); ui->twitterAuthenticateButton->setText( "Authenticate" ); + ui->twitterInstructionsBox->setVisible( false ); } } +void +SettingsDialog::startPostGotTomahawkStatus() +{ + qDebug() << "Posting Got Tomahawk status"; + TomahawkSettings* s = TomahawkSettings::instance(); + if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() ) + { + QMessageBox::critical( 0, QString("Tweetin' Error"), QString("Your saved credentials could not be loaded.\nYou may wish to try re-authenticating.") ); + return; + } + TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this ); + twitAuth->setNetworkAccessManager( TomahawkUtils::nam() ); + twitAuth->setOAuthToken( s->twitterOAuthToken().toLatin1() ); + twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() ); + QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this ); + connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( postGotTomahawkStatusAuthVerifyReply(const QTweetUser &) ) ); + credVerifier->verify(); +} + +void +SettingsDialog::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user ) +{ + if ( user.id() == 0 ) + { + QMessageBox::critical( 0, QString("Tweetin' Error"), QString("Your saved credentials could not be verified.\nYou may wish to try re-authenticating.") ); + return; + } + TomahawkSettings* s = TomahawkSettings::instance(); + TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this ); + twitAuth->setNetworkAccessManager( TomahawkUtils::nam() ); + twitAuth->setOAuthToken( s->twitterOAuthToken().toLatin1() ); + twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() ); + QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( twitAuth, this ); + connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postGotTomahawkStatusUpdateReply(const QTweetStatus &) ) ); + statUpdate->post( QString( "Got Tomahawk?" ) ); +} + +void +SettingsDialog::postGotTomahawkStatusUpdateReply( const QTweetStatus& status ) +{ + if ( status.id() == 0 ) + QMessageBox::critical( 0, QString("Tweetin' Error"), QString("There was an error posting your status -- sorry!") ); + else + QMessageBox::information( 0, QString("Tweeted!"), QString("Your tweet has been posted!") ); +} + ProxyDialog::ProxyDialog( QWidget *parent ) : QDialog( parent ) , ui( new Ui::ProxyDialog ) diff --git a/src/settingsdialog.h b/src/settingsdialog.h index dc82f03be..1912ce730 100644 --- a/src/settingsdialog.h +++ b/src/settingsdialog.h @@ -3,6 +3,9 @@ #include +#include +#include + class QNetworkReply; namespace Ui @@ -52,6 +55,9 @@ private slots: void onLastFmFinished(); void authenticateTwitter(); + void startPostGotTomahawkStatus(); + void postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user ); + void postGotTomahawkStatusUpdateReply( const QTweetStatus &status ); void addScriptResolver(); void scriptSelectionChanged(); diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 4009156eb..30701062e 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -29,7 +29,7 @@ - 0 + 2 @@ -462,6 +462,35 @@ When you press the button your web browser will launch and take you to Twitter.c + + + + Instructions + + + + + + + + How it works is simple: just tweet "Got Tomahawk?" and be (very) patient. It can take a bit. + + + + + + + + + Press here if you'd like to have Tomahawk tweet this for you + + + + + + + + @@ -769,5 +798,21 @@ When you press the button your web browser will launch and take you to Twitter.c + + twitterTweetGotTomahawkButton + pressed() + SettingsDialog + startPostGotTomahawkStatus() + + + 310 + 313 + + + 310 + 216 + + + diff --git a/src/sip/twitter/tomahawkoauthtwitter.h b/src/sip/twitter/tomahawkoauthtwitter.h index bef823c36..5d56b889a 100644 --- a/src/sip/twitter/tomahawkoauthtwitter.h +++ b/src/sip/twitter/tomahawkoauthtwitter.h @@ -11,7 +11,7 @@ class SIPDLLEXPORT TomahawkOAuthTwitter : public OAuthTwitter public: TomahawkOAuthTwitter( QObject *parent = 0 ); - + ~TomahawkOAuthTwitter() {} protected: From 68d3f066e3a6c8ed9db24caea680d5fda91dd843 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 10:54:07 -0500 Subject: [PATCH 10/62] Enable twitter plugin, doesn't do much yet but does authenticate -- also change status post to include a short UUID so we don't get duplicate tweet errors. --- src/libtomahawk/sip/SipPlugin.h | 2 ++ src/settingsdialog.cpp | 3 +- src/settingsdialog.ui | 2 +- src/sip/jabber/jabber.h | 3 ++ src/sip/twitter/CMakeLists.txt | 5 ++-- src/sip/twitter/twitter.cpp | 51 ++++++++++++++++++++++++++------- src/sip/twitter/twitter.h | 13 ++++++--- src/sip/zeroconf/zeroconf.h | 2 ++ 8 files changed, 63 insertions(+), 18 deletions(-) diff --git a/src/libtomahawk/sip/SipPlugin.h b/src/libtomahawk/sip/SipPlugin.h index 6b4f5cb5c..52daa67eb 100644 --- a/src/libtomahawk/sip/SipPlugin.h +++ b/src/libtomahawk/sip/SipPlugin.h @@ -14,6 +14,8 @@ public: enum SipErrorCode { AuthError, ConnectionError }; // Placeholder for errors, to be defined virtual ~SipPlugin() {} + + virtual bool isValid() = 0; public slots: virtual bool connect( bool startup = false ) = 0; diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 22ca85469..9f0ae3560 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -349,7 +349,8 @@ SettingsDialog::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user ) twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() ); QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( twitAuth, this ); connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postGotTomahawkStatusUpdateReply(const QTweetStatus &) ) ); - statUpdate->post( QString( "Got Tomahawk?" ) ); + QString uuid = QUuid::createUuid(); + statUpdate->post( QString( "Got Tomahawk? (" ) + uuid.mid( 1, 8 ) + ")" ); } void diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 30701062e..c0c29c599 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -29,7 +29,7 @@ - 2 + 0 diff --git a/src/sip/jabber/jabber.h b/src/sip/jabber/jabber.h index 65ccaca3a..19cc5d1de 100644 --- a/src/sip/jabber/jabber.h +++ b/src/sip/jabber/jabber.h @@ -18,6 +18,9 @@ public: virtual ~JabberPlugin() { delete p; } + //FIXME: Make this more correct + virtual bool isValid() { return true; } + void setProxy( QNetworkProxy* proxy ); public slots: diff --git a/src/sip/twitter/CMakeLists.txt b/src/sip/twitter/CMakeLists.txt index 6fd91e9d6..7ca0f93c8 100644 --- a/src/sip/twitter/CMakeLists.txt +++ b/src/sip/twitter/CMakeLists.txt @@ -4,14 +4,15 @@ include( ${QT_USE_FILE} ) add_definitions( ${QT_DEFINITIONS} ) add_definitions( -DQT_PLUGIN ) add_definitions( -DQT_SHARED ) +add_definitions( -DSIPDLLEXPORT_PRO ) set( twitterSources - # twitter.cpp + twitter.cpp tomahawkoauthtwitter.cpp ) set( twitterHeaders - # twitter.h + twitter.h tomahawkoauthtwitter.h ) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 20dd60057..99d3d4e4b 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -2,27 +2,44 @@ #include +#include +#include + #include +#include + +TwitterPlugin::TwitterPlugin() + : m_twitterAuth( 0 ) + , m_isAuthed( false ) +{ +} + +bool +TwitterPlugin::isValid() +{ + return m_isAuthed; +} bool TwitterPlugin::connect( bool /*startup*/ ) -{ - delete m_twitterAuth; - m_twitterAuth = new OAuthTwitter( this ); - +{ TomahawkSettings *settings = TomahawkSettings::instance(); - QString oauthtoken = settings->twitterOAuthToken(); - QString oauthtokensecret = settings->twitterOAuthTokenSecret(); - if ( oauthtoken.isEmpty() || oauthtokensecret.isEmpty() ) + if ( settings->twitterOAuthToken().isEmpty() || settings->twitterOAuthTokenSecret().isEmpty() ) { qDebug() << "Empty Twitter credentials; not connecting"; return false; } + + delete m_twitterAuth; + m_twitterAuth = new TomahawkOAuthTwitter( this ); + m_twitterAuth->setNetworkAccessManager( TomahawkUtils::nam() ); + m_twitterAuth->setOAuthToken( settings->twitterOAuthToken().toLatin1() ); + m_twitterAuth->setOAuthTokenSecret( settings->twitterOAuthTokenSecret().toLatin1() ); - m_twitterAuth->setOAuthToken( oauthtoken ); - m_twitterAuth->setOAuthTokenSecret( oauthtokensecret ); - + QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth, this ); + QObject::connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) ); + credVerifier->verify(); /* QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ), SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) ); @@ -31,6 +48,20 @@ TwitterPlugin::connect( bool /*startup*/ ) return true; } +void +TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) +{ + if ( user.id() == 0 ) + { + qDebug() << "Could not authenticate to Twitter"; + m_isAuthed = false; + } + else + { + qDebug() << "Successfully authenticated to Twitter as user " << user.screenName(); + m_isAuthed = true; + } +} void TwitterPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ) diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index bede2e4e3..fd64c1e94 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -3,6 +3,8 @@ #include "sip/SipPlugin.h" #include "tomahawkoauthtwitter.h" +#include +#include #include "../sipdllmacro.h" @@ -12,11 +14,11 @@ class SIPDLLEXPORT TwitterPlugin : public SipPlugin Q_INTERFACES( SipPlugin ) public: - TwitterPlugin() - : m_twitterAuth( 0 ) - {} + TwitterPlugin(); virtual ~TwitterPlugin() {} + + virtual bool isValid(); public slots: virtual bool connect( bool startup ); @@ -39,9 +41,12 @@ public slots: private slots: void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ); + void connectAuthVerifyReply( const QTweetUser &user ); + void connectAuthVerifyError( QTweetNetBase::ErrorCode errorCode, const QString& errorMsg ); private: - OAuthTwitter *m_twitterAuth; + TomahawkOAuthTwitter *m_twitterAuth; + bool m_isAuthed; }; #endif diff --git a/src/sip/zeroconf/zeroconf.h b/src/sip/zeroconf/zeroconf.h index c347608ad..233160589 100644 --- a/src/sip/zeroconf/zeroconf.h +++ b/src/sip/zeroconf/zeroconf.h @@ -17,6 +17,8 @@ public: {} virtual ~ZeroconfPlugin() {} + + virtual bool isValid() { return true; } public slots: virtual bool connect( bool startup ); From 2bab8ea776a26c84168d43c1f973f41aab3d68f9 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 12:14:27 -0500 Subject: [PATCH 11/62] Work towards getting friends statuses --- src/libtomahawk/sip/SipPlugin.h | 5 +- src/libtomahawk/tomahawksettings.cpp | 24 +++++++ src/libtomahawk/tomahawksettings.h | 6 ++ src/settingsdialog.cpp | 18 ++--- src/sip/SipHandler.cpp | 25 ++++--- src/sip/SipHandler.h | 4 +- src/sip/jabber/jabber.cpp | 7 +- src/sip/jabber/jabber.h | 7 +- src/sip/twitter/twitter.cpp | 98 +++++++++++++++++++++++----- src/sip/twitter/twitter.h | 32 +++++---- src/sip/zeroconf/zeroconf.cpp | 7 +- src/sip/zeroconf/zeroconf.h | 7 +- src/tomahawkapp.cpp | 2 +- 13 files changed, 186 insertions(+), 56 deletions(-) diff --git a/src/libtomahawk/sip/SipPlugin.h b/src/libtomahawk/sip/SipPlugin.h index 52daa67eb..73c127311 100644 --- a/src/libtomahawk/sip/SipPlugin.h +++ b/src/libtomahawk/sip/SipPlugin.h @@ -16,10 +16,11 @@ public: virtual ~SipPlugin() {} virtual bool isValid() = 0; + virtual const QString name() = 0; public slots: - virtual bool connect( bool startup = false ) = 0; - virtual void disconnect() = 0; + virtual bool connectPlugin( bool startup = false ) = 0; + virtual void disconnectPlugin() = 0; virtual void addContact( const QString &jid, const QString& msg = QString() ) = 0; virtual void sendMsg( const QString& to, const QString& msg ) = 0; diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index e961b4871..2fea7e2ac 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -402,6 +402,30 @@ TomahawkSettings::setTwitterOAuthTokenSecret( const QString& oauthtokensecret ) setValue( "twitter/oauthtokensecret", oauthtokensecret ); } +qint64 +TomahawkSettings::twitterCachedFriendsSinceId() const +{ + return value( "twitter/cachedfriendssinceid", 0 ).toLongLong(); +} + +void +TomahawkSettings::setTwitterCachedFriendsSinceId( qint64 cachedId ) +{ + setValue( "twitter/cachedfriendssinceid", cachedId ); +} + +qint64 +TomahawkSettings::twitterCachedMentionsSinceId() const +{ + return value( "twitter/cachedmentionssinceid", 0 ).toLongLong(); +} + +void +TomahawkSettings::setTwitterCachedMentionsSinceId( qint64 cachedId ) +{ + setValue( "twitter/cachedmentionssinceid", cachedId ); +} + bool TomahawkSettings::scrobblingEnabled() const { diff --git a/src/libtomahawk/tomahawksettings.h b/src/libtomahawk/tomahawksettings.h index 7e92afe5c..3dc1f5d52 100644 --- a/src/libtomahawk/tomahawksettings.h +++ b/src/libtomahawk/tomahawksettings.h @@ -103,6 +103,12 @@ public: QString twitterOAuthTokenSecret() const; void setTwitterOAuthTokenSecret( const QString& oauthtokensecret ); + qint64 twitterCachedFriendsSinceId() const; + void setTwitterCachedFriendsSinceId( qint64 sinceid ); + + qint64 twitterCachedMentionsSinceId() const; + void setTwitterCachedMentionsSinceId( qint64 sinceid ); + /// XMPP Component Settings QString xmppBotServer() const; void setXmppBotServer( const QString &server ); diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 9f0ae3560..2991be622 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -1,7 +1,3 @@ -#include "settingsdialog.h" -#include "ui_settingsdialog.h" -#include "ui_proxydialog.h" - #include #include #include @@ -14,14 +10,17 @@ #include #endif +#include +#include + +#include "settingsdialog.h" +#include "ui_settingsdialog.h" +#include "ui_proxydialog.h" #include "tomahawk/tomahawkapp.h" #include "musicscanner.h" #include "tomahawksettings.h" #include "sip/SipHandler.h" #include "sip/twitter/tomahawkoauthtwitter.h" -#include -#include - static QString md5( const QByteArray& src ) @@ -156,8 +155,8 @@ SettingsDialog::~SettingsDialog() if( rejabber ) { - APP->sipHandler()->disconnect(); - APP->sipHandler()->connect(); + APP->sipHandler()->disconnectPlugins(); + APP->sipHandler()->connectPlugins(); } } else @@ -303,6 +302,7 @@ SettingsDialog::authenticateTwitter() ui->twitterStatusLabel->setText("Status: Credentials saved"); ui->twitterAuthenticateButton->setText( "Re-authenticate" ); ui->twitterInstructionsBox->setVisible( true ); + TomahawkApp::instance()->sipHandler()->connectPlugins( false, "SIPTWITTER" ); } else { diff --git a/src/sip/SipHandler.cpp b/src/sip/SipHandler.cpp index 9e72cb2e6..51b118bc2 100644 --- a/src/sip/SipHandler.cpp +++ b/src/sip/SipHandler.cpp @@ -114,30 +114,39 @@ SipHandler::loadPlugin( QObject* plugin ) void -SipHandler::connect( bool startup ) +SipHandler::connectPlugins( bool startup, const QString &pluginName ) { foreach( SipPlugin* sip, m_plugins ) - sip->connect( startup ); + { + if ( pluginName.isEmpty() || ( !pluginName.isEmpty() && sip->name() == pluginName ) ) + sip->connectPlugin( startup ); + } m_connected = true; } void -SipHandler::disconnect() +SipHandler::disconnectPlugins( const QString &pluginName ) { foreach( SipPlugin* sip, m_plugins ) - sip->disconnect(); - SourceList::instance()->removeAllRemote(); - m_connected = false; + { + if ( pluginName.isEmpty() || ( !pluginName.isEmpty() && sip->name() == pluginName ) ) + sip->disconnectPlugin(); + } + if( pluginName.isEmpty() ) + { + SourceList::instance()->removeAllRemote(); + m_connected = false; + } } void SipHandler::toggleConnect() { if( m_connected ) - disconnect(); + disconnectPlugins(); else - connect(); + connectPlugins(); } diff --git a/src/sip/SipHandler.h b/src/sip/SipHandler.h index 1ae2b6592..775fc653b 100644 --- a/src/sip/SipHandler.h +++ b/src/sip/SipHandler.h @@ -19,8 +19,8 @@ public: public slots: void addContact( const QString& id ) { qDebug() << Q_FUNC_INFO << id; } - void connect( bool startup = false ); - void disconnect(); + void connectPlugins( bool startup = false, const QString &pluginName = QString() ); + void disconnectPlugins( const QString &pluginName = QString() ); void toggleConnect(); signals: diff --git a/src/sip/jabber/jabber.cpp b/src/sip/jabber/jabber.cpp index 112caf64d..1df70718c 100644 --- a/src/sip/jabber/jabber.cpp +++ b/src/sip/jabber/jabber.cpp @@ -12,9 +12,14 @@ JabberPlugin::setProxy( QNetworkProxy* proxy ) p->setProxy( proxy ); } +const QString +JabberPlugin::name() +{ + return QString( MYNAME ); +} bool -JabberPlugin::connect( bool startup ) +JabberPlugin::connectPlugin( bool startup ) { qDebug() << "JabberPlugin::connect"; if ( startup && !TomahawkSettings::instance()->jabberAutoConnect() ) diff --git a/src/sip/jabber/jabber.h b/src/sip/jabber/jabber.h index 19cc5d1de..c2a80ce61 100644 --- a/src/sip/jabber/jabber.h +++ b/src/sip/jabber/jabber.h @@ -6,6 +6,8 @@ #include "../sipdllmacro.h" +#define MYNAME "SIPJABBER" + class SIPDLLEXPORT JabberPlugin : public SipPlugin { Q_OBJECT @@ -20,13 +22,14 @@ public: //FIXME: Make this more correct virtual bool isValid() { return true; } + virtual const QString name(); void setProxy( QNetworkProxy* proxy ); public slots: - virtual bool connect( bool startup ); + virtual bool connectPlugin( bool startup ); - void disconnect() + void disconnectPlugin() { QMetaObject::invokeMethod( p, "disconnect", diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 99d3d4e4b..4b8fe687d 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -1,28 +1,46 @@ #include "twitter.h" -#include +#include +#include #include #include +#include +#include -#include #include +#include + TwitterPlugin::TwitterPlugin() - : m_twitterAuth( 0 ) - , m_isAuthed( false ) + : SipPlugin() + , m_isValid( false ) + , m_checkTimer( this ) { + m_checkTimer.setInterval( 60000 ); + m_checkTimer.setSingleShot( false ); + QObject::connect( &m_checkTimer, SIGNAL( timeout() ), SLOT( checkTimerFired() ) ); + m_checkTimer.start(); } bool TwitterPlugin::isValid() { - return m_isAuthed; + return m_isValid; +} + +const QString +TwitterPlugin::name() +{ + qDebug() << "TwitterPlugin returning plugin name " << QString( MYNAME ); + return QString( MYNAME ); } bool -TwitterPlugin::connect( bool /*startup*/ ) -{ +TwitterPlugin::connectPlugin( bool /*startup*/ ) +{ + qDebug() << "TwitterPlugin connectPlugin called"; + TomahawkSettings *settings = TomahawkSettings::instance(); if ( settings->twitterOAuthToken().isEmpty() || settings->twitterOAuthTokenSecret().isEmpty() ) @@ -31,13 +49,13 @@ TwitterPlugin::connect( bool /*startup*/ ) return false; } - delete m_twitterAuth; - m_twitterAuth = new TomahawkOAuthTwitter( this ); - m_twitterAuth->setNetworkAccessManager( TomahawkUtils::nam() ); - m_twitterAuth->setOAuthToken( settings->twitterOAuthToken().toLatin1() ); - m_twitterAuth->setOAuthTokenSecret( settings->twitterOAuthTokenSecret().toLatin1() ); + delete m_twitterAuth.data(); + m_twitterAuth = QWeakPointer( new TomahawkOAuthTwitter( this ) ); + m_twitterAuth.data()->setNetworkAccessManager( TomahawkUtils::nam() ); + m_twitterAuth.data()->setOAuthToken( settings->twitterOAuthToken().toLatin1() ); + m_twitterAuth.data()->setOAuthTokenSecret( settings->twitterOAuthTokenSecret().toLatin1() ); - QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth, this ); + QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this ); QObject::connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) ); credVerifier->verify(); /* @@ -48,18 +66,66 @@ TwitterPlugin::connect( bool /*startup*/ ) return true; } +void +TwitterPlugin::disconnectPlugin() +{ + if( !m_friendsTimeline.isNull() ) + m_friendsTimeline.data()->deleteLater(); + if( !m_twitterAuth.isNull() ) + m_twitterAuth.data()->deleteLater(); +} + void TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) { if ( user.id() == 0 ) { qDebug() << "Could not authenticate to Twitter"; - m_isAuthed = false; + m_isValid = false; } else { - qDebug() << "Successfully authenticated to Twitter as user " << user.screenName(); - m_isAuthed = true; + qDebug() << "TwitterPlugin successfully authenticated to Twitter as user " << user.screenName(); + m_isValid = true; + if ( !m_twitterAuth.isNull() ) + { + m_friendsTimeline = QWeakPointer( new QTweetFriendsTimeline( m_twitterAuth.data(), this ) ); + QObject::connect( m_friendsTimeline.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( friendsTimelineStatuses(const QList &) ) ); + QMetaObject::invokeMethod( this, "checkTimerFired", Qt::DirectConnection ); + } + else + { + qDebug() << "Twitter auth pointer was null!"; + m_isValid = false; + } + } +} + +void +TwitterPlugin::checkTimerFired() +{ + if ( isValid() ) + { + qint64 cachedfriendssinceid = TomahawkSettings::instance()->twitterCachedFriendsSinceId(); + if ( !m_friendsTimeline.isNull() ) + m_friendsTimeline.data()->fetch( cachedfriendssinceid, 0, 800 ); + } +} + +void +TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus >& statuses ) +{ + QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); + foreach( QTweetStatus status, statuses ) + { + QString statusText = status.text(); + qDebug() << "Performing matching on status text " << statusText; + if ( regex.exactMatch( statusText ) ) + { + qDebug() << "Found an exact matching Tweet from user " << status.user().screenName(); + } + else + qDebug() << "No match, matched length is " << regex.matchedLength(); } } diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index fd64c1e94..96d7a855d 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -1,31 +1,36 @@ -#ifndef ZEROCONF_H -#define ZEROCONF_H +#ifndef TWITTER_H +#define TWITTER_H + +#include +#include -#include "sip/SipPlugin.h" -#include "tomahawkoauthtwitter.h" #include #include +#include #include "../sipdllmacro.h" +#include "sip/SipPlugin.h" +#include "tomahawkoauthtwitter.h" + +#define MYNAME "SIPTWITTER" class SIPDLLEXPORT TwitterPlugin : public SipPlugin { Q_OBJECT Q_INTERFACES( SipPlugin ) - + public: TwitterPlugin(); virtual ~TwitterPlugin() {} virtual bool isValid(); + virtual const QString name(); public slots: - virtual bool connect( bool startup ); + virtual bool connectPlugin( bool startup ); - void disconnect() - { - } + void disconnectPlugin(); void sendMsg( const QString& to, const QString& msg ) { @@ -42,11 +47,14 @@ public slots: private slots: void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ); void connectAuthVerifyReply( const QTweetUser &user ); - void connectAuthVerifyError( QTweetNetBase::ErrorCode errorCode, const QString& errorMsg ); + void checkTimerFired(); + void friendsTimelineStatuses( const QList< QTweetStatus > &statuses ); private: - TomahawkOAuthTwitter *m_twitterAuth; - bool m_isAuthed; + QWeakPointer m_twitterAuth; + bool m_isValid; + QTimer m_checkTimer; + QWeakPointer m_friendsTimeline; }; #endif diff --git a/src/sip/zeroconf/zeroconf.cpp b/src/sip/zeroconf/zeroconf.cpp index 702c7983b..c4b692214 100644 --- a/src/sip/zeroconf/zeroconf.cpp +++ b/src/sip/zeroconf/zeroconf.cpp @@ -2,9 +2,14 @@ #include +const QString +ZeroconfPlugin::name() +{ + return QString( MYNAME ); +} bool -ZeroconfPlugin::connect( bool /*startup*/ ) +ZeroconfPlugin::connectPlugin( bool /*startup*/ ) { delete m_zeroconf; m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this ); diff --git a/src/sip/zeroconf/zeroconf.h b/src/sip/zeroconf/zeroconf.h index 233160589..164a1c545 100644 --- a/src/sip/zeroconf/zeroconf.h +++ b/src/sip/zeroconf/zeroconf.h @@ -6,6 +6,8 @@ #include "../sipdllmacro.h" +#define MYNAME "SIPZEROCONF" + class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin { Q_OBJECT @@ -19,11 +21,12 @@ public: virtual ~ZeroconfPlugin() {} virtual bool isValid() { return true; } + virtual const QString name(); public slots: - virtual bool connect( bool startup ); + virtual bool connectPlugin( bool startup ); - void disconnect() + void disconnectPlugin() { } diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index f6b01fa19..99d7ea296 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -422,7 +422,7 @@ TomahawkApp::setupSIP() { m_xmppBot = new XMPPBot( this ); qDebug() << "Connecting SIP classes"; - m_sipHandler->connect( true ); + m_sipHandler->connectPlugins( true ); // m_sipHandler->setProxy( *TomahawkUtils::proxy() ); } } From 6e02fda609ef1e97f891604e267daa2f9bf32cbb Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 12:57:29 -0500 Subject: [PATCH 12/62] Successfully parse friend and mentions timelines --- src/settingsdialog.cpp | 2 ++ src/sip/twitter/twitter.cpp | 43 +++++++++++++++++++++++++++++++------ src/sip/twitter/twitter.h | 7 +++++- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 2991be622..8b7ebc466 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -302,6 +302,8 @@ SettingsDialog::authenticateTwitter() ui->twitterStatusLabel->setText("Status: Credentials saved"); ui->twitterAuthenticateButton->setText( "Re-authenticate" ); ui->twitterInstructionsBox->setVisible( true ); + TomahawkSettings::instance()->setTwitterCachedFriendsSinceId( 0 ); + TomahawkSettings::instance()->setTwitterCachedMentionsSinceId( 0 ); TomahawkApp::instance()->sipHandler()->connectPlugins( false, "SIPTWITTER" ); } else diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 4b8fe687d..60311d0d8 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -16,6 +16,8 @@ TwitterPlugin::TwitterPlugin() : SipPlugin() , m_isValid( false ) , m_checkTimer( this ) + , m_cachedFriendsSinceId( 0 ) + , m_cachedMentionsSinceId( 0 ) { m_checkTimer.setInterval( 60000 ); m_checkTimer.setSingleShot( false ); @@ -90,7 +92,9 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) if ( !m_twitterAuth.isNull() ) { m_friendsTimeline = QWeakPointer( new QTweetFriendsTimeline( m_twitterAuth.data(), this ) ); + m_mentions = QWeakPointer( new QTweetMentions( m_twitterAuth.data(), this ) ); QObject::connect( m_friendsTimeline.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( friendsTimelineStatuses(const QList &) ) ); + QObject::connect( m_mentions.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( mentionsStatuses(const QList &) ) ); QMetaObject::invokeMethod( this, "checkTimerFired", Qt::DirectConnection ); } else @@ -106,27 +110,54 @@ TwitterPlugin::checkTimerFired() { if ( isValid() ) { - qint64 cachedfriendssinceid = TomahawkSettings::instance()->twitterCachedFriendsSinceId(); + if ( m_cachedFriendsSinceId == 0 ) + m_cachedFriendsSinceId = TomahawkSettings::instance()->twitterCachedFriendsSinceId(); if ( !m_friendsTimeline.isNull() ) - m_friendsTimeline.data()->fetch( cachedfriendssinceid, 0, 800 ); + m_friendsTimeline.data()->fetch( m_cachedFriendsSinceId, 0, 800 ); + + if ( m_cachedMentionsSinceId == 0 ) + m_cachedMentionsSinceId = TomahawkSettings::instance()->twitterCachedMentionsSinceId(); + if ( !m_mentions.isNull() ) + m_mentions.data()->fetch( m_cachedMentionsSinceId, 0, 800 ); } } void TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus >& statuses ) { + qDebug() << "TwitterPlugin checking friends"; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); foreach( QTweetStatus status, statuses ) { + if ( status.id() > m_cachedFriendsSinceId ) + m_cachedFriendsSinceId = status.id(); QString statusText = status.text(); - qDebug() << "Performing matching on status text " << statusText; if ( regex.exactMatch( statusText ) ) { - qDebug() << "Found an exact matching Tweet from user " << status.user().screenName(); + qDebug() << "TwitterPlugin found an exact tweet from friend " << status.user().screenName(); } - else - qDebug() << "No match, matched length is " << regex.matchedLength(); } + + TomahawkSettings::instance()->setTwitterCachedFriendsSinceId( m_cachedFriendsSinceId ); +} + +void +TwitterPlugin::mentionsStatuses( const QList< QTweetStatus >& statuses ) +{ + qDebug() << "TwitterPlugin checking mentions"; + QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); + foreach( QTweetStatus status, statuses ) + { + if ( status.id() > m_cachedMentionsSinceId ) + m_cachedMentionsSinceId = status.id(); + QString statusText = status.text(); + if ( regex.exactMatch( statusText ) ) + { + qDebug() << "TwitterPlugin found an exact matching mention from user " << status.user().screenName(); + } + } + + TomahawkSettings::instance()->setTwitterCachedMentionsSinceId( m_cachedMentionsSinceId ); } void diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index 96d7a855d..89d56f2cc 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "../sipdllmacro.h" #include "sip/SipPlugin.h" @@ -49,12 +50,16 @@ private slots: void connectAuthVerifyReply( const QTweetUser &user ); void checkTimerFired(); void friendsTimelineStatuses( const QList< QTweetStatus > &statuses ); + void mentionsStatuses( const QList< QTweetStatus > &statuses ); private: QWeakPointer m_twitterAuth; + QWeakPointer m_friendsTimeline; + QWeakPointer m_mentions; bool m_isValid; QTimer m_checkTimer; - QWeakPointer m_friendsTimeline; + qint64 m_cachedFriendsSinceId; + qint64 m_cachedMentionsSinceId; }; #endif From 1744f3659e410d04c8abc0f473ca8ebb952d9f94 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 13:10:50 -0500 Subject: [PATCH 13/62] I've seen some wonky behavior coming from the settings module, so add a mutex for safety --- src/libtomahawk/tomahawksettings.cpp | 69 ++++++++++++++++++++++++++++ src/libtomahawk/tomahawksettings.h | 1 + 2 files changed, 70 insertions(+) diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index 2fea7e2ac..c707237ab 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -20,9 +20,12 @@ TomahawkSettings::instance() TomahawkSettings::TomahawkSettings( QObject* parent ) : QSettings( parent ) + , m_safety() { s_instance = this; + m_safety = new QMutex(); + QMutexLocker locker( m_safety ); #ifndef TOMAHAWK_HEADLESS if( !contains( "configversion") ) { @@ -50,6 +53,7 @@ TomahawkSettings::~TomahawkSettings() QString TomahawkSettings::scannerPath() const { + QMutexLocker locker( m_safety ); #ifndef TOMAHAWK_HEADLESS return value( "scannerpath", QDesktopServices::storageLocation( QDesktopServices::MusicLocation ) ).toString(); #else @@ -61,6 +65,7 @@ TomahawkSettings::scannerPath() const void TomahawkSettings::setScannerPath( const QString& path ) { + QMutexLocker locker( m_safety ); setValue( "scannerpath", path ); } @@ -68,6 +73,7 @@ TomahawkSettings::setScannerPath( const QString& path ) bool TomahawkSettings::hasScannerPath() const { + QMutexLocker locker( m_safety ); return contains( "scannerpath" ); } @@ -75,6 +81,7 @@ TomahawkSettings::hasScannerPath() const bool TomahawkSettings::httpEnabled() const { + QMutexLocker locker( m_safety ); return value( "network/http", true ).toBool(); } @@ -82,6 +89,7 @@ TomahawkSettings::httpEnabled() const void TomahawkSettings::setHttpEnabled( bool enable ) { + QMutexLocker locker( m_safety ); setValue( "network/http", enable ); } @@ -89,6 +97,7 @@ TomahawkSettings::setHttpEnabled( bool enable ) QString TomahawkSettings::proxyHost() const { + QMutexLocker locker( m_safety ); return value( "network/proxy/host", QString() ).toString(); } @@ -96,6 +105,7 @@ TomahawkSettings::proxyHost() const void TomahawkSettings::setProxyHost( const QString& host ) { + QMutexLocker locker( m_safety ); setValue( "network/proxy/host", host ); } @@ -103,6 +113,7 @@ TomahawkSettings::setProxyHost( const QString& host ) qulonglong TomahawkSettings::proxyPort() const { + QMutexLocker locker( m_safety ); return value( "network/proxy/port", 1080 ).toULongLong(); } @@ -110,6 +121,7 @@ TomahawkSettings::proxyPort() const void TomahawkSettings::setProxyPort( const qulonglong port ) { + QMutexLocker locker( m_safety ); setValue( "network/proxy/port", port ); } @@ -117,6 +129,7 @@ TomahawkSettings::setProxyPort( const qulonglong port ) QString TomahawkSettings::proxyUsername() const { + QMutexLocker locker( m_safety ); return value( "network/proxy/username", QString() ).toString(); } @@ -124,6 +137,7 @@ TomahawkSettings::proxyUsername() const void TomahawkSettings::setProxyUsername( const QString& username ) { + QMutexLocker locker( m_safety ); setValue( "network/proxy/username", username ); } @@ -131,6 +145,7 @@ TomahawkSettings::setProxyUsername( const QString& username ) QString TomahawkSettings::proxyPassword() const { + QMutexLocker locker( m_safety ); return value( "network/proxy/password", QString() ).toString(); } @@ -138,6 +153,7 @@ TomahawkSettings::proxyPassword() const void TomahawkSettings::setProxyPassword( const QString& password ) { + QMutexLocker locker( m_safety ); setValue( "network/proxy/password", password ); } @@ -145,6 +161,7 @@ TomahawkSettings::setProxyPassword( const QString& password ) int TomahawkSettings::proxyType() const { + QMutexLocker locker( m_safety ); return value( "network/proxy/type", 0 ).toInt(); } @@ -152,6 +169,7 @@ TomahawkSettings::proxyType() const void TomahawkSettings::setProxyType( const int type ) { + QMutexLocker locker( m_safety ); setValue( "network/proxy/type", type ); } @@ -159,6 +177,7 @@ TomahawkSettings::setProxyType( const int type ) QByteArray TomahawkSettings::mainWindowGeometry() const { + QMutexLocker locker( m_safety ); return value( "ui/mainwindow/geometry" ).toByteArray(); } @@ -166,6 +185,7 @@ TomahawkSettings::mainWindowGeometry() const void TomahawkSettings::setMainWindowGeometry( const QByteArray& geom ) { + QMutexLocker locker( m_safety ); setValue( "ui/mainwindow/geometry", geom ); } @@ -173,6 +193,7 @@ TomahawkSettings::setMainWindowGeometry( const QByteArray& geom ) QByteArray TomahawkSettings::mainWindowState() const { + QMutexLocker locker( m_safety ); return value( "ui/mainwindow/state" ).toByteArray(); } @@ -180,6 +201,7 @@ TomahawkSettings::mainWindowState() const void TomahawkSettings::setMainWindowState( const QByteArray& state ) { + QMutexLocker locker( m_safety ); setValue( "ui/mainwindow/state", state ); } @@ -187,6 +209,7 @@ TomahawkSettings::setMainWindowState( const QByteArray& state ) QList TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const { + QMutexLocker locker( m_safety ); return value( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ) ).toList(); } @@ -194,6 +217,7 @@ TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const void TomahawkSettings::setPlaylistColumnSizes( const QString& playlistid, const QList& cols ) { + QMutexLocker locker( m_safety ); setValue( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ), cols ); } @@ -201,6 +225,7 @@ TomahawkSettings::setPlaylistColumnSizes( const QString& playlistid, const QList QList TomahawkSettings::recentlyPlayedPlaylists() const { + QMutexLocker locker( m_safety ); QStringList playlist_guids = value( "playlists/recentlyPlayed" ).toStringList(); QList playlists; @@ -218,6 +243,7 @@ TomahawkSettings::recentlyPlayedPlaylists() const void TomahawkSettings::appendRecentlyPlayedPlaylist( const Tomahawk::playlist_ptr& playlist ) { + QMutexLocker locker( m_safety ); QStringList playlist_guids = value( "playlists/recentlyPlayed" ).toStringList(); playlist_guids.removeAll( playlist->guid() ); @@ -230,6 +256,7 @@ TomahawkSettings::appendRecentlyPlayedPlaylist( const Tomahawk::playlist_ptr& pl bool TomahawkSettings::jabberAutoConnect() const { + QMutexLocker locker( m_safety ); return value( "jabber/autoconnect", true ).toBool(); } @@ -237,6 +264,7 @@ TomahawkSettings::jabberAutoConnect() const void TomahawkSettings::setJabberAutoConnect( bool autoconnect ) { + QMutexLocker locker( m_safety ); setValue( "jabber/autoconnect", autoconnect ); } @@ -244,6 +272,7 @@ TomahawkSettings::setJabberAutoConnect( bool autoconnect ) unsigned int TomahawkSettings::jabberPort() const { + QMutexLocker locker( m_safety ); return value( "jabber/port", 5222 ).toUInt(); } @@ -251,6 +280,7 @@ TomahawkSettings::jabberPort() const void TomahawkSettings::setJabberPort( int port ) { + QMutexLocker locker( m_safety ); if ( port < 0 ) return; setValue( "jabber/port", port ); @@ -260,6 +290,7 @@ TomahawkSettings::setJabberPort( int port ) QString TomahawkSettings::jabberServer() const { + QMutexLocker locker( m_safety ); return value( "jabber/server" ).toString(); } @@ -267,6 +298,7 @@ TomahawkSettings::jabberServer() const void TomahawkSettings::setJabberServer( const QString& server ) { + QMutexLocker locker( m_safety ); setValue( "jabber/server", server ); } @@ -274,6 +306,7 @@ TomahawkSettings::setJabberServer( const QString& server ) QString TomahawkSettings::jabberUsername() const { + QMutexLocker locker( m_safety ); return value( "jabber/username" ).toString(); } @@ -281,6 +314,7 @@ TomahawkSettings::jabberUsername() const void TomahawkSettings::setJabberUsername( const QString& username ) { + QMutexLocker locker( m_safety ); setValue( "jabber/username", username ); } @@ -288,6 +322,7 @@ TomahawkSettings::setJabberUsername( const QString& username ) QString TomahawkSettings::jabberPassword() const { + QMutexLocker locker( m_safety ); return value( "jabber/password" ).toString(); } @@ -295,6 +330,7 @@ TomahawkSettings::jabberPassword() const void TomahawkSettings::setJabberPassword( const QString& pw ) { + QMutexLocker locker( m_safety ); setValue( "jabber/password", pw ); } @@ -302,6 +338,7 @@ TomahawkSettings::setJabberPassword( const QString& pw ) TomahawkSettings::ExternalAddressMode TomahawkSettings::externalAddressMode() const { + QMutexLocker locker( m_safety ); return (TomahawkSettings::ExternalAddressMode) value( "network/external-address-mode", TomahawkSettings::Upnp ).toInt(); } @@ -309,30 +346,35 @@ TomahawkSettings::externalAddressMode() const void TomahawkSettings::setExternalAddressMode( ExternalAddressMode externalAddressMode ) { + QMutexLocker locker( m_safety ); setValue( "network/external-address-mode", externalAddressMode ); } QString TomahawkSettings::externalHostname() const { + QMutexLocker locker( m_safety ); return value( "network/external-hostname" ).toString(); } void TomahawkSettings::setExternalHostname(const QString& externalHostname) { + QMutexLocker locker( m_safety ); setValue( "network/external-hostname", externalHostname ); } int TomahawkSettings::externalPort() const { + QMutexLocker locker( m_safety ); return value( "network/external-port" ).toInt(); } void TomahawkSettings::setExternalPort(int externalPort) { + QMutexLocker locker( m_safety ); setValue( "network/external-port", externalPort); } @@ -340,6 +382,7 @@ TomahawkSettings::setExternalPort(int externalPort) QString TomahawkSettings::lastFmPassword() const { + QMutexLocker locker( m_safety ); return value( "lastfm/password" ).toString(); } @@ -347,6 +390,7 @@ TomahawkSettings::lastFmPassword() const void TomahawkSettings::setLastFmPassword( const QString& password ) { + QMutexLocker locker( m_safety ); setValue( "lastfm/password", password ); } @@ -354,6 +398,7 @@ TomahawkSettings::setLastFmPassword( const QString& password ) QByteArray TomahawkSettings::lastFmSessionKey() const { + QMutexLocker locker( m_safety ); return value( "lastfm/session" ).toByteArray(); } @@ -361,6 +406,7 @@ TomahawkSettings::lastFmSessionKey() const void TomahawkSettings::setLastFmSessionKey( const QByteArray& key ) { + QMutexLocker locker( m_safety ); setValue( "lastfm/session", key ); } @@ -368,6 +414,7 @@ TomahawkSettings::setLastFmSessionKey( const QByteArray& key ) QString TomahawkSettings::lastFmUsername() const { + QMutexLocker locker( m_safety ); return value( "lastfm/username" ).toString(); } @@ -375,60 +422,70 @@ TomahawkSettings::lastFmUsername() const void TomahawkSettings::setLastFmUsername( const QString& username ) { + QMutexLocker locker( m_safety ); setValue( "lastfm/username", username ); } QString TomahawkSettings::twitterOAuthToken() const { + QMutexLocker locker( m_safety ); return value( "twitter/oauthtoken" ).toString(); } void TomahawkSettings::setTwitterOAuthToken( const QString& oauthtoken ) { + QMutexLocker locker( m_safety ); setValue( "twitter/oauthtoken", oauthtoken ); } QString TomahawkSettings::twitterOAuthTokenSecret() const { + QMutexLocker locker( m_safety ); return value( "twitter/oauthtokensecret" ).toString(); } void TomahawkSettings::setTwitterOAuthTokenSecret( const QString& oauthtokensecret ) { + QMutexLocker locker( m_safety ); setValue( "twitter/oauthtokensecret", oauthtokensecret ); } qint64 TomahawkSettings::twitterCachedFriendsSinceId() const { + QMutexLocker locker( m_safety ); return value( "twitter/cachedfriendssinceid", 0 ).toLongLong(); } void TomahawkSettings::setTwitterCachedFriendsSinceId( qint64 cachedId ) { + QMutexLocker locker( m_safety ); setValue( "twitter/cachedfriendssinceid", cachedId ); } qint64 TomahawkSettings::twitterCachedMentionsSinceId() const { + QMutexLocker locker( m_safety ); return value( "twitter/cachedmentionssinceid", 0 ).toLongLong(); } void TomahawkSettings::setTwitterCachedMentionsSinceId( qint64 cachedId ) { + QMutexLocker locker( m_safety ); setValue( "twitter/cachedmentionssinceid", cachedId ); } bool TomahawkSettings::scrobblingEnabled() const { + QMutexLocker locker( m_safety ); return value( "lastfm/enablescrobbling", false ).toBool(); } @@ -436,6 +493,7 @@ TomahawkSettings::scrobblingEnabled() const void TomahawkSettings::setScrobblingEnabled( bool enable ) { + QMutexLocker locker( m_safety ); setValue( "lastfm/enablescrobbling", enable ); } @@ -443,6 +501,7 @@ TomahawkSettings::setScrobblingEnabled( bool enable ) QString TomahawkSettings::xmppBotServer() const { + QMutexLocker locker( m_safety ); return value( "xmppBot/server", QString() ).toString(); } @@ -450,6 +509,7 @@ TomahawkSettings::xmppBotServer() const void TomahawkSettings::setXmppBotServer( const QString& server ) { + QMutexLocker locker( m_safety ); setValue( "xmppBot/server", server ); } @@ -457,6 +517,7 @@ TomahawkSettings::setXmppBotServer( const QString& server ) QString TomahawkSettings::xmppBotJid() const { + QMutexLocker locker( m_safety ); return value( "xmppBot/jid", QString() ).toString(); } @@ -464,6 +525,7 @@ TomahawkSettings::xmppBotJid() const void TomahawkSettings::setXmppBotJid( const QString& component ) { + QMutexLocker locker( m_safety ); setValue( "xmppBot/jid", component ); } @@ -471,6 +533,7 @@ TomahawkSettings::setXmppBotJid( const QString& component ) QString TomahawkSettings::xmppBotPassword() const { + QMutexLocker locker( m_safety ); return value( "xmppBot/password", QString() ).toString(); } @@ -478,6 +541,7 @@ TomahawkSettings::xmppBotPassword() const void TomahawkSettings::setXmppBotPassword( const QString& password ) { + QMutexLocker locker( m_safety ); setValue( "xmppBot/password", password ); } @@ -485,6 +549,7 @@ TomahawkSettings::setXmppBotPassword( const QString& password ) int TomahawkSettings::xmppBotPort() const { + QMutexLocker locker( m_safety ); return value( "xmppBot/port", -1 ).toInt(); } @@ -492,23 +557,27 @@ TomahawkSettings::xmppBotPort() const void TomahawkSettings::setXmppBotPort( const int port ) { + QMutexLocker locker( m_safety ); setValue( "xmppBot/port", -1 ); } void TomahawkSettings::addScriptResolver(const QString& resolver) { + QMutexLocker locker( m_safety ); setValue( "script/resolvers", scriptResolvers() << resolver ); } QStringList TomahawkSettings::scriptResolvers() const { + QMutexLocker locker( m_safety ); return value( "script/resolvers" ).toStringList(); } void TomahawkSettings::setScriptResolvers( const QStringList& resolver ) { + QMutexLocker locker( m_safety ); setValue( "script/resolvers", resolver ); } diff --git a/src/libtomahawk/tomahawksettings.h b/src/libtomahawk/tomahawksettings.h index 3dc1f5d52..5aae2a546 100644 --- a/src/libtomahawk/tomahawksettings.h +++ b/src/libtomahawk/tomahawksettings.h @@ -130,6 +130,7 @@ public: private: static TomahawkSettings* s_instance; + QMutex *m_safety; }; #endif From 782a38ec5acf271302b72bc04c3485e0b3b3448a Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 14:25:34 -0500 Subject: [PATCH 14/62] Save and load cached twitter peers (no syncing actually done yet) --- src/libtomahawk/tomahawksettings.cpp | 14 ++++++++ src/libtomahawk/tomahawksettings.h | 3 ++ src/sip/SipHandler.cpp | 1 + src/sip/twitter/twitter.cpp | 48 +++++++++++++++++++++------- src/sip/twitter/twitter.h | 3 +- 5 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index c707237ab..18a5deedf 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -482,6 +482,20 @@ TomahawkSettings::setTwitterCachedMentionsSinceId( qint64 cachedId ) setValue( "twitter/cachedmentionssinceid", cachedId ); } +QHash +TomahawkSettings::twitterCachedPeers() const +{ + QMutexLocker locker( m_safety ); + return value( "twitter/cachedpeers", QHash() ).toHash(); +} + +void +TomahawkSettings::setTwitterCachedPeers( const QHash &cachedPeers ) +{ + QMutexLocker locker( m_safety ); + setValue( "twitter/cachedpeers", cachedPeers ); +} + bool TomahawkSettings::scrobblingEnabled() const { diff --git a/src/libtomahawk/tomahawksettings.h b/src/libtomahawk/tomahawksettings.h index 5aae2a546..25ea4c937 100644 --- a/src/libtomahawk/tomahawksettings.h +++ b/src/libtomahawk/tomahawksettings.h @@ -109,6 +109,9 @@ public: qint64 twitterCachedMentionsSinceId() const; void setTwitterCachedMentionsSinceId( qint64 sinceid ); + QHash twitterCachedPeers() const; + void setTwitterCachedPeers( const QHash &cachedPeers ); + /// XMPP Component Settings QString xmppBotServer() const; void setXmppBotServer( const QString &server ); diff --git a/src/sip/SipHandler.cpp b/src/sip/SipHandler.cpp index 51b118bc2..59f846638 100644 --- a/src/sip/SipHandler.cpp +++ b/src/sip/SipHandler.cpp @@ -21,6 +21,7 @@ SipHandler::SipHandler( QObject* parent ) SipHandler::~SipHandler() { + disconnectPlugins(); } diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 60311d0d8..7bba948c7 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -14,11 +14,13 @@ TwitterPlugin::TwitterPlugin() : SipPlugin() - , m_isValid( false ) + , m_isAuthed( false ) , m_checkTimer( this ) , m_cachedFriendsSinceId( 0 ) , m_cachedMentionsSinceId( 0 ) + , m_cachedPeers() { + qDebug() << Q_FUNC_INFO; m_checkTimer.setInterval( 60000 ); m_checkTimer.setSingleShot( false ); QObject::connect( &m_checkTimer, SIGNAL( timeout() ), SLOT( checkTimerFired() ) ); @@ -28,7 +30,7 @@ TwitterPlugin::TwitterPlugin() bool TwitterPlugin::isValid() { - return m_isValid; + return m_isAuthed || !m_cachedPeers.isEmpty(); } const QString @@ -41,14 +43,22 @@ TwitterPlugin::name() bool TwitterPlugin::connectPlugin( bool /*startup*/ ) { - qDebug() << "TwitterPlugin connectPlugin called"; + qDebug() << Q_FUNC_INFO; TomahawkSettings *settings = TomahawkSettings::instance(); + m_cachedPeers = settings->twitterCachedPeers(); + QList peerlist = m_cachedPeers.keys(); + qStableSort( peerlist.begin(), peerlist.end() ); + foreach( QString key, peerlist ) + { + qDebug() << "TwitterPlugin found cached peer with host " << m_cachedPeers[key].toHash()["host"].toString() << " and port " << m_cachedPeers[key].toHash()["port"].toString(); + } + if ( settings->twitterOAuthToken().isEmpty() || settings->twitterOAuthTokenSecret().isEmpty() ) { - qDebug() << "Empty Twitter credentials; not connecting"; - return false; + qDebug() << "TwitterPlugin has empty Twitter credentials; not connecting"; + return m_cachedPeers.isEmpty(); } delete m_twitterAuth.data(); @@ -71,10 +81,14 @@ TwitterPlugin::connectPlugin( bool /*startup*/ ) void TwitterPlugin::disconnectPlugin() { + qDebug() << Q_FUNC_INFO; if( !m_friendsTimeline.isNull() ) m_friendsTimeline.data()->deleteLater(); if( !m_twitterAuth.isNull() ) m_twitterAuth.data()->deleteLater(); + + TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); + m_cachedPeers.empty(); } void @@ -82,13 +96,13 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) { if ( user.id() == 0 ) { - qDebug() << "Could not authenticate to Twitter"; - m_isValid = false; + qDebug() << "TwitterPlugin could not authenticate to Twitter"; + m_isAuthed = false; } else { qDebug() << "TwitterPlugin successfully authenticated to Twitter as user " << user.screenName(); - m_isValid = true; + m_isAuthed = true; if ( !m_twitterAuth.isNull() ) { m_friendsTimeline = QWeakPointer( new QTweetFriendsTimeline( m_twitterAuth.data(), this ) ); @@ -99,8 +113,8 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) } else { - qDebug() << "Twitter auth pointer was null!"; - m_isValid = false; + qDebug() << "TwitterPlugin auth pointer was null!"; + m_isAuthed = false; } } } @@ -112,11 +126,13 @@ TwitterPlugin::checkTimerFired() { if ( m_cachedFriendsSinceId == 0 ) m_cachedFriendsSinceId = TomahawkSettings::instance()->twitterCachedFriendsSinceId(); + qDebug() << "TwitterPlugin using friend timeline id of " << m_cachedFriendsSinceId; if ( !m_friendsTimeline.isNull() ) m_friendsTimeline.data()->fetch( m_cachedFriendsSinceId, 0, 800 ); if ( m_cachedMentionsSinceId == 0 ) m_cachedMentionsSinceId = TomahawkSettings::instance()->twitterCachedMentionsSinceId(); + qDebug() << "TwitterPlugin using mentions timeline id of " << m_cachedMentionsSinceId; if ( !m_mentions.isNull() ) m_mentions.data()->fetch( m_cachedMentionsSinceId, 0, 800 ); } @@ -125,7 +141,7 @@ TwitterPlugin::checkTimerFired() void TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus >& statuses ) { - qDebug() << "TwitterPlugin checking friends"; + qDebug() << Q_FUNC_INFO; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); foreach( QTweetStatus status, statuses ) { @@ -135,6 +151,10 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus >& statuses ) if ( regex.exactMatch( statusText ) ) { qDebug() << "TwitterPlugin found an exact tweet from friend " << status.user().screenName(); + QHash peerData; + peerData["host"] = QVariant::fromValue( "somehost" ); + peerData["port"] = QVariant::fromValue( "port" ); + m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); } } @@ -144,7 +164,7 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus >& statuses ) void TwitterPlugin::mentionsStatuses( const QList< QTweetStatus >& statuses ) { - qDebug() << "TwitterPlugin checking mentions"; + qDebug() << Q_FUNC_INFO; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); foreach( QTweetStatus status, statuses ) { @@ -154,6 +174,10 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus >& statuses ) if ( regex.exactMatch( statusText ) ) { qDebug() << "TwitterPlugin found an exact matching mention from user " << status.user().screenName(); + QHash peerData; + peerData["host"] = QVariant::fromValue( "somehost" ); + peerData["port"] = QVariant::fromValue( "port" ); + m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); } } diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index 89d56f2cc..49d489e27 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -56,10 +56,11 @@ private: QWeakPointer m_twitterAuth; QWeakPointer m_friendsTimeline; QWeakPointer m_mentions; - bool m_isValid; + bool m_isAuthed; QTimer m_checkTimer; qint64 m_cachedFriendsSinceId; qint64 m_cachedMentionsSinceId; + QHash m_cachedPeers; }; #endif From eee324d9c28534fafdafad954aa8fd0e1cd03055 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 15:08:59 -0500 Subject: [PATCH 15/62] Interim work at fetching direct messages --- src/libtomahawk/tomahawksettings.cpp | 34 +++++--- src/libtomahawk/tomahawksettings.h | 3 + src/sip/twitter/twitter.cpp | 123 ++++++++++++++++++++------- src/sip/twitter/twitter.h | 16 +++- 4 files changed, 129 insertions(+), 47 deletions(-) diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index 18a5deedf..8f2f86941 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -430,70 +430,84 @@ QString TomahawkSettings::twitterOAuthToken() const { QMutexLocker locker( m_safety ); - return value( "twitter/oauthtoken" ).toString(); + return value( "twitter/OAuthToken" ).toString(); } void TomahawkSettings::setTwitterOAuthToken( const QString& oauthtoken ) { QMutexLocker locker( m_safety ); - setValue( "twitter/oauthtoken", oauthtoken ); + setValue( "twitter/OAuthToken", oauthtoken ); } QString TomahawkSettings::twitterOAuthTokenSecret() const { QMutexLocker locker( m_safety ); - return value( "twitter/oauthtokensecret" ).toString(); + return value( "twitter/OAuthTokenSecret" ).toString(); } void TomahawkSettings::setTwitterOAuthTokenSecret( const QString& oauthtokensecret ) { QMutexLocker locker( m_safety ); - setValue( "twitter/oauthtokensecret", oauthtokensecret ); + setValue( "twitter/OAuthTokenSecret", oauthtokensecret ); } qint64 TomahawkSettings::twitterCachedFriendsSinceId() const { QMutexLocker locker( m_safety ); - return value( "twitter/cachedfriendssinceid", 0 ).toLongLong(); + return value( "twitter/CachedFriendsSinceID", 0 ).toLongLong(); } void TomahawkSettings::setTwitterCachedFriendsSinceId( qint64 cachedId ) { QMutexLocker locker( m_safety ); - setValue( "twitter/cachedfriendssinceid", cachedId ); + setValue( "twitter/CachedFriendsSinceID", cachedId ); } qint64 TomahawkSettings::twitterCachedMentionsSinceId() const { QMutexLocker locker( m_safety ); - return value( "twitter/cachedmentionssinceid", 0 ).toLongLong(); + return value( "twitter/CachedMentionsSinceID", 0 ).toLongLong(); } void TomahawkSettings::setTwitterCachedMentionsSinceId( qint64 cachedId ) { QMutexLocker locker( m_safety ); - setValue( "twitter/cachedmentionssinceid", cachedId ); + setValue( "twitter/CachedMentionsSinceID", cachedId ); +} + +qint64 +TomahawkSettings::twitterCachedDirectMessagesSinceId() const +{ + QMutexLocker locker( m_safety ); + return value( "twitter/CachedDirectMessagesSinceID", 0 ).toLongLong(); +} + +void +TomahawkSettings::setTwitterCachedDirectMessagesSinceId( qint64 cachedId ) +{ + QMutexLocker locker( m_safety ); + setValue( "twitter/CachedDirectMessagesSinceID", cachedId ); } QHash TomahawkSettings::twitterCachedPeers() const { QMutexLocker locker( m_safety ); - return value( "twitter/cachedpeers", QHash() ).toHash(); + return value( "twitter/CachedPeers", QHash() ).toHash(); } void TomahawkSettings::setTwitterCachedPeers( const QHash &cachedPeers ) { QMutexLocker locker( m_safety ); - setValue( "twitter/cachedpeers", cachedPeers ); + setValue( "twitter/CachedPeers", cachedPeers ); } bool diff --git a/src/libtomahawk/tomahawksettings.h b/src/libtomahawk/tomahawksettings.h index 25ea4c937..f08b3be0c 100644 --- a/src/libtomahawk/tomahawksettings.h +++ b/src/libtomahawk/tomahawksettings.h @@ -109,6 +109,9 @@ public: qint64 twitterCachedMentionsSinceId() const; void setTwitterCachedMentionsSinceId( qint64 sinceid ); + qint64 twitterCachedDirectMessagesSinceId() const; + void setTwitterCachedDirectMessagesSinceId( qint64 sinceid ); + QHash twitterCachedPeers() const; void setTwitterCachedPeers( const QHash &cachedPeers ); diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 7bba948c7..4ee4a7636 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include @@ -18,12 +17,15 @@ TwitterPlugin::TwitterPlugin() , m_checkTimer( this ) , m_cachedFriendsSinceId( 0 ) , m_cachedMentionsSinceId( 0 ) + , m_cachedDirectMessagesSinceId( 0 ) , m_cachedPeers() + , m_finishedFriends( false ) + , m_finishedMentions( false ) { qDebug() << Q_FUNC_INFO; m_checkTimer.setInterval( 60000 ); m_checkTimer.setSingleShot( false ); - QObject::connect( &m_checkTimer, SIGNAL( timeout() ), SLOT( checkTimerFired() ) ); + connect( &m_checkTimer, SIGNAL( timeout() ), SLOT( checkTimerFired() ) ); m_checkTimer.start(); } @@ -68,7 +70,7 @@ TwitterPlugin::connectPlugin( bool /*startup*/ ) m_twitterAuth.data()->setOAuthTokenSecret( settings->twitterOAuthTokenSecret().toLatin1() ); QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this ); - QObject::connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) ); + connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) ); credVerifier->verify(); /* QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ), @@ -107,9 +109,11 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) { m_friendsTimeline = QWeakPointer( new QTweetFriendsTimeline( m_twitterAuth.data(), this ) ); m_mentions = QWeakPointer( new QTweetMentions( m_twitterAuth.data(), this ) ); - QObject::connect( m_friendsTimeline.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( friendsTimelineStatuses(const QList &) ) ); - QObject::connect( m_mentions.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( mentionsStatuses(const QList &) ) ); - QMetaObject::invokeMethod( this, "checkTimerFired", Qt::DirectConnection ); + m_directMessages = QWeakPointer( new QTweetDirectMessages( m_twitterAuth.data(), this ) ); + connect( m_friendsTimeline.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( friendsTimelineStatuses(const QList &) ) ); + connect( m_mentions.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( mentionsStatuses(const QList &) ) ); + connect( m_directMessages.data(), SIGNAL( parsedStatuses(const QList< QTweetDMStatus > &) ), SLOT( mentionsStatuses(const QList &) ) ); + QMetaObject::invokeMethod( this, "checkTimerFired", Qt::AutoConnection ); } else { @@ -122,24 +126,24 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) void TwitterPlugin::checkTimerFired() { - if ( isValid() ) - { - if ( m_cachedFriendsSinceId == 0 ) - m_cachedFriendsSinceId = TomahawkSettings::instance()->twitterCachedFriendsSinceId(); - qDebug() << "TwitterPlugin using friend timeline id of " << m_cachedFriendsSinceId; - if ( !m_friendsTimeline.isNull() ) - m_friendsTimeline.data()->fetch( m_cachedFriendsSinceId, 0, 800 ); - - if ( m_cachedMentionsSinceId == 0 ) - m_cachedMentionsSinceId = TomahawkSettings::instance()->twitterCachedMentionsSinceId(); - qDebug() << "TwitterPlugin using mentions timeline id of " << m_cachedMentionsSinceId; - if ( !m_mentions.isNull() ) - m_mentions.data()->fetch( m_cachedMentionsSinceId, 0, 800 ); - } + if ( !isValid() ) + return; + + if ( m_cachedFriendsSinceId == 0 ) + m_cachedFriendsSinceId = TomahawkSettings::instance()->twitterCachedFriendsSinceId(); + qDebug() << "TwitterPlugin using friend timeline id of " << m_cachedFriendsSinceId; + if ( !m_friendsTimeline.isNull() ) + m_friendsTimeline.data()->fetch( m_cachedFriendsSinceId, 0, 800 ); + + if ( m_cachedMentionsSinceId == 0 ) + m_cachedMentionsSinceId = TomahawkSettings::instance()->twitterCachedMentionsSinceId(); + qDebug() << "TwitterPlugin using mentions timeline id of " << m_cachedMentionsSinceId; + if ( !m_mentions.isNull() ) + m_mentions.data()->fetch( m_cachedMentionsSinceId, 0, 800 ); } void -TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus >& statuses ) +TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << Q_FUNC_INFO; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); @@ -147,22 +151,27 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus >& statuses ) { if ( status.id() > m_cachedFriendsSinceId ) m_cachedFriendsSinceId = status.id(); - QString statusText = status.text(); - if ( regex.exactMatch( statusText ) ) + if ( regex.exactMatch( status.text() ) ) { qDebug() << "TwitterPlugin found an exact tweet from friend " << status.user().screenName(); QHash peerData; - peerData["host"] = QVariant::fromValue( "somehost" ); - peerData["port"] = QVariant::fromValue( "port" ); - m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); + if ( ! m_cachedPeers.contains( status.user().screenName() ) ) + { + QHash< QString, QVariant > peerData; + peerData["sentuid"] = QVariant::fromValue< QString >( uuid() ); + m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); + } } } TomahawkSettings::instance()->setTwitterCachedFriendsSinceId( m_cachedFriendsSinceId ); + + m_finishedFriends = true; + QMetaObject::invokeMethod( this, "pollDirectMessages", Qt::AutoConnection ); } void -TwitterPlugin::mentionsStatuses( const QList< QTweetStatus >& statuses ) +TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << Q_FUNC_INFO; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); @@ -170,18 +179,66 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus >& statuses ) { if ( status.id() > m_cachedMentionsSinceId ) m_cachedMentionsSinceId = status.id(); - QString statusText = status.text(); - if ( regex.exactMatch( statusText ) ) + if ( regex.exactMatch( status.text() ) ) { qDebug() << "TwitterPlugin found an exact matching mention from user " << status.user().screenName(); - QHash peerData; - peerData["host"] = QVariant::fromValue( "somehost" ); - peerData["port"] = QVariant::fromValue( "port" ); - m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); + if ( ! m_cachedPeers.contains( status.user().screenName() ) ) + { + QHash< QString, QVariant > peerData; + peerData["sentuid"] = QVariant::fromValue< QString >( uuid() ); + m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); + } } } TomahawkSettings::instance()->setTwitterCachedMentionsSinceId( m_cachedMentionsSinceId ); + + m_finishedMentions = true; + QMetaObject::invokeMethod( this, "pollDirectMessages", Qt::AutoConnection ); +} + +void +TwitterPlugin::pollDirectMessages() +{ + if ( !m_finishedMentions || !m_finishedFriends ) + return; + + m_finishedFriends = false; + m_finishedMentions = false; + + if ( !isValid() ) + return; + + if ( m_cachedDirectMessagesSinceId == 0 ) + m_cachedDirectMessagesSinceId = TomahawkSettings::instance()->twitterCachedDirectMessagesSinceId(); + qDebug() << "TwitterPlugin using direct messages id of " << m_cachedDirectMessagesSinceId; + if ( !m_directMessages.isNull() ) + m_directMessages.data()->fetch( m_cachedDirectMessagesSinceId, 0, 800 ); +} + +void +TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) +{ + qDebug() << Q_FUNC_INFO; + QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); + foreach( QTweetDMStatus status, messages ) + { + if ( status.id() > m_cachedDirectMessagesSinceId ) + m_cachedDirectMessagesSinceId = status.id(); + if ( regex.exactMatch( status.text() ) ) + { + qDebug() << "TwitterPlugin found an exact matching mention from user " << status.sender().screenName(); + if ( ! m_cachedPeers.contains( status.sender().screenName() ) ) + { + QHash< QString, QVariant > peerData; + peerData["sentuid"] = QVariant::fromValue< QString >( uuid() ); + m_cachedPeers[status.sender().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); + } + } + } + + TomahawkSettings::instance()->setTwitterCachedDirectMessagesSinceId( m_cachedDirectMessagesSinceId ); + } void diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index 49d489e27..9e100b16f 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -7,7 +7,9 @@ #include #include #include +#include #include +#include #include "../sipdllmacro.h" #include "sip/SipPlugin.h" @@ -51,16 +53,22 @@ private slots: void checkTimerFired(); void friendsTimelineStatuses( const QList< QTweetStatus > &statuses ); void mentionsStatuses( const QList< QTweetStatus > &statuses ); + void pollDirectMessages(); + void directMessages( const QList< QTweetDMStatus > &messages ); private: - QWeakPointer m_twitterAuth; - QWeakPointer m_friendsTimeline; - QWeakPointer m_mentions; + QWeakPointer< TomahawkOAuthTwitter > m_twitterAuth; + QWeakPointer< QTweetFriendsTimeline > m_friendsTimeline; + QWeakPointer< QTweetMentions > m_mentions; + QWeakPointer< QTweetDirectMessages > m_directMessages; bool m_isAuthed; QTimer m_checkTimer; qint64 m_cachedFriendsSinceId; qint64 m_cachedMentionsSinceId; - QHash m_cachedPeers; + qint64 m_cachedDirectMessagesSinceId; + QHash< QString, QVariant > m_cachedPeers; + bool m_finishedFriends; + bool m_finishedMentions; }; #endif From ef92a9b4db62ce88d6c56b5997647cc42fbf0aa3 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 16:21:16 -0500 Subject: [PATCH 16/62] Interim checking towards protocol handling --- src/libtomahawk/network/servent.cpp | 10 +- src/libtomahawk/network/servent.h | 2 +- src/sip/twitter/twitter.cpp | 142 +++++++++++++++++++++------- src/sip/twitter/twitter.h | 7 +- 4 files changed, 122 insertions(+), 39 deletions(-) diff --git a/src/libtomahawk/network/servent.cpp b/src/libtomahawk/network/servent.cpp index ddcaa5839..978d712ff 100644 --- a/src/libtomahawk/network/servent.cpp +++ b/src/libtomahawk/network/servent.cpp @@ -123,15 +123,17 @@ Servent::startListening( QHostAddress ha, bool upnp, int port ) QString -Servent::createConnectionKey( const QString& name ) +Servent::createConnectionKey( const QString& name, const QString &nodeid, const QString &key ) { Q_ASSERT( this->thread() == QThread::currentThread() ); - QString key = uuid(); + QString _key = ( key.isEmpty() ? uuid() : key ); ControlConnection* cc = new ControlConnection( this ); cc->setName( name.isEmpty() ? QString( "KEY(%1)" ).arg( key ) : name ); - registerOffer( key, cc ); - return key; + if( !nodeid.isEmpty() ) + cc->setId( nodeid ); + registerOffer( _key, cc ); + return _key; } diff --git a/src/libtomahawk/network/servent.h b/src/libtomahawk/network/servent.h index 86fde1261..add40c098 100644 --- a/src/libtomahawk/network/servent.h +++ b/src/libtomahawk/network/servent.h @@ -78,7 +78,7 @@ public: int port() const { return m_port; } // creates new token that allows a controlconnection to be set up - QString createConnectionKey( const QString& name = "" ); + QString createConnectionKey( const QString& name = "", const QString &nodeid = "", const QString &key = "" ); void registerOffer( const QString& key, Connection* conn ); diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 4ee4a7636..7b41b9c49 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -9,6 +10,8 @@ #include #include +#include +#include TwitterPlugin::TwitterPlugin() @@ -52,9 +55,10 @@ TwitterPlugin::connectPlugin( bool /*startup*/ ) m_cachedPeers = settings->twitterCachedPeers(); QList peerlist = m_cachedPeers.keys(); qStableSort( peerlist.begin(), peerlist.end() ); - foreach( QString key, peerlist ) + foreach( QString screenName, peerlist ) { - qDebug() << "TwitterPlugin found cached peer with host " << m_cachedPeers[key].toHash()["host"].toString() << " and port " << m_cachedPeers[key].toHash()["port"].toString(); + QHash< QString, QVariant > cachedPeer = m_cachedPeers[screenName].toHash(); + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&cachedPeer ) ); } if ( settings->twitterOAuthToken().isEmpty() || settings->twitterOAuthTokenSecret().isEmpty() ) @@ -72,11 +76,7 @@ TwitterPlugin::connectPlugin( bool /*startup*/ ) QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this ); connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) ); credVerifier->verify(); - /* - QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ), - SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) ); - */ - + return true; } @@ -110,9 +110,11 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) m_friendsTimeline = QWeakPointer( new QTweetFriendsTimeline( m_twitterAuth.data(), this ) ); m_mentions = QWeakPointer( new QTweetMentions( m_twitterAuth.data(), this ) ); m_directMessages = QWeakPointer( new QTweetDirectMessages( m_twitterAuth.data(), this ) ); + m_directMessageNew = QWeakPointer( new QTweetDirectMessageNew( m_twitterAuth.data(), this ) ); connect( m_friendsTimeline.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( friendsTimelineStatuses(const QList &) ) ); connect( m_mentions.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( mentionsStatuses(const QList &) ) ); - connect( m_directMessages.data(), SIGNAL( parsedStatuses(const QList< QTweetDMStatus > &) ), SLOT( mentionsStatuses(const QList &) ) ); + connect( m_directMessages.data(), SIGNAL( parsedStatuses(const QList< QTweetDMStatus > &) ), SLOT( directMessages(const QList &) ) ); + connect( m_directMessageNew.data(), SIGNAL( parsedStatuses(const QList< QTweetDMStatus > &) ), SLOT( directMessageNew(const QList &) ) ); QMetaObject::invokeMethod( this, "checkTimerFired", Qt::AutoConnection ); } else @@ -147,6 +149,7 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << Q_FUNC_INFO; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); + bool peersChanged = false; foreach( QTweetStatus status, statuses ) { if ( status.id() > m_cachedFriendsSinceId ) @@ -155,16 +158,21 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << "TwitterPlugin found an exact tweet from friend " << status.user().screenName(); QHash peerData; - if ( ! m_cachedPeers.contains( status.user().screenName() ) ) + if ( !m_cachedPeers.contains( status.user().screenName() ) ) { QHash< QString, QVariant > peerData; - peerData["sentuid"] = QVariant::fromValue< QString >( uuid() ); - m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); + QString okey = QUuid::createUuid().toString().split( '-' ).last(); + okey.chop( 1 ); + peerData["okey"] = QVariant::fromValue< QString >( okey ); + QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + peersChanged = true; } } } TomahawkSettings::instance()->setTwitterCachedFriendsSinceId( m_cachedFriendsSinceId ); + if ( peersChanged ) + TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); m_finishedFriends = true; QMetaObject::invokeMethod( this, "pollDirectMessages", Qt::AutoConnection ); @@ -175,6 +183,7 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << Q_FUNC_INFO; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); + bool peersChanged = false; foreach( QTweetStatus status, statuses ) { if ( status.id() > m_cachedMentionsSinceId ) @@ -182,16 +191,21 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) if ( regex.exactMatch( status.text() ) ) { qDebug() << "TwitterPlugin found an exact matching mention from user " << status.user().screenName(); - if ( ! m_cachedPeers.contains( status.user().screenName() ) ) + if ( !m_cachedPeers.contains( status.user().screenName() ) ) { QHash< QString, QVariant > peerData; - peerData["sentuid"] = QVariant::fromValue< QString >( uuid() ); - m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); + QString okey = QUuid::createUuid().toString().split( '-' ).last(); + okey.chop( 1 ); + peerData["okey"] = QVariant::fromValue< QString >( okey ); + QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + peersChanged = true; } } } TomahawkSettings::instance()->setTwitterCachedMentionsSinceId( m_cachedMentionsSinceId ); + if ( peersChanged ) + TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); m_finishedMentions = true; QMetaObject::invokeMethod( this, "pollDirectMessages", Qt::AutoConnection ); @@ -220,36 +234,98 @@ void TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) { qDebug() << Q_FUNC_INFO; - QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); + + bool peersChanged = false; + foreach( QTweetDMStatus status, messages ) { if ( status.id() > m_cachedDirectMessagesSinceId ) m_cachedDirectMessagesSinceId = status.id(); - if ( regex.exactMatch( status.text() ) ) - { - qDebug() << "TwitterPlugin found an exact matching mention from user " << status.sender().screenName(); - if ( ! m_cachedPeers.contains( status.sender().screenName() ) ) - { - QHash< QString, QVariant > peerData; - peerData["sentuid"] = QVariant::fromValue< QString >( uuid() ); - m_cachedPeers[status.sender().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); - } - } + QStringList splitList = status.text().split(':'); + if ( splitList.length() < 5 ) + continue; + if ( splitList[0] != "TOMAHAWKPEERSTART" ) + continue; + if ( !splitList[1].startsWith( "Host=" ) || !splitList[2].startsWith( "Port=" ) || !splitList[3].startsWith( "Node=" ) || !splitList[4].startsWith( "PKey=" ) ) + continue; + int port = splitList[2].mid( 5 ).toInt(); + if ( port == 0 ) + continue; + QString host = splitList[1].mid( 5 ); + QString node = splitList[3].mid( 5 ); + QString pkey = splitList[4].mid( 5 ); + qDebug() << "TwitterPlugin found a peerstart message from " << status.senderScreenName() << " with host " << host << " and port " << port << " and node " << node << " and pkey " << pkey; + + QHash< QString, QVariant > peerData; + if ( m_cachedPeers.contains( status.senderScreenName() ) ) + peerData = m_cachedPeers[status.senderScreenName()].toHash(); + + peerData["host"] = QVariant::fromValue< QString >( host ); + peerData["port"] = QVariant::fromValue< int >( port ); + peerData["node"] = QVariant::fromValue< QString >( node ); + peerData["pkey"] = QVariant::fromValue< QString >( pkey ); + m_cachedPeers[status.senderScreenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); + peersChanged = true; + + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.senderScreenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } TomahawkSettings::instance()->setTwitterCachedDirectMessagesSinceId( m_cachedDirectMessagesSinceId ); - + if ( peersChanged ) + TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); } void -TwitterPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ) +TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerdata ) { - /* - qDebug() << "Found LAN host:" << host << port << nodeid; - - if ( !Servent::instance()->connectedToSession( nodeid ) ) - Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid ); - */ + qDebug() << Q_FUNC_INFO; + if ( !peerdata.contains( "node" ) || !peerdata.contains( "host" ) || !peerdata.contains( "port" ) || !peerdata.contains( "pkey" ) ) + { + qDebug() << "Could not find node and/or host and/or port and/or pkey for peer " << screenName; + return; + } + if ( !Servent::instance()->connectedToSession( peerdata["node"].toString() ) ) + Servent::instance()->connectToPeer( peerdata["host"].toString(), + peerdata["port"].toString().toInt(), + peerdata["pkey"].toString(), + QString( '@' + peerdata["screenname"].toString() ), + peerdata["node"].toString() ); } +void +TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata ) +{ + qDebug() << Q_FUNC_INFO; + if ( !peerdata.contains( "node" ) || !peerdata.contains( "okey" ) ) + { + qDebug() << "Could not find node and/or okey for peer " << screenName; + return; + } + qDebug() << "TwitterPlugin registering offer to " << QString( '@' + screenName ) << " with node " << peerdata["node"].toString() << " and offeredkey " << peerdata["okey"].toString(); + Servent::instance()->createConnectionKey( QString( '@' + screenName ), peerdata["node"].toString(), peerdata["okey"].toString() ); + if ( peerdata.contains( "node" ) && peerdata.contains( "host" ) && peerdata.contains( "port" ) && peerdata.contains( "pkey" ) ) + QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerdata ) ); +} + +void +TwitterPlugin::sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata ) +{ + qDebug() << Q_FUNC_INFO; + QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:Node=%3:PKey=%4" ).arg( Servent::instance()->externalAddress() ) + .arg( Servent::instance()->externalPort() ) + .arg( Database::instance()->dbid() ) + .arg( peerdata["okey"].toString() ); + qDebug() << "Sending message to " << screenName << ": " << offerString; + if( !m_directMessageNew.isNull() ) + m_directMessageNew.data()->post( screenName, offerString ); +} + +void +TwitterPlugin::directMessageNew(const QTweetDMStatus& message) +{ + qDebug() << Q_FUNC_INFO; + qDebug() << "Message sent to " << message.recipientScreenName() << " containing: " << message.text(); +} + + Q_EXPORT_PLUGIN2( sip, TwitterPlugin ) diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index 9e100b16f..16b768b04 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -48,19 +49,23 @@ public slots: } private slots: - void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ); void connectAuthVerifyReply( const QTweetUser &user ); void checkTimerFired(); void friendsTimelineStatuses( const QList< QTweetStatus > &statuses ); void mentionsStatuses( const QList< QTweetStatus > &statuses ); void pollDirectMessages(); void directMessages( const QList< QTweetDMStatus > &messages ); + void directMessageNew( const QTweetDMStatus &message ); + void registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata ); + void sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata ); + void makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerdata ); private: QWeakPointer< TomahawkOAuthTwitter > m_twitterAuth; QWeakPointer< QTweetFriendsTimeline > m_friendsTimeline; QWeakPointer< QTweetMentions > m_mentions; QWeakPointer< QTweetDirectMessages > m_directMessages; + QWeakPointer< QTweetDirectMessageNew > m_directMessageNew; bool m_isAuthed; QTimer m_checkTimer; qint64 m_cachedFriendsSinceId; From 53892683917c431ef49599d08274d05dc6ec83f3 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 18:51:44 -0500 Subject: [PATCH 17/62] Fix some bonehead issues --- src/sip/twitter/twitter.cpp | 39 +++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 0d1580b47..821ed002b 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -159,14 +159,16 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) if ( regex.exactMatch( status.text() ) ) { qDebug() << "TwitterPlugin found an exact tweet from friend " << status.user().screenName(); - QHash peerData; if ( !m_cachedPeers.contains( status.user().screenName() ) ) { QHash< QString, QVariant > peerData; QString okey = QUuid::createUuid().toString().split( '-' ).last(); okey.chop( 1 ); peerData["okey"] = QVariant::fromValue< QString >( okey ); + peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); + peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); peersChanged = true; } } @@ -199,7 +201,10 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) QString okey = QUuid::createUuid().toString().split( '-' ).last(); okey.chop( 1 ); peerData["okey"] = QVariant::fromValue< QString >( okey ); + peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); + peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); peersChanged = true; } } @@ -280,45 +285,45 @@ TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) } void -TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerdata ) +TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerData ) { qDebug() << Q_FUNC_INFO; - if ( !peerdata.contains( "node" ) || !peerdata.contains( "host" ) || !peerdata.contains( "port" ) || !peerdata.contains( "pkey" ) ) + if ( !peerData.contains( "node" ) || !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) { qDebug() << "Could not find node and/or host and/or port and/or pkey for peer " << screenName; return; } - if ( !Servent::instance()->connectedToSession( peerdata["node"].toString() ) ) - Servent::instance()->connectToPeer( peerdata["host"].toString(), - peerdata["port"].toString().toInt(), - peerdata["pkey"].toString(), - QString( '@' + peerdata["screenname"].toString() ), - peerdata["node"].toString() ); + if ( !Servent::instance()->connectedToSession( peerData["node"].toString() ) ) + Servent::instance()->connectToPeer( peerData["host"].toString(), + peerData["port"].toString().toInt(), + peerData["pkey"].toString(), + QString( '@' + peerData["screenname"].toString() ), + peerData["node"].toString() ); } void -TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata ) +TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerData ) { qDebug() << Q_FUNC_INFO; - if ( !peerdata.contains( "node" ) || !peerdata.contains( "okey" ) ) + if ( !peerData.contains( "node" ) || !peerData.contains( "okey" ) ) { qDebug() << "Could not find node and/or okey for peer " << screenName; return; } - qDebug() << "TwitterPlugin registering offer to " << QString( '@' + screenName ) << " with node " << peerdata["node"].toString() << " and offeredkey " << peerdata["okey"].toString(); - Servent::instance()->createConnectionKey( QString( '@' + screenName ), peerdata["node"].toString(), peerdata["okey"].toString() ); - if ( peerdata.contains( "node" ) && peerdata.contains( "host" ) && peerdata.contains( "port" ) && peerdata.contains( "pkey" ) ) - QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerdata ) ); + qDebug() << "TwitterPlugin registering offer to " << QString( '@' + screenName ) << " with node " << peerData["node"].toString() << " and offeredkey " << peerData["okey"].toString(); + Servent::instance()->createConnectionKey( QString( '@' + screenName ), peerData["node"].toString(), peerData["okey"].toString() ); + if ( peerData.contains( "node" ) && peerData.contains( "host" ) && peerData.contains( "port" ) && peerData.contains( "pkey" ) ) + QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } void -TwitterPlugin::sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata ) +TwitterPlugin::sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerData ) { qDebug() << Q_FUNC_INFO; QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:Node=%3:PKey=%4" ).arg( Servent::instance()->externalAddress() ) .arg( Servent::instance()->externalPort() ) .arg( Database::instance()->dbid() ) - .arg( peerdata["okey"].toString() ); + .arg( peerData["okey"].toString() ); qDebug() << "Sending message to " << screenName << ": " << offerString; if( !m_directMessageNew.isNull() ) m_directMessageNew.data()->post( screenName, offerString ); From 2d918156d130e80d1816aec5f919780ae83cafb0 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 19:15:08 -0500 Subject: [PATCH 18/62] Add some error logging and the connection timer --- src/sip/twitter/twitter.cpp | 43 +++++++++++++++++++++++++++++++++++-- src/sip/twitter/twitter.h | 3 +++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 821ed002b..fa2d3d6d3 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -18,6 +18,7 @@ TwitterPlugin::TwitterPlugin() : SipPlugin() , m_isAuthed( false ) , m_checkTimer( this ) + , m_connectTimer( this ) , m_cachedFriendsSinceId( 0 ) , m_cachedMentionsSinceId( 0 ) , m_cachedDirectMessagesSinceId( 0 ) @@ -30,6 +31,11 @@ TwitterPlugin::TwitterPlugin() m_checkTimer.setSingleShot( false ); connect( &m_checkTimer, SIGNAL( timeout() ), SLOT( checkTimerFired() ) ); m_checkTimer.start(); + + m_connectTimer.setInterval( 60000 ); + m_connectTimer.setSingleShot( false ); + connect( &m_connectTimer, SIGNAL( timeout() ), SLOT( connectTimerFired() ) ); + m_connectTimer.start(); } bool @@ -116,6 +122,7 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) connect( m_mentions.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( mentionsStatuses(const QList &) ) ); connect( m_directMessages.data(), SIGNAL( parsedStatuses(const QList< QTweetDMStatus > &) ), SLOT( directMessages(const QList &) ) ); connect( m_directMessageNew.data(), SIGNAL( parsedStatuses(const QList< QTweetDMStatus > &) ), SLOT( directMessagePosted(const QTweetDMStatus &) ) ); + connect( m_directMessageNew.data(), SIGNAL( error(QTweetNetBase::ErrorCode, const QString &) ), SLOT( directMessagePostError(QTweetNetBase::ErrorCode, const QString &) ) ); connect( m_directMessageDestroy.data(), SIGNAL( parsedStatuses(const QList< QTweetDMStatus > &) ), SLOT( directMessageDestoyed(const QTweetDMStatus &) ) ); QMetaObject::invokeMethod( this, "checkTimerFired", Qt::AutoConnection ); } @@ -146,6 +153,30 @@ TwitterPlugin::checkTimerFired() m_mentions.data()->fetch( m_cachedMentionsSinceId, 0, 800 ); } +void +TwitterPlugin::connectTimerFired() +{ + if ( !isValid() || m_cachedPeers.isEmpty() ) + return; + + QList peerlist = m_cachedPeers.keys(); + qStableSort( peerlist.begin(), peerlist.end() ); + foreach( QString screenName, peerlist ) + { + QHash< QString, QVariant > peerData = m_cachedPeers[screenName].toHash(); + if ( !peerData.contains( "node" ) || !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) + continue; + + if ( !peerData.contains( "ohst" ) || !peerData.contains( "oprt" ) || + peerData["ohst"].toString() != Servent::instance()->externalAddress() || + peerData["oprt"].toInt() != Servent::instance()->externalPort() + ) + QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + else + QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + } +} + void TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) { @@ -330,11 +361,19 @@ TwitterPlugin::sendOffer( const QString &screenName, const QHash< QString, QVari } void -TwitterPlugin::directMessagePosted(const QTweetDMStatus& message) +TwitterPlugin::directMessagePosted( const QTweetDMStatus& message ) { qDebug() << Q_FUNC_INFO; - qDebug() << "Message sent to " << message.recipientScreenName() << " containing: " << message.text();} + qDebug() << "Message sent to " << message.recipientScreenName() << " containing: " << message.text(); + +} +void +TwitterPlugin::directMessagePostError( QTweetNetBase::ErrorCode errorCode, const QString &message ) +{ + qDebug() << Q_FUNC_INFO; + qDebug() << "Received an error posting direct message: " << m_directMessageNew.data()->lastErrorMessage(); +} void TwitterPlugin::directMessageDestroyed(const QTweetDMStatus& message) diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index f67a70877..c9b7f365f 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -52,11 +52,13 @@ public slots: private slots: void connectAuthVerifyReply( const QTweetUser &user ); void checkTimerFired(); + void connectTimerFired(); void friendsTimelineStatuses( const QList< QTweetStatus > &statuses ); void mentionsStatuses( const QList< QTweetStatus > &statuses ); void pollDirectMessages(); void directMessages( const QList< QTweetDMStatus > &messages ); void directMessagePosted( const QTweetDMStatus &message ); + void directMessagePostError( QTweetNetBase::ErrorCode errorCode, const QString &message ); void directMessageDestroyed( const QTweetDMStatus &message ); void registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata ); void sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata ); @@ -71,6 +73,7 @@ private: QWeakPointer< QTweetDirectMessageDestroy > m_directMessageDestroy; bool m_isAuthed; QTimer m_checkTimer; + QTimer m_connectTimer; qint64 m_cachedFriendsSinceId; qint64 m_cachedMentionsSinceId; qint64 m_cachedDirectMessagesSinceId; From 12253e2fd3424bebb507d3549289c660b126d0af Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 19:43:42 -0500 Subject: [PATCH 19/62] Standardize debugging messages --- src/sip/twitter/twitter.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index fa2d3d6d3..66bd8560c 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -321,7 +321,7 @@ TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, qDebug() << Q_FUNC_INFO; if ( !peerData.contains( "node" ) || !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) { - qDebug() << "Could not find node and/or host and/or port and/or pkey for peer " << screenName; + qDebug() << "TwitterPlugin could not find node and/or host and/or port and/or pkey for peer " << screenName; return; } if ( !Servent::instance()->connectedToSession( peerData["node"].toString() ) ) @@ -338,7 +338,7 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q qDebug() << Q_FUNC_INFO; if ( !peerData.contains( "node" ) || !peerData.contains( "okey" ) ) { - qDebug() << "Could not find node and/or okey for peer " << screenName; + qDebug() << "TwitterPlugin could not find node and/or okey for peer " << screenName; return; } qDebug() << "TwitterPlugin registering offer to " << QString( '@' + screenName ) << " with node " << peerData["node"].toString() << " and offeredkey " << peerData["okey"].toString(); @@ -355,7 +355,7 @@ TwitterPlugin::sendOffer( const QString &screenName, const QHash< QString, QVari .arg( Servent::instance()->externalPort() ) .arg( Database::instance()->dbid() ) .arg( peerData["okey"].toString() ); - qDebug() << "Sending message to " << screenName << ": " << offerString; + qDebug() << "TwitterPlugin sending message to " << screenName << ": " << offerString; if( !m_directMessageNew.isNull() ) m_directMessageNew.data()->post( screenName, offerString ); } @@ -364,7 +364,7 @@ void TwitterPlugin::directMessagePosted( const QTweetDMStatus& message ) { qDebug() << Q_FUNC_INFO; - qDebug() << "Message sent to " << message.recipientScreenName() << " containing: " << message.text(); + qDebug() << "TwitterPlugin sent message to " << message.recipientScreenName() << " containing: " << message.text(); } @@ -372,14 +372,14 @@ void TwitterPlugin::directMessagePostError( QTweetNetBase::ErrorCode errorCode, const QString &message ) { qDebug() << Q_FUNC_INFO; - qDebug() << "Received an error posting direct message: " << m_directMessageNew.data()->lastErrorMessage(); + qDebug() << "TwitterPlugin received an error posting direct message: " << m_directMessageNew.data()->lastErrorMessage(); } void TwitterPlugin::directMessageDestroyed(const QTweetDMStatus& message) { qDebug() << Q_FUNC_INFO; - qDebug() << "Message " << message.text() << " destroyed"; + qDebug() << "TwitterPlugin destroyed message " << message.text(); } Q_EXPORT_PLUGIN2( sip, TwitterPlugin ) From 29d096be1525b0096eaa04f7110e452d0a1ec472 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 20:15:54 -0500 Subject: [PATCH 20/62] Fix misnamed signals and stupidity in qtweetnetbase --- src/sip/twitter/twitter.cpp | 8 ++++---- thirdparty/qtweetlib/src/qtweetnetbase.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 66bd8560c..bf7036f2d 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -120,10 +120,10 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) m_directMessageDestroy = QWeakPointer( new QTweetDirectMessageDestroy( m_twitterAuth.data(), this ) ); connect( m_friendsTimeline.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( friendsTimelineStatuses(const QList &) ) ); connect( m_mentions.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( mentionsStatuses(const QList &) ) ); - connect( m_directMessages.data(), SIGNAL( parsedStatuses(const QList< QTweetDMStatus > &) ), SLOT( directMessages(const QList &) ) ); - connect( m_directMessageNew.data(), SIGNAL( parsedStatuses(const QList< QTweetDMStatus > &) ), SLOT( directMessagePosted(const QTweetDMStatus &) ) ); + connect( m_directMessages.data(), SIGNAL( parsedDirectMessages(const QList &)), SLOT( directMessages(const QList &) ) ); + connect( m_directMessageNew.data(), SIGNAL( parsedDirectMessage(const QTweetDMStatus &)), SLOT( directMessagePosted(const QTweetDMStatus &) ) ); connect( m_directMessageNew.data(), SIGNAL( error(QTweetNetBase::ErrorCode, const QString &) ), SLOT( directMessagePostError(QTweetNetBase::ErrorCode, const QString &) ) ); - connect( m_directMessageDestroy.data(), SIGNAL( parsedStatuses(const QList< QTweetDMStatus > &) ), SLOT( directMessageDestoyed(const QTweetDMStatus &) ) ); + connect( m_directMessageDestroy.data(), SIGNAL( parsedDirectMessage(const QTweetDMStatus &) ), SLOT( directMessageDestroyed(const QTweetDMStatus &) ) ); QMetaObject::invokeMethod( this, "checkTimerFired", Qt::AutoConnection ); } else @@ -376,7 +376,7 @@ TwitterPlugin::directMessagePostError( QTweetNetBase::ErrorCode errorCode, const } void -TwitterPlugin::directMessageDestroyed(const QTweetDMStatus& message) +TwitterPlugin::directMessageDestroyed( const QTweetDMStatus& message ) { qDebug() << Q_FUNC_INFO; qDebug() << "TwitterPlugin destroyed message " << message.text(); diff --git a/thirdparty/qtweetlib/src/qtweetnetbase.h b/thirdparty/qtweetlib/src/qtweetnetbase.h index 910193f3f..01f1ca7b4 100644 --- a/thirdparty/qtweetlib/src/qtweetnetbase.h +++ b/thirdparty/qtweetlib/src/qtweetnetbase.h @@ -89,7 +89,7 @@ signals: * In that case check response. * @remarks DOESN'T emit finished signal */ - void error(ErrorCode code, const QString& errorMsg); + void error(QTweetNetBase::ErrorCode code, const QString& errorMsg); protected slots: virtual void parsingJsonFinished(const QVariant& json, bool ok, const QString& errorMsg) = 0; From 893dfd038a25279ce85d2507865708a9251baeb0 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 20:23:22 -0500 Subject: [PATCH 21/62] Not sure if this could loop, but not going to risk it --- src/sip/twitter/twitter.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index bf7036f2d..5fa16488d 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -159,6 +159,7 @@ TwitterPlugin::connectTimerFired() if ( !isValid() || m_cachedPeers.isEmpty() ) return; + bool peersChanged = false; QList peerlist = m_cachedPeers.keys(); qStableSort( peerlist.begin(), peerlist.end() ); foreach( QString screenName, peerlist ) @@ -171,10 +172,20 @@ TwitterPlugin::connectTimerFired() peerData["ohst"].toString() != Servent::instance()->externalAddress() || peerData["oprt"].toInt() != Servent::instance()->externalPort() ) - QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + { + peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); + peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); + QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); + peersChanged = true; + + } else QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } + + if ( peersChanged ) + TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); } void From 7951003cbcc3be457ac989b8f8e36be9b950caf9 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 20:36:51 -0500 Subject: [PATCH 22/62] Hopefully prevent sending DMs to yourself --- src/libtomahawk/tomahawksettings.cpp | 14 ++++++++++++++ src/libtomahawk/tomahawksettings.h | 3 +++ src/settingsdialog.cpp | 1 + src/sip/twitter/twitter.cpp | 9 +++++++++ 4 files changed, 27 insertions(+) diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index 8f2f86941..bd0363e6d 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -426,6 +426,20 @@ TomahawkSettings::setLastFmUsername( const QString& username ) setValue( "lastfm/username", username ); } +QString +TomahawkSettings::twitterScreenName() const +{ + QMutexLocker locker( m_safety ); + return value( "twitter/ScreenName" ).toString(); +} + +void +TomahawkSettings::setTwitterScreenName( const QString& screenName ) +{ + QMutexLocker locker( m_safety ); + setValue( "twitter/ScreenName", screenName ); +} + QString TomahawkSettings::twitterOAuthToken() const { diff --git a/src/libtomahawk/tomahawksettings.h b/src/libtomahawk/tomahawksettings.h index f08b3be0c..249495026 100644 --- a/src/libtomahawk/tomahawksettings.h +++ b/src/libtomahawk/tomahawksettings.h @@ -97,6 +97,9 @@ public: void setLastFmSessionKey( const QByteArray& key ); /// Twitter settings + QString twitterScreenName() const; + void setTwitterScreenName( const QString& screenName ); + QString twitterOAuthToken() const; void setTwitterOAuthToken( const QString& oauthtoken ); diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 8b7ebc466..b6b90aa2e 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -345,6 +345,7 @@ SettingsDialog::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user ) return; } TomahawkSettings* s = TomahawkSettings::instance(); + s->setTwitterScreenName( user.screenName() ); TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this ); twitAuth->setNetworkAccessManager( TomahawkUtils::nam() ); twitAuth->setOAuthToken( s->twitterOAuthToken().toLatin1() ); diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 5fa16488d..accca9f5d 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -113,6 +113,7 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) m_isAuthed = true; if ( !m_twitterAuth.isNull() ) { + TomahawkSettings::instance()->setTwitterScreenName( user.screenName() ); m_friendsTimeline = QWeakPointer( new QTweetFriendsTimeline( m_twitterAuth.data(), this ) ); m_mentions = QWeakPointer( new QTweetMentions( m_twitterAuth.data(), this ) ); m_directMessages = QWeakPointer( new QTweetDirectMessages( m_twitterAuth.data(), this ) ); @@ -160,11 +161,13 @@ TwitterPlugin::connectTimerFired() return; bool peersChanged = false; + QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); QList peerlist = m_cachedPeers.keys(); qStableSort( peerlist.begin(), peerlist.end() ); foreach( QString screenName, peerlist ) { QHash< QString, QVariant > peerData = m_cachedPeers[screenName].toHash(); + if ( !peerData.contains( "node" ) || !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) continue; @@ -194,10 +197,13 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) qDebug() << Q_FUNC_INFO; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); bool peersChanged = false; + QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); foreach( QTweetStatus status, statuses ) { if ( status.id() > m_cachedFriendsSinceId ) m_cachedFriendsSinceId = status.id(); + if ( status.user().screenName() == myScreenName ) + continue; if ( regex.exactMatch( status.text() ) ) { qDebug() << "TwitterPlugin found an exact tweet from friend " << status.user().screenName(); @@ -230,10 +236,13 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) qDebug() << Q_FUNC_INFO; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); bool peersChanged = false; + QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); foreach( QTweetStatus status, statuses ) { if ( status.id() > m_cachedMentionsSinceId ) m_cachedMentionsSinceId = status.id(); + if ( status.user().screenName() == myScreenName ) + continue; if ( regex.exactMatch( status.text() ) ) { qDebug() << "TwitterPlugin found an exact matching mention from user " << status.user().screenName(); From d1e0b2cca210e4343adf85895974684dd877df69 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 20:49:18 -0500 Subject: [PATCH 23/62] Add some debugging --- src/sip/twitter/twitter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index accca9f5d..8de2c28f3 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -297,9 +297,13 @@ TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) foreach( QTweetDMStatus status, messages ) { + qDebug() << "TwitterPlugin checking direct message from " << status.senderScreenName() << " with content " << status.text(); if ( status.id() > m_cachedDirectMessagesSinceId ) m_cachedDirectMessagesSinceId = status.id(); QStringList splitList = status.text().split(':'); + qDebug() << "TwitterPlugin found " << splitList.length() << " parts to the message; the parts are:"; + foreach( QString part, splitList ) + qDebug() << part; if ( splitList.length() < 5 ) continue; if ( splitList[0] != "TOMAHAWKPEERSTART" ) From eccf96b2e220c63c8f480611b1f66dcb3dbf4b03 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 20:59:46 -0500 Subject: [PATCH 24/62] Fix bonehead error --- src/sip/twitter/twitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 8de2c28f3..e6bb6d92d 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -306,7 +306,7 @@ TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) qDebug() << part; if ( splitList.length() < 5 ) continue; - if ( splitList[0] != "TOMAHAWKPEERSTART" ) + if ( splitList[0] != "TOMAHAWKPEER" ) continue; if ( !splitList[1].startsWith( "Host=" ) || !splitList[2].startsWith( "Port=" ) || !splitList[3].startsWith( "Node=" ) || !splitList[4].startsWith( "PKey=" ) ) continue; From 12555372d65354935c796ee0710794f4788541d5 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 21:33:26 -0500 Subject: [PATCH 25/62] Actually register offers... --- src/sip/twitter/twitter.cpp | 18 ++++++++++-------- src/sip/twitter/twitter.h | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index e6bb6d92d..6c54b2993 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -64,7 +64,7 @@ TwitterPlugin::connectPlugin( bool /*startup*/ ) foreach( QString screenName, peerlist ) { QHash< QString, QVariant > cachedPeer = m_cachedPeers[screenName].toHash(); - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&cachedPeer ) ); + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&cachedPeer ), Q_ARG( bool, false ) ); } if ( settings->twitterOAuthToken().isEmpty() || settings->twitterOAuthTokenSecret().isEmpty() ) @@ -178,7 +178,7 @@ TwitterPlugin::connectTimerFired() { peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); - QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ), Q_ARG( bool, true ) ); m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); peersChanged = true; @@ -215,7 +215,7 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) peerData["okey"] = QVariant::fromValue< QString >( okey ); peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); - QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ), Q_ARG( bool, true ) ); m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); peersChanged = true; } @@ -254,7 +254,7 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) peerData["okey"] = QVariant::fromValue< QString >( okey ); peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); - QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ), Q_ARG( bool, true ) ); m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); peersChanged = true; } @@ -329,7 +329,7 @@ TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) m_cachedPeers[status.senderScreenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); peersChanged = true; - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.senderScreenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.senderScreenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ), Q_ARG( bool, true ) ); if ( !m_directMessageDestroy.isNull() ) m_directMessageDestroy.data()->destroyMessage( status.id() ); } @@ -357,7 +357,7 @@ TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, } void -TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerData ) +TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerData, bool sendOffer ) { qDebug() << Q_FUNC_INFO; if ( !peerData.contains( "node" ) || !peerData.contains( "okey" ) ) @@ -367,6 +367,8 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q } qDebug() << "TwitterPlugin registering offer to " << QString( '@' + screenName ) << " with node " << peerData["node"].toString() << " and offeredkey " << peerData["okey"].toString(); Servent::instance()->createConnectionKey( QString( '@' + screenName ), peerData["node"].toString(), peerData["okey"].toString() ); + if ( sendOffer ) + QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); if ( peerData.contains( "node" ) && peerData.contains( "host" ) && peerData.contains( "port" ) && peerData.contains( "pkey" ) ) QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } @@ -375,8 +377,8 @@ void TwitterPlugin::sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerData ) { qDebug() << Q_FUNC_INFO; - QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:Node=%3:PKey=%4" ).arg( Servent::instance()->externalAddress() ) - .arg( Servent::instance()->externalPort() ) + QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:Node=%3:PKey=%4" ).arg( peerData["ohst"].toString() ) + .arg( peerData["oprt"].toString() ) .arg( Database::instance()->dbid() ) .arg( peerData["okey"].toString() ); qDebug() << "TwitterPlugin sending message to " << screenName << ": " << offerString; diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index c9b7f365f..d36af1a3b 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -60,7 +60,7 @@ private slots: void directMessagePosted( const QTweetDMStatus &message ); void directMessagePostError( QTweetNetBase::ErrorCode errorCode, const QString &message ); void directMessageDestroyed( const QTweetDMStatus &message ); - void registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata ); + void registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata, bool sendOffer ); void sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata ); void makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerdata ); From 5c152033eab4ae90596bf66bd6ad86ce25ee0dd0 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 21:46:29 -0500 Subject: [PATCH 26/62] More debugging --- src/sip/twitter/twitter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 6c54b2993..ed632f7f1 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -362,7 +362,10 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q qDebug() << Q_FUNC_INFO; if ( !peerData.contains( "node" ) || !peerData.contains( "okey" ) ) { - qDebug() << "TwitterPlugin could not find node and/or okey for peer " << screenName; + if ( !peerData.contains( "okey" ) ) + qDebug() << "TwitterPlugin could not find okey to register offer for peer " << screenName; + if ( !peerData.contains( "node" ) ) + qDebug() << "TwitterPlugin could not find node to register offer for peer " << screenName; return; } qDebug() << "TwitterPlugin registering offer to " << QString( '@' + screenName ) << " with node " << peerData["node"].toString() << " and offeredkey " << peerData["okey"].toString(); From feaf5caa22a1f4e1b1cf0462fc256928069956aa Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 21:55:28 -0500 Subject: [PATCH 27/62] rejig what is used for the node to solve chicken+egg problem --- src/sip/twitter/twitter.cpp | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index ed632f7f1..498135306 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -168,7 +168,7 @@ TwitterPlugin::connectTimerFired() { QHash< QString, QVariant > peerData = m_cachedPeers[screenName].toHash(); - if ( !peerData.contains( "node" ) || !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) + if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) continue; if ( !peerData.contains( "ohst" ) || !peerData.contains( "oprt" ) || @@ -304,19 +304,18 @@ TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) qDebug() << "TwitterPlugin found " << splitList.length() << " parts to the message; the parts are:"; foreach( QString part, splitList ) qDebug() << part; - if ( splitList.length() < 5 ) + if ( splitList.length() != 4 ) continue; if ( splitList[0] != "TOMAHAWKPEER" ) continue; - if ( !splitList[1].startsWith( "Host=" ) || !splitList[2].startsWith( "Port=" ) || !splitList[3].startsWith( "Node=" ) || !splitList[4].startsWith( "PKey=" ) ) + if ( !splitList[1].startsWith( "Host=" ) || !splitList[2].startsWith( "Port=" ) || !splitList[3].startsWith( "PKey=" ) ) continue; int port = splitList[2].mid( 5 ).toInt(); if ( port == 0 ) continue; QString host = splitList[1].mid( 5 ); - QString node = splitList[3].mid( 5 ); - QString pkey = splitList[4].mid( 5 ); - qDebug() << "TwitterPlugin found a peerstart message from " << status.senderScreenName() << " with host " << host << " and port " << port << " and node " << node << " and pkey " << pkey; + QString pkey = splitList[3].mid( 5 ); + qDebug() << "TwitterPlugin found a peerstart message from " << status.senderScreenName() << " with host " << host << " and port " << port << " and pkey " << pkey; QHash< QString, QVariant > peerData; if ( m_cachedPeers.contains( status.senderScreenName() ) ) @@ -324,7 +323,6 @@ TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) peerData["host"] = QVariant::fromValue< QString >( host ); peerData["port"] = QVariant::fromValue< int >( port ); - peerData["node"] = QVariant::fromValue< QString >( node ); peerData["pkey"] = QVariant::fromValue< QString >( pkey ); m_cachedPeers[status.senderScreenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); peersChanged = true; @@ -343,36 +341,36 @@ void TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerData ) { qDebug() << Q_FUNC_INFO; - if ( !peerData.contains( "node" ) || !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) + if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) { - qDebug() << "TwitterPlugin could not find node and/or host and/or port and/or pkey for peer " << screenName; + qDebug() << "TwitterPlugin could not find host and/or port and/or pkey for peer " << screenName; return; } - if ( !Servent::instance()->connectedToSession( peerData["node"].toString() ) ) + QString node = QString( '@' + screenName ); + if ( !Servent::instance()->connectedToSession( node ) ) Servent::instance()->connectToPeer( peerData["host"].toString(), peerData["port"].toString().toInt(), peerData["pkey"].toString(), - QString( '@' + peerData["screenname"].toString() ), - peerData["node"].toString() ); + node, + node ); } void TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerData, bool sendOffer ) { qDebug() << Q_FUNC_INFO; - if ( !peerData.contains( "node" ) || !peerData.contains( "okey" ) ) + QString node = QString( '@' + screenName ); + if ( !peerData.contains( "okey" ) ) { if ( !peerData.contains( "okey" ) ) qDebug() << "TwitterPlugin could not find okey to register offer for peer " << screenName; - if ( !peerData.contains( "node" ) ) - qDebug() << "TwitterPlugin could not find node to register offer for peer " << screenName; return; } - qDebug() << "TwitterPlugin registering offer to " << QString( '@' + screenName ) << " with node " << peerData["node"].toString() << " and offeredkey " << peerData["okey"].toString(); - Servent::instance()->createConnectionKey( QString( '@' + screenName ), peerData["node"].toString(), peerData["okey"].toString() ); + qDebug() << "TwitterPlugin registering offer to " << node << " with node " << node << " and offeredkey " << peerData["okey"].toString(); + Servent::instance()->createConnectionKey( node, node, peerData["okey"].toString() ); if ( sendOffer ) QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); - if ( peerData.contains( "node" ) && peerData.contains( "host" ) && peerData.contains( "port" ) && peerData.contains( "pkey" ) ) + if ( peerData.contains( "host" ) && peerData.contains( "port" ) && peerData.contains( "pkey" ) ) QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } @@ -380,9 +378,8 @@ void TwitterPlugin::sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerData ) { qDebug() << Q_FUNC_INFO; - QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:Node=%3:PKey=%4" ).arg( peerData["ohst"].toString() ) + QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:PKey=%3" ).arg( peerData["ohst"].toString() ) .arg( peerData["oprt"].toString() ) - .arg( Database::instance()->dbid() ) .arg( peerData["okey"].toString() ); qDebug() << "TwitterPlugin sending message to " << screenName << ": " << offerString; if( !m_directMessageNew.isNull() ) From f62d2dacabca0f48bd086383441f71168d9bd30b Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 22:53:50 -0500 Subject: [PATCH 28/62] Massive code cleanup, and hopefully functional fixes too! --- src/sip/twitter/twitter.cpp | 156 ++++++++++++++++++------------------ src/sip/twitter/twitter.h | 4 +- 2 files changed, 81 insertions(+), 79 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 498135306..c51b8579a 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -23,6 +23,7 @@ TwitterPlugin::TwitterPlugin() , m_cachedMentionsSinceId( 0 ) , m_cachedDirectMessagesSinceId( 0 ) , m_cachedPeers() + , m_keyCache() , m_finishedFriends( false ) , m_finishedMentions( false ) { @@ -64,7 +65,7 @@ TwitterPlugin::connectPlugin( bool /*startup*/ ) foreach( QString screenName, peerlist ) { QHash< QString, QVariant > cachedPeer = m_cachedPeers[screenName].toHash(); - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&cachedPeer ), Q_ARG( bool, false ) ); + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&cachedPeer ) ); } if ( settings->twitterOAuthToken().isEmpty() || settings->twitterOAuthTokenSecret().isEmpty() ) @@ -160,7 +161,6 @@ TwitterPlugin::connectTimerFired() if ( !isValid() || m_cachedPeers.isEmpty() ) return; - bool peersChanged = false; QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); QList peerlist = m_cachedPeers.keys(); qStableSort( peerlist.begin(), peerlist.end() ); @@ -171,24 +171,8 @@ TwitterPlugin::connectTimerFired() if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) continue; - if ( !peerData.contains( "ohst" ) || !peerData.contains( "oprt" ) || - peerData["ohst"].toString() != Servent::instance()->externalAddress() || - peerData["oprt"].toInt() != Servent::instance()->externalPort() - ) - { - peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); - peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ), Q_ARG( bool, true ) ); - m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); - peersChanged = true; - - } - else - QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } - - if ( peersChanged ) - TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); } void @@ -196,7 +180,6 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << Q_FUNC_INFO; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); - bool peersChanged = false; QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); foreach( QTweetStatus status, statuses ) { @@ -210,21 +193,12 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) if ( !m_cachedPeers.contains( status.user().screenName() ) ) { QHash< QString, QVariant > peerData; - QString okey = QUuid::createUuid().toString().split( '-' ).last(); - okey.chop( 1 ); - peerData["okey"] = QVariant::fromValue< QString >( okey ); - peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); - peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ), Q_ARG( bool, true ) ); - m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); - peersChanged = true; + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } } } TomahawkSettings::instance()->setTwitterCachedFriendsSinceId( m_cachedFriendsSinceId ); - if ( peersChanged ) - TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); m_finishedFriends = true; QMetaObject::invokeMethod( this, "pollDirectMessages", Qt::AutoConnection ); @@ -235,7 +209,6 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << Q_FUNC_INFO; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); - bool peersChanged = false; QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); foreach( QTweetStatus status, statuses ) { @@ -249,21 +222,12 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) if ( !m_cachedPeers.contains( status.user().screenName() ) ) { QHash< QString, QVariant > peerData; - QString okey = QUuid::createUuid().toString().split( '-' ).last(); - okey.chop( 1 ); - peerData["okey"] = QVariant::fromValue< QString >( okey ); - peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); - peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ), Q_ARG( bool, true ) ); - m_cachedPeers[status.user().screenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); - peersChanged = true; + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } } } TomahawkSettings::instance()->setTwitterCachedMentionsSinceId( m_cachedMentionsSinceId ); - if ( peersChanged ) - TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); m_finishedMentions = true; QMetaObject::invokeMethod( this, "pollDirectMessages", Qt::AutoConnection ); @@ -317,24 +281,91 @@ TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) QString pkey = splitList[3].mid( 5 ); qDebug() << "TwitterPlugin found a peerstart message from " << status.senderScreenName() << " with host " << host << " and port " << port << " and pkey " << pkey; - QHash< QString, QVariant > peerData; - if ( m_cachedPeers.contains( status.senderScreenName() ) ) - peerData = m_cachedPeers[status.senderScreenName()].toHash(); + QHash< QString, QVariant > peerData = ( m_cachedPeers.contains( status.senderScreenName() ) ) ? + m_cachedPeers[status.senderScreenName()].toHash() : + QHash< QString, QVariant >(); peerData["host"] = QVariant::fromValue< QString >( host ); peerData["port"] = QVariant::fromValue< int >( port ); peerData["pkey"] = QVariant::fromValue< QString >( pkey ); + m_cachedPeers[status.senderScreenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); peersChanged = true; - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.senderScreenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ), Q_ARG( bool, true ) ); + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.senderScreenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + if ( !m_directMessageDestroy.isNull() ) m_directMessageDestroy.data()->destroyMessage( status.id() ); } - - TomahawkSettings::instance()->setTwitterCachedDirectMessagesSinceId( m_cachedDirectMessagesSinceId ); + if ( peersChanged ) TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); + + TomahawkSettings::instance()->setTwitterCachedDirectMessagesSinceId( m_cachedDirectMessagesSinceId ); +} + +void +TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerData ) +{ + qDebug() << Q_FUNC_INFO; + QString node = QString( '@' + screenName ); + bool peersChanged = false; + QHash< QString, QVariant > _peerData = peerData; + + bool needToSend = false; + bool needToAddToCache = false; + + if ( !_peerData.contains( "okey" ) ) + { + QString okey = QUuid::createUuid().toString().split( '-' ).last(); + okey.chop( 1 ); + _peerData["okey"] = QVariant::fromValue< QString >( okey ); + peersChanged = true; + needToAddToCache = true; + needToSend = true; + } + + if ( !m_keyCache.contains( _peerData["okey"].toString() ) ) + needToAddToCache = true; + + if ( !_peerData.contains( "ohst" ) || !_peerData.contains( "oprt" ) || + _peerData["ohst"].toString() != Servent::instance()->externalAddress() || + _peerData["oprt"].toInt() != Servent::instance()->externalPort() + ) + needToSend = true; + + if( needToAddToCache ) + { + qDebug() << "TwitterPlugin registering offer to " << node << " with node " << node << " and offeredkey " << _peerData["okey"].toString(); + m_keyCache << Servent::instance()->createConnectionKey( node, node, _peerData["okey"].toString() ); + } + + if( needToSend ) + { + _peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); + _peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); + m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( _peerData ); + peersChanged = true; + QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) ); + } + + if ( _peerData.contains( "host" ) && _peerData.contains( "port" ) && _peerData.contains( "pkey" ) ) + QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) ); + + if ( peersChanged ) + TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); +} + +void +TwitterPlugin::sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerData ) +{ + qDebug() << Q_FUNC_INFO; + QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:PKey=%3" ).arg( peerData["ohst"].toString() ) + .arg( peerData["oprt"].toString() ) + .arg( peerData["okey"].toString() ); + qDebug() << "TwitterPlugin sending message to " << screenName << ": " << offerString; + if( !m_directMessageNew.isNull() ) + m_directMessageNew.data()->post( screenName, offerString ); } void @@ -355,37 +386,6 @@ TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, node ); } -void -TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerData, bool sendOffer ) -{ - qDebug() << Q_FUNC_INFO; - QString node = QString( '@' + screenName ); - if ( !peerData.contains( "okey" ) ) - { - if ( !peerData.contains( "okey" ) ) - qDebug() << "TwitterPlugin could not find okey to register offer for peer " << screenName; - return; - } - qDebug() << "TwitterPlugin registering offer to " << node << " with node " << node << " and offeredkey " << peerData["okey"].toString(); - Servent::instance()->createConnectionKey( node, node, peerData["okey"].toString() ); - if ( sendOffer ) - QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); - if ( peerData.contains( "host" ) && peerData.contains( "port" ) && peerData.contains( "pkey" ) ) - QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); -} - -void -TwitterPlugin::sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerData ) -{ - qDebug() << Q_FUNC_INFO; - QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:PKey=%3" ).arg( peerData["ohst"].toString() ) - .arg( peerData["oprt"].toString() ) - .arg( peerData["okey"].toString() ); - qDebug() << "TwitterPlugin sending message to " << screenName << ": " << offerString; - if( !m_directMessageNew.isNull() ) - m_directMessageNew.data()->post( screenName, offerString ); -} - void TwitterPlugin::directMessagePosted( const QTweetDMStatus& message ) { diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index d36af1a3b..e409554ce 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -60,7 +61,7 @@ private slots: void directMessagePosted( const QTweetDMStatus &message ); void directMessagePostError( QTweetNetBase::ErrorCode errorCode, const QString &message ); void directMessageDestroyed( const QTweetDMStatus &message ); - void registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata, bool sendOffer ); + void registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata ); void sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata ); void makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerdata ); @@ -78,6 +79,7 @@ private: qint64 m_cachedMentionsSinceId; qint64 m_cachedDirectMessagesSinceId; QHash< QString, QVariant > m_cachedPeers; + QSet m_keyCache; bool m_finishedFriends; bool m_finishedMentions; }; From b6cb99fa670ff3bc73fecb4f689da948c07d3685 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 23:16:53 -0500 Subject: [PATCH 29/62] Ignore all but the lastest DM from a particular user --- src/sip/twitter/twitter.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index c51b8579a..c92520752 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -258,8 +258,21 @@ TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) qDebug() << Q_FUNC_INFO; bool peersChanged = false; + + QHash< QString, QTweetDMStatus > latestHash; - foreach( QTweetDMStatus status, messages ) + foreach ( QTweetDMStatus status, messages ) + { + if ( !latestHash.contains( status.senderScreenName() ) ) + latestHash[status.senderScreenName()] = status; + else + { + if ( status.id() > latestHash[status.senderScreenName()].id() ) + latestHash[status.senderScreenName()] = status; + } + } + + foreach( QTweetDMStatus status, latestHash.values() ) { qDebug() << "TwitterPlugin checking direct message from " << status.senderScreenName() << " with content " << status.text(); if ( status.id() > m_cachedDirectMessagesSinceId ) From 64bb73ded27c1c4d360d0a28cbc55fc1e9a8155b Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 23:25:16 -0500 Subject: [PATCH 30/62] A bit more debugging --- src/libtomahawk/network/servent.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libtomahawk/network/servent.cpp b/src/libtomahawk/network/servent.cpp index 978d712ff..2b043e9bc 100644 --- a/src/libtomahawk/network/servent.cpp +++ b/src/libtomahawk/network/servent.cpp @@ -125,6 +125,7 @@ Servent::startListening( QHostAddress ha, bool upnp, int port ) QString Servent::createConnectionKey( const QString& name, const QString &nodeid, const QString &key ) { + qDebug() << Q_FUNC_INFO; Q_ASSERT( this->thread() == QThread::currentThread() ); QString _key = ( key.isEmpty() ? uuid() : key ); @@ -132,6 +133,7 @@ Servent::createConnectionKey( const QString& name, const QString &nodeid, const cc->setName( name.isEmpty() ? QString( "KEY(%1)" ).arg( key ) : name ); if( !nodeid.isEmpty() ) cc->setId( nodeid ); + qDebug() << "Creating connection key with name of " << cc->name() << " and id of " << cc->id() << " and key of " << _key; registerOffer( _key, cc ); return _key; } From a961b7086b848b9b39027256fedcb94156777ee9 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 12 Feb 2011 23:29:52 -0500 Subject: [PATCH 31/62] Remove onceOnly connection type for twitter sessions --- src/libtomahawk/network/servent.cpp | 5 +++-- src/libtomahawk/network/servent.h | 2 +- src/sip/twitter/twitter.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libtomahawk/network/servent.cpp b/src/libtomahawk/network/servent.cpp index 2b043e9bc..87d48a8b1 100644 --- a/src/libtomahawk/network/servent.cpp +++ b/src/libtomahawk/network/servent.cpp @@ -123,7 +123,7 @@ Servent::startListening( QHostAddress ha, bool upnp, int port ) QString -Servent::createConnectionKey( const QString& name, const QString &nodeid, const QString &key ) +Servent::createConnectionKey( const QString& name, const QString &nodeid, const QString &key, bool onceOnly ) { qDebug() << Q_FUNC_INFO; Q_ASSERT( this->thread() == QThread::currentThread() ); @@ -133,7 +133,8 @@ Servent::createConnectionKey( const QString& name, const QString &nodeid, const cc->setName( name.isEmpty() ? QString( "KEY(%1)" ).arg( key ) : name ); if( !nodeid.isEmpty() ) cc->setId( nodeid ); - qDebug() << "Creating connection key with name of " << cc->name() << " and id of " << cc->id() << " and key of " << _key; + cc->setOnceOnly( onceOnly ); + qDebug() << "Creating connection key with name of " << cc->name() << " and id of " << cc->id() << " and key of " << _key << "; key is once only? : " << (onceOnly ? "true" : "false"); registerOffer( _key, cc ); return _key; } diff --git a/src/libtomahawk/network/servent.h b/src/libtomahawk/network/servent.h index add40c098..d67fedd2a 100644 --- a/src/libtomahawk/network/servent.h +++ b/src/libtomahawk/network/servent.h @@ -78,7 +78,7 @@ public: int port() const { return m_port; } // creates new token that allows a controlconnection to be set up - QString createConnectionKey( const QString& name = "", const QString &nodeid = "", const QString &key = "" ); + QString createConnectionKey( const QString& name = "", const QString &nodeid = "", const QString &key = "", bool onceOnly = true ); void registerOffer( const QString& key, Connection* conn ); diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index c92520752..6f92fdff7 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -350,7 +350,7 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q if( needToAddToCache ) { qDebug() << "TwitterPlugin registering offer to " << node << " with node " << node << " and offeredkey " << _peerData["okey"].toString(); - m_keyCache << Servent::instance()->createConnectionKey( node, node, _peerData["okey"].toString() ); + m_keyCache << Servent::instance()->createConnectionKey( node, node, _peerData["okey"].toString(), false ); } if( needToSend ) From f924643bfed82b321bd6dfb4401d6cdd508a26f1 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 13 Feb 2011 05:54:29 +0100 Subject: [PATCH 32/62] * Reset ControlConnection's id when we received the first packet. --- src/libtomahawk/network/servent.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libtomahawk/network/servent.cpp b/src/libtomahawk/network/servent.cpp index 87d48a8b1..a405444f9 100644 --- a/src/libtomahawk/network/servent.cpp +++ b/src/libtomahawk/network/servent.cpp @@ -267,6 +267,8 @@ Servent::readyRead() if( !nodeid.isEmpty() && cc != 0 ) // only control connections send nodeid { + cc->setId( nodeid ); + foreach( ControlConnection* con, m_controlconnections ) { qDebug() << con->socket() << sock; From f097bc067dbe69e3e1ce7084ec4791e919114430 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 00:08:28 -0500 Subject: [PATCH 33/62] Don't connect when offline --- src/sip/twitter/twitter.cpp | 8 ++++++-- src/sip/twitter/twitter.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 6f92fdff7..5a4a4e1f9 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -17,6 +17,7 @@ TwitterPlugin::TwitterPlugin() : SipPlugin() , m_isAuthed( false ) + , m_isOnline( false ) , m_checkTimer( this ) , m_connectTimer( this ) , m_cachedFriendsSinceId( 0 ) @@ -83,7 +84,7 @@ TwitterPlugin::connectPlugin( bool /*startup*/ ) QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this ); connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) ); credVerifier->verify(); - + return true; } @@ -98,6 +99,8 @@ TwitterPlugin::disconnectPlugin() TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); m_cachedPeers.empty(); + delete m_twitterAuth.data(); + m_isOnline = false; } void @@ -126,6 +129,7 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) connect( m_directMessageNew.data(), SIGNAL( parsedDirectMessage(const QTweetDMStatus &)), SLOT( directMessagePosted(const QTweetDMStatus &) ) ); connect( m_directMessageNew.data(), SIGNAL( error(QTweetNetBase::ErrorCode, const QString &) ), SLOT( directMessagePostError(QTweetNetBase::ErrorCode, const QString &) ) ); connect( m_directMessageDestroy.data(), SIGNAL( parsedDirectMessage(const QTweetDMStatus &) ), SLOT( directMessageDestroyed(const QTweetDMStatus &) ) ); + m_isOnline = true; QMetaObject::invokeMethod( this, "checkTimerFired", Qt::AutoConnection ); } else @@ -362,7 +366,7 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) ); } - if ( _peerData.contains( "host" ) && _peerData.contains( "port" ) && _peerData.contains( "pkey" ) ) + if ( m_isOnline && _peerData.contains( "host" ) && _peerData.contains( "port" ) && _peerData.contains( "pkey" ) ) QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) ); if ( peersChanged ) diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index e409554ce..2e1c07b84 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -73,6 +73,7 @@ private: QWeakPointer< QTweetDirectMessageNew > m_directMessageNew; QWeakPointer< QTweetDirectMessageDestroy > m_directMessageDestroy; bool m_isAuthed; + bool m_isOnline; QTimer m_checkTimer; QTimer m_connectTimer; qint64 m_cachedFriendsSinceId; From 0a3913970345f43dbaac55993934cfa360767a8c Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 00:22:53 -0500 Subject: [PATCH 34/62] Now zeroconf doesn't connect when offline either --- src/sip/zeroconf/zeroconf.cpp | 25 +++++++++++++++++++++++++ src/sip/zeroconf/zeroconf.h | 8 +++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/sip/zeroconf/zeroconf.cpp b/src/sip/zeroconf/zeroconf.cpp index c4b692214..e4d7783c7 100644 --- a/src/sip/zeroconf/zeroconf.cpp +++ b/src/sip/zeroconf/zeroconf.cpp @@ -17,15 +17,40 @@ ZeroconfPlugin::connectPlugin( bool /*startup*/ ) SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) ); m_zeroconf->advertise(); + + m_isOnline = true; + + foreach( QStringList *currNode, m_cachedNodes ) + { + QStringList nodeSet = *currNode; + if ( !Servent::instance()->connectedToSession( nodeSet[3] ) ) + Servent::instance()->connectToPeer( nodeSet[0], nodeSet[1].toInt(), "whitelist", nodeSet[2], nodeSet[3] ); + delete currNode; + } + m_cachedNodes.empty(); return true; } +void +ZeroconfPlugin::disconnectPlugin() +{ + m_isOnline = false; +} void ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ) { qDebug() << "Found LAN host:" << host << port << nodeid; + + if ( !m_isOnline ) + { + qDebug() << "Not online, so not connecting"; + QStringList *nodeSet = new QStringList(); + *nodeSet << host << QString::number( port ) << name << nodeid; + m_cachedNodes.insert( nodeSet ); + return; + } if ( !Servent::instance()->connectedToSession( nodeid ) ) Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid ); diff --git a/src/sip/zeroconf/zeroconf.h b/src/sip/zeroconf/zeroconf.h index 164a1c545..727bb84c0 100644 --- a/src/sip/zeroconf/zeroconf.h +++ b/src/sip/zeroconf/zeroconf.h @@ -16,6 +16,8 @@ class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin public: ZeroconfPlugin() : m_zeroconf( 0 ) + , m_isOnline( false ) + , m_cachedNodes() {} virtual ~ZeroconfPlugin() {} @@ -26,9 +28,7 @@ public: public slots: virtual bool connectPlugin( bool startup ); - void disconnectPlugin() - { - } + void disconnectPlugin(); void sendMsg( const QString& to, const QString& msg ) { @@ -47,6 +47,8 @@ private slots: private: TomahawkZeroconf* m_zeroconf; + bool m_isOnline; + QSet< QStringList* > m_cachedNodes; }; #endif From ab9d79e21f14a9d0bcefa0f6d3a7a7fff17071bb Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 00:30:18 -0500 Subject: [PATCH 35/62] Add fixme note --- src/sip/zeroconf/zeroconf.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sip/zeroconf/zeroconf.cpp b/src/sip/zeroconf/zeroconf.cpp index e4d7783c7..91382c468 100644 --- a/src/sip/zeroconf/zeroconf.cpp +++ b/src/sip/zeroconf/zeroconf.cpp @@ -43,6 +43,7 @@ ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name { qDebug() << "Found LAN host:" << host << port << nodeid; + //FIXME: This doesn't work...why? I never see Found LAN host in debug either, but somehow nodes are being connected... if ( !m_isOnline ) { qDebug() << "Not online, so not connecting"; From 312537fc8a78d5a791e964dce7e21c9592fd239d Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 00:36:54 -0500 Subject: [PATCH 36/62] Now that it's not just jabber that is autoconnected, don't ignore the option... --- src/sip/SipHandler.cpp | 2 +- src/tomahawkapp.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sip/SipHandler.cpp b/src/sip/SipHandler.cpp index 59f846638..d9f524ba0 100644 --- a/src/sip/SipHandler.cpp +++ b/src/sip/SipHandler.cpp @@ -13,8 +13,8 @@ SipHandler::SipHandler( QObject* parent ) : QObject( parent ) + , m_connected( false ) { - m_connected = false; loadPlugins( findPlugins() ); } diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index 99d7ea296..6ab88a607 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -418,7 +418,8 @@ TomahawkApp::setupSIP() { qDebug() << Q_FUNC_INFO; - if( !arguments().contains( "--nosip" ) ) + //FIXME: jabber autoconnect is really more, now that there is sip -- should be renamed and/or split out of jabber-specific settings + if( !arguments().contains( "--nosip" ) && TomahawkSettings::instance()->jabberAutoConnect() ) { m_xmppBot = new XMPPBot( this ); qDebug() << "Connecting SIP classes"; From 6f7c9f4bc8ad8792808eb8eff50947df881e4305 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 13 Feb 2011 06:49:02 +0100 Subject: [PATCH 37/62] * Fix broken duplicate connection check. --- src/libtomahawk/network/servent.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libtomahawk/network/servent.cpp b/src/libtomahawk/network/servent.cpp index a405444f9..03d8d8d3a 100644 --- a/src/libtomahawk/network/servent.cpp +++ b/src/libtomahawk/network/servent.cpp @@ -265,10 +265,8 @@ Servent::readyRead() qDebug() << m; - if( !nodeid.isEmpty() && cc != 0 ) // only control connections send nodeid + if( !nodeid.isEmpty() ) // only control connections send nodeid { - cc->setId( nodeid ); - foreach( ControlConnection* con, m_controlconnections ) { qDebug() << con->socket() << sock; From d7182437d3fc71a315f5f9cca26854821b4adc98 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 01:28:05 -0500 Subject: [PATCH 38/62] Re-send on "Got Tomahawk?" tweets even if you already have them in your peercache --- src/sip/twitter/twitter.cpp | 69 +++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 19 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 5a4a4e1f9..c5e8db714 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -66,6 +66,8 @@ TwitterPlugin::connectPlugin( bool /*startup*/ ) foreach( QString screenName, peerlist ) { QHash< QString, QVariant > cachedPeer = m_cachedPeers[screenName].toHash(); + foreach( QString prop, cachedPeer.keys() ) + qDebug() << "TwitterPlugin : " << screenName << ", key " << prop << ", value " << ( cachedPeer[prop].canConvert< QString >() ? cachedPeer[prop].toString() : QString::number( cachedPeer[prop].toInt() ) ); QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&cachedPeer ) ); } @@ -97,7 +99,6 @@ TwitterPlugin::disconnectPlugin() if( !m_twitterAuth.isNull() ) m_twitterAuth.data()->deleteLater(); - TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); m_cachedPeers.empty(); delete m_twitterAuth.data(); m_isOnline = false; @@ -185,7 +186,20 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) qDebug() << Q_FUNC_INFO; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); - foreach( QTweetStatus status, statuses ) + + QHash< QString, QTweetStatus > latestHash; + foreach ( QTweetStatus status, statuses ) + { + if ( !latestHash.contains( status.user().screenName() ) ) + latestHash[status.user().screenName()] = status; + else + { + if ( status.id() > latestHash[status.user().screenName()].id() ) + latestHash[status.user().screenName()] = status; + } + } + + foreach( QTweetStatus status, latestHash.values() ) { if ( status.id() > m_cachedFriendsSinceId ) m_cachedFriendsSinceId = status.id(); @@ -194,11 +208,14 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) if ( regex.exactMatch( status.text() ) ) { qDebug() << "TwitterPlugin found an exact tweet from friend " << status.user().screenName(); - if ( !m_cachedPeers.contains( status.user().screenName() ) ) + QHash< QString, QVariant > peerData; + if( m_cachedPeers.contains( status.user().screenName() ) ) { - QHash< QString, QVariant > peerData; - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + peerData = m_cachedPeers[status.user().screenName()].toHash(); + //force a re-send of info but no need to re-register + peerData["oprt"] = Servent::instance()->externalPort() + 1; } + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } } @@ -214,7 +231,20 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) qDebug() << Q_FUNC_INFO; QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); - foreach( QTweetStatus status, statuses ) + + QHash< QString, QTweetStatus > latestHash; + foreach ( QTweetStatus status, statuses ) + { + if ( !latestHash.contains( status.user().screenName() ) ) + latestHash[status.user().screenName()] = status; + else + { + if ( status.id() > latestHash[status.user().screenName()].id() ) + latestHash[status.user().screenName()] = status; + } + } + + foreach( QTweetStatus status, latestHash.values() ) { if ( status.id() > m_cachedMentionsSinceId ) m_cachedMentionsSinceId = status.id(); @@ -223,11 +253,14 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) if ( regex.exactMatch( status.text() ) ) { qDebug() << "TwitterPlugin found an exact matching mention from user " << status.user().screenName(); - if ( !m_cachedPeers.contains( status.user().screenName() ) ) + QHash< QString, QVariant > peerData; + if( m_cachedPeers.contains( status.user().screenName() ) ) { - QHash< QString, QVariant > peerData; - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); + peerData = m_cachedPeers[status.user().screenName()].toHash(); + //force a re-send of info but no need to re-register + peerData["oprt"] = Servent::instance()->externalPort() + 1; } + QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } } @@ -261,10 +294,7 @@ TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) { qDebug() << Q_FUNC_INFO; - bool peersChanged = false; - QHash< QString, QTweetDMStatus > latestHash; - foreach ( QTweetDMStatus status, messages ) { if ( !latestHash.contains( status.senderScreenName() ) ) @@ -305,19 +335,14 @@ TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) peerData["host"] = QVariant::fromValue< QString >( host ); peerData["port"] = QVariant::fromValue< int >( port ); peerData["pkey"] = QVariant::fromValue< QString >( pkey ); + peerData["dirty"] = QVariant::fromValue< bool >( true ); - m_cachedPeers[status.senderScreenName()] = QVariant::fromValue< QHash< QString, QVariant > >( peerData ); - peersChanged = true; - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.senderScreenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); if ( !m_directMessageDestroy.isNull() ) m_directMessageDestroy.data()->destroyMessage( status.id() ); } - if ( peersChanged ) - TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); - TomahawkSettings::instance()->setTwitterCachedDirectMessagesSinceId( m_cachedDirectMessagesSinceId ); } @@ -327,11 +352,17 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q qDebug() << Q_FUNC_INFO; QString node = QString( '@' + screenName ); bool peersChanged = false; - QHash< QString, QVariant > _peerData = peerData; + QHash< QString, QVariant > _peerData( peerData ); bool needToSend = false; bool needToAddToCache = false; + if ( _peerData.contains( "dirty" ) ) + { + peersChanged = true; + _peerData.remove( "dirty" ); + } + if ( !_peerData.contains( "okey" ) ) { QString okey = QUuid::createUuid().toString().split( '-' ).last(); From 90295cde29a836bfad201e4487f802184ccd03a4 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 01:46:38 -0500 Subject: [PATCH 39/62] Don't send offers that you can never actually resolve (i.e. empty) --- src/sip/twitter/twitter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index c5e8db714..22087ee7b 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -393,8 +393,9 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q _peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); _peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( _peerData ); - peersChanged = true; - QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) ); + peersChanged = true; + if( !Servent::instance()->externalAddress().isEmpty() && !Servent::instance()->externalPort() == 0 ) + QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) ); } if ( m_isOnline && _peerData.contains( "host" ) && _peerData.contains( "port" ) && _peerData.contains( "pkey" ) ) From 16fc949f53b5d8e9db37cbf1079c85fa7f2fa147 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 11:29:02 -0500 Subject: [PATCH 40/62] Only honor Got Tomahawk statuses sent to a particular person if the message is directed at you --- src/sip/twitter/twitter.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 22087ee7b..df6d30df3 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -184,7 +184,7 @@ void TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << Q_FUNC_INFO; - QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); + QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$", Qt::CaseSensitive, QRegExp::RegExp2 ) ); QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); QHash< QString, QTweetStatus > latestHash; @@ -208,6 +208,11 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) if ( regex.exactMatch( status.text() ) ) { qDebug() << "TwitterPlugin found an exact tweet from friend " << status.user().screenName(); + if ( status.text().startsWith( '@' ) && regex.captureCount() >= 2 && regex.cap( 1 ) != QString( '@' + myScreenName ) ) + { + qDebug() << "TwitterPlugin skipping tweet because it's directed @someone that isn't us"; + continue; + } QHash< QString, QVariant > peerData; if( m_cachedPeers.contains( status.user().screenName() ) ) { @@ -229,7 +234,7 @@ void TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << Q_FUNC_INFO; - QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ) ); + QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$", Qt::CaseSensitive, QRegExp::RegExp2 ) ); QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); QHash< QString, QTweetStatus > latestHash; @@ -253,6 +258,11 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) if ( regex.exactMatch( status.text() ) ) { qDebug() << "TwitterPlugin found an exact matching mention from user " << status.user().screenName(); + if ( status.text().startsWith( '@' ) && regex.captureCount() >= 2 && regex.cap( 1 ) != QString( '@' + myScreenName ) ) + { + qDebug() << "TwitterPlugin skipping mention because it's directed @someone that isn't us"; + continue; + } QHash< QString, QVariant > peerData; if( m_cachedPeers.contains( status.user().screenName() ) ) { From d48a7b11fad89cc57ba48671faf05df399f39da0 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 11:33:51 -0500 Subject: [PATCH 41/62] At what point did I forget to actually check compilation before committing? blech --- src/sip/twitter/twitter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index df6d30df3..a2fa582e2 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -184,7 +184,7 @@ void TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << Q_FUNC_INFO; - QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$", Qt::CaseSensitive, QRegExp::RegExp2 ) ); + QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ), Qt::CaseSensitive, QRegExp::RegExp2 ); QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); QHash< QString, QTweetStatus > latestHash; @@ -234,7 +234,7 @@ void TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << Q_FUNC_INFO; - QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$", Qt::CaseSensitive, QRegExp::RegExp2 ) ); + QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ), Qt::CaseSensitive, QRegExp::RegExp2 ); QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); QHash< QString, QTweetStatus > latestHash; From b3acdd3795aef0053b389e9f8d9980754e40734f Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 12:41:39 -0500 Subject: [PATCH 42/62] Send node information in initial Got Tomahawk message --- src/settingsdialog.cpp | 12 +++++- src/settingsdialog.h | 4 +- src/settingsdialog.ui | 8 +++- src/sip/twitter/twitter.cpp | 75 ++++++++++++++++++++++++++++++------- 4 files changed, 81 insertions(+), 18 deletions(-) diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index b6b90aa2e..3b66be646 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -21,6 +21,7 @@ #include "tomahawksettings.h" #include "sip/SipHandler.h" #include "sip/twitter/tomahawkoauthtwitter.h" +#include static QString md5( const QByteArray& src ) @@ -314,6 +315,7 @@ SettingsDialog::authenticateTwitter() ui->twitterStatusLabel->setText("Status: No saved credentials"); ui->twitterAuthenticateButton->setText( "Authenticate" ); ui->twitterInstructionsBox->setVisible( false ); + QMessageBox::critical( 0, QString("Tweetin' Error"), QString("There was an error validating your authentication") ); } } @@ -352,8 +354,9 @@ SettingsDialog::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user ) twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() ); QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( twitAuth, this ); connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postGotTomahawkStatusUpdateReply(const QTweetStatus &) ) ); + connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) ); QString uuid = QUuid::createUuid(); - statUpdate->post( QString( "Got Tomahawk? (" ) + uuid.mid( 1, 8 ) + ")" ); + statUpdate->post( QString( "Got Tomahawk? {" ) + Database::instance()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) ); } void @@ -364,6 +367,13 @@ SettingsDialog::postGotTomahawkStatusUpdateReply( const QTweetStatus& status ) else QMessageBox::information( 0, QString("Tweeted!"), QString("Your tweet has been posted!") ); } +void +SettingsDialog::postGotTomahawkStatusUpdateError( QTweetNetBase::ErrorCode code, const QString& errorMsg ) +{ + qDebug() << Q_FUNC_INFO; + qDebug() << "Error posting Got Tomahawk message, error code is " << code << ", error message is " << errorMsg; + QMessageBox::critical( 0, QString("Tweetin' Error"), QString("There was an error posting your status -- sorry!") ); +} ProxyDialog::ProxyDialog( QWidget *parent ) : QDialog( parent ) diff --git a/src/settingsdialog.h b/src/settingsdialog.h index 1912ce730..72ba47ad7 100644 --- a/src/settingsdialog.h +++ b/src/settingsdialog.h @@ -5,6 +5,7 @@ #include #include +#include class QNetworkReply; @@ -58,7 +59,8 @@ private slots: void startPostGotTomahawkStatus(); void postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user ); void postGotTomahawkStatusUpdateReply( const QTweetStatus &status ); - + void postGotTomahawkStatusUpdateError( QTweetNetBase::ErrorCode, const QString &errorMsg ); + void addScriptResolver(); void scriptSelectionChanged(); void removeScriptResolver(); diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index c0c29c599..616de8780 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -473,16 +473,20 @@ When you press the button your web browser will launch and take you to Twitter.c - How it works is simple: just tweet "Got Tomahawk?" and be (very) patient. It can take a bit. + How it works is simple: just press the button below to tweet "Got Tomahawk?" and some necessary information. Then be (very) patient. Twitter is an asynchronous protocol so it can take a bit! +If connections to peers seem to have been lost, just press the button again to re-post a tweet for resynchronization. + + true + - Press here if you'd like to have Tomahawk tweet this for you + Press here to have Tomahawk post a tweet diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index a2fa582e2..9aca46149 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -184,7 +184,7 @@ void TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << Q_FUNC_INFO; - QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ), Qt::CaseSensitive, QRegExp::RegExp2 ); + QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?(Got Tomahawk\\?) (\\{[a-fA-F0-9\\-]+\\}) (.*)$" ), Qt::CaseSensitive, QRegExp::RegExp2 ); QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); QHash< QString, QTweetStatus > latestHash; @@ -213,13 +213,33 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) qDebug() << "TwitterPlugin skipping tweet because it's directed @someone that isn't us"; continue; } + + QString node; + for ( int i = 0; i < regex.captureCount(); ++i ) + { + if ( regex.cap( i ) == QString( "Got Tomahawk?" ) ) + { + QString nodeCap = regex.cap( i + 1 ); + nodeCap.chop( 1 ); + node = nodeCap.mid( 1 ); + } + } + if ( node.isEmpty() ) + { + qDebug() << "TwitterPlugin could not parse node out of the tweet"; + continue; + } + else + qDebug() << "TwitterPlugin parsed node " << node << " out of the tweet"; + QHash< QString, QVariant > peerData; if( m_cachedPeers.contains( status.user().screenName() ) ) { peerData = m_cachedPeers[status.user().screenName()].toHash(); //force a re-send of info but no need to re-register - peerData["oprt"] = Servent::instance()->externalPort() + 1; + peerData["resend"] = QVariant::fromValue< bool >( true ); } + peerData["node"] = QVariant::fromValue< QString >( node ); QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } } @@ -234,7 +254,7 @@ void TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) { qDebug() << Q_FUNC_INFO; - QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?Got Tomahawk\\?(.*)$" ), Qt::CaseSensitive, QRegExp::RegExp2 ); + QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?(Got Tomahawk\\?) (\\{[a-fA-F0-9\\-]+\\}) (.*)$" ), Qt::CaseSensitive, QRegExp::RegExp2 ); QString myScreenName = TomahawkSettings::instance()->twitterScreenName(); QHash< QString, QTweetStatus > latestHash; @@ -263,13 +283,33 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) qDebug() << "TwitterPlugin skipping mention because it's directed @someone that isn't us"; continue; } + + QString node; + for ( int i = 0; i < regex.captureCount(); ++i ) + { + if ( regex.cap( i ) == QString( "Got Tomahawk?" ) ) + { + QString nodeCap = regex.cap( i + 1 ); + nodeCap.chop( 1 ); + node = nodeCap.mid( 1 ); + } + } + if ( node.isEmpty() ) + { + qDebug() << "TwitterPlugin could not parse node out of the tweet"; + continue; + } + else + qDebug() << "TwitterPlugin parsed node " << node << " out of the tweet"; + QHash< QString, QVariant > peerData; if( m_cachedPeers.contains( status.user().screenName() ) ) { peerData = m_cachedPeers[status.user().screenName()].toHash(); //force a re-send of info but no need to re-register - peerData["oprt"] = Servent::instance()->externalPort() + 1; + peerData["resend"] = QVariant::fromValue< bool >( true ); } + peerData["node"] = QVariant::fromValue< QString >( node ); QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } } @@ -360,7 +400,7 @@ void TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerData ) { qDebug() << Q_FUNC_INFO; - QString node = QString( '@' + screenName ); + QString friendlyName = QString( '@' + screenName ); bool peersChanged = false; QHash< QString, QVariant > _peerData( peerData ); @@ -373,6 +413,13 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q _peerData.remove( "dirty" ); } + if ( _peerData.contains( "resend" ) ) + { + needToSend = true; + peersChanged = true; + _peerData.remove( "resend" ); + } + if ( !_peerData.contains( "okey" ) ) { QString okey = QUuid::createUuid().toString().split( '-' ).last(); @@ -392,13 +439,13 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q ) needToSend = true; - if( needToAddToCache ) + if( needToAddToCache && _peerData.contains( "node" ) ) { - qDebug() << "TwitterPlugin registering offer to " << node << " with node " << node << " and offeredkey " << _peerData["okey"].toString(); - m_keyCache << Servent::instance()->createConnectionKey( node, node, _peerData["okey"].toString(), false ); + qDebug() << "TwitterPlugin registering offer to " << friendlyName << " with node " << _peerData["node"].toString() << " and offeredkey " << _peerData["okey"].toString(); + m_keyCache << Servent::instance()->createConnectionKey( friendlyName, _peerData["node"].toString(), _peerData["okey"].toString(), false ); } - if( needToSend ) + if( needToSend && _peerData.contains( "node") ) { _peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); _peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); @@ -431,18 +478,18 @@ void TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerData ) { qDebug() << Q_FUNC_INFO; - if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) + if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) || !peerData.contains( "node" ) ) { qDebug() << "TwitterPlugin could not find host and/or port and/or pkey for peer " << screenName; return; } - QString node = QString( '@' + screenName ); - if ( !Servent::instance()->connectedToSession( node ) ) + QString friendlyName = QString( '@' + screenName ); + if ( !Servent::instance()->connectedToSession( peerData["node"].toString() ) ) Servent::instance()->connectToPeer( peerData["host"].toString(), peerData["port"].toString().toInt(), peerData["pkey"].toString(), - node, - node ); + friendlyName, + peerData["node"].toString() ); } void From 7005d6f1236a227478f795c702a37927f400dd38 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 13:35:38 -0500 Subject: [PATCH 43/62] Add twitter key file to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cb16342d6..12b7b33f7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ Makefile* moc_* *~ /tomahawk +WARNING-twitter-api-keys From 98bd3d226c68446afd73518699f3a283c208766c Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 13:39:22 -0500 Subject: [PATCH 44/62] Remove twitter api keys from oauth.cpp, they've been regenerated --- thirdparty/qtweetlib/src/oauth.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thirdparty/qtweetlib/src/oauth.cpp b/thirdparty/qtweetlib/src/oauth.cpp index 3214bb8b1..28c4a91d9 100644 --- a/thirdparty/qtweetlib/src/oauth.cpp +++ b/thirdparty/qtweetlib/src/oauth.cpp @@ -25,11 +25,11 @@ #include "oauth.h" #ifndef CONSUMER_KEY - #define CONSUMER_KEY "B92heFT38GQtmnVnAzAdg" + #define CONSUMER_KEY "" #endif //CONSUMER_KEY #ifndef CONSUMER_SECRET - #define CONSUMER_SECRET "nDJpSsXXBIFFIB2XrkwBL48h0ztsBUZ939CX1sh1U" + #define CONSUMER_SECRET "" #endif //CONSUMER_SECRET /** From 0f55df58a5dbf77dfe2a4fdcb6c2087cc1544c4f Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 13:41:36 -0500 Subject: [PATCH 45/62] Move location of twitter api key include --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 12b7b33f7..7a9999082 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ Makefile* moc_* *~ /tomahawk -WARNING-twitter-api-keys +thirdparty/qtweetlib/WARNING-twitter-api-keys From 202e43668ccece9586626e0312ca567f9cc745aa Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 13:51:45 -0500 Subject: [PATCH 46/62] Cmake will now source a file with the necessary property definitions --- thirdparty/qtweetlib/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/thirdparty/qtweetlib/CMakeLists.txt b/thirdparty/qtweetlib/CMakeLists.txt index 38c738e03..431604c3f 100644 --- a/thirdparty/qtweetlib/CMakeLists.txt +++ b/thirdparty/qtweetlib/CMakeLists.txt @@ -6,6 +6,7 @@ SET(CMAKE_VERBOSE_MAKEFILE ON) SET( QT_USE_QTNETWORK TRUE ) INCLUDE( ${QT_USE_FILE} ) + add_definitions( ${QT_DEFINITIONS} ) add_definitions( -DQT_SHARED ) @@ -171,6 +172,7 @@ target_link_libraries(tomahawk_qtweetlib ) SET_TARGET_PROPERTIES( tomahawk_qtweetlib PROPERTIES DEFINE_SYMBOL MAKE_QTWEETLIB_LIB ) +include ( ${CMAKE_CURRENT_SOURCE_DIR}/WARNING-twitter-api-keys ) INSTALL(TARGETS tomahawk_qtweetlib DESTINATION lib) From 3a38abd0b95e9ee9ef433ae2000021211782ab9a Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 14:20:17 -0500 Subject: [PATCH 47/62] Add twitter example file and update README --- README | 5 +++++ examples/twitter-api-keys.example | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 examples/twitter-api-keys.example diff --git a/README b/README index 10cf07700..67376dae7 100644 --- a/README +++ b/README @@ -94,6 +94,11 @@ Dependencies To build the app: ----------------- + + For SIP-over-Twitter support, you must first register an application with Twitter and copy the file + examples/twitter-api-keys.example to thirdparty/qtweetlib/WARNING-twitter-api-keys, substituting in + your particular consumer key and secret. + $ mkdir build && cd build Pick one of the following two choices. If uncertain pick the second one, you probably want a GUI. diff --git a/examples/twitter-api-keys.example b/examples/twitter-api-keys.example new file mode 100644 index 000000000..5fa0abee7 --- /dev/null +++ b/examples/twitter-api-keys.example @@ -0,0 +1,9 @@ +set_property( + TARGET tomahawk_qtweetlib + APPEND PROPERTY COMPILE_DEFINITIONS CONSUMER_KEY="aaaaaaaaaaaaaaa" +) + +set_property( + TARGET tomahawk_qtweetlib + APPEND PROPERTY COMPILE_DEFINITIONS CONSUMER_SECRET="bbbbbbbbbbbbbbbbb" +) From f02367abf1232c6cbcb09ce8a33ba4d5cabe8afd Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 14:46:06 -0500 Subject: [PATCH 48/62] Add some debug --- src/sip/twitter/twitter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 9aca46149..dc6b5b90e 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -447,12 +447,15 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q if( needToSend && _peerData.contains( "node") ) { + qDebug() << "TwitterPlugin needs to send and has node"; _peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); _peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( _peerData ); peersChanged = true; if( !Servent::instance()->externalAddress().isEmpty() && !Servent::instance()->externalPort() == 0 ) QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) ); + else + qDebug() << "TwitterPlugin did not send offer because external address is " << Servent::instance()->externalAddress() << " and external port is " << Servent::instance()->externalPort(); } if ( m_isOnline && _peerData.contains( "host" ) && _peerData.contains( "port" ) && _peerData.contains( "pkey" ) ) From c9de25a4c6ebc40e56b70057cfe1d7f8cfab925c Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 15:49:09 -0500 Subject: [PATCH 49/62] Remember values instead of forgetting some --- src/sip/twitter/twitter.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index dc6b5b90e..ec56b855b 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -163,6 +163,7 @@ TwitterPlugin::checkTimerFired() void TwitterPlugin::connectTimerFired() { + qDebug() << Q_FUNC_INFO; if ( !isValid() || m_cachedPeers.isEmpty() ) return; @@ -174,7 +175,10 @@ TwitterPlugin::connectTimerFired() QHash< QString, QVariant > peerData = m_cachedPeers[screenName].toHash(); if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) + { + qDebug() << "TwitterPlugin does not have host, port and/or pkey values for " << screenName; continue; + } QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) ); } @@ -450,7 +454,6 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q qDebug() << "TwitterPlugin needs to send and has node"; _peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); _peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); - m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( _peerData ); peersChanged = true; if( !Servent::instance()->externalAddress().isEmpty() && !Servent::instance()->externalPort() == 0 ) QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) ); @@ -462,7 +465,10 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) ); if ( peersChanged ) + { + m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( _peerData ); TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers ); + } } void From 1b4cdaa5ab4f87d592df6b1f9989f5498487ede1 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 16:00:23 -0500 Subject: [PATCH 50/62] Try connecting on startup after a short delay --- src/sip/twitter/twitter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index ec56b855b..5035f0cab 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -132,6 +132,7 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user ) connect( m_directMessageDestroy.data(), SIGNAL( parsedDirectMessage(const QTweetDMStatus &) ), SLOT( directMessageDestroyed(const QTweetDMStatus &) ) ); m_isOnline = true; QMetaObject::invokeMethod( this, "checkTimerFired", Qt::AutoConnection ); + QTimer::singleShot( 20000, this, SLOT( connectTimerFired() ) ); } else { From 8b1a9d1f18175ec7787764d50869840995d4ab3a Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 22:41:51 -0500 Subject: [PATCH 51/62] When using UPnP mode and it doens't work and you have an external address/port set, fall back to using those. --- src/libtomahawk/network/servent.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/network/servent.cpp b/src/libtomahawk/network/servent.cpp index b2444b47e..4d69e8134 100644 --- a/src/libtomahawk/network/servent.cpp +++ b/src/libtomahawk/network/servent.cpp @@ -146,9 +146,18 @@ Servent::setExternalAddress( QHostAddress ha, unsigned int port ) m_externalAddress = ha; m_externalPort = port; - if( m_externalPort == 0 ) + if( m_externalPort == 0 || m_externalAddress.toString().isEmpty() ) { - qDebug() << "No external access, LAN and outbound connections only!"; + if( !TomahawkSettings::instance()->externalHostname().isEmpty() && + !TomahawkSettings::instance()->externalPort() == 0 ) + { + qDebug() << "UPnP failed, have external address/port -- falling back"; + m_externalHostname = TomahawkSettings::instance()->externalHostname(); + m_externalPort = TomahawkSettings::instance()->externalPort(); + qDebug() << m_externalHostname << m_externalPort; + } + else + qDebug() << "No external access, LAN and outbound connections only!"; } emit ready(); From e27159142f30524de6fbeadb0d71328c4bc929dd Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 23:22:05 -0500 Subject: [PATCH 52/62] Revamp the config gui slightly. Put network settings on its own tab and jabber settings on its own tab. Add a UI way to set the external port. --- src/libtomahawk/tomahawksettings.cpp | 7 +- src/settingsdialog.cpp | 15 +- src/settingsdialog.ui | 380 ++++++++++++++------------- 3 files changed, 200 insertions(+), 202 deletions(-) diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index bd0363e6d..2b6b9935f 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -368,14 +368,17 @@ int TomahawkSettings::externalPort() const { QMutexLocker locker( m_safety ); - return value( "network/external-port" ).toInt(); + return value( "network/external-port", 50210 ).toInt(); } void TomahawkSettings::setExternalPort(int externalPort) { QMutexLocker locker( m_safety ); - setValue( "network/external-port", externalPort); + if ( externalPort == 0 ) + setValue( "network/external-port", 50210); + else + setValue( "network/external-port", externalPort); } diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 3b66be646..30818b0b2 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -51,19 +51,7 @@ SettingsDialog::SettingsDialog( QWidget *parent ) ui->jabberServer->setText( s->jabberServer() ); ui->jabberPort->setValue( s->jabberPort() ); ui->staticHostName->setText( s->externalHostname() ); - ui->proxyButton->setVisible( false ); - - if ( ui->jabberPort->text().toInt() != 5222 || !ui->jabberServer->text().isEmpty() ) - { - ui->checkBoxAdvanced->setChecked( true ); - } - else - { - // hide advanved settings - ui->checkBoxAdvanced->setChecked( false ); - ui->groupBoxJabberAdvanced->setVisible( false ); - ui->groupBoxNetworkAdvanced->setVisible( false ); - } + ui->staticPort->setValue( s->externalPort() ); if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() ) { @@ -134,6 +122,7 @@ SettingsDialog::~SettingsDialog() s->setJabberPort( ui->jabberPort->value() ); s->setExternalHostname( ui->staticHostName->text() ); + s->setExternalPort( ui->staticPort->value() ); s->setScannerPath( ui->lineEditMusicPath->text() ); diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 616de8780..2b844db9a 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -40,36 +40,30 @@ 16 - - - 16 - - + + - + 0 0 - 100 + 0 0 Jabber ID: - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - jabberUsername - + @@ -79,20 +73,23 @@ - + + + + 0 + 0 + + Password: - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - jabberPassword - + @@ -108,22 +105,6 @@ - - - - - 0 - 0 - - - - Qt::RightToLeft - - - Show Advanced Settings - - - @@ -227,72 +208,6 @@ - - - - - 0 - 0 - - - - Advanced Network Settings - - - - - - - - Static Host Name: - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Proxy Settings... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - @@ -306,50 +221,189 @@ - - - - Qt::RightToLeft - - - Playdar HTTP API - NO AUTH - - - false - - - - - - - Qt::RightToLeft - - - Use UPnP to establish port forward - - - true - - - - - - - Qt::RightToLeft - - - Connect automatically when Tomahawk starts - - - true - - - + + + Network + + + + + 20 + 10 + 551 + 341 + + + + + 0 + 0 + + + + Advanced Network Settings + + + + + + + + + 0 + 0 + + + + If you're having difficulty connecting to peers, try setting this to your external IP address/host name and a port number (default 50210). Make sure to forward that port to this machine! + + + true + + + + + + + + + + 0 + 0 + + + + Static Host Name: + + + + + + + + + + + 0 + 0 + + + + Static Port: + + + + + + + 65535 + + + 50210 + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Proxy Settings... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::RightToLeft + + + Playdar HTTP API - NO AUTH + + + false + + + + + + + Qt::RightToLeft + + + Connect automatically when Tomahawk starts + + + true + + + + + + + Qt::RightToLeft + + + Use UPnP to establish port forward + + + true + + + + + + - Music + Local Music @@ -430,7 +484,7 @@ Authenticating with Twitter allows you to discover and play music from your Twitter friends running Tomahawk. -This feature works best when you have set a static host name in the "Jabber" settings tab under Advanced Settings, but may work even if you do not. Please note: this discovery uses Direct Messages and will only work when both Twitter users have followed each other. Tomahawk will attempt to "clean up" after itself to keep your Direct Message inbox tidy, but may miss some. +This feature works best when you have set a static host name in the "Network" settings tab under Advanced Settings, but may work even if you do not. Please note: this discovery uses Direct Messages and will only work when both Twitter users have followed each other. Tomahawk will attempt to "clean up" after itself to keep your Direct Message inbox tidy, but may miss some. When you press the button your web browser will launch and take you to Twitter.com to authenticate. You must copy and paste the PIN number into the dialog box that appears. @@ -738,54 +792,6 @@ If connections to peers seem to have been lost, just press the button again to r - - checkBoxAdvanced - toggled(bool) - proxyButton - setVisible(bool) - - - 310 - 110 - - - 368 - 194 - - - - - checkBoxAdvanced - toggled(bool) - groupBoxJabberAdvanced - setVisible(bool) - - - 310 - 115 - - - 310 - 174 - - - - - checkBoxAdvanced - toggled(bool) - groupBoxNetworkAdvanced - setVisible(bool) - - - 310 - 115 - - - 310 - 262 - - - twitterAuthenticateButton pressed() From dacedf66ccfc4c848815ab819454df49a8b887bf Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 23:24:34 -0500 Subject: [PATCH 53/62] Proxy doens't work properly so for now don't show the button to enable it. --- src/settingsdialog.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 30818b0b2..a4ef3e39e 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -50,9 +50,12 @@ SettingsDialog::SettingsDialog( QWidget *parent ) ui->jabberPassword->setText( s->jabberPassword() ); ui->jabberServer->setText( s->jabberServer() ); ui->jabberPort->setValue( s->jabberPort() ); + ui->staticHostName->setText( s->externalHostname() ); ui->staticPort->setValue( s->externalPort() ); + ui->proxyButton->setVisible( false ); + if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() ) { ui->twitterStatusLabel->setText("Status: No saved credentials"); From de827a59a8e0134cbb43044fbdf26cea49e3b099 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 23:38:17 -0500 Subject: [PATCH 54/62] Some code cleanup, and allow for finding yourself in tweets if the node is different (interim step until, eventually, hopefully allowing multiple accesses) --- src/sip/twitter/twitter.cpp | 43 ++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 5035f0cab..0a4de44e3 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -150,13 +150,18 @@ TwitterPlugin::checkTimerFired() if ( m_cachedFriendsSinceId == 0 ) m_cachedFriendsSinceId = TomahawkSettings::instance()->twitterCachedFriendsSinceId(); - qDebug() << "TwitterPlugin using friend timeline id of " << m_cachedFriendsSinceId; + + qDebug() << "TwitterPlugin looking at friends timeline since id " << m_cachedFriendsSinceId; + if ( !m_friendsTimeline.isNull() ) m_friendsTimeline.data()->fetch( m_cachedFriendsSinceId, 0, 800 ); + if ( m_cachedMentionsSinceId == 0 ) m_cachedMentionsSinceId = TomahawkSettings::instance()->twitterCachedMentionsSinceId(); - qDebug() << "TwitterPlugin using mentions timeline id of " << m_cachedMentionsSinceId; + + qDebug() << "TwitterPlugin looking at mentions timeline since id " << m_cachedMentionsSinceId; + if ( !m_mentions.isNull() ) m_mentions.data()->fetch( m_cachedMentionsSinceId, 0, 800 ); } @@ -208,8 +213,7 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) { if ( status.id() > m_cachedFriendsSinceId ) m_cachedFriendsSinceId = status.id(); - if ( status.user().screenName() == myScreenName ) - continue; + if ( regex.exactMatch( status.text() ) ) { qDebug() << "TwitterPlugin found an exact tweet from friend " << status.user().screenName(); @@ -236,6 +240,9 @@ TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) } else qDebug() << "TwitterPlugin parsed node " << node << " out of the tweet"; + + if ( status.user().screenName() == myScreenName && node == Database::instance()->dbid() ) + continue; QHash< QString, QVariant > peerData; if( m_cachedPeers.contains( status.user().screenName() ) ) @@ -278,8 +285,7 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) { if ( status.id() > m_cachedMentionsSinceId ) m_cachedMentionsSinceId = status.id(); - if ( status.user().screenName() == myScreenName ) - continue; + if ( regex.exactMatch( status.text() ) ) { qDebug() << "TwitterPlugin found an exact matching mention from user " << status.user().screenName(); @@ -306,7 +312,10 @@ TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) } else qDebug() << "TwitterPlugin parsed node " << node << " out of the tweet"; - + + if ( status.user().screenName() == myScreenName && node == Database::instance()->dbid() ) + continue; + QHash< QString, QVariant > peerData; if( m_cachedPeers.contains( status.user().screenName() ) ) { @@ -339,7 +348,9 @@ TwitterPlugin::pollDirectMessages() if ( m_cachedDirectMessagesSinceId == 0 ) m_cachedDirectMessagesSinceId = TomahawkSettings::instance()->twitterCachedDirectMessagesSinceId(); - qDebug() << "TwitterPlugin using direct messages id of " << m_cachedDirectMessagesSinceId; + + qDebug() << "TwitterPlugin looking for direct messages since id " << m_cachedDirectMessagesSinceId; + if ( !m_directMessages.isNull() ) m_directMessages.data()->fetch( m_cachedDirectMessagesSinceId, 0, 800 ); } @@ -405,26 +416,28 @@ void TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerData ) { qDebug() << Q_FUNC_INFO; - QString friendlyName = QString( '@' + screenName ); + bool peersChanged = false; - QHash< QString, QVariant > _peerData( peerData ); - bool needToSend = false; bool needToAddToCache = false; - + + QString friendlyName = QString( '@' + screenName ); + + QHash< QString, QVariant > _peerData( peerData ); + if ( _peerData.contains( "dirty" ) ) { peersChanged = true; _peerData.remove( "dirty" ); } - + if ( _peerData.contains( "resend" ) ) { needToSend = true; peersChanged = true; _peerData.remove( "resend" ); } - + if ( !_peerData.contains( "okey" ) ) { QString okey = QUuid::createUuid().toString().split( '-' ).last(); @@ -443,7 +456,7 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q _peerData["oprt"].toInt() != Servent::instance()->externalPort() ) needToSend = true; - + if( needToAddToCache && _peerData.contains( "node" ) ) { qDebug() << "TwitterPlugin registering offer to " << friendlyName << " with node " << _peerData["node"].toString() << " and offeredkey " << _peerData["okey"].toString(); From 6ccac6ad0edf5a41fafc6fd0629f706477751d2a Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 13 Feb 2011 23:43:35 -0500 Subject: [PATCH 55/62] Re-add sending node in DMs; this will help allow multiple thawk instances to get hooked up to others by allowing it to ignore (and keep in inbox) DMs not meant for that particular instance (each instance will have to send a Got Tomahawk? tweet though) --- src/sip/twitter/twitter.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 0a4de44e3..901d84377 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -381,18 +381,25 @@ TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages ) qDebug() << "TwitterPlugin found " << splitList.length() << " parts to the message; the parts are:"; foreach( QString part, splitList ) qDebug() << part; - if ( splitList.length() != 4 ) + if ( splitList.length() != 5 ) continue; if ( splitList[0] != "TOMAHAWKPEER" ) continue; - if ( !splitList[1].startsWith( "Host=" ) || !splitList[2].startsWith( "Port=" ) || !splitList[3].startsWith( "PKey=" ) ) + if ( !splitList[1].startsWith( "Host=" ) || !splitList[2].startsWith( "Port=" ) || !splitList[3].startsWith( "Node=" ) || !splitList[4].startsWith( "PKey=" ) ) continue; int port = splitList[2].mid( 5 ).toInt(); if ( port == 0 ) continue; QString host = splitList[1].mid( 5 ); - QString pkey = splitList[3].mid( 5 ); - qDebug() << "TwitterPlugin found a peerstart message from " << status.senderScreenName() << " with host " << host << " and port " << port << " and pkey " << pkey; + QString node = splitList[3].mid( 5 ); + QString pkey = splitList[4].mid( 5 ); + qDebug() << "TwitterPlugin found a peerstart message from " << status.senderScreenName() << " with host " << host << " and port " << port << " and pkey " << pkey << " destined for node " << node; + + if ( node != Database::instance()->dbid() ) + { + qDebug() << "Not destined for this node; leaving it alone and not answering"; + continue; + } QHash< QString, QVariant > peerData = ( m_cachedPeers.contains( status.senderScreenName() ) ) ? m_cachedPeers[status.senderScreenName()].toHash() : @@ -489,8 +496,9 @@ void TwitterPlugin::sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerData ) { qDebug() << Q_FUNC_INFO; - QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:PKey=%3" ).arg( peerData["ohst"].toString() ) + QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:Node=%3:PKey=%4" ).arg( peerData["ohst"].toString() ) .arg( peerData["oprt"].toString() ) + .arg( peerData["node"].toString() ) .arg( peerData["okey"].toString() ); qDebug() << "TwitterPlugin sending message to " << screenName << ": " << offerString; if( !m_directMessageNew.isNull() ) From 0ca1212691f032e4a3c093ab90801b025392ca6a Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sun, 13 Feb 2011 12:37:03 -0500 Subject: [PATCH 56/62] Add some mac-specific code. Tomahawk now opens spiffs from the browser or the finder. There is also commented out code for handling multimedia keys. Thanks to the Clementine project for the cocoa code :) --- admin/mac/Info.plist | 32 ++++- include/tomahawk/tomahawkapp.h | 7 +- src/CMakeLists.osx.txt | 25 ++++ src/CMakeLists.txt | 11 ++ src/config.h.in | 10 ++ src/main.cpp | 44 +++++++ src/tomahawkapp.cpp | 55 ++++++-- src/tomahawkapp_mac.h | 28 ++++ src/tomahawkapp_mac.mm | 229 +++++++++++++++++++++++++++++++++ src/tomahawkapp_macdelegate.h | 25 ++++ 10 files changed, 453 insertions(+), 13 deletions(-) create mode 100644 src/config.h.in create mode 100644 src/tomahawkapp_mac.h create mode 100644 src/tomahawkapp_mac.mm create mode 100644 src/tomahawkapp_macdelegate.h diff --git a/admin/mac/Info.plist b/admin/mac/Info.plist index 3187e4438..e1114d48c 100644 --- a/admin/mac/Info.plist +++ b/admin/mac/Info.plist @@ -23,6 +23,36 @@ CFBundleName Tomahawk LSMinimumSystemVersion - 10.5.0 + 10.5.0 + CFBundleURLTypes + + + CFBundleURLName + Tomahawk URL + CFBundleURLSchemes + + tomahawk + + + + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + xspf + + CFBundleTypeIconFile + Generic.icns + CFBundleTypeMIMETypes + + application/xspf+xml + + CFBundleTypeName + XSPF Playlist + CFBundleTypeRole + Viewer + + diff --git a/include/tomahawk/tomahawkapp.h b/include/tomahawk/tomahawkapp.h index 7f0fc2005..a7be72230 100644 --- a/include/tomahawk/tomahawkapp.h +++ b/include/tomahawk/tomahawkapp.h @@ -4,6 +4,7 @@ #define APP TomahawkApp::instance() #include "headlesscheck.h" +#include "tomahawkapp_mac.h" // for PlatforInterface #include #include @@ -47,7 +48,7 @@ class TomahawkWindow; // this also acts as a a container for important top-level objects // that other parts of the app need to find // (eg, library, pipeline, friends list) -class TomahawkApp : public TOMAHAWK_APPLICATION +class TomahawkApp : public TOMAHAWK_APPLICATION, public Tomahawk::PlatformInterface { Q_OBJECT @@ -69,6 +70,10 @@ public: void addScriptResolver( const QString& scriptPath ); void removeScriptResolver( const QString& scriptPath ); + // PlatformInterface + virtual void activate(); + virtual bool loadUrl( const QString& url ); + signals: void settingsChanged(); diff --git a/src/CMakeLists.osx.txt b/src/CMakeLists.osx.txt index 77590e8b5..256e34746 100644 --- a/src/CMakeLists.osx.txt +++ b/src/CMakeLists.osx.txt @@ -2,6 +2,31 @@ SET( OS_SPECIFIC_LINK_LIBRARIES ${OS_SPECIFIC_LINK_LIBRARIES} ${COREAUDIO_LIBRARY} ${COREFOUNDATION_LIBRARY} + + /System/Library/Frameworks/AppKit.framework + /System/Library/Frameworks/Carbon.framework + /System/Library/Frameworks/DiskArbitration.framework + /System/Library/Frameworks/Foundation.framework + /System/Library/Frameworks/IOKit.framework + rtaudio tomahawklib ) + +if (APPLE) +# find_library(GROWL Growl) +# option(ENABLE_SPARKLE "Sparkle updating" ON) +# find_library(SPARKLE Sparkle) +# if (ENABLE_SPARKLE AND SPARKLE) +# set(HAVE_SPARKLE ON) +# endif (ENABLE_SPARKLE AND SPARKLE) + # Uses Darwin kernel version. + # 9.8.0 -> 10.5/Leopard + # 10.4.0 -> 10.6/Snow Leopard + string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${CMAKE_HOST_SYSTEM_VERSION}) + if (DARWIN_VERSION GREATER 9) + SET(SNOW_LEOPARD 1) + elseif (DARWIN_VERSION GREATER 8) + SET(LEOPARD 1) + endif (DARWIN_VERSION GREATER 9) +endif (APPLE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d486966e0..b3d616e0a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -57,6 +57,12 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui} tomahawkwindow.cpp ) + +IF( APPLE ) + SET( tomahawkHeaders ${tomahawkHeaders} tomahawkapp_mac.h ) + SET( tomahawkSources ${tomahawkSources} tomahawkapp_mac.mm ) +ENDIF( APPLE ) + SET( tomahawkHeaders ${tomahawkHeaders} "${TOMAHAWK_INC_DIR}/tomahawk/tomahawkapp.h" "${TOMAHAWK_INC_DIR}/tomahawk/infosystem.h" @@ -138,6 +144,9 @@ kde4_add_app_icon( tomahawkSources "${CMAKE_CURRENT_SOURCE_DIR}/../data/icons/to qt4_add_resources( RC_SRCS "../resources.qrc" ) qt4_wrap_cpp( tomahawkMoc ${tomahawkHeaders} ) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/config.h) + SET( final_src ${final_src} ${tomahawkMoc} ${tomahawkSources} ${tomahawkHeaders} ) IF( "${gui}" STREQUAL "no" ) @@ -152,6 +161,8 @@ IF( UNIX AND NOT APPLE ) ENDIF( UNIX AND NOT APPLE ) IF( APPLE ) ADD_EXECUTABLE( tomahawk MACOSX_BUNDLE ${final_src} ) + SET_TARGET_PROPERTIES(tomahawk PROPERTIES MACOSX_BUNDLE_INFO_PLIST "../admin/mac/Info.plist" +) ENDIF( APPLE ) IF( WIN32 ) ADD_EXECUTABLE( tomahawk ${final_src} ) diff --git a/src/config.h.in b/src/config.h.in new file mode 100644 index 000000000..a06d239a5 --- /dev/null +++ b/src/config.h.in @@ -0,0 +1,10 @@ +#ifndef CONFIG_H_IN +#define CONFIG_H_IN + +#define CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" + +#cmakedefine SNOW_LEOPARD +#cmakedefine LEOPARD +#cmakedefine HAVE_SPARKLE + +#endif // CONFIG_H_IN diff --git a/src/main.cpp b/src/main.cpp index 4519a116e..d755703d2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,24 @@ #include "tomahawk/tomahawkapp.h" +#ifdef Q_WS_MAC +#include "tomahawkapp_mac.h" +#include +static pascal OSErr appleEventHandler( const AppleEvent*, AppleEvent*, long ); +#endif + #include int main( int argc, char *argv[] ) { +#ifdef Q_WS_MAC + // Do Mac specific startup to get media keys working. + // This must go before QApplication initialisation. + Tomahawk::macMain(); + + // used for url handler + AEEventHandlerUPP h = AEEventHandlerUPP( appleEventHandler ); + AEInstallEventHandler( 'GURL', 'GURL', h, 0, false ); + +#endif try { TomahawkApp a( argc, argv ); return a.exec(); @@ -10,3 +26,31 @@ int main( int argc, char *argv[] ) return 0; } } + +#ifdef Q_WS_MAC +static pascal OSErr appleEventHandler( const AppleEvent* e, AppleEvent*, long ) +{ + OSType id = typeWildCard; + AEGetAttributePtr( e, keyEventIDAttr, typeType, 0, &id, sizeof(id), 0 ); + + switch (id) + { + case 'GURL': + { + DescType type; + Size size; + + char buf[1024]; + AEGetParamPtr( e, keyDirectObject, typeChar, &type, &buf, 1023, &size ); + buf[size] = '\0'; + + QString url = QString::fromUtf8( buf ); + static_cast(qApp)->loadUrl( url ); + return noErr; + } + + default: + return unimpErr; + } +} +#endif diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index 30cba6dcc..b865d7b4d 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include "artist.h" #include "album.h" @@ -31,6 +33,10 @@ #include #endif +#ifdef Q_WS_MAC + #include "tomahawkapp_mac.h" +#endif + #include #include @@ -176,6 +182,10 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] ) TomahawkUtils::setNam( new QNetworkAccessManager ); #endif +#ifdef Q_WS_MAC + Tomahawk::setApplicationHandler( this ); +#endif + // Set up proxy if( TomahawkSettings::instance()->proxyType() != QNetworkProxy::NoProxy && !TomahawkSettings::instance()->proxyHost().isEmpty() ) @@ -454,16 +464,20 @@ TomahawkApp::setupSIP() } } -void -TomahawkApp::messageReceived( const QString& msg ) + +void +TomahawkApp::activate() { - qDebug() << "MESSAGE RECEIVED" << msg; - if( msg.isEmpty() ) { - return; - } - - if( msg.contains( "tomahawk://" ) ) { - QString cmd = msg.mid( 11 ); +#ifndef TOMAHAWK_HEADLESS + mainWindow()->show(); +#endif +} + +bool +TomahawkApp::loadUrl( const QString& url ) +{ + if( url.contains( "tomahawk://" ) ) { + QString cmd = url.mid( 11 ); qDebug() << "tomahawk!s" << cmd; if( cmd.startsWith( "load/" ) ) { cmd = cmd.mid( 5 ); @@ -474,7 +488,26 @@ TomahawkApp::messageReceived( const QString& msg ) l->load( QUrl( cmd.mid( 5 ) ) ); } } - - } + } else { + QFile f( url ); + QFileInfo info( f ); + if( f.exists() && info.suffix() == "xspf" ) { + XSPFLoader* l = new XSPFLoader( true, this ); + qDebug() << "Loading spiff:" << url; + l->load( QUrl( url ) ); + } + } + return true; +} + +void +TomahawkApp::messageReceived( const QString& msg ) +{ + qDebug() << "MESSAGE RECEIVED" << msg; + if( msg.isEmpty() ) { + return; + } + + loadUrl( msg ); } diff --git a/src/tomahawkapp_mac.h b/src/tomahawkapp_mac.h new file mode 100644 index 000000000..ce4199677 --- /dev/null +++ b/src/tomahawkapp_mac.h @@ -0,0 +1,28 @@ +#ifndef TOMAHAWKAPP_MAC_H +#define TOMAHAWKAPP_MAC_H + +// this file and tomahawk_app.mm copied and inspired by mac_startup.* in clementine player, +// copyright David Sansome 2010 + +class QString; + +namespace Tomahawk { + +/// Interface between cocoa and tomahawk +class PlatformInterface { + public: + // Called when the application should show itself. + virtual void activate() = 0; + virtual bool loadUrl( const QString& url ) = 0; + + virtual ~PlatformInterface() {} +}; + +void macMain(); +//void setShortcutHandler(GlobalShortcuts* handler); +// used for opening files with tomahawk +void setApplicationHandler(PlatformInterface* handler); + +}; + +#endif diff --git a/src/tomahawkapp_mac.mm b/src/tomahawkapp_mac.mm new file mode 100644 index 000000000..dfc08c34b --- /dev/null +++ b/src/tomahawkapp_mac.mm @@ -0,0 +1,229 @@ +#include "tomahawkapp_mac.h" +#include "tomahawkapp_macdelegate.h" +#include + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + +// Capture global media keys on Mac (Cocoa only!) +// See: http://www.rogueamoeba.com/utm/2007/09/29/apple-keyboard-media-key-event-handling/ + +@interface MacApplication :NSApplication { + // MacGlobalShortcutBackend* shortcut_handler_; + Tomahawk::PlatformInterface* application_handler_; +} + +//- (MacGlobalShortcutBackend*) shortcut_handler; +//- (void) SetShortcutHandler: (MacGlobalShortcutBackend*)handler; + +- (Tomahawk::PlatformInterface*) application_handler; +- (void) SetApplicationHandler: (Tomahawk::PlatformInterface*)handler; +- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent; +//- (void) mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat; +@end + + +@implementation AppDelegate + +- (id) init { + if ((self = [super init])) { + application_handler_ = nil; +// dock_menu_ = nil; + } + return self; +} + +- (id) initWithHandler: (Tomahawk::PlatformInterface*)handler { + application_handler_ = handler; + return self; +} + +- (BOOL) applicationShouldHandleReopen: (NSApplication*)app hasVisibleWindows:(BOOL)flag { + if (application_handler_) { + application_handler_->activate(); + } + return YES; +} +/* +- (void) setDockMenu: (NSMenu*)menu { + dock_menu_ = menu; +} + +- (NSMenu*) applicationDockMenu: (NSApplication*)sender { + return dock_menu_; +} +*/ +- (BOOL) application: (NSApplication*)app openFile:(NSString*)filename { + qDebug() << "Wants to open:" << [filename UTF8String]; + + if (application_handler_->loadUrl(QString::fromUtf8([filename UTF8String]))) { + return YES; + } + + return NO; +} +@end + +@implementation MacApplication + +- (id) init { + if ((self = [super init])) { +// [self SetShortcutHandler:nil]; + [self SetApplicationHandler:nil]; + + NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager]; + [em + setEventHandler:self + andSelector:@selector(getUrl:withReplyEvent:) + forEventClass:kInternetEventClass + andEventID:kAEGetURL]; + [em + setEventHandler:self + andSelector:@selector(getUrl:withReplyEvent:) + forEventClass:'WWW!' + andEventID:'OURL']; + NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier]; + OSStatus httpResult = LSSetDefaultHandlerForURLScheme((CFStringRef)@"tomahawk", (CFStringRef)bundleID); + //TODO: Check httpResult and httpsResult for errors + } + return self; +} +/* +- (MacGlobalShortcutBackend*) shortcut_handler { + return shortcut_handler_; +} + +- (void) SetShortcutHandler: (MacGlobalShortcutBackend*)handler { + shortcut_handler_ = handler; +} +*/ +- (Tomahawk::PlatformInterface*) application_handler { + return application_handler_; +} + +- (void) SetApplicationHandler: (Tomahawk::PlatformInterface*)handler { + AppDelegate* delegate = [[AppDelegate alloc] initWithHandler:handler]; + [self setDelegate:delegate]; +} + +-(void) sendEvent: (NSEvent*)event { + if ([event type] == NSSystemDefined && [event subtype] == 8) { + int keycode = (([event data1] & 0xFFFF0000) >> 16); + int keyflags = ([event data1] & 0x0000FFFF); + int keystate = (((keyflags & 0xFF00) >> 8)) == 0xA; + int keyrepeat = (keyflags & 0x1); + + //[self mediaKeyEvent: keycode state: keystate repeat: keyrepeat]; + } + + [super sendEvent: event]; +} +/* +-(void) mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat { + if (!shortcut_handler_) { + return; + } + if (state == 0) { + shortcut_handler_->MacMediaKeyPressed(key); + } +} */ + +- (void)getUrl:(NSAppleEventDescriptor *)event + withReplyEvent:(NSAppleEventDescriptor *)replyEvent +{ + // Get the URL + NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject] + stringValue]; + qDebug() << "Wants to open:" << [urlStr UTF8String]; + + //TODO: Your custom URL handling code here +} + +@end + +void Tomahawk::macMain() { + [[NSAutoreleasePool alloc] init]; + // Creates and sets the magic global variable so QApplication will find it. + [MacApplication sharedApplication]; + #ifdef HAVE_SPARKLE + // Creates and sets the magic global variable for Sparkle. + [[SUUpdater sharedUpdater] setDelegate: NSApp]; + #endif +} + +/* +void setShortcutHandler(MacGlobalShortcutBackend* handler) { + [NSApp SetShortcutHandler: handler]; +} +*/ +void Tomahawk::setApplicationHandler(Tomahawk::PlatformInterface* handler) { + [NSApp SetApplicationHandler: handler]; +} + +void CheckForUpdates() { + #ifdef HAVE_SPARKLE + [[SUUpdater sharedUpdater] checkForUpdates: NSApp]; + #endif +} + +QString GetBundlePath() { + CFURLRef app_url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); + CFStringRef mac_path = CFURLCopyFileSystemPath(app_url, kCFURLPOSIXPathStyle); + const char* path = CFStringGetCStringPtr(mac_path, CFStringGetSystemEncoding()); + QString bundle_path = QString::fromUtf8(path); + CFRelease(app_url); + CFRelease(mac_path); + return bundle_path; +} + +QString GetResourcesPath() { + QString bundle_path = GetBundlePath(); + return bundle_path + "/Contents/Resources"; +} + +QString GetApplicationSupportPath() { + NSAutoreleasePool* pool = [NSAutoreleasePool alloc]; + [pool init]; + NSArray* paths = NSSearchPathForDirectoriesInDomains( + NSApplicationSupportDirectory, + NSUserDomainMask, + YES); + QString ret; + if ([paths count] > 0) { + NSString* user_path = [paths objectAtIndex:0]; + ret = QString::fromUtf8([user_path UTF8String]); + } else { + ret = "~/Library/Application Support"; + } + [pool drain]; + return ret; +} + +QString GetMusicDirectory() { + NSAutoreleasePool* pool = [NSAutoreleasePool alloc]; + [pool init]; + NSArray* paths = NSSearchPathForDirectoriesInDomains( + NSMusicDirectory, + NSUserDomainMask, + YES); + QString ret; + if ([paths count] > 0) { + NSString* user_path = [paths objectAtIndex:0]; + ret = QString::fromUtf8([user_path UTF8String]); + } else { + ret = "~/Music"; + } + [pool drain]; + return ret; +} + diff --git a/src/tomahawkapp_macdelegate.h b/src/tomahawkapp_macdelegate.h new file mode 100644 index 000000000..a5884e225 --- /dev/null +++ b/src/tomahawkapp_macdelegate.h @@ -0,0 +1,25 @@ +#import + +#include "config.h" + +// this file copied and inspired by mac_startup.* in clementine player, +// copyright David Sansome 2010 +namespace Tomahawk { + class PlatformInterface; +} + +#ifdef SNOW_LEOPARD +@interface AppDelegate : NSObject { +#else +@interface AppDelegate : NSObject { +#endif + Tomahawk::PlatformInterface* application_handler_; + //NSMenu* dock_menu_; +} + +- (id) initWithHandler: (Tomahawk::PlatformInterface*)handler; +// NSApplicationDelegate +- (BOOL) applicationShouldHandleReopen: (NSApplication*)app hasVisibleWindows:(BOOL)flag; +//- (NSMenu*) applicationDockMenu: (NSApplication*)sender; +//- (void) setDockMenu: (NSMenu*)menu; +@end From 1647293adadd24e670bb5144d1965d34ffca1fdb Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sun, 13 Feb 2011 23:57:25 -0500 Subject: [PATCH 57/62] Add some shortcuts for mac Fix osx shortcuts --- include/tomahawk/tomahawkapp.h | 4 +- src/CMakeLists.txt | 7 ++- src/libtomahawk/audio/audioengine.cpp | 14 ++++++ src/libtomahawk/audio/audioengine.h | 2 + src/mac/macshortcuthandler.cpp | 31 ++++++++++++ src/mac/macshortcuthandler.h | 22 ++++++++ src/{ => mac}/tomahawkapp_mac.h | 4 +- src/{ => mac}/tomahawkapp_mac.mm | 72 +++++++++------------------ src/shortcuthandler.cpp | 13 +++++ src/shortcuthandler.h | 34 +++++++++++++ src/tomahawkapp.cpp | 66 ++++++++++++++---------- 11 files changed, 192 insertions(+), 77 deletions(-) create mode 100644 src/mac/macshortcuthandler.cpp create mode 100644 src/mac/macshortcuthandler.h rename src/{ => mac}/tomahawkapp_mac.h (86%) rename src/{ => mac}/tomahawkapp_mac.mm (69%) create mode 100644 src/shortcuthandler.cpp create mode 100644 src/shortcuthandler.h diff --git a/include/tomahawk/tomahawkapp.h b/include/tomahawk/tomahawkapp.h index a7be72230..be8e7d16b 100644 --- a/include/tomahawk/tomahawkapp.h +++ b/include/tomahawk/tomahawkapp.h @@ -4,7 +4,7 @@ #define APP TomahawkApp::instance() #include "headlesscheck.h" -#include "tomahawkapp_mac.h" // for PlatforInterface +#include "mac/tomahawkapp_mac.h" // for PlatforInterface #include #include @@ -29,6 +29,7 @@ class XMPPBot; namespace Tomahawk { + class ShortcutHandler; namespace InfoSystem { class InfoSystem; @@ -99,6 +100,7 @@ private: SipHandler* m_sipHandler; Servent* m_servent; XMPPBot* m_xmppBot; + Tomahawk::ShortcutHandler* m_shortcutHandler; #ifndef NO_LIBLASTFM Scrobbler* m_scrobbler; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b3d616e0a..b97f30412 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,6 +39,7 @@ SET( tomahawkSources ${tomahawkSources} musicscanner.cpp scriptresolver.cpp scrobbler.cpp + shortcuthandler.cpp tomahawkapp.cpp main.cpp @@ -59,8 +60,8 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui} IF( APPLE ) - SET( tomahawkHeaders ${tomahawkHeaders} tomahawkapp_mac.h ) - SET( tomahawkSources ${tomahawkSources} tomahawkapp_mac.mm ) + SET( tomahawkHeaders ${tomahawkHeaders} mac/tomahawkapp_mac.h mac/macshortcuthandler.h ) + SET( tomahawkSources ${tomahawkSources} mac/tomahawkapp_mac.mm mac/macshortcuthandler.cpp ) ENDIF( APPLE ) SET( tomahawkHeaders ${tomahawkHeaders} @@ -78,6 +79,7 @@ SET( tomahawkHeaders ${tomahawkHeaders} musicscanner.h scriptresolver.h scrobbler.h + shortcuthandler.h ) SET( tomahawkHeadersGui ${tomahawkHeadersGui} @@ -115,6 +117,7 @@ INCLUDE_DIRECTORIES( topbar utils libtomahawk + mac ../alsa-playback ../rtaudio diff --git a/src/libtomahawk/audio/audioengine.cpp b/src/libtomahawk/audio/audioengine.cpp index 7ebbf9197..7231e3a72 100644 --- a/src/libtomahawk/audio/audioengine.cpp +++ b/src/libtomahawk/audio/audioengine.cpp @@ -62,6 +62,15 @@ AudioEngine::~AudioEngine() delete m_audio; } +void +AudioEngine::playPause() +{ + if( m_audio->isPlaying() ) + pause(); + else + play(); + +} void AudioEngine::play() @@ -141,6 +150,11 @@ AudioEngine::setVolume( int percentage ) emit volumeChanged( percentage ); } +void +AudioEngine::mute() +{ + setVolume( 0 ); +} void AudioEngine::onTrackAboutToClose() diff --git a/src/libtomahawk/audio/audioengine.h b/src/libtomahawk/audio/audioengine.h index e763c9235..a94a5359b 100644 --- a/src/libtomahawk/audio/audioengine.h +++ b/src/libtomahawk/audio/audioengine.h @@ -40,6 +40,7 @@ public: PlaylistInterface* playlist() const { return m_playlist; } public slots: + void playPause(); void play(); void pause(); void stop(); @@ -51,6 +52,7 @@ public slots: void lowerVolume() { setVolume( volume() - AUDIO_VOLUME_STEP ); } void raiseVolume() { setVolume( volume() + AUDIO_VOLUME_STEP ); } void onVolumeChanged( float volume ) { emit volumeChanged( volume * 100 ); } + void mute(); void playItem( PlaylistInterface* playlist, const Tomahawk::result_ptr& result ); void setPlaylist( PlaylistInterface* playlist ) { m_playlist = playlist; } diff --git a/src/mac/macshortcuthandler.cpp b/src/mac/macshortcuthandler.cpp new file mode 100644 index 000000000..80bc64815 --- /dev/null +++ b/src/mac/macshortcuthandler.cpp @@ -0,0 +1,31 @@ +#include "macshortcuthandler.h" + +#include +#include + +using namespace Tomahawk; + +MacShortcutHandler::MacShortcutHandler(QObject *parent) : + Tomahawk::ShortcutHandler(parent) +{ + +} + +void +MacShortcutHandler::macMediaKeyPressed( int key ) +{ + switch (key) { + case NX_KEYTYPE_PLAY: + qDebug() << "emitting PlayPause pressed"; + emit playPause(); + break; + case NX_KEYTYPE_FAST: + qDebug() << "emitting next pressed"; + emit next(); + break; + case NX_KEYTYPE_REWIND: + qDebug() << "emitting prev pressed"; + emit previous(); + break; + } +} diff --git a/src/mac/macshortcuthandler.h b/src/mac/macshortcuthandler.h new file mode 100644 index 000000000..014d71421 --- /dev/null +++ b/src/mac/macshortcuthandler.h @@ -0,0 +1,22 @@ +#ifndef MACSHORTCUTHANDLER_H +#define MACSHORTCUTHANDLER_H + +#include "shortcuthandler.h" + +#include + +namespace Tomahawk { + + +class MacShortcutHandler : public ShortcutHandler +{ + Q_OBJECT +public: + explicit MacShortcutHandler(QObject *parent = 0); + + void macMediaKeyPressed( int key ); +}; + +} + +#endif // MACSHORTCUTHANDLER_H diff --git a/src/tomahawkapp_mac.h b/src/mac/tomahawkapp_mac.h similarity index 86% rename from src/tomahawkapp_mac.h rename to src/mac/tomahawkapp_mac.h index ce4199677..c242b2e0a 100644 --- a/src/tomahawkapp_mac.h +++ b/src/mac/tomahawkapp_mac.h @@ -8,6 +8,8 @@ class QString; namespace Tomahawk { +class MacShortcutHandler; + /// Interface between cocoa and tomahawk class PlatformInterface { public: @@ -19,7 +21,7 @@ class PlatformInterface { }; void macMain(); -//void setShortcutHandler(GlobalShortcuts* handler); +void setShortcutHandler(Tomahawk::MacShortcutHandler* engine); // used for opening files with tomahawk void setApplicationHandler(PlatformInterface* handler); diff --git a/src/tomahawkapp_mac.mm b/src/mac/tomahawkapp_mac.mm similarity index 69% rename from src/tomahawkapp_mac.mm rename to src/mac/tomahawkapp_mac.mm index dfc08c34b..cf60300b0 100644 --- a/src/tomahawkapp_mac.mm +++ b/src/mac/tomahawkapp_mac.mm @@ -1,5 +1,6 @@ #include "tomahawkapp_mac.h" #include "tomahawkapp_macdelegate.h" +#include "macshortcuthandler.h" #include #import @@ -19,17 +20,17 @@ // See: http://www.rogueamoeba.com/utm/2007/09/29/apple-keyboard-media-key-event-handling/ @interface MacApplication :NSApplication { - // MacGlobalShortcutBackend* shortcut_handler_; + Tomahawk::MacShortcutHandler* shortcut_handler_; Tomahawk::PlatformInterface* application_handler_; } -//- (MacGlobalShortcutBackend*) shortcut_handler; -//- (void) SetShortcutHandler: (MacGlobalShortcutBackend*)handler; +- (Tomahawk::MacShortcutHandler*) shortcutHandler; +- (void) setShortcutHandler: (Tomahawk::MacShortcutHandler*)handler; - (Tomahawk::PlatformInterface*) application_handler; -- (void) SetApplicationHandler: (Tomahawk::PlatformInterface*)handler; -- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent; -//- (void) mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat; +- (void) setApplicationHandler: (Tomahawk::PlatformInterface*)handler; +- (void) getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent; +- (void) mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat; @end @@ -78,40 +79,26 @@ - (id) init { if ((self = [super init])) { -// [self SetShortcutHandler:nil]; - [self SetApplicationHandler:nil]; - - NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager]; - [em - setEventHandler:self - andSelector:@selector(getUrl:withReplyEvent:) - forEventClass:kInternetEventClass - andEventID:kAEGetURL]; - [em - setEventHandler:self - andSelector:@selector(getUrl:withReplyEvent:) - forEventClass:'WWW!' - andEventID:'OURL']; - NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier]; - OSStatus httpResult = LSSetDefaultHandlerForURLScheme((CFStringRef)@"tomahawk", (CFStringRef)bundleID); - //TODO: Check httpResult and httpsResult for errors + [self setShortcutHandler:nil]; + [self setApplicationHandler:nil]; } return self; } -/* -- (MacGlobalShortcutBackend*) shortcut_handler { - return shortcut_handler_; + +- (Tomahawk::MacShortcutHandler*) shortcutHandler { + return shortcut_handler_; } -- (void) SetShortcutHandler: (MacGlobalShortcutBackend*)handler { +- (void) setShortcutHandler: (Tomahawk::MacShortcutHandler*)handler { + qDebug() << "Setting shortcut handler of MacAPp"; shortcut_handler_ = handler; } -*/ + - (Tomahawk::PlatformInterface*) application_handler { return application_handler_; } -- (void) SetApplicationHandler: (Tomahawk::PlatformInterface*)handler { +- (void) setApplicationHandler: (Tomahawk::PlatformInterface*)handler { AppDelegate* delegate = [[AppDelegate alloc] initWithHandler:handler]; [self setDelegate:delegate]; } @@ -123,30 +110,19 @@ int keystate = (((keyflags & 0xFF00) >> 8)) == 0xA; int keyrepeat = (keyflags & 0x1); - //[self mediaKeyEvent: keycode state: keystate repeat: keyrepeat]; + [self mediaKeyEvent: keycode state: keystate repeat: keyrepeat]; } [super sendEvent: event]; } -/* + -(void) mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat { if (!shortcut_handler_) { return; } if (state == 0) { - shortcut_handler_->MacMediaKeyPressed(key); + shortcut_handler_->macMediaKeyPressed(key); } -} */ - -- (void)getUrl:(NSAppleEventDescriptor *)event - withReplyEvent:(NSAppleEventDescriptor *)replyEvent -{ - // Get the URL - NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject] - stringValue]; - qDebug() << "Wants to open:" << [urlStr UTF8String]; - - //TODO: Your custom URL handling code here } @end @@ -161,13 +137,13 @@ void Tomahawk::macMain() { #endif } -/* -void setShortcutHandler(MacGlobalShortcutBackend* handler) { - [NSApp SetShortcutHandler: handler]; + +void Tomahawk::setShortcutHandler(Tomahawk::MacShortcutHandler* handler) { + [NSApp setShortcutHandler: handler]; } -*/ + void Tomahawk::setApplicationHandler(Tomahawk::PlatformInterface* handler) { - [NSApp SetApplicationHandler: handler]; + [NSApp setApplicationHandler: handler]; } void CheckForUpdates() { diff --git a/src/shortcuthandler.cpp b/src/shortcuthandler.cpp new file mode 100644 index 000000000..7709789ca --- /dev/null +++ b/src/shortcuthandler.cpp @@ -0,0 +1,13 @@ +#include "shortcuthandler.h" + +using namespace Tomahawk; + +ShortcutHandler::ShortcutHandler( QObject *parent ) + : QObject( parent ) +{ + +} + + ShortcutHandler::~ShortcutHandler() + { + } diff --git a/src/shortcuthandler.h b/src/shortcuthandler.h new file mode 100644 index 000000000..6462c0ebf --- /dev/null +++ b/src/shortcuthandler.h @@ -0,0 +1,34 @@ +#ifndef SHORTCUTHANDLER_H +#define SHORTCUTHANDLER_H + +#include + +namespace Tomahawk { +/** + Base class for various shortcut plugins on different platforms + */ +class ShortcutHandler : public QObject +{ + Q_OBJECT +public: + virtual ~ShortcutHandler(); + +signals: + // add more as needed + void playPause(); + void pause(); + void stop(); + void previous(); + void next(); + + void volumeUp(); + void volumeDown(); + void mute(); +protected: + explicit ShortcutHandler( QObject *parent = 0 ); + +}; + +} + +#endif // SHORTCUTHANDLER_H diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index b865d7b4d..1b0757389 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -24,8 +24,11 @@ #include "web/api_v1.h" #include "scriptresolver.h" #include "sourcelist.h" +#include "shortcuthandler.h" +#include "tomahawksettings.h" #include "audio/audioengine.h" +#include "utils/xspfloader.h" #ifndef TOMAHAWK_HEADLESS #include "tomahawkwindow.h" @@ -34,7 +37,7 @@ #endif #ifdef Q_WS_MAC - #include "tomahawkapp_mac.h" +#include "mac/macshortcuthandler.h" #endif #include @@ -42,8 +45,6 @@ #define LOGFILE TomahawkUtils::appDataDir().filePath( "tomahawk.log" ).toLocal8Bit() #define LOGFILE_SIZE 1024 * 512 -#include "tomahawksettings.h" -#include using namespace std; ofstream logfile; @@ -114,6 +115,7 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] ) , m_audioEngine( 0 ) , m_sipHandler( 0 ) , m_servent( 0 ) + , m_shortcutHandler( 0 ) , m_mainwindow( 0 ) , m_infoSystem( 0 ) { @@ -160,35 +162,49 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] ) qDebug() << "Init Echonest Factory."; GeneratorFactory::registerFactory( "echonest", new EchonestFactory ); -#ifndef NO_LIBLASTFM - qDebug() << "Init Scrobbler."; - m_scrobbler = new Scrobbler( this ); - qDebug() << "Setting NAM."; - TomahawkUtils::setNam( new lastfm::NetworkAccessManager( this ) ); + // Register shortcut handler for this platform +#ifdef Q_WS_MAC + m_shortcutHandler = new MacShortcutHandler( this ); + Tomahawk::setShortcutHandler( static_cast( m_shortcutHandler) ); - connect( m_audioEngine, SIGNAL( started( const Tomahawk::result_ptr& ) ), - m_scrobbler, SLOT( trackStarted( const Tomahawk::result_ptr& ) ), Qt::QueuedConnection ); - - connect( m_audioEngine, SIGNAL( paused() ), - m_scrobbler, SLOT( trackPaused() ), Qt::QueuedConnection ); - - connect( m_audioEngine, SIGNAL( resumed() ), - m_scrobbler, SLOT( trackResumed() ), Qt::QueuedConnection ); - - connect( m_audioEngine, SIGNAL( stopped() ), - m_scrobbler, SLOT( trackStopped() ), Qt::QueuedConnection ); -#else - qDebug() << "Setting NAM."; - TomahawkUtils::setNam( new QNetworkAccessManager ); + Tomahawk::setApplicationHandler( this ); #endif -#ifdef Q_WS_MAC - Tomahawk::setApplicationHandler( this ); + // Connect up shortcuts + connect( m_shortcutHandler, SIGNAL( playPause() ), m_audioEngine, SLOT( playPause() ) ); + connect( m_shortcutHandler, SIGNAL( pause() ), m_audioEngine, SLOT( pause() ) ); + connect( m_shortcutHandler, SIGNAL( stop() ), m_audioEngine, SLOT( stop() ) ); + connect( m_shortcutHandler, SIGNAL( previous() ), m_audioEngine, SLOT( previous() ) ); + connect( m_shortcutHandler, SIGNAL( next() ), m_audioEngine, SLOT( next() ) ); + connect( m_shortcutHandler, SIGNAL( volumeUp() ), m_audioEngine, SLOT( raiseVolume() ) ); + connect( m_shortcutHandler, SIGNAL( volumeDown() ), m_audioEngine, SLOT( lowerVolume() ) ); + connect( m_shortcutHandler, SIGNAL( mute() ), m_audioEngine, SLOT( mute() ) ); + +#ifndef NO_LIBLASTFM + qDebug() << "Init Scrobbler."; + m_scrobbler = new Scrobbler( this ); + qDebug() << "Setting NAM."; + TomahawkUtils::setNam( new lastfm::NetworkAccessManager( this ) ); + + connect( m_audioEngine, SIGNAL( started( const Tomahawk::result_ptr& ) ), + m_scrobbler, SLOT( trackStarted( const Tomahawk::result_ptr& ) ), Qt::QueuedConnection ); + + connect( m_audioEngine, SIGNAL( paused() ), + m_scrobbler, SLOT( trackPaused() ), Qt::QueuedConnection ); + + connect( m_audioEngine, SIGNAL( resumed() ), + m_scrobbler, SLOT( trackResumed() ), Qt::QueuedConnection ); + + connect( m_audioEngine, SIGNAL( stopped() ), + m_scrobbler, SLOT( trackStopped() ), Qt::QueuedConnection ); +#else + qDebug() << "Setting NAM."; + TomahawkUtils::setNam( new QNetworkAccessManager ); #endif // Set up proxy if( TomahawkSettings::instance()->proxyType() != QNetworkProxy::NoProxy && - !TomahawkSettings::instance()->proxyHost().isEmpty() ) + !TomahawkSettings::instance()->proxyHost().isEmpty() ) { qDebug() << "Setting proxy to saved values"; TomahawkUtils::setProxy( new QNetworkProxy( static_cast(TomahawkSettings::instance()->proxyType()), TomahawkSettings::instance()->proxyHost(), TomahawkSettings::instance()->proxyPort(), TomahawkSettings::instance()->proxyUsername(), TomahawkSettings::instance()->proxyPassword() ) ); From 6fa87ebea5c61af54bebf50f688495e9b344a8dc Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Mon, 14 Feb 2011 18:52:18 +0100 Subject: [PATCH 58/62] * This should hopefully fix CLuceneError exceptions on Win32. --- src/libtomahawk/database/fuzzyindex.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libtomahawk/database/fuzzyindex.cpp b/src/libtomahawk/database/fuzzyindex.cpp index 5f0c62e40..1a6cdb724 100644 --- a/src/libtomahawk/database/fuzzyindex.cpp +++ b/src/libtomahawk/database/fuzzyindex.cpp @@ -46,6 +46,11 @@ FuzzyIndex::beginIndexing() { m_mutex.lock(); + delete m_luceneSearcher; + delete m_luceneReader; + m_luceneSearcher = 0; + m_luceneReader = 0; + try { IndexWriter luceneWriter = IndexWriter( m_luceneDir, m_analyzer, true ); @@ -71,11 +76,6 @@ FuzzyIndex::appendFields( const QString& table, const QMap< unsigned int, QStrin { try { - delete m_luceneSearcher; - delete m_luceneReader; - m_luceneSearcher = 0; - m_luceneReader = 0; - bool create = !IndexReader::indexExists( TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" ).toStdString().c_str() ); IndexWriter luceneWriter = IndexWriter( m_luceneDir, m_analyzer, create ); Document doc; From a5895da88346dc5524b34b586bc5a3c6eac7d0d7 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 14 Feb 2011 13:38:50 -0500 Subject: [PATCH 59/62] Only include twitter key file if it actually exists --- thirdparty/qtweetlib/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/thirdparty/qtweetlib/CMakeLists.txt b/thirdparty/qtweetlib/CMakeLists.txt index 431604c3f..331bf45a5 100644 --- a/thirdparty/qtweetlib/CMakeLists.txt +++ b/thirdparty/qtweetlib/CMakeLists.txt @@ -172,7 +172,10 @@ target_link_libraries(tomahawk_qtweetlib ) SET_TARGET_PROPERTIES( tomahawk_qtweetlib PROPERTIES DEFINE_SYMBOL MAKE_QTWEETLIB_LIB ) -include ( ${CMAKE_CURRENT_SOURCE_DIR}/WARNING-twitter-api-keys ) + +IF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/WARNING-twitter-api-keys ) + INCLUDE( ${CMAKE_CURRENT_SOURCE_DIR}/WARNING-twitter-api-keys ) +ENDIF() INSTALL(TARGETS tomahawk_qtweetlib DESTINATION lib) From 697d69a54f3125b6eca647300a75f920c540e8ff Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 14 Feb 2011 13:40:52 -0500 Subject: [PATCH 60/62] Display warning if twitter consumer key/secret file not found, letting users know it will not be available --- thirdparty/qtweetlib/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/thirdparty/qtweetlib/CMakeLists.txt b/thirdparty/qtweetlib/CMakeLists.txt index 331bf45a5..fd6ac782a 100644 --- a/thirdparty/qtweetlib/CMakeLists.txt +++ b/thirdparty/qtweetlib/CMakeLists.txt @@ -175,6 +175,8 @@ SET_TARGET_PROPERTIES( tomahawk_qtweetlib PROPERTIES DEFINE_SYMBOL MAKE_QTWEETL IF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/WARNING-twitter-api-keys ) INCLUDE( ${CMAKE_CURRENT_SOURCE_DIR}/WARNING-twitter-api-keys ) +ELSE() + MESSAGE( WARNING "Twitter Consumer Key/Secret OAuth keys not found; Twitter SIP support will not be available" ) ENDIF() INSTALL(TARGETS tomahawk_qtweetlib DESTINATION lib) From 4060a95c3859d3b9ac87362e6af6a63f497be4a5 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 14 Feb 2011 14:28:48 -0500 Subject: [PATCH 61/62] Fix link error from not-included cpp file --- src/libtomahawk/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index e6e2083f4..8e53e4edc 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -50,6 +50,7 @@ set( libSources database/databasecommand_logplayback.cpp database/databasecommand_addsource.cpp database/databasecommand_sourceoffline.cpp + database/databasecommand_collectionstats.cpp database/databasecommand_loadplaylistentries.cpp database/databasecommand_modifyplaylist.cpp database/databasecommand_playbackhistory.cpp @@ -307,7 +308,7 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. ../../thirdparty/jdns ../../thirdparty/jdns/jdns ../../thirdparty/jdns/jdnsshared - ../../thirdparty/qtweetlib/src + ../../thirdparty/qtweetlib/qtweetlib/src playlist ) From d858c3fae8e713b92640dea060ee9d7566cab4fa Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 14 Feb 2011 14:29:37 -0500 Subject: [PATCH 62/62] Clean up qtweetlib a bit, and put API keys back...can change them at some point if it becomes a problem --- examples/twitter-api-keys.example | 9 - src/CMakeLists.txt | 2 +- thirdparty/qtweetlib/CMakeLists.txt | 278 +++++++++--------- thirdparty/qtweetlib/{ => qtweetlib}/LICENSE | 0 .../qtweetlib/{ => qtweetlib}/QTweetLib.pro | 0 thirdparty/qtweetlib/{ => qtweetlib}/README | 0 .../{ => qtweetlib}/examples/examples.pro | 0 .../examples/followers/FollowerDelegate.qml | 0 .../examples/followers/FollowersList.qml | 0 .../examples/followers/followers.cpp | 0 .../examples/followers/followers.h | 0 .../examples/followers/followers.pro | 0 .../examples/followers/followers.qrc | 0 .../examples/followers/followers.ui | 0 .../examples/followers/followerslistmodel.cpp | 0 .../examples/followers/followerslistmodel.h | 0 .../examples/followers/main.cpp | 0 .../examples/georeverse/georeverse.cpp | 0 .../examples/georeverse/georeverse.h | 0 .../examples/georeverse/georeverse.pro | 0 .../examples/georeverse/georeverse.ui | 0 .../examples/georeverse/main.cpp | 0 .../examples/geosearch/geosearch.cpp | 0 .../examples/geosearch/geosearch.h | 0 .../examples/geosearch/geosearch.pro | 0 .../examples/geosearch/geosearch.ui | 0 .../examples/geosearch/main.cpp | 0 .../{ => qtweetlib}/examples/search/main.cpp | 0 .../examples/search/mainwindow.cpp | 0 .../examples/search/mainwindow.h | 0 .../examples/search/mainwindow.ui | 0 .../examples/search/search.pro | 0 .../examples/statusupdate/main.cpp | 0 .../examples/statusupdate/mainwindow.cpp | 0 .../examples/statusupdate/mainwindow.h | 0 .../examples/statusupdate/mainwindow.ui | 0 .../examples/statusupdate/statusupdate.pro | 0 .../examples/timelines/main.cpp | 0 .../examples/timelines/mainwindow.cpp | 0 .../examples/timelines/mainwindow.h | 0 .../examples/timelines/mainwindow.ui | 0 .../examples/timelines/timelines.pro | 0 .../examples/userstream/main.cpp | 0 .../examples/userstream/userstream.cpp | 0 .../examples/userstream/userstream.h | 0 .../examples/userstream/userstream.pro | 0 .../examples/userstream/userstream.ui | 0 .../{ => qtweetlib}/qjson/json_parser.cc | 0 .../{ => qtweetlib}/qjson/json_parser.hh | 0 .../{ => qtweetlib}/qjson/json_parser.yy | 0 .../{ => qtweetlib}/qjson/json_scanner.cpp | 0 .../{ => qtweetlib}/qjson/json_scanner.h | 0 .../{ => qtweetlib}/qjson/location.hh | 0 .../{ => qtweetlib}/qjson/parser.cpp | 0 .../qtweetlib/{ => qtweetlib}/qjson/parser.h | 0 .../{ => qtweetlib}/qjson/parser_p.h | 0 .../{ => qtweetlib}/qjson/parserrunnable.cpp | 0 .../{ => qtweetlib}/qjson/parserrunnable.h | 0 .../{ => qtweetlib}/qjson/position.hh | 0 .../qtweetlib/{ => qtweetlib}/qjson/qjson.pro | 0 .../{ => qtweetlib}/qjson/qjson_debug.h | 0 .../{ => qtweetlib}/qjson/qjson_export.h | 0 .../{ => qtweetlib}/qjson/qobjecthelper.cpp | 0 .../{ => qtweetlib}/qjson/qobjecthelper.h | 0 .../{ => qtweetlib}/qjson/serializer.cpp | 0 .../{ => qtweetlib}/qjson/serializer.h | 0 .../qjson/serializerrunnable.cpp | 0 .../qjson/serializerrunnable.h | 0 .../qtweetlib/{ => qtweetlib}/qjson/src.pro | 0 .../qtweetlib/{ => qtweetlib}/qjson/stack.hh | 0 .../qtweetlib/{ => qtweetlib}/src/oauth.cpp | 0 .../qtweetlib/{ => qtweetlib}/src/oauth.h | 0 .../{ => qtweetlib}/src/oauthtwitter.cpp | 0 .../{ => qtweetlib}/src/oauthtwitter.h | 0 .../src/qtweetaccountratelimitstatus.cpp | 0 .../src/qtweetaccountratelimitstatus.h | 0 .../src/qtweetaccountverifycredentials.cpp | 0 .../src/qtweetaccountverifycredentials.h | 0 .../{ => qtweetlib}/src/qtweetconvert.cpp | 0 .../{ => qtweetlib}/src/qtweetconvert.h | 0 .../src/qtweetdirectmessagedestroy.cpp | 0 .../src/qtweetdirectmessagedestroy.h | 0 .../src/qtweetdirectmessagenew.cpp | 0 .../src/qtweetdirectmessagenew.h | 0 .../src/qtweetdirectmessages.cpp | 0 .../src/qtweetdirectmessages.h | 0 .../src/qtweetdirectmessagessent.cpp | 0 .../src/qtweetdirectmessagessent.h | 0 .../{ => qtweetlib}/src/qtweetdmstatus.cpp | 0 .../{ => qtweetlib}/src/qtweetdmstatus.h | 0 .../src/qtweetentityhashtag.cpp | 0 .../{ => qtweetlib}/src/qtweetentityhashtag.h | 0 .../{ => qtweetlib}/src/qtweetentityurl.cpp | 0 .../{ => qtweetlib}/src/qtweetentityurl.h | 0 .../src/qtweetentityusermentions.cpp | 0 .../src/qtweetentityusermentions.h | 0 .../{ => qtweetlib}/src/qtweetfavorites.cpp | 0 .../{ => qtweetlib}/src/qtweetfavorites.h | 0 .../src/qtweetfavoritescreate.cpp | 0 .../src/qtweetfavoritescreate.h | 0 .../src/qtweetfavoritesdestroy.cpp | 0 .../src/qtweetfavoritesdestroy.h | 0 .../{ => qtweetlib}/src/qtweetfollowersid.cpp | 0 .../{ => qtweetlib}/src/qtweetfollowersid.h | 0 .../src/qtweetfriendshipcreate.cpp | 0 .../src/qtweetfriendshipcreate.h | 0 .../src/qtweetfriendshipdestroy.cpp | 0 .../src/qtweetfriendshipdestroy.h | 0 .../{ => qtweetlib}/src/qtweetfriendsid.cpp | 0 .../{ => qtweetlib}/src/qtweetfriendsid.h | 0 .../src/qtweetfriendstimeline.cpp | 0 .../src/qtweetfriendstimeline.h | 0 .../src/qtweetgeoboundingbox.cpp | 0 .../src/qtweetgeoboundingbox.h | 0 .../{ => qtweetlib}/src/qtweetgeocoord.cpp | 0 .../{ => qtweetlib}/src/qtweetgeocoord.h | 0 .../src/qtweetgeoplacecreate.cpp | 0 .../src/qtweetgeoplacecreate.h | 0 .../{ => qtweetlib}/src/qtweetgeoplaceid.cpp | 0 .../{ => qtweetlib}/src/qtweetgeoplaceid.h | 0 .../src/qtweetgeoreversegeocode.cpp | 0 .../src/qtweetgeoreversegeocode.h | 0 .../{ => qtweetlib}/src/qtweetgeosearch.cpp | 0 .../{ => qtweetlib}/src/qtweetgeosearch.h | 0 .../src/qtweetgeosimilarplaces.cpp | 0 .../src/qtweetgeosimilarplaces.h | 0 .../src/qtweethometimeline.cpp | 0 .../{ => qtweetlib}/src/qtweethometimeline.h | 0 .../{ => qtweetlib}/src/qtweetlib_global.h | 0 .../{ => qtweetlib}/src/qtweetlist.cpp | 0 .../{ => qtweetlib}/src/qtweetlist.h | 0 .../src/qtweetlistaddmember.cpp | 0 .../{ => qtweetlib}/src/qtweetlistaddmember.h | 0 .../{ => qtweetlib}/src/qtweetlistcreate.cpp | 0 .../{ => qtweetlib}/src/qtweetlistcreate.h | 0 .../src/qtweetlistdeletelist.cpp | 0 .../src/qtweetlistdeletelist.h | 0 .../src/qtweetlistdeletemember.cpp | 0 .../src/qtweetlistdeletemember.h | 0 .../src/qtweetlistgetlists.cpp | 0 .../{ => qtweetlib}/src/qtweetlistgetlists.h | 0 .../src/qtweetlistgetmembers.cpp | 0 .../src/qtweetlistgetmembers.h | 0 .../src/qtweetlistmemberships.cpp | 0 .../src/qtweetlistmemberships.h | 0 .../src/qtweetlistshowlist.cpp | 0 .../{ => qtweetlib}/src/qtweetlistshowlist.h | 0 .../src/qtweetliststatuses.cpp | 0 .../{ => qtweetlib}/src/qtweetliststatuses.h | 0 .../src/qtweetlistsubscribe.cpp | 0 .../{ => qtweetlib}/src/qtweetlistsubscribe.h | 0 .../src/qtweetlistsubscribers.cpp | 0 .../src/qtweetlistsubscribers.h | 0 .../src/qtweetlistsubscriptions.cpp | 0 .../src/qtweetlistsubscriptions.h | 0 .../src/qtweetlistunsubscribe.cpp | 0 .../src/qtweetlistunsubscribe.h | 0 .../{ => qtweetlib}/src/qtweetlistupdate.cpp | 0 .../{ => qtweetlib}/src/qtweetlistupdate.h | 0 .../{ => qtweetlib}/src/qtweetmentions.cpp | 0 .../{ => qtweetlib}/src/qtweetmentions.h | 0 .../{ => qtweetlib}/src/qtweetnetbase.cpp | 0 .../{ => qtweetlib}/src/qtweetnetbase.h | 0 .../{ => qtweetlib}/src/qtweetplace.cpp | 0 .../{ => qtweetlib}/src/qtweetplace.h | 0 .../{ => qtweetlib}/src/qtweetretweetbyme.cpp | 0 .../{ => qtweetlib}/src/qtweetretweetbyme.h | 0 .../src/qtweetretweetsofme.cpp | 0 .../{ => qtweetlib}/src/qtweetretweetsofme.h | 0 .../{ => qtweetlib}/src/qtweetretweettome.cpp | 0 .../{ => qtweetlib}/src/qtweetretweettome.h | 0 .../{ => qtweetlib}/src/qtweetsearch.cpp | 0 .../{ => qtweetlib}/src/qtweetsearch.h | 0 .../src/qtweetsearchpageresults.cpp | 0 .../src/qtweetsearchpageresults.h | 0 .../src/qtweetsearchresult.cpp | 0 .../{ => qtweetlib}/src/qtweetsearchresult.h | 0 .../{ => qtweetlib}/src/qtweetstatus.cpp | 0 .../{ => qtweetlib}/src/qtweetstatus.h | 0 .../src/qtweetstatusdestroy.cpp | 0 .../{ => qtweetlib}/src/qtweetstatusdestroy.h | 0 .../src/qtweetstatusretweet.cpp | 0 .../{ => qtweetlib}/src/qtweetstatusretweet.h | 0 .../src/qtweetstatusretweets.cpp | 0 .../src/qtweetstatusretweets.h | 0 .../{ => qtweetlib}/src/qtweetstatusshow.cpp | 0 .../{ => qtweetlib}/src/qtweetstatusshow.h | 0 .../src/qtweetstatusupdate.cpp | 0 .../{ => qtweetlib}/src/qtweetstatusupdate.h | 0 .../{ => qtweetlib}/src/qtweetuser.cpp | 0 .../{ => qtweetlib}/src/qtweetuser.h | 0 .../{ => qtweetlib}/src/qtweetuserlookup.cpp | 0 .../{ => qtweetlib}/src/qtweetuserlookup.h | 0 .../{ => qtweetlib}/src/qtweetusersearch.cpp | 0 .../{ => qtweetlib}/src/qtweetusersearch.h | 0 .../{ => qtweetlib}/src/qtweetusershow.cpp | 0 .../{ => qtweetlib}/src/qtweetusershow.h | 0 .../src/qtweetuserstatusesfollowers.cpp | 0 .../src/qtweetuserstatusesfollowers.h | 0 .../src/qtweetuserstatusesfriends.cpp | 0 .../src/qtweetuserstatusesfriends.h | 0 .../{ => qtweetlib}/src/qtweetuserstream.cpp | 0 .../{ => qtweetlib}/src/qtweetuserstream.h | 0 .../src/qtweetusertimeline.cpp | 0 .../{ => qtweetlib}/src/qtweetusertimeline.h | 0 .../qtweetlib/{ => qtweetlib}/src/src.pro | 0 thirdparty/qtweetlib/twitter-api-keys | 9 + 207 files changed, 147 insertions(+), 151 deletions(-) delete mode 100644 examples/twitter-api-keys.example rename thirdparty/qtweetlib/{ => qtweetlib}/LICENSE (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/QTweetLib.pro (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/README (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/examples.pro (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/followers/FollowerDelegate.qml (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/followers/FollowersList.qml (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/followers/followers.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/followers/followers.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/followers/followers.pro (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/followers/followers.qrc (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/followers/followers.ui (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/followers/followerslistmodel.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/followers/followerslistmodel.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/followers/main.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/georeverse/georeverse.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/georeverse/georeverse.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/georeverse/georeverse.pro (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/georeverse/georeverse.ui (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/georeverse/main.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/geosearch/geosearch.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/geosearch/geosearch.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/geosearch/geosearch.pro (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/geosearch/geosearch.ui (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/geosearch/main.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/search/main.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/search/mainwindow.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/search/mainwindow.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/search/mainwindow.ui (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/search/search.pro (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/statusupdate/main.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/statusupdate/mainwindow.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/statusupdate/mainwindow.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/statusupdate/mainwindow.ui (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/statusupdate/statusupdate.pro (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/timelines/main.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/timelines/mainwindow.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/timelines/mainwindow.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/timelines/mainwindow.ui (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/timelines/timelines.pro (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/userstream/main.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/userstream/userstream.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/userstream/userstream.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/userstream/userstream.pro (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/examples/userstream/userstream.ui (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/json_parser.cc (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/json_parser.hh (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/json_parser.yy (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/json_scanner.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/json_scanner.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/location.hh (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/parser.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/parser.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/parser_p.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/parserrunnable.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/parserrunnable.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/position.hh (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/qjson.pro (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/qjson_debug.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/qjson_export.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/qobjecthelper.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/qobjecthelper.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/serializer.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/serializer.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/serializerrunnable.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/serializerrunnable.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/src.pro (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/qjson/stack.hh (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/oauth.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/oauth.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/oauthtwitter.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/oauthtwitter.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetaccountratelimitstatus.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetaccountratelimitstatus.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetaccountverifycredentials.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetaccountverifycredentials.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetconvert.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetconvert.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetdirectmessagedestroy.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetdirectmessagedestroy.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetdirectmessagenew.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetdirectmessagenew.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetdirectmessages.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetdirectmessages.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetdirectmessagessent.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetdirectmessagessent.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetdmstatus.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetdmstatus.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetentityhashtag.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetentityhashtag.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetentityurl.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetentityurl.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetentityusermentions.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetentityusermentions.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfavorites.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfavorites.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfavoritescreate.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfavoritescreate.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfavoritesdestroy.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfavoritesdestroy.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfollowersid.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfollowersid.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfriendshipcreate.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfriendshipcreate.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfriendshipdestroy.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfriendshipdestroy.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfriendsid.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfriendsid.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfriendstimeline.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetfriendstimeline.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeoboundingbox.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeoboundingbox.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeocoord.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeocoord.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeoplacecreate.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeoplacecreate.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeoplaceid.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeoplaceid.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeoreversegeocode.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeoreversegeocode.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeosearch.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeosearch.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeosimilarplaces.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetgeosimilarplaces.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweethometimeline.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweethometimeline.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlib_global.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlist.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlist.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistaddmember.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistaddmember.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistcreate.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistcreate.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistdeletelist.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistdeletelist.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistdeletemember.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistdeletemember.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistgetlists.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistgetlists.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistgetmembers.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistgetmembers.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistmemberships.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistmemberships.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistshowlist.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistshowlist.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetliststatuses.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetliststatuses.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistsubscribe.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistsubscribe.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistsubscribers.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistsubscribers.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistsubscriptions.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistsubscriptions.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistunsubscribe.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistunsubscribe.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistupdate.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetlistupdate.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetmentions.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetmentions.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetnetbase.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetnetbase.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetplace.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetplace.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetretweetbyme.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetretweetbyme.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetretweetsofme.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetretweetsofme.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetretweettome.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetretweettome.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetsearch.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetsearch.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetsearchpageresults.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetsearchpageresults.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetsearchresult.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetsearchresult.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetstatus.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetstatus.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetstatusdestroy.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetstatusdestroy.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetstatusretweet.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetstatusretweet.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetstatusretweets.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetstatusretweets.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetstatusshow.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetstatusshow.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetstatusupdate.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetstatusupdate.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetuser.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetuser.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetuserlookup.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetuserlookup.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetusersearch.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetusersearch.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetusershow.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetusershow.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetuserstatusesfollowers.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetuserstatusesfollowers.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetuserstatusesfriends.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetuserstatusesfriends.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetuserstream.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetuserstream.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetusertimeline.cpp (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/qtweetusertimeline.h (100%) rename thirdparty/qtweetlib/{ => qtweetlib}/src/src.pro (100%) create mode 100644 thirdparty/qtweetlib/twitter-api-keys diff --git a/examples/twitter-api-keys.example b/examples/twitter-api-keys.example deleted file mode 100644 index 5fa0abee7..000000000 --- a/examples/twitter-api-keys.example +++ /dev/null @@ -1,9 +0,0 @@ -set_property( - TARGET tomahawk_qtweetlib - APPEND PROPERTY COMPILE_DEFINITIONS CONSUMER_KEY="aaaaaaaaaaaaaaa" -) - -set_property( - TARGET tomahawk_qtweetlib - APPEND PROPERTY COMPILE_DEFINITIONS CONSUMER_SECRET="bbbbbbbbbbbbbbbbb" -) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 477781072..75a08412a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -124,7 +124,7 @@ INCLUDE_DIRECTORIES( ../alsa-playback ../rtaudio ../qxt/qxtweb-standalone/qxtweb - ../thirdparty/qtweetlib/src + ../thirdparty/qtweetlib/qtweetlib/src /usr/include/taglib /usr/local/include/taglib diff --git a/thirdparty/qtweetlib/CMakeLists.txt b/thirdparty/qtweetlib/CMakeLists.txt index fd6ac782a..55fa6cbcd 100644 --- a/thirdparty/qtweetlib/CMakeLists.txt +++ b/thirdparty/qtweetlib/CMakeLists.txt @@ -15,151 +15,151 @@ if(WIN32) endif(WIN32) set(TOMAHAWK_QTWEETLIB_SOURCES - src/oauth.cpp - src/oauthtwitter.cpp - src/qtweetfriendstimeline.cpp - src/qtweethometimeline.cpp - src/qtweetmentions.cpp - src/qtweetnetbase.cpp - src/qtweetretweetbyme.cpp - src/qtweetretweetsofme.cpp - src/qtweetretweettome.cpp - src/qtweetstatus.cpp - src/qtweetstatusshow.cpp - src/qtweetstatusupdate.cpp - src/qtweetuser.cpp - src/qtweetusertimeline.cpp - src/qtweetstatusdestroy.cpp - src/qtweetstatusretweet.cpp - src/qtweetstatusretweets.cpp - src/qtweetusershow.cpp - src/qtweetuserlookup.cpp - src/qtweetdirectmessages.cpp - src/qtweetuserstream.cpp - src/qtweetdmstatus.cpp - src/qtweetusersearch.cpp - src/qtweetuserstatusesfriends.cpp - src/qtweetuserstatusesfollowers.cpp - src/qtweetlist.cpp - src/qtweetlistcreate.cpp - src/qtweetlistupdate.cpp - src/qtweetlistgetlists.cpp - src/qtweetlistshowlist.cpp - src/qtweetlistdeletelist.cpp - src/qtweetliststatuses.cpp - src/qtweetlistmemberships.cpp - src/qtweetlistsubscriptions.cpp - src/qtweetlistgetmembers.cpp - src/qtweetlistaddmember.cpp - src/qtweetlistdeletemember.cpp - src/qtweetlistsubscribers.cpp - src/qtweetlistsubscribe.cpp - src/qtweetlistunsubscribe.cpp - src/qtweetdirectmessagessent.cpp - src/qtweetdirectmessagenew.cpp - src/qtweetdirectmessagedestroy.cpp - src/qtweetfriendshipcreate.cpp - src/qtweetfriendshipdestroy.cpp - src/qtweetfriendsid.cpp - src/qtweetfollowersid.cpp - src/qtweetaccountverifycredentials.cpp - src/qtweetaccountratelimitstatus.cpp - src/qtweetfavorites.cpp - src/qtweetfavoritescreate.cpp - src/qtweetfavoritesdestroy.cpp - src/qtweetsearch.cpp - src/qtweetsearchresult.cpp - src/qtweetsearchpageresults.cpp - src/qtweetplace.cpp - src/qtweetgeoreversegeocode.cpp - src/qtweetgeosearch.cpp - src/qtweetgeosimilarplaces.cpp - src/qtweetgeoplaceid.cpp - src/qtweetgeoplacecreate.cpp - src/qtweetgeocoord.cpp - src/qtweetgeoboundingbox.cpp - src/qtweetconvert.cpp - src/qtweetentityurl.cpp - src/qtweetentityhashtag.cpp - src/qtweetentityusermentions.cpp + qtweetlib/src/oauth.cpp + qtweetlib/src/oauthtwitter.cpp + qtweetlib/src/qtweetfriendstimeline.cpp + qtweetlib/src/qtweethometimeline.cpp + qtweetlib/src/qtweetmentions.cpp + qtweetlib/src/qtweetnetbase.cpp + qtweetlib/src/qtweetretweetbyme.cpp + qtweetlib/src/qtweetretweetsofme.cpp + qtweetlib/src/qtweetretweettome.cpp + qtweetlib/src/qtweetstatus.cpp + qtweetlib/src/qtweetstatusshow.cpp + qtweetlib/src/qtweetstatusupdate.cpp + qtweetlib/src/qtweetuser.cpp + qtweetlib/src/qtweetusertimeline.cpp + qtweetlib/src/qtweetstatusdestroy.cpp + qtweetlib/src/qtweetstatusretweet.cpp + qtweetlib/src/qtweetstatusretweets.cpp + qtweetlib/src/qtweetusershow.cpp + qtweetlib/src/qtweetuserlookup.cpp + qtweetlib/src/qtweetdirectmessages.cpp + qtweetlib/src/qtweetuserstream.cpp + qtweetlib/src/qtweetdmstatus.cpp + qtweetlib/src/qtweetusersearch.cpp + qtweetlib/src/qtweetuserstatusesfriends.cpp + qtweetlib/src/qtweetuserstatusesfollowers.cpp + qtweetlib/src/qtweetlist.cpp + qtweetlib/src/qtweetlistcreate.cpp + qtweetlib/src/qtweetlistupdate.cpp + qtweetlib/src/qtweetlistgetlists.cpp + qtweetlib/src/qtweetlistshowlist.cpp + qtweetlib/src/qtweetlistdeletelist.cpp + qtweetlib/src/qtweetliststatuses.cpp + qtweetlib/src/qtweetlistmemberships.cpp + qtweetlib/src/qtweetlistsubscriptions.cpp + qtweetlib/src/qtweetlistgetmembers.cpp + qtweetlib/src/qtweetlistaddmember.cpp + qtweetlib/src/qtweetlistdeletemember.cpp + qtweetlib/src/qtweetlistsubscribers.cpp + qtweetlib/src/qtweetlistsubscribe.cpp + qtweetlib/src/qtweetlistunsubscribe.cpp + qtweetlib/src/qtweetdirectmessagessent.cpp + qtweetlib/src/qtweetdirectmessagenew.cpp + qtweetlib/src/qtweetdirectmessagedestroy.cpp + qtweetlib/src/qtweetfriendshipcreate.cpp + qtweetlib/src/qtweetfriendshipdestroy.cpp + qtweetlib/src/qtweetfriendsid.cpp + qtweetlib/src/qtweetfollowersid.cpp + qtweetlib/src/qtweetaccountverifycredentials.cpp + qtweetlib/src/qtweetaccountratelimitstatus.cpp + qtweetlib/src/qtweetfavorites.cpp + qtweetlib/src/qtweetfavoritescreate.cpp + qtweetlib/src/qtweetfavoritesdestroy.cpp + qtweetlib/src/qtweetsearch.cpp + qtweetlib/src/qtweetsearchresult.cpp + qtweetlib/src/qtweetsearchpageresults.cpp + qtweetlib/src/qtweetplace.cpp + qtweetlib/src/qtweetgeoreversegeocode.cpp + qtweetlib/src/qtweetgeosearch.cpp + qtweetlib/src/qtweetgeosimilarplaces.cpp + qtweetlib/src/qtweetgeoplaceid.cpp + qtweetlib/src/qtweetgeoplacecreate.cpp + qtweetlib/src/qtweetgeocoord.cpp + qtweetlib/src/qtweetgeoboundingbox.cpp + qtweetlib/src/qtweetconvert.cpp + qtweetlib/src/qtweetentityurl.cpp + qtweetlib/src/qtweetentityhashtag.cpp + qtweetlib/src/qtweetentityusermentions.cpp ) set(TOMAHAWK_QTWEETLIB_HEADERS - src/oauth.h - src/oauthtwitter.h - src/qtweetfriendstimeline.h - src/qtweetlib_global.h - src/qtweethometimeline.h - src/qtweetmentions.h - src/qtweetnetbase.h - src/qtweetretweetbyme.h - src/qtweetretweetsofme.h - src/qtweetretweettome.h - src/qtweetstatus.h - src/qtweetstatusshow.h - src/qtweetstatusupdate.h - src/qtweetuser.h - src/qtweetusertimeline.h - src/qtweetstatusdestroy.h - src/qtweetstatusretweet.h - src/qtweetstatusretweets.h - src/qtweetusershow.h - src/qtweetuserlookup.h - src/qtweetdirectmessages.h - src/qtweetuserstream.h - src/qtweetdmstatus.h - src/qtweetusersearch.h - src/qtweetuserstatusesfriends.h - src/qtweetuserstatusesfollowers.h - src/qtweetlist.h - src/qtweetlistcreate.h - src/qtweetlistupdate.h - src/qtweetlistgetlists.h - src/qtweetlistshowlist.h - src/qtweetlistdeletelist.h - src/qtweetliststatuses.h - src/qtweetlistmemberships.h - src/qtweetlistsubscriptions.h - src/qtweetlistgetmembers.h - src/qtweetlistaddmember.h - src/qtweetlistdeletemember.h - src/qtweetlistsubscribers.h - src/qtweetlistsubscribe.h - src/qtweetlistunsubscribe.h - src/qtweetdirectmessagessent.h - src/qtweetdirectmessagenew.h - src/qtweetdirectmessagedestroy.h - src/qtweetfriendshipcreate.h - src/qtweetfriendshipdestroy.h - src/qtweetfriendsid.h - src/qtweetfollowersid.h - src/qtweetaccountverifycredentials.h - src/qtweetaccountratelimitstatus.h - src/qtweetfavorites.h - src/qtweetfavoritescreate.h - src/qtweetfavoritesdestroy.h - src/qtweetsearch.h - src/qtweetsearchresult.h - src/qtweetsearchpageresults.h - src/qtweetplace.h - src/qtweetgeoreversegeocode.h - src/qtweetgeosearch.h - src/qtweetgeosimilarplaces.h - src/qtweetgeoplaceid.h - src/qtweetgeoplacecreate.h - src/qtweetgeocoord.h - src/qtweetgeoboundingbox.h - src/qtweetconvert.h - src/qtweetentityurl.h - src/qtweetentityhashtag.h - src/qtweetentityusermentions.h + qtweetlib/src/oauth.h + qtweetlib/src/oauthtwitter.h + qtweetlib/src/qtweetfriendstimeline.h + qtweetlib/src/qtweetlib_global.h + qtweetlib/src/qtweethometimeline.h + qtweetlib/src/qtweetmentions.h + qtweetlib/src/qtweetnetbase.h + qtweetlib/src/qtweetretweetbyme.h + qtweetlib/src/qtweetretweetsofme.h + qtweetlib/src/qtweetretweettome.h + qtweetlib/src/qtweetstatus.h + qtweetlib/src/qtweetstatusshow.h + qtweetlib/src/qtweetstatusupdate.h + qtweetlib/src/qtweetuser.h + qtweetlib/src/qtweetusertimeline.h + qtweetlib/src/qtweetstatusdestroy.h + qtweetlib/src/qtweetstatusretweet.h + qtweetlib/src/qtweetstatusretweets.h + qtweetlib/src/qtweetusershow.h + qtweetlib/src/qtweetuserlookup.h + qtweetlib/src/qtweetdirectmessages.h + qtweetlib/src/qtweetuserstream.h + qtweetlib/src/qtweetdmstatus.h + qtweetlib/src/qtweetusersearch.h + qtweetlib/src/qtweetuserstatusesfriends.h + qtweetlib/src/qtweetuserstatusesfollowers.h + qtweetlib/src/qtweetlist.h + qtweetlib/src/qtweetlistcreate.h + qtweetlib/src/qtweetlistupdate.h + qtweetlib/src/qtweetlistgetlists.h + qtweetlib/src/qtweetlistshowlist.h + qtweetlib/src/qtweetlistdeletelist.h + qtweetlib/src/qtweetliststatuses.h + qtweetlib/src/qtweetlistmemberships.h + qtweetlib/src/qtweetlistsubscriptions.h + qtweetlib/src/qtweetlistgetmembers.h + qtweetlib/src/qtweetlistaddmember.h + qtweetlib/src/qtweetlistdeletemember.h + qtweetlib/src/qtweetlistsubscribers.h + qtweetlib/src/qtweetlistsubscribe.h + qtweetlib/src/qtweetlistunsubscribe.h + qtweetlib/src/qtweetdirectmessagessent.h + qtweetlib/src/qtweetdirectmessagenew.h + qtweetlib/src/qtweetdirectmessagedestroy.h + qtweetlib/src/qtweetfriendshipcreate.h + qtweetlib/src/qtweetfriendshipdestroy.h + qtweetlib/src/qtweetfriendsid.h + qtweetlib/src/qtweetfollowersid.h + qtweetlib/src/qtweetaccountverifycredentials.h + qtweetlib/src/qtweetaccountratelimitstatus.h + qtweetlib/src/qtweetfavorites.h + qtweetlib/src/qtweetfavoritescreate.h + qtweetlib/src/qtweetfavoritesdestroy.h + qtweetlib/src/qtweetsearch.h + qtweetlib/src/qtweetsearchresult.h + qtweetlib/src/qtweetsearchpageresults.h + qtweetlib/src/qtweetplace.h + qtweetlib/src/qtweetgeoreversegeocode.h + qtweetlib/src/qtweetgeosearch.h + qtweetlib/src/qtweetgeosimilarplaces.h + qtweetlib/src/qtweetgeoplaceid.h + qtweetlib/src/qtweetgeoplacecreate.h + qtweetlib/src/qtweetgeocoord.h + qtweetlib/src/qtweetgeoboundingbox.h + qtweetlib/src/qtweetconvert.h + qtweetlib/src/qtweetentityurl.h + qtweetlib/src/qtweetentityhashtag.h + qtweetlib/src/qtweetentityusermentions.h ) include_directories( . ${QT_INCLUDE_DIR} ${QT_INCLUDES} - src + qtweetlib/src ) qt4_wrap_cpp( TOMAHAWK_QTWEETLIB_MOC ${TOMAHAWK_QTWEETLIB_HEADERS} ) @@ -173,11 +173,7 @@ target_link_libraries(tomahawk_qtweetlib SET_TARGET_PROPERTIES( tomahawk_qtweetlib PROPERTIES DEFINE_SYMBOL MAKE_QTWEETLIB_LIB ) -IF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/WARNING-twitter-api-keys ) - INCLUDE( ${CMAKE_CURRENT_SOURCE_DIR}/WARNING-twitter-api-keys ) -ELSE() - MESSAGE( WARNING "Twitter Consumer Key/Secret OAuth keys not found; Twitter SIP support will not be available" ) -ENDIF() +INCLUDE( ${CMAKE_CURRENT_SOURCE_DIR}/twitter-api-keys ) INSTALL(TARGETS tomahawk_qtweetlib DESTINATION lib) diff --git a/thirdparty/qtweetlib/LICENSE b/thirdparty/qtweetlib/qtweetlib/LICENSE similarity index 100% rename from thirdparty/qtweetlib/LICENSE rename to thirdparty/qtweetlib/qtweetlib/LICENSE diff --git a/thirdparty/qtweetlib/QTweetLib.pro b/thirdparty/qtweetlib/qtweetlib/QTweetLib.pro similarity index 100% rename from thirdparty/qtweetlib/QTweetLib.pro rename to thirdparty/qtweetlib/qtweetlib/QTweetLib.pro diff --git a/thirdparty/qtweetlib/README b/thirdparty/qtweetlib/qtweetlib/README similarity index 100% rename from thirdparty/qtweetlib/README rename to thirdparty/qtweetlib/qtweetlib/README diff --git a/thirdparty/qtweetlib/examples/examples.pro b/thirdparty/qtweetlib/qtweetlib/examples/examples.pro similarity index 100% rename from thirdparty/qtweetlib/examples/examples.pro rename to thirdparty/qtweetlib/qtweetlib/examples/examples.pro diff --git a/thirdparty/qtweetlib/examples/followers/FollowerDelegate.qml b/thirdparty/qtweetlib/qtweetlib/examples/followers/FollowerDelegate.qml similarity index 100% rename from thirdparty/qtweetlib/examples/followers/FollowerDelegate.qml rename to thirdparty/qtweetlib/qtweetlib/examples/followers/FollowerDelegate.qml diff --git a/thirdparty/qtweetlib/examples/followers/FollowersList.qml b/thirdparty/qtweetlib/qtweetlib/examples/followers/FollowersList.qml similarity index 100% rename from thirdparty/qtweetlib/examples/followers/FollowersList.qml rename to thirdparty/qtweetlib/qtweetlib/examples/followers/FollowersList.qml diff --git a/thirdparty/qtweetlib/examples/followers/followers.cpp b/thirdparty/qtweetlib/qtweetlib/examples/followers/followers.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/followers/followers.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/followers/followers.cpp diff --git a/thirdparty/qtweetlib/examples/followers/followers.h b/thirdparty/qtweetlib/qtweetlib/examples/followers/followers.h similarity index 100% rename from thirdparty/qtweetlib/examples/followers/followers.h rename to thirdparty/qtweetlib/qtweetlib/examples/followers/followers.h diff --git a/thirdparty/qtweetlib/examples/followers/followers.pro b/thirdparty/qtweetlib/qtweetlib/examples/followers/followers.pro similarity index 100% rename from thirdparty/qtweetlib/examples/followers/followers.pro rename to thirdparty/qtweetlib/qtweetlib/examples/followers/followers.pro diff --git a/thirdparty/qtweetlib/examples/followers/followers.qrc b/thirdparty/qtweetlib/qtweetlib/examples/followers/followers.qrc similarity index 100% rename from thirdparty/qtweetlib/examples/followers/followers.qrc rename to thirdparty/qtweetlib/qtweetlib/examples/followers/followers.qrc diff --git a/thirdparty/qtweetlib/examples/followers/followers.ui b/thirdparty/qtweetlib/qtweetlib/examples/followers/followers.ui similarity index 100% rename from thirdparty/qtweetlib/examples/followers/followers.ui rename to thirdparty/qtweetlib/qtweetlib/examples/followers/followers.ui diff --git a/thirdparty/qtweetlib/examples/followers/followerslistmodel.cpp b/thirdparty/qtweetlib/qtweetlib/examples/followers/followerslistmodel.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/followers/followerslistmodel.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/followers/followerslistmodel.cpp diff --git a/thirdparty/qtweetlib/examples/followers/followerslistmodel.h b/thirdparty/qtweetlib/qtweetlib/examples/followers/followerslistmodel.h similarity index 100% rename from thirdparty/qtweetlib/examples/followers/followerslistmodel.h rename to thirdparty/qtweetlib/qtweetlib/examples/followers/followerslistmodel.h diff --git a/thirdparty/qtweetlib/examples/followers/main.cpp b/thirdparty/qtweetlib/qtweetlib/examples/followers/main.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/followers/main.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/followers/main.cpp diff --git a/thirdparty/qtweetlib/examples/georeverse/georeverse.cpp b/thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/georeverse/georeverse.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.cpp diff --git a/thirdparty/qtweetlib/examples/georeverse/georeverse.h b/thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.h similarity index 100% rename from thirdparty/qtweetlib/examples/georeverse/georeverse.h rename to thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.h diff --git a/thirdparty/qtweetlib/examples/georeverse/georeverse.pro b/thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.pro similarity index 100% rename from thirdparty/qtweetlib/examples/georeverse/georeverse.pro rename to thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.pro diff --git a/thirdparty/qtweetlib/examples/georeverse/georeverse.ui b/thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.ui similarity index 100% rename from thirdparty/qtweetlib/examples/georeverse/georeverse.ui rename to thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.ui diff --git a/thirdparty/qtweetlib/examples/georeverse/main.cpp b/thirdparty/qtweetlib/qtweetlib/examples/georeverse/main.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/georeverse/main.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/georeverse/main.cpp diff --git a/thirdparty/qtweetlib/examples/geosearch/geosearch.cpp b/thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/geosearch/geosearch.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.cpp diff --git a/thirdparty/qtweetlib/examples/geosearch/geosearch.h b/thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.h similarity index 100% rename from thirdparty/qtweetlib/examples/geosearch/geosearch.h rename to thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.h diff --git a/thirdparty/qtweetlib/examples/geosearch/geosearch.pro b/thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.pro similarity index 100% rename from thirdparty/qtweetlib/examples/geosearch/geosearch.pro rename to thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.pro diff --git a/thirdparty/qtweetlib/examples/geosearch/geosearch.ui b/thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.ui similarity index 100% rename from thirdparty/qtweetlib/examples/geosearch/geosearch.ui rename to thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.ui diff --git a/thirdparty/qtweetlib/examples/geosearch/main.cpp b/thirdparty/qtweetlib/qtweetlib/examples/geosearch/main.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/geosearch/main.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/geosearch/main.cpp diff --git a/thirdparty/qtweetlib/examples/search/main.cpp b/thirdparty/qtweetlib/qtweetlib/examples/search/main.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/search/main.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/search/main.cpp diff --git a/thirdparty/qtweetlib/examples/search/mainwindow.cpp b/thirdparty/qtweetlib/qtweetlib/examples/search/mainwindow.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/search/mainwindow.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/search/mainwindow.cpp diff --git a/thirdparty/qtweetlib/examples/search/mainwindow.h b/thirdparty/qtweetlib/qtweetlib/examples/search/mainwindow.h similarity index 100% rename from thirdparty/qtweetlib/examples/search/mainwindow.h rename to thirdparty/qtweetlib/qtweetlib/examples/search/mainwindow.h diff --git a/thirdparty/qtweetlib/examples/search/mainwindow.ui b/thirdparty/qtweetlib/qtweetlib/examples/search/mainwindow.ui similarity index 100% rename from thirdparty/qtweetlib/examples/search/mainwindow.ui rename to thirdparty/qtweetlib/qtweetlib/examples/search/mainwindow.ui diff --git a/thirdparty/qtweetlib/examples/search/search.pro b/thirdparty/qtweetlib/qtweetlib/examples/search/search.pro similarity index 100% rename from thirdparty/qtweetlib/examples/search/search.pro rename to thirdparty/qtweetlib/qtweetlib/examples/search/search.pro diff --git a/thirdparty/qtweetlib/examples/statusupdate/main.cpp b/thirdparty/qtweetlib/qtweetlib/examples/statusupdate/main.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/statusupdate/main.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/statusupdate/main.cpp diff --git a/thirdparty/qtweetlib/examples/statusupdate/mainwindow.cpp b/thirdparty/qtweetlib/qtweetlib/examples/statusupdate/mainwindow.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/statusupdate/mainwindow.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/statusupdate/mainwindow.cpp diff --git a/thirdparty/qtweetlib/examples/statusupdate/mainwindow.h b/thirdparty/qtweetlib/qtweetlib/examples/statusupdate/mainwindow.h similarity index 100% rename from thirdparty/qtweetlib/examples/statusupdate/mainwindow.h rename to thirdparty/qtweetlib/qtweetlib/examples/statusupdate/mainwindow.h diff --git a/thirdparty/qtweetlib/examples/statusupdate/mainwindow.ui b/thirdparty/qtweetlib/qtweetlib/examples/statusupdate/mainwindow.ui similarity index 100% rename from thirdparty/qtweetlib/examples/statusupdate/mainwindow.ui rename to thirdparty/qtweetlib/qtweetlib/examples/statusupdate/mainwindow.ui diff --git a/thirdparty/qtweetlib/examples/statusupdate/statusupdate.pro b/thirdparty/qtweetlib/qtweetlib/examples/statusupdate/statusupdate.pro similarity index 100% rename from thirdparty/qtweetlib/examples/statusupdate/statusupdate.pro rename to thirdparty/qtweetlib/qtweetlib/examples/statusupdate/statusupdate.pro diff --git a/thirdparty/qtweetlib/examples/timelines/main.cpp b/thirdparty/qtweetlib/qtweetlib/examples/timelines/main.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/timelines/main.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/timelines/main.cpp diff --git a/thirdparty/qtweetlib/examples/timelines/mainwindow.cpp b/thirdparty/qtweetlib/qtweetlib/examples/timelines/mainwindow.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/timelines/mainwindow.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/timelines/mainwindow.cpp diff --git a/thirdparty/qtweetlib/examples/timelines/mainwindow.h b/thirdparty/qtweetlib/qtweetlib/examples/timelines/mainwindow.h similarity index 100% rename from thirdparty/qtweetlib/examples/timelines/mainwindow.h rename to thirdparty/qtweetlib/qtweetlib/examples/timelines/mainwindow.h diff --git a/thirdparty/qtweetlib/examples/timelines/mainwindow.ui b/thirdparty/qtweetlib/qtweetlib/examples/timelines/mainwindow.ui similarity index 100% rename from thirdparty/qtweetlib/examples/timelines/mainwindow.ui rename to thirdparty/qtweetlib/qtweetlib/examples/timelines/mainwindow.ui diff --git a/thirdparty/qtweetlib/examples/timelines/timelines.pro b/thirdparty/qtweetlib/qtweetlib/examples/timelines/timelines.pro similarity index 100% rename from thirdparty/qtweetlib/examples/timelines/timelines.pro rename to thirdparty/qtweetlib/qtweetlib/examples/timelines/timelines.pro diff --git a/thirdparty/qtweetlib/examples/userstream/main.cpp b/thirdparty/qtweetlib/qtweetlib/examples/userstream/main.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/userstream/main.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/userstream/main.cpp diff --git a/thirdparty/qtweetlib/examples/userstream/userstream.cpp b/thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.cpp similarity index 100% rename from thirdparty/qtweetlib/examples/userstream/userstream.cpp rename to thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.cpp diff --git a/thirdparty/qtweetlib/examples/userstream/userstream.h b/thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.h similarity index 100% rename from thirdparty/qtweetlib/examples/userstream/userstream.h rename to thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.h diff --git a/thirdparty/qtweetlib/examples/userstream/userstream.pro b/thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.pro similarity index 100% rename from thirdparty/qtweetlib/examples/userstream/userstream.pro rename to thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.pro diff --git a/thirdparty/qtweetlib/examples/userstream/userstream.ui b/thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.ui similarity index 100% rename from thirdparty/qtweetlib/examples/userstream/userstream.ui rename to thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.ui diff --git a/thirdparty/qtweetlib/qjson/json_parser.cc b/thirdparty/qtweetlib/qtweetlib/qjson/json_parser.cc similarity index 100% rename from thirdparty/qtweetlib/qjson/json_parser.cc rename to thirdparty/qtweetlib/qtweetlib/qjson/json_parser.cc diff --git a/thirdparty/qtweetlib/qjson/json_parser.hh b/thirdparty/qtweetlib/qtweetlib/qjson/json_parser.hh similarity index 100% rename from thirdparty/qtweetlib/qjson/json_parser.hh rename to thirdparty/qtweetlib/qtweetlib/qjson/json_parser.hh diff --git a/thirdparty/qtweetlib/qjson/json_parser.yy b/thirdparty/qtweetlib/qtweetlib/qjson/json_parser.yy similarity index 100% rename from thirdparty/qtweetlib/qjson/json_parser.yy rename to thirdparty/qtweetlib/qtweetlib/qjson/json_parser.yy diff --git a/thirdparty/qtweetlib/qjson/json_scanner.cpp b/thirdparty/qtweetlib/qtweetlib/qjson/json_scanner.cpp similarity index 100% rename from thirdparty/qtweetlib/qjson/json_scanner.cpp rename to thirdparty/qtweetlib/qtweetlib/qjson/json_scanner.cpp diff --git a/thirdparty/qtweetlib/qjson/json_scanner.h b/thirdparty/qtweetlib/qtweetlib/qjson/json_scanner.h similarity index 100% rename from thirdparty/qtweetlib/qjson/json_scanner.h rename to thirdparty/qtweetlib/qtweetlib/qjson/json_scanner.h diff --git a/thirdparty/qtweetlib/qjson/location.hh b/thirdparty/qtweetlib/qtweetlib/qjson/location.hh similarity index 100% rename from thirdparty/qtweetlib/qjson/location.hh rename to thirdparty/qtweetlib/qtweetlib/qjson/location.hh diff --git a/thirdparty/qtweetlib/qjson/parser.cpp b/thirdparty/qtweetlib/qtweetlib/qjson/parser.cpp similarity index 100% rename from thirdparty/qtweetlib/qjson/parser.cpp rename to thirdparty/qtweetlib/qtweetlib/qjson/parser.cpp diff --git a/thirdparty/qtweetlib/qjson/parser.h b/thirdparty/qtweetlib/qtweetlib/qjson/parser.h similarity index 100% rename from thirdparty/qtweetlib/qjson/parser.h rename to thirdparty/qtweetlib/qtweetlib/qjson/parser.h diff --git a/thirdparty/qtweetlib/qjson/parser_p.h b/thirdparty/qtweetlib/qtweetlib/qjson/parser_p.h similarity index 100% rename from thirdparty/qtweetlib/qjson/parser_p.h rename to thirdparty/qtweetlib/qtweetlib/qjson/parser_p.h diff --git a/thirdparty/qtweetlib/qjson/parserrunnable.cpp b/thirdparty/qtweetlib/qtweetlib/qjson/parserrunnable.cpp similarity index 100% rename from thirdparty/qtweetlib/qjson/parserrunnable.cpp rename to thirdparty/qtweetlib/qtweetlib/qjson/parserrunnable.cpp diff --git a/thirdparty/qtweetlib/qjson/parserrunnable.h b/thirdparty/qtweetlib/qtweetlib/qjson/parserrunnable.h similarity index 100% rename from thirdparty/qtweetlib/qjson/parserrunnable.h rename to thirdparty/qtweetlib/qtweetlib/qjson/parserrunnable.h diff --git a/thirdparty/qtweetlib/qjson/position.hh b/thirdparty/qtweetlib/qtweetlib/qjson/position.hh similarity index 100% rename from thirdparty/qtweetlib/qjson/position.hh rename to thirdparty/qtweetlib/qtweetlib/qjson/position.hh diff --git a/thirdparty/qtweetlib/qjson/qjson.pro b/thirdparty/qtweetlib/qtweetlib/qjson/qjson.pro similarity index 100% rename from thirdparty/qtweetlib/qjson/qjson.pro rename to thirdparty/qtweetlib/qtweetlib/qjson/qjson.pro diff --git a/thirdparty/qtweetlib/qjson/qjson_debug.h b/thirdparty/qtweetlib/qtweetlib/qjson/qjson_debug.h similarity index 100% rename from thirdparty/qtweetlib/qjson/qjson_debug.h rename to thirdparty/qtweetlib/qtweetlib/qjson/qjson_debug.h diff --git a/thirdparty/qtweetlib/qjson/qjson_export.h b/thirdparty/qtweetlib/qtweetlib/qjson/qjson_export.h similarity index 100% rename from thirdparty/qtweetlib/qjson/qjson_export.h rename to thirdparty/qtweetlib/qtweetlib/qjson/qjson_export.h diff --git a/thirdparty/qtweetlib/qjson/qobjecthelper.cpp b/thirdparty/qtweetlib/qtweetlib/qjson/qobjecthelper.cpp similarity index 100% rename from thirdparty/qtweetlib/qjson/qobjecthelper.cpp rename to thirdparty/qtweetlib/qtweetlib/qjson/qobjecthelper.cpp diff --git a/thirdparty/qtweetlib/qjson/qobjecthelper.h b/thirdparty/qtweetlib/qtweetlib/qjson/qobjecthelper.h similarity index 100% rename from thirdparty/qtweetlib/qjson/qobjecthelper.h rename to thirdparty/qtweetlib/qtweetlib/qjson/qobjecthelper.h diff --git a/thirdparty/qtweetlib/qjson/serializer.cpp b/thirdparty/qtweetlib/qtweetlib/qjson/serializer.cpp similarity index 100% rename from thirdparty/qtweetlib/qjson/serializer.cpp rename to thirdparty/qtweetlib/qtweetlib/qjson/serializer.cpp diff --git a/thirdparty/qtweetlib/qjson/serializer.h b/thirdparty/qtweetlib/qtweetlib/qjson/serializer.h similarity index 100% rename from thirdparty/qtweetlib/qjson/serializer.h rename to thirdparty/qtweetlib/qtweetlib/qjson/serializer.h diff --git a/thirdparty/qtweetlib/qjson/serializerrunnable.cpp b/thirdparty/qtweetlib/qtweetlib/qjson/serializerrunnable.cpp similarity index 100% rename from thirdparty/qtweetlib/qjson/serializerrunnable.cpp rename to thirdparty/qtweetlib/qtweetlib/qjson/serializerrunnable.cpp diff --git a/thirdparty/qtweetlib/qjson/serializerrunnable.h b/thirdparty/qtweetlib/qtweetlib/qjson/serializerrunnable.h similarity index 100% rename from thirdparty/qtweetlib/qjson/serializerrunnable.h rename to thirdparty/qtweetlib/qtweetlib/qjson/serializerrunnable.h diff --git a/thirdparty/qtweetlib/qjson/src.pro b/thirdparty/qtweetlib/qtweetlib/qjson/src.pro similarity index 100% rename from thirdparty/qtweetlib/qjson/src.pro rename to thirdparty/qtweetlib/qtweetlib/qjson/src.pro diff --git a/thirdparty/qtweetlib/qjson/stack.hh b/thirdparty/qtweetlib/qtweetlib/qjson/stack.hh similarity index 100% rename from thirdparty/qtweetlib/qjson/stack.hh rename to thirdparty/qtweetlib/qtweetlib/qjson/stack.hh diff --git a/thirdparty/qtweetlib/src/oauth.cpp b/thirdparty/qtweetlib/qtweetlib/src/oauth.cpp similarity index 100% rename from thirdparty/qtweetlib/src/oauth.cpp rename to thirdparty/qtweetlib/qtweetlib/src/oauth.cpp diff --git a/thirdparty/qtweetlib/src/oauth.h b/thirdparty/qtweetlib/qtweetlib/src/oauth.h similarity index 100% rename from thirdparty/qtweetlib/src/oauth.h rename to thirdparty/qtweetlib/qtweetlib/src/oauth.h diff --git a/thirdparty/qtweetlib/src/oauthtwitter.cpp b/thirdparty/qtweetlib/qtweetlib/src/oauthtwitter.cpp similarity index 100% rename from thirdparty/qtweetlib/src/oauthtwitter.cpp rename to thirdparty/qtweetlib/qtweetlib/src/oauthtwitter.cpp diff --git a/thirdparty/qtweetlib/src/oauthtwitter.h b/thirdparty/qtweetlib/qtweetlib/src/oauthtwitter.h similarity index 100% rename from thirdparty/qtweetlib/src/oauthtwitter.h rename to thirdparty/qtweetlib/qtweetlib/src/oauthtwitter.h diff --git a/thirdparty/qtweetlib/src/qtweetaccountratelimitstatus.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetaccountratelimitstatus.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetaccountratelimitstatus.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetaccountratelimitstatus.cpp diff --git a/thirdparty/qtweetlib/src/qtweetaccountratelimitstatus.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetaccountratelimitstatus.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetaccountratelimitstatus.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetaccountratelimitstatus.h diff --git a/thirdparty/qtweetlib/src/qtweetaccountverifycredentials.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetaccountverifycredentials.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetaccountverifycredentials.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetaccountverifycredentials.cpp diff --git a/thirdparty/qtweetlib/src/qtweetaccountverifycredentials.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetaccountverifycredentials.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetaccountverifycredentials.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetaccountverifycredentials.h diff --git a/thirdparty/qtweetlib/src/qtweetconvert.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetconvert.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetconvert.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetconvert.cpp diff --git a/thirdparty/qtweetlib/src/qtweetconvert.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetconvert.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetconvert.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetconvert.h diff --git a/thirdparty/qtweetlib/src/qtweetdirectmessagedestroy.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessagedestroy.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetdirectmessagedestroy.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessagedestroy.cpp diff --git a/thirdparty/qtweetlib/src/qtweetdirectmessagedestroy.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessagedestroy.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetdirectmessagedestroy.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessagedestroy.h diff --git a/thirdparty/qtweetlib/src/qtweetdirectmessagenew.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessagenew.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetdirectmessagenew.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessagenew.cpp diff --git a/thirdparty/qtweetlib/src/qtweetdirectmessagenew.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessagenew.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetdirectmessagenew.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessagenew.h diff --git a/thirdparty/qtweetlib/src/qtweetdirectmessages.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessages.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetdirectmessages.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessages.cpp diff --git a/thirdparty/qtweetlib/src/qtweetdirectmessages.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessages.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetdirectmessages.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessages.h diff --git a/thirdparty/qtweetlib/src/qtweetdirectmessagessent.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessagessent.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetdirectmessagessent.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessagessent.cpp diff --git a/thirdparty/qtweetlib/src/qtweetdirectmessagessent.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessagessent.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetdirectmessagessent.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetdirectmessagessent.h diff --git a/thirdparty/qtweetlib/src/qtweetdmstatus.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetdmstatus.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetdmstatus.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetdmstatus.cpp diff --git a/thirdparty/qtweetlib/src/qtweetdmstatus.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetdmstatus.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetdmstatus.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetdmstatus.h diff --git a/thirdparty/qtweetlib/src/qtweetentityhashtag.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetentityhashtag.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetentityhashtag.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetentityhashtag.cpp diff --git a/thirdparty/qtweetlib/src/qtweetentityhashtag.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetentityhashtag.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetentityhashtag.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetentityhashtag.h diff --git a/thirdparty/qtweetlib/src/qtweetentityurl.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetentityurl.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetentityurl.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetentityurl.cpp diff --git a/thirdparty/qtweetlib/src/qtweetentityurl.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetentityurl.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetentityurl.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetentityurl.h diff --git a/thirdparty/qtweetlib/src/qtweetentityusermentions.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetentityusermentions.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetentityusermentions.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetentityusermentions.cpp diff --git a/thirdparty/qtweetlib/src/qtweetentityusermentions.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetentityusermentions.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetentityusermentions.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetentityusermentions.h diff --git a/thirdparty/qtweetlib/src/qtweetfavorites.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetfavorites.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfavorites.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfavorites.cpp diff --git a/thirdparty/qtweetlib/src/qtweetfavorites.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetfavorites.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfavorites.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfavorites.h diff --git a/thirdparty/qtweetlib/src/qtweetfavoritescreate.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetfavoritescreate.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfavoritescreate.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfavoritescreate.cpp diff --git a/thirdparty/qtweetlib/src/qtweetfavoritescreate.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetfavoritescreate.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfavoritescreate.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfavoritescreate.h diff --git a/thirdparty/qtweetlib/src/qtweetfavoritesdestroy.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetfavoritesdestroy.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfavoritesdestroy.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfavoritesdestroy.cpp diff --git a/thirdparty/qtweetlib/src/qtweetfavoritesdestroy.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetfavoritesdestroy.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfavoritesdestroy.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfavoritesdestroy.h diff --git a/thirdparty/qtweetlib/src/qtweetfollowersid.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetfollowersid.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfollowersid.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfollowersid.cpp diff --git a/thirdparty/qtweetlib/src/qtweetfollowersid.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetfollowersid.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfollowersid.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfollowersid.h diff --git a/thirdparty/qtweetlib/src/qtweetfriendshipcreate.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetfriendshipcreate.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfriendshipcreate.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfriendshipcreate.cpp diff --git a/thirdparty/qtweetlib/src/qtweetfriendshipcreate.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetfriendshipcreate.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfriendshipcreate.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfriendshipcreate.h diff --git a/thirdparty/qtweetlib/src/qtweetfriendshipdestroy.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetfriendshipdestroy.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfriendshipdestroy.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfriendshipdestroy.cpp diff --git a/thirdparty/qtweetlib/src/qtweetfriendshipdestroy.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetfriendshipdestroy.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfriendshipdestroy.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfriendshipdestroy.h diff --git a/thirdparty/qtweetlib/src/qtweetfriendsid.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetfriendsid.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfriendsid.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfriendsid.cpp diff --git a/thirdparty/qtweetlib/src/qtweetfriendsid.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetfriendsid.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfriendsid.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfriendsid.h diff --git a/thirdparty/qtweetlib/src/qtweetfriendstimeline.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetfriendstimeline.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfriendstimeline.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfriendstimeline.cpp diff --git a/thirdparty/qtweetlib/src/qtweetfriendstimeline.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetfriendstimeline.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetfriendstimeline.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetfriendstimeline.h diff --git a/thirdparty/qtweetlib/src/qtweetgeoboundingbox.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeoboundingbox.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeoboundingbox.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeoboundingbox.cpp diff --git a/thirdparty/qtweetlib/src/qtweetgeoboundingbox.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeoboundingbox.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeoboundingbox.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeoboundingbox.h diff --git a/thirdparty/qtweetlib/src/qtweetgeocoord.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeocoord.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeocoord.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeocoord.cpp diff --git a/thirdparty/qtweetlib/src/qtweetgeocoord.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeocoord.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeocoord.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeocoord.h diff --git a/thirdparty/qtweetlib/src/qtweetgeoplacecreate.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeoplacecreate.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeoplacecreate.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeoplacecreate.cpp diff --git a/thirdparty/qtweetlib/src/qtweetgeoplacecreate.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeoplacecreate.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeoplacecreate.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeoplacecreate.h diff --git a/thirdparty/qtweetlib/src/qtweetgeoplaceid.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeoplaceid.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeoplaceid.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeoplaceid.cpp diff --git a/thirdparty/qtweetlib/src/qtweetgeoplaceid.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeoplaceid.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeoplaceid.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeoplaceid.h diff --git a/thirdparty/qtweetlib/src/qtweetgeoreversegeocode.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeoreversegeocode.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeoreversegeocode.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeoreversegeocode.cpp diff --git a/thirdparty/qtweetlib/src/qtweetgeoreversegeocode.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeoreversegeocode.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeoreversegeocode.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeoreversegeocode.h diff --git a/thirdparty/qtweetlib/src/qtweetgeosearch.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeosearch.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeosearch.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeosearch.cpp diff --git a/thirdparty/qtweetlib/src/qtweetgeosearch.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeosearch.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeosearch.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeosearch.h diff --git a/thirdparty/qtweetlib/src/qtweetgeosimilarplaces.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeosimilarplaces.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeosimilarplaces.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeosimilarplaces.cpp diff --git a/thirdparty/qtweetlib/src/qtweetgeosimilarplaces.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetgeosimilarplaces.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetgeosimilarplaces.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetgeosimilarplaces.h diff --git a/thirdparty/qtweetlib/src/qtweethometimeline.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweethometimeline.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweethometimeline.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweethometimeline.cpp diff --git a/thirdparty/qtweetlib/src/qtweethometimeline.h b/thirdparty/qtweetlib/qtweetlib/src/qtweethometimeline.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweethometimeline.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweethometimeline.h diff --git a/thirdparty/qtweetlib/src/qtweetlib_global.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlib_global.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlib_global.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlib_global.h diff --git a/thirdparty/qtweetlib/src/qtweetlist.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlist.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlist.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlist.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlist.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlist.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlist.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlist.h diff --git a/thirdparty/qtweetlib/src/qtweetlistaddmember.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistaddmember.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistaddmember.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistaddmember.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistaddmember.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistaddmember.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistaddmember.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistaddmember.h diff --git a/thirdparty/qtweetlib/src/qtweetlistcreate.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistcreate.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistcreate.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistcreate.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistcreate.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistcreate.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistcreate.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistcreate.h diff --git a/thirdparty/qtweetlib/src/qtweetlistdeletelist.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistdeletelist.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistdeletelist.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistdeletelist.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistdeletelist.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistdeletelist.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistdeletelist.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistdeletelist.h diff --git a/thirdparty/qtweetlib/src/qtweetlistdeletemember.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistdeletemember.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistdeletemember.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistdeletemember.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistdeletemember.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistdeletemember.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistdeletemember.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistdeletemember.h diff --git a/thirdparty/qtweetlib/src/qtweetlistgetlists.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistgetlists.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistgetlists.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistgetlists.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistgetlists.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistgetlists.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistgetlists.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistgetlists.h diff --git a/thirdparty/qtweetlib/src/qtweetlistgetmembers.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistgetmembers.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistgetmembers.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistgetmembers.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistgetmembers.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistgetmembers.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistgetmembers.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistgetmembers.h diff --git a/thirdparty/qtweetlib/src/qtweetlistmemberships.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistmemberships.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistmemberships.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistmemberships.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistmemberships.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistmemberships.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistmemberships.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistmemberships.h diff --git a/thirdparty/qtweetlib/src/qtweetlistshowlist.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistshowlist.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistshowlist.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistshowlist.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistshowlist.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistshowlist.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistshowlist.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistshowlist.h diff --git a/thirdparty/qtweetlib/src/qtweetliststatuses.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetliststatuses.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetliststatuses.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetliststatuses.cpp diff --git a/thirdparty/qtweetlib/src/qtweetliststatuses.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetliststatuses.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetliststatuses.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetliststatuses.h diff --git a/thirdparty/qtweetlib/src/qtweetlistsubscribe.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistsubscribe.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistsubscribe.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistsubscribe.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistsubscribe.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistsubscribe.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistsubscribe.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistsubscribe.h diff --git a/thirdparty/qtweetlib/src/qtweetlistsubscribers.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistsubscribers.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistsubscribers.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistsubscribers.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistsubscribers.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistsubscribers.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistsubscribers.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistsubscribers.h diff --git a/thirdparty/qtweetlib/src/qtweetlistsubscriptions.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistsubscriptions.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistsubscriptions.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistsubscriptions.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistsubscriptions.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistsubscriptions.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistsubscriptions.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistsubscriptions.h diff --git a/thirdparty/qtweetlib/src/qtweetlistunsubscribe.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistunsubscribe.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistunsubscribe.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistunsubscribe.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistunsubscribe.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistunsubscribe.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistunsubscribe.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistunsubscribe.h diff --git a/thirdparty/qtweetlib/src/qtweetlistupdate.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistupdate.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistupdate.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistupdate.cpp diff --git a/thirdparty/qtweetlib/src/qtweetlistupdate.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetlistupdate.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetlistupdate.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetlistupdate.h diff --git a/thirdparty/qtweetlib/src/qtweetmentions.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetmentions.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetmentions.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetmentions.cpp diff --git a/thirdparty/qtweetlib/src/qtweetmentions.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetmentions.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetmentions.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetmentions.h diff --git a/thirdparty/qtweetlib/src/qtweetnetbase.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetnetbase.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetnetbase.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetnetbase.cpp diff --git a/thirdparty/qtweetlib/src/qtweetnetbase.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetnetbase.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetnetbase.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetnetbase.h diff --git a/thirdparty/qtweetlib/src/qtweetplace.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetplace.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetplace.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetplace.cpp diff --git a/thirdparty/qtweetlib/src/qtweetplace.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetplace.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetplace.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetplace.h diff --git a/thirdparty/qtweetlib/src/qtweetretweetbyme.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetretweetbyme.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetretweetbyme.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetretweetbyme.cpp diff --git a/thirdparty/qtweetlib/src/qtweetretweetbyme.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetretweetbyme.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetretweetbyme.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetretweetbyme.h diff --git a/thirdparty/qtweetlib/src/qtweetretweetsofme.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetretweetsofme.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetretweetsofme.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetretweetsofme.cpp diff --git a/thirdparty/qtweetlib/src/qtweetretweetsofme.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetretweetsofme.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetretweetsofme.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetretweetsofme.h diff --git a/thirdparty/qtweetlib/src/qtweetretweettome.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetretweettome.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetretweettome.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetretweettome.cpp diff --git a/thirdparty/qtweetlib/src/qtweetretweettome.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetretweettome.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetretweettome.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetretweettome.h diff --git a/thirdparty/qtweetlib/src/qtweetsearch.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetsearch.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetsearch.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetsearch.cpp diff --git a/thirdparty/qtweetlib/src/qtweetsearch.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetsearch.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetsearch.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetsearch.h diff --git a/thirdparty/qtweetlib/src/qtweetsearchpageresults.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetsearchpageresults.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetsearchpageresults.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetsearchpageresults.cpp diff --git a/thirdparty/qtweetlib/src/qtweetsearchpageresults.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetsearchpageresults.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetsearchpageresults.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetsearchpageresults.h diff --git a/thirdparty/qtweetlib/src/qtweetsearchresult.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetsearchresult.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetsearchresult.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetsearchresult.cpp diff --git a/thirdparty/qtweetlib/src/qtweetsearchresult.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetsearchresult.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetsearchresult.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetsearchresult.h diff --git a/thirdparty/qtweetlib/src/qtweetstatus.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetstatus.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetstatus.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetstatus.cpp diff --git a/thirdparty/qtweetlib/src/qtweetstatus.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetstatus.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetstatus.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetstatus.h diff --git a/thirdparty/qtweetlib/src/qtweetstatusdestroy.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetstatusdestroy.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetstatusdestroy.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetstatusdestroy.cpp diff --git a/thirdparty/qtweetlib/src/qtweetstatusdestroy.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetstatusdestroy.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetstatusdestroy.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetstatusdestroy.h diff --git a/thirdparty/qtweetlib/src/qtweetstatusretweet.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetstatusretweet.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetstatusretweet.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetstatusretweet.cpp diff --git a/thirdparty/qtweetlib/src/qtweetstatusretweet.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetstatusretweet.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetstatusretweet.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetstatusretweet.h diff --git a/thirdparty/qtweetlib/src/qtweetstatusretweets.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetstatusretweets.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetstatusretweets.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetstatusretweets.cpp diff --git a/thirdparty/qtweetlib/src/qtweetstatusretweets.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetstatusretweets.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetstatusretweets.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetstatusretweets.h diff --git a/thirdparty/qtweetlib/src/qtweetstatusshow.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetstatusshow.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetstatusshow.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetstatusshow.cpp diff --git a/thirdparty/qtweetlib/src/qtweetstatusshow.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetstatusshow.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetstatusshow.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetstatusshow.h diff --git a/thirdparty/qtweetlib/src/qtweetstatusupdate.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetstatusupdate.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetstatusupdate.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetstatusupdate.cpp diff --git a/thirdparty/qtweetlib/src/qtweetstatusupdate.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetstatusupdate.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetstatusupdate.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetstatusupdate.h diff --git a/thirdparty/qtweetlib/src/qtweetuser.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetuser.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetuser.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetuser.cpp diff --git a/thirdparty/qtweetlib/src/qtweetuser.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetuser.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetuser.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetuser.h diff --git a/thirdparty/qtweetlib/src/qtweetuserlookup.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetuserlookup.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetuserlookup.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetuserlookup.cpp diff --git a/thirdparty/qtweetlib/src/qtweetuserlookup.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetuserlookup.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetuserlookup.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetuserlookup.h diff --git a/thirdparty/qtweetlib/src/qtweetusersearch.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetusersearch.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetusersearch.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetusersearch.cpp diff --git a/thirdparty/qtweetlib/src/qtweetusersearch.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetusersearch.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetusersearch.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetusersearch.h diff --git a/thirdparty/qtweetlib/src/qtweetusershow.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetusershow.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetusershow.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetusershow.cpp diff --git a/thirdparty/qtweetlib/src/qtweetusershow.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetusershow.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetusershow.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetusershow.h diff --git a/thirdparty/qtweetlib/src/qtweetuserstatusesfollowers.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetuserstatusesfollowers.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetuserstatusesfollowers.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetuserstatusesfollowers.cpp diff --git a/thirdparty/qtweetlib/src/qtweetuserstatusesfollowers.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetuserstatusesfollowers.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetuserstatusesfollowers.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetuserstatusesfollowers.h diff --git a/thirdparty/qtweetlib/src/qtweetuserstatusesfriends.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetuserstatusesfriends.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetuserstatusesfriends.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetuserstatusesfriends.cpp diff --git a/thirdparty/qtweetlib/src/qtweetuserstatusesfriends.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetuserstatusesfriends.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetuserstatusesfriends.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetuserstatusesfriends.h diff --git a/thirdparty/qtweetlib/src/qtweetuserstream.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetuserstream.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetuserstream.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetuserstream.cpp diff --git a/thirdparty/qtweetlib/src/qtweetuserstream.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetuserstream.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetuserstream.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetuserstream.h diff --git a/thirdparty/qtweetlib/src/qtweetusertimeline.cpp b/thirdparty/qtweetlib/qtweetlib/src/qtweetusertimeline.cpp similarity index 100% rename from thirdparty/qtweetlib/src/qtweetusertimeline.cpp rename to thirdparty/qtweetlib/qtweetlib/src/qtweetusertimeline.cpp diff --git a/thirdparty/qtweetlib/src/qtweetusertimeline.h b/thirdparty/qtweetlib/qtweetlib/src/qtweetusertimeline.h similarity index 100% rename from thirdparty/qtweetlib/src/qtweetusertimeline.h rename to thirdparty/qtweetlib/qtweetlib/src/qtweetusertimeline.h diff --git a/thirdparty/qtweetlib/src/src.pro b/thirdparty/qtweetlib/qtweetlib/src/src.pro similarity index 100% rename from thirdparty/qtweetlib/src/src.pro rename to thirdparty/qtweetlib/qtweetlib/src/src.pro diff --git a/thirdparty/qtweetlib/twitter-api-keys b/thirdparty/qtweetlib/twitter-api-keys new file mode 100644 index 000000000..b4b664840 --- /dev/null +++ b/thirdparty/qtweetlib/twitter-api-keys @@ -0,0 +1,9 @@ +set_property( + TARGET tomahawk_qtweetlib + APPEND PROPERTY COMPILE_DEFINITIONS CONSUMER_KEY="C4v4Wfa21rfIDck4HMR3A" +) + +set_property( + TARGET tomahawk_qtweetlib + APPEND PROPERTY COMPILE_DEFINITIONS CONSUMER_SECRET="zXSjU6bjrvg6UVMJX4JufqHyjj3iextY14SR9uBEAo" +)