├── examples ├── georeverse │ ├── start_georeverse.sh │ ├── georeverse.pro │ ├── main.cpp │ ├── georeverse.h │ └── georeverse.ui ├── geosearch │ ├── start_geosearch.sh │ ├── geosearch.pro │ ├── main.cpp │ ├── geosearch.h │ └── geosearch.ui ├── timelines │ ├── start_timelines.sh │ ├── timelines.pro │ ├── main.cpp │ └── mainwindow.h ├── userstream │ ├── start_userstream.sh │ ├── userstream.pro │ ├── main.cpp │ ├── userstream.h │ └── userstream.ui ├── search │ ├── start_searchexample.sh │ ├── search.pro │ ├── main.cpp │ ├── mainwindow.h │ └── mainwindow.ui ├── statusupdate │ ├── start_statusupdate.sh │ ├── statusupdate.pro │ ├── main.cpp │ └── mainwindow.h ├── pinauthstatusupdate │ ├── start_pinauthstatusupdate.sh │ ├── pinauthstatusupdate.pro │ ├── main.cpp │ └── statusupdatewidget.h ├── examples.pro └── followers │ ├── followers.qrc │ ├── FollowersList.qml │ ├── followers.pro │ ├── main.cpp │ ├── followers.ui │ ├── followers.h │ ├── FollowerDelegate.qml │ ├── followerslistmodel.h │ └── followers.cpp ├── QTweetLib.pro ├── README ├── src ├── json │ ├── qjsonexport.h │ └── qjsonwriter_p.h ├── qtweetlib_global.h ├── qtweetgeoplaceid.h ├── qtweetblocksblockingids.h ├── qtweetentityhashtag.h ├── qtweetblocksblocking.h ├── qtweetlistsubscribe.h ├── qtweetgeoboundingbox.cpp ├── qtweetlistshowlist.h ├── qtweetstatusdestroy.h ├── qtweetgeocoord.h ├── qtweetusersearch.h ├── qtweetdirectmessagesshow.h ├── qtweetlistcreate.h ├── qtweetusershow.h ├── qtweetlistupdate.h ├── qtweetfavorites.h ├── qtweetfavoritescreate.h ├── qtweetentityurl.h ├── qtweetfavoritesdestroy.h ├── qtweetdirectmessagedestroy.h ├── qtweetuserlookup.h ├── qtweetlistaddmember.h ├── qtweetdirectmessages.h ├── qtweetlistdeletemember.h ├── qtweetblocksdestroy.h ├── qtweetblocksexists.h ├── qtweetgeocoord.cpp ├── qtweetfriendshipdestroy.h ├── qtweetgeoplacecreate.h ├── qtweetdirectmessagessent.h ├── qtweetaccountverifycredentials.h ├── qtweetblockscreate.h ├── qtweetentityusermentions.h ├── qtweetaccountratelimitstatus.h ├── qtweetfriendshipcreate.h ├── qtweetdirectmessagenew.h ├── qtweetgeoreversegeocode.h ├── qtweetstatusupdate.h ├── qtweetsearch.h ├── qtweetgeosimilarplaces.h ├── qtweetfriendsid.h ├── qtweetfollowersid.h ├── qtweetgeosearch.h ├── qtweetsearchresult.h ├── qtweetentityhashtag.cpp ├── qtweetentitymedia.h ├── qtweetstatusretweetbyid.h ├── qtweetlist.h ├── qtweetstatusretweetedby.h ├── qtweetstatusretweets.h ├── qtweetdmstatus.h ├── qtweetgeoboundingbox.h ├── qtweetstatusretweet.h ├── qtweetplace.h ├── qtweetsearchpageresults.h ├── qtweetlistshowlist.cpp ├── qtweetgeoplaceid.cpp ├── qtweetlistsubscribe.cpp ├── qtweetuserstatusesfollowers.h ├── qtweetlistdeletemember.cpp ├── oauthtwitter.h ├── qtweetplace.cpp ├── qtweetblocksblockingids.cpp ├── qtweetlistaddmember.cpp ├── oauth.h ├── qtweetstatusshow.h ├── qtweetstatusretweets.cpp ├── qtweetdirectmessagesshow.cpp ├── qtweetaccountratelimitstatus.cpp ├── qtweetaccountverifycredentials.cpp ├── qtweetentityurl.cpp ├── qtweetstatusretweetedby.cpp ├── qtweetfavoritesdestroy.cpp ├── qtweetblocksblocking.cpp ├── qtweetconvert.h ├── qtweetstatusretweetbyid.cpp ├── qtweetfavoritescreate.cpp ├── qtweetstatusdestroy.cpp ├── qtweetstatusretweet.cpp ├── qtweetentityusermentions.cpp ├── qtweetstatusshow.cpp ├── qtweetfavorites.cpp └── qtweetusersearch.cpp ├── CMakeLists.txt ├── cmake └── modules │ └── FindQJSON.cmake └── .gitignore /examples/georeverse/start_georeverse.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LD_LIBRARY_PATH=../../lib ./georeverse -------------------------------------------------------------------------------- /examples/geosearch/start_geosearch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LD_LIBRARY_PATH=../../lib ./geosearch -------------------------------------------------------------------------------- /examples/timelines/start_timelines.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LD_LIBRARY_PATH=../../lib ./timelines -------------------------------------------------------------------------------- /examples/userstream/start_userstream.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LD_LIBRARY_PATH=../../lib ./userstream -------------------------------------------------------------------------------- /examples/search/start_searchexample.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LD_LIBRARY_PATH=../../lib ./searchexample -------------------------------------------------------------------------------- /examples/statusupdate/start_statusupdate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LD_LIBRARY_PATH=../../lib ./statusupdate -------------------------------------------------------------------------------- /examples/pinauthstatusupdate/start_pinauthstatusupdate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LD_LIBRARY_PATH=../../lib ./pinauthstatusupdate -------------------------------------------------------------------------------- /QTweetLib.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = sub_src sub_examples 3 | 4 | sub_src.subdir = src 5 | 6 | sub_examples.subdir = examples 7 | -------------------------------------------------------------------------------- /examples/examples.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = search timelines statusupdate geosearch georeverse \ 3 | followers userstream pinauthstatusupdate 4 | -------------------------------------------------------------------------------- /examples/followers/followers.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | FollowerDelegate.qml 4 | FollowersList.qml 5 | 6 | 7 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | - Supports most of the Twitter API 2 | - Supports XAuth and pin based authorization 3 | - Modular 4 | 5 | Requirements and dependencies: 6 | - Qt needs to be compiled with OpenSSL support 7 | - Valid OAuth consumer tokens for Twitter API access 8 | -------------------------------------------------------------------------------- /src/json/qjsonexport.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef QJSONEXPORT_H 3 | #define QJSONEXPORT_H 4 | 5 | 6 | #ifdef Q_JSONRPC_DLL 7 | # ifdef Q_BUILD_JSONRPC // build qjsonrpc Dll 8 | # define Q_JSONRPC_EXPORT Q_DECL_EXPORT 9 | # else // use qjsonrpc as Dll 10 | # define Q_JSONRPC_EXPORT Q_DECL_IMPORT 11 | # endif 12 | #else 13 | # define Q_JSONRPC_EXPORT 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /examples/timelines/timelines.pro: -------------------------------------------------------------------------------- 1 | QT += core gui network 2 | 3 | TARGET = timelines 4 | TEMPLATE = app 5 | win32:LIBS += ../../lib/QTweetLib.lib 6 | INCLUDEPATH += ../../src 7 | 8 | SOURCES += \ 9 | mainwindow.cpp \ 10 | main.cpp 11 | 12 | HEADERS += \ 13 | mainwindow.h 14 | 15 | FORMS += \ 16 | mainwindow.ui 17 | 18 | symbian: LIBS += -lqtweetlib 19 | else:unix|win32: LIBS += -L$$OUT_PWD/../../lib/ -lqtweetlib 20 | 21 | INCLUDEPATH += $$PWD/../../src 22 | DEPENDPATH += $$PWD/../../lib 23 | -------------------------------------------------------------------------------- /examples/pinauthstatusupdate/pinauthstatusupdate.pro: -------------------------------------------------------------------------------- 1 | QT += core gui network 2 | 3 | TARGET = pinauthstatusupdate 4 | TEMPLATE = app 5 | INCLUDEPATH += ../../src 6 | 7 | HEADERS += \ 8 | statusupdatewidget.h 9 | 10 | SOURCES += \ 11 | statusupdatewidget.cpp \ 12 | main.cpp 13 | 14 | FORMS += \ 15 | statusupdatewidget.ui 16 | 17 | symbian: LIBS += -lqtweetlib 18 | else:unix|win32: LIBS += -L$$OUT_PWD/../../lib/ -lqtweetlib 19 | 20 | INCLUDEPATH += $$PWD/../../src 21 | DEPENDPATH += $$PWD/../../lib 22 | -------------------------------------------------------------------------------- /examples/search/search.pro: -------------------------------------------------------------------------------- 1 | QT += core gui network 2 | 3 | TARGET = searchexample 4 | TEMPLATE = app 5 | win32:LIBS += ../../lib/QTweetLib.lib 6 | INCLUDEPATH += ../../src 7 | 8 | SOURCES +=\ 9 | mainwindow.cpp \ 10 | main.cpp 11 | 12 | HEADERS += \ 13 | mainwindow.h 14 | 15 | 16 | FORMS += \ 17 | mainwindow.ui 18 | 19 | symbian: LIBS += -lqtweetlib 20 | else:unix|win32: LIBS += -L$$OUT_PWD/../../lib/ -lqtweetlib 21 | 22 | INCLUDEPATH += $$PWD/../../src 23 | DEPENDPATH += $$PWD/../../lib 24 | -------------------------------------------------------------------------------- /examples/statusupdate/statusupdate.pro: -------------------------------------------------------------------------------- 1 | QT += core gui network 2 | 3 | TARGET = statusupdate 4 | TEMPLATE = app 5 | win32:LIBS += ../../lib/QTweetLib.lib 6 | INCLUDEPATH += ../../src 7 | 8 | SOURCES += \ 9 | main.cpp \ 10 | mainwindow.cpp 11 | 12 | HEADERS += \ 13 | mainwindow.h 14 | 15 | FORMS += \ 16 | mainwindow.ui 17 | 18 | symbian: LIBS += -lqtweetlib 19 | else:unix|win32: LIBS += -L$$OUT_PWD/../../lib/ -lqtweetlib 20 | 21 | INCLUDEPATH += $$PWD/../../src 22 | DEPENDPATH += $$PWD/../../lib 23 | -------------------------------------------------------------------------------- /examples/userstream/userstream.pro: -------------------------------------------------------------------------------- 1 | QT += core gui network 2 | 3 | TARGET = userstream 4 | TEMPLATE = app 5 | win32:LIBS += ../../lib/QTweetLib.lib 6 | INCLUDEPATH += ../../src 7 | 8 | 9 | SOURCES += \ 10 | main.cpp \ 11 | userstream.cpp 12 | 13 | HEADERS += \ 14 | userstream.h 15 | 16 | FORMS += \ 17 | userstream.ui 18 | 19 | symbian: LIBS += -lqtweetlib 20 | else:unix|win32: LIBS += -L$$OUT_PWD/../../lib/ -lqtweetlib 21 | 22 | INCLUDEPATH += $$PWD/../../src 23 | DEPENDPATH += $$PWD/../../lib 24 | -------------------------------------------------------------------------------- /examples/followers/FollowersList.qml: -------------------------------------------------------------------------------- 1 | import Qt 4.7 2 | 3 | //followersListModel - external 4 | 5 | Item { 6 | ListView { 7 | id: followersListView 8 | width: parent.width; height: parent.height 9 | clip: true 10 | model: followersListModel 11 | delegate: FollowerDelegate { 12 | id: followerDelegate 13 | name: nameRole 14 | screenName: screenNameRole 15 | description: descriptionRole 16 | avatarUrl: avatarRole 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/geosearch/geosearch.pro: -------------------------------------------------------------------------------- 1 | QT += core gui network 2 | 3 | TARGET = geosearch 4 | TEMPLATE = app 5 | win32:LIBS += ../../lib/QTweetLib.lib 6 | INCLUDEPATH += ../../src 7 | CONFIG += mobility 8 | MOBILITY += location 9 | 10 | SOURCES += \ 11 | main.cpp \ 12 | geosearch.cpp 13 | 14 | HEADERS += \ 15 | geosearch.h 16 | 17 | FORMS += \ 18 | geosearch.ui 19 | 20 | symbian: LIBS += -lqtweetlib 21 | else:unix|win32: LIBS += -L$$OUT_PWD/../../lib/ -lqtweetlib 22 | 23 | INCLUDEPATH += $$PWD/../../src 24 | DEPENDPATH += $$PWD/../../lib 25 | -------------------------------------------------------------------------------- /examples/georeverse/georeverse.pro: -------------------------------------------------------------------------------- 1 | QT += core gui network 2 | 3 | TARGET = georeverse 4 | TEMPLATE = app 5 | win32:LIBS += ../../lib/QTweetLib.lib 6 | INCLUDEPATH += ../../src 7 | CONFIG += mobility 8 | MOBILITY += location 9 | 10 | SOURCES += \ 11 | main.cpp \ 12 | georeverse.cpp 13 | 14 | HEADERS += \ 15 | georeverse.h 16 | 17 | FORMS += \ 18 | georeverse.ui 19 | 20 | symbian: LIBS += -lqtweetlib 21 | else:unix|win32: LIBS += -L$$OUT_PWD/../../lib/ -lqtweetlib 22 | 23 | INCLUDEPATH += $$PWD/../../src 24 | DEPENDPATH += $$PWD/../../lib 25 | -------------------------------------------------------------------------------- /examples/followers/followers.pro: -------------------------------------------------------------------------------- 1 | QT += core gui network declarative 2 | 3 | TARGET = followers 4 | TEMPLATE = app 5 | INCLUDEPATH += ../../src 6 | 7 | SOURCES += \ 8 | main.cpp \ 9 | followers.cpp \ 10 | followerslistmodel.cpp 11 | 12 | HEADERS += \ 13 | followers.h \ 14 | followerslistmodel.h 15 | 16 | FORMS += \ 17 | followers.ui 18 | 19 | OTHER_FILES += \ 20 | FollowerDelegate.qml \ 21 | FollowersList.qml 22 | 23 | RESOURCES += \ 24 | followers.qrc 25 | 26 | symbian: LIBS += -lqtweetlib 27 | else:unix|win32: LIBS += -L$$OUT_PWD/../../lib/ -lqtweetlib 28 | 29 | INCLUDEPATH += $$PWD/../../src 30 | DEPENDPATH += $$PWD/../../lib 31 | -------------------------------------------------------------------------------- /examples/followers/main.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include "followers.h" 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | QApplication a(argc, argv); 24 | Followers w; 25 | w.show(); 26 | 27 | return a.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /examples/geosearch/main.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include "geosearch.h" 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | QApplication a(argc, argv); 24 | GeoSearch w; 25 | w.show(); 26 | 27 | return a.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /examples/search/main.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include "mainwindow.h" 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | QApplication a(argc, argv); 24 | MainWindow w; 25 | w.show(); 26 | 27 | return a.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 2 | 3 | ## project settings 4 | PROJECT(QTweetLib) 5 | SET( QTWEETLIB_MAJOR_VERSION 1 ) 6 | SET( QTWEETLIB_MINOR_VERSION 0 ) 7 | SET( QTWEETLIB_PATCH_VERSION 0 ) 8 | 9 | SET( QTWEETLIB_VERSION ${QTWEETLIB_MAJOR_VERSION}.${QTWEETLIB_MINOR_VERSION}.${QTWEETLIB_PATCH_VERSION} ) 10 | SET( QTWEETLIB_SONAME ${QTWEETLIB_MAJOR_VERSION}.${QTWEETLIB_MINOR_VERSION} ) 11 | 12 | MESSAGE(STATUS "Building QTweetLib " ${QTWEETLIB_VERSION} ) 13 | 14 | # cmake modules 15 | SET( CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake/modules" ) 16 | 17 | ## required deps 18 | # qt4 19 | FIND_PACKAGE( Qt4 COMPONENTS QtCore QtNetwork QtGui REQUIRED ) 20 | INCLUDE( ${QT_USE_FILE} ) 21 | # qjson 22 | FIND_PACKAGE( QJSON REQUIRED ) 23 | 24 | # definitions 25 | ADD_DEFINITIONS( ${QT_DEFINITIONS} ) 26 | ADD_DEFINITIONS( -DQT_SHARED ) 27 | ADD_DEFINITIONS( -DQTWEETLIB_MAKEDLL ) 28 | 29 | # build actual source dir 30 | ADD_SUBDIRECTORY( src ) 31 | -------------------------------------------------------------------------------- /examples/georeverse/main.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include "georeverse.h" 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | QApplication a(argc, argv); 24 | GeoReverse w; 25 | w.show(); 26 | 27 | return a.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /examples/statusupdate/main.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include "mainwindow.h" 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | QApplication a(argc, argv); 24 | MainWindow w; 25 | w.show(); 26 | 27 | return a.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /examples/timelines/main.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include "mainwindow.h" 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | QApplication a(argc, argv); 24 | MainWindow w; 25 | w.show(); 26 | 27 | return a.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /examples/userstream/main.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include "userstream.h" 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | QApplication a(argc, argv); 24 | UserStream w; 25 | w.show(); 26 | 27 | return a.exec(); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /examples/pinauthstatusupdate/main.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include "statusupdatewidget.h" 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | QApplication a(argc, argv); 24 | StatusUpdateWidget w; 25 | w.show(); 26 | 27 | return a.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /src/qtweetlib_global.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETLIB_GLOBAL_H 19 | #define QTWEETLIB_GLOBAL_H 20 | 21 | #include 22 | 23 | #ifndef QTWEETLIBSHARED_EXPORT 24 | # if defined (QTWEETLIB_MAKEDLL) 25 | # define QTWEETLIBSHARED_EXPORT Q_DECL_EXPORT 26 | # else 27 | # define QTWEETLIBSHARED_EXPORT Q_DECL_IMPORT 28 | # endif 29 | #endif 30 | 31 | #define AUTH_HEADER "Authorization" 32 | 33 | #endif // QTWEETLIB_GLOBAL_H 34 | -------------------------------------------------------------------------------- /examples/followers/followers.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Followers 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | QDeclarativeView::SizeRootObjectToView 21 | 22 | 23 | 24 | 25 | 26 | 27 | Fetch Followers 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | QDeclarativeView 36 | QGraphicsView 37 |
QtDeclarative/QDeclarativeView
38 |
39 |
40 | 41 | 42 |
43 | -------------------------------------------------------------------------------- /examples/followers/followers.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef FOLLOWERS_H 19 | #define FOLLOWERS_H 20 | 21 | #include 22 | 23 | class OAuthTwitter; 24 | class FollowersListModel; 25 | 26 | namespace Ui { 27 | class Followers; 28 | } 29 | 30 | class Followers : public QWidget 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit Followers(QWidget *parent = 0); 36 | ~Followers(); 37 | 38 | protected: 39 | void changeEvent(QEvent *e); 40 | 41 | private slots: 42 | void onFetchFollowersPushButtonClicked(); 43 | 44 | private: 45 | Ui::Followers *ui; 46 | OAuthTwitter *m_oauthTwitter; 47 | FollowersListModel *m_followersListModel; 48 | }; 49 | 50 | #endif // FOLLOWERS_H 51 | -------------------------------------------------------------------------------- /examples/geosearch/geosearch.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef GEOSEARCH_H 19 | #define GEOSEARCH_H 20 | 21 | #include 22 | 23 | namespace Ui { 24 | class GeoSearch; 25 | } 26 | 27 | class OAuthTwitter; 28 | class QTweetPlace; 29 | 30 | class GeoSearch : public QWidget 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit GeoSearch(QWidget *parent = 0); 36 | ~GeoSearch(); 37 | 38 | protected: 39 | void changeEvent(QEvent *e); 40 | 41 | private slots: 42 | void onSearchPushButtonClicked(); 43 | void searchPlacesFinished(const QList& places); 44 | 45 | private: 46 | Ui::GeoSearch *ui; 47 | OAuthTwitter *m_oauthTwitter; 48 | }; 49 | 50 | #endif // GEOSEARCH_H 51 | -------------------------------------------------------------------------------- /examples/georeverse/georeverse.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef GEOREVERSE_H 19 | #define GEOREVERSE_H 20 | 21 | #include 22 | 23 | namespace Ui { 24 | class GeoReverse; 25 | } 26 | 27 | class OAuthTwitter; 28 | class QTweetPlace; 29 | 30 | class GeoReverse : public QWidget 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit GeoReverse(QWidget *parent = 0); 36 | ~GeoReverse(); 37 | 38 | protected: 39 | void changeEvent(QEvent *e); 40 | 41 | private slots: 42 | void onSearchPushButtonClicked(); 43 | void reverseGeoFinished(const QList& places); 44 | 45 | private: 46 | Ui::GeoReverse *ui; 47 | OAuthTwitter *m_oauthTwitter; 48 | 49 | }; 50 | 51 | #endif // GEOREVERSE_H 52 | -------------------------------------------------------------------------------- /examples/search/mainwindow.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef MAINWINDOW_H 19 | #define MAINWINDOW_H 20 | 21 | #include 22 | 23 | class OAuthTwitter; 24 | class QTweetSearchPageResults; 25 | 26 | namespace Ui { 27 | class MainWindow; 28 | } 29 | 30 | class MainWindow : public QMainWindow 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit MainWindow(QWidget *parent = 0); 36 | ~MainWindow(); 37 | 38 | protected: 39 | void changeEvent(QEvent *e); 40 | 41 | private slots: 42 | void searchButtonClicked(); 43 | void finishedSearch(const QTweetSearchPageResults& results); 44 | 45 | private: 46 | Ui::MainWindow *ui; 47 | OAuthTwitter* m_oauthTwitter; 48 | }; 49 | 50 | #endif // MAINWINDOW_H 51 | -------------------------------------------------------------------------------- /src/qtweetgeoplaceid.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETGEOPLACEID_H 19 | #define QTWEETGEOPLACEID_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | class QTweetPlace; 24 | 25 | /** 26 | * Fetches all the information about a known place 27 | */ 28 | class QTWEETLIBSHARED_EXPORT QTweetGeoPlaceID : public QTweetNetBase 29 | { 30 | Q_OBJECT 31 | public: 32 | QTweetGeoPlaceID(QObject *parent = 0); 33 | QTweetGeoPlaceID(OAuthTwitter *oauthTwitter, QObject *parent = 0); 34 | void get(const QString& placeid); 35 | 36 | signals: 37 | /** Emits the place */ 38 | void parsedPlace(const QTweetPlace& place); 39 | 40 | protected slots: 41 | void parseJsonFinished(const QJsonDocument &jsonDoc); 42 | }; 43 | 44 | #endif // QTWEETGEOPLACEID_H 45 | -------------------------------------------------------------------------------- /src/qtweetblocksblockingids.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETBLOCKSBLOCKINGIDS_H 19 | #define QTWEETBLOCKSBLOCKINGIDS_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Emits a list of numeric user ids the authenticating user is blocking. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetBlocksBlockingIDs : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit QTweetBlocksBlockingIDs(QObject *parent = 0); 31 | QTweetBlocksBlockingIDs(OAuthTwitter *oauthTwitter, QObject *parent = 0); 32 | void getIDs(); 33 | 34 | signals: 35 | void finishedGettingIDs(const QList useridlist); 36 | 37 | protected slots: 38 | void parseJsonFinished(const QJsonDocument &jsonDoc); 39 | }; 40 | 41 | #endif // QTWEETBLOCKSBLOCKINGIDS_H 42 | -------------------------------------------------------------------------------- /src/qtweetentityhashtag.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETENTITYHASHTAG_H 19 | #define QTWEETENTITYHASHTAG_H 20 | 21 | #include 22 | 23 | class QTweetEntityHashtagData; 24 | 25 | class QTweetEntityHashtag 26 | { 27 | public: 28 | QTweetEntityHashtag(); 29 | QTweetEntityHashtag(const QTweetEntityHashtag &); 30 | QTweetEntityHashtag &operator=(const QTweetEntityHashtag &); 31 | ~QTweetEntityHashtag(); 32 | 33 | void setText(const QString& text); 34 | QString text() const; 35 | void setLowerIndex(int index); 36 | int lowerIndex() const; 37 | void setHigherIndex(int index); 38 | int higherIndex() const; 39 | 40 | private: 41 | QSharedDataPointer data; 42 | }; 43 | 44 | #endif // QTWEETENTITYHASHTAG_H 45 | -------------------------------------------------------------------------------- /src/qtweetblocksblocking.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETBLOCKSBLOCKING_H 19 | #define QTWEETBLOCKSBLOCKING_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Emits the list of users that the authenticating user is blocking. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetBlocksBlocking : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit QTweetBlocksBlocking(QObject *parent = 0); 31 | QTweetBlocksBlocking(OAuthTwitter *oauthTwitter, QObject *parent = 0); 32 | void getBlocks(int page = 0, bool includeEntities = false); 33 | 34 | signals: 35 | void finishedGettingBlocks(const QList& users); 36 | 37 | protected slots: 38 | void parseJsonFinished(const QJsonDocument &jsonDoc); 39 | }; 40 | 41 | #endif // QTWEETBLOCKSBLOCKING_H 42 | -------------------------------------------------------------------------------- /src/qtweetlistsubscribe.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETLISTSUBSCRIBE_H 19 | #define QTWEETLISTSUBSCRIBE_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Make the authenticated user follow the specified list. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetListSubscribe : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetListSubscribe(QObject *parent = 0); 31 | QTweetListSubscribe(OAuthTwitter *oauthTwitter, QObject *parent = 0); 32 | void follow(qint64 user, 33 | qint64 list); 34 | 35 | signals: 36 | /** Emits the specified list */ 37 | void parsedList(const QTweetList& list); 38 | 39 | protected slots: 40 | void parseJsonFinished(const QJsonDocument &jsonDoc); 41 | }; 42 | 43 | #endif // QTWEETLISTSUBSCRIBE_H 44 | -------------------------------------------------------------------------------- /src/qtweetgeoboundingbox.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include "qtweetgeoboundingbox.h" 19 | 20 | QTweetGeoBoundingBox::QTweetGeoBoundingBox() 21 | { 22 | } 23 | 24 | QTweetGeoBoundingBox::QTweetGeoBoundingBox(const QTweetGeoCoord &topLeft, 25 | const QTweetGeoCoord &topRight, 26 | const QTweetGeoCoord &bottomRight, 27 | const QTweetGeoCoord &bottomLeft) 28 | { 29 | setTopLeft(topLeft); 30 | setTopRight(topRight); 31 | setBottomRight(bottomRight); 32 | setBottomLeft(bottomLeft); 33 | } 34 | 35 | bool QTweetGeoBoundingBox::isValid() const 36 | { 37 | return m_topLeft.isValid() & m_topRight.isValid() & 38 | m_bottomRight.isValid() & m_bottomLeft.isValid(); 39 | } 40 | -------------------------------------------------------------------------------- /src/qtweetlistshowlist.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETLISTSHOWLIST_H 19 | #define QTWEETLISTSHOWLIST_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Show the specified list. 25 | * Private lists will only be shown if the authenticated user owns the specified list. 26 | */ 27 | class QTWEETLIBSHARED_EXPORT QTweetListShowList : public QTweetNetBase 28 | { 29 | Q_OBJECT 30 | public: 31 | QTweetListShowList(QObject *parent = 0); 32 | QTweetListShowList(OAuthTwitter *oauthTwitter, QObject *parent = 0); 33 | void show(qint64 id, qint64 list); 34 | 35 | signals: 36 | /** Emits the list */ 37 | void parsedList(const QTweetList& list); 38 | 39 | protected slots: 40 | void parseJsonFinished(const QJsonDocument &jsonDoc); 41 | }; 42 | 43 | #endif // QTWEETLISTSHOWLIST_H 44 | -------------------------------------------------------------------------------- /src/qtweetstatusdestroy.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETSTATUSDESTROY_H 19 | #define QTWEETSTATUSDESTROY_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Class for destroying specified tweet (user must be author of tweet) 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetStatusDestroy : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetStatusDestroy(QObject *parent = 0); 31 | QTweetStatusDestroy(OAuthTwitter* oauthTwitter, QObject *parent = 0); 32 | void destroy(qint64 id, 33 | bool trimUser = false); 34 | 35 | signals: 36 | /** Emits deleted status */ 37 | void deletedStatus(const QTweetStatus& status); 38 | 39 | protected slots: 40 | void parseJsonFinished(const QJsonDocument &jsonDoc); 41 | }; 42 | 43 | #endif // QTWEETSTATUSDESTROY_H 44 | -------------------------------------------------------------------------------- /examples/georeverse/georeverse.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | GeoReverse 4 | 5 | 6 | 7 | 0 8 | 0 9 | 598 10 | 506 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Latitude 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | Longitude 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | Reverse geosearch 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/qtweetgeocoord.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETGEOCOORD_H 19 | #define QTWEETGEOCOORD_H 20 | 21 | #include "qtweetlib_global.h" 22 | 23 | /** 24 | * Stores latitude/longitude coordinates 25 | * Does basic checking if latitude/longitude is in valid degrees 26 | */ 27 | class QTWEETLIBSHARED_EXPORT QTweetGeoCoord 28 | { 29 | public: 30 | QTweetGeoCoord(); 31 | QTweetGeoCoord(double latitude, double longitude); 32 | bool isValid() const; 33 | double latitude() const { return m_latitude; } 34 | double longitude() const { return m_longitude; } 35 | void setLatitude(double latitude); 36 | void setLongitude(double longitude); 37 | 38 | private: 39 | double m_latitude; 40 | double m_longitude; 41 | bool m_validLatitude; 42 | bool m_validLongitude; 43 | }; 44 | 45 | #endif // QTWEETGEOCOORD_H 46 | -------------------------------------------------------------------------------- /examples/statusupdate/mainwindow.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef MAINWINDOW_H 19 | #define MAINWINDOW_H 20 | 21 | #include 22 | 23 | namespace Ui { 24 | class MainWindow; 25 | } 26 | 27 | class OAuthTwitter; 28 | class QTweetStatus; 29 | 30 | class MainWindow : public QMainWindow 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit MainWindow(QWidget *parent = 0); 36 | ~MainWindow(); 37 | 38 | protected: 39 | void changeEvent(QEvent *e); 40 | 41 | private slots: 42 | void authorizeButtonClicked(); 43 | void xauthFinished(); 44 | void xauthError(); 45 | void updateButtonClicked(); 46 | void postStatusFinished(const QTweetStatus& status); 47 | 48 | private: 49 | Ui::MainWindow *ui; 50 | OAuthTwitter *m_oauthTwitter; 51 | bool m_authorized; 52 | }; 53 | 54 | #endif // MAINWINDOW_H 55 | -------------------------------------------------------------------------------- /src/qtweetusersearch.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETUSERSEARCH_H 19 | #define QTWEETUSERSEARCH_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Runs a search for users 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetUserSearch : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetUserSearch(QObject *parent = 0); 31 | QTweetUserSearch(OAuthTwitter* oauthTwitter, QObject *parent); 32 | void search(const QString& query, 33 | int perPage = 0, 34 | int page = 0, 35 | bool includeEntities = false); 36 | 37 | signals: 38 | /** Emits list of users */ 39 | void parsedUserInfoList(const QList& userInfoList); 40 | 41 | protected slots: 42 | void parseJsonFinished(const QJsonDocument &jsonDoc); 43 | }; 44 | 45 | #endif // QTWEETUSERSEARCH_H 46 | -------------------------------------------------------------------------------- /src/qtweetdirectmessagesshow.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETDIRECTMESSAGESSHOW_H 19 | #define QTWEETDIRECTMESSAGESSHOW_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | class QTweetDMStatus; 24 | 25 | /** 26 | * Class for fetching a single direct message 27 | */ 28 | class QTWEETLIBSHARED_EXPORT QTweetDirectMessagesShow : public QTweetNetBase 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | explicit QTweetDirectMessagesShow(QObject *parent = 0); 34 | QTweetDirectMessagesShow(OAuthTwitter* oauthTwitter, QObject *parent = 0); 35 | void fetch(qint64 id); 36 | 37 | signals: 38 | /** Emits the fetched direct message */ 39 | void parsedDirectMessage(const QTweetDMStatus& message); 40 | 41 | protected slots: 42 | void parseJsonFinished(const QJsonDocument& jsonDocument); 43 | }; 44 | 45 | #endif // QTWEETDIRECTMESSAGESSHOW_H 46 | -------------------------------------------------------------------------------- /cmake/modules/FindQJSON.cmake: -------------------------------------------------------------------------------- 1 | # Find QJSON - JSON handling library for Qt 2 | # 3 | # This module defines 4 | # QJSON_FOUND - whether the qsjon library was found 5 | # QJSON_LIBRARIES - the qjson library 6 | # QJSON_INCLUDE_DIR - the include path of the qjson library 7 | # 8 | if (QJSON_INCLUDE_DIR AND QJSON_LIBRARIES) 9 | 10 | # Already in cache 11 | set (QJSON_FOUND TRUE) 12 | 13 | else (QJSON_INCLUDE_DIR AND QJSON_LIBRARIES) 14 | 15 | if (NOT WIN32) 16 | # Disabled because it broke compilation for people by 17 | # adding a "QtCore" to QJSON_LIBRARIES 18 | # also ${QJSON_INCLUDE_DIRS} pointed to /usr/include/QtCore 19 | # and ${QJSON_LIBRARY_DIRS} was empty which makes no sense either 20 | 21 | # use pkg-config to get the values of QJSON_INCLUDE_DIRS 22 | # and QJSON_LIBRARY_DIRS to add as hints to the find commands. 23 | #include (FindPkgConfig) 24 | #pkg_check_modules (QJSON REQUIRED QJson>=0.5) 25 | endif (NOT WIN32) 26 | 27 | find_library (QJSON_LIBRARIES 28 | NAMES 29 | qjson 30 | PATHS 31 | ${QJSON_LIBRARY_DIRS} 32 | ${LIB_INSTALL_DIR} 33 | ${KDE4_LIB_DIR} 34 | ) 35 | 36 | find_path (QJSON_INCLUDE_DIR 37 | NAMES 38 | parser.h 39 | PATH_SUFFIXES 40 | qjson 41 | PATHS 42 | ${QJSON_INCLUDE_DIRS} 43 | ${INCLUDE_INSTALL_DIR} 44 | ${KDE4_INCLUDE_DIR} 45 | ) 46 | 47 | include(FindPackageHandleStandardArgs) 48 | find_package_handle_standard_args(QJSON DEFAULT_MSG QJSON_LIBRARIES QJSON_INCLUDE_DIR) 49 | 50 | endif (QJSON_INCLUDE_DIR AND QJSON_LIBRARIES) 51 | -------------------------------------------------------------------------------- /src/qtweetlistcreate.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETLISTCREATE_H 19 | #define QTWEETLISTCREATE_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Creates a new list for the authenticated user. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetListCreate : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetListCreate(QObject *parent = 0); 31 | QTweetListCreate(OAuthTwitter *oauthTwitter, QObject *parent = 0); 32 | void create(qint64 user, 33 | const QString& name, 34 | bool mode = true, 35 | const QString& description = QString()); 36 | 37 | signals: 38 | /** Emits created list */ 39 | void parsedList(const QTweetList& list); 40 | 41 | protected slots: 42 | void parseJsonFinished(const QJsonDocument &jsonDoc); 43 | }; 44 | 45 | #endif // QTWEETLISTCREATE_H 46 | -------------------------------------------------------------------------------- /src/qtweetusershow.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETUSERSHOW_H 19 | #define QTWEETUSERSHOW_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Class for fetching extended information for given user 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetUserShow : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetUserShow(QObject *parent = 0); 31 | QTweetUserShow(OAuthTwitter *oauthTwitter, QObject *parent = 0); 32 | void fetch(qint64 userid = 0, 33 | bool includeEntities = false); 34 | void fetch(const QString& screenName, 35 | bool includeEntities = false); 36 | 37 | signals: 38 | /** Emits user */ 39 | void parsedUserInfo(const QTweetUser& userInfo); 40 | 41 | protected slots: 42 | void parseJsonFinished(const QJsonDocument &jsonDoc); 43 | }; 44 | 45 | #endif // QTWEETUSERSHOW_H 46 | -------------------------------------------------------------------------------- /examples/followers/FollowerDelegate.qml: -------------------------------------------------------------------------------- 1 | import Qt 4.7 2 | 3 | Rectangle { 4 | property string name: "Twitter name" 5 | property string screenName: "Twitter screen name" 6 | property string description: "Twitter description" 7 | property string avatarUrl 8 | 9 | width: ListView.view.width - 1; 10 | height: 100 11 | radius: 10 12 | border.width: 1 13 | border.color: "#000000" 14 | 15 | Image { 16 | id: avatar 17 | anchors.top: parent.top 18 | anchors.left: parent.left 19 | width: 48; height: 48 20 | anchors.leftMargin: 2 21 | anchors.topMargin: 2 22 | source: avatarUrl 23 | } 24 | 25 | Text { 26 | id: screenNameText 27 | text: screenName 28 | anchors.leftMargin: 2 29 | anchors.topMargin: 2 30 | anchors.left: avatar.right 31 | anchors.top: parent.top 32 | } 33 | 34 | Text { 35 | id: nameText 36 | text: name 37 | anchors.leftMargin: 2 38 | anchors.topMargin: 2 39 | anchors.top: screenNameText.bottom 40 | anchors.left: avatar.right 41 | } 42 | 43 | Text { 44 | id: descriptionText 45 | text: description 46 | anchors.rightMargin: 2 47 | anchors.leftMargin: 2 48 | anchors.bottomMargin: 2 49 | anchors.topMargin: 2 50 | anchors.bottom: parent.bottom 51 | anchors.top: avatar.bottom 52 | anchors.left: parent.left 53 | anchors.right: parent.right 54 | wrapMode: "WordWrap" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/qtweetlistupdate.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETLISTUPDATE_H 19 | #define QTWEETLISTUPDATE_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Updates the specified list. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetListUpdate : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetListUpdate(QObject *parent = 0); 31 | QTweetListUpdate(OAuthTwitter *oauthTwitter, QObject *parent = 0); 32 | void update(qint64 user, 33 | qint64 list, 34 | const QString& name = QString(), 35 | bool mode = true, 36 | const QString& description = QString()); 37 | signals: 38 | /** Emits updated list */ 39 | void parsedList(const QTweetList& list); 40 | 41 | protected slots: 42 | void parseJsonFinished(const QJsonDocument &jsonDoc); 43 | }; 44 | 45 | #endif // QTWEETLISTUPDATE_H 46 | -------------------------------------------------------------------------------- /src/qtweetfavorites.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETFAVORITES_H 19 | #define QTWEETFAVORITES_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Fetches favorite statuses for the authenticating user or 25 | * user specified by the ID parameter 26 | */ 27 | class QTWEETLIBSHARED_EXPORT QTweetFavorites : public QTweetNetBase 28 | { 29 | Q_OBJECT 30 | public: 31 | QTweetFavorites(QObject *parent = 0); 32 | QTweetFavorites(OAuthTwitter *oauthTwitter, QObject *parent = 0); 33 | void fetch(qint64 id = 0, 34 | int page = 0, 35 | bool includeEntities = false); 36 | 37 | signals: 38 | /** Emits list of favorited statuses */ 39 | void parsedFavorites(const QList& favorites); 40 | 41 | protected slots: 42 | void parseJsonFinished(const QJsonDocument &jsonDoc); 43 | }; 44 | 45 | #endif // QTWEETFAVORITES_H 46 | -------------------------------------------------------------------------------- /src/qtweetfavoritescreate.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETFAVORITESCREATE_H 19 | #define QTWEETFAVORITESCREATE_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Favorites the status specified in the ID parameter as the authenticating user. 25 | * Emits the favorite status when successful. 26 | */ 27 | class QTWEETLIBSHARED_EXPORT QTweetFavoritesCreate : public QTweetNetBase 28 | { 29 | Q_OBJECT 30 | public: 31 | QTweetFavoritesCreate(QObject *parent = 0); 32 | QTweetFavoritesCreate(OAuthTwitter *oauthTwitter, QObject *parent = 0); 33 | void create(qint64 statusid, bool includeEntities = false); 34 | 35 | signals: 36 | /** Emits favorited status */ 37 | void parsedStatus(const QTweetStatus& status); 38 | 39 | protected slots: 40 | void parseJsonFinished(const QJsonDocument &jsonDoc); 41 | }; 42 | 43 | #endif // QTWEETFAVORITESCREATE_H 44 | -------------------------------------------------------------------------------- /src/qtweetentityurl.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETENTITYURL_H 19 | #define QTWEETENTITYURL_H 20 | 21 | #include 22 | 23 | class QTweetEntityUrlData; 24 | 25 | class QTweetEntityUrl 26 | { 27 | public: 28 | QTweetEntityUrl(); 29 | QTweetEntityUrl(const QTweetEntityUrl &); 30 | QTweetEntityUrl &operator=(const QTweetEntityUrl &); 31 | ~QTweetEntityUrl(); 32 | 33 | void setDisplayUrl(const QString& url); 34 | QString displayUrl() const; 35 | void setUrl(const QString& url); 36 | QString url() const; 37 | void setExpandedUrl(const QString& url); 38 | QString expandedUrl() const; 39 | void setLowerIndex(int index); 40 | int lowerIndex() const; 41 | void setHigherIndex(int index); 42 | int higherIndex() const; 43 | 44 | private: 45 | QSharedDataPointer data; 46 | }; 47 | 48 | #endif // QTWEETENTITYURL_H 49 | -------------------------------------------------------------------------------- /src/qtweetfavoritesdestroy.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETFAVORITESDESTROY_H 19 | #define QTWEETFAVORITESDESTROY_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Un-favorites the status specified in the ID parameter as the authenticating user. 25 | * Emits the un-favorited status when successful. 26 | */ 27 | class QTWEETLIBSHARED_EXPORT QTweetFavoritesDestroy : public QTweetNetBase 28 | { 29 | Q_OBJECT 30 | public: 31 | QTweetFavoritesDestroy(QObject *parent = 0); 32 | QTweetFavoritesDestroy(OAuthTwitter *oauthTwitter, QObject *parent = 0); 33 | void unfavorite(qint64 statusid, bool includeEntities = false); 34 | 35 | signals: 36 | /** Emits the unfavorited status */ 37 | void parsedStatus(const QTweetStatus& status); 38 | 39 | protected slots: 40 | void parseJsonFinished(const QJsonDocument &jsonDoc); 41 | }; 42 | 43 | #endif // QTWEETFAVORITESDESTROY_H 44 | -------------------------------------------------------------------------------- /src/qtweetdirectmessagedestroy.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETDIRECTMESSAGEDESTROY_H 19 | #define QTWEETDIRECTMESSAGEDESTROY_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Destroys the direct message. 25 | * The authenticating user must be the recipient of the specified direct message. 26 | */ 27 | class QTWEETLIBSHARED_EXPORT QTweetDirectMessageDestroy : public QTweetNetBase 28 | { 29 | Q_OBJECT 30 | public: 31 | QTweetDirectMessageDestroy(QObject *parent = 0); 32 | QTweetDirectMessageDestroy(OAuthTwitter *oauthTwitter, QObject *parent = 0); 33 | void destroyMessage(qint64 id, bool includeEntities = false); 34 | 35 | signals: 36 | /** emits destroyed direct message */ 37 | void parsedDirectMessage(const QTweetDMStatus& message); 38 | 39 | protected slots: 40 | void parseJsonFinished(const QJsonDocument &jsonDoc); 41 | }; 42 | 43 | #endif // QTWEETDIRECTMESSAGEDESTROY_H 44 | -------------------------------------------------------------------------------- /src/qtweetuserlookup.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETUSERLOOKUP_H 19 | #define QTWEETUSERLOOKUP_H 20 | 21 | #include 22 | #include "qtweetnetbase.h" 23 | 24 | class QTweetUser; 25 | 26 | /** 27 | * Class for fetching up to 100 users and theirs most recent status 28 | */ 29 | class QTWEETLIBSHARED_EXPORT QTweetUserLookup : public QTweetNetBase 30 | { 31 | Q_OBJECT 32 | public: 33 | QTweetUserLookup(QObject *parent = 0); 34 | QTweetUserLookup(OAuthTwitter *oauthTwitter, QObject *parent = 0); 35 | void fetch(const QList& useridList = QList(), 36 | const QStringList& screenNameList = QStringList()); 37 | 38 | signals: 39 | /** Emits list of users */ 40 | void parsedUserInfoList(const QList& userInfoList); 41 | 42 | protected slots: 43 | void parseJsonFinished(const QJsonDocument &jsonDoc); 44 | }; 45 | 46 | #endif // QTWEETUSERLOOKUP_H 47 | -------------------------------------------------------------------------------- /examples/geosearch/geosearch.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | GeoSearch 4 | 5 | 6 | 7 | 0 8 | 0 9 | 616 10 | 434 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | 26 | 27 | Latitude 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Longitude 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | Search 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/qtweetlistaddmember.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETLISTADDMEMBER_H 19 | #define QTWEETLISTADDMEMBER_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Add a member to a list. 25 | * The authenticated user must own the list to be able to add members to it. 26 | * Lists are limited to having 500 members. 27 | */ 28 | class QTWEETLIBSHARED_EXPORT QTweetListAddMember : public QTweetNetBase 29 | { 30 | Q_OBJECT 31 | public: 32 | QTweetListAddMember(QObject *parent = 0); 33 | QTweetListAddMember(OAuthTwitter *oauthTwitter, QObject *parent = 0); 34 | void add(qint64 user, 35 | qint64 list, 36 | qint64 memberid); 37 | 38 | signals: 39 | /** Emits list in which user was added */ 40 | void parsedList(const QTweetList& list); 41 | 42 | protected slots: 43 | void parseJsonFinished(const QJsonDocument &jsonDoc); 44 | }; 45 | 46 | #endif // QTWEETLISTADDMEMBER_H 47 | -------------------------------------------------------------------------------- /src/qtweetdirectmessages.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETDIRECTMESSAGES_H 19 | #define QTWEETDIRECTMESSAGES_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | class QTweetDMStatus; 24 | 25 | /** 26 | * Class for fetching direct messages 27 | */ 28 | class QTWEETLIBSHARED_EXPORT QTweetDirectMessages : public QTweetNetBase 29 | { 30 | Q_OBJECT 31 | public: 32 | QTweetDirectMessages(QObject *parent = 0); 33 | QTweetDirectMessages(OAuthTwitter* oauthTwitter, QObject *parent = 0); 34 | void fetch(qint64 sinceid = 0, 35 | qint64 maxid = 0, 36 | int count = 0, 37 | bool includeEntities = false); 38 | 39 | signals: 40 | /** Emits parsed direct messages list */ 41 | void parsedDirectMessages(const QList& messages); 42 | 43 | protected slots: 44 | void parseJsonFinished(const QJsonDocument &jsonDoc); 45 | }; 46 | 47 | #endif // QTWEETDIRECTMESSAGES_H 48 | -------------------------------------------------------------------------------- /src/qtweetlistdeletemember.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETLISTDELETEMEMBER_H 19 | #define QTWEETLISTDELETEMEMBER_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Removes the specified member from the list. 25 | * The authenticated user must be the list's owner to remove members from the list. 26 | */ 27 | class QTWEETLIBSHARED_EXPORT QTweetListDeleteMember : public QTweetNetBase 28 | { 29 | Q_OBJECT 30 | public: 31 | QTweetListDeleteMember(QObject *parent = 0); 32 | QTweetListDeleteMember(OAuthTwitter *oauthTwitter, QObject *parent = 0); 33 | void remove(qint64 user, 34 | qint64 list, 35 | qint64 member); 36 | 37 | signals: 38 | /** Emits list where member was deleted */ 39 | void parsedList(const QTweetList& list); 40 | 41 | protected slots: 42 | void parseJsonFinished(const QJsonDocument &jsonDoc); 43 | }; 44 | 45 | #endif // QTWEETLISTDELETEMEMBER_H 46 | -------------------------------------------------------------------------------- /src/qtweetblocksdestroy.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETBLOCKSDESTROY_H 19 | #define QTWEETBLOCKSDESTROY_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Un-blocks the user specified in the ID parameter for the authenticating user. 25 | * Returns the un-blocked user when successful. 26 | */ 27 | class QTWEETLIBSHARED_EXPORT QTweetBlocksDestroy : public QTweetNetBase 28 | { 29 | Q_OBJECT 30 | public: 31 | explicit QTweetBlocksDestroy(QObject *parent = 0); 32 | QTweetBlocksDestroy(OAuthTwitter *oauthTwitter, QObject *parent = 0); 33 | void unblock(qint64 userid, bool includeEntities = false); 34 | void unblock(const QString& screenName, bool includeEntities = false); 35 | 36 | signals: 37 | /** Emits the ublocked user */ 38 | void finishedUnblocking(const QTweetUser& user); 39 | 40 | protected slots: 41 | void parseJsonFinished(const QJsonDocument &jsonDoc); 42 | }; 43 | 44 | #endif // QTWEETBLOCKSDESTROY_H 45 | -------------------------------------------------------------------------------- /src/qtweetblocksexists.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETBLOCKSEXISTS_H 19 | #define QTWEETBLOCKSEXISTS_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Emits finishedIsBlocked if the authenticating user is blocking a target user. 25 | * Will return the blocked user's object if a block exists, 26 | * and error with a HTTP 404 response code otherwise. 27 | */ 28 | class QTweetBlocksExists : public QTweetNetBase 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit QTweetBlocksExists(QObject *parent = 0); 33 | QTweetBlocksExists(OAuthTwitter *oauthTwitter, QObject *parent = 0); 34 | void isBlocked(qint64 userid, bool includeEntities = false); 35 | void isBlocked(const QString& screenName, bool includeEntities = false); 36 | 37 | signals: 38 | void finishedIsBlocked(const QTweetUser& user); 39 | 40 | protected slots: 41 | void parseJsonFinished(const QJsonDocument &jsonDoc); 42 | }; 43 | 44 | #endif // QTWEETBLOCKSEXISTS_H 45 | -------------------------------------------------------------------------------- /src/qtweetgeocoord.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include "qtweetgeocoord.h" 19 | 20 | QTweetGeoCoord::QTweetGeoCoord() 21 | : m_validLatitude(false), m_validLongitude(false) 22 | { 23 | } 24 | 25 | QTweetGeoCoord::QTweetGeoCoord(double latitude, double longitude) 26 | { 27 | setLatitude(latitude); 28 | setLongitude(longitude); 29 | } 30 | 31 | bool QTweetGeoCoord::isValid() const 32 | { 33 | return m_validLatitude & m_validLongitude; 34 | } 35 | 36 | void QTweetGeoCoord::setLatitude(double latitude) 37 | { 38 | m_latitude = latitude; 39 | 40 | if (m_latitude > -90.0 || m_latitude < 90.0) 41 | m_validLatitude = true; 42 | else 43 | m_validLatitude = false; 44 | } 45 | 46 | void QTweetGeoCoord::setLongitude(double longitude) 47 | { 48 | m_longitude = longitude; 49 | 50 | if (m_longitude > -180.0 || m_longitude < 180.0) 51 | m_validLongitude = true; 52 | else 53 | m_validLongitude = false; 54 | } 55 | -------------------------------------------------------------------------------- /src/qtweetfriendshipdestroy.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETFRIENDSHIPDESTROY_H 19 | #define QTWEETFRIENDSHIPDESTROY_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Allows the authenticating users to unfollow the user specified in the ID parameter. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetFriendshipDestroy : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetFriendshipDestroy(QObject *parent = 0); 31 | QTweetFriendshipDestroy(OAuthTwitter *oauthTwitter, QObject *parent = 0); 32 | void unfollow(qint64 userid, 33 | bool includeEntities = false); 34 | void unfollow(const QString& screenName, 35 | bool includeEntities = false); 36 | 37 | signals: 38 | /** Emits unfollowed user */ 39 | void parsedUser(const QTweetUser& user); 40 | 41 | protected slots: 42 | void parseJsonFinished(const QJsonDocument &jsonDoc); 43 | }; 44 | 45 | #endif // QTWEETFRIENDSHIPDESTROY_H 46 | -------------------------------------------------------------------------------- /src/qtweetgeoplacecreate.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETGEOPLACECREATE_H 19 | #define QTWEETGEOPLACECREATE_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | class QTweetPlace; 24 | class QTweetGeoCoord; 25 | 26 | /** 27 | * Creates a new place at the given latitude and longitude 28 | */ 29 | class QTWEETLIBSHARED_EXPORT QTweetGeoPlaceCreate : public QTweetNetBase 30 | { 31 | Q_OBJECT 32 | public: 33 | QTweetGeoPlaceCreate(QObject *parent = 0); 34 | QTweetGeoPlaceCreate(OAuthTwitter *oauthTwitter, QObject *parent = 0); 35 | 36 | void create(const QString& name, 37 | const QString& containedWithin, 38 | const QString& token, 39 | const QTweetGeoCoord& latLong); 40 | 41 | signals: 42 | /** Emits geo place */ 43 | void parsedPlace(const QTweetPlace& place); 44 | 45 | protected slots: 46 | void parseJsonFinished(const QJsonDocument &jsonDoc); 47 | }; 48 | 49 | #endif // QTWEETGEOPLACECREATE_H 50 | -------------------------------------------------------------------------------- /src/qtweetdirectmessagessent.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETDIRECTMESSAGESSENT_H 19 | #define QTWEETDIRECTMESSAGESSENT_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Fetches direct messages sent by the authenticating user. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetDirectMessagesSent : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetDirectMessagesSent(QObject *parent = 0); 31 | QTweetDirectMessagesSent(OAuthTwitter *oauthTwitter, QObject *parent = 0); 32 | void fetch(qint64 sinceid = 0, 33 | qint64 maxid = 0, 34 | int count = 0, 35 | int page = 0, 36 | bool includeEntities = false); 37 | 38 | signals: 39 | /** Emits direct messages list */ 40 | void parsedDirectMessages(const QList& messages); 41 | 42 | protected slots: 43 | void parseJsonFinished(const QJsonDocument &jsonDoc); 44 | }; 45 | 46 | #endif // QTWEETDIRECTMESSAGESSENT_H 47 | -------------------------------------------------------------------------------- /examples/userstream/userstream.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef USERSTREAM_H 19 | #define USERSTREAM_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace Ui { 26 | class UserStream; 27 | } 28 | 29 | class OAuthTwitter; 30 | class QTweetUserStream; 31 | class QTweetStatus; 32 | 33 | class UserStream : public QWidget 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | explicit UserStream(QWidget *parent = 0); 39 | ~UserStream(); 40 | 41 | protected: 42 | void changeEvent(QEvent *e); 43 | 44 | private slots: 45 | void onConnectButtonClicked(); 46 | void onAuthorizeFinished(); 47 | void onAuthorizeError(); 48 | void stream(const QByteArray& stream); 49 | void statusStream(const QTweetStatus& tweet); 50 | 51 | private: 52 | Ui::UserStream *ui; 53 | OAuthTwitter *m_oauthTwitter; 54 | QTweetUserStream *m_userStream; 55 | QTextStream m_streamlogger; 56 | QFile m_file; 57 | }; 58 | 59 | #endif // USERSTREAM_H 60 | -------------------------------------------------------------------------------- /src/qtweetaccountverifycredentials.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETACCOUNTVERIFYCREDENTIALS_H 19 | #define QTWEETACCOUNTVERIFYCREDENTIALS_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Checks credentials of a authenticated user. Should emit parsedUser signal 25 | * if authentication was successful, error if not. Use this to test if 26 | * supplied user credentials are valid 27 | */ 28 | class QTWEETLIBSHARED_EXPORT QTweetAccountVerifyCredentials : public QTweetNetBase 29 | { 30 | Q_OBJECT 31 | public: 32 | QTweetAccountVerifyCredentials(QObject *parent = 0); 33 | QTweetAccountVerifyCredentials(OAuthTwitter *oauthTwitter, QObject *parent = 0); 34 | void verify(bool includeEntities = false); 35 | 36 | signals: 37 | /** Emits parsed user when credentials are valid */ 38 | void parsedUser(const QTweetUser& user); 39 | 40 | protected slots: 41 | void parseJsonFinished(const QJsonDocument &jsonDoc); 42 | }; 43 | 44 | #endif // QTWEETACCOUNTVERIFYCREDENTIALS_H 45 | -------------------------------------------------------------------------------- /src/qtweetblockscreate.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETBLOCKSCREATE_H 19 | #define QTWEETBLOCKSCREATE_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Blocks the user specified in the ID parameter as the authenticating user. 25 | * Destroys a friendship to the blocked user if it exists. 26 | * Returns the blocked user when successful. 27 | */ 28 | class QTWEETLIBSHARED_EXPORT QTweetBlocksCreate : public QTweetNetBase 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit QTweetBlocksCreate(QObject *parent = 0); 33 | QTweetBlocksCreate(OAuthTwitter *oauthTwitter, QObject *parent = 0); 34 | void create(qint64 userid, bool includeEnttities = false); 35 | void create(const QString& screenName, bool includeEntities = false); 36 | 37 | signals: 38 | /** Emits the blocked user */ 39 | void finishedCreatingBlock(const QTweetUser& user); 40 | 41 | protected slots: 42 | void parseJsonFinished(const QJsonDocument &jsonDoc); 43 | }; 44 | 45 | #endif // QTWEETBLOCKSCREATE_H 46 | -------------------------------------------------------------------------------- /src/qtweetentityusermentions.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETENTITYUSERMENTIONS_H 19 | #define QTWEETENTITYUSERMENTIONS_H 20 | 21 | #include 22 | 23 | class QTweetEntityUserMentionsData; 24 | 25 | class QTweetEntityUserMentions 26 | { 27 | public: 28 | QTweetEntityUserMentions(); 29 | QTweetEntityUserMentions(const QTweetEntityUserMentions &); 30 | QTweetEntityUserMentions &operator=(const QTweetEntityUserMentions &); 31 | ~QTweetEntityUserMentions(); 32 | 33 | void setScreenName(const QString& screenName); 34 | QString screenName() const; 35 | void setName(const QString& name); 36 | QString name() const; 37 | void setUserid(qint64 id); 38 | qint64 userid() const; 39 | void setLowerIndex(int index); 40 | int lowerIndex() const; 41 | void setHigherIndex(int index); 42 | int higherIndex() const; 43 | 44 | private: 45 | QSharedDataPointer data; 46 | }; 47 | 48 | #endif // QTWEETENTITYUSERMENTIONS_H 49 | -------------------------------------------------------------------------------- /examples/pinauthstatusupdate/statusupdatewidget.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef STATUSUPDATEWIDGET_H 19 | #define STATUSUPDATEWIDGET_H 20 | 21 | #include 22 | 23 | namespace Ui { 24 | class StatusUpdateWidget; 25 | } 26 | 27 | class OAuthTwitter; 28 | class QTweetStatus; 29 | 30 | class StatusUpdateWidget : public QWidget 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit StatusUpdateWidget(QWidget *parent = 0); 36 | ~StatusUpdateWidget(); 37 | 38 | private slots: 39 | void on_authorizeButton_clicked(); 40 | void on_updateButton_clicked(); 41 | void on_pinPushButton_clicked(); 42 | void finishedPostedStatus(const QTweetStatus& status); 43 | void finishedPostedStatusWithMedia(const QTweetStatus& status); 44 | void authenticateFinished(); 45 | void grantedAccess(); 46 | void error(); 47 | 48 | void on_addImagePushButton_clicked(); 49 | 50 | private: 51 | Ui::StatusUpdateWidget *ui; 52 | OAuthTwitter *m_oauthTwitter; 53 | }; 54 | 55 | #endif // STATUSUPDATEWIDGET_H 56 | -------------------------------------------------------------------------------- /src/qtweetaccountratelimitstatus.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETACCOUNTRATELIMITSTATUS_H 19 | #define QTWEETACCOUNTRATELIMITSTATUS_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Returns the remaining number of API requests available to the requesting user 25 | * before the API limit is reached for the current hour. 26 | */ 27 | class QTweetAccountRateLimitStatus : public QTweetNetBase 28 | { 29 | Q_OBJECT 30 | public: 31 | QTweetAccountRateLimitStatus(QObject *parent = 0); 32 | QTweetAccountRateLimitStatus(OAuthTwitter *oauthTwitter, QObject *parent = 0); 33 | void check(); 34 | 35 | signals: 36 | /** Emits rate limit info 37 | * @param remainingHits Remaining hits 38 | * @param resetTime Reset time in seconds 39 | * @param hourlyLimit 40 | */ 41 | void rateLimitInfo(int remainingHits, int resetTime, int hourlyLimit); 42 | 43 | protected slots: 44 | void parseJsonFinished(const QJsonDocument &jsonDoc); 45 | }; 46 | 47 | #endif // QTWEETACCOUNTRATELIMITSTATUS_H 48 | -------------------------------------------------------------------------------- /src/qtweetfriendshipcreate.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETFRIENDSHIPCREATE_H 19 | #define QTWEETFRIENDSHIPCREATE_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Allows the authenticating users to follow the user specified in the ID parameter. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetFriendshipCreate : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetFriendshipCreate(QObject *parent = 0); 31 | QTweetFriendshipCreate(OAuthTwitter *oauthTwitter, QObject *parent = 0); 32 | void create(qint64 userid, 33 | bool follow = false, 34 | bool includeEntities = false); 35 | void create(const QString& screenName, 36 | bool follow = false, 37 | bool includeEntities = false); 38 | 39 | signals: 40 | /** Emits the befriended user */ 41 | void parsedUser(const QTweetUser& user); 42 | 43 | protected slots: 44 | void parseJsonFinished(const QJsonDocument &jsonDoc); 45 | }; 46 | 47 | #endif // QTWEETFRIENDSHIPCREATE_H 48 | -------------------------------------------------------------------------------- /src/qtweetdirectmessagenew.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETDIRECTMESSAGENEW_H 19 | #define QTWEETDIRECTMESSAGENEW_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Sends a new direct message to the specified user from the authenticating user. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetDirectMessageNew : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetDirectMessageNew(QObject *parent = 0); 31 | QTweetDirectMessageNew(OAuthTwitter *oauhtTwitter, QObject *parent = 0); 32 | void post(qint64 user, 33 | const QString& text, 34 | bool includeEntities = false); 35 | void post(const QString& screenName, 36 | const QString& text, 37 | bool includeEntities = false); 38 | 39 | signals: 40 | /** Emits direct message who was sent */ 41 | void parsedDirectMessage(const QTweetDMStatus& message); 42 | 43 | protected slots: 44 | void parseJsonFinished(const QJsonDocument &jsonDoc); 45 | }; 46 | 47 | #endif // QTWEETDIRECTMESSAGENEW_H 48 | -------------------------------------------------------------------------------- /src/qtweetgeoreversegeocode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETGEOREVERSEGEOCODE_H 19 | #define QTWEETGEOREVERSEGEOCODE_H 20 | 21 | #include "qtweetnetbase.h" 22 | #include "qtweetplace.h" 23 | 24 | /** 25 | * Given a latitude and a longitude, searches up to 20 places that can be used 26 | * as placeId when updating a status 27 | */ 28 | class QTWEETLIBSHARED_EXPORT QTweetGeoReverseGeoCode : public QTweetNetBase 29 | { 30 | Q_OBJECT 31 | public: 32 | QTweetGeoReverseGeoCode(QObject *parent = 0); 33 | QTweetGeoReverseGeoCode(OAuthTwitter *oauthTwitter, QObject *parent = 0); 34 | 35 | void getPlaces(const QTweetGeoCoord& latLong, 36 | int accuracy = 0, 37 | QTweetPlace::Type granularity = QTweetPlace::Neighborhood, 38 | int maxResults = 0); 39 | 40 | signals: 41 | /** Emits list of places */ 42 | void parsedPlaces(const QList& places); 43 | 44 | protected slots: 45 | void parseJsonFinished(const QJsonDocument &jsonDoc); 46 | }; 47 | 48 | #endif // QTWEETGEOREVERSEGEOCODE_H 49 | -------------------------------------------------------------------------------- /src/qtweetstatusupdate.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETSTATUSUPDATE_H 19 | #define QTWEETSTATUSUPDATE_H 20 | 21 | #include "qtweetnetbase.h" 22 | #include "qtweetgeocoord.h" 23 | 24 | /** 25 | * Class for updating user status (posting tweet) 26 | */ 27 | class QTWEETLIBSHARED_EXPORT QTweetStatusUpdate : public QTweetNetBase 28 | { 29 | Q_OBJECT 30 | public: 31 | QTweetStatusUpdate(QObject *parent = 0); 32 | QTweetStatusUpdate(OAuthTwitter *oauthTwitter, QObject *parent = 0); 33 | void post(const QString& status, 34 | qint64 inReplyToStatus = 0, 35 | const QTweetGeoCoord& latLong = QTweetGeoCoord(), 36 | const QString& placeid = QString(), 37 | bool displayCoordinates = false, 38 | bool trimUser = false, 39 | bool includeEntities = false); 40 | 41 | signals: 42 | /** Emits posted status */ 43 | void postedStatus(const QTweetStatus& status); 44 | 45 | protected slots: 46 | void parseJsonFinished(const QJsonDocument &jsonDoc); 47 | }; 48 | 49 | #endif // QTWEETSTATUSUPDATE_H 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | QtwitterLib.pro.user 3 | *.pdb 4 | debug/* 5 | Makefile* 6 | QTwitLib.pro.user 7 | release/* 8 | QTweetLib.pro.user 9 | QTweetLib.pro.user.* 10 | exampletest/debug/* 11 | exampletest/ui_*.h 12 | exampletest/exampletest.pro.user 13 | exampletest/*.sdf 14 | exampletest/*.sln 15 | exampletest/*.suo 16 | exampletest/*.vcxproj 17 | exampletest/*.vcxproj.* 18 | exampletest/ipch/* 19 | *.opensdf 20 | exampletest/exampletest.pro.user.* 21 | lib/*.exe 22 | lib/*.dll 23 | lib/*.exp 24 | lib/*.ilk 25 | lib/*.lib 26 | lib/*.prl 27 | qjson/debug 28 | scr/debug 29 | src/debug 30 | qjson/*.vcxproj 31 | qjson/*.vcxproj.* 32 | *.sdf 33 | *.sln 34 | *.suo 35 | src/*.vcxproj 36 | src/*.vcxproj.* 37 | examples/search/debug/* 38 | examples/timelines/debug/* 39 | examples/statusupdate/debug/* 40 | examples/statusupdate/ui_mainwindow.h 41 | examples/timelines/ui_mainwindow.h 42 | examples/timelines/ui_mainwindow.h 43 | examples/geosearch/debug/* 44 | ipch/* 45 | examples/timelines/*.vcxproj.* 46 | examples/geosearch/*.vcxproj* 47 | examples/geosearch/ui_geosearch.h 48 | examples/search/*.vcxproj* 49 | examples/statusupdate/*.vcxproj* 50 | examples/timelines/*.vcxproj* 51 | examples/georeverse/debug/* 52 | examples/georeverse/ui_*.h 53 | examples/followers/debug/* 54 | examples/followers/*.vcxproj.* 55 | examples/followers/*.vcxproj 56 | examples/georeverse/*.vcxproj* 57 | examples/followers/ui_*.h 58 | examples/search/ui_*.h 59 | examples/search/ui_*.h 60 | examples/search/ui_*.h 61 | examples/userstream/debug/* 62 | examples/userstream/ui_*.h 63 | examples/pinauthstatusupdate/debug/*.obj 64 | examples/pinauthstatusupdate/debug/moc_*.cpp 65 | examples/pinauthstatusupdate/debug/*.exe 66 | examples/pinauthstatusupdate/debug/*.ilk 67 | examples/pinauthstatusupdate/debug/*.intermediate.manifest 68 | examples/pinauthstatusupdate/ui_*.h 69 | *.o -------------------------------------------------------------------------------- /src/qtweetsearch.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETSEARCH_H 19 | #define QTWEETSEARCH_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Gets tweets that match a specified query 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetSearch : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetSearch(QObject *parent = 0); 31 | QTweetSearch(OAuthTwitter *oauthTwitter, QObject *parent = 0); 32 | void start(const QString& query, 33 | const QString& lang = QString(), 34 | /* const QString& locale = QString(), */ 35 | int rpp = 0, 36 | int page = 0, 37 | qint64 sinceid = 0 38 | //geocode ### TODO 39 | //resultType ### TODO 40 | ); 41 | void startWithCustomQuery(const QByteArray& encodedQuery); 42 | 43 | signals: 44 | /** Emits page of search results */ 45 | void parsedPageResults(const QTweetSearchPageResults& pageResults); 46 | 47 | protected slots: 48 | void parseJsonFinished(const QJsonDocument &jsonDoc); 49 | }; 50 | 51 | #endif // QTWEETSEARCH_H 52 | -------------------------------------------------------------------------------- /examples/followers/followerslistmodel.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef FOLLOWERSLISTMODEL_H 19 | #define FOLLOWERSLISTMODEL_H 20 | 21 | #include 22 | #include "qtweetuser.h" 23 | 24 | class OAuthTwitter; 25 | 26 | class FollowersListModel : public QAbstractListModel 27 | { 28 | Q_OBJECT 29 | public: 30 | enum Roles { 31 | NameRole = Qt::UserRole + 1, 32 | ScreenNameRole, 33 | DescriptionRole, 34 | AvatarRole 35 | }; 36 | 37 | FollowersListModel(QObject *parent = 0); 38 | FollowersListModel(OAuthTwitter *oauthTwitter, QObject *parent = 0); 39 | void setOAuthTwitter(OAuthTwitter *oauthTwitter); 40 | int rowCount(const QModelIndex &parent) const; 41 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 42 | void fetchFollowers(const QString& cursor = QString("-1")); 43 | 44 | private slots: 45 | void followersFinished(const QList& followers, 46 | const QString& nextCursor); 47 | 48 | private: 49 | OAuthTwitter *m_oauthTwitter; 50 | QList m_users; 51 | }; 52 | 53 | #endif // FOLLOWERSLISTMODEL_H 54 | -------------------------------------------------------------------------------- /src/qtweetgeosimilarplaces.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETGEOSIMILARPLACES_H 19 | #define QTWEETGEOSIMILARPLACES_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | class QTweetPlace; 24 | class QTweetGeoCoord; 25 | 26 | /** 27 | * Locates places near the given coordinates which are similar in name 28 | * @see http://dev.twitter.com/doc/get/geo/similar_places 29 | */ 30 | class QTWEETLIBSHARED_EXPORT QTweetGeoSimilarPlaces : public QTweetNetBase 31 | { 32 | Q_OBJECT 33 | public: 34 | QTweetGeoSimilarPlaces(QObject *parent = 0); 35 | QTweetGeoSimilarPlaces(OAuthTwitter *oauthTwitter, QObject *parent = 0); 36 | void get(const QTweetGeoCoord& latLong, 37 | const QString& name, 38 | const QString& containedWithin = QString()); 39 | // ### TODO: Atributes, lack of documentation 40 | 41 | signals: 42 | /** Emits places 43 | * @param places list of places 44 | * @param token token to create a new place 45 | */ 46 | void parsedPlaces(const QList& places, const QString& token); 47 | 48 | protected slots: 49 | void parseJsonFinished(const QJsonDocument &jsonDoc); 50 | }; 51 | 52 | #endif // QTWEETGEOSIMILARPLACES_H 53 | -------------------------------------------------------------------------------- /examples/userstream/userstream.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | UserStream 4 | 5 | 6 | 7 | 0 8 | 0 9 | 418 10 | 529 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Username: 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Password: 38 | 39 | 40 | 41 | 42 | 43 | 44 | QLineEdit::Password 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Connect 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/qtweetfriendsid.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETFRIENDSID_H 19 | #define QTWEETFRIENDSID_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Returns an list of numeric IDs for every user the specified user is following. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetFriendsID : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetFriendsID(QObject *parent = 0); 31 | QTweetFriendsID(OAuthTwitter *oauthTwitter, QObject *parent = 0); 32 | void fetch(qint64 user, 33 | const QString& cursor = QString("-1")); 34 | void fetch(const QString& screenName, 35 | const QString& cursor = QString("-1")); 36 | 37 | signals: 38 | /** Emits one page of ids 39 | * @param ids list of ids user is following 40 | * @param nextCursor cursor for next page, "0" if there is no page 41 | * @param prevCursor cursor for prev page "0" if there is no page 42 | */ 43 | void parsedIDs(const QList& ids, 44 | const QString& nextCursor, 45 | const QString& prevCursor); 46 | 47 | protected slots: 48 | void parseJsonFinished(const QJsonDocument &jsonDoc); 49 | }; 50 | 51 | #endif // QTWEETFRIENDSID_H 52 | -------------------------------------------------------------------------------- /src/qtweetfollowersid.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETFOLLOWERSID_H 19 | #define QTWEETFOLLOWERSID_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Returns an list of numeric IDs for every user following the specified user. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetFollowersID : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | public: 30 | QTweetFollowersID(QObject *parent = 0); 31 | QTweetFollowersID(OAuthTwitter *oauthTwitter, QObject *parent = 0); 32 | void fetch(qint64 user, 33 | const QString& cursor = QString("-1")); 34 | void fetch(const QString& screenName, 35 | const QString& cursor = QString("-1")); 36 | 37 | signals: 38 | /** 39 | * Emits one page of ids 40 | * @param ids List of ids following the user 41 | * @param nextCursor Cursor for next page, "0" if there is no page 42 | * @param prevCursor Cursor for prev page "0" if there is no page 43 | */ 44 | void parsedIDs(const QList& ids, 45 | const QString& nextCursor, 46 | const QString& prevCursor); 47 | 48 | protected slots: 49 | void parseJsonFinished(const QJsonDocument &jsonDoc); 50 | }; 51 | #endif // QTWEETFOLLOWERSID_H 52 | -------------------------------------------------------------------------------- /examples/timelines/mainwindow.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef MAINWINDOW_H 19 | #define MAINWINDOW_H 20 | 21 | #include 22 | 23 | namespace Ui { 24 | class MainWindow; 25 | } 26 | 27 | class OAuthTwitter; 28 | class QTimer; 29 | class QTweetStatus; 30 | class QTweetDMStatus; 31 | 32 | class MainWindow : public QMainWindow 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | explicit MainWindow(QWidget *parent = 0); 38 | ~MainWindow(); 39 | 40 | protected: 41 | void changeEvent(QEvent *e); 42 | 43 | private slots: 44 | void authorizeButtonClicked(); 45 | void xauthFinished(); 46 | void xauthError(); 47 | void timerTimeOut(); 48 | void homeTimelineStatuses(const QList& statuses); 49 | void mentionsStatuses(const QList& statuses); 50 | void userTimelineStatuses(const QList& statuses); 51 | void directMessages(const QList& directMessages); 52 | 53 | private: 54 | Ui::MainWindow *ui; 55 | OAuthTwitter *m_oauthTwitter; 56 | QTimer *m_timer; 57 | qint64 m_sinceidHomeTimeline; 58 | qint64 m_sinceidMentions; 59 | qint64 m_sinceidUserTimeline; 60 | qint64 m_sinceidDirectMessages; 61 | 62 | }; 63 | 64 | #endif // MAINWINDOW_H 65 | -------------------------------------------------------------------------------- /src/qtweetgeosearch.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETGEOSEARCH_H 19 | #define QTWEETGEOSEARCH_H 20 | 21 | #include "qtweetplace.h" 22 | #include "qtweetnetbase.h" 23 | 24 | 25 | /** 26 | * Search for places that can be attached to a statuses/update 27 | * @see http://dev.twitter.com/doc/get/geo/search 28 | */ 29 | class QTWEETLIBSHARED_EXPORT QTweetGeoSearch : public QTweetNetBase 30 | { 31 | Q_OBJECT 32 | public: 33 | QTweetGeoSearch(QObject *parent = 0); 34 | QTweetGeoSearch(OAuthTwitter *oauthTwitter, QObject *parent = 0); 35 | void search(const QTweetGeoCoord& latLong = QTweetGeoCoord(), 36 | const QString& query = QString(), 37 | const QString& ip = QString(), 38 | QTweetPlace::Type granularity = QTweetPlace::Neighborhood, 39 | int accuracy = 0, 40 | int maxResults = 0, 41 | const QString& containedWithin = QString()); 42 | // ### TODO Atributes, not enough documentation 43 | 44 | signals: 45 | /** Emits list of places */ 46 | void parsedPlaces(const QList& places); 47 | 48 | protected slots: 49 | void parseJsonFinished(const QJsonDocument &jsonDoc); 50 | }; 51 | 52 | #endif // QTWEETGEOSEARCH_H 53 | -------------------------------------------------------------------------------- /examples/search/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 621 10 | 600 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 21 | Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Query: 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | Qt::Horizontal 41 | 42 | 43 | 44 | 40 45 | 20 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Search 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/qtweetsearchresult.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETSEARCHRESULT_H 19 | #define QTWEETSEARCHRESULT_H 20 | 21 | #include 22 | #include 23 | #include "qtweetlib_global.h" 24 | 25 | class QTweetSearchResultData; 26 | 27 | /** 28 | * Stores search result 29 | */ 30 | class QTWEETLIBSHARED_EXPORT QTweetSearchResult 31 | { 32 | public: 33 | QTweetSearchResult(); 34 | QTweetSearchResult(const QTweetSearchResult &); 35 | QTweetSearchResult &operator=(const QTweetSearchResult &); 36 | ~QTweetSearchResult(); 37 | 38 | void setCreatedAt(const QString& twitterDate); 39 | void setCreatedAt(const QDateTime& dateTime); 40 | QDateTime createdAt() const; 41 | void setFromUser(const QString& screenName); 42 | QString fromUser() const; 43 | void setId(qint64 id); 44 | qint64 id() const; 45 | void setLang(const QString& lang); 46 | QString lang() const; 47 | void setProfileImageUrl(const QString& url); 48 | QString profileImageUrl() const; 49 | void setSource(const QString& source); 50 | QString source() const; 51 | void setText(const QString& text); 52 | QString text() const; 53 | void setToUser(const QString& screenName); 54 | QString toUser() const; 55 | 56 | private: 57 | QSharedDataPointer data; 58 | }; 59 | 60 | #endif // QTWEETSEARCHRESULT_H 61 | -------------------------------------------------------------------------------- /src/qtweetentityhashtag.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include "qtweetentityhashtag.h" 19 | #include 20 | #include 21 | 22 | class QTweetEntityHashtagData : public QSharedData 23 | { 24 | public: 25 | QString hashtag; 26 | int lower_index; 27 | int higher_index; 28 | }; 29 | 30 | QTweetEntityHashtag::QTweetEntityHashtag() 31 | : data(new QTweetEntityHashtagData) 32 | { 33 | } 34 | 35 | QTweetEntityHashtag::QTweetEntityHashtag(const QTweetEntityHashtag &rhs) 36 | : data(rhs.data) 37 | { 38 | } 39 | 40 | QTweetEntityHashtag &QTweetEntityHashtag::operator=(const QTweetEntityHashtag &rhs) 41 | { 42 | if (this != &rhs) 43 | data.operator=(rhs.data); 44 | return *this; 45 | } 46 | 47 | QTweetEntityHashtag::~QTweetEntityHashtag() 48 | { 49 | } 50 | 51 | void QTweetEntityHashtag::setText(const QString &text) 52 | { 53 | data->hashtag = text; 54 | } 55 | 56 | QString QTweetEntityHashtag::text() const 57 | { 58 | return data->hashtag; 59 | } 60 | 61 | void QTweetEntityHashtag::setLowerIndex(int index) 62 | { 63 | data->lower_index = index; 64 | } 65 | 66 | int QTweetEntityHashtag::lowerIndex() const 67 | { 68 | return data->lower_index; 69 | } 70 | 71 | void QTweetEntityHashtag::setHigherIndex(int index) 72 | { 73 | data->higher_index = index; 74 | } 75 | 76 | int QTweetEntityHashtag::higherIndex() const 77 | { 78 | return data->higher_index; 79 | } 80 | -------------------------------------------------------------------------------- /examples/followers/followers.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include "followers.h" 19 | #include "ui_followers.h" 20 | #include 21 | #include 22 | #include "followerslistmodel.h" 23 | #include "oauthtwitter.h" 24 | 25 | Followers::Followers(QWidget *parent) : 26 | QWidget(parent), 27 | ui(new Ui::Followers) 28 | { 29 | ui->setupUi(this); 30 | 31 | m_oauthTwitter = new OAuthTwitter(this); 32 | m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this)); 33 | m_oauthTwitter->setOAuthToken(""); 34 | m_oauthTwitter->setOAuthTokenSecret(""); 35 | 36 | m_followersListModel = new FollowersListModel(m_oauthTwitter, this); 37 | 38 | ui->declarativeView->rootContext()->setContextProperty("followersListModel", m_followersListModel); 39 | ui->declarativeView->setSource(QUrl("qrc:/FollowersList.qml")); 40 | 41 | connect(ui->fetchFollowersPushButton, SIGNAL(clicked()), SLOT(onFetchFollowersPushButtonClicked())); 42 | } 43 | 44 | Followers::~Followers() 45 | { 46 | delete ui; 47 | } 48 | 49 | void Followers::changeEvent(QEvent *e) 50 | { 51 | QWidget::changeEvent(e); 52 | switch (e->type()) { 53 | case QEvent::LanguageChange: 54 | ui->retranslateUi(this); 55 | break; 56 | default: 57 | break; 58 | } 59 | } 60 | 61 | void Followers::onFetchFollowersPushButtonClicked() 62 | { 63 | m_followersListModel->fetchFollowers(); 64 | } 65 | -------------------------------------------------------------------------------- /src/qtweetentitymedia.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETENTITYMEDIA_H 19 | #define QTWEETENTITYMEDIA_H 20 | 21 | #include 22 | 23 | class QTweetEntityMediaData; 24 | class QSize; 25 | 26 | class QTweetEntityMedia 27 | { 28 | public: 29 | QTweetEntityMedia(); 30 | QTweetEntityMedia(const QTweetEntityMedia& ); 31 | QTweetEntityMedia & operator = (const QTweetEntityMedia& ); 32 | ~QTweetEntityMedia(); 33 | 34 | enum MediaSize { 35 | LARGE, 36 | MEDIUM, 37 | SMALL, 38 | THUMB 39 | }; 40 | 41 | void setID(const QString& id); 42 | QString id() const; 43 | 44 | void setMediaUrl(const QString& url); 45 | QString mediaUrl() const; 46 | 47 | void setMediaUrlHttps(const QString& url); 48 | QString mediaUrlHttps() const; 49 | 50 | void setUrl(const QString& url); 51 | QString url() const; 52 | 53 | void setDisplayUrl(const QString& url); 54 | QString displayUrl() const; 55 | 56 | void setExpandedUrl(const QString& url); 57 | QString expandedUrl() const; 58 | 59 | void setSize(const QSize& size, MediaSize type); 60 | QSize size(MediaSize type) const; 61 | 62 | void setHigherIndex(int index); 63 | int higherIndex() const; 64 | 65 | void setLowerIndex(int index); 66 | int lowerIndex() const; 67 | 68 | private: 69 | QSharedDataPointer data; 70 | }; 71 | 72 | #endif // QTWEETENTITYMEDIA_H 73 | -------------------------------------------------------------------------------- /src/qtweetstatusretweetbyid.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETSTATUSRETWEETBYID_H 19 | #define QTWEETSTATUSRETWEETBYID_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Show user ids of up to 100 users who retweeted the status. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetStatusRetweetByID : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | Q_PROPERTY(qint64 tweetid READ tweetid WRITE setTweetid) 30 | Q_PROPERTY(int count READ count WRITE setCount) 31 | Q_PROPERTY(int page READ page WRITE setPage) 32 | 33 | public: 34 | explicit QTweetStatusRetweetByID(QObject *parent = 0); 35 | QTweetStatusRetweetByID(OAuthTwitter *oauthTwitter, QObject *parent = 0); 36 | void fetch(qint64 tweetid, int count = 0, int page = 0); 37 | void get(); 38 | 39 | void setTweetid(qint64 id) { m_tweetid = id; } 40 | qint64 tweetid() const { return m_tweetid; } 41 | 42 | void setCount(int count) { m_count = count; } 43 | int count() const { return m_count; } 44 | 45 | void setPage(int page) { m_page = page; } 46 | int page() const { return m_page; } 47 | 48 | signals: 49 | /** Emits the users id who retweeted the tweet */ 50 | void parsedUsersID(const QList& listid); 51 | 52 | protected slots: 53 | void parseJsonFinished(const QJsonDocument &jsonDoc); 54 | 55 | private: 56 | qint64 m_tweetid; 57 | int m_count; 58 | int m_page; 59 | }; 60 | 61 | #endif // QTWEETSTATUSRETWEETBYID_H 62 | -------------------------------------------------------------------------------- /src/qtweetlist.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETLIST_H 19 | #define QTWEETLIST_H 20 | 21 | #include 22 | #include 23 | #include "qtweetlib_global.h" 24 | 25 | class QTweetUser; 26 | class QTweetListData; 27 | 28 | /** 29 | * Stores list information 30 | */ 31 | class QTWEETLIBSHARED_EXPORT QTweetList 32 | { 33 | public: 34 | QTweetList(); 35 | QTweetList(const QTweetList& other); 36 | QTweetList& operator=(const QTweetList& other); 37 | ~QTweetList(); 38 | 39 | void setMode(const QString& mode); 40 | QString mode() const; 41 | void setDescription(const QString& desc); 42 | QString description() const; 43 | void setFollowing(bool following); 44 | bool following() const; 45 | void setMemberCount(int count); 46 | int memberCount() const; 47 | void setFullName(const QString& name); 48 | QString fullName() const; 49 | void setSubscriberCount(int count); 50 | int subscriberCount() const; 51 | void setSlug(const QString& slug); 52 | QString slug() const; 53 | void setName(const QString& name); 54 | QString name() const; 55 | void setId(qint64 id); 56 | qint64 id() const; 57 | void setUri(const QString& uri); 58 | QString uri() const; 59 | void setUser(const QTweetUser& user); 60 | QTweetUser user() const; 61 | 62 | private: 63 | QSharedDataPointer d; 64 | }; 65 | 66 | Q_DECLARE_METATYPE(QTweetList) 67 | 68 | #endif // QTWEETLIST_H 69 | -------------------------------------------------------------------------------- /src/qtweetstatusretweetedby.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETSTATUSRETWEETEDBY_H 19 | #define QTWEETSTATUSRETWEETEDBY_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Show user objects of up to 100 members who retweeted the status. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetStatusRetweetedBy : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | Q_PROPERTY(qint64 tweetid READ tweetid WRITE setTweetid) 30 | Q_PROPERTY(int count READ count WRITE setCount) 31 | Q_PROPERTY(int page READ page WRITE setPage) 32 | 33 | public: 34 | explicit QTweetStatusRetweetedBy(QObject *parent = 0); 35 | QTweetStatusRetweetedBy(OAuthTwitter *oauthTwitter, QObject *parent = 0); 36 | void fetch(qint64 tweetid, int count = 0, int page = 0); 37 | void get(); 38 | 39 | void setTweetid(qint64 id) { m_tweetid = id; } 40 | qint64 tweetid() const { return m_tweetid; } 41 | 42 | void setCount(int count) { m_count = count; } 43 | int count() const { return m_count; } 44 | 45 | void setPage(int page) { m_page = page; } 46 | int page() const { return m_page; } 47 | 48 | signals: 49 | /** Emits the users who retweeted the tweet */ 50 | void parsedUsers(const QList& users); 51 | 52 | protected slots: 53 | void parseJsonFinished(const QJsonDocument &jsonDoc); 54 | 55 | public slots: 56 | 57 | private: 58 | qint64 m_tweetid; 59 | int m_count; 60 | int m_page; 61 | }; 62 | 63 | #endif // QTWEETSTATUSRETWEETEDBY_H 64 | -------------------------------------------------------------------------------- /src/qtweetstatusretweets.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETSTATUSRETWEETS_H 19 | #define QTWEETSTATUSRETWEETS_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Class to fetch up to 100 of the first retweets of a given tweet. 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetStatusRetweets : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | Q_PROPERTY(qint64 tweetid READ tweetid WRITE setTweetid) 30 | Q_PROPERTY(int count READ count WRITE setCount) 31 | Q_PROPERTY(bool trimUser READ isTrimUser WRITE setTrimUser) 32 | 33 | public: 34 | explicit QTweetStatusRetweets(QObject *parent = 0); 35 | QTweetStatusRetweets(OAuthTwitter *oauthTwitter, QObject *parent = 0); 36 | void fetch(qint64 id, int count = 0, bool trimUser = false); 37 | void get(); 38 | 39 | void setTweetid(qint64 id) { m_tweetid = id; } 40 | qint64 tweetid() const { return m_tweetid; } 41 | 42 | void setCount(int count) { m_count = count; } 43 | int count() const { return m_count; } 44 | 45 | void setTrimUser(bool trimUser) { m_trimUser = trimUser; } 46 | bool isTrimUser() const { return m_trimUser; } 47 | 48 | signals: 49 | /** Emits retweet status list */ 50 | void parsedStatuses(const QList& statuses); 51 | 52 | protected slots: 53 | void parseJsonFinished(const QJsonDocument &jsonDoc); 54 | 55 | private: 56 | // ### TODO: Use pimpl 57 | qint64 m_tweetid; 58 | int m_count; 59 | bool m_trimUser; 60 | }; 61 | 62 | #endif // QTWEETSTATUSRETWEETS_H 63 | -------------------------------------------------------------------------------- /src/qtweetdmstatus.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETDMSTATUS_H 19 | #define QTWEETDMSTATUS_H 20 | 21 | #include 22 | #include 23 | #include "qtweetlib_global.h" 24 | 25 | class QTweetUser; 26 | class QTweetDMStatusData; 27 | 28 | /** 29 | * Stores direct message info 30 | */ 31 | class QTWEETLIBSHARED_EXPORT QTweetDMStatus 32 | { 33 | public: 34 | QTweetDMStatus(); 35 | QTweetDMStatus(const QTweetDMStatus& other); 36 | QTweetDMStatus& operator=(const QTweetDMStatus& other); 37 | ~QTweetDMStatus(); 38 | 39 | void setCreatedAt(const QString& twitterDate); 40 | void setCreatedAt(const QDateTime& datetime); 41 | QDateTime createdAt() const; 42 | void setSenderScreenName(const QString& screenName); 43 | QString senderScreenName() const; 44 | void setSender(const QTweetUser& sender); 45 | QTweetUser sender() const; 46 | void setText(const QString& text); 47 | QString text() const; 48 | void setRecipientScreenName(const QString& screenName); 49 | QString recipientScreenName() const; 50 | void setId(qint64 id); 51 | qint64 id() const; 52 | void setRecipient(const QTweetUser& recipient); 53 | QTweetUser recipient() const; 54 | void setRecipientId(qint64 id); 55 | qint64 recipientId() const; 56 | void setSenderId(qint64 id); 57 | qint64 senderId() const; 58 | 59 | private: 60 | QSharedDataPointer d; 61 | }; 62 | 63 | Q_DECLARE_METATYPE(QTweetDMStatus) 64 | 65 | #endif // QTWEETDMSTATUS_H 66 | -------------------------------------------------------------------------------- /src/qtweetgeoboundingbox.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETGEOBOUNDINGBOX_H 19 | #define QTWEETGEOBOUNDINGBOX_H 20 | 21 | #include "qtweetlib_global.h" 22 | #include "qtweetgeocoord.h" 23 | 24 | /** 25 | * Stores geo bounding box 26 | * Doesnt' do anything fancy/calculations just stores boundind box info from twitter api 27 | */ 28 | class QTWEETLIBSHARED_EXPORT QTweetGeoBoundingBox 29 | { 30 | public: 31 | QTweetGeoBoundingBox(); 32 | QTweetGeoBoundingBox(const QTweetGeoCoord& topLeft, 33 | const QTweetGeoCoord& topRight, 34 | const QTweetGeoCoord& bottomRight, 35 | const QTweetGeoCoord& bottomLeft); 36 | QTweetGeoCoord topLeft() const { return m_topLeft; } 37 | QTweetGeoCoord topRight() const { return m_topRight; } 38 | QTweetGeoCoord bottomRight() const { return m_bottomRight; } 39 | QTweetGeoCoord bottomLeft() const { return m_bottomLeft; } 40 | void setTopLeft(const QTweetGeoCoord& topLeft) { m_topLeft = topLeft; } 41 | void setTopRight(const QTweetGeoCoord& topRight) { m_topRight = topRight; } 42 | void setBottomRight(const QTweetGeoCoord& bottomRight) { m_bottomRight = bottomRight; } 43 | void setBottomLeft(const QTweetGeoCoord& bottomLeft) { m_bottomLeft = bottomLeft; } 44 | bool isValid() const; 45 | 46 | private: 47 | QTweetGeoCoord m_topLeft; 48 | QTweetGeoCoord m_topRight; 49 | QTweetGeoCoord m_bottomRight; 50 | QTweetGeoCoord m_bottomLeft; 51 | }; 52 | 53 | #endif // QTWEETGEOBOUNDINGBOX_H 54 | -------------------------------------------------------------------------------- /src/qtweetstatusretweet.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETSTATUSRETWEET_H 19 | #define QTWEETSTATUSRETWEET_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Class for retweeting tweet 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetStatusRetweet : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | Q_PROPERTY(qint64 id READ id WRITE setID) 30 | Q_PROPERTY(bool trimUser READ trimUser WRITE setTrimUser) 31 | Q_PROPERTY(bool includeEntities READ includeEntities WRITE setIncludeEntities) 32 | 33 | public: 34 | QTweetStatusRetweet(QObject *parent = 0); 35 | QTweetStatusRetweet(OAuthTwitter *oauthTwitter, QObject *parent = 0); 36 | void retweet(qint64 id, 37 | bool trimUser = false, 38 | bool includeEntities = false); 39 | void retweet(); 40 | 41 | void setID(qint64 id) { m_id = id; } 42 | qint64 id() const { return m_id; } 43 | 44 | void setTrimUser(bool trimUser) { m_trimUser = trimUser; } 45 | bool trimUser() const { return m_trimUser; } 46 | 47 | void setIncludeEntities(bool includeEntities) { m_includeEntities = includeEntities; } 48 | bool includeEntities() const { return m_includeEntities; } 49 | 50 | signals: 51 | /** Emits retweeted tweet */ 52 | void postedRetweet(const QTweetStatus& status); 53 | 54 | protected slots: 55 | void parseJsonFinished(const QJsonDocument &jsonDoc); 56 | 57 | private: 58 | qint64 m_id; 59 | bool m_trimUser; 60 | bool m_includeEntities; 61 | }; 62 | 63 | #endif // QTWEETSTATUSRETWEET_H 64 | -------------------------------------------------------------------------------- /src/qtweetplace.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETPLACE_H 19 | #define QTWEETPLACE_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include "qtweetgeoboundingbox.h" 25 | #include "qtweetlib_global.h" 26 | 27 | 28 | /** 29 | * Store place info 30 | */ 31 | class QTWEETLIBSHARED_EXPORT QTweetPlace 32 | { 33 | public: 34 | enum Type { Poi, Neighborhood, City, Admin, Country }; 35 | 36 | QTweetPlace(); 37 | void setName(const QString& name); 38 | QString name() const; 39 | void setCountry(const QString& country); 40 | QString country() const; 41 | void setCountryCode(const QString& code); 42 | QString countryCode() const; 43 | void setID(const QString& id); // http://api.twitter.com/1/geo/id/.json 44 | QString id() const; 45 | void setBoundingBox(const QTweetGeoBoundingBox& box); 46 | QTweetGeoBoundingBox boundingBox() const; 47 | void setContainedWithin(const QList& places); 48 | QList containedWithin() const; 49 | void setFullName(const QString& name); 50 | QString fullName() const; 51 | void setType(Type type); 52 | Type type() const; 53 | 54 | private: 55 | QString m_name; 56 | QString m_country; 57 | QString m_countryCode; 58 | // ### TODO: Attributes 59 | QString m_id; 60 | QTweetGeoBoundingBox m_boundingBox; 61 | QList m_containedWithin; 62 | QString m_fullName; 63 | Type m_type; 64 | }; 65 | 66 | Q_DECLARE_METATYPE(QTweetPlace) 67 | 68 | #endif // QTWEETPLACE_H 69 | -------------------------------------------------------------------------------- /src/qtweetsearchpageresults.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETSEARCHPAGERESULTS_H 19 | #define QTWEETSEARCHPAGERESULTS_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include "qtweetlib_global.h" 25 | 26 | class QTweetSearchPageResultsData; 27 | class QTweetSearchResult; 28 | 29 | /** 30 | * Stores page of a search results 31 | */ 32 | class QTWEETLIBSHARED_EXPORT QTweetSearchPageResults 33 | { 34 | public: 35 | QTweetSearchPageResults(); 36 | QTweetSearchPageResults(const QTweetSearchPageResults &); 37 | QTweetSearchPageResults &operator=(const QTweetSearchPageResults &); 38 | ~QTweetSearchPageResults(); 39 | 40 | void setMaxId(qint64 maxid); 41 | qint64 maxid() const; 42 | void setNextPage(const QByteArray& nextPage); 43 | QByteArray nextPage() const; 44 | void setPage(int numPage); 45 | int page() const; 46 | void setQuery(const QByteArray& query); 47 | QByteArray query() const; 48 | void setRefreshUrl(const QByteArray& url); 49 | QByteArray refreshUrl() const; 50 | void setResults(const QList& results); 51 | QList results() const; 52 | void setResultsPerPage (int count); 53 | int resultsPerPage() const; 54 | void setSinceId(qint64 sinceid); 55 | qint64 sinceid() const; 56 | void setTotal(int total); 57 | int total() const; 58 | 59 | private: 60 | QSharedDataPointer data; 61 | }; 62 | 63 | Q_DECLARE_METATYPE(QTweetSearchPageResults) 64 | 65 | #endif // QTWEETSEARCHPAGERESULTS_H 66 | -------------------------------------------------------------------------------- /src/qtweetlistshowlist.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetlistshowlist.h" 22 | #include "qtweetlist.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonarray.h" 26 | #include "json/qjsonobject.h" 27 | 28 | QTweetListShowList::QTweetListShowList(QObject *parent) : 29 | QTweetNetBase(parent) 30 | { 31 | } 32 | 33 | QTweetListShowList::QTweetListShowList(OAuthTwitter *oauthTwitter, QObject *parent) : 34 | QTweetNetBase(oauthTwitter, parent) 35 | { 36 | } 37 | 38 | /** 39 | * Shows (gets) specified list 40 | * @param id user id 41 | * @param list list id 42 | */ 43 | void QTweetListShowList::show(qint64 id, qint64 list) 44 | { 45 | // slug parameter? 46 | 47 | if (!isAuthenticationEnabled()) { 48 | qCritical("Needs authentication to be enabled"); 49 | return; 50 | } 51 | 52 | QUrl url(QString("http://api.twitter.com/1/%1/lists/%2.json").arg(id).arg(list)); 53 | 54 | QNetworkRequest req(url); 55 | 56 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 57 | req.setRawHeader(AUTH_HEADER, oauthHeader); 58 | 59 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 60 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 61 | } 62 | 63 | void QTweetListShowList::parseJsonFinished(const QJsonDocument &jsonDoc) 64 | { 65 | if (jsonDoc.isObject()) { 66 | QTweetList list = QTweetConvert::jsonObjectToTweetList(jsonDoc.object()); 67 | 68 | emit parsedList(list); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/qtweetgeoplaceid.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetgeoplaceid.h" 22 | #include "qtweetplace.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonobject.h" 26 | 27 | /** 28 | * Constructor 29 | */ 30 | QTweetGeoPlaceID::QTweetGeoPlaceID(QObject *parent) : 31 | QTweetNetBase(parent) 32 | { 33 | } 34 | 35 | /** 36 | * Constructor 37 | * @param oauthTwitter OAuthTwitter object 38 | * @param parent parent QObject 39 | */ 40 | QTweetGeoPlaceID::QTweetGeoPlaceID(OAuthTwitter *oauthTwitter, QObject *parent) : 41 | QTweetNetBase(oauthTwitter, parent) 42 | { 43 | } 44 | 45 | /** 46 | * Starts fetching information about place 47 | * @param placeid a place in the world. These ID's can be retrieved from QTweetGeoReverseGeoCode 48 | */ 49 | void QTweetGeoPlaceID::get(const QString &placeid) 50 | { 51 | QUrl url(QString("http://api.twitter.com/1/geo/id/%1.json").arg(placeid)); 52 | 53 | QNetworkRequest req(url); 54 | 55 | if (isAuthenticationEnabled()) { 56 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 57 | req.setRawHeader(AUTH_HEADER, oauthHeader); 58 | } 59 | 60 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 61 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 62 | } 63 | 64 | void QTweetGeoPlaceID::parseJsonFinished(const QJsonDocument &jsonDoc) 65 | { 66 | if (jsonDoc.isObject()) { 67 | QTweetPlace place = QTweetConvert::jsonObjectToPlaceRecursive(jsonDoc.object()); 68 | 69 | emit parsedPlace(place); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/qtweetlistsubscribe.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetlistsubscribe.h" 22 | #include "qtweetlist.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonobject.h" 26 | 27 | QTweetListSubscribe::QTweetListSubscribe(QObject *parent) : 28 | QTweetNetBase(parent) 29 | { 30 | } 31 | 32 | QTweetListSubscribe::QTweetListSubscribe(OAuthTwitter *oauthTwitter, QObject *parent) : 33 | QTweetNetBase(oauthTwitter, parent) 34 | { 35 | } 36 | 37 | /** 38 | * @param user user id owner of the list 39 | * @param list list id 40 | */ 41 | void QTweetListSubscribe::follow(qint64 user, qint64 list) 42 | { 43 | if (!isAuthenticationEnabled()) { 44 | qCritical("Needs authentication to be enabled"); 45 | return; 46 | } 47 | 48 | QUrl url(QString("http://api.twitter.com/1/%1/%2/subscribers.json").arg(user).arg(list)); 49 | 50 | QNetworkRequest req(url); 51 | 52 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::POST); 53 | req.setRawHeader(AUTH_HEADER, oauthHeader); 54 | req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); 55 | 56 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, QByteArray()); 57 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 58 | } 59 | 60 | void QTweetListSubscribe::parseJsonFinished(const QJsonDocument &jsonDoc) 61 | { 62 | if (jsonDoc.isObject()) { 63 | QTweetList list = QTweetConvert::jsonObjectToTweetList(jsonDoc.object()); 64 | 65 | emit parsedList(list); 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/qtweetuserstatusesfollowers.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETUSERSTATUSESFOLLOWERS_H 19 | #define QTWEETUSERSTATUSESFOLLOWERS_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Fetches the authenticating user's followers, each with current status inline. 25 | * They are ordered by the order in which they followed the user, 100 at a time. 26 | * 27 | * Use the cursor option to access older friends. 28 | */ 29 | class QTWEETLIBSHARED_EXPORT QTweetUserStatusesFollowers : public QTweetNetBase 30 | { 31 | Q_OBJECT 32 | public: 33 | QTweetUserStatusesFollowers(QObject *parent = 0); 34 | QTweetUserStatusesFollowers(OAuthTwitter *oauthTwitter, QObject *parent = 0); 35 | void fetch(qint64 userid = 0, 36 | const QString& cursor = QString(), 37 | bool includeEntities = false); 38 | void fetch(const QString& screenName = QString(), 39 | const QString& cursor = QString(), 40 | bool includeEntities = false); 41 | 42 | signals: 43 | /** Emits page of followers list 44 | * @param followersList list of friends 45 | * @param nextCursor cursor for next page, "0" if there is no next page, empty if there is no paging 46 | * @param prevCursor cursor for prev page, "0" if there is no prev page, empty if there is no paging 47 | */ 48 | void parsedFollowersList(const QList& followersList, 49 | const QString& nextCursor = QString(), 50 | const QString& prevCursor = QString()); 51 | 52 | protected slots: 53 | void parseJsonFinished(const QJsonDocument &jsonDoc); 54 | 55 | private: 56 | bool m_usesCursoring; 57 | }; 58 | 59 | #endif // QTWEETUSERSTATUSESFOLLOWERS_H 60 | -------------------------------------------------------------------------------- /src/qtweetlistdeletemember.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetlistdeletemember.h" 22 | #include "qtweetlist.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonobject.h" 26 | 27 | QTweetListDeleteMember::QTweetListDeleteMember(QObject *parent) : 28 | QTweetNetBase(parent) 29 | { 30 | } 31 | 32 | QTweetListDeleteMember::QTweetListDeleteMember(OAuthTwitter *oauthTwitter, QObject *parent) : 33 | QTweetNetBase(oauthTwitter, parent) 34 | { 35 | } 36 | 37 | /** 38 | * @param user user id (owner of the list 39 | * @param list list id 40 | * @param member user id of the list member to remove 41 | */ 42 | void QTweetListDeleteMember::remove(qint64 user, qint64 list, qint64 member) 43 | { 44 | if (!isAuthenticationEnabled()) { 45 | qCritical("Needs authentication to be enabled"); 46 | return; 47 | } 48 | 49 | QUrl url(QString("http://api.twitter.com/1/%1/%2/members.json").arg(user).arg(list)); 50 | 51 | url.addQueryItem("id", QString::number(member)); 52 | 53 | QNetworkRequest req(url); 54 | 55 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::DELETE); 56 | req.setRawHeader(AUTH_HEADER, oauthHeader); 57 | 58 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->deleteResource(req); 59 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 60 | } 61 | 62 | void QTweetListDeleteMember::parseJsonFinished(const QJsonDocument &jsonDoc) 63 | { 64 | if (jsonDoc.isObject()) { 65 | QTweetList list = QTweetConvert::jsonObjectToTweetList(jsonDoc.object()); 66 | 67 | emit parsedList(list); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/oauthtwitter.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef OAUTHTWITTER_H 19 | #define OAUTHTWITTER_H 20 | 21 | #include "oauth.h" 22 | 23 | class QNetworkAccessManager; 24 | 25 | /** 26 | * OAuth Twitter authorization class 27 | */ 28 | class QTWEETLIBSHARED_EXPORT OAuthTwitter : public OAuth 29 | { 30 | Q_OBJECT 31 | Q_PROPERTY(QNetworkAccessManager* networkAccessManager 32 | READ networkAccessManager 33 | WRITE setNetworkAccessManager) 34 | public: 35 | OAuthTwitter(QObject *parent = 0); 36 | OAuthTwitter(QNetworkAccessManager* netManager, QObject *parent = 0); 37 | OAuthTwitter(const QByteArray& consumerKey, const QByteArray& consumerSecret, QObject *parent = 0); 38 | void setNetworkAccessManager(QNetworkAccessManager* netManager); 39 | QNetworkAccessManager* networkAccessManager() const; 40 | 41 | signals: 42 | /** Emited when XAuth authorization is finished */ 43 | void authorizeXAuthFinished(); 44 | /** Emited when pin authenticate is finished. This is where user should enter PIN number */ 45 | void authorizePinAuthenticate(); 46 | /** Emited when PIN authorization is finished (access tokens granted) */ 47 | void authorizePinFinished(); 48 | /** Emited when there is error in XAuth authorization */ 49 | // ### TODO Error detection 50 | void authorizeXAuthError(); 51 | 52 | public slots: 53 | void requestAccessToken(const QString& pin); 54 | void authorizeXAuth(const QString& username, const QString& password); 55 | void authorizePin(); 56 | 57 | protected: 58 | virtual void requestAuthorization(); 59 | 60 | private slots: 61 | void finishedAuthorization(); 62 | 63 | private: 64 | QNetworkAccessManager *m_netManager; 65 | }; 66 | 67 | #endif //OAUTHTWITTER_H 68 | -------------------------------------------------------------------------------- /src/qtweetplace.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include "qtweetplace.h" 19 | 20 | QTweetPlace::QTweetPlace() 21 | { 22 | } 23 | 24 | void QTweetPlace::setName(const QString &name) 25 | { 26 | m_name = name; 27 | } 28 | 29 | QString QTweetPlace::name() const 30 | { 31 | return m_name; 32 | } 33 | 34 | void QTweetPlace::setCountry(const QString &country) 35 | { 36 | m_country = country; 37 | } 38 | 39 | QString QTweetPlace::country() const 40 | { 41 | return m_country; 42 | } 43 | 44 | void QTweetPlace::setCountryCode(const QString &code) 45 | { 46 | m_countryCode = code; 47 | } 48 | 49 | QString QTweetPlace::countryCode() const 50 | { 51 | return m_countryCode; 52 | } 53 | 54 | void QTweetPlace::setID(const QString &id) 55 | { 56 | m_id = id; 57 | } 58 | 59 | QString QTweetPlace::id() const 60 | { 61 | return m_id; 62 | } 63 | 64 | void QTweetPlace::setBoundingBox(const QTweetGeoBoundingBox &box) 65 | { 66 | m_boundingBox = box; 67 | } 68 | 69 | QTweetGeoBoundingBox QTweetPlace::boundingBox() const 70 | { 71 | return m_boundingBox; 72 | } 73 | 74 | void QTweetPlace::setContainedWithin(const QList &places) 75 | { 76 | m_containedWithin = places; 77 | } 78 | 79 | QList QTweetPlace::containedWithin() const 80 | { 81 | return m_containedWithin; 82 | } 83 | 84 | void QTweetPlace::setFullName(const QString &name) 85 | { 86 | m_fullName = name; 87 | } 88 | 89 | QString QTweetPlace::fullName() const 90 | { 91 | return m_fullName; 92 | } 93 | 94 | void QTweetPlace::setType(Type type) 95 | { 96 | m_type = type; 97 | } 98 | 99 | QTweetPlace::Type QTweetPlace::type() const 100 | { 101 | return m_type; 102 | } 103 | -------------------------------------------------------------------------------- /src/qtweetblocksblockingids.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include "qtweetblocksblockingids.h" 19 | #include 20 | #include 21 | #include 22 | #include "json/qjsondocument.h" 23 | #include "json/qjsonarray.h" 24 | 25 | /** 26 | * Constructor 27 | */ 28 | QTweetBlocksBlockingIDs::QTweetBlocksBlockingIDs(QObject *parent) : 29 | QTweetNetBase(parent) 30 | { 31 | } 32 | 33 | /** 34 | * Constructor 35 | * @param oauthTwitter OAuthTwitter object 36 | * @param parent parent QObject 37 | */ 38 | QTweetBlocksBlockingIDs::QTweetBlocksBlockingIDs(OAuthTwitter *oauthTwitter, QObject *parent) : 39 | QTweetNetBase(oauthTwitter, parent) 40 | { 41 | } 42 | 43 | /** 44 | * Gets the user ids which user is blocking 45 | */ 46 | void QTweetBlocksBlockingIDs::getIDs() 47 | { 48 | if (!isAuthenticationEnabled()) { 49 | qCritical("Needs authentication to be enabled"); 50 | return; 51 | } 52 | 53 | QUrl url("http://api.twitter.com/1/blocks/blocking/ids.json"); 54 | 55 | QNetworkRequest req(url); 56 | 57 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 58 | req.setRawHeader(AUTH_HEADER, oauthHeader); 59 | 60 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 61 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 62 | } 63 | 64 | void QTweetBlocksBlockingIDs::parseJsonFinished(const QJsonDocument &jsonDoc) 65 | { 66 | if (jsonDoc.isArray()) { 67 | QList useridlist; 68 | 69 | QJsonArray varJsonArray = jsonDoc.array(); 70 | 71 | for (int i = 0; i < varJsonArray.size(); ++i) 72 | useridlist.append(static_cast(varJsonArray[i].toDouble())); 73 | 74 | emit finishedGettingIDs(useridlist); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/qtweetlistaddmember.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetlistaddmember.h" 22 | #include "qtweetlist.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonobject.h" 26 | 27 | QTweetListAddMember::QTweetListAddMember(QObject *parent) : 28 | QTweetNetBase(parent) 29 | { 30 | } 31 | 32 | QTweetListAddMember::QTweetListAddMember(OAuthTwitter *oauthTwitter, QObject *parent) : 33 | QTweetNetBase(oauthTwitter, parent) 34 | { 35 | } 36 | 37 | /** 38 | * @param user user id (owner of the list) 39 | * @param list list id 40 | * @param memberid user id of the list member 41 | */ 42 | void QTweetListAddMember::add(qint64 user, qint64 list, qint64 memberid) 43 | { 44 | if (!isAuthenticationEnabled()) { 45 | qCritical("Needs authentication to be enabled"); 46 | return; 47 | } 48 | 49 | QUrl url(QString("http://api.twitter.com/1/%1/%2/members.json").arg(user).arg(list)); 50 | 51 | url.addQueryItem("id", QString::number(memberid)); 52 | 53 | QNetworkRequest req(url); 54 | 55 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::POST); 56 | req.setRawHeader(AUTH_HEADER, oauthHeader); 57 | req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); 58 | 59 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, QByteArray()); 60 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 61 | } 62 | 63 | void QTweetListAddMember::parseJsonFinished(const QJsonDocument &jsonDoc) 64 | { 65 | if (jsonDoc.isObject()) { 66 | QTweetList list = QTweetConvert::jsonObjectToTweetList(jsonDoc.object()); 67 | 68 | emit parsedList(list); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/oauth.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef OAUTH_H 19 | #define OAUTH_H 20 | 21 | #include 22 | #include 23 | #include "qtweetlib_global.h" 24 | 25 | class QByteArray; 26 | 27 | /** 28 | * Base OAuth class 29 | */ 30 | class QTWEETLIBSHARED_EXPORT OAuth : public QObject 31 | { 32 | Q_OBJECT 33 | Q_ENUMS(HttpMethod) 34 | Q_PROPERTY(QByteArray oauthToken READ oauthToken WRITE setOAuthToken) 35 | Q_PROPERTY(QByteArray oauthTokenSecret READ oauthTokenSecret WRITE setOAuthTokenSecret) 36 | Q_PROPERTY(QByteArray consumerKey READ consumerKey WRITE setConsumerKey) 37 | Q_PROPERTY(QByteArray consumerSecret READ consumerSecret WRITE setConsumerSecret) 38 | 39 | public: 40 | OAuth(QObject *parent = 0); 41 | OAuth(const QByteArray& consumerKey, const QByteArray& consumerSecret, QObject *parent = 0); 42 | 43 | enum HttpMethod {GET, POST, PUT, DELETE}; 44 | 45 | void parseTokens(const QByteArray& response); 46 | QByteArray generateAuthorizationHeader(const QUrl& url, HttpMethod method); 47 | void setOAuthToken(const QByteArray& token); 48 | void setOAuthTokenSecret(const QByteArray& tokenSecret); 49 | void setConsumerKey(const QByteArray& key); 50 | void setConsumerSecret(const QByteArray& secret); 51 | void clearTokens(); 52 | QByteArray oauthToken() const; 53 | QByteArray oauthTokenSecret() const; 54 | QByteArray consumerKey() const; 55 | QByteArray consumerSecret() const; 56 | 57 | private: 58 | QByteArray generateSignatureHMACSHA1(const QByteArray& signatureBase); 59 | QByteArray generateSignatureBase(const QUrl& url, HttpMethod method, const QByteArray& timestamp, const QByteArray& nonce); 60 | 61 | QByteArray m_oauthToken; 62 | QByteArray m_oauthTokenSecret; 63 | QByteArray m_oauthConsumerSecret; 64 | QByteArray m_oauthConsumerKey; 65 | }; 66 | 67 | #endif //OAUTH_H 68 | -------------------------------------------------------------------------------- /src/qtweetstatusshow.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETSTATUSSHOW_H 19 | #define QTWEETSTATUSSHOW_H 20 | 21 | #include "qtweetnetbase.h" 22 | 23 | /** 24 | * Class for fetching single tweet 25 | */ 26 | class QTWEETLIBSHARED_EXPORT QTweetStatusShow : public QTweetNetBase 27 | { 28 | Q_OBJECT 29 | Q_PROPERTY(qint64 tweetid READ tweetid WRITE setTweetid) 30 | Q_PROPERTY(bool trimUser READ isTrimUser WRITE setTrimUser) 31 | Q_PROPERTY(bool includeMyRetweet READ includeMyRetweet WRITE setIncludeMyRetweet) 32 | Q_PROPERTY(bool includeEntities READ includeEntities WRITE setIncludeEntities) 33 | 34 | public: 35 | QTweetStatusShow(QObject *parent = 0); 36 | QTweetStatusShow(OAuthTwitter *oauthTwitter, QObject *parent = 0); 37 | void fetch(qint64 id, 38 | bool trimUser = false, 39 | bool includeMyRetweet = false, 40 | bool includeEntities = false); 41 | void get(); 42 | 43 | qint64 tweetid() const { return m_tweetid; } 44 | void setTweetid(qint64 id) { m_tweetid = id; } 45 | 46 | void setTrimUser(bool trimUser) { m_trimUser = trimUser; } 47 | bool isTrimUser() const { return m_trimUser; } 48 | 49 | void setIncludeMyRetweet(bool includeMyRetweet) { m_includeMyRetweet = includeMyRetweet; } 50 | bool includeMyRetweet() const { return m_includeMyRetweet; } 51 | 52 | void setIncludeEntities(bool includeEntities) { m_includeEntities = includeEntities; } 53 | bool includeEntities() const { return m_includeEntities; } 54 | 55 | signals: 56 | /** Emits specified tweet */ 57 | void parsedStatus(const QTweetStatus& status); 58 | 59 | protected slots: 60 | void parseJsonFinished(const QJsonDocument &jsonDoc); 61 | 62 | private: 63 | // ### TODO: Use pimpl 64 | qint64 m_tweetid; 65 | bool m_trimUser; 66 | bool m_includeMyRetweet; 67 | bool m_includeEntities; 68 | }; 69 | 70 | #endif // QTWEETSTATUSSHOW_H 71 | -------------------------------------------------------------------------------- /src/json/qjsonwriter_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/ 5 | ** 6 | ** This file is part of the QtCore module of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** GNU Lesser General Public License Usage 10 | ** This file may be used under the terms of the GNU Lesser General Public 11 | ** License version 2.1 as published by the Free Software Foundation and 12 | ** appearing in the file LICENSE.LGPL included in the packaging of this 13 | ** file. Please review the following information to ensure the GNU Lesser 14 | ** General Public License version 2.1 requirements will be met: 15 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 16 | ** 17 | ** In addition, as a special exception, Nokia gives you certain additional 18 | ** rights. These rights are described in the Nokia Qt LGPL Exception 19 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 20 | ** 21 | ** GNU General Public License Usage 22 | ** Alternatively, this file may be used under the terms of the GNU General 23 | ** Public License version 3.0 as published by the Free Software Foundation 24 | ** and appearing in the file LICENSE.GPL included in the packaging of this 25 | ** file. Please review the following information to ensure the GNU General 26 | ** Public License version 3.0 requirements will be met: 27 | ** http://www.gnu.org/copyleft/gpl.html. 28 | ** 29 | ** Other Usage 30 | ** Alternatively, this file may be used in accordance with the terms and 31 | ** conditions contained in a signed written agreement between you and Nokia. 32 | ** 33 | ** 34 | ** 35 | ** 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef QJSONWRITER_P_H 43 | #define QJSONWRITER_P_H 44 | 45 | // 46 | // W A R N I N G 47 | // ------------- 48 | // 49 | // This file is not part of the Qt API. It exists purely as an 50 | // implementation detail. This header file may change from version to 51 | // version without notice, or even be removed. 52 | // 53 | // We mean it. 54 | // 55 | #include "qjsonvalue.h" 56 | 57 | QT_BEGIN_NAMESPACE 58 | 59 | namespace QJsonPrivate 60 | { 61 | 62 | class Writer 63 | { 64 | public: 65 | static void objectToJson(const QJsonPrivate::Object *o, QByteArray &json, int indent, bool compact = false); 66 | static void arrayToJson(const QJsonPrivate::Array *a, QByteArray &json, int indent, bool compact = false); 67 | }; 68 | 69 | } 70 | 71 | QT_END_NAMESPACE 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/qtweetstatusretweets.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include "json/qjsondocument.h" 21 | #include "json/qjsonarray.h" 22 | #include "qtweetstatusretweets.h" 23 | #include "qtweetstatus.h" 24 | #include "qtweetconvert.h" 25 | 26 | QTweetStatusRetweets::QTweetStatusRetweets(QObject *parent) : 27 | QTweetNetBase(parent), 28 | m_tweetid(0), 29 | m_count(0), 30 | m_trimUser(false) 31 | { 32 | } 33 | 34 | QTweetStatusRetweets::QTweetStatusRetweets(OAuthTwitter *oauthTwitter, QObject *parent) : 35 | QTweetNetBase(oauthTwitter, parent), 36 | m_tweetid(0), 37 | m_count(0), 38 | m_trimUser(false) 39 | { 40 | } 41 | 42 | /** 43 | * Start fetching 44 | * @param id tweet ID 45 | * @param count numbers of retweets to fetch 46 | */ 47 | void QTweetStatusRetweets::fetch(qint64 id, int count, bool trimUser) 48 | { 49 | QString urlString = QString("https://api.twitter.com/1.1/statuses/retweets/%1.json").arg(id); 50 | QUrl url(urlString); 51 | 52 | if (count != 0) 53 | url.addQueryItem("count", QString::number(count)); 54 | 55 | if (trimUser) 56 | url.addQueryItem("trim_user", "true"); 57 | 58 | QNetworkRequest req(url); 59 | 60 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 61 | req.setRawHeader(AUTH_HEADER, oauthHeader); 62 | 63 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 64 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 65 | } 66 | 67 | void QTweetStatusRetweets::get() 68 | { 69 | fetch(m_tweetid, m_count, m_trimUser); 70 | } 71 | 72 | void QTweetStatusRetweets::parseJsonFinished(const QJsonDocument &jsonDoc) 73 | { 74 | if (jsonDoc.isArray()) { 75 | QList statuses = QTweetConvert::jsonArrayToStatusList(jsonDoc.array()); 76 | 77 | emit parsedStatuses(statuses); 78 | } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /src/qtweetdirectmessagesshow.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include "qtweetdirectmessagesshow.h" 19 | #include 20 | #include 21 | #include 22 | #include "qtweetdmstatus.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonarray.h" 26 | 27 | /** 28 | * Constructor 29 | * @param parent 30 | */ 31 | QTweetDirectMessagesShow::QTweetDirectMessagesShow(QObject *parent) : 32 | QTweetNetBase(parent) 33 | { 34 | } 35 | 36 | /** 37 | * Constructor 38 | * 39 | * @param oauthTwitter OAuthTwitter object 40 | * @param parent parent QObject 41 | */ 42 | QTweetDirectMessagesShow::QTweetDirectMessagesShow(OAuthTwitter *oauthTwitter, QObject *parent) : 43 | QTweetNetBase(oauthTwitter, parent) 44 | { 45 | } 46 | 47 | /** 48 | * Starts fetching the direct message 49 | * 50 | * @param id id of the direct message to fetch 51 | */ 52 | void QTweetDirectMessagesShow::fetch(qint64 id) 53 | { 54 | if (!isAuthenticationEnabled()) { 55 | qCritical("Need authentication to be enabled"); 56 | return; 57 | } 58 | 59 | QUrl url("https://api.twitter.com/1.1/direct_messages/show.json"); 60 | url.addQueryItem("id", QString::number(id)); 61 | 62 | QNetworkRequest req(url); 63 | 64 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 65 | req.setRawHeader(AUTH_HEADER, oauthHeader); 66 | 67 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 68 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 69 | } 70 | 71 | void QTweetDirectMessagesShow::parseJsonFinished(const QJsonDocument &jsonDocument) 72 | { 73 | if (jsonDocument.isArray()) { 74 | QList directMessages = QTweetConvert::jsonArrayToDirectMessagesList(jsonDocument.array()); 75 | 76 | if (directMessages.size()) 77 | emit parsedDirectMessage(directMessages.at(0)); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/qtweetaccountratelimitstatus.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetaccountratelimitstatus.h" 22 | #include "json/qjsondocument.h" 23 | #include "json/qjsonobject.h" 24 | 25 | /** 26 | * Constructor 27 | */ 28 | QTweetAccountRateLimitStatus::QTweetAccountRateLimitStatus(QObject *parent) : 29 | QTweetNetBase(parent) 30 | { 31 | } 32 | 33 | /** 34 | * Constructor 35 | * @param oauthTwitter OAuthTwitter object 36 | * @param parent parent QObject 37 | */ 38 | QTweetAccountRateLimitStatus::QTweetAccountRateLimitStatus(OAuthTwitter *oauthTwitter, QObject *parent) : 39 | QTweetNetBase(oauthTwitter, parent) 40 | { 41 | } 42 | 43 | /** 44 | * Starts checking rate limit status 45 | * @remarks Should be emiting rateLimitInfo signal after finishing 46 | */ 47 | void QTweetAccountRateLimitStatus::check() 48 | { 49 | QUrl url("http://api.twitter.com/1/account/rate_limit_status.json"); 50 | 51 | QNetworkRequest req(url); 52 | 53 | if (isAuthenticationEnabled()) { 54 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 55 | req.setRawHeader(AUTH_HEADER, oauthHeader); 56 | } 57 | 58 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 59 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 60 | } 61 | 62 | void QTweetAccountRateLimitStatus::parseJsonFinished(const QJsonDocument &jsonDoc) 63 | { 64 | if (jsonDoc.isObject()) { 65 | QJsonObject respJsonObject = jsonDoc.object(); 66 | 67 | int remainingHits = static_cast(respJsonObject["remaining_hits"].toDouble()); 68 | int resetTime = static_cast(respJsonObject["reset_time_in_seconds"].toDouble()); 69 | int hourlyLimit = static_cast(respJsonObject["hourly_limit"].toDouble()); 70 | 71 | emit rateLimitInfo(remainingHits, resetTime, hourlyLimit); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/qtweetaccountverifycredentials.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetaccountverifycredentials.h" 22 | #include "qtweetuser.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonobject.h" 26 | 27 | /** 28 | * Constructor 29 | */ 30 | QTweetAccountVerifyCredentials::QTweetAccountVerifyCredentials(QObject *parent) : 31 | QTweetNetBase(parent) 32 | { 33 | } 34 | 35 | /** 36 | * Constructor 37 | * @param oauthTwitter OAuthTwitter object 38 | * @param parent parent QObject 39 | */ 40 | QTweetAccountVerifyCredentials::QTweetAccountVerifyCredentials(OAuthTwitter *oauthTwitter, QObject *parent) : 41 | QTweetNetBase(oauthTwitter, parent) 42 | { 43 | } 44 | 45 | /** 46 | * Verifies credentials 47 | * @param includeEntities when set to either true, t or 1, each tweet will include a node called "entities,". 48 | */ 49 | void QTweetAccountVerifyCredentials::verify(bool includeEntities) 50 | { 51 | if (!isAuthenticationEnabled()) { 52 | qCritical("Needs authentication to be enabled"); 53 | return; 54 | } 55 | 56 | QUrl url("https://api.twitter.com/1/account/verify_credentials.json"); 57 | 58 | if (includeEntities) 59 | url.addQueryItem("include_entities", "true"); 60 | 61 | QNetworkRequest req(url); 62 | 63 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 64 | req.setRawHeader(AUTH_HEADER, oauthHeader); 65 | 66 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 67 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 68 | } 69 | 70 | void QTweetAccountVerifyCredentials::parseJsonFinished(const QJsonDocument &jsonDoc) 71 | { 72 | if (jsonDoc.isObject()) { 73 | QTweetUser user = QTweetConvert::jsonObjectToUser(jsonDoc.object()); 74 | 75 | emit parsedUser(user); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/qtweetentityurl.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include "qtweetentityurl.h" 19 | #include 20 | #include 21 | 22 | class QTweetEntityUrlData : public QSharedData 23 | { 24 | 25 | public: 26 | QTweetEntityUrlData() : lower_index(0), higher_index(0) { } 27 | 28 | QString displayUrl; 29 | QString url; 30 | QString expandedUrl; 31 | int lower_index; 32 | int higher_index; 33 | }; 34 | 35 | QTweetEntityUrl::QTweetEntityUrl() 36 | : data(new QTweetEntityUrlData) 37 | { 38 | } 39 | 40 | QTweetEntityUrl::QTweetEntityUrl(const QTweetEntityUrl &rhs) 41 | : data(rhs.data) 42 | { 43 | } 44 | 45 | QTweetEntityUrl &QTweetEntityUrl::operator=(const QTweetEntityUrl &rhs) 46 | { 47 | if (this != &rhs) 48 | data.operator=(rhs.data); 49 | return *this; 50 | } 51 | 52 | QTweetEntityUrl::~QTweetEntityUrl() 53 | { 54 | } 55 | 56 | void QTweetEntityUrl::setDisplayUrl(const QString &url) 57 | { 58 | data->displayUrl = url; 59 | } 60 | 61 | QString QTweetEntityUrl::displayUrl() const 62 | { 63 | return data->displayUrl; 64 | } 65 | 66 | void QTweetEntityUrl::setUrl(const QString &url) 67 | { 68 | data->url = url; 69 | } 70 | 71 | QString QTweetEntityUrl::url() const 72 | { 73 | return data->url; 74 | } 75 | 76 | void QTweetEntityUrl::setExpandedUrl(const QString &url) 77 | { 78 | data->url = url; 79 | } 80 | 81 | QString QTweetEntityUrl::expandedUrl() const 82 | { 83 | return data->url; 84 | } 85 | 86 | void QTweetEntityUrl::setLowerIndex(int index) 87 | { 88 | data->lower_index = index; 89 | } 90 | 91 | int QTweetEntityUrl::lowerIndex() const 92 | { 93 | return data->lower_index; 94 | } 95 | 96 | void QTweetEntityUrl::setHigherIndex(int index) 97 | { 98 | data->higher_index = index; 99 | } 100 | 101 | int QTweetEntityUrl::higherIndex() const 102 | { 103 | return data->higher_index; 104 | } 105 | -------------------------------------------------------------------------------- /src/qtweetstatusretweetedby.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include "qtweetstatusretweetedby.h" 19 | #include 20 | #include 21 | #include 22 | #include "qtweetuser.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonarray.h" 26 | 27 | QTweetStatusRetweetedBy::QTweetStatusRetweetedBy(QObject *parent) : 28 | QTweetNetBase(parent), 29 | m_tweetid(0), 30 | m_count(0), 31 | m_page(0) 32 | { 33 | } 34 | 35 | QTweetStatusRetweetedBy::QTweetStatusRetweetedBy(OAuthTwitter *oauthTwitter, QObject *parent) : 36 | QTweetNetBase(oauthTwitter, parent), 37 | m_tweetid(0), 38 | m_count(0), 39 | m_page(0) 40 | { 41 | } 42 | 43 | void QTweetStatusRetweetedBy::fetch(qint64 tweetid, int count, int page) 44 | { 45 | if (!isAuthenticationEnabled()) { 46 | qCritical("Needs authentication to be enabled"); 47 | return; 48 | } 49 | 50 | QString urlString = QString("http://api.twitter.com/1/statuses/%1/retweeted_by.json").arg(tweetid); 51 | QUrl url(urlString); 52 | 53 | if (count != 0) 54 | url.addQueryItem("count", QString::number(count)); 55 | 56 | if (page != 0) 57 | url.addQueryItem("page", QString::number(page)); 58 | 59 | QNetworkRequest req(url); 60 | 61 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 62 | req.setRawHeader(AUTH_HEADER, oauthHeader); 63 | 64 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 65 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 66 | } 67 | 68 | void QTweetStatusRetweetedBy::get() 69 | { 70 | fetch(m_tweetid, m_count, m_page); 71 | } 72 | 73 | void QTweetStatusRetweetedBy::parseJsonFinished(const QJsonDocument &jsonDoc) 74 | { 75 | if (jsonDoc.isArray()) { 76 | QList users = QTweetConvert::jsonArrayToUserInfoList(jsonDoc.array()); 77 | 78 | emit parsedUsers(users); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/qtweetfavoritesdestroy.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetfavoritesdestroy.h" 22 | #include "qtweetstatus.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonobject.h" 26 | 27 | /** 28 | * Constructor 29 | */ 30 | QTweetFavoritesDestroy::QTweetFavoritesDestroy(QObject *parent) : 31 | QTweetNetBase(parent) 32 | { 33 | } 34 | 35 | /** 36 | * Constructor 37 | * @param oauthTwitter OAuthTwitter object 38 | * @param parent parent QObject 39 | */ 40 | QTweetFavoritesDestroy::QTweetFavoritesDestroy(OAuthTwitter *oauthTwitter, QObject *parent) : 41 | QTweetNetBase(oauthTwitter, parent) 42 | { 43 | } 44 | 45 | /** 46 | * Starts unfavoriting status 47 | * @param statusid ID of the desired status 48 | * @param includeEntities When set to true, each tweet will include a node called "entities," 49 | */ 50 | void QTweetFavoritesDestroy::unfavorite(qint64 statusid, bool includeEntities) 51 | { 52 | if (!isAuthenticationEnabled()) { 53 | qCritical("Needs authentication to be enabled"); 54 | return; 55 | } 56 | 57 | QUrl url(QString("http://api.twitter.com/1/favorites/destroy/%1.json").arg(statusid)); 58 | 59 | if (includeEntities) 60 | url.addQueryItem("include_entities", "true"); 61 | 62 | QNetworkRequest req(url); 63 | 64 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::DELETE); 65 | req.setRawHeader(AUTH_HEADER, oauthHeader); 66 | 67 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->deleteResource(req); 68 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 69 | } 70 | 71 | void QTweetFavoritesDestroy::parseJsonFinished(const QJsonDocument &jsonDoc) 72 | { 73 | if (jsonDoc.isObject()) { 74 | QTweetStatus status = QTweetConvert::jsonObjectToStatus(jsonDoc.object()); 75 | 76 | emit parsedStatus(status); 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /src/qtweetblocksblocking.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include "qtweetblocksblocking.h" 19 | #include 20 | #include 21 | #include 22 | #include "qtweetuser.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonarray.h" 26 | 27 | /** 28 | * Constructor 29 | */ 30 | QTweetBlocksBlocking::QTweetBlocksBlocking(QObject *parent) : 31 | QTweetNetBase(parent) 32 | { 33 | } 34 | 35 | /** 36 | * Constructor 37 | * @param oauthTwitter OAuthTwitter object 38 | * @param parent parent QObject 39 | */ 40 | QTweetBlocksBlocking::QTweetBlocksBlocking(OAuthTwitter *oauthTwitter, QObject *parent) : 41 | QTweetNetBase(oauthTwitter, parent) 42 | { 43 | } 44 | 45 | /** 46 | * Gets the list of blocks 47 | * @param page specifies the page of results to retrieve 48 | * @param includeEntities When set to true, each tweet will include a node called "entities" 49 | */ 50 | void QTweetBlocksBlocking::getBlocks(int page, bool includeEntities) 51 | { 52 | if (!isAuthenticationEnabled()) { 53 | qCritical("Needs authentication to be enabled"); 54 | return; 55 | } 56 | 57 | QUrl url("http://api.twitter.com/1/blocks/blocking.json"); 58 | 59 | if (page) 60 | url.addQueryItem("page", QString::number(page)); 61 | 62 | if (includeEntities) 63 | url.addQueryItem("include_entities", "true"); 64 | 65 | QNetworkRequest req(url); 66 | 67 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 68 | req.setRawHeader(AUTH_HEADER, oauthHeader); 69 | 70 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 71 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 72 | } 73 | 74 | void QTweetBlocksBlocking::parseJsonFinished(const QJsonDocument &jsonDoc) 75 | { 76 | if (jsonDoc.isArray()) { 77 | QList userlist = QTweetConvert::jsonArrayToUserInfoList(jsonDoc.array()); 78 | 79 | emit finishedGettingBlocks(userlist); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/qtweetconvert.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #ifndef QTWEETCONVERT_H 19 | #define QTWEETCONVERT_H 20 | 21 | #include 22 | 23 | class QTweetStatus; 24 | class QTweetUser; 25 | class QTweetDMStatus; 26 | class QTweetList; 27 | class QTweetSearchResult; 28 | class QTweetSearchPageResults; 29 | class QTweetPlace; 30 | class QTweetEntityUrl; 31 | class QTweetEntityHashtag; 32 | class QTweetEntityUserMentions; 33 | class QTweetEntityMedia; 34 | 35 | class QJsonArray; 36 | class QJsonObject; 37 | 38 | /** 39 | * Contains static converting functions 40 | */ 41 | class QTweetConvert 42 | { 43 | public: 44 | static QList jsonArrayToStatusList(const QJsonArray& jsonArray); 45 | static QTweetStatus jsonObjectToStatus(const QJsonObject& jsonObject); 46 | static QTweetUser jsonObjectToUser(const QJsonObject& jsonObject); 47 | static QList jsonArrayToDirectMessagesList(const QJsonArray& jsonArray); 48 | static QTweetDMStatus jsonObjectToDirectMessage(const QJsonObject& jsonObject); 49 | static QTweetList jsonObjectToTweetList(const QJsonObject& jsonObject); 50 | static QList jsonArrayToUserInfoList(const QJsonArray& jsonArray); 51 | static QList jsonArrayToTweetLists(const QJsonArray& jsonArray); 52 | static QTweetSearchResult jsonObjectToSearchResult(const QJsonObject& var); 53 | static QTweetSearchPageResults jsonObjectToSearchPageResults(const QJsonObject& jsonObject); 54 | static QTweetPlace jsonObjectToPlace(const QJsonObject& var); 55 | static QTweetPlace jsonObjectToPlaceRecursive(const QJsonObject& jsonObject); 56 | static QList jsonObjectToPlaceList(const QJsonObject& jsonObject); 57 | static QTweetEntityUrl jsonObjectToEntityUrl(const QJsonObject& jsonObject); 58 | static QTweetEntityHashtag jsonObjectToEntityHashtag(const QJsonObject &jsonObject); 59 | static QTweetEntityUserMentions jsonObjectToEntityUserMentions(const QJsonObject& jsonObject); 60 | static QTweetEntityMedia jsonObjectToEntityMedia(const QJsonObject& jsonObject); 61 | }; 62 | 63 | #endif // QTWEETCONVERT_H 64 | -------------------------------------------------------------------------------- /src/qtweetstatusretweetbyid.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include "qtweetstatusretweetbyid.h" 19 | #include 20 | #include 21 | #include 22 | #include "qtweetconvert.h" 23 | #include "json/qjsondocument.h" 24 | #include "json/qjsonarray.h" 25 | 26 | QTweetStatusRetweetByID::QTweetStatusRetweetByID(QObject *parent) : 27 | QTweetNetBase(parent), 28 | m_tweetid(0), 29 | m_count(0), 30 | m_page(0) 31 | { 32 | } 33 | 34 | QTweetStatusRetweetByID::QTweetStatusRetweetByID(OAuthTwitter *oauthTwitter, QObject *parent) : 35 | QTweetNetBase(oauthTwitter, parent), 36 | m_tweetid(0), 37 | m_count(0), 38 | m_page(0) 39 | { 40 | } 41 | 42 | void QTweetStatusRetweetByID::fetch(qint64 tweetid, int count, int page) 43 | { 44 | if (!isAuthenticationEnabled()) { 45 | qCritical("Needs authentication to be enabled"); 46 | return; 47 | } 48 | 49 | QString urlString = QString("https://api.twitter.com/1/statuses/%1/retweeted_by/ids.json").arg(tweetid); 50 | QUrl url(urlString); 51 | 52 | if (count != 0) 53 | url.addQueryItem("count", QString::number(count)); 54 | 55 | if (page != 0) 56 | url.addQueryItem("page", QString::number(page)); 57 | 58 | QNetworkRequest req(url); 59 | 60 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 61 | req.setRawHeader(AUTH_HEADER, oauthHeader); 62 | 63 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 64 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 65 | } 66 | 67 | void QTweetStatusRetweetByID::get() 68 | { 69 | fetch(m_tweetid, m_count, m_page); 70 | } 71 | 72 | void QTweetStatusRetweetByID::parseJsonFinished(const QJsonDocument &jsonDoc) 73 | { 74 | if (jsonDoc.isArray()) { 75 | QList userid; 76 | QJsonArray idJsonArray = jsonDoc.array(); 77 | 78 | for (int i = 0; i < idJsonArray.size(); ++i) 79 | userid.append(static_cast(idJsonArray[i].toDouble())); 80 | 81 | emit parsedUsersID(userid); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/qtweetfavoritescreate.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetfavoritescreate.h" 22 | #include "qtweetstatus.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonobject.h" 26 | 27 | /** 28 | * Constructor 29 | */ 30 | QTweetFavoritesCreate::QTweetFavoritesCreate(QObject *parent) : 31 | QTweetNetBase(parent) 32 | { 33 | } 34 | 35 | /** 36 | * Constructor 37 | * @param oauthTwitter OAuthTwitter object 38 | * @param parent parent QObject 39 | */ 40 | QTweetFavoritesCreate::QTweetFavoritesCreate(OAuthTwitter *oauthTwitter, QObject *parent) : 41 | QTweetNetBase(oauthTwitter, parent) 42 | { 43 | } 44 | 45 | /** 46 | * Starts creating favorited statues 47 | * @param statusid ID of the desired status to be favorited. 48 | * @param includeEntities When set to true, each tweet will include a node called "entities,". 49 | */ 50 | void QTweetFavoritesCreate::create(qint64 statusid, bool includeEntities) 51 | { 52 | if (!isAuthenticationEnabled()) { 53 | qCritical("Needs authentication to be enabled"); 54 | return; 55 | } 56 | 57 | QUrl url(QString("http://api.twitter.com/1.1/favorites/create.json")); 58 | url.addQueryItem("id", QString::number(statusid)); 59 | 60 | if (includeEntities) 61 | url.addQueryItem("include_entities", "true"); 62 | 63 | QNetworkRequest req(url); 64 | 65 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::POST); 66 | req.setRawHeader(AUTH_HEADER, oauthHeader); 67 | req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); 68 | 69 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, QByteArray()); 70 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 71 | } 72 | 73 | void QTweetFavoritesCreate::parseJsonFinished(const QJsonDocument &jsonDoc) 74 | { 75 | if (jsonDoc.isObject()) { 76 | QTweetStatus status = QTweetConvert::jsonObjectToStatus(jsonDoc.object()); 77 | 78 | emit parsedStatus(status); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/qtweetstatusdestroy.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetstatusdestroy.h" 22 | #include "qtweetstatus.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonobject.h" 26 | 27 | QTweetStatusDestroy::QTweetStatusDestroy(QObject *parent) : 28 | QTweetNetBase(parent) 29 | { 30 | } 31 | 32 | QTweetStatusDestroy::QTweetStatusDestroy(OAuthTwitter *oauthTwitter, QObject *parent) : 33 | QTweetNetBase(oauthTwitter, parent) 34 | { 35 | } 36 | 37 | /** 38 | * Destroys tweet with id 39 | * @param id tweet ID 40 | * @param trimUser trims users info 41 | * @param includeEntities true to include node entities in response 42 | */ 43 | void QTweetStatusDestroy::destroy(qint64 id, 44 | bool trimUser) 45 | { 46 | if (!isAuthenticationEnabled()) { 47 | qCritical("Needs authentication to be enabled"); 48 | return; 49 | } 50 | 51 | QUrl url("https://api.twitter.com/1.1/statuses/destroy.json"); 52 | 53 | QUrl urlQuery(url); 54 | 55 | urlQuery.addQueryItem("id", QString::number(id)); 56 | 57 | if (trimUser) 58 | urlQuery.addQueryItem("trim_user", "true"); 59 | 60 | QNetworkRequest req(url); 61 | 62 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST); 63 | req.setRawHeader(AUTH_HEADER, oauthHeader); 64 | req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); 65 | 66 | QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath); 67 | postBody.remove(0, 1); 68 | 69 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody); 70 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 71 | } 72 | 73 | void QTweetStatusDestroy::parseJsonFinished(const QJsonDocument &jsonDoc) 74 | { 75 | if (jsonDoc.isObject()) { 76 | QTweetStatus status = QTweetConvert::jsonObjectToStatus(jsonDoc.object()); 77 | 78 | emit deletedStatus(status); 79 | } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/qtweetstatusretweet.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetstatusretweet.h" 22 | #include "qtweetstatus.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonobject.h" 26 | 27 | QTweetStatusRetweet::QTweetStatusRetweet(QObject *parent) : 28 | QTweetNetBase(parent) 29 | { 30 | } 31 | 32 | QTweetStatusRetweet::QTweetStatusRetweet(OAuthTwitter *oauthTwitter, QObject *parent) : 33 | QTweetNetBase(oauthTwitter, parent) 34 | { 35 | } 36 | 37 | /** 38 | * Retweets the tweet 39 | * @param id tweet ID to retweet 40 | * @param trimUser trims user info in response 41 | * @param includeEntities true to include node entities in response 42 | */ 43 | void QTweetStatusRetweet::retweet(qint64 id, 44 | bool trimUser, 45 | bool includeEntities) 46 | { 47 | QUrl url(QString("https://api.twitter.com/1.1/statuses/retweet/%1.json").arg(id)); 48 | 49 | if (trimUser) 50 | url.addQueryItem("trim_user", "true"); 51 | 52 | if (includeEntities) 53 | url.addQueryItem("include_entities", "true"); 54 | 55 | QNetworkRequest req(url); 56 | req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); 57 | 58 | if (isAuthenticationEnabled()) { //Oh, Twitter API docs wrong? 59 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::POST); 60 | req.setRawHeader(AUTH_HEADER, oauthHeader); 61 | } 62 | 63 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, QByteArray()); 64 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 65 | } 66 | 67 | void QTweetStatusRetweet::retweet() 68 | { 69 | retweet(m_id, m_trimUser, m_includeEntities); 70 | } 71 | 72 | void QTweetStatusRetweet::parseJsonFinished(const QJsonDocument &jsonDoc) 73 | { 74 | if (jsonDoc.isObject()) { 75 | QTweetStatus status = QTweetConvert::jsonObjectToStatus(jsonDoc.object()); 76 | 77 | emit postedRetweet(status); 78 | } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /src/qtweetentityusermentions.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include "qtweetentityusermentions.h" 19 | #include 20 | #include 21 | 22 | class QTweetEntityUserMentionsData : public QSharedData 23 | { 24 | public: 25 | QTweetEntityUserMentionsData() : userid(0) {} 26 | 27 | QString screenName; 28 | QString name; 29 | qint64 userid; 30 | int lower_index; 31 | int higher_index; 32 | }; 33 | 34 | QTweetEntityUserMentions::QTweetEntityUserMentions() 35 | : data(new QTweetEntityUserMentionsData) 36 | { 37 | } 38 | 39 | QTweetEntityUserMentions::QTweetEntityUserMentions(const QTweetEntityUserMentions &rhs) 40 | : data(rhs.data) 41 | { 42 | } 43 | 44 | QTweetEntityUserMentions &QTweetEntityUserMentions::operator=(const QTweetEntityUserMentions &rhs) 45 | { 46 | if (this != &rhs) 47 | data.operator=(rhs.data); 48 | return *this; 49 | } 50 | 51 | QTweetEntityUserMentions::~QTweetEntityUserMentions() 52 | { 53 | } 54 | 55 | void QTweetEntityUserMentions::setScreenName(const QString &screenName) 56 | { 57 | data->screenName = screenName; 58 | } 59 | 60 | QString QTweetEntityUserMentions::screenName() const 61 | { 62 | return data->screenName; 63 | } 64 | 65 | void QTweetEntityUserMentions::setName(const QString &name) 66 | { 67 | data->name = name; 68 | } 69 | 70 | QString QTweetEntityUserMentions::name() const 71 | { 72 | return data->name; 73 | } 74 | 75 | void QTweetEntityUserMentions::setUserid(qint64 id) 76 | { 77 | data->userid = id; 78 | } 79 | 80 | qint64 QTweetEntityUserMentions::userid() const 81 | { 82 | return data->userid; 83 | } 84 | 85 | void QTweetEntityUserMentions::setLowerIndex(int index) 86 | { 87 | data->lower_index = index; 88 | } 89 | 90 | int QTweetEntityUserMentions::lowerIndex() const 91 | { 92 | return data->lower_index; 93 | } 94 | 95 | void QTweetEntityUserMentions::setHigherIndex(int index) 96 | { 97 | data->higher_index = index; 98 | } 99 | 100 | int QTweetEntityUserMentions::higherIndex() const 101 | { 102 | return data->higher_index; 103 | } 104 | -------------------------------------------------------------------------------- /src/qtweetstatusshow.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetstatusshow.h" 22 | #include "qtweetstatus.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonobject.h" 26 | 27 | QTweetStatusShow::QTweetStatusShow(QObject *parent) : 28 | QTweetNetBase(parent), 29 | m_tweetid(0), 30 | m_includeMyRetweet(false), 31 | m_includeEntities(false) 32 | { 33 | } 34 | 35 | QTweetStatusShow::QTweetStatusShow(OAuthTwitter *oauthTwitter, QObject *parent) : 36 | QTweetNetBase(oauthTwitter, parent), 37 | m_tweetid(0), 38 | m_includeMyRetweet(false), 39 | m_includeEntities(false) 40 | { 41 | } 42 | 43 | /** 44 | * Starts fetching 45 | * @param id tweet ID 46 | * @param trimUser set to true to trim user info in response 47 | * @param includeEntities set to true to include node entities in response 48 | */ 49 | void QTweetStatusShow::fetch(qint64 id, bool trimUser, bool includeMyRetweet, bool includeEntities) 50 | { 51 | QUrl url("https://api.twitter.com/1.1/statuses/show.json"); 52 | 53 | url.addQueryItem("id", QString::number(id)); 54 | 55 | if (trimUser) 56 | url.addQueryItem("trim_user", "true"); 57 | 58 | if (includeMyRetweet) 59 | url.addQueryItem("include_my_retweet", "true"); 60 | 61 | if (includeEntities) 62 | url.addQueryItem("include_entities", "true"); 63 | 64 | QNetworkRequest req(url); 65 | 66 | if (isAuthenticationEnabled()) { 67 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 68 | req.setRawHeader(AUTH_HEADER, oauthHeader); 69 | } 70 | 71 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 72 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 73 | } 74 | 75 | void QTweetStatusShow::get() 76 | { 77 | fetch(m_tweetid, m_trimUser, m_includeMyRetweet, m_includeEntities); 78 | } 79 | 80 | void QTweetStatusShow::parseJsonFinished(const QJsonDocument &jsonDoc) 81 | { 82 | if (jsonDoc.isObject()) { 83 | QTweetStatus status = QTweetConvert::jsonObjectToStatus(jsonDoc.object()); 84 | 85 | emit parsedStatus(status); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/qtweetfavorites.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetfavorites.h" 22 | #include "qtweetstatus.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonarray.h" 26 | 27 | /** 28 | * Constructor 29 | */ 30 | QTweetFavorites::QTweetFavorites(QObject *parent) : 31 | QTweetNetBase(parent) 32 | { 33 | } 34 | 35 | /** 36 | * Constructor 37 | * @param oauthTwitter OAuthTwitter object 38 | * @param parent parent QObject 39 | */ 40 | QTweetFavorites::QTweetFavorites(OAuthTwitter *oauthTwitter, QObject *parent) : 41 | QTweetNetBase(oauthTwitter, parent) 42 | { 43 | } 44 | 45 | /** 46 | * Starts fetching favorites 47 | * @param id the ID of the user for whom to request a list of favorite statuses. 0 for authenticated user 48 | * @param page Specifies the page of results to retrieve. 49 | * @param includeEntities When set to true, each tweet will include a node called "entities,". 50 | */ 51 | void QTweetFavorites::fetch(qint64 id, int page, bool includeEntities) 52 | { 53 | if (!isAuthenticationEnabled()) { 54 | qCritical("Needs authentication to be enabled"); 55 | return; 56 | } 57 | 58 | QUrl url; 59 | 60 | if (id) { 61 | url.setUrl(QString("http://api.twitter.com/1/favorites/%1.json").arg(id)); 62 | } else { 63 | url.setUrl("http://api.twitter.com/1/favorites.json"); 64 | } 65 | 66 | if (page) 67 | url.addQueryItem("page", QString::number(page)); 68 | 69 | if (includeEntities) 70 | url.addQueryItem("include_entities", "true"); 71 | 72 | QNetworkRequest req(url); 73 | 74 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 75 | req.setRawHeader(AUTH_HEADER, oauthHeader); 76 | 77 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 78 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 79 | } 80 | 81 | void QTweetFavorites::parseJsonFinished(const QJsonDocument &jsonDoc) 82 | { 83 | if (jsonDoc.isArray()) { 84 | QList statuses = QTweetConvert::jsonArrayToStatusList(jsonDoc.array()); 85 | 86 | emit parsedFavorites(statuses); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/qtweetusersearch.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 Antonie Jovanoski 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * Contact e-mail: Antonie Jovanoski 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "qtweetusersearch.h" 22 | #include "qtweetuser.h" 23 | #include "qtweetconvert.h" 24 | #include "json/qjsondocument.h" 25 | #include "json/qjsonarray.h" 26 | 27 | QTweetUserSearch::QTweetUserSearch(QObject *parent) : 28 | QTweetNetBase(parent) 29 | { 30 | } 31 | 32 | QTweetUserSearch::QTweetUserSearch(OAuthTwitter *oauthTwitter, QObject *parent) : 33 | QTweetNetBase(oauthTwitter, parent) 34 | { 35 | } 36 | 37 | /** 38 | * Starts a search 39 | * @param query the search query to run against people search 40 | * @param perPage the number of people per page to retrieve. Maxiumum of 20 allowed per page. 41 | * @param page specifies the page of results to retrieve 42 | * @param includeEntities when set to true each tweet will include a node called "entities". 43 | */ 44 | void QTweetUserSearch::search(const QString &query, 45 | int perPage, 46 | int page, 47 | bool includeEntities) 48 | { 49 | if (!isAuthenticationEnabled()) { 50 | qCritical("Needs authentication to be enabled"); 51 | return; 52 | } 53 | 54 | QUrl url("http://api.twitter.com/1/users/search.json"); 55 | 56 | url.addQueryItem("q", query); 57 | 58 | if (perPage) 59 | url.addQueryItem("per_page", QString::number(perPage)); 60 | 61 | if (page) 62 | url.addQueryItem("page", QString::number(page)); 63 | 64 | if (includeEntities) 65 | url.addQueryItem("include_entities", "true"); 66 | 67 | QNetworkRequest req(url); 68 | 69 | QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET); 70 | req.setRawHeader(AUTH_HEADER, oauthHeader); 71 | 72 | QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req); 73 | connect(reply, SIGNAL(finished()), this, SLOT(reply())); 74 | } 75 | 76 | void QTweetUserSearch::parseJsonFinished(const QJsonDocument &jsonDoc) 77 | { 78 | if (jsonDoc.isArray()) { 79 | QList userInfoList = QTweetConvert::jsonArrayToUserInfoList(jsonDoc.array()); 80 | 81 | emit parsedUserInfoList(userInfoList); 82 | } 83 | } 84 | 85 | --------------------------------------------------------------------------------