mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Merge branch 'master' of github.com:tomahawk-player/tomahawk
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ Makefile*
|
||||
moc_*
|
||||
*~
|
||||
/tomahawk
|
||||
thirdparty/qtweetlib/WARNING-twitter-api-keys
|
||||
|
5
README
5
README
@@ -94,6 +94,11 @@ Dependencies
|
||||
|
||||
To build the app:
|
||||
-----------------
|
||||
|
||||
For SIP-over-Twitter support, you must first register an application with Twitter and copy the file
|
||||
examples/twitter-api-keys.example to thirdparty/qtweetlib/WARNING-twitter-api-keys, substituting in
|
||||
your particular consumer key and secret.
|
||||
|
||||
$ mkdir build && cd build
|
||||
|
||||
Pick one of the following two choices. If uncertain pick the second one, you probably want a GUI.
|
||||
|
@@ -23,6 +23,36 @@
|
||||
<key>CFBundleName</key>
|
||||
<string>Tomahawk</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.5.0</string>
|
||||
<string>10.5.0</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>Tomahawk URL</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>tomahawk</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>xspf</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>Generic.icns</string>
|
||||
<key>CFBundleTypeMIMETypes</key>
|
||||
<array>
|
||||
<string>application/xspf+xml</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>XSPF Playlist</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#define APP TomahawkApp::instance()
|
||||
|
||||
#include "headlesscheck.h"
|
||||
#include "mac/tomahawkapp_mac.h" // for PlatforInterface
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QFile>
|
||||
@@ -28,6 +29,7 @@ class XMPPBot;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
class ShortcutHandler;
|
||||
namespace InfoSystem
|
||||
{
|
||||
class InfoSystem;
|
||||
@@ -47,7 +49,7 @@ class TomahawkWindow;
|
||||
// this also acts as a a container for important top-level objects
|
||||
// that other parts of the app need to find
|
||||
// (eg, library, pipeline, friends list)
|
||||
class TomahawkApp : public TOMAHAWK_APPLICATION
|
||||
class TomahawkApp : public TOMAHAWK_APPLICATION, public Tomahawk::PlatformInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -69,6 +71,10 @@ public:
|
||||
void addScriptResolver( const QString& scriptPath );
|
||||
void removeScriptResolver( const QString& scriptPath );
|
||||
|
||||
// PlatformInterface
|
||||
virtual void activate();
|
||||
virtual bool loadUrl( const QString& url );
|
||||
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
||||
@@ -94,6 +100,7 @@ private:
|
||||
SipHandler* m_sipHandler;
|
||||
Servent* m_servent;
|
||||
XMPPBot* m_xmppBot;
|
||||
Tomahawk::ShortcutHandler* m_shortcutHandler;
|
||||
|
||||
#ifndef NO_LIBLASTFM
|
||||
Scrobbler* m_scrobbler;
|
||||
|
@@ -2,6 +2,31 @@ SET( OS_SPECIFIC_LINK_LIBRARIES
|
||||
${OS_SPECIFIC_LINK_LIBRARIES}
|
||||
${COREAUDIO_LIBRARY}
|
||||
${COREFOUNDATION_LIBRARY}
|
||||
|
||||
/System/Library/Frameworks/AppKit.framework
|
||||
/System/Library/Frameworks/Carbon.framework
|
||||
/System/Library/Frameworks/DiskArbitration.framework
|
||||
/System/Library/Frameworks/Foundation.framework
|
||||
/System/Library/Frameworks/IOKit.framework
|
||||
|
||||
rtaudio
|
||||
tomahawklib
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
# find_library(GROWL Growl)
|
||||
# option(ENABLE_SPARKLE "Sparkle updating" ON)
|
||||
# find_library(SPARKLE Sparkle)
|
||||
# if (ENABLE_SPARKLE AND SPARKLE)
|
||||
# set(HAVE_SPARKLE ON)
|
||||
# endif (ENABLE_SPARKLE AND SPARKLE)
|
||||
# Uses Darwin kernel version.
|
||||
# 9.8.0 -> 10.5/Leopard
|
||||
# 10.4.0 -> 10.6/Snow Leopard
|
||||
string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${CMAKE_HOST_SYSTEM_VERSION})
|
||||
if (DARWIN_VERSION GREATER 9)
|
||||
SET(SNOW_LEOPARD 1)
|
||||
elseif (DARWIN_VERSION GREATER 8)
|
||||
SET(LEOPARD 1)
|
||||
endif (DARWIN_VERSION GREATER 9)
|
||||
endif (APPLE)
|
||||
|
@@ -28,6 +28,7 @@ SET( TOMAHAWK_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../include/" )
|
||||
|
||||
SET( tomahawkSources ${tomahawkSources}
|
||||
sip/SipHandler.cpp
|
||||
sip/twitter/tomahawkoauthtwitter.cpp
|
||||
|
||||
infosystem/infosystem.cpp
|
||||
infosystem/infoplugins/echonestplugin.cpp
|
||||
@@ -39,6 +40,7 @@ SET( tomahawkSources ${tomahawkSources}
|
||||
musicscanner.cpp
|
||||
scriptresolver.cpp
|
||||
scrobbler.cpp
|
||||
shortcuthandler.cpp
|
||||
|
||||
tomahawkapp.cpp
|
||||
main.cpp
|
||||
@@ -57,11 +59,18 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
||||
tomahawkwindow.cpp
|
||||
)
|
||||
|
||||
|
||||
IF( APPLE )
|
||||
SET( tomahawkHeaders ${tomahawkHeaders} mac/tomahawkapp_mac.h mac/macshortcuthandler.h )
|
||||
SET( tomahawkSources ${tomahawkSources} mac/tomahawkapp_mac.mm mac/macshortcuthandler.cpp )
|
||||
ENDIF( APPLE )
|
||||
|
||||
SET( tomahawkHeaders ${tomahawkHeaders}
|
||||
"${TOMAHAWK_INC_DIR}/tomahawk/tomahawkapp.h"
|
||||
"${TOMAHAWK_INC_DIR}/tomahawk/infosystem.h"
|
||||
|
||||
sip/SipHandler.h
|
||||
sip/twitter/tomahawkoauthtwitter.h
|
||||
|
||||
infosystem/infoplugins/echonestplugin.h
|
||||
infosystem/infoplugins/musixmatchplugin.h
|
||||
@@ -72,6 +81,7 @@ SET( tomahawkHeaders ${tomahawkHeaders}
|
||||
musicscanner.h
|
||||
scriptresolver.h
|
||||
scrobbler.h
|
||||
shortcuthandler.h
|
||||
)
|
||||
|
||||
SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
||||
@@ -109,10 +119,12 @@ INCLUDE_DIRECTORIES(
|
||||
topbar
|
||||
utils
|
||||
libtomahawk
|
||||
mac
|
||||
|
||||
../alsa-playback
|
||||
../rtaudio
|
||||
../qxt/qxtweb-standalone/qxtweb
|
||||
../thirdparty/qtweetlib/qtweetlib/src
|
||||
|
||||
/usr/include/taglib
|
||||
/usr/local/include/taglib
|
||||
@@ -132,12 +144,16 @@ IF( UNIX )
|
||||
ENDIF( UNIX )
|
||||
|
||||
ADD_SUBDIRECTORY( sip/jabber )
|
||||
ADD_SUBDIRECTORY( sip/twitter )
|
||||
ADD_SUBDIRECTORY( sip/zeroconf )
|
||||
|
||||
kde4_add_app_icon( tomahawkSources "${CMAKE_CURRENT_SOURCE_DIR}/../data/icons/tomahawk-icon-*.png" )
|
||||
qt4_add_resources( RC_SRCS "../resources.qrc" )
|
||||
qt4_wrap_cpp( tomahawkMoc ${tomahawkHeaders} )
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
SET( final_src ${final_src} ${tomahawkMoc} ${tomahawkSources} ${tomahawkHeaders} )
|
||||
|
||||
IF( "${gui}" STREQUAL "no" )
|
||||
@@ -152,6 +168,8 @@ IF( UNIX AND NOT APPLE )
|
||||
ENDIF( UNIX AND NOT APPLE )
|
||||
IF( APPLE )
|
||||
ADD_EXECUTABLE( tomahawk MACOSX_BUNDLE ${final_src} )
|
||||
SET_TARGET_PROPERTIES(tomahawk PROPERTIES MACOSX_BUNDLE_INFO_PLIST "../admin/mac/Info.plist"
|
||||
)
|
||||
ENDIF( APPLE )
|
||||
IF( WIN32 )
|
||||
ADD_EXECUTABLE( tomahawk ${final_src} )
|
||||
@@ -167,6 +185,7 @@ TARGET_LINK_LIBRARIES( tomahawk
|
||||
|
||||
qjson
|
||||
tag
|
||||
tomahawk_qtweetlib
|
||||
)
|
||||
|
||||
INCLUDE( "CPack.txt" )
|
||||
|
10
src/config.h.in
Normal file
10
src/config.h.in
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef CONFIG_H_IN
|
||||
#define CONFIG_H_IN
|
||||
|
||||
#define CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}"
|
||||
|
||||
#cmakedefine SNOW_LEOPARD
|
||||
#cmakedefine LEOPARD
|
||||
#cmakedefine HAVE_SPARKLE
|
||||
|
||||
#endif // CONFIG_H_IN
|
@@ -308,6 +308,7 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
|
||||
../../thirdparty/jdns
|
||||
../../thirdparty/jdns/jdns
|
||||
../../thirdparty/jdns/jdnsshared
|
||||
../../thirdparty/qtweetlib/qtweetlib/src
|
||||
playlist
|
||||
)
|
||||
|
||||
@@ -371,6 +372,7 @@ target_link_libraries( tomahawklib
|
||||
vorbisfile
|
||||
ogg
|
||||
FLAC++
|
||||
tomahawk_qtweetlib
|
||||
${CLUCENE_LIBRARY}
|
||||
)
|
||||
|
||||
|
@@ -62,6 +62,15 @@ AudioEngine::~AudioEngine()
|
||||
delete m_audio;
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngine::playPause()
|
||||
{
|
||||
if( m_audio->isPlaying() )
|
||||
pause();
|
||||
else
|
||||
play();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngine::play()
|
||||
@@ -141,6 +150,11 @@ AudioEngine::setVolume( int percentage )
|
||||
emit volumeChanged( percentage );
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngine::mute()
|
||||
{
|
||||
setVolume( 0 );
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngine::onTrackAboutToClose()
|
||||
|
@@ -40,6 +40,7 @@ public:
|
||||
PlaylistInterface* playlist() const { return m_playlist; }
|
||||
|
||||
public slots:
|
||||
void playPause();
|
||||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
@@ -51,6 +52,7 @@ public slots:
|
||||
void lowerVolume() { setVolume( volume() - AUDIO_VOLUME_STEP ); }
|
||||
void raiseVolume() { setVolume( volume() + AUDIO_VOLUME_STEP ); }
|
||||
void onVolumeChanged( float volume ) { emit volumeChanged( volume * 100 ); }
|
||||
void mute();
|
||||
|
||||
void playItem( PlaylistInterface* playlist, const Tomahawk::result_ptr& result );
|
||||
void setPlaylist( PlaylistInterface* playlist ) { m_playlist = playlist; }
|
||||
|
@@ -46,6 +46,11 @@ FuzzyIndex::beginIndexing()
|
||||
{
|
||||
m_mutex.lock();
|
||||
|
||||
delete m_luceneSearcher;
|
||||
delete m_luceneReader;
|
||||
m_luceneSearcher = 0;
|
||||
m_luceneReader = 0;
|
||||
|
||||
try
|
||||
{
|
||||
IndexWriter luceneWriter = IndexWriter( m_luceneDir, m_analyzer, true );
|
||||
@@ -71,11 +76,6 @@ FuzzyIndex::appendFields( const QString& table, const QMap< unsigned int, QStrin
|
||||
{
|
||||
try
|
||||
{
|
||||
delete m_luceneSearcher;
|
||||
delete m_luceneReader;
|
||||
m_luceneSearcher = 0;
|
||||
m_luceneReader = 0;
|
||||
|
||||
bool create = !IndexReader::indexExists( TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" ).toStdString().c_str() );
|
||||
IndexWriter luceneWriter = IndexWriter( m_luceneDir, m_analyzer, create );
|
||||
Document doc;
|
||||
|
@@ -123,15 +123,20 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
|
||||
|
||||
|
||||
QString
|
||||
Servent::createConnectionKey( const QString& name )
|
||||
Servent::createConnectionKey( const QString& name, const QString &nodeid, const QString &key, bool onceOnly )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
Q_ASSERT( this->thread() == QThread::currentThread() );
|
||||
|
||||
QString key = uuid();
|
||||
QString _key = ( key.isEmpty() ? uuid() : key );
|
||||
ControlConnection* cc = new ControlConnection( this );
|
||||
cc->setName( name.isEmpty() ? QString( "KEY(%1)" ).arg( key ) : name );
|
||||
registerOffer( key, cc );
|
||||
return key;
|
||||
if( !nodeid.isEmpty() )
|
||||
cc->setId( nodeid );
|
||||
cc->setOnceOnly( onceOnly );
|
||||
qDebug() << "Creating connection key with name of " << cc->name() << " and id of " << cc->id() << " and key of " << _key << "; key is once only? : " << (onceOnly ? "true" : "false");
|
||||
registerOffer( _key, cc );
|
||||
return _key;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,9 +146,18 @@ Servent::setExternalAddress( QHostAddress ha, unsigned int port )
|
||||
m_externalAddress = ha;
|
||||
m_externalPort = port;
|
||||
|
||||
if( m_externalPort == 0 )
|
||||
if( m_externalPort == 0 || m_externalAddress.toString().isEmpty() )
|
||||
{
|
||||
qDebug() << "No external access, LAN and outbound connections only!";
|
||||
if( !TomahawkSettings::instance()->externalHostname().isEmpty() &&
|
||||
!TomahawkSettings::instance()->externalPort() == 0 )
|
||||
{
|
||||
qDebug() << "UPnP failed, have external address/port -- falling back";
|
||||
m_externalHostname = TomahawkSettings::instance()->externalHostname();
|
||||
m_externalPort = TomahawkSettings::instance()->externalPort();
|
||||
qDebug() << m_externalHostname << m_externalPort;
|
||||
}
|
||||
else
|
||||
qDebug() << "No external access, LAN and outbound connections only!";
|
||||
}
|
||||
|
||||
emit ready();
|
||||
@@ -260,7 +274,7 @@ Servent::readyRead()
|
||||
|
||||
qDebug() << m;
|
||||
|
||||
if( !nodeid.isEmpty() && cc != 0 ) // only control connections send nodeid
|
||||
if( !nodeid.isEmpty() ) // only control connections send nodeid
|
||||
{
|
||||
foreach( ControlConnection* con, m_controlconnections )
|
||||
{
|
||||
|
@@ -78,7 +78,7 @@ public:
|
||||
int port() const { return m_port; }
|
||||
|
||||
// creates new token that allows a controlconnection to be set up
|
||||
QString createConnectionKey( const QString& name = "" );
|
||||
QString createConnectionKey( const QString& name = "", const QString &nodeid = "", const QString &key = "", bool onceOnly = true );
|
||||
|
||||
void registerOffer( const QString& key, Connection* conn );
|
||||
|
||||
|
@@ -14,10 +14,13 @@ public:
|
||||
enum SipErrorCode { AuthError, ConnectionError }; // Placeholder for errors, to be defined
|
||||
|
||||
virtual ~SipPlugin() {}
|
||||
|
||||
virtual bool isValid() = 0;
|
||||
virtual const QString name() = 0;
|
||||
|
||||
public slots:
|
||||
virtual bool connect( bool startup = false ) = 0;
|
||||
virtual void disconnect() = 0;
|
||||
virtual bool connectPlugin( bool startup = false ) = 0;
|
||||
virtual void disconnectPlugin() = 0;
|
||||
|
||||
virtual void addContact( const QString &jid, const QString& msg = QString() ) = 0;
|
||||
virtual void sendMsg( const QString& to, const QString& msg ) = 0;
|
||||
|
@@ -327,13 +327,16 @@ TomahawkSettings::setExternalHostname(const QString& externalHostname)
|
||||
int
|
||||
TomahawkSettings::externalPort() const
|
||||
{
|
||||
return value( "network/external-port" ).toInt();
|
||||
return value( "network/external-port", 50210 ).toInt();
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkSettings::setExternalPort(int externalPort)
|
||||
{
|
||||
setValue( "network/external-port", externalPort);
|
||||
if ( externalPort == 0 )
|
||||
setValue( "network/external-port", 50210);
|
||||
else
|
||||
setValue( "network/external-port", externalPort);
|
||||
}
|
||||
|
||||
|
||||
@@ -378,6 +381,89 @@ TomahawkSettings::setLastFmUsername( const QString& username )
|
||||
setValue( "lastfm/username", username );
|
||||
}
|
||||
|
||||
QString
|
||||
TomahawkSettings::twitterScreenName() const
|
||||
{
|
||||
return value( "twitter/ScreenName" ).toString();
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkSettings::setTwitterScreenName( const QString& screenName )
|
||||
{
|
||||
setValue( "twitter/ScreenName", screenName );
|
||||
}
|
||||
|
||||
QString
|
||||
TomahawkSettings::twitterOAuthToken() const
|
||||
{
|
||||
return value( "twitter/OAuthToken" ).toString();
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkSettings::setTwitterOAuthToken( const QString& oauthtoken )
|
||||
{
|
||||
setValue( "twitter/OAuthToken", oauthtoken );
|
||||
}
|
||||
|
||||
QString
|
||||
TomahawkSettings::twitterOAuthTokenSecret() const
|
||||
{
|
||||
return value( "twitter/OAuthTokenSecret" ).toString();
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkSettings::setTwitterOAuthTokenSecret( const QString& oauthtokensecret )
|
||||
{
|
||||
setValue( "twitter/OAuthTokenSecret", oauthtokensecret );
|
||||
}
|
||||
|
||||
qint64
|
||||
TomahawkSettings::twitterCachedFriendsSinceId() const
|
||||
{
|
||||
return value( "twitter/CachedFriendsSinceID", 0 ).toLongLong();
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkSettings::setTwitterCachedFriendsSinceId( qint64 cachedId )
|
||||
{
|
||||
setValue( "twitter/CachedFriendsSinceID", cachedId );
|
||||
}
|
||||
|
||||
qint64
|
||||
TomahawkSettings::twitterCachedMentionsSinceId() const
|
||||
{
|
||||
return value( "twitter/CachedMentionsSinceID", 0 ).toLongLong();
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkSettings::setTwitterCachedMentionsSinceId( qint64 cachedId )
|
||||
{
|
||||
setValue( "twitter/CachedMentionsSinceID", cachedId );
|
||||
}
|
||||
|
||||
qint64
|
||||
TomahawkSettings::twitterCachedDirectMessagesSinceId() const
|
||||
{
|
||||
return value( "twitter/CachedDirectMessagesSinceID", 0 ).toLongLong();
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkSettings::setTwitterCachedDirectMessagesSinceId( qint64 cachedId )
|
||||
{
|
||||
setValue( "twitter/CachedDirectMessagesSinceID", cachedId );
|
||||
}
|
||||
|
||||
QHash<QString, QVariant>
|
||||
TomahawkSettings::twitterCachedPeers() const
|
||||
{
|
||||
return value( "twitter/CachedPeers", QHash<QString, QVariant>() ).toHash();
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkSettings::setTwitterCachedPeers( const QHash<QString, QVariant> &cachedPeers )
|
||||
{
|
||||
setValue( "twitter/CachedPeers", cachedPeers );
|
||||
}
|
||||
|
||||
bool
|
||||
TomahawkSettings::scrobblingEnabled() const
|
||||
|
@@ -95,7 +95,29 @@ public:
|
||||
|
||||
QByteArray lastFmSessionKey() const;
|
||||
void setLastFmSessionKey( const QByteArray& key );
|
||||
|
||||
/// Twitter settings
|
||||
QString twitterScreenName() const;
|
||||
void setTwitterScreenName( const QString& screenName );
|
||||
|
||||
QString twitterOAuthToken() const;
|
||||
void setTwitterOAuthToken( const QString& oauthtoken );
|
||||
|
||||
QString twitterOAuthTokenSecret() const;
|
||||
void setTwitterOAuthTokenSecret( const QString& oauthtokensecret );
|
||||
|
||||
qint64 twitterCachedFriendsSinceId() const;
|
||||
void setTwitterCachedFriendsSinceId( qint64 sinceid );
|
||||
|
||||
qint64 twitterCachedMentionsSinceId() const;
|
||||
void setTwitterCachedMentionsSinceId( qint64 sinceid );
|
||||
|
||||
qint64 twitterCachedDirectMessagesSinceId() const;
|
||||
void setTwitterCachedDirectMessagesSinceId( qint64 sinceid );
|
||||
|
||||
QHash<QString, QVariant> twitterCachedPeers() const;
|
||||
void setTwitterCachedPeers( const QHash<QString, QVariant> &cachedPeers );
|
||||
|
||||
/// XMPP Component Settings
|
||||
QString xmppBotServer() const;
|
||||
void setXmppBotServer( const QString &server );
|
||||
|
31
src/mac/macshortcuthandler.cpp
Normal file
31
src/mac/macshortcuthandler.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "macshortcuthandler.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <IOKit/hidsystem/ev_keymap.h>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
MacShortcutHandler::MacShortcutHandler(QObject *parent) :
|
||||
Tomahawk::ShortcutHandler(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MacShortcutHandler::macMediaKeyPressed( int key )
|
||||
{
|
||||
switch (key) {
|
||||
case NX_KEYTYPE_PLAY:
|
||||
qDebug() << "emitting PlayPause pressed";
|
||||
emit playPause();
|
||||
break;
|
||||
case NX_KEYTYPE_FAST:
|
||||
qDebug() << "emitting next pressed";
|
||||
emit next();
|
||||
break;
|
||||
case NX_KEYTYPE_REWIND:
|
||||
qDebug() << "emitting prev pressed";
|
||||
emit previous();
|
||||
break;
|
||||
}
|
||||
}
|
22
src/mac/macshortcuthandler.h
Normal file
22
src/mac/macshortcuthandler.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef MACSHORTCUTHANDLER_H
|
||||
#define MACSHORTCUTHANDLER_H
|
||||
|
||||
#include "shortcuthandler.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace Tomahawk {
|
||||
|
||||
|
||||
class MacShortcutHandler : public ShortcutHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MacShortcutHandler(QObject *parent = 0);
|
||||
|
||||
void macMediaKeyPressed( int key );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MACSHORTCUTHANDLER_H
|
30
src/mac/tomahawkapp_mac.h
Normal file
30
src/mac/tomahawkapp_mac.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef TOMAHAWKAPP_MAC_H
|
||||
#define TOMAHAWKAPP_MAC_H
|
||||
|
||||
// this file and tomahawk_app.mm copied and inspired by mac_startup.* in clementine player,
|
||||
// copyright David Sansome 2010
|
||||
|
||||
class QString;
|
||||
|
||||
namespace Tomahawk {
|
||||
|
||||
class MacShortcutHandler;
|
||||
|
||||
/// Interface between cocoa and tomahawk
|
||||
class PlatformInterface {
|
||||
public:
|
||||
// Called when the application should show itself.
|
||||
virtual void activate() = 0;
|
||||
virtual bool loadUrl( const QString& url ) = 0;
|
||||
|
||||
virtual ~PlatformInterface() {}
|
||||
};
|
||||
|
||||
void macMain();
|
||||
void setShortcutHandler(Tomahawk::MacShortcutHandler* engine);
|
||||
// used for opening files with tomahawk
|
||||
void setApplicationHandler(PlatformInterface* handler);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
205
src/mac/tomahawkapp_mac.mm
Normal file
205
src/mac/tomahawkapp_mac.mm
Normal file
@@ -0,0 +1,205 @@
|
||||
#include "tomahawkapp_mac.h"
|
||||
#include "tomahawkapp_macdelegate.h"
|
||||
#include "macshortcuthandler.h"
|
||||
#include <QDebug>
|
||||
|
||||
#import <AppKit/NSApplication.h>
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSBundle.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSFileManager.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
#import <Foundation/NSThread.h>
|
||||
#import <Foundation/NSTimer.h>
|
||||
#import <Foundation/NSAppleEventManager.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
#import <AppKit/NSEvent.h>
|
||||
#import <AppKit/NSNibDeclarations.h>
|
||||
|
||||
// Capture global media keys on Mac (Cocoa only!)
|
||||
// See: http://www.rogueamoeba.com/utm/2007/09/29/apple-keyboard-media-key-event-handling/
|
||||
|
||||
@interface MacApplication :NSApplication {
|
||||
Tomahawk::MacShortcutHandler* shortcut_handler_;
|
||||
Tomahawk::PlatformInterface* application_handler_;
|
||||
}
|
||||
|
||||
- (Tomahawk::MacShortcutHandler*) shortcutHandler;
|
||||
- (void) setShortcutHandler: (Tomahawk::MacShortcutHandler*)handler;
|
||||
|
||||
- (Tomahawk::PlatformInterface*) application_handler;
|
||||
- (void) setApplicationHandler: (Tomahawk::PlatformInterface*)handler;
|
||||
- (void) getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
|
||||
- (void) mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat;
|
||||
@end
|
||||
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (id) init {
|
||||
if ((self = [super init])) {
|
||||
application_handler_ = nil;
|
||||
// dock_menu_ = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithHandler: (Tomahawk::PlatformInterface*)handler {
|
||||
application_handler_ = handler;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) applicationShouldHandleReopen: (NSApplication*)app hasVisibleWindows:(BOOL)flag {
|
||||
if (application_handler_) {
|
||||
application_handler_->activate();
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
/*
|
||||
- (void) setDockMenu: (NSMenu*)menu {
|
||||
dock_menu_ = menu;
|
||||
}
|
||||
|
||||
- (NSMenu*) applicationDockMenu: (NSApplication*)sender {
|
||||
return dock_menu_;
|
||||
}
|
||||
*/
|
||||
- (BOOL) application: (NSApplication*)app openFile:(NSString*)filename {
|
||||
qDebug() << "Wants to open:" << [filename UTF8String];
|
||||
|
||||
if (application_handler_->loadUrl(QString::fromUtf8([filename UTF8String]))) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation MacApplication
|
||||
|
||||
- (id) init {
|
||||
if ((self = [super init])) {
|
||||
[self setShortcutHandler:nil];
|
||||
[self setApplicationHandler:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (Tomahawk::MacShortcutHandler*) shortcutHandler {
|
||||
return shortcut_handler_;
|
||||
}
|
||||
|
||||
- (void) setShortcutHandler: (Tomahawk::MacShortcutHandler*)handler {
|
||||
qDebug() << "Setting shortcut handler of MacAPp";
|
||||
shortcut_handler_ = handler;
|
||||
}
|
||||
|
||||
- (Tomahawk::PlatformInterface*) application_handler {
|
||||
return application_handler_;
|
||||
}
|
||||
|
||||
- (void) setApplicationHandler: (Tomahawk::PlatformInterface*)handler {
|
||||
AppDelegate* delegate = [[AppDelegate alloc] initWithHandler:handler];
|
||||
[self setDelegate:delegate];
|
||||
}
|
||||
|
||||
-(void) sendEvent: (NSEvent*)event {
|
||||
if ([event type] == NSSystemDefined && [event subtype] == 8) {
|
||||
int keycode = (([event data1] & 0xFFFF0000) >> 16);
|
||||
int keyflags = ([event data1] & 0x0000FFFF);
|
||||
int keystate = (((keyflags & 0xFF00) >> 8)) == 0xA;
|
||||
int keyrepeat = (keyflags & 0x1);
|
||||
|
||||
[self mediaKeyEvent: keycode state: keystate repeat: keyrepeat];
|
||||
}
|
||||
|
||||
[super sendEvent: event];
|
||||
}
|
||||
|
||||
-(void) mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat {
|
||||
if (!shortcut_handler_) {
|
||||
return;
|
||||
}
|
||||
if (state == 0) {
|
||||
shortcut_handler_->macMediaKeyPressed(key);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
void Tomahawk::macMain() {
|
||||
[[NSAutoreleasePool alloc] init];
|
||||
// Creates and sets the magic global variable so QApplication will find it.
|
||||
[MacApplication sharedApplication];
|
||||
#ifdef HAVE_SPARKLE
|
||||
// Creates and sets the magic global variable for Sparkle.
|
||||
[[SUUpdater sharedUpdater] setDelegate: NSApp];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Tomahawk::setShortcutHandler(Tomahawk::MacShortcutHandler* handler) {
|
||||
[NSApp setShortcutHandler: handler];
|
||||
}
|
||||
|
||||
void Tomahawk::setApplicationHandler(Tomahawk::PlatformInterface* handler) {
|
||||
[NSApp setApplicationHandler: handler];
|
||||
}
|
||||
|
||||
void CheckForUpdates() {
|
||||
#ifdef HAVE_SPARKLE
|
||||
[[SUUpdater sharedUpdater] checkForUpdates: NSApp];
|
||||
#endif
|
||||
}
|
||||
|
||||
QString GetBundlePath() {
|
||||
CFURLRef app_url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||
CFStringRef mac_path = CFURLCopyFileSystemPath(app_url, kCFURLPOSIXPathStyle);
|
||||
const char* path = CFStringGetCStringPtr(mac_path, CFStringGetSystemEncoding());
|
||||
QString bundle_path = QString::fromUtf8(path);
|
||||
CFRelease(app_url);
|
||||
CFRelease(mac_path);
|
||||
return bundle_path;
|
||||
}
|
||||
|
||||
QString GetResourcesPath() {
|
||||
QString bundle_path = GetBundlePath();
|
||||
return bundle_path + "/Contents/Resources";
|
||||
}
|
||||
|
||||
QString GetApplicationSupportPath() {
|
||||
NSAutoreleasePool* pool = [NSAutoreleasePool alloc];
|
||||
[pool init];
|
||||
NSArray* paths = NSSearchPathForDirectoriesInDomains(
|
||||
NSApplicationSupportDirectory,
|
||||
NSUserDomainMask,
|
||||
YES);
|
||||
QString ret;
|
||||
if ([paths count] > 0) {
|
||||
NSString* user_path = [paths objectAtIndex:0];
|
||||
ret = QString::fromUtf8([user_path UTF8String]);
|
||||
} else {
|
||||
ret = "~/Library/Application Support";
|
||||
}
|
||||
[pool drain];
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString GetMusicDirectory() {
|
||||
NSAutoreleasePool* pool = [NSAutoreleasePool alloc];
|
||||
[pool init];
|
||||
NSArray* paths = NSSearchPathForDirectoriesInDomains(
|
||||
NSMusicDirectory,
|
||||
NSUserDomainMask,
|
||||
YES);
|
||||
QString ret;
|
||||
if ([paths count] > 0) {
|
||||
NSString* user_path = [paths objectAtIndex:0];
|
||||
ret = QString::fromUtf8([user_path UTF8String]);
|
||||
} else {
|
||||
ret = "~/Music";
|
||||
}
|
||||
[pool drain];
|
||||
return ret;
|
||||
}
|
||||
|
44
src/main.cpp
44
src/main.cpp
@@ -1,8 +1,24 @@
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#include "tomahawkapp_mac.h"
|
||||
#include </System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/Headers/AppleEvents.h>
|
||||
static pascal OSErr appleEventHandler( const AppleEvent*, AppleEvent*, long );
|
||||
#endif
|
||||
|
||||
#include <exception>
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
#ifdef Q_WS_MAC
|
||||
// Do Mac specific startup to get media keys working.
|
||||
// This must go before QApplication initialisation.
|
||||
Tomahawk::macMain();
|
||||
|
||||
// used for url handler
|
||||
AEEventHandlerUPP h = AEEventHandlerUPP( appleEventHandler );
|
||||
AEInstallEventHandler( 'GURL', 'GURL', h, 0, false );
|
||||
|
||||
#endif
|
||||
try {
|
||||
TomahawkApp a( argc, argv );
|
||||
return a.exec();
|
||||
@@ -10,3 +26,31 @@ int main( int argc, char *argv[] )
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
static pascal OSErr appleEventHandler( const AppleEvent* e, AppleEvent*, long )
|
||||
{
|
||||
OSType id = typeWildCard;
|
||||
AEGetAttributePtr( e, keyEventIDAttr, typeType, 0, &id, sizeof(id), 0 );
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case 'GURL':
|
||||
{
|
||||
DescType type;
|
||||
Size size;
|
||||
|
||||
char buf[1024];
|
||||
AEGetParamPtr( e, keyDirectObject, typeChar, &type, &buf, 1023, &size );
|
||||
buf[size] = '\0';
|
||||
|
||||
QString url = QString::fromUtf8( buf );
|
||||
static_cast<TomahawkApp*>(qApp)->loadUrl( url );
|
||||
return noErr;
|
||||
}
|
||||
|
||||
default:
|
||||
return unimpErr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,7 +1,3 @@
|
||||
#include "settingsdialog.h"
|
||||
#include "ui_settingsdialog.h"
|
||||
#include "ui_proxydialog.h"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
@@ -14,11 +10,18 @@
|
||||
#include <lastfm/XmlQuery>
|
||||
#endif
|
||||
|
||||
#include <qtweetaccountverifycredentials.h>
|
||||
#include <qtweetstatusupdate.h>
|
||||
|
||||
#include "settingsdialog.h"
|
||||
#include "ui_settingsdialog.h"
|
||||
#include "ui_proxydialog.h"
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "musicscanner.h"
|
||||
#include "tomahawksettings.h"
|
||||
#include "sip/SipHandler.h"
|
||||
|
||||
#include "sip/twitter/tomahawkoauthtwitter.h"
|
||||
#include <database/database.h>
|
||||
|
||||
static QString
|
||||
md5( const QByteArray& src )
|
||||
@@ -47,19 +50,23 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
||||
ui->jabberPassword->setText( s->jabberPassword() );
|
||||
ui->jabberServer->setText( s->jabberServer() );
|
||||
ui->jabberPort->setValue( s->jabberPort() );
|
||||
|
||||
ui->staticHostName->setText( s->externalHostname() );
|
||||
ui->proxyButton->setVisible( false );
|
||||
ui->staticPort->setValue( s->externalPort() );
|
||||
|
||||
if ( ui->jabberPort->text().toInt() != 5222 || !ui->jabberServer->text().isEmpty() )
|
||||
ui->proxyButton->setVisible( false );
|
||||
|
||||
if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() )
|
||||
{
|
||||
ui->checkBoxAdvanced->setChecked( true );
|
||||
ui->twitterStatusLabel->setText("Status: No saved credentials");
|
||||
ui->twitterAuthenticateButton->setText( "Authenticate" );
|
||||
ui->twitterInstructionsBox->setVisible( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
// hide advanved settings
|
||||
ui->checkBoxAdvanced->setChecked( false );
|
||||
ui->groupBoxJabberAdvanced->setVisible( false );
|
||||
ui->groupBoxNetworkAdvanced->setVisible( false );
|
||||
ui->twitterStatusLabel->setText("Status: Credentials saved");
|
||||
ui->twitterAuthenticateButton->setText( "Re-authenticate" );
|
||||
ui->twitterInstructionsBox->setVisible( true );
|
||||
}
|
||||
|
||||
// MUSIC SCANNER
|
||||
@@ -118,6 +125,7 @@ SettingsDialog::~SettingsDialog()
|
||||
s->setJabberPort( ui->jabberPort->value() );
|
||||
|
||||
s->setExternalHostname( ui->staticHostName->text() );
|
||||
s->setExternalPort( ui->staticPort->value() );
|
||||
|
||||
s->setScannerPath( ui->lineEditMusicPath->text() );
|
||||
|
||||
@@ -140,8 +148,8 @@ SettingsDialog::~SettingsDialog()
|
||||
|
||||
if( rejabber )
|
||||
{
|
||||
APP->sipHandler()->disconnect();
|
||||
APP->sipHandler()->connect();
|
||||
APP->sipHandler()->disconnectPlugins();
|
||||
APP->sipHandler()->connectPlugins();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -273,6 +281,91 @@ SettingsDialog::onLastFmFinished()
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
SettingsDialog::authenticateTwitter()
|
||||
{
|
||||
TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
|
||||
twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
|
||||
twitAuth->authorizePin();
|
||||
if ( !twitAuth->oauthToken().isEmpty() && !twitAuth->oauthTokenSecret().isEmpty() )
|
||||
{
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
s->setTwitterOAuthToken( twitAuth->oauthToken() );
|
||||
s->setTwitterOAuthTokenSecret( twitAuth->oauthTokenSecret() );
|
||||
ui->twitterStatusLabel->setText("Status: Credentials saved");
|
||||
ui->twitterAuthenticateButton->setText( "Re-authenticate" );
|
||||
ui->twitterInstructionsBox->setVisible( true );
|
||||
TomahawkSettings::instance()->setTwitterCachedFriendsSinceId( 0 );
|
||||
TomahawkSettings::instance()->setTwitterCachedMentionsSinceId( 0 );
|
||||
TomahawkApp::instance()->sipHandler()->connectPlugins( false, "SIPTWITTER" );
|
||||
}
|
||||
else
|
||||
{
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
s->setTwitterOAuthToken( QString() );
|
||||
s->setTwitterOAuthTokenSecret( QString() );
|
||||
ui->twitterStatusLabel->setText("Status: No saved credentials");
|
||||
ui->twitterAuthenticateButton->setText( "Authenticate" );
|
||||
ui->twitterInstructionsBox->setVisible( false );
|
||||
QMessageBox::critical( 0, QString("Tweetin' Error"), QString("There was an error validating your authentication") );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SettingsDialog::startPostGotTomahawkStatus()
|
||||
{
|
||||
qDebug() << "Posting Got Tomahawk status";
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() )
|
||||
{
|
||||
QMessageBox::critical( 0, QString("Tweetin' Error"), QString("Your saved credentials could not be loaded.\nYou may wish to try re-authenticating.") );
|
||||
return;
|
||||
}
|
||||
TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
|
||||
twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
|
||||
twitAuth->setOAuthToken( s->twitterOAuthToken().toLatin1() );
|
||||
twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() );
|
||||
QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this );
|
||||
connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( postGotTomahawkStatusAuthVerifyReply(const QTweetUser &) ) );
|
||||
credVerifier->verify();
|
||||
}
|
||||
|
||||
void
|
||||
SettingsDialog::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user )
|
||||
{
|
||||
if ( user.id() == 0 )
|
||||
{
|
||||
QMessageBox::critical( 0, QString("Tweetin' Error"), QString("Your saved credentials could not be verified.\nYou may wish to try re-authenticating.") );
|
||||
return;
|
||||
}
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
s->setTwitterScreenName( user.screenName() );
|
||||
TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
|
||||
twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
|
||||
twitAuth->setOAuthToken( s->twitterOAuthToken().toLatin1() );
|
||||
twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() );
|
||||
QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( twitAuth, this );
|
||||
connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postGotTomahawkStatusUpdateReply(const QTweetStatus &) ) );
|
||||
connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
|
||||
QString uuid = QUuid::createUuid();
|
||||
statUpdate->post( QString( "Got Tomahawk? {" ) + Database::instance()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) );
|
||||
}
|
||||
|
||||
void
|
||||
SettingsDialog::postGotTomahawkStatusUpdateReply( const QTweetStatus& status )
|
||||
{
|
||||
if ( status.id() == 0 )
|
||||
QMessageBox::critical( 0, QString("Tweetin' Error"), QString("There was an error posting your status -- sorry!") );
|
||||
else
|
||||
QMessageBox::information( 0, QString("Tweeted!"), QString("Your tweet has been posted!") );
|
||||
}
|
||||
void
|
||||
SettingsDialog::postGotTomahawkStatusUpdateError( QTweetNetBase::ErrorCode code, const QString& errorMsg )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qDebug() << "Error posting Got Tomahawk message, error code is " << code << ", error message is " << errorMsg;
|
||||
QMessageBox::critical( 0, QString("Tweetin' Error"), QString("There was an error posting your status -- sorry!") );
|
||||
}
|
||||
|
||||
ProxyDialog::ProxyDialog( QWidget *parent )
|
||||
: QDialog( parent )
|
||||
|
@@ -3,6 +3,10 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <qtweetstatus.h>
|
||||
#include <qtweetuser.h>
|
||||
#include <qtweetnetbase.h>
|
||||
|
||||
class QNetworkReply;
|
||||
|
||||
namespace Ui
|
||||
@@ -50,7 +54,13 @@ private slots:
|
||||
|
||||
void testLastFmLogin();
|
||||
void onLastFmFinished();
|
||||
|
||||
|
||||
void authenticateTwitter();
|
||||
void startPostGotTomahawkStatus();
|
||||
void postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user );
|
||||
void postGotTomahawkStatusUpdateReply( const QTweetStatus &status );
|
||||
void postGotTomahawkStatusUpdateError( QTweetNetBase::ErrorCode, const QString &errorMsg );
|
||||
|
||||
void addScriptResolver();
|
||||
void scriptSelectionChanged();
|
||||
void removeScriptResolver();
|
||||
|
@@ -40,36 +40,30 @@
|
||||
<number>16</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="horizontalSpacing">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Jabber ID:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>jabberUsername</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="jabberUsername">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
@@ -79,20 +73,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>jabberPassword</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="jabberPassword">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
@@ -108,22 +105,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBoxAdvanced">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show Advanced Settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -227,72 +208,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBoxNetworkAdvanced">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Advanced Network Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="staticHostNameHLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="staticHostNameLabel">
|
||||
<property name="text">
|
||||
<string>Static Host Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="staticHostName"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="proxySettingsHLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="proxyButton">
|
||||
<property name="text">
|
||||
<string>Proxy Settings...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
@@ -306,50 +221,189 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxHttp">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Playdar HTTP API - NO AUTH</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxUpnp">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use UPnP to establish port forward</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxJabberAutoConnect">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connect automatically when Tomahawk starts</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabNetwork">
|
||||
<attribute name="title">
|
||||
<string>Network</string>
|
||||
</attribute>
|
||||
<widget class="QGroupBox" name="groupBoxNetworkAdvanced">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>10</y>
|
||||
<width>551</width>
|
||||
<height>341</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Advanced Network Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>If you're having difficulty connecting to peers, try setting this to your external IP address/host name and a port number (default 50210). Make sure to forward that port to this machine!</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="staticHostNameLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Static Host Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="staticHostName"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="staticPortLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Static Port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="staticPort">
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>50210</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="proxySettingsHLayout">
|
||||
<item>
|
||||
<spacer name="proxySettingsLeftSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="proxyButton">
|
||||
<property name="text">
|
||||
<string>Proxy Settings...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="proxySettingsRightSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxHttp">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Playdar HTTP API - NO AUTH</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxJabberAutoConnect">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connect automatically when Tomahawk starts</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxUpnp">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use UPnP to establish port forward</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabMusic">
|
||||
<attribute name="title">
|
||||
<string>Music</string>
|
||||
<string>Local Music</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<property name="margin">
|
||||
@@ -412,6 +466,104 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabTwitter">
|
||||
<attribute name="title">
|
||||
<string>Twitter</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="twitterVertLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="twitterInfoLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Authenticating with Twitter allows you to discover and play music from your Twitter friends running Tomahawk.
|
||||
|
||||
This feature works best when you have set a static host name in the "Network" settings tab under Advanced Settings, but may work even if you do not. Please note: this discovery uses Direct Messages and will only work when both Twitter users have followed each other. Tomahawk will attempt to "clean up" after itself to keep your Direct Message inbox tidy, but may miss some.
|
||||
|
||||
When you press the button your web browser will launch and take you to Twitter.com to authenticate. You must copy and paste the PIN number into the dialog box that appears.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="twitterHorizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="twitterStatusLabel">
|
||||
<property name="text">
|
||||
<string>Status: No saved credentials</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="twitterAuthenticateButton">
|
||||
<property name="text">
|
||||
<string>Authenticate with Twitter</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="twitterInstructionsBox">
|
||||
<property name="title">
|
||||
<string>Instructions</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="twitterInstructionsVLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="twitterInstructionsInfoLabel">
|
||||
<property name="text">
|
||||
<string>How it works is simple: just press the button below to tweet "Got Tomahawk?" and some necessary information. Then be (very) patient. Twitter is an asynchronous protocol so it can take a bit!
|
||||
|
||||
If connections to peers seem to have been lost, just press the button again to re-post a tweet for resynchronization.
|
||||
</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="twitterTweetGotTomahawkButton">
|
||||
<property name="text">
|
||||
<string>Press here to have Tomahawk post a tweet</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="twitterVertSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabLastfm">
|
||||
<attribute name="title">
|
||||
<string>Last.fm</string>
|
||||
@@ -641,50 +793,34 @@
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBoxAdvanced</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>proxyButton</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<sender>twitterAuthenticateButton</sender>
|
||||
<signal>pressed()</signal>
|
||||
<receiver>SettingsDialog</receiver>
|
||||
<slot>authenticateTwitter()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>310</x>
|
||||
<y>110</y>
|
||||
<x>459</x>
|
||||
<y>205</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>368</x>
|
||||
<y>194</y>
|
||||
<x>310</x>
|
||||
<y>216</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBoxAdvanced</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>groupBoxJabberAdvanced</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<sender>twitterTweetGotTomahawkButton</sender>
|
||||
<signal>pressed()</signal>
|
||||
<receiver>SettingsDialog</receiver>
|
||||
<slot>startPostGotTomahawkStatus()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>310</x>
|
||||
<y>115</y>
|
||||
<y>313</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>310</x>
|
||||
<y>174</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBoxAdvanced</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>groupBoxNetworkAdvanced</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>310</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>310</x>
|
||||
<y>262</y>
|
||||
<y>216</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
13
src/shortcuthandler.cpp
Normal file
13
src/shortcuthandler.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "shortcuthandler.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
ShortcutHandler::ShortcutHandler( QObject *parent )
|
||||
: QObject( parent )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ShortcutHandler::~ShortcutHandler()
|
||||
{
|
||||
}
|
34
src/shortcuthandler.h
Normal file
34
src/shortcuthandler.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef SHORTCUTHANDLER_H
|
||||
#define SHORTCUTHANDLER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace Tomahawk {
|
||||
/**
|
||||
Base class for various shortcut plugins on different platforms
|
||||
*/
|
||||
class ShortcutHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~ShortcutHandler();
|
||||
|
||||
signals:
|
||||
// add more as needed
|
||||
void playPause();
|
||||
void pause();
|
||||
void stop();
|
||||
void previous();
|
||||
void next();
|
||||
|
||||
void volumeUp();
|
||||
void volumeDown();
|
||||
void mute();
|
||||
protected:
|
||||
explicit ShortcutHandler( QObject *parent = 0 );
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SHORTCUTHANDLER_H
|
@@ -13,14 +13,15 @@
|
||||
|
||||
SipHandler::SipHandler( QObject* parent )
|
||||
: QObject( parent )
|
||||
, m_connected( false )
|
||||
{
|
||||
m_connected = false;
|
||||
loadPlugins( findPlugins() );
|
||||
}
|
||||
|
||||
|
||||
SipHandler::~SipHandler()
|
||||
{
|
||||
disconnectPlugins();
|
||||
}
|
||||
|
||||
|
||||
@@ -114,30 +115,39 @@ SipHandler::loadPlugin( QObject* plugin )
|
||||
|
||||
|
||||
void
|
||||
SipHandler::connect( bool startup )
|
||||
SipHandler::connectPlugins( bool startup, const QString &pluginName )
|
||||
{
|
||||
foreach( SipPlugin* sip, m_plugins )
|
||||
sip->connect( startup );
|
||||
{
|
||||
if ( pluginName.isEmpty() || ( !pluginName.isEmpty() && sip->name() == pluginName ) )
|
||||
sip->connectPlugin( startup );
|
||||
}
|
||||
m_connected = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SipHandler::disconnect()
|
||||
SipHandler::disconnectPlugins( const QString &pluginName )
|
||||
{
|
||||
foreach( SipPlugin* sip, m_plugins )
|
||||
sip->disconnect();
|
||||
SourceList::instance()->removeAllRemote();
|
||||
m_connected = false;
|
||||
{
|
||||
if ( pluginName.isEmpty() || ( !pluginName.isEmpty() && sip->name() == pluginName ) )
|
||||
sip->disconnectPlugin();
|
||||
}
|
||||
if( pluginName.isEmpty() )
|
||||
{
|
||||
SourceList::instance()->removeAllRemote();
|
||||
m_connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SipHandler::toggleConnect()
|
||||
{
|
||||
if( m_connected )
|
||||
disconnect();
|
||||
disconnectPlugins();
|
||||
else
|
||||
connect();
|
||||
connectPlugins();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -19,8 +19,8 @@ public:
|
||||
public slots:
|
||||
void addContact( const QString& id ) { qDebug() << Q_FUNC_INFO << id; }
|
||||
|
||||
void connect( bool startup = false );
|
||||
void disconnect();
|
||||
void connectPlugins( bool startup = false, const QString &pluginName = QString() );
|
||||
void disconnectPlugins( const QString &pluginName = QString() );
|
||||
void toggleConnect();
|
||||
|
||||
signals:
|
||||
|
@@ -12,9 +12,14 @@ JabberPlugin::setProxy( QNetworkProxy* proxy )
|
||||
p->setProxy( proxy );
|
||||
}
|
||||
|
||||
const QString
|
||||
JabberPlugin::name()
|
||||
{
|
||||
return QString( MYNAME );
|
||||
}
|
||||
|
||||
bool
|
||||
JabberPlugin::connect( bool startup )
|
||||
JabberPlugin::connectPlugin( bool startup )
|
||||
{
|
||||
qDebug() << "JabberPlugin::connect";
|
||||
if ( startup && !TomahawkSettings::instance()->jabberAutoConnect() )
|
||||
|
@@ -6,6 +6,8 @@
|
||||
|
||||
#include "../sipdllmacro.h"
|
||||
|
||||
#define MYNAME "SIPJABBER"
|
||||
|
||||
class SIPDLLEXPORT JabberPlugin : public SipPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -18,12 +20,16 @@ public:
|
||||
|
||||
virtual ~JabberPlugin() { delete p; }
|
||||
|
||||
//FIXME: Make this more correct
|
||||
virtual bool isValid() { return true; }
|
||||
virtual const QString name();
|
||||
|
||||
void setProxy( QNetworkProxy* proxy );
|
||||
|
||||
public slots:
|
||||
virtual bool connect( bool startup );
|
||||
virtual bool connectPlugin( bool startup );
|
||||
|
||||
void disconnect()
|
||||
void disconnectPlugin()
|
||||
{
|
||||
QMetaObject::invokeMethod( p,
|
||||
"disconnect",
|
||||
|
45
src/sip/twitter/CMakeLists.txt
Normal file
45
src/sip/twitter/CMakeLists.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
project( tomahawk )
|
||||
|
||||
include( ${QT_USE_FILE} )
|
||||
add_definitions( ${QT_DEFINITIONS} )
|
||||
add_definitions( -DQT_PLUGIN )
|
||||
add_definitions( -DQT_SHARED )
|
||||
add_definitions( -DSIPDLLEXPORT_PRO )
|
||||
|
||||
set( twitterSources
|
||||
twitter.cpp
|
||||
tomahawkoauthtwitter.cpp
|
||||
)
|
||||
|
||||
set( twitterHeaders
|
||||
twitter.h
|
||||
tomahawkoauthtwitter.h
|
||||
)
|
||||
|
||||
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
|
||||
${QT_INCLUDE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/thirdparty/qtweetlib/src
|
||||
)
|
||||
|
||||
qt4_wrap_cpp( twitterMoc ${twitterHeaders} )
|
||||
add_library( sip_twitter SHARED ${twitterSources} ${twitterMoc} )
|
||||
|
||||
IF( WIN32 )
|
||||
SET( OS_SPECIFIC_LINK_LIBRARIES
|
||||
${OS_SPECIFIC_LINK_LIBRARIES}
|
||||
"winmm.dll"
|
||||
"iphlpapi.a"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../../build/src/libtomahawk/libtomahawklib.dll"
|
||||
)
|
||||
ENDIF( WIN32 )
|
||||
|
||||
target_link_libraries( sip_twitter
|
||||
${QT_LIBRARIES}
|
||||
${OS_SPECIFIC_LINK_LIBRARIES}
|
||||
)
|
||||
|
||||
IF( APPLE )
|
||||
SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" )
|
||||
ENDIF( APPLE )
|
||||
|
||||
install( TARGETS sip_twitter DESTINATION lib )
|
18
src/sip/twitter/tomahawkoauthtwitter.cpp
Normal file
18
src/sip/twitter/tomahawkoauthtwitter.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "tomahawkoauthtwitter.h"
|
||||
#include <QInputDialog>
|
||||
|
||||
TomahawkOAuthTwitter::TomahawkOAuthTwitter( QObject* parent )
|
||||
: OAuthTwitter( parent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int TomahawkOAuthTwitter::authorizationWidget()
|
||||
{
|
||||
bool ok;
|
||||
int i = QInputDialog::getInt(0, QString( "Twitter PIN" ), QString( "After authenticating on Twitter's web site,\nenter the displayed PIN number here:" ), 0, 0, 2147483647, 1, &ok);
|
||||
if (ok)
|
||||
return i;
|
||||
|
||||
return 0;
|
||||
}
|
21
src/sip/twitter/tomahawkoauthtwitter.h
Normal file
21
src/sip/twitter/tomahawkoauthtwitter.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef TOMAHAWKOAUTHTWITTER
|
||||
#define TOMAHAWKOAUTHTWITTER
|
||||
|
||||
#include <oauthtwitter.h>
|
||||
|
||||
#include "../sipdllmacro.h"
|
||||
|
||||
class SIPDLLEXPORT TomahawkOAuthTwitter : public OAuthTwitter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TomahawkOAuthTwitter( QObject *parent = 0 );
|
||||
|
||||
~TomahawkOAuthTwitter() {}
|
||||
|
||||
protected:
|
||||
virtual int authorizationWidget();
|
||||
};
|
||||
|
||||
#endif
|
548
src/sip/twitter/twitter.cpp
Normal file
548
src/sip/twitter/twitter.cpp
Normal file
@@ -0,0 +1,548 @@
|
||||
#include "twitter.h"
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QRegExp>
|
||||
#include <QStringList>
|
||||
|
||||
#include <qtweetaccountverifycredentials.h>
|
||||
#include <qtweetuser.h>
|
||||
#include <qtweetstatus.h>
|
||||
|
||||
#include <utils/tomahawkutils.h>
|
||||
#include <tomahawksettings.h>
|
||||
#include <database/database.h>
|
||||
#include <network/servent.h>
|
||||
|
||||
|
||||
TwitterPlugin::TwitterPlugin()
|
||||
: SipPlugin()
|
||||
, m_isAuthed( false )
|
||||
, m_isOnline( false )
|
||||
, m_checkTimer( this )
|
||||
, m_connectTimer( this )
|
||||
, m_cachedFriendsSinceId( 0 )
|
||||
, m_cachedMentionsSinceId( 0 )
|
||||
, m_cachedDirectMessagesSinceId( 0 )
|
||||
, m_cachedPeers()
|
||||
, m_keyCache()
|
||||
, m_finishedFriends( false )
|
||||
, m_finishedMentions( false )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
m_checkTimer.setInterval( 60000 );
|
||||
m_checkTimer.setSingleShot( false );
|
||||
connect( &m_checkTimer, SIGNAL( timeout() ), SLOT( checkTimerFired() ) );
|
||||
m_checkTimer.start();
|
||||
|
||||
m_connectTimer.setInterval( 60000 );
|
||||
m_connectTimer.setSingleShot( false );
|
||||
connect( &m_connectTimer, SIGNAL( timeout() ), SLOT( connectTimerFired() ) );
|
||||
m_connectTimer.start();
|
||||
}
|
||||
|
||||
bool
|
||||
TwitterPlugin::isValid()
|
||||
{
|
||||
return m_isAuthed || !m_cachedPeers.isEmpty();
|
||||
}
|
||||
|
||||
const QString
|
||||
TwitterPlugin::name()
|
||||
{
|
||||
qDebug() << "TwitterPlugin returning plugin name " << QString( MYNAME );
|
||||
return QString( MYNAME );
|
||||
}
|
||||
|
||||
bool
|
||||
TwitterPlugin::connectPlugin( bool /*startup*/ )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
TomahawkSettings *settings = TomahawkSettings::instance();
|
||||
|
||||
m_cachedPeers = settings->twitterCachedPeers();
|
||||
QList<QString> peerlist = m_cachedPeers.keys();
|
||||
qStableSort( peerlist.begin(), peerlist.end() );
|
||||
foreach( QString screenName, peerlist )
|
||||
{
|
||||
QHash< QString, QVariant > cachedPeer = m_cachedPeers[screenName].toHash();
|
||||
foreach( QString prop, cachedPeer.keys() )
|
||||
qDebug() << "TwitterPlugin : " << screenName << ", key " << prop << ", value " << ( cachedPeer[prop].canConvert< QString >() ? cachedPeer[prop].toString() : QString::number( cachedPeer[prop].toInt() ) );
|
||||
QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&cachedPeer ) );
|
||||
}
|
||||
|
||||
if ( settings->twitterOAuthToken().isEmpty() || settings->twitterOAuthTokenSecret().isEmpty() )
|
||||
{
|
||||
qDebug() << "TwitterPlugin has empty Twitter credentials; not connecting";
|
||||
return m_cachedPeers.isEmpty();
|
||||
}
|
||||
|
||||
delete m_twitterAuth.data();
|
||||
m_twitterAuth = QWeakPointer<TomahawkOAuthTwitter>( new TomahawkOAuthTwitter( this ) );
|
||||
m_twitterAuth.data()->setNetworkAccessManager( TomahawkUtils::nam() );
|
||||
m_twitterAuth.data()->setOAuthToken( settings->twitterOAuthToken().toLatin1() );
|
||||
m_twitterAuth.data()->setOAuthTokenSecret( settings->twitterOAuthTokenSecret().toLatin1() );
|
||||
|
||||
QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this );
|
||||
connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) );
|
||||
credVerifier->verify();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::disconnectPlugin()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if( !m_friendsTimeline.isNull() )
|
||||
m_friendsTimeline.data()->deleteLater();
|
||||
if( !m_twitterAuth.isNull() )
|
||||
m_twitterAuth.data()->deleteLater();
|
||||
|
||||
m_cachedPeers.empty();
|
||||
delete m_twitterAuth.data();
|
||||
m_isOnline = false;
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user )
|
||||
{
|
||||
if ( user.id() == 0 )
|
||||
{
|
||||
qDebug() << "TwitterPlugin could not authenticate to Twitter";
|
||||
m_isAuthed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "TwitterPlugin successfully authenticated to Twitter as user " << user.screenName();
|
||||
m_isAuthed = true;
|
||||
if ( !m_twitterAuth.isNull() )
|
||||
{
|
||||
TomahawkSettings::instance()->setTwitterScreenName( user.screenName() );
|
||||
m_friendsTimeline = QWeakPointer<QTweetFriendsTimeline>( new QTweetFriendsTimeline( m_twitterAuth.data(), this ) );
|
||||
m_mentions = QWeakPointer<QTweetMentions>( new QTweetMentions( m_twitterAuth.data(), this ) );
|
||||
m_directMessages = QWeakPointer<QTweetDirectMessages>( new QTweetDirectMessages( m_twitterAuth.data(), this ) );
|
||||
m_directMessageNew = QWeakPointer<QTweetDirectMessageNew>( new QTweetDirectMessageNew( m_twitterAuth.data(), this ) );
|
||||
m_directMessageDestroy = QWeakPointer<QTweetDirectMessageDestroy>( new QTweetDirectMessageDestroy( m_twitterAuth.data(), this ) );
|
||||
connect( m_friendsTimeline.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( friendsTimelineStatuses(const QList<QTweetStatus> &) ) );
|
||||
connect( m_mentions.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( mentionsStatuses(const QList<QTweetStatus> &) ) );
|
||||
connect( m_directMessages.data(), SIGNAL( parsedDirectMessages(const QList<QTweetDMStatus> &)), SLOT( directMessages(const QList<QTweetDMStatus> &) ) );
|
||||
connect( m_directMessageNew.data(), SIGNAL( parsedDirectMessage(const QTweetDMStatus &)), SLOT( directMessagePosted(const QTweetDMStatus &) ) );
|
||||
connect( m_directMessageNew.data(), SIGNAL( error(QTweetNetBase::ErrorCode, const QString &) ), SLOT( directMessagePostError(QTweetNetBase::ErrorCode, const QString &) ) );
|
||||
connect( m_directMessageDestroy.data(), SIGNAL( parsedDirectMessage(const QTweetDMStatus &) ), SLOT( directMessageDestroyed(const QTweetDMStatus &) ) );
|
||||
m_isOnline = true;
|
||||
QMetaObject::invokeMethod( this, "checkTimerFired", Qt::AutoConnection );
|
||||
QTimer::singleShot( 20000, this, SLOT( connectTimerFired() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "TwitterPlugin auth pointer was null!";
|
||||
m_isAuthed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::checkTimerFired()
|
||||
{
|
||||
if ( !isValid() )
|
||||
return;
|
||||
|
||||
if ( m_cachedFriendsSinceId == 0 )
|
||||
m_cachedFriendsSinceId = TomahawkSettings::instance()->twitterCachedFriendsSinceId();
|
||||
|
||||
qDebug() << "TwitterPlugin looking at friends timeline since id " << m_cachedFriendsSinceId;
|
||||
|
||||
if ( !m_friendsTimeline.isNull() )
|
||||
m_friendsTimeline.data()->fetch( m_cachedFriendsSinceId, 0, 800 );
|
||||
|
||||
|
||||
if ( m_cachedMentionsSinceId == 0 )
|
||||
m_cachedMentionsSinceId = TomahawkSettings::instance()->twitterCachedMentionsSinceId();
|
||||
|
||||
qDebug() << "TwitterPlugin looking at mentions timeline since id " << m_cachedMentionsSinceId;
|
||||
|
||||
if ( !m_mentions.isNull() )
|
||||
m_mentions.data()->fetch( m_cachedMentionsSinceId, 0, 800 );
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::connectTimerFired()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( !isValid() || m_cachedPeers.isEmpty() )
|
||||
return;
|
||||
|
||||
QString myScreenName = TomahawkSettings::instance()->twitterScreenName();
|
||||
QList<QString> peerlist = m_cachedPeers.keys();
|
||||
qStableSort( peerlist.begin(), peerlist.end() );
|
||||
foreach( QString screenName, peerlist )
|
||||
{
|
||||
QHash< QString, QVariant > peerData = m_cachedPeers[screenName].toHash();
|
||||
|
||||
if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) )
|
||||
{
|
||||
qDebug() << "TwitterPlugin does not have host, port and/or pkey values for " << screenName;
|
||||
continue;
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?(Got Tomahawk\\?) (\\{[a-fA-F0-9\\-]+\\}) (.*)$" ), Qt::CaseSensitive, QRegExp::RegExp2 );
|
||||
QString myScreenName = TomahawkSettings::instance()->twitterScreenName();
|
||||
|
||||
QHash< QString, QTweetStatus > latestHash;
|
||||
foreach ( QTweetStatus status, statuses )
|
||||
{
|
||||
if ( !latestHash.contains( status.user().screenName() ) )
|
||||
latestHash[status.user().screenName()] = status;
|
||||
else
|
||||
{
|
||||
if ( status.id() > latestHash[status.user().screenName()].id() )
|
||||
latestHash[status.user().screenName()] = status;
|
||||
}
|
||||
}
|
||||
|
||||
foreach( QTweetStatus status, latestHash.values() )
|
||||
{
|
||||
if ( status.id() > m_cachedFriendsSinceId )
|
||||
m_cachedFriendsSinceId = status.id();
|
||||
|
||||
if ( regex.exactMatch( status.text() ) )
|
||||
{
|
||||
qDebug() << "TwitterPlugin found an exact tweet from friend " << status.user().screenName();
|
||||
if ( status.text().startsWith( '@' ) && regex.captureCount() >= 2 && regex.cap( 1 ) != QString( '@' + myScreenName ) )
|
||||
{
|
||||
qDebug() << "TwitterPlugin skipping tweet because it's directed @someone that isn't us";
|
||||
continue;
|
||||
}
|
||||
|
||||
QString node;
|
||||
for ( int i = 0; i < regex.captureCount(); ++i )
|
||||
{
|
||||
if ( regex.cap( i ) == QString( "Got Tomahawk?" ) )
|
||||
{
|
||||
QString nodeCap = regex.cap( i + 1 );
|
||||
nodeCap.chop( 1 );
|
||||
node = nodeCap.mid( 1 );
|
||||
}
|
||||
}
|
||||
if ( node.isEmpty() )
|
||||
{
|
||||
qDebug() << "TwitterPlugin could not parse node out of the tweet";
|
||||
continue;
|
||||
}
|
||||
else
|
||||
qDebug() << "TwitterPlugin parsed node " << node << " out of the tweet";
|
||||
|
||||
if ( status.user().screenName() == myScreenName && node == Database::instance()->dbid() )
|
||||
continue;
|
||||
|
||||
QHash< QString, QVariant > peerData;
|
||||
if( m_cachedPeers.contains( status.user().screenName() ) )
|
||||
{
|
||||
peerData = m_cachedPeers[status.user().screenName()].toHash();
|
||||
//force a re-send of info but no need to re-register
|
||||
peerData["resend"] = QVariant::fromValue< bool >( true );
|
||||
}
|
||||
peerData["node"] = QVariant::fromValue< QString >( node );
|
||||
QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) );
|
||||
}
|
||||
}
|
||||
|
||||
TomahawkSettings::instance()->setTwitterCachedFriendsSinceId( m_cachedFriendsSinceId );
|
||||
|
||||
m_finishedFriends = true;
|
||||
QMetaObject::invokeMethod( this, "pollDirectMessages", Qt::AutoConnection );
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QRegExp regex( QString( "^(@[a-zA-Z0-9]+ )?(Got Tomahawk\\?) (\\{[a-fA-F0-9\\-]+\\}) (.*)$" ), Qt::CaseSensitive, QRegExp::RegExp2 );
|
||||
QString myScreenName = TomahawkSettings::instance()->twitterScreenName();
|
||||
|
||||
QHash< QString, QTweetStatus > latestHash;
|
||||
foreach ( QTweetStatus status, statuses )
|
||||
{
|
||||
if ( !latestHash.contains( status.user().screenName() ) )
|
||||
latestHash[status.user().screenName()] = status;
|
||||
else
|
||||
{
|
||||
if ( status.id() > latestHash[status.user().screenName()].id() )
|
||||
latestHash[status.user().screenName()] = status;
|
||||
}
|
||||
}
|
||||
|
||||
foreach( QTweetStatus status, latestHash.values() )
|
||||
{
|
||||
if ( status.id() > m_cachedMentionsSinceId )
|
||||
m_cachedMentionsSinceId = status.id();
|
||||
|
||||
if ( regex.exactMatch( status.text() ) )
|
||||
{
|
||||
qDebug() << "TwitterPlugin found an exact matching mention from user " << status.user().screenName();
|
||||
if ( status.text().startsWith( '@' ) && regex.captureCount() >= 2 && regex.cap( 1 ) != QString( '@' + myScreenName ) )
|
||||
{
|
||||
qDebug() << "TwitterPlugin skipping mention because it's directed @someone that isn't us";
|
||||
continue;
|
||||
}
|
||||
|
||||
QString node;
|
||||
for ( int i = 0; i < regex.captureCount(); ++i )
|
||||
{
|
||||
if ( regex.cap( i ) == QString( "Got Tomahawk?" ) )
|
||||
{
|
||||
QString nodeCap = regex.cap( i + 1 );
|
||||
nodeCap.chop( 1 );
|
||||
node = nodeCap.mid( 1 );
|
||||
}
|
||||
}
|
||||
if ( node.isEmpty() )
|
||||
{
|
||||
qDebug() << "TwitterPlugin could not parse node out of the tweet";
|
||||
continue;
|
||||
}
|
||||
else
|
||||
qDebug() << "TwitterPlugin parsed node " << node << " out of the tweet";
|
||||
|
||||
if ( status.user().screenName() == myScreenName && node == Database::instance()->dbid() )
|
||||
continue;
|
||||
|
||||
QHash< QString, QVariant > peerData;
|
||||
if( m_cachedPeers.contains( status.user().screenName() ) )
|
||||
{
|
||||
peerData = m_cachedPeers[status.user().screenName()].toHash();
|
||||
//force a re-send of info but no need to re-register
|
||||
peerData["resend"] = QVariant::fromValue< bool >( true );
|
||||
}
|
||||
peerData["node"] = QVariant::fromValue< QString >( node );
|
||||
QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.user().screenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) );
|
||||
}
|
||||
}
|
||||
|
||||
TomahawkSettings::instance()->setTwitterCachedMentionsSinceId( m_cachedMentionsSinceId );
|
||||
|
||||
m_finishedMentions = true;
|
||||
QMetaObject::invokeMethod( this, "pollDirectMessages", Qt::AutoConnection );
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::pollDirectMessages()
|
||||
{
|
||||
if ( !m_finishedMentions || !m_finishedFriends )
|
||||
return;
|
||||
|
||||
m_finishedFriends = false;
|
||||
m_finishedMentions = false;
|
||||
|
||||
if ( !isValid() )
|
||||
return;
|
||||
|
||||
if ( m_cachedDirectMessagesSinceId == 0 )
|
||||
m_cachedDirectMessagesSinceId = TomahawkSettings::instance()->twitterCachedDirectMessagesSinceId();
|
||||
|
||||
qDebug() << "TwitterPlugin looking for direct messages since id " << m_cachedDirectMessagesSinceId;
|
||||
|
||||
if ( !m_directMessages.isNull() )
|
||||
m_directMessages.data()->fetch( m_cachedDirectMessagesSinceId, 0, 800 );
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::directMessages( const QList< QTweetDMStatus > &messages )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
QHash< QString, QTweetDMStatus > latestHash;
|
||||
foreach ( QTweetDMStatus status, messages )
|
||||
{
|
||||
if ( !latestHash.contains( status.senderScreenName() ) )
|
||||
latestHash[status.senderScreenName()] = status;
|
||||
else
|
||||
{
|
||||
if ( status.id() > latestHash[status.senderScreenName()].id() )
|
||||
latestHash[status.senderScreenName()] = status;
|
||||
}
|
||||
}
|
||||
|
||||
foreach( QTweetDMStatus status, latestHash.values() )
|
||||
{
|
||||
qDebug() << "TwitterPlugin checking direct message from " << status.senderScreenName() << " with content " << status.text();
|
||||
if ( status.id() > m_cachedDirectMessagesSinceId )
|
||||
m_cachedDirectMessagesSinceId = status.id();
|
||||
QStringList splitList = status.text().split(':');
|
||||
qDebug() << "TwitterPlugin found " << splitList.length() << " parts to the message; the parts are:";
|
||||
foreach( QString part, splitList )
|
||||
qDebug() << part;
|
||||
if ( splitList.length() != 5 )
|
||||
continue;
|
||||
if ( splitList[0] != "TOMAHAWKPEER" )
|
||||
continue;
|
||||
if ( !splitList[1].startsWith( "Host=" ) || !splitList[2].startsWith( "Port=" ) || !splitList[3].startsWith( "Node=" ) || !splitList[4].startsWith( "PKey=" ) )
|
||||
continue;
|
||||
int port = splitList[2].mid( 5 ).toInt();
|
||||
if ( port == 0 )
|
||||
continue;
|
||||
QString host = splitList[1].mid( 5 );
|
||||
QString node = splitList[3].mid( 5 );
|
||||
QString pkey = splitList[4].mid( 5 );
|
||||
qDebug() << "TwitterPlugin found a peerstart message from " << status.senderScreenName() << " with host " << host << " and port " << port << " and pkey " << pkey << " destined for node " << node;
|
||||
|
||||
if ( node != Database::instance()->dbid() )
|
||||
{
|
||||
qDebug() << "Not destined for this node; leaving it alone and not answering";
|
||||
continue;
|
||||
}
|
||||
|
||||
QHash< QString, QVariant > peerData = ( m_cachedPeers.contains( status.senderScreenName() ) ) ?
|
||||
m_cachedPeers[status.senderScreenName()].toHash() :
|
||||
QHash< QString, QVariant >();
|
||||
|
||||
peerData["host"] = QVariant::fromValue< QString >( host );
|
||||
peerData["port"] = QVariant::fromValue< int >( port );
|
||||
peerData["pkey"] = QVariant::fromValue< QString >( pkey );
|
||||
peerData["dirty"] = QVariant::fromValue< bool >( true );
|
||||
|
||||
QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.senderScreenName() ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&peerData ) );
|
||||
|
||||
if ( !m_directMessageDestroy.isNull() )
|
||||
m_directMessageDestroy.data()->destroyMessage( status.id() );
|
||||
}
|
||||
|
||||
TomahawkSettings::instance()->setTwitterCachedDirectMessagesSinceId( m_cachedDirectMessagesSinceId );
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
bool peersChanged = false;
|
||||
bool needToSend = false;
|
||||
bool needToAddToCache = false;
|
||||
|
||||
QString friendlyName = QString( '@' + screenName );
|
||||
|
||||
QHash< QString, QVariant > _peerData( peerData );
|
||||
|
||||
if ( _peerData.contains( "dirty" ) )
|
||||
{
|
||||
peersChanged = true;
|
||||
_peerData.remove( "dirty" );
|
||||
}
|
||||
|
||||
if ( _peerData.contains( "resend" ) )
|
||||
{
|
||||
needToSend = true;
|
||||
peersChanged = true;
|
||||
_peerData.remove( "resend" );
|
||||
}
|
||||
|
||||
if ( !_peerData.contains( "okey" ) )
|
||||
{
|
||||
QString okey = QUuid::createUuid().toString().split( '-' ).last();
|
||||
okey.chop( 1 );
|
||||
_peerData["okey"] = QVariant::fromValue< QString >( okey );
|
||||
peersChanged = true;
|
||||
needToAddToCache = true;
|
||||
needToSend = true;
|
||||
}
|
||||
|
||||
if ( !m_keyCache.contains( _peerData["okey"].toString() ) )
|
||||
needToAddToCache = true;
|
||||
|
||||
if ( !_peerData.contains( "ohst" ) || !_peerData.contains( "oprt" ) ||
|
||||
_peerData["ohst"].toString() != Servent::instance()->externalAddress() ||
|
||||
_peerData["oprt"].toInt() != Servent::instance()->externalPort()
|
||||
)
|
||||
needToSend = true;
|
||||
|
||||
if( needToAddToCache && _peerData.contains( "node" ) )
|
||||
{
|
||||
qDebug() << "TwitterPlugin registering offer to " << friendlyName << " with node " << _peerData["node"].toString() << " and offeredkey " << _peerData["okey"].toString();
|
||||
m_keyCache << Servent::instance()->createConnectionKey( friendlyName, _peerData["node"].toString(), _peerData["okey"].toString(), false );
|
||||
}
|
||||
|
||||
if( needToSend && _peerData.contains( "node") )
|
||||
{
|
||||
qDebug() << "TwitterPlugin needs to send and has node";
|
||||
_peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() );
|
||||
_peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() );
|
||||
peersChanged = true;
|
||||
if( !Servent::instance()->externalAddress().isEmpty() && !Servent::instance()->externalPort() == 0 )
|
||||
QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) );
|
||||
else
|
||||
qDebug() << "TwitterPlugin did not send offer because external address is " << Servent::instance()->externalAddress() << " and external port is " << Servent::instance()->externalPort();
|
||||
}
|
||||
|
||||
if ( m_isOnline && _peerData.contains( "host" ) && _peerData.contains( "port" ) && _peerData.contains( "pkey" ) )
|
||||
QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) );
|
||||
|
||||
if ( peersChanged )
|
||||
{
|
||||
m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( _peerData );
|
||||
TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:Node=%3:PKey=%4" ).arg( peerData["ohst"].toString() )
|
||||
.arg( peerData["oprt"].toString() )
|
||||
.arg( peerData["node"].toString() )
|
||||
.arg( peerData["okey"].toString() );
|
||||
qDebug() << "TwitterPlugin sending message to " << screenName << ": " << offerString;
|
||||
if( !m_directMessageNew.isNull() )
|
||||
m_directMessageNew.data()->post( screenName, offerString );
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) || !peerData.contains( "node" ) )
|
||||
{
|
||||
qDebug() << "TwitterPlugin could not find host and/or port and/or pkey for peer " << screenName;
|
||||
return;
|
||||
}
|
||||
QString friendlyName = QString( '@' + screenName );
|
||||
if ( !Servent::instance()->connectedToSession( peerData["node"].toString() ) )
|
||||
Servent::instance()->connectToPeer( peerData["host"].toString(),
|
||||
peerData["port"].toString().toInt(),
|
||||
peerData["pkey"].toString(),
|
||||
friendlyName,
|
||||
peerData["node"].toString() );
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::directMessagePosted( const QTweetDMStatus& message )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qDebug() << "TwitterPlugin sent message to " << message.recipientScreenName() << " containing: " << message.text();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::directMessagePostError( QTweetNetBase::ErrorCode errorCode, const QString &message )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qDebug() << "TwitterPlugin received an error posting direct message: " << m_directMessageNew.data()->lastErrorMessage();
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::directMessageDestroyed( const QTweetDMStatus& message )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qDebug() << "TwitterPlugin destroyed message " << message.text();
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2( sip, TwitterPlugin )
|
88
src/sip/twitter/twitter.h
Normal file
88
src/sip/twitter/twitter.h
Normal file
@@ -0,0 +1,88 @@
|
||||
#ifndef TWITTER_H
|
||||
#define TWITTER_H
|
||||
|
||||
#include <QTimer>
|
||||
#include <QWeakPointer>
|
||||
#include <QSet>
|
||||
|
||||
#include <qtweetuser.h>
|
||||
#include <qtweetnetbase.h>
|
||||
#include <qtweetfriendstimeline.h>
|
||||
#include <qtweetdirectmessages.h>
|
||||
#include <qtweetdirectmessagenew.h>
|
||||
#include <qtweetdirectmessagedestroy.h>
|
||||
#include <qtweetmentions.h>
|
||||
#include <qtweetdmstatus.h>
|
||||
|
||||
#include "../sipdllmacro.h"
|
||||
#include "sip/SipPlugin.h"
|
||||
#include "tomahawkoauthtwitter.h"
|
||||
|
||||
#define MYNAME "SIPTWITTER"
|
||||
|
||||
class SIPDLLEXPORT TwitterPlugin : public SipPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES( SipPlugin )
|
||||
|
||||
public:
|
||||
TwitterPlugin();
|
||||
|
||||
virtual ~TwitterPlugin() {}
|
||||
|
||||
virtual bool isValid();
|
||||
virtual const QString name();
|
||||
|
||||
public slots:
|
||||
virtual bool connectPlugin( bool startup );
|
||||
|
||||
void disconnectPlugin();
|
||||
|
||||
void sendMsg( const QString& to, const QString& msg )
|
||||
{
|
||||
}
|
||||
|
||||
void broadcastMsg( const QString &msg )
|
||||
{
|
||||
}
|
||||
|
||||
void addContact( const QString &jid, const QString& msg = QString() )
|
||||
{
|
||||
}
|
||||
|
||||
private slots:
|
||||
void connectAuthVerifyReply( const QTweetUser &user );
|
||||
void checkTimerFired();
|
||||
void connectTimerFired();
|
||||
void friendsTimelineStatuses( const QList< QTweetStatus > &statuses );
|
||||
void mentionsStatuses( const QList< QTweetStatus > &statuses );
|
||||
void pollDirectMessages();
|
||||
void directMessages( const QList< QTweetDMStatus > &messages );
|
||||
void directMessagePosted( const QTweetDMStatus &message );
|
||||
void directMessagePostError( QTweetNetBase::ErrorCode errorCode, const QString &message );
|
||||
void directMessageDestroyed( const QTweetDMStatus &message );
|
||||
void registerOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata );
|
||||
void sendOffer( const QString &screenName, const QHash< QString, QVariant > &peerdata );
|
||||
void makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerdata );
|
||||
|
||||
private:
|
||||
QWeakPointer< TomahawkOAuthTwitter > m_twitterAuth;
|
||||
QWeakPointer< QTweetFriendsTimeline > m_friendsTimeline;
|
||||
QWeakPointer< QTweetMentions > m_mentions;
|
||||
QWeakPointer< QTweetDirectMessages > m_directMessages;
|
||||
QWeakPointer< QTweetDirectMessageNew > m_directMessageNew;
|
||||
QWeakPointer< QTweetDirectMessageDestroy > m_directMessageDestroy;
|
||||
bool m_isAuthed;
|
||||
bool m_isOnline;
|
||||
QTimer m_checkTimer;
|
||||
QTimer m_connectTimer;
|
||||
qint64 m_cachedFriendsSinceId;
|
||||
qint64 m_cachedMentionsSinceId;
|
||||
qint64 m_cachedDirectMessagesSinceId;
|
||||
QHash< QString, QVariant > m_cachedPeers;
|
||||
QSet<QString> m_keyCache;
|
||||
bool m_finishedFriends;
|
||||
bool m_finishedMentions;
|
||||
};
|
||||
|
||||
#endif
|
@@ -2,9 +2,14 @@
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
const QString
|
||||
ZeroconfPlugin::name()
|
||||
{
|
||||
return QString( MYNAME );
|
||||
}
|
||||
|
||||
bool
|
||||
ZeroconfPlugin::connect( bool /*startup*/ )
|
||||
ZeroconfPlugin::connectPlugin( bool /*startup*/ )
|
||||
{
|
||||
delete m_zeroconf;
|
||||
m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this );
|
||||
@@ -12,15 +17,41 @@ ZeroconfPlugin::connect( bool /*startup*/ )
|
||||
SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) );
|
||||
|
||||
m_zeroconf->advertise();
|
||||
|
||||
m_isOnline = true;
|
||||
|
||||
foreach( QStringList *currNode, m_cachedNodes )
|
||||
{
|
||||
QStringList nodeSet = *currNode;
|
||||
if ( !Servent::instance()->connectedToSession( nodeSet[3] ) )
|
||||
Servent::instance()->connectToPeer( nodeSet[0], nodeSet[1].toInt(), "whitelist", nodeSet[2], nodeSet[3] );
|
||||
delete currNode;
|
||||
}
|
||||
m_cachedNodes.empty();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ZeroconfPlugin::disconnectPlugin()
|
||||
{
|
||||
m_isOnline = false;
|
||||
}
|
||||
|
||||
void
|
||||
ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid )
|
||||
{
|
||||
qDebug() << "Found LAN host:" << host << port << nodeid;
|
||||
|
||||
//FIXME: This doesn't work...why? I never see Found LAN host in debug either, but somehow nodes are being connected...
|
||||
if ( !m_isOnline )
|
||||
{
|
||||
qDebug() << "Not online, so not connecting";
|
||||
QStringList *nodeSet = new QStringList();
|
||||
*nodeSet << host << QString::number( port ) << name << nodeid;
|
||||
m_cachedNodes.insert( nodeSet );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !Servent::instance()->connectedToSession( nodeid ) )
|
||||
Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid );
|
||||
|
@@ -6,6 +6,8 @@
|
||||
|
||||
#include "../sipdllmacro.h"
|
||||
|
||||
#define MYNAME "SIPZEROCONF"
|
||||
|
||||
class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -14,16 +16,19 @@ class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin
|
||||
public:
|
||||
ZeroconfPlugin()
|
||||
: m_zeroconf( 0 )
|
||||
, m_isOnline( false )
|
||||
, m_cachedNodes()
|
||||
{}
|
||||
|
||||
virtual ~ZeroconfPlugin() {}
|
||||
|
||||
virtual bool isValid() { return true; }
|
||||
virtual const QString name();
|
||||
|
||||
public slots:
|
||||
virtual bool connect( bool startup );
|
||||
virtual bool connectPlugin( bool startup );
|
||||
|
||||
void disconnect()
|
||||
{
|
||||
}
|
||||
void disconnectPlugin();
|
||||
|
||||
void sendMsg( const QString& to, const QString& msg )
|
||||
{
|
||||
@@ -42,6 +47,8 @@ private slots:
|
||||
|
||||
private:
|
||||
TomahawkZeroconf* m_zeroconf;
|
||||
bool m_isOnline;
|
||||
QSet< QStringList* > m_cachedNodes;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -5,6 +5,8 @@
|
||||
#include <QMetaType>
|
||||
#include <QTime>
|
||||
#include <QNetworkReply>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "artist.h"
|
||||
#include "album.h"
|
||||
@@ -22,8 +24,11 @@
|
||||
#include "web/api_v1.h"
|
||||
#include "scriptresolver.h"
|
||||
#include "sourcelist.h"
|
||||
#include "shortcuthandler.h"
|
||||
#include "tomahawksettings.h"
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "utils/xspfloader.h"
|
||||
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
#include "tomahawkwindow.h"
|
||||
@@ -31,13 +36,15 @@
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#include "mac/macshortcuthandler.h"
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#define LOGFILE TomahawkUtils::appDataDir().filePath( "tomahawk.log" ).toLocal8Bit()
|
||||
#define LOGFILE_SIZE 1024 * 512
|
||||
#include "tomahawksettings.h"
|
||||
#include <utils/xspfloader.h>
|
||||
|
||||
using namespace std;
|
||||
ofstream logfile;
|
||||
@@ -108,6 +115,7 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
||||
, m_audioEngine( 0 )
|
||||
, m_sipHandler( 0 )
|
||||
, m_servent( 0 )
|
||||
, m_shortcutHandler( 0 )
|
||||
, m_mainwindow( 0 )
|
||||
, m_infoSystem( 0 )
|
||||
{
|
||||
@@ -154,31 +162,49 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
||||
qDebug() << "Init Echonest Factory.";
|
||||
GeneratorFactory::registerFactory( "echonest", new EchonestFactory );
|
||||
|
||||
// Register shortcut handler for this platform
|
||||
#ifdef Q_WS_MAC
|
||||
m_shortcutHandler = new MacShortcutHandler( this );
|
||||
Tomahawk::setShortcutHandler( static_cast<MacShortcutHandler*>( m_shortcutHandler) );
|
||||
|
||||
Tomahawk::setApplicationHandler( this );
|
||||
#endif
|
||||
|
||||
// Connect up shortcuts
|
||||
connect( m_shortcutHandler, SIGNAL( playPause() ), m_audioEngine, SLOT( playPause() ) );
|
||||
connect( m_shortcutHandler, SIGNAL( pause() ), m_audioEngine, SLOT( pause() ) );
|
||||
connect( m_shortcutHandler, SIGNAL( stop() ), m_audioEngine, SLOT( stop() ) );
|
||||
connect( m_shortcutHandler, SIGNAL( previous() ), m_audioEngine, SLOT( previous() ) );
|
||||
connect( m_shortcutHandler, SIGNAL( next() ), m_audioEngine, SLOT( next() ) );
|
||||
connect( m_shortcutHandler, SIGNAL( volumeUp() ), m_audioEngine, SLOT( raiseVolume() ) );
|
||||
connect( m_shortcutHandler, SIGNAL( volumeDown() ), m_audioEngine, SLOT( lowerVolume() ) );
|
||||
connect( m_shortcutHandler, SIGNAL( mute() ), m_audioEngine, SLOT( mute() ) );
|
||||
|
||||
#ifndef NO_LIBLASTFM
|
||||
qDebug() << "Init Scrobbler.";
|
||||
m_scrobbler = new Scrobbler( this );
|
||||
qDebug() << "Setting NAM.";
|
||||
TomahawkUtils::setNam( new lastfm::NetworkAccessManager( this ) );
|
||||
qDebug() << "Init Scrobbler.";
|
||||
m_scrobbler = new Scrobbler( this );
|
||||
qDebug() << "Setting NAM.";
|
||||
TomahawkUtils::setNam( new lastfm::NetworkAccessManager( this ) );
|
||||
|
||||
connect( m_audioEngine, SIGNAL( started( const Tomahawk::result_ptr& ) ),
|
||||
m_scrobbler, SLOT( trackStarted( const Tomahawk::result_ptr& ) ), Qt::QueuedConnection );
|
||||
connect( m_audioEngine, SIGNAL( started( const Tomahawk::result_ptr& ) ),
|
||||
m_scrobbler, SLOT( trackStarted( const Tomahawk::result_ptr& ) ), Qt::QueuedConnection );
|
||||
|
||||
connect( m_audioEngine, SIGNAL( paused() ),
|
||||
m_scrobbler, SLOT( trackPaused() ), Qt::QueuedConnection );
|
||||
connect( m_audioEngine, SIGNAL( paused() ),
|
||||
m_scrobbler, SLOT( trackPaused() ), Qt::QueuedConnection );
|
||||
|
||||
connect( m_audioEngine, SIGNAL( resumed() ),
|
||||
m_scrobbler, SLOT( trackResumed() ), Qt::QueuedConnection );
|
||||
connect( m_audioEngine, SIGNAL( resumed() ),
|
||||
m_scrobbler, SLOT( trackResumed() ), Qt::QueuedConnection );
|
||||
|
||||
connect( m_audioEngine, SIGNAL( stopped() ),
|
||||
m_scrobbler, SLOT( trackStopped() ), Qt::QueuedConnection );
|
||||
connect( m_audioEngine, SIGNAL( stopped() ),
|
||||
m_scrobbler, SLOT( trackStopped() ), Qt::QueuedConnection );
|
||||
#else
|
||||
qDebug() << "Setting NAM.";
|
||||
TomahawkUtils::setNam( new QNetworkAccessManager );
|
||||
qDebug() << "Setting NAM.";
|
||||
TomahawkUtils::setNam( new QNetworkAccessManager );
|
||||
#endif
|
||||
|
||||
// Set up proxy
|
||||
if( TomahawkSettings::instance()->proxyType() != QNetworkProxy::NoProxy &&
|
||||
!TomahawkSettings::instance()->proxyHost().isEmpty() )
|
||||
!TomahawkSettings::instance()->proxyHost().isEmpty() )
|
||||
{
|
||||
qDebug() << "Setting proxy to saved values";
|
||||
TomahawkUtils::setProxy( new QNetworkProxy( static_cast<QNetworkProxy::ProxyType>(TomahawkSettings::instance()->proxyType()), TomahawkSettings::instance()->proxyHost(), TomahawkSettings::instance()->proxyPort(), TomahawkSettings::instance()->proxyUsername(), TomahawkSettings::instance()->proxyPassword() ) );
|
||||
@@ -445,25 +471,30 @@ TomahawkApp::setupSIP()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if( !arguments().contains( "--nosip" ) )
|
||||
//FIXME: jabber autoconnect is really more, now that there is sip -- should be renamed and/or split out of jabber-specific settings
|
||||
if( !arguments().contains( "--nosip" ) && TomahawkSettings::instance()->jabberAutoConnect() )
|
||||
{
|
||||
m_xmppBot = new XMPPBot( this );
|
||||
qDebug() << "Connecting SIP classes";
|
||||
m_sipHandler->connect( true );
|
||||
m_sipHandler->connectPlugins( true );
|
||||
// m_sipHandler->setProxy( *TomahawkUtils::proxy() );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkApp::messageReceived( const QString& msg )
|
||||
|
||||
void
|
||||
TomahawkApp::activate()
|
||||
{
|
||||
qDebug() << "MESSAGE RECEIVED" << msg;
|
||||
if( msg.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( msg.contains( "tomahawk://" ) ) {
|
||||
QString cmd = msg.mid( 11 );
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
mainWindow()->show();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
TomahawkApp::loadUrl( const QString& url )
|
||||
{
|
||||
if( url.contains( "tomahawk://" ) ) {
|
||||
QString cmd = url.mid( 11 );
|
||||
qDebug() << "tomahawk!s" << cmd;
|
||||
if( cmd.startsWith( "load/" ) ) {
|
||||
cmd = cmd.mid( 5 );
|
||||
@@ -474,7 +505,26 @@ TomahawkApp::messageReceived( const QString& msg )
|
||||
l->load( QUrl( cmd.mid( 5 ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
QFile f( url );
|
||||
QFileInfo info( f );
|
||||
if( f.exists() && info.suffix() == "xspf" ) {
|
||||
XSPFLoader* l = new XSPFLoader( true, this );
|
||||
qDebug() << "Loading spiff:" << url;
|
||||
l->load( QUrl( url ) );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkApp::messageReceived( const QString& msg )
|
||||
{
|
||||
qDebug() << "MESSAGE RECEIVED" << msg;
|
||||
if( msg.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
loadUrl( msg );
|
||||
}
|
||||
|
||||
|
25
src/tomahawkapp_macdelegate.h
Normal file
25
src/tomahawkapp_macdelegate.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#import <AppKit/NSApplication.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
// this file copied and inspired by mac_startup.* in clementine player,
|
||||
// copyright David Sansome 2010
|
||||
namespace Tomahawk {
|
||||
class PlatformInterface;
|
||||
}
|
||||
|
||||
#ifdef SNOW_LEOPARD
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate> {
|
||||
#else
|
||||
@interface AppDelegate : NSObject {
|
||||
#endif
|
||||
Tomahawk::PlatformInterface* application_handler_;
|
||||
//NSMenu* dock_menu_;
|
||||
}
|
||||
|
||||
- (id) initWithHandler: (Tomahawk::PlatformInterface*)handler;
|
||||
// NSApplicationDelegate
|
||||
- (BOOL) applicationShouldHandleReopen: (NSApplication*)app hasVisibleWindows:(BOOL)flag;
|
||||
//- (NSMenu*) applicationDockMenu: (NSApplication*)sender;
|
||||
//- (void) setDockMenu: (NSMenu*)menu;
|
||||
@end
|
1
thirdparty/CMakeLists.txt
vendored
1
thirdparty/CMakeLists.txt
vendored
@@ -1 +1,2 @@
|
||||
add_subdirectory( jdns )
|
||||
add_subdirectory( qtweetlib )
|
||||
|
180
thirdparty/qtweetlib/CMakeLists.txt
vendored
Normal file
180
thirdparty/qtweetlib/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
PROJECT(QTweetLib)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
|
||||
SET(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
SET( QT_USE_QTNETWORK TRUE )
|
||||
INCLUDE( ${QT_USE_FILE} )
|
||||
|
||||
|
||||
add_definitions( ${QT_DEFINITIONS} )
|
||||
add_definitions( -DQT_SHARED )
|
||||
|
||||
if(WIN32)
|
||||
set(PLATFORM_SPECIFIC_LIBS "ws2_32.dll" "advapi32.dll" )
|
||||
endif(WIN32)
|
||||
|
||||
set(TOMAHAWK_QTWEETLIB_SOURCES
|
||||
qtweetlib/src/oauth.cpp
|
||||
qtweetlib/src/oauthtwitter.cpp
|
||||
qtweetlib/src/qtweetfriendstimeline.cpp
|
||||
qtweetlib/src/qtweethometimeline.cpp
|
||||
qtweetlib/src/qtweetmentions.cpp
|
||||
qtweetlib/src/qtweetnetbase.cpp
|
||||
qtweetlib/src/qtweetretweetbyme.cpp
|
||||
qtweetlib/src/qtweetretweetsofme.cpp
|
||||
qtweetlib/src/qtweetretweettome.cpp
|
||||
qtweetlib/src/qtweetstatus.cpp
|
||||
qtweetlib/src/qtweetstatusshow.cpp
|
||||
qtweetlib/src/qtweetstatusupdate.cpp
|
||||
qtweetlib/src/qtweetuser.cpp
|
||||
qtweetlib/src/qtweetusertimeline.cpp
|
||||
qtweetlib/src/qtweetstatusdestroy.cpp
|
||||
qtweetlib/src/qtweetstatusretweet.cpp
|
||||
qtweetlib/src/qtweetstatusretweets.cpp
|
||||
qtweetlib/src/qtweetusershow.cpp
|
||||
qtweetlib/src/qtweetuserlookup.cpp
|
||||
qtweetlib/src/qtweetdirectmessages.cpp
|
||||
qtweetlib/src/qtweetuserstream.cpp
|
||||
qtweetlib/src/qtweetdmstatus.cpp
|
||||
qtweetlib/src/qtweetusersearch.cpp
|
||||
qtweetlib/src/qtweetuserstatusesfriends.cpp
|
||||
qtweetlib/src/qtweetuserstatusesfollowers.cpp
|
||||
qtweetlib/src/qtweetlist.cpp
|
||||
qtweetlib/src/qtweetlistcreate.cpp
|
||||
qtweetlib/src/qtweetlistupdate.cpp
|
||||
qtweetlib/src/qtweetlistgetlists.cpp
|
||||
qtweetlib/src/qtweetlistshowlist.cpp
|
||||
qtweetlib/src/qtweetlistdeletelist.cpp
|
||||
qtweetlib/src/qtweetliststatuses.cpp
|
||||
qtweetlib/src/qtweetlistmemberships.cpp
|
||||
qtweetlib/src/qtweetlistsubscriptions.cpp
|
||||
qtweetlib/src/qtweetlistgetmembers.cpp
|
||||
qtweetlib/src/qtweetlistaddmember.cpp
|
||||
qtweetlib/src/qtweetlistdeletemember.cpp
|
||||
qtweetlib/src/qtweetlistsubscribers.cpp
|
||||
qtweetlib/src/qtweetlistsubscribe.cpp
|
||||
qtweetlib/src/qtweetlistunsubscribe.cpp
|
||||
qtweetlib/src/qtweetdirectmessagessent.cpp
|
||||
qtweetlib/src/qtweetdirectmessagenew.cpp
|
||||
qtweetlib/src/qtweetdirectmessagedestroy.cpp
|
||||
qtweetlib/src/qtweetfriendshipcreate.cpp
|
||||
qtweetlib/src/qtweetfriendshipdestroy.cpp
|
||||
qtweetlib/src/qtweetfriendsid.cpp
|
||||
qtweetlib/src/qtweetfollowersid.cpp
|
||||
qtweetlib/src/qtweetaccountverifycredentials.cpp
|
||||
qtweetlib/src/qtweetaccountratelimitstatus.cpp
|
||||
qtweetlib/src/qtweetfavorites.cpp
|
||||
qtweetlib/src/qtweetfavoritescreate.cpp
|
||||
qtweetlib/src/qtweetfavoritesdestroy.cpp
|
||||
qtweetlib/src/qtweetsearch.cpp
|
||||
qtweetlib/src/qtweetsearchresult.cpp
|
||||
qtweetlib/src/qtweetsearchpageresults.cpp
|
||||
qtweetlib/src/qtweetplace.cpp
|
||||
qtweetlib/src/qtweetgeoreversegeocode.cpp
|
||||
qtweetlib/src/qtweetgeosearch.cpp
|
||||
qtweetlib/src/qtweetgeosimilarplaces.cpp
|
||||
qtweetlib/src/qtweetgeoplaceid.cpp
|
||||
qtweetlib/src/qtweetgeoplacecreate.cpp
|
||||
qtweetlib/src/qtweetgeocoord.cpp
|
||||
qtweetlib/src/qtweetgeoboundingbox.cpp
|
||||
qtweetlib/src/qtweetconvert.cpp
|
||||
qtweetlib/src/qtweetentityurl.cpp
|
||||
qtweetlib/src/qtweetentityhashtag.cpp
|
||||
qtweetlib/src/qtweetentityusermentions.cpp
|
||||
)
|
||||
|
||||
set(TOMAHAWK_QTWEETLIB_HEADERS
|
||||
qtweetlib/src/oauth.h
|
||||
qtweetlib/src/oauthtwitter.h
|
||||
qtweetlib/src/qtweetfriendstimeline.h
|
||||
qtweetlib/src/qtweetlib_global.h
|
||||
qtweetlib/src/qtweethometimeline.h
|
||||
qtweetlib/src/qtweetmentions.h
|
||||
qtweetlib/src/qtweetnetbase.h
|
||||
qtweetlib/src/qtweetretweetbyme.h
|
||||
qtweetlib/src/qtweetretweetsofme.h
|
||||
qtweetlib/src/qtweetretweettome.h
|
||||
qtweetlib/src/qtweetstatus.h
|
||||
qtweetlib/src/qtweetstatusshow.h
|
||||
qtweetlib/src/qtweetstatusupdate.h
|
||||
qtweetlib/src/qtweetuser.h
|
||||
qtweetlib/src/qtweetusertimeline.h
|
||||
qtweetlib/src/qtweetstatusdestroy.h
|
||||
qtweetlib/src/qtweetstatusretweet.h
|
||||
qtweetlib/src/qtweetstatusretweets.h
|
||||
qtweetlib/src/qtweetusershow.h
|
||||
qtweetlib/src/qtweetuserlookup.h
|
||||
qtweetlib/src/qtweetdirectmessages.h
|
||||
qtweetlib/src/qtweetuserstream.h
|
||||
qtweetlib/src/qtweetdmstatus.h
|
||||
qtweetlib/src/qtweetusersearch.h
|
||||
qtweetlib/src/qtweetuserstatusesfriends.h
|
||||
qtweetlib/src/qtweetuserstatusesfollowers.h
|
||||
qtweetlib/src/qtweetlist.h
|
||||
qtweetlib/src/qtweetlistcreate.h
|
||||
qtweetlib/src/qtweetlistupdate.h
|
||||
qtweetlib/src/qtweetlistgetlists.h
|
||||
qtweetlib/src/qtweetlistshowlist.h
|
||||
qtweetlib/src/qtweetlistdeletelist.h
|
||||
qtweetlib/src/qtweetliststatuses.h
|
||||
qtweetlib/src/qtweetlistmemberships.h
|
||||
qtweetlib/src/qtweetlistsubscriptions.h
|
||||
qtweetlib/src/qtweetlistgetmembers.h
|
||||
qtweetlib/src/qtweetlistaddmember.h
|
||||
qtweetlib/src/qtweetlistdeletemember.h
|
||||
qtweetlib/src/qtweetlistsubscribers.h
|
||||
qtweetlib/src/qtweetlistsubscribe.h
|
||||
qtweetlib/src/qtweetlistunsubscribe.h
|
||||
qtweetlib/src/qtweetdirectmessagessent.h
|
||||
qtweetlib/src/qtweetdirectmessagenew.h
|
||||
qtweetlib/src/qtweetdirectmessagedestroy.h
|
||||
qtweetlib/src/qtweetfriendshipcreate.h
|
||||
qtweetlib/src/qtweetfriendshipdestroy.h
|
||||
qtweetlib/src/qtweetfriendsid.h
|
||||
qtweetlib/src/qtweetfollowersid.h
|
||||
qtweetlib/src/qtweetaccountverifycredentials.h
|
||||
qtweetlib/src/qtweetaccountratelimitstatus.h
|
||||
qtweetlib/src/qtweetfavorites.h
|
||||
qtweetlib/src/qtweetfavoritescreate.h
|
||||
qtweetlib/src/qtweetfavoritesdestroy.h
|
||||
qtweetlib/src/qtweetsearch.h
|
||||
qtweetlib/src/qtweetsearchresult.h
|
||||
qtweetlib/src/qtweetsearchpageresults.h
|
||||
qtweetlib/src/qtweetplace.h
|
||||
qtweetlib/src/qtweetgeoreversegeocode.h
|
||||
qtweetlib/src/qtweetgeosearch.h
|
||||
qtweetlib/src/qtweetgeosimilarplaces.h
|
||||
qtweetlib/src/qtweetgeoplaceid.h
|
||||
qtweetlib/src/qtweetgeoplacecreate.h
|
||||
qtweetlib/src/qtweetgeocoord.h
|
||||
qtweetlib/src/qtweetgeoboundingbox.h
|
||||
qtweetlib/src/qtweetconvert.h
|
||||
qtweetlib/src/qtweetentityurl.h
|
||||
qtweetlib/src/qtweetentityhashtag.h
|
||||
qtweetlib/src/qtweetentityusermentions.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
.
|
||||
${QT_INCLUDE_DIR}
|
||||
${QT_INCLUDES}
|
||||
qtweetlib/src
|
||||
)
|
||||
|
||||
qt4_wrap_cpp( TOMAHAWK_QTWEETLIB_MOC ${TOMAHAWK_QTWEETLIB_HEADERS} )
|
||||
|
||||
ADD_LIBRARY(tomahawk_qtweetlib SHARED ${TOMAHAWK_QTWEETLIB_SOURCES} ${TOMAHAWK_QTWEETLIB_MOC})
|
||||
|
||||
target_link_libraries(tomahawk_qtweetlib
|
||||
${QT_LIBRARIES}
|
||||
qjson
|
||||
)
|
||||
|
||||
SET_TARGET_PROPERTIES( tomahawk_qtweetlib PROPERTIES DEFINE_SYMBOL MAKE_QTWEETLIB_LIB )
|
||||
|
||||
INCLUDE( ${CMAKE_CURRENT_SOURCE_DIR}/twitter-api-keys )
|
||||
|
||||
INSTALL(TARGETS tomahawk_qtweetlib DESTINATION lib)
|
||||
|
||||
|
459
thirdparty/qtweetlib/qtweetlib/LICENSE
vendored
Normal file
459
thirdparty/qtweetlib/qtweetlib/LICENSE
vendored
Normal file
@@ -0,0 +1,459 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
10
thirdparty/qtweetlib/qtweetlib/QTweetLib.pro
vendored
Normal file
10
thirdparty/qtweetlib/qtweetlib/QTweetLib.pro
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = sub_qjson sub_src sub_examples
|
||||
|
||||
sub_qjson.subdir = qjson
|
||||
|
||||
sub_src.subdir = src
|
||||
sub_src.depends = sub_qjson
|
||||
|
||||
sub_examples.subdir = examples
|
||||
sub_examples.depends = sub_src
|
12
thirdparty/qtweetlib/qtweetlib/README
vendored
Normal file
12
thirdparty/qtweetlib/qtweetlib/README
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
- Supports only XAuth protocol (if there is need for PIN based OAuth I will include it)
|
||||
- OAuth tokens must be set in oauth.cpp line 27 and 28 to work properly
|
||||
- Uses QJson library by Flavio Castelli for parsing JSON responses
|
||||
- JSON parsing is done in multithreaded way using QThreadPool
|
||||
- User Streams support is not completed (fetches responses correctly, JSON parsing is not full implemented)
|
||||
|
||||
Requirements and dependencies:
|
||||
- Qt needs to be compiled with OpenSSL support (there are two places where is used https protocol)
|
||||
- You will also need xAuth privilege access to Twitter API ( see http://dev.twitter.com/pages/xauth )
|
||||
- Valid OAuth consumer tokens, put them in oauth.cpp line 27 and 28
|
||||
- If you have already access tokens ( see http://dev.twitter.com/pages/oauth_single_token ) put them directly
|
||||
with OAuthTwitter::setOAuthToken() and OAuthTwitter::setOAuthTokenSecret()
|
3
thirdparty/qtweetlib/qtweetlib/examples/examples.pro
vendored
Normal file
3
thirdparty/qtweetlib/qtweetlib/examples/examples.pro
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = search timelines statusupdate geosearch georeverse \
|
||||
followers userstream
|
56
thirdparty/qtweetlib/qtweetlib/examples/followers/FollowerDelegate.qml
vendored
Normal file
56
thirdparty/qtweetlib/qtweetlib/examples/followers/FollowerDelegate.qml
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
import Qt 4.7
|
||||
|
||||
Rectangle {
|
||||
property string name: "Twitter name"
|
||||
property string screenName: "Twitter screen name"
|
||||
property string description: "Twitter description"
|
||||
property string avatarUrl
|
||||
|
||||
width: ListView.view.width - 1;
|
||||
height: 100
|
||||
radius: 10
|
||||
border.width: 1
|
||||
border.color: "#000000"
|
||||
|
||||
Image {
|
||||
id: avatar
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
width: 48; height: 48
|
||||
anchors.leftMargin: 2
|
||||
anchors.topMargin: 2
|
||||
source: avatarUrl
|
||||
}
|
||||
|
||||
Text {
|
||||
id: screenNameText
|
||||
text: screenName
|
||||
anchors.leftMargin: 2
|
||||
anchors.topMargin: 2
|
||||
anchors.left: avatar.right
|
||||
anchors.top: parent.top
|
||||
}
|
||||
|
||||
Text {
|
||||
id: nameText
|
||||
text: name
|
||||
anchors.leftMargin: 2
|
||||
anchors.topMargin: 2
|
||||
anchors.top: screenNameText.bottom
|
||||
anchors.left: avatar.right
|
||||
}
|
||||
|
||||
Text {
|
||||
id: descriptionText
|
||||
text: description
|
||||
anchors.rightMargin: 2
|
||||
anchors.leftMargin: 2
|
||||
anchors.bottomMargin: 2
|
||||
anchors.topMargin: 2
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.top: avatar.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
wrapMode: "WordWrap"
|
||||
}
|
||||
}
|
19
thirdparty/qtweetlib/qtweetlib/examples/followers/FollowersList.qml
vendored
Normal file
19
thirdparty/qtweetlib/qtweetlib/examples/followers/FollowersList.qml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import Qt 4.7
|
||||
|
||||
//followersListModel - external
|
||||
|
||||
Item {
|
||||
ListView {
|
||||
id: followersListView
|
||||
width: parent.width; height: parent.height
|
||||
clip: true
|
||||
model: followersListModel
|
||||
delegate: FollowerDelegate {
|
||||
id: followerDelegate
|
||||
name: nameRole
|
||||
screenName: screenNameRole
|
||||
description: descriptionRole
|
||||
avatarUrl: avatarRole
|
||||
}
|
||||
}
|
||||
}
|
67
thirdparty/qtweetlib/qtweetlib/examples/followers/followers.cpp
vendored
Normal file
67
thirdparty/qtweetlib/qtweetlib/examples/followers/followers.cpp
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#include "followers.h"
|
||||
#include "ui_followers.h"
|
||||
#include <QDeclarativeContext>
|
||||
#include <QNetworkAccessManager>
|
||||
#include "followerslistmodel.h"
|
||||
#include "oauthtwitter.h"
|
||||
|
||||
Followers::Followers(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Followers)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_oauthTwitter = new OAuthTwitter(this);
|
||||
m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this));
|
||||
m_oauthTwitter->setOAuthToken("");
|
||||
m_oauthTwitter->setOAuthTokenSecret("");
|
||||
|
||||
m_followersListModel = new FollowersListModel(m_oauthTwitter, this);
|
||||
|
||||
ui->declarativeView->rootContext()->setContextProperty("followersListModel", m_followersListModel);
|
||||
ui->declarativeView->setSource(QUrl("qrc:/FollowersList.qml"));
|
||||
|
||||
connect(ui->fetchFollowersPushButton, SIGNAL(clicked()), SLOT(onFetchFollowersPushButtonClicked()));
|
||||
}
|
||||
|
||||
Followers::~Followers()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Followers::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Followers::onFetchFollowersPushButtonClicked()
|
||||
{
|
||||
m_followersListModel->fetchFollowers();
|
||||
}
|
53
thirdparty/qtweetlib/qtweetlib/examples/followers/followers.h
vendored
Normal file
53
thirdparty/qtweetlib/qtweetlib/examples/followers/followers.h
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef FOLLOWERS_H
|
||||
#define FOLLOWERS_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class OAuthTwitter;
|
||||
class FollowersListModel;
|
||||
|
||||
namespace Ui {
|
||||
class Followers;
|
||||
}
|
||||
|
||||
class Followers : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Followers(QWidget *parent = 0);
|
||||
~Followers();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private slots:
|
||||
void onFetchFollowersPushButtonClicked();
|
||||
|
||||
private:
|
||||
Ui::Followers *ui;
|
||||
OAuthTwitter *m_oauthTwitter;
|
||||
FollowersListModel *m_followersListModel;
|
||||
};
|
||||
|
||||
#endif // FOLLOWERS_H
|
25
thirdparty/qtweetlib/qtweetlib/examples/followers/followers.pro
vendored
Normal file
25
thirdparty/qtweetlib/qtweetlib/examples/followers/followers.pro
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
QT += core gui network declarative
|
||||
|
||||
TARGET = followers
|
||||
TEMPLATE = app
|
||||
win32:LIBS += ../../lib/QTweetLib.lib
|
||||
INCLUDEPATH += ../../src
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
followers.cpp \
|
||||
followerslistmodel.cpp
|
||||
|
||||
HEADERS += \
|
||||
followers.h \
|
||||
followerslistmodel.h
|
||||
|
||||
FORMS += \
|
||||
followers.ui
|
||||
|
||||
OTHER_FILES += \
|
||||
FollowerDelegate.qml \
|
||||
FollowersList.qml
|
||||
|
||||
RESOURCES += \
|
||||
followers.qrc
|
6
thirdparty/qtweetlib/qtweetlib/examples/followers/followers.qrc
vendored
Normal file
6
thirdparty/qtweetlib/qtweetlib/examples/followers/followers.qrc
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>FollowerDelegate.qml</file>
|
||||
<file>FollowersList.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
42
thirdparty/qtweetlib/qtweetlib/examples/followers/followers.ui
vendored
Normal file
42
thirdparty/qtweetlib/qtweetlib/examples/followers/followers.ui
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Followers</class>
|
||||
<widget class="QWidget" name="Followers">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QDeclarativeView" name="declarativeView">
|
||||
<property name="resizeMode">
|
||||
<enum>QDeclarativeView::SizeRootObjectToView</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="fetchFollowersPushButton">
|
||||
<property name="text">
|
||||
<string>Fetch Followers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QDeclarativeView</class>
|
||||
<extends>QGraphicsView</extends>
|
||||
<header>QtDeclarative/QDeclarativeView</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
113
thirdparty/qtweetlib/qtweetlib/examples/followers/followerslistmodel.cpp
vendored
Normal file
113
thirdparty/qtweetlib/qtweetlib/examples/followers/followerslistmodel.cpp
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#include "followerslistmodel.h"
|
||||
#include "oauthtwitter.h"
|
||||
#include "qtweetuser.h"
|
||||
#include "qtweetuserstatusesfollowers.h"
|
||||
|
||||
FollowersListModel::FollowersListModel(QObject *parent) :
|
||||
QAbstractListModel(parent)
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[NameRole] = "nameRole";
|
||||
roles[ScreenNameRole] = "screenNameRole";
|
||||
roles[DescriptionRole] = "descriptionRole";
|
||||
roles[AvatarRole] = "avatarRole";
|
||||
setRoleNames(roles);
|
||||
}
|
||||
|
||||
FollowersListModel::FollowersListModel(OAuthTwitter *oauthTwitter, QObject *parent) :
|
||||
QAbstractListModel(parent)
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[NameRole] = "nameRole";
|
||||
roles[ScreenNameRole] = "screenNameRole";
|
||||
roles[DescriptionRole] = "descriptionRole";
|
||||
roles[AvatarRole] = "avatarRole";
|
||||
setRoleNames(roles);
|
||||
|
||||
m_oauthTwitter = oauthTwitter;
|
||||
}
|
||||
|
||||
void FollowersListModel::setOAuthTwitter(OAuthTwitter *oauthTwitter)
|
||||
{
|
||||
m_oauthTwitter = oauthTwitter;
|
||||
}
|
||||
|
||||
int FollowersListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return m_users.count();
|
||||
}
|
||||
|
||||
QVariant FollowersListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (index.row() < 0 || index.row() > m_users.count())
|
||||
return QVariant();
|
||||
|
||||
const QTweetUser &user = m_users.at(index.row());
|
||||
|
||||
if (role == NameRole)
|
||||
return user.name();
|
||||
else if (role == ScreenNameRole)
|
||||
return user.screenName();
|
||||
else if (role == DescriptionRole)
|
||||
return user.description();
|
||||
else if (role == AvatarRole)
|
||||
return user.profileImageUrl();
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void FollowersListModel::fetchFollowers(const QString &cursor)
|
||||
{
|
||||
if (cursor == "-1") {
|
||||
beginResetModel();
|
||||
m_users.clear();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
QTweetUserStatusesFollowers *followers = new QTweetUserStatusesFollowers;
|
||||
followers->setOAuthTwitter(m_oauthTwitter);
|
||||
followers->fetch(0, cursor, false);
|
||||
connect(followers, SIGNAL(parsedFollowersList(QList<QTweetUser>,QString)),
|
||||
this, SLOT(followersFinished(QList<QTweetUser>,QString)));
|
||||
|
||||
}
|
||||
|
||||
void FollowersListModel::followersFinished(const QList<QTweetUser> &followers, const QString &nextCursor)
|
||||
{
|
||||
QTweetUserStatusesFollowers *users = qobject_cast<QTweetUserStatusesFollowers*>(sender());
|
||||
|
||||
if (users) {
|
||||
beginInsertRows(QModelIndex(), m_users.count(), m_users.count() + followers.count());
|
||||
m_users.append(followers);
|
||||
endInsertRows();
|
||||
|
||||
if (nextCursor == "0")
|
||||
return;
|
||||
|
||||
//continue fetchingg next page
|
||||
fetchFollowers(nextCursor);
|
||||
|
||||
users->deleteLater();
|
||||
}
|
||||
}
|
56
thirdparty/qtweetlib/qtweetlib/examples/followers/followerslistmodel.h
vendored
Normal file
56
thirdparty/qtweetlib/qtweetlib/examples/followers/followerslistmodel.h
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef FOLLOWERSLISTMODEL_H
|
||||
#define FOLLOWERSLISTMODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
class OAuthTwitter;
|
||||
class QTweetUser;
|
||||
|
||||
class FollowersListModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Roles {
|
||||
NameRole = Qt::UserRole + 1,
|
||||
ScreenNameRole,
|
||||
DescriptionRole,
|
||||
AvatarRole
|
||||
};
|
||||
|
||||
FollowersListModel(QObject *parent = 0);
|
||||
FollowersListModel(OAuthTwitter *oauthTwitter, QObject *parent = 0);
|
||||
void setOAuthTwitter(OAuthTwitter *oauthTwitter);
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
void fetchFollowers(const QString& cursor = QString("-1"));
|
||||
|
||||
private slots:
|
||||
void followersFinished(const QList<QTweetUser>& followers,
|
||||
const QString& nextCursor);
|
||||
|
||||
private:
|
||||
OAuthTwitter *m_oauthTwitter;
|
||||
QList<QTweetUser> m_users;
|
||||
};
|
||||
|
||||
#endif // FOLLOWERSLISTMODEL_H
|
32
thirdparty/qtweetlib/qtweetlib/examples/followers/main.cpp
vendored
Normal file
32
thirdparty/qtweetlib/qtweetlib/examples/followers/main.cpp
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include "followers.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
Followers w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
106
thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.cpp
vendored
Normal file
106
thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.cpp
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include "oauthtwitter.h"
|
||||
#include "qtweetplace.h"
|
||||
#include "qtweetgeocoord.h"
|
||||
#include "qtweetgeoreversegeocode.h"
|
||||
#include "georeverse.h"
|
||||
#include "ui_georeverse.h"
|
||||
|
||||
GeoReverse::GeoReverse(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::GeoReverse)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_oauthTwitter = new OAuthTwitter(this);
|
||||
m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this));
|
||||
m_oauthTwitter->setOAuthToken("");
|
||||
m_oauthTwitter->setOAuthTokenSecret("");
|
||||
|
||||
QDoubleValidator *latValidator = new QDoubleValidator(ui->latitudeLineEdit);
|
||||
latValidator->setNotation(QDoubleValidator::StandardNotation);
|
||||
ui->latitudeLineEdit->setValidator(latValidator);
|
||||
|
||||
QDoubleValidator *longValidator = new QDoubleValidator(ui->longitudeLineEdit);
|
||||
longValidator->setNotation(QDoubleValidator::StandardNotation);
|
||||
ui->longitudeLineEdit->setValidator(longValidator);
|
||||
|
||||
connect(ui->searchPushButton, SIGNAL(clicked()), SLOT(onSearchPushButtonClicked()));
|
||||
}
|
||||
|
||||
GeoReverse::~GeoReverse()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void GeoReverse::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GeoReverse::onSearchPushButtonClicked()
|
||||
{
|
||||
QTweetGeoReverseGeoCode *reverseGeo = new QTweetGeoReverseGeoCode(m_oauthTwitter, this);
|
||||
reverseGeo->getPlaces(QTweetGeoCoord(ui->latitudeLineEdit->text().toDouble(),
|
||||
ui->longitudeLineEdit->text().toDouble()));
|
||||
connect(reverseGeo, SIGNAL(parsedPlaces(QList<QTweetPlace>)), SLOT(reverseGeoFinished(QList<QTweetPlace>)));
|
||||
}
|
||||
|
||||
void GeoReverse::reverseGeoFinished(const QList<QTweetPlace> &places)
|
||||
{
|
||||
QTweetGeoReverseGeoCode *reverseGeo = qobject_cast<QTweetGeoReverseGeoCode*>(sender());
|
||||
|
||||
if (reverseGeo) {
|
||||
ui->tableWidget->clear();
|
||||
ui->tableWidget->setRowCount(places.count());
|
||||
ui->tableWidget->setColumnCount(4);
|
||||
|
||||
int row = 0;
|
||||
foreach (const QTweetPlace& place, places) {
|
||||
QTableWidgetItem *fullname = new QTableWidgetItem(place.fullName());
|
||||
ui->tableWidget->setItem(row, 0, fullname);
|
||||
QTableWidgetItem *placeid = new QTableWidgetItem(place.id());
|
||||
ui->tableWidget->setItem(row, 1, placeid);
|
||||
|
||||
//QGeoBoundingBox bb = place.boundingBox();
|
||||
//QGeoCoordinate coord = bb.center();
|
||||
|
||||
//approximate, just shows center of the box
|
||||
//QTableWidgetItem *lat = new QTableWidgetItem(QString::number(coord.latitude()));
|
||||
//ui->tableWidget->setItem(row, 2, lat);
|
||||
//QTableWidgetItem *longit = new QTableWidgetItem(QString::number(coord.longitude()));
|
||||
//ui->tableWidget->setItem(row, 3, longit);
|
||||
//++row;
|
||||
}
|
||||
|
||||
reverseGeo->deleteLater();
|
||||
}
|
||||
}
|
54
thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.h
vendored
Normal file
54
thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.h
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef GEOREVERSE_H
|
||||
#define GEOREVERSE_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class GeoReverse;
|
||||
}
|
||||
|
||||
class OAuthTwitter;
|
||||
class QTweetPlace;
|
||||
|
||||
class GeoReverse : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GeoReverse(QWidget *parent = 0);
|
||||
~GeoReverse();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private slots:
|
||||
void onSearchPushButtonClicked();
|
||||
void reverseGeoFinished(const QList<QTweetPlace>& places);
|
||||
|
||||
private:
|
||||
Ui::GeoReverse *ui;
|
||||
OAuthTwitter *m_oauthTwitter;
|
||||
|
||||
};
|
||||
|
||||
#endif // GEOREVERSE_H
|
18
thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.pro
vendored
Normal file
18
thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.pro
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
QT += core gui network
|
||||
|
||||
TARGET = georeverse
|
||||
TEMPLATE = app
|
||||
win32:LIBS += ../../lib/QTweetLib.lib
|
||||
INCLUDEPATH += ../../src
|
||||
CONFIG += mobility
|
||||
MOBILITY += location
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
georeverse.cpp
|
||||
|
||||
HEADERS += \
|
||||
georeverse.h
|
||||
|
||||
FORMS += \
|
||||
georeverse.ui
|
51
thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.ui
vendored
Normal file
51
thirdparty/qtweetlib/qtweetlib/examples/georeverse/georeverse.ui
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GeoReverse</class>
|
||||
<widget class="QWidget" name="GeoReverse">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>598</width>
|
||||
<height>506</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="5">
|
||||
<widget class="QTableWidget" name="tableWidget"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Latitude</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="latitudeLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Longitude</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLineEdit" name="longitudeLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QPushButton" name="searchPushButton">
|
||||
<property name="text">
|
||||
<string>Reverse geosearch</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
32
thirdparty/qtweetlib/qtweetlib/examples/georeverse/main.cpp
vendored
Normal file
32
thirdparty/qtweetlib/qtweetlib/examples/georeverse/main.cpp
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include "georeverse.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
GeoReverse w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
102
thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.cpp
vendored
Normal file
102
thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.cpp
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QDoubleValidator>
|
||||
#include "oauthtwitter.h"
|
||||
#include "qtweetplace.h"
|
||||
#include "qtweetgeosearch.h"
|
||||
#include "geosearch.h"
|
||||
#include "qtweetgeocoord.h"
|
||||
#include "ui_geosearch.h"
|
||||
|
||||
GeoSearch::GeoSearch(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::GeoSearch)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_oauthTwitter = new OAuthTwitter(this);
|
||||
m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this));
|
||||
m_oauthTwitter->setOAuthToken("");
|
||||
m_oauthTwitter->setOAuthTokenSecret("");
|
||||
|
||||
QDoubleValidator *latValidator = new QDoubleValidator(ui->latitudeLineEdit);
|
||||
latValidator->setNotation(QDoubleValidator::StandardNotation);
|
||||
ui->latitudeLineEdit->setValidator(latValidator);
|
||||
|
||||
QDoubleValidator *longValidator = new QDoubleValidator(ui->longitudeLineEdit);
|
||||
longValidator->setNotation(QDoubleValidator::StandardNotation);
|
||||
ui->longitudeLineEdit->setValidator(longValidator);
|
||||
|
||||
connect(ui->searchPushButton, SIGNAL(clicked()), SLOT(onSearchPushButtonClicked()));
|
||||
}
|
||||
|
||||
GeoSearch::~GeoSearch()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void GeoSearch::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GeoSearch::onSearchPushButtonClicked()
|
||||
{
|
||||
QTweetGeoSearch *geoSearch = new QTweetGeoSearch(m_oauthTwitter, this);
|
||||
QTweetGeoCoord latLong;
|
||||
latLong.setLatitude(ui->latitudeLineEdit->text().toDouble());
|
||||
latLong.setLongitude(ui->longitudeLineEdit->text().toDouble());
|
||||
|
||||
geoSearch->search(latLong);
|
||||
connect(geoSearch, SIGNAL(parsedPlaces(QList<QTweetPlace>)), SLOT(searchPlacesFinished(QList<QTweetPlace>)));
|
||||
}
|
||||
|
||||
void GeoSearch::searchPlacesFinished(const QList<QTweetPlace> &places)
|
||||
{
|
||||
QTweetGeoSearch *geoSearch = qobject_cast<QTweetGeoSearch*>(sender());
|
||||
|
||||
if (geoSearch) {
|
||||
ui->tableWidget->clear();
|
||||
ui->tableWidget->setRowCount(places.count());
|
||||
ui->tableWidget->setColumnCount(2);
|
||||
|
||||
int row = 0;
|
||||
foreach (const QTweetPlace& place, places) {
|
||||
QTableWidgetItem *fullname = new QTableWidgetItem(place.fullName());
|
||||
ui->tableWidget->setItem(row, 0, fullname);
|
||||
QTableWidgetItem *placeid = new QTableWidgetItem(place.id());
|
||||
ui->tableWidget->setItem(row, 1, placeid);
|
||||
|
||||
++row;
|
||||
}
|
||||
|
||||
geoSearch->deleteLater();
|
||||
|
||||
}
|
||||
}
|
53
thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.h
vendored
Normal file
53
thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.h
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef GEOSEARCH_H
|
||||
#define GEOSEARCH_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class GeoSearch;
|
||||
}
|
||||
|
||||
class OAuthTwitter;
|
||||
class QTweetPlace;
|
||||
|
||||
class GeoSearch : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GeoSearch(QWidget *parent = 0);
|
||||
~GeoSearch();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private slots:
|
||||
void onSearchPushButtonClicked();
|
||||
void searchPlacesFinished(const QList<QTweetPlace>& places);
|
||||
|
||||
private:
|
||||
Ui::GeoSearch *ui;
|
||||
OAuthTwitter *m_oauthTwitter;
|
||||
};
|
||||
|
||||
#endif // GEOSEARCH_H
|
18
thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.pro
vendored
Normal file
18
thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.pro
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
QT += core gui network
|
||||
|
||||
TARGET = geosearch
|
||||
TEMPLATE = app
|
||||
win32:LIBS += ../../lib/QTweetLib.lib
|
||||
INCLUDEPATH += ../../src
|
||||
CONFIG += mobility
|
||||
MOBILITY += location
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
geosearch.cpp
|
||||
|
||||
HEADERS += \
|
||||
geosearch.h
|
||||
|
||||
FORMS += \
|
||||
geosearch.ui
|
55
thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.ui
vendored
Normal file
55
thirdparty/qtweetlib/qtweetlib/examples/geosearch/geosearch.ui
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GeoSearch</class>
|
||||
<widget class="QWidget" name="GeoSearch">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>616</width>
|
||||
<height>434</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="5">
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Latitude</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="latitudeLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Longitude</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLineEdit" name="longitudeLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QPushButton" name="searchPushButton">
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
32
thirdparty/qtweetlib/qtweetlib/examples/geosearch/main.cpp
vendored
Normal file
32
thirdparty/qtweetlib/qtweetlib/examples/geosearch/main.cpp
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include "geosearch.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
GeoSearch w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
31
thirdparty/qtweetlib/qtweetlib/examples/search/main.cpp
vendored
Normal file
31
thirdparty/qtweetlib/qtweetlib/examples/search/main.cpp
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
100
thirdparty/qtweetlib/qtweetlib/examples/search/mainwindow.cpp
vendored
Normal file
100
thirdparty/qtweetlib/qtweetlib/examples/search/mainwindow.cpp
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QDateTime>
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "oauthtwitter.h"
|
||||
#include "qtweetsearch.h"
|
||||
#include "qtweetsearchpageresults.h"
|
||||
#include "qtweetsearchresult.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_oauthTwitter = new OAuthTwitter(this);
|
||||
m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this));
|
||||
|
||||
connect(ui->startSearchButton, SIGNAL(clicked()), this, SLOT(searchButtonClicked()));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::searchButtonClicked()
|
||||
{
|
||||
QTweetSearch *twitSearch = new QTweetSearch(m_oauthTwitter, m_oauthTwitter);
|
||||
twitSearch->setAuthenticationEnabled(false);
|
||||
twitSearch->start(ui->queryLineEdit->text());
|
||||
connect(twitSearch, SIGNAL(parsedPageResults(QTweetSearchPageResults)),
|
||||
this, SLOT(finishedSearch(QTweetSearchPageResults)));
|
||||
}
|
||||
|
||||
void MainWindow::finishedSearch(const QTweetSearchPageResults &results)
|
||||
{
|
||||
QTweetSearch *twitSearch = qobject_cast<QTweetSearch*>(sender());
|
||||
|
||||
if (twitSearch) {
|
||||
ui->resultsTextEdit->append("maxid: " + QString::number(results.maxid()));
|
||||
ui->resultsTextEdit->append("next page: " + results.nextPage());
|
||||
ui->resultsTextEdit->append("page: " + QString::number(results.page()));
|
||||
ui->resultsTextEdit->append("query: " + results.query());
|
||||
ui->resultsTextEdit->append("refresh url: " + results.refreshUrl());
|
||||
ui->resultsTextEdit->append("rpp: " + QString::number(results.resultsPerPage()));
|
||||
ui->resultsTextEdit->append("sinceid: " + QString::number(results.sinceid()));
|
||||
ui->resultsTextEdit->append("total: " + QString::number(results.total()));
|
||||
|
||||
QList<QTweetSearchResult> listResults = results.results();
|
||||
|
||||
ui->resultsTextEdit->append("results: \n");
|
||||
|
||||
foreach (const QTweetSearchResult& singleResult, listResults) {
|
||||
ui->resultsTextEdit->append("created: " + singleResult.createdAt().toString());
|
||||
ui->resultsTextEdit->append("from user: " + singleResult.fromUser());
|
||||
ui->resultsTextEdit->append("id: " + QString::number(singleResult.id()));
|
||||
ui->resultsTextEdit->append("lang: " + singleResult.lang());
|
||||
ui->resultsTextEdit->append("avatar url: " + singleResult.profileImageUrl());
|
||||
ui->resultsTextEdit->append("source: " + singleResult.source());
|
||||
ui->resultsTextEdit->append("text: " + singleResult.text());
|
||||
ui->resultsTextEdit->append("to user: " + singleResult.toUser());
|
||||
ui->resultsTextEdit->append("-------");
|
||||
}
|
||||
|
||||
twitSearch->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::changeEvent(QEvent *e)
|
||||
{
|
||||
QMainWindow::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
53
thirdparty/qtweetlib/qtweetlib/examples/search/mainwindow.h
vendored
Normal file
53
thirdparty/qtweetlib/qtweetlib/examples/search/mainwindow.h
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class OAuthTwitter;
|
||||
class QTweetSearchPageResults;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private slots:
|
||||
void searchButtonClicked();
|
||||
void finishedSearch(const QTweetSearchPageResults& results);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
OAuthTwitter* m_oauthTwitter;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
64
thirdparty/qtweetlib/qtweetlib/examples/search/mainwindow.ui
vendored
Normal file
64
thirdparty/qtweetlib/qtweetlib/examples/search/mainwindow.ui
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>621</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="resultsTextEdit">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Query:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="queryLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="startSearchButton">
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
17
thirdparty/qtweetlib/qtweetlib/examples/search/search.pro
vendored
Normal file
17
thirdparty/qtweetlib/qtweetlib/examples/search/search.pro
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
QT += core gui network
|
||||
|
||||
TARGET = searchexample
|
||||
TEMPLATE = app
|
||||
win32:LIBS += ../../lib/QTweetLib.lib
|
||||
INCLUDEPATH += ../../src
|
||||
|
||||
SOURCES +=\
|
||||
mainwindow.cpp \
|
||||
main.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
32
thirdparty/qtweetlib/qtweetlib/examples/statusupdate/main.cpp
vendored
Normal file
32
thirdparty/qtweetlib/qtweetlib/examples/statusupdate/main.cpp
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
117
thirdparty/qtweetlib/qtweetlib/examples/statusupdate/mainwindow.cpp
vendored
Normal file
117
thirdparty/qtweetlib/qtweetlib/examples/statusupdate/mainwindow.cpp
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QDoubleValidator>
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "oauthtwitter.h"
|
||||
#include "qtweetstatusupdate.h"
|
||||
#include "qtweetstatus.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
//m_authorized = false;
|
||||
|
||||
QDoubleValidator *latValidator = new QDoubleValidator(ui->latLineEdit);
|
||||
latValidator->setNotation(QDoubleValidator::StandardNotation);
|
||||
ui->latLineEdit->setValidator(latValidator);
|
||||
|
||||
QDoubleValidator *longValidator = new QDoubleValidator(ui->longLineEdit);
|
||||
longValidator->setNotation(QDoubleValidator::StandardNotation);
|
||||
ui->longLineEdit->setValidator(longValidator);
|
||||
|
||||
m_oauthTwitter = new OAuthTwitter(this);
|
||||
m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this));
|
||||
connect(m_oauthTwitter, SIGNAL(authorizeXAuthFinished()), SLOT(xauthFinished()));
|
||||
connect(m_oauthTwitter, SIGNAL(authorizeXAuthError()), SLOT(xauthError()));
|
||||
|
||||
connect(ui->authPushButton, SIGNAL(clicked()), SLOT(authorizeButtonClicked()));
|
||||
connect(ui->udpatePushButton, SIGNAL(clicked()), SLOT(updateButtonClicked()));
|
||||
|
||||
m_authorized = true;
|
||||
m_oauthTwitter->setOAuthToken("16290455-CPyk9D9hJoCghpw7zAE73IZ0g0XtbVHU7xbI5RJE2");
|
||||
m_oauthTwitter->setOAuthTokenSecret("NMCzZHio4YAB1ZrTsNP35HLHeN4Ze1GI3qT4zvMCctQ");
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::changeEvent(QEvent *e)
|
||||
{
|
||||
QMainWindow::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::authorizeButtonClicked()
|
||||
{
|
||||
m_oauthTwitter->authorizeXAuth(ui->userNameLineEdit->text(), ui->passwordLineEdit->text());
|
||||
}
|
||||
|
||||
void MainWindow::xauthFinished()
|
||||
{
|
||||
ui->statusbar->showMessage("XAuth succesfull!");
|
||||
m_authorized = true;
|
||||
}
|
||||
|
||||
void MainWindow::xauthError()
|
||||
{
|
||||
ui->statusbar->showMessage("XAuth failed");
|
||||
m_authorized = false;
|
||||
}
|
||||
|
||||
void MainWindow::updateButtonClicked()
|
||||
{
|
||||
if (m_authorized) {
|
||||
QTweetStatusUpdate *statusUpdate = new QTweetStatusUpdate(m_oauthTwitter, this);
|
||||
statusUpdate->post(ui->statusTextEdit->toPlainText(),
|
||||
0,
|
||||
QTweetGeoCoord(ui->latLineEdit->text().toDouble(), ui->longLineEdit->text().toDouble()),
|
||||
QString(),
|
||||
true);
|
||||
connect(statusUpdate, SIGNAL(postedStatus(QTweetStatus)), SLOT(postStatusFinished(QTweetStatus)));
|
||||
|
||||
} else {
|
||||
ui->statusbar->showMessage("You cannot post, needs autorization!");
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::postStatusFinished(const QTweetStatus &status)
|
||||
{
|
||||
QTweetStatusUpdate *statusUpdate = qobject_cast<QTweetStatusUpdate*>(sender());
|
||||
|
||||
if (statusUpdate) {
|
||||
ui->statusbar->showMessage("Posted status with id " + QString::number(status.id()));
|
||||
|
||||
statusUpdate->deleteLater();
|
||||
}
|
||||
}
|
57
thirdparty/qtweetlib/qtweetlib/examples/statusupdate/mainwindow.h
vendored
Normal file
57
thirdparty/qtweetlib/qtweetlib/examples/statusupdate/mainwindow.h
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class OAuthTwitter;
|
||||
class QTweetStatus;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private slots:
|
||||
void authorizeButtonClicked();
|
||||
void xauthFinished();
|
||||
void xauthError();
|
||||
void updateButtonClicked();
|
||||
void postStatusFinished(const QTweetStatus& status);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
OAuthTwitter *m_oauthTwitter;
|
||||
bool m_authorized;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
206
thirdparty/qtweetlib/qtweetlib/examples/statusupdate/mainwindow.ui
vendored
Normal file
206
thirdparty/qtweetlib/qtweetlib/examples/statusupdate/mainwindow.ui
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>541</width>
|
||||
<height>287</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Username:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="userNameLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="passwordLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="authPushButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Authorize</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Status text:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="statusTextEdit">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Latitude:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="latLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Longitude:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="longLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QPushButton" name="udpatePushButton">
|
||||
<property name="text">
|
||||
<string>Update</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
16
thirdparty/qtweetlib/qtweetlib/examples/statusupdate/statusupdate.pro
vendored
Normal file
16
thirdparty/qtweetlib/qtweetlib/examples/statusupdate/statusupdate.pro
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
QT += core gui network
|
||||
|
||||
TARGET = statusupdate
|
||||
TEMPLATE = app
|
||||
win32:LIBS += ../../lib/QTweetLib.lib
|
||||
INCLUDEPATH += ../../src
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
32
thirdparty/qtweetlib/qtweetlib/examples/timelines/main.cpp
vendored
Normal file
32
thirdparty/qtweetlib/qtweetlib/examples/timelines/main.cpp
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
224
thirdparty/qtweetlib/qtweetlib/examples/timelines/mainwindow.cpp
vendored
Normal file
224
thirdparty/qtweetlib/qtweetlib/examples/timelines/mainwindow.cpp
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "oauthtwitter.h"
|
||||
#include "qtweethometimeline.h"
|
||||
#include "qtweetmentions.h"
|
||||
#include "qtweetusertimeline.h"
|
||||
#include "qtweetdirectmessages.h"
|
||||
#include "qtweetstatus.h"
|
||||
#include "qtweetdmstatus.h"
|
||||
#include "qtweetuser.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_sinceidHomeTimeline = 0;
|
||||
m_sinceidMentions = 0;
|
||||
m_sinceidUserTimeline = 0;
|
||||
m_sinceidDirectMessages = 0;
|
||||
|
||||
m_oauthTwitter = new OAuthTwitter(this);
|
||||
m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this));
|
||||
connect(m_oauthTwitter, SIGNAL(authorizeXAuthFinished()), this, SLOT(xauthFinished()));
|
||||
connect(m_oauthTwitter, SIGNAL(authorizeXAuthError()), this, SLOT(xauthError()));
|
||||
|
||||
m_timer = new QTimer(this);
|
||||
m_timer->setInterval(60000);
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(timerTimeOut()));
|
||||
|
||||
connect(ui->authorizePushButton, SIGNAL(clicked()), this, SLOT(authorizeButtonClicked()));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::changeEvent(QEvent *e)
|
||||
{
|
||||
QMainWindow::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::authorizeButtonClicked()
|
||||
{
|
||||
m_oauthTwitter->authorizeXAuth(ui->usernameLineEdit->text(), ui->passwordLineEdit->text());
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::xauthFinished()
|
||||
{
|
||||
ui->statusBar->showMessage("xauth succesfull");
|
||||
m_timer->start();
|
||||
timerTimeOut();
|
||||
}
|
||||
|
||||
void MainWindow::xauthError()
|
||||
{
|
||||
ui->statusBar->showMessage("xauth failed");
|
||||
}
|
||||
|
||||
void MainWindow::timerTimeOut()
|
||||
{
|
||||
QTweetHomeTimeline *homeTimeline = new QTweetHomeTimeline(m_oauthTwitter, this);
|
||||
homeTimeline->fetch(m_sinceidHomeTimeline);
|
||||
connect(homeTimeline, SIGNAL(parsedStatuses(QList<QTweetStatus>)),
|
||||
this, SLOT(homeTimelineStatuses(QList<QTweetStatus>)));
|
||||
|
||||
QTweetMentions *mentions = new QTweetMentions(m_oauthTwitter, this);
|
||||
mentions->fetch(m_sinceidMentions);
|
||||
connect(mentions, SIGNAL(parsedStatuses(QList<QTweetStatus>)),
|
||||
this, SLOT(mentionsStatuses(QList<QTweetStatus>)));
|
||||
|
||||
QTweetUserTimeline *userTimeline = new QTweetUserTimeline(m_oauthTwitter, this);
|
||||
userTimeline->fetch(0, QString(), m_sinceidUserTimeline);
|
||||
connect(userTimeline, SIGNAL(parsedStatuses(QList<QTweetStatus>)),
|
||||
this, SLOT(userTimelineStatuses(QList<QTweetStatus>)));
|
||||
|
||||
QTweetDirectMessages *dmTimeline = new QTweetDirectMessages(m_oauthTwitter, this);
|
||||
dmTimeline->fetch(m_sinceidDirectMessages);
|
||||
connect(dmTimeline, SIGNAL(parsedDirectMessages(QList<QTweetDMStatus>)),
|
||||
this, SLOT(directMessages(QList<QTweetDMStatus>)));
|
||||
}
|
||||
|
||||
void MainWindow::homeTimelineStatuses(const QList<QTweetStatus> &statuses)
|
||||
{
|
||||
QTweetHomeTimeline *homeTimeline = qobject_cast<QTweetHomeTimeline*>(sender());
|
||||
|
||||
if (homeTimeline) {
|
||||
if (statuses.count()) {
|
||||
//order is messed up, but this is just example
|
||||
foreach (const QTweetStatus& status, statuses) {
|
||||
ui->homeTimelineTextEdit->append("id: " + QString::number(status.id()));
|
||||
ui->homeTimelineTextEdit->append("text: " + status.text());
|
||||
ui->homeTimelineTextEdit->append("created: " + status.createdAt().toString());
|
||||
|
||||
QTweetUser userinfo = status.user();
|
||||
|
||||
ui->homeTimelineTextEdit->append("screen name: " + userinfo.screenName());
|
||||
ui->homeTimelineTextEdit->append("user id: " + QString::number(userinfo.id()));
|
||||
|
||||
//is it retweet?
|
||||
QTweetStatus rtStatus = status.retweetedStatus();
|
||||
|
||||
if (rtStatus.id()) {
|
||||
ui->homeTimelineTextEdit->append("retweet text: " + rtStatus.text());
|
||||
}
|
||||
|
||||
ui->homeTimelineTextEdit->append("----------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
m_sinceidHomeTimeline = statuses.at(0).id();
|
||||
}
|
||||
|
||||
homeTimeline->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::mentionsStatuses(const QList<QTweetStatus> &statuses)
|
||||
{
|
||||
QTweetMentions *mentions = qobject_cast<QTweetMentions*>(sender());
|
||||
|
||||
if (mentions) {
|
||||
if (statuses.count()) {
|
||||
foreach (const QTweetStatus& status, statuses) {
|
||||
ui->mentionsTextEdit->append("id: " + QString::number(status.id()));
|
||||
ui->mentionsTextEdit->append("text: " + status.text());
|
||||
ui->mentionsTextEdit->append("created: " + status.createdAt().toString());
|
||||
|
||||
QTweetUser userinfo = status.user();
|
||||
|
||||
ui->mentionsTextEdit->append("screen name: " + userinfo.screenName());
|
||||
ui->mentionsTextEdit->append("user id: " + QString::number(userinfo.id()));
|
||||
|
||||
ui->mentionsTextEdit->append("----------------------------------------");
|
||||
}
|
||||
|
||||
m_sinceidMentions = statuses.at(0).id();
|
||||
}
|
||||
mentions->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::userTimelineStatuses(const QList<QTweetStatus> &statuses)
|
||||
{
|
||||
QTweetUserTimeline *userTimeline = qobject_cast<QTweetUserTimeline*>(sender());
|
||||
|
||||
if (userTimeline) {
|
||||
if (statuses.count()) {
|
||||
//order is messed up, but this is just example
|
||||
foreach (const QTweetStatus& status, statuses) {
|
||||
ui->userTimelineTextEdit->append("id: " + QString::number(status.id()));
|
||||
ui->userTimelineTextEdit->append("text: " + status.text());
|
||||
ui->userTimelineTextEdit->append("created: " + status.createdAt().toString());
|
||||
|
||||
QTweetUser userinfo = status.user();
|
||||
|
||||
ui->userTimelineTextEdit->append("screen name: " + userinfo.screenName());
|
||||
ui->userTimelineTextEdit->append("user id: " + QString::number(userinfo.id()));
|
||||
|
||||
ui->userTimelineTextEdit->append("----------------------------------------");
|
||||
}
|
||||
|
||||
m_sinceidUserTimeline = statuses.at(0).id();
|
||||
}
|
||||
|
||||
userTimeline->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::directMessages(const QList<QTweetDMStatus> &directMessages)
|
||||
{
|
||||
QTweetDirectMessages *dmTimeline = qobject_cast<QTweetDirectMessages*>(sender());
|
||||
|
||||
if (dmTimeline) {
|
||||
if (directMessages.count()) {
|
||||
foreach (const QTweetDMStatus& message, directMessages) {
|
||||
ui->directMessagesTextEdit->append("id: " + QString::number(message.id()));
|
||||
ui->directMessagesTextEdit->append("text: " + message.text());
|
||||
ui->directMessagesTextEdit->append("created: " + message.createdAt().toString());
|
||||
ui->directMessagesTextEdit->append("sender: " + message.senderScreenName());
|
||||
ui->directMessagesTextEdit->append("sender id: " + QString::number(message.senderId()));
|
||||
|
||||
ui->directMessagesTextEdit->append("----------------------------------------");
|
||||
}
|
||||
|
||||
m_sinceidDirectMessages = directMessages.at(0).id();
|
||||
}
|
||||
}
|
||||
|
||||
dmTimeline->deleteLater();
|
||||
}
|
67
thirdparty/qtweetlib/qtweetlib/examples/timelines/mainwindow.h
vendored
Normal file
67
thirdparty/qtweetlib/qtweetlib/examples/timelines/mainwindow.h
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class OAuthTwitter;
|
||||
class QTimer;
|
||||
class QTweetStatus;
|
||||
class QTweetDMStatus;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private slots:
|
||||
void authorizeButtonClicked();
|
||||
void xauthFinished();
|
||||
void xauthError();
|
||||
void timerTimeOut();
|
||||
void homeTimelineStatuses(const QList<QTweetStatus>& statuses);
|
||||
void mentionsStatuses(const QList<QTweetStatus>& statuses);
|
||||
void userTimelineStatuses(const QList<QTweetStatus>& statuses);
|
||||
void directMessages(const QList<QTweetDMStatus>& directMessages);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
OAuthTwitter *m_oauthTwitter;
|
||||
QTimer *m_timer;
|
||||
qint64 m_sinceidHomeTimeline;
|
||||
qint64 m_sinceidMentions;
|
||||
qint64 m_sinceidUserTimeline;
|
||||
qint64 m_sinceidDirectMessages;
|
||||
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
156
thirdparty/qtweetlib/qtweetlib/examples/timelines/mainwindow.ui
vendored
Normal file
156
thirdparty/qtweetlib/qtweetlib/examples/timelines/mainwindow.ui
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>627</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string> Home timeline</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextEdit" name="homeTimelineTextEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Mentions timeline</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextEdit" name="mentionsTextEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
<string>User timeline</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextEdit" name="userTimelineTextEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_4">
|
||||
<attribute name="title">
|
||||
<string>Direct Messages</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextEdit" name="directMessagesTextEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Username:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="usernameLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="passwordLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="authorizePushButton">
|
||||
<property name="text">
|
||||
<string>Authorize</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>368</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
16
thirdparty/qtweetlib/qtweetlib/examples/timelines/timelines.pro
vendored
Normal file
16
thirdparty/qtweetlib/qtweetlib/examples/timelines/timelines.pro
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
QT += core gui network
|
||||
|
||||
TARGET = timelines
|
||||
TEMPLATE = app
|
||||
win32:LIBS += ../../lib/QTweetLib.lib
|
||||
INCLUDEPATH += ../../src
|
||||
|
||||
SOURCES += \
|
||||
mainwindow.cpp \
|
||||
main.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
32
thirdparty/qtweetlib/qtweetlib/examples/userstream/main.cpp
vendored
Normal file
32
thirdparty/qtweetlib/qtweetlib/examples/userstream/main.cpp
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include "userstream.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
UserStream w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
110
thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.cpp
vendored
Normal file
110
thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.cpp
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#include "userstream.h"
|
||||
#include "ui_userstream.h"
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QTextStream>
|
||||
#include <QFile>
|
||||
#include "oauthtwitter.h"
|
||||
#include "qtweetuserstream.h"
|
||||
#include "qtweetstatus.h"
|
||||
#include "qtweetuser.h"
|
||||
|
||||
UserStream::UserStream(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::UserStream)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_oauthTwitter = new OAuthTwitter(new QNetworkAccessManager, this);
|
||||
connect(m_oauthTwitter, SIGNAL(authorizeXAuthFinished()), SLOT(onAuthorizeFinished()));
|
||||
connect(m_oauthTwitter, SIGNAL(authorizeXAuthError()), SLOT(onAuthorizeError()));
|
||||
|
||||
m_userStream = new QTweetUserStream(this);
|
||||
m_userStream->setOAuthTwitter(m_oauthTwitter);
|
||||
connect(m_userStream, SIGNAL(stream(QByteArray)), SLOT(stream(QByteArray)));
|
||||
connect(m_userStream, SIGNAL(statusesStream(QTweetStatus)), SLOT(statusStream(QTweetStatus)));
|
||||
|
||||
connect(ui->connectButton, SIGNAL(clicked()), SLOT(onConnectButtonClicked()));
|
||||
|
||||
//for internal purposes
|
||||
m_file.setFileName("logstream.txt");
|
||||
m_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
|
||||
m_streamlogger.setDevice(&m_file);
|
||||
|
||||
}
|
||||
|
||||
UserStream::~UserStream()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void UserStream::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UserStream::onConnectButtonClicked()
|
||||
{
|
||||
m_oauthTwitter->authorizeXAuth(ui->usernameLineEdit->text(), ui->passwordLineEdit->text());
|
||||
ui->infoTextBrowser->append("XAuth authorization started");
|
||||
ui->connectButton->setEnabled(false);
|
||||
}
|
||||
|
||||
void UserStream::onAuthorizeFinished()
|
||||
{
|
||||
ui->infoTextBrowser->append("XAuth authorization success.");
|
||||
ui->infoTextBrowser->append("oauth token: " + m_oauthTwitter->oauthToken());
|
||||
ui->infoTextBrowser->append("oauth token secret: " + m_oauthTwitter->oauthTokenSecret());
|
||||
ui->infoTextBrowser->append("Starting user stream fetching");
|
||||
|
||||
m_userStream->startFetching();
|
||||
}
|
||||
|
||||
void UserStream::onAuthorizeError()
|
||||
{
|
||||
ui->infoTextBrowser->append("XAuth authorization error");
|
||||
ui->connectButton->setEnabled(true);
|
||||
}
|
||||
|
||||
void UserStream::stream(const QByteArray &stream)
|
||||
{
|
||||
//for internal purposes
|
||||
m_streamlogger << stream << "\n";
|
||||
m_streamlogger << "################################################################" << "\n";
|
||||
m_streamlogger.flush();
|
||||
}
|
||||
|
||||
void UserStream::statusStream(const QTweetStatus &tweet)
|
||||
{
|
||||
ui->infoTextBrowser->append("New tweet");
|
||||
ui->infoTextBrowser->append("id: " + QString::number(tweet.id()));
|
||||
ui->infoTextBrowser->append("text: " + tweet.text());
|
||||
ui->infoTextBrowser->append("name: " + tweet.user().name());
|
||||
}
|
62
thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.h
vendored
Normal file
62
thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.h
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/* Copyright (c) 2010, Antonie Jovanoski
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef USERSTREAM_H
|
||||
#define USERSTREAM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTextStream>
|
||||
#include <QFile>
|
||||
|
||||
namespace Ui {
|
||||
class UserStream;
|
||||
}
|
||||
|
||||
class OAuthTwitter;
|
||||
class QTweetUserStream;
|
||||
class QTweetStatus;
|
||||
|
||||
class UserStream : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UserStream(QWidget *parent = 0);
|
||||
~UserStream();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private slots:
|
||||
void onConnectButtonClicked();
|
||||
void onAuthorizeFinished();
|
||||
void onAuthorizeError();
|
||||
void stream(const QByteArray& stream);
|
||||
void statusStream(const QTweetStatus& tweet);
|
||||
|
||||
private:
|
||||
Ui::UserStream *ui;
|
||||
OAuthTwitter *m_oauthTwitter;
|
||||
QTweetUserStream *m_userStream;
|
||||
QTextStream m_streamlogger;
|
||||
QFile m_file;
|
||||
};
|
||||
|
||||
#endif // USERSTREAM_H
|
17
thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.pro
vendored
Normal file
17
thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.pro
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
QT += core gui network
|
||||
|
||||
TARGET = userstream
|
||||
TEMPLATE = app
|
||||
win32:LIBS += ../../lib/QTweetLib.lib
|
||||
INCLUDEPATH += ../../src
|
||||
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
userstream.cpp
|
||||
|
||||
HEADERS += \
|
||||
userstream.h
|
||||
|
||||
FORMS += \
|
||||
userstream.ui
|
63
thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.ui
vendored
Normal file
63
thirdparty/qtweetlib/qtweetlib/examples/userstream/userstream.ui
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>UserStream</class>
|
||||
<widget class="QWidget" name="UserStream">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>418</width>
|
||||
<height>529</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="infoTextBrowser"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Username:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="usernameLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="passwordLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="connectButton">
|
||||
<property name="text">
|
||||
<string>Connect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
1116
thirdparty/qtweetlib/qtweetlib/qjson/json_parser.cc
vendored
Normal file
1116
thirdparty/qtweetlib/qtweetlib/qjson/json_parser.cc
vendored
Normal file
File diff suppressed because it is too large
Load Diff
325
thirdparty/qtweetlib/qtweetlib/qjson/json_parser.hh
vendored
Normal file
325
thirdparty/qtweetlib/qtweetlib/qjson/json_parser.hh
vendored
Normal file
@@ -0,0 +1,325 @@
|
||||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
|
||||
/* Skeleton interface for Bison LALR(1) parsers in C++
|
||||
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/* C++ LALR(1) parser skeleton written by Akim Demaille. */
|
||||
|
||||
#ifndef PARSER_HEADER_H
|
||||
# define PARSER_HEADER_H
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "stack.hh"
|
||||
|
||||
namespace yy
|
||||
{
|
||||
class position;
|
||||
class location;
|
||||
}
|
||||
|
||||
/* First part of user declarations. */
|
||||
#line 25 "json_parser.yy"
|
||||
|
||||
#include "parser_p.h"
|
||||
#include "json_scanner.h"
|
||||
#include "qjson_debug.h"
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
#include <limits>
|
||||
|
||||
class JSonScanner;
|
||||
|
||||
namespace QJson {
|
||||
class Parser;
|
||||
}
|
||||
|
||||
#define YYERROR_VERBOSE 1
|
||||
|
||||
|
||||
/* Line 35 of lalr1.cc. */
|
||||
#line 75 "json_parser.hh"
|
||||
|
||||
#include "location.hh"
|
||||
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 1
|
||||
#endif
|
||||
|
||||
/* Enabling verbose error messages. */
|
||||
#ifdef YYERROR_VERBOSE
|
||||
# undef YYERROR_VERBOSE
|
||||
# define YYERROR_VERBOSE 1
|
||||
#else
|
||||
# define YYERROR_VERBOSE 1
|
||||
#endif
|
||||
|
||||
/* Enabling the token table. */
|
||||
#ifndef YYTOKEN_TABLE
|
||||
# define YYTOKEN_TABLE 0
|
||||
#endif
|
||||
|
||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||
If N is 0, then set CURRENT to the empty location which ends
|
||||
the previous symbol: RHS[0] (always defined). */
|
||||
|
||||
#ifndef YYLLOC_DEFAULT
|
||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
do { \
|
||||
if (N) \
|
||||
{ \
|
||||
(Current).begin = (Rhs)[1].begin; \
|
||||
(Current).end = (Rhs)[N].end; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(Current).begin = (Current).end = (Rhs)[0].end; \
|
||||
} \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
namespace yy
|
||||
{
|
||||
|
||||
/// A Bison parser.
|
||||
class json_parser
|
||||
{
|
||||
public:
|
||||
/// Symbol semantic values.
|
||||
#ifndef YYSTYPE
|
||||
typedef int semantic_type;
|
||||
#else
|
||||
typedef YYSTYPE semantic_type;
|
||||
#endif
|
||||
/// Symbol locations.
|
||||
typedef location location_type;
|
||||
/// Tokens.
|
||||
struct token
|
||||
{
|
||||
/* Tokens. */
|
||||
enum yytokentype {
|
||||
END = 0,
|
||||
CURLY_BRACKET_OPEN = 1,
|
||||
CURLY_BRACKET_CLOSE = 2,
|
||||
SQUARE_BRACKET_OPEN = 3,
|
||||
SQUARE_BRACKET_CLOSE = 4,
|
||||
COLON = 5,
|
||||
COMMA = 6,
|
||||
MINUS = 7,
|
||||
DOT = 8,
|
||||
DIGIT = 9,
|
||||
E = 10,
|
||||
TRUE_VAL = 11,
|
||||
FALSE_VAL = 12,
|
||||
NULL_VAL = 13,
|
||||
QUOTMARKOPEN = 14,
|
||||
QUOTMARKCLOSE = 15,
|
||||
STRING = 16,
|
||||
INFINITY_VAL = 17,
|
||||
NAN_VAL = 18
|
||||
};
|
||||
|
||||
};
|
||||
/// Token type.
|
||||
typedef token::yytokentype token_type;
|
||||
|
||||
/// Build a parser object.
|
||||
json_parser (QJson::ParserPrivate* driver_yyarg);
|
||||
virtual ~json_parser ();
|
||||
|
||||
/// Parse.
|
||||
/// \returns 0 iff parsing succeeded.
|
||||
virtual int parse ();
|
||||
|
||||
/// The current debugging stream.
|
||||
std::ostream& debug_stream () const;
|
||||
/// Set the current debugging stream.
|
||||
void set_debug_stream (std::ostream &);
|
||||
|
||||
/// Type for debugging levels.
|
||||
typedef int debug_level_type;
|
||||
/// The current debugging level.
|
||||
debug_level_type debug_level () const;
|
||||
/// Set the current debugging level.
|
||||
void set_debug_level (debug_level_type l);
|
||||
|
||||
private:
|
||||
/// Report a syntax error.
|
||||
/// \param loc where the syntax error is found.
|
||||
/// \param msg a description of the syntax error.
|
||||
virtual void error (const location_type& loc, const std::string& msg);
|
||||
|
||||
/// Generate an error message.
|
||||
/// \param state the state where the error occurred.
|
||||
/// \param tok the look-ahead token.
|
||||
virtual std::string yysyntax_error_ (int yystate, int tok);
|
||||
|
||||
#if YYDEBUG
|
||||
/// \brief Report a symbol value on the debug stream.
|
||||
/// \param yytype The token type.
|
||||
/// \param yyvaluep Its semantic value.
|
||||
/// \param yylocationp Its location.
|
||||
virtual void yy_symbol_value_print_ (int yytype,
|
||||
const semantic_type* yyvaluep,
|
||||
const location_type* yylocationp);
|
||||
/// \brief Report a symbol on the debug stream.
|
||||
/// \param yytype The token type.
|
||||
/// \param yyvaluep Its semantic value.
|
||||
/// \param yylocationp Its location.
|
||||
virtual void yy_symbol_print_ (int yytype,
|
||||
const semantic_type* yyvaluep,
|
||||
const location_type* yylocationp);
|
||||
#endif /* ! YYDEBUG */
|
||||
|
||||
|
||||
/// State numbers.
|
||||
typedef int state_type;
|
||||
/// State stack type.
|
||||
typedef stack<state_type> state_stack_type;
|
||||
/// Semantic value stack type.
|
||||
typedef stack<semantic_type> semantic_stack_type;
|
||||
/// location stack type.
|
||||
typedef stack<location_type> location_stack_type;
|
||||
|
||||
/// The state stack.
|
||||
state_stack_type yystate_stack_;
|
||||
/// The semantic value stack.
|
||||
semantic_stack_type yysemantic_stack_;
|
||||
/// The location stack.
|
||||
location_stack_type yylocation_stack_;
|
||||
|
||||
/// Internal symbol numbers.
|
||||
typedef unsigned char token_number_type;
|
||||
/* Tables. */
|
||||
/// For a state, the index in \a yytable_ of its portion.
|
||||
static const signed char yypact_[];
|
||||
static const signed char yypact_ninf_;
|
||||
|
||||
/// For a state, default rule to reduce.
|
||||
/// Unless\a yytable_ specifies something else to do.
|
||||
/// Zero means the default is an error.
|
||||
static const unsigned char yydefact_[];
|
||||
|
||||
static const signed char yypgoto_[];
|
||||
static const signed char yydefgoto_[];
|
||||
|
||||
/// What to do in a state.
|
||||
/// \a yytable_[yypact_[s]]: what to do in state \a s.
|
||||
/// - if positive, shift that token.
|
||||
/// - if negative, reduce the rule which number is the opposite.
|
||||
/// - if zero, do what YYDEFACT says.
|
||||
static const unsigned char yytable_[];
|
||||
static const signed char yytable_ninf_;
|
||||
|
||||
static const signed char yycheck_[];
|
||||
|
||||
/// For a state, its accessing symbol.
|
||||
static const unsigned char yystos_[];
|
||||
|
||||
/// For a rule, its LHS.
|
||||
static const unsigned char yyr1_[];
|
||||
/// For a rule, its RHS length.
|
||||
static const unsigned char yyr2_[];
|
||||
|
||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
||||
/// For a symbol, its name in clear.
|
||||
static const char* const yytname_[];
|
||||
#endif
|
||||
|
||||
#if YYERROR_VERBOSE
|
||||
/// Convert the symbol name \a n to a form suitable for a diagnostic.
|
||||
virtual std::string yytnamerr_ (const char *n);
|
||||
#endif
|
||||
|
||||
#if YYDEBUG
|
||||
/// A type to store symbol numbers and -1.
|
||||
typedef signed char rhs_number_type;
|
||||
/// A `-1'-separated list of the rules' RHS.
|
||||
static const rhs_number_type yyrhs_[];
|
||||
/// For each rule, the index of the first RHS symbol in \a yyrhs_.
|
||||
static const unsigned char yyprhs_[];
|
||||
/// For each rule, its source line number.
|
||||
static const unsigned char yyrline_[];
|
||||
/// For each scanner token number, its symbol number.
|
||||
static const unsigned short int yytoken_number_[];
|
||||
/// Report on the debug stream that the rule \a r is going to be reduced.
|
||||
virtual void yy_reduce_print_ (int r);
|
||||
/// Print the state stack on the debug stream.
|
||||
virtual void yystack_print_ ();
|
||||
#endif
|
||||
|
||||
/// Convert a scanner token number \a t to a symbol number.
|
||||
token_number_type yytranslate_ (int t);
|
||||
|
||||
/// \brief Reclaim the memory associated to a symbol.
|
||||
/// \param yymsg Why this token is reclaimed.
|
||||
/// \param yytype The symbol type.
|
||||
/// \param yyvaluep Its semantic value.
|
||||
/// \param yylocationp Its location.
|
||||
inline void yydestruct_ (const char* yymsg,
|
||||
int yytype,
|
||||
semantic_type* yyvaluep,
|
||||
location_type* yylocationp);
|
||||
|
||||
/// Pop \a n symbols the three stacks.
|
||||
inline void yypop_ (unsigned int n = 1);
|
||||
|
||||
/* Constants. */
|
||||
static const int yyeof_;
|
||||
/* LAST_ -- Last index in TABLE_. */
|
||||
static const int yylast_;
|
||||
static const int yynnts_;
|
||||
static const int yyempty_;
|
||||
static const int yyfinal_;
|
||||
static const int yyterror_;
|
||||
static const int yyerrcode_;
|
||||
static const int yyntokens_;
|
||||
static const unsigned int yyuser_token_number_max_;
|
||||
static const token_number_type yyundef_token_;
|
||||
|
||||
/* Debugging. */
|
||||
int yydebug_;
|
||||
std::ostream* yycdebug_;
|
||||
|
||||
|
||||
/* User arguments. */
|
||||
QJson::ParserPrivate* driver;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif /* ! defined PARSER_HEADER_H */
|
219
thirdparty/qtweetlib/qtweetlib/qjson/json_parser.yy
vendored
Normal file
219
thirdparty/qtweetlib/qtweetlib/qjson/json_parser.yy
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
/* This file is part of QJSon
|
||||
*
|
||||
* Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
%skeleton "lalr1.cc"
|
||||
%defines
|
||||
%define "parser_class_name" "json_parser"
|
||||
|
||||
%{
|
||||
#include "parser_p.h"
|
||||
#include "json_scanner.h"
|
||||
#include "qjson_debug.h"
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
#include <limits>
|
||||
|
||||
class JSonScanner;
|
||||
|
||||
namespace QJson {
|
||||
class Parser;
|
||||
}
|
||||
|
||||
#define YYERROR_VERBOSE 1
|
||||
%}
|
||||
|
||||
%parse-param { QJson::ParserPrivate* driver }
|
||||
%lex-param { QJson::ParserPrivate* driver }
|
||||
|
||||
%locations
|
||||
|
||||
%debug
|
||||
%error-verbose
|
||||
|
||||
%token END 0 "end of file"
|
||||
|
||||
%token CURLY_BRACKET_OPEN 1 "{"
|
||||
%token CURLY_BRACKET_CLOSE 2 "}"
|
||||
%token SQUARE_BRACKET_OPEN 3 "["
|
||||
%token SQUARE_BRACKET_CLOSE 4 "]"
|
||||
|
||||
%token COLON 5 ":"
|
||||
%token COMMA 6 ","
|
||||
%token MINUS 7 "-"
|
||||
%token DOT 8 "."
|
||||
%token DIGIT 9 "digit"
|
||||
%token E 10 "exponential"
|
||||
%token TRUE_VAL 11 "true"
|
||||
%token FALSE_VAL 12 "false"
|
||||
%token NULL_VAL 13 "null"
|
||||
%token QUOTMARKOPEN 14 "open quotation mark"
|
||||
%token QUOTMARKCLOSE 15 "close quotation mark"
|
||||
|
||||
%token STRING 16 "string"
|
||||
%token INFINITY_VAL 17 "Infinity"
|
||||
%token NAN_VAL 18 "NaN"
|
||||
|
||||
// define the initial token
|
||||
%start start
|
||||
|
||||
%%
|
||||
|
||||
// grammar rules
|
||||
|
||||
start: data {
|
||||
driver->m_result = $1;
|
||||
qjsonDebug() << "json_parser - parsing finished";
|
||||
};
|
||||
|
||||
data: value { $$ = $1; }
|
||||
| error
|
||||
{
|
||||
qCritical()<< "json_parser - syntax error found, "
|
||||
<< "forcing abort, Line" << @$.begin.line << "Column" << @$.begin.column;
|
||||
YYABORT;
|
||||
}
|
||||
| END;
|
||||
|
||||
object: CURLY_BRACKET_OPEN members CURLY_BRACKET_CLOSE { $$ = $2; };
|
||||
|
||||
members: /* empty */ { $$ = QVariant (QVariantMap()); }
|
||||
| pair r_members {
|
||||
QVariantMap members = $2.toMap();
|
||||
$2 = QVariant(); // Allow reuse of map
|
||||
$$ = QVariant(members.unite ($1.toMap()));
|
||||
};
|
||||
|
||||
r_members: /* empty */ { $$ = QVariant (QVariantMap()); }
|
||||
| COMMA pair r_members {
|
||||
QVariantMap members = $3.toMap();
|
||||
$3 = QVariant(); // Allow reuse of map
|
||||
$$ = QVariant(members.unite ($2.toMap()));
|
||||
};
|
||||
|
||||
pair: string COLON value {
|
||||
QVariantMap pair;
|
||||
pair.insert ($1.toString(), QVariant($3));
|
||||
$$ = QVariant (pair);
|
||||
};
|
||||
|
||||
array: SQUARE_BRACKET_OPEN values SQUARE_BRACKET_CLOSE { $$ = $2; };
|
||||
|
||||
values: /* empty */ { $$ = QVariant (QVariantList()); }
|
||||
| value r_values {
|
||||
QVariantList members = $2.toList();
|
||||
$2 = QVariant(); // Allow reuse of list
|
||||
members.prepend ($1);
|
||||
$$ = QVariant(members);
|
||||
};
|
||||
|
||||
r_values: /* empty */ { $$ = QVariant (QVariantList()); }
|
||||
| COMMA value r_values {
|
||||
QVariantList members = $3.toList();
|
||||
$3 = QVariant(); // Allow reuse of list
|
||||
members.prepend ($2);
|
||||
$$ = QVariant(members);
|
||||
};
|
||||
|
||||
value: string { $$ = $1; }
|
||||
| special_or_number { $$ = $1; }
|
||||
| object { $$ = $1; }
|
||||
| array { $$ = $1; }
|
||||
| TRUE_VAL { $$ = QVariant (true); }
|
||||
| FALSE_VAL { $$ = QVariant (false); }
|
||||
| NULL_VAL {
|
||||
QVariant null_variant;
|
||||
$$ = null_variant;
|
||||
};
|
||||
|
||||
special_or_number: MINUS INFINITY_VAL { $$ = QVariant(QVariant::Double); $$.setValue( -std::numeric_limits<double>::infinity() ); }
|
||||
| INFINITY_VAL { $$ = QVariant(QVariant::Double); $$.setValue( std::numeric_limits<double>::infinity() ); }
|
||||
| NAN_VAL { $$ = QVariant(QVariant::Double); $$.setValue( std::numeric_limits<double>::quiet_NaN() ); }
|
||||
| number;
|
||||
|
||||
number: int {
|
||||
if ($1.toByteArray().startsWith('-')) {
|
||||
$$ = QVariant (QVariant::LongLong);
|
||||
$$.setValue($1.toLongLong());
|
||||
}
|
||||
else {
|
||||
$$ = QVariant (QVariant::ULongLong);
|
||||
$$.setValue($1.toULongLong());
|
||||
}
|
||||
}
|
||||
| int fract {
|
||||
const QByteArray value = $1.toByteArray() + $2.toByteArray();
|
||||
$$ = QVariant(QVariant::Double);
|
||||
$$.setValue(value.toDouble());
|
||||
}
|
||||
| int exp { $$ = QVariant ($1.toByteArray() + $2.toByteArray()); }
|
||||
| int fract exp {
|
||||
const QByteArray value = $1.toByteArray() + $2.toByteArray() + $3.toByteArray();
|
||||
$$ = QVariant (value);
|
||||
};
|
||||
|
||||
int: DIGIT digits { $$ = QVariant ($1.toByteArray() + $2.toByteArray()); }
|
||||
| MINUS DIGIT digits { $$ = QVariant (QByteArray("-") + $2.toByteArray() + $3.toByteArray()); };
|
||||
|
||||
digits: /* empty */ { $$ = QVariant (QByteArray("")); }
|
||||
| DIGIT digits {
|
||||
$$ = QVariant($1.toByteArray() + $2.toByteArray());
|
||||
};
|
||||
|
||||
fract: DOT digits {
|
||||
$$ = QVariant(QByteArray(".") + $2.toByteArray());
|
||||
};
|
||||
|
||||
exp: E digits { $$ = QVariant($1.toByteArray() + $2.toByteArray()); };
|
||||
|
||||
string: QUOTMARKOPEN string_arg QUOTMARKCLOSE { $$ = $2; };
|
||||
|
||||
string_arg: /*empty */ { $$ = QVariant (QString(QLatin1String(""))); }
|
||||
| STRING {
|
||||
$$ = $1;
|
||||
};
|
||||
|
||||
%%
|
||||
|
||||
int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver)
|
||||
{
|
||||
JSonScanner* scanner = driver->m_scanner;
|
||||
yylval->clear();
|
||||
int ret = scanner->yylex(yylval, yylloc);
|
||||
|
||||
qjsonDebug() << "json_parser::yylex - calling scanner yylval==|"
|
||||
<< yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void yy::json_parser::error (const yy::location& yyloc,
|
||||
const std::string& error)
|
||||
{
|
||||
/*qjsonDebug() << yyloc.begin.line;
|
||||
qjsonDebug() << yyloc.begin.column;
|
||||
qjsonDebug() << yyloc.end.line;
|
||||
qjsonDebug() << yyloc.end.column;*/
|
||||
qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ;
|
||||
driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line);
|
||||
}
|
377
thirdparty/qtweetlib/qtweetlib/qjson/json_scanner.cpp
vendored
Normal file
377
thirdparty/qtweetlib/qtweetlib/qjson/json_scanner.cpp
vendored
Normal file
@@ -0,0 +1,377 @@
|
||||
/* This file is part of QJson
|
||||
*
|
||||
* Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "qjson_debug.h"
|
||||
#include "json_scanner.h"
|
||||
#include "json_parser.hh"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QRegExp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
bool ishexnstring(const QString& string) {
|
||||
for (int i = 0; i < string.length(); i++) {
|
||||
if (isxdigit(string[i] == 0))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
JSonScanner::JSonScanner(QIODevice* io)
|
||||
: m_allowSpecialNumbers(false),
|
||||
m_io (io)
|
||||
{
|
||||
m_quotmarkClosed = true;
|
||||
m_quotmarkCount = 0;
|
||||
}
|
||||
|
||||
void JSonScanner::allowSpecialNumbers(bool allow) {
|
||||
m_allowSpecialNumbers = allow;
|
||||
}
|
||||
|
||||
static QString unescape( const QByteArray& ba, bool* ok ) {
|
||||
assert( ok );
|
||||
*ok = false;
|
||||
QString res;
|
||||
QByteArray seg;
|
||||
bool bs = false;
|
||||
for ( int i = 0, size = ba.size(); i < size; ++i ) {
|
||||
const char ch = ba[i];
|
||||
if ( !bs ) {
|
||||
if ( ch == '\\' )
|
||||
bs = true;
|
||||
else
|
||||
seg += ch;
|
||||
} else {
|
||||
bs = false;
|
||||
switch ( ch ) {
|
||||
case 'b':
|
||||
seg += '\b';
|
||||
break;
|
||||
case 'f':
|
||||
seg += '\f';
|
||||
break;
|
||||
case 'n':
|
||||
seg += '\n';
|
||||
break;
|
||||
case 'r':
|
||||
seg += '\r';
|
||||
break;
|
||||
case 't':
|
||||
seg += '\t';
|
||||
break;
|
||||
case 'u':
|
||||
{
|
||||
res += QString::fromUtf8( seg );
|
||||
seg.clear();
|
||||
|
||||
if ( i > size - 5 ) {
|
||||
//error
|
||||
return QString();
|
||||
}
|
||||
|
||||
const QString hex_digit1 = QString::fromUtf8( ba.mid( i + 1, 2 ) );
|
||||
const QString hex_digit2 = QString::fromUtf8( ba.mid( i + 3, 2 ) );
|
||||
i += 4;
|
||||
|
||||
if ( !ishexnstring( hex_digit1 ) || !ishexnstring( hex_digit2 ) ) {
|
||||
qCritical() << "Not an hex string:" << hex_digit1 << hex_digit2;
|
||||
return QString();
|
||||
}
|
||||
bool hexOk;
|
||||
const ushort hex_code1 = hex_digit1.toShort( &hexOk, 16 );
|
||||
if (!hexOk) {
|
||||
qCritical() << "error converting hex value to short:" << hex_digit1;
|
||||
return QString();
|
||||
}
|
||||
const ushort hex_code2 = hex_digit2.toShort( &hexOk, 16 );
|
||||
if (!hexOk) {
|
||||
qCritical() << "error converting hex value to short:" << hex_digit2;
|
||||
return QString();
|
||||
}
|
||||
|
||||
res += QChar(hex_code2, hex_code1);
|
||||
break;
|
||||
}
|
||||
case '\\':
|
||||
seg += '\\';
|
||||
break;
|
||||
default:
|
||||
seg += ch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
res += QString::fromUtf8( seg );
|
||||
*ok = true;
|
||||
return res;
|
||||
}
|
||||
|
||||
int JSonScanner::yylex(YYSTYPE* yylval, yy::location *yylloc)
|
||||
{
|
||||
char ch;
|
||||
|
||||
if (!m_io->isOpen()) {
|
||||
qCritical() << "JSonScanner::yylex - io device is not open";
|
||||
return -1;
|
||||
}
|
||||
|
||||
yylloc->step();
|
||||
|
||||
do {
|
||||
bool ret;
|
||||
if (m_io->atEnd()) {
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::END";
|
||||
return yy::json_parser::token::END;
|
||||
}
|
||||
else
|
||||
ret = m_io->getChar(&ch);
|
||||
|
||||
if (!ret) {
|
||||
qCritical() << "JSonScanner::yylex - error reading from io device";
|
||||
return -1;
|
||||
}
|
||||
|
||||
qjsonDebug() << "JSonScanner::yylex - got |" << ch << "|";
|
||||
yylloc->columns();
|
||||
|
||||
if (ch == '\n' || ch == '\r')
|
||||
yylloc->lines();
|
||||
} while (m_quotmarkClosed && (isspace(ch) != 0));
|
||||
|
||||
if (m_quotmarkClosed && ((ch == 't') || (ch == 'T'))) {
|
||||
const QByteArray buf = m_io->peek(3).toLower();
|
||||
if (buf == "rue") {
|
||||
m_io->read (3);
|
||||
yylloc->columns(3);
|
||||
qjsonDebug() << "JSonScanner::yylex - TRUE_VAL";
|
||||
return yy::json_parser::token::TRUE_VAL;
|
||||
}
|
||||
}
|
||||
else if (m_quotmarkClosed && ((ch == 'n') || (ch == 'N'))) {
|
||||
const QByteArray buf = m_io->peek(3).toLower();
|
||||
if (buf == "ull") {
|
||||
m_io->read (3);
|
||||
yylloc->columns(3);
|
||||
qjsonDebug() << "JSonScanner::yylex - NULL_VAL";
|
||||
return yy::json_parser::token::NULL_VAL;
|
||||
} else if (buf.startsWith("an") && m_allowSpecialNumbers) {
|
||||
m_io->read(2);
|
||||
yylloc->columns(2);
|
||||
qjsonDebug() << "JSonScanner::yylex - NAN_VAL";
|
||||
return yy::json_parser::token::NAN_VAL;
|
||||
|
||||
}
|
||||
}
|
||||
else if (m_quotmarkClosed && ((ch == 'f') || (ch == 'F'))) {
|
||||
// check false value
|
||||
const QByteArray buf = m_io->peek(4).toLower();
|
||||
if (buf.length() == 4) {
|
||||
if (buf == "alse") {
|
||||
m_io->read (4);
|
||||
yylloc->columns(4);
|
||||
qjsonDebug() << "JSonScanner::yylex - FALSE_VAL";
|
||||
return yy::json_parser::token::FALSE_VAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_quotmarkClosed && ((ch == 'e') || (ch == 'E'))) {
|
||||
QByteArray ret(1, ch);
|
||||
const QByteArray buf = m_io->peek(1);
|
||||
if (!buf.isEmpty()) {
|
||||
if ((buf[0] == '+' ) || (buf[0] == '-' )) {
|
||||
ret += m_io->read (1);
|
||||
yylloc->columns();
|
||||
}
|
||||
}
|
||||
*yylval = QVariant(QString::fromUtf8(ret));
|
||||
return yy::json_parser::token::E;
|
||||
}
|
||||
else if (m_allowSpecialNumbers && m_quotmarkClosed && ((ch == 'I') || (ch == 'i'))) {
|
||||
QByteArray ret(1, ch);
|
||||
const QByteArray buf = m_io->peek(7);
|
||||
if (buf == "nfinity") {
|
||||
m_io->read(7);
|
||||
yylloc->columns(7);
|
||||
qjsonDebug() << "JSonScanner::yylex - INFINITY_VAL";
|
||||
return yy::json_parser::token::INFINITY_VAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ch != '"' && !m_quotmarkClosed) {
|
||||
// we're inside a " " block
|
||||
QByteArray raw;
|
||||
raw += ch;
|
||||
char prevCh = ch;
|
||||
bool escape_on = (ch == '\\') ? true : false;
|
||||
|
||||
while ( true ) {
|
||||
char nextCh;
|
||||
qint64 ret = m_io->peek(&nextCh, 1);
|
||||
if (ret != 1) {
|
||||
if (m_io->atEnd())
|
||||
return yy::json_parser::token::END;
|
||||
else
|
||||
return -1;
|
||||
} else if ( !escape_on && nextCh == '\"' ) {
|
||||
bool ok;
|
||||
const QString str = unescape( raw, &ok );
|
||||
*yylval = ok ? str : QString();
|
||||
return ok ? yy::json_parser::token::STRING : -1;
|
||||
}
|
||||
#if 0
|
||||
if ( prevCh == '\\' && nextCh != '"' && nextCh != '\\' && nextCh != '/' &&
|
||||
nextCh != 'b' && nextCh != 'f' && nextCh != 'n' &&
|
||||
nextCh != 'r' && nextCh != 't' && nextCh != 'u') {
|
||||
qjsonDebug() << "Just read" << nextCh;
|
||||
qjsonDebug() << "JSonScanner::yylex - error decoding escaped sequence";
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
m_io->read(1); // consume
|
||||
raw += nextCh;
|
||||
prevCh = nextCh;
|
||||
if (escape_on)
|
||||
escape_on = false;
|
||||
else
|
||||
escape_on = (prevCh == '\\') ? true : false;
|
||||
#if 0
|
||||
if (nextCh == '\\') {
|
||||
char buf;
|
||||
if (m_io->getChar (&buf)) {
|
||||
yylloc->columns();
|
||||
if (((buf != '"') && (buf != '\\') && (buf != '/') &&
|
||||
(buf != 'b') && (buf != 'f') && (buf != 'n') &&
|
||||
(buf != 'r') && (buf != 't') && (buf != 'u'))) {
|
||||
qjsonDebug() << "Just read" << buf;
|
||||
qjsonDebug() << "JSonScanner::yylex - error decoding escaped sequence";
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
qCritical() << "JSonScanner::yylex - error decoding escaped sequence : io error";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (isdigit(ch) != 0 && m_quotmarkClosed) {
|
||||
bool ok;
|
||||
QByteArray numArray = QByteArray::fromRawData( &ch, 1 * sizeof(char) );
|
||||
qulonglong number = numArray.toULongLong(&ok);
|
||||
if (!ok) {
|
||||
//This shouldn't happen
|
||||
qCritical() << "JSonScanner::yylex - error while converting char to ulonglong, returning -1";
|
||||
return -1;
|
||||
}
|
||||
if (number == 0) {
|
||||
// we have to return immediately otherwise numbers like
|
||||
// 2.04 will be converted to 2.4
|
||||
*yylval = QVariant(number);
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::DIGIT";
|
||||
return yy::json_parser::token::DIGIT;
|
||||
}
|
||||
|
||||
char nextCh;
|
||||
qint64 ret = m_io->peek(&nextCh, 1);
|
||||
while (ret == 1 && isdigit(nextCh)) {
|
||||
m_io->read(1); //consume
|
||||
yylloc->columns(1);
|
||||
numArray = QByteArray::fromRawData( &nextCh, 1 * sizeof(char) );
|
||||
number = number * 10 + numArray.toULongLong(&ok);
|
||||
if (!ok) {
|
||||
//This shouldn't happen
|
||||
qCritical() << "JSonScanner::yylex - error while converting char to ulonglong, returning -1";
|
||||
return -1;
|
||||
}
|
||||
ret = m_io->peek(&nextCh, 1);
|
||||
}
|
||||
|
||||
*yylval = QVariant(number);
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::DIGIT";
|
||||
return yy::json_parser::token::DIGIT;
|
||||
}
|
||||
else if (isalnum(ch) != 0) {
|
||||
*yylval = QVariant(QString(QChar::fromLatin1(ch)));
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::WORD ("
|
||||
<< ch << ")";
|
||||
return yy::json_parser::token::STRING;
|
||||
}
|
||||
else if (ch == ':') {
|
||||
// set yylval
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::COLON";
|
||||
return yy::json_parser::token::COLON;
|
||||
}
|
||||
else if (ch == '"') {
|
||||
// yy::json_parser::token::QUOTMARK (")
|
||||
|
||||
// set yylval
|
||||
m_quotmarkCount++;
|
||||
if (m_quotmarkCount %2 == 0) {
|
||||
m_quotmarkClosed = true;
|
||||
m_quotmarkCount = 0;
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::QUOTMARKCLOSE";
|
||||
return yy::json_parser::token::QUOTMARKCLOSE;
|
||||
}
|
||||
else {
|
||||
m_quotmarkClosed = false;
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::QUOTMARKOPEN";
|
||||
return yy::json_parser::token::QUOTMARKOPEN;
|
||||
}
|
||||
}
|
||||
else if (ch == ',') {
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::COMMA";
|
||||
return yy::json_parser::token::COMMA;
|
||||
}
|
||||
else if (ch == '.') {
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::DOT";
|
||||
return yy::json_parser::token::DOT;
|
||||
}
|
||||
else if (ch == '-') {
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::MINUS";
|
||||
return yy::json_parser::token::MINUS;
|
||||
}
|
||||
else if (ch == '[') {
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::SQUARE_BRACKET_OPEN";
|
||||
return yy::json_parser::token::SQUARE_BRACKET_OPEN;
|
||||
}
|
||||
else if (ch == ']') {
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::SQUARE_BRACKET_CLOSE";
|
||||
return yy::json_parser::token::SQUARE_BRACKET_CLOSE;
|
||||
}
|
||||
else if (ch == '{') {
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::CURLY_BRACKET_OPEN";
|
||||
return yy::json_parser::token::CURLY_BRACKET_OPEN;
|
||||
}
|
||||
else if (ch == '}') {
|
||||
qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::CURLY_BRACKET_CLOSE";
|
||||
return yy::json_parser::token::CURLY_BRACKET_CLOSE;
|
||||
}
|
||||
|
||||
//unknown char!
|
||||
//TODO yyerror?
|
||||
qCritical() << "JSonScanner::yylex - unknown char, returning -1";
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
54
thirdparty/qtweetlib/qtweetlib/qjson/json_scanner.h
vendored
Normal file
54
thirdparty/qtweetlib/qtweetlib/qjson/json_scanner.h
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
/* This file is part of QJson
|
||||
*
|
||||
* Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _JSON_SCANNER
|
||||
#define _JSON_SCANNER
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include <QtCore/QIODevice>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
#define YYSTYPE QVariant
|
||||
|
||||
#include "parser_p.h"
|
||||
|
||||
namespace yy {
|
||||
class location;
|
||||
int yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver);
|
||||
}
|
||||
|
||||
class JSonScanner
|
||||
{
|
||||
public:
|
||||
explicit JSonScanner(QIODevice* io);
|
||||
int yylex(YYSTYPE* yylval, yy::location *yylloc);
|
||||
void allowSpecialNumbers(bool allow);
|
||||
|
||||
protected:
|
||||
bool m_quotmarkClosed;
|
||||
bool m_allowSpecialNumbers;
|
||||
unsigned int m_quotmarkCount;
|
||||
QIODevice* m_io;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
145
thirdparty/qtweetlib/qtweetlib/qjson/location.hh
vendored
Normal file
145
thirdparty/qtweetlib/qtweetlib/qjson/location.hh
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
|
||||
/* Locations for Bison parsers in C++
|
||||
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/**
|
||||
** \file location.hh
|
||||
** Define the yy::location class.
|
||||
*/
|
||||
|
||||
#ifndef BISON_LOCATION_HH
|
||||
# define BISON_LOCATION_HH
|
||||
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
# include "position.hh"
|
||||
|
||||
namespace yy
|
||||
{
|
||||
|
||||
/// Abstract a location.
|
||||
class location
|
||||
{
|
||||
public:
|
||||
|
||||
/// Construct a location.
|
||||
location ()
|
||||
: begin (), end ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// Initialization.
|
||||
inline void initialize (std::string* fn)
|
||||
{
|
||||
begin.initialize (fn);
|
||||
end = begin;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
public:
|
||||
/// Reset initial location to final location.
|
||||
inline void step ()
|
||||
{
|
||||
begin = end;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next columns.
|
||||
inline void columns (unsigned int count = 1)
|
||||
{
|
||||
end += count;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next lines.
|
||||
inline void lines (unsigned int count = 1)
|
||||
{
|
||||
end.lines (count);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
|
||||
public:
|
||||
/// Beginning of the located region.
|
||||
position begin;
|
||||
/// End of the located region.
|
||||
position end;
|
||||
};
|
||||
|
||||
/// Join two location objects to create a location.
|
||||
inline const location operator+ (const location& begin, const location& end)
|
||||
{
|
||||
location res = begin;
|
||||
res.end = end.end;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add two location objects.
|
||||
inline const location operator+ (const location& begin, unsigned int width)
|
||||
{
|
||||
location res = begin;
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add and assign a location.
|
||||
inline location& operator+= (location& res, unsigned int width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/** \brief Intercept output stream redirection.
|
||||
** \param ostr the destination output stream
|
||||
** \param loc a reference to the location to redirect
|
||||
**
|
||||
** Avoid duplicate information.
|
||||
*/
|
||||
inline std::ostream& operator<< (std::ostream& ostr, const location& loc)
|
||||
{
|
||||
position last = loc.end - 1;
|
||||
ostr << loc.begin;
|
||||
if (last.filename
|
||||
&& (!loc.begin.filename
|
||||
|| *loc.begin.filename != *last.filename))
|
||||
ostr << '-' << last;
|
||||
else if (loc.begin.line != last.line)
|
||||
ostr << '-' << last.line << '.' << last.column;
|
||||
else if (loc.begin.column != last.column)
|
||||
ostr << '-' << last.column;
|
||||
return ostr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // not BISON_LOCATION_HH
|
124
thirdparty/qtweetlib/qtweetlib/qjson/parser.cpp
vendored
Normal file
124
thirdparty/qtweetlib/qtweetlib/qjson/parser.cpp
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
/* This file is part of QJson
|
||||
*
|
||||
* Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "parser.h"
|
||||
#include "parser_p.h"
|
||||
#include "json_parser.hh"
|
||||
#include "json_scanner.h"
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
using namespace QJson;
|
||||
|
||||
ParserPrivate::ParserPrivate() :
|
||||
m_scanner(0)
|
||||
, m_negate(false)
|
||||
, m_error(false)
|
||||
, m_specialNumbersAllowed(false)
|
||||
{
|
||||
}
|
||||
|
||||
ParserPrivate::~ParserPrivate()
|
||||
{
|
||||
delete m_scanner;
|
||||
}
|
||||
|
||||
void ParserPrivate::setError(QString errorMsg, int errorLine) {
|
||||
m_error = true;
|
||||
m_errorMsg = errorMsg;
|
||||
m_errorLine = errorLine;
|
||||
}
|
||||
|
||||
Parser::Parser() :
|
||||
d(new ParserPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
Parser::~Parser()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
QVariant Parser::parse (QIODevice* io, bool* ok)
|
||||
{
|
||||
d->m_errorMsg.clear();
|
||||
delete d->m_scanner;
|
||||
d->m_scanner = 0;
|
||||
|
||||
if (!io->isOpen()) {
|
||||
if (!io->open(QIODevice::ReadOnly)) {
|
||||
if (ok != 0)
|
||||
*ok = false;
|
||||
qCritical ("Error opening device");
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
if (!io->isReadable()) {
|
||||
if (ok != 0)
|
||||
*ok = false;
|
||||
qCritical ("Device is not readable");
|
||||
io->close();
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
d->m_scanner = new JSonScanner (io);
|
||||
d->m_scanner->allowSpecialNumbers(d->m_specialNumbersAllowed);
|
||||
yy::json_parser parser(d);
|
||||
parser.parse();
|
||||
|
||||
delete d->m_scanner;
|
||||
d->m_scanner = 0;
|
||||
|
||||
if (ok != 0)
|
||||
*ok = !d->m_error;
|
||||
|
||||
io->close();
|
||||
return d->m_result;
|
||||
}
|
||||
|
||||
QVariant Parser::parse(const QByteArray& jsonString, bool* ok) {
|
||||
QBuffer buffer;
|
||||
buffer.open(QBuffer::ReadWrite);
|
||||
buffer.write(jsonString);
|
||||
buffer.seek(0);
|
||||
return parse (&buffer, ok);
|
||||
}
|
||||
|
||||
QString Parser::errorString() const
|
||||
{
|
||||
return d->m_errorMsg;
|
||||
}
|
||||
|
||||
int Parser::errorLine() const
|
||||
{
|
||||
return d->m_errorLine;
|
||||
}
|
||||
|
||||
void QJson::Parser::allowSpecialNumbers(bool allowSpecialNumbers) {
|
||||
d->m_specialNumbersAllowed = allowSpecialNumbers;
|
||||
}
|
||||
|
||||
bool Parser::specialNumbersAllowed() const {
|
||||
return d->m_specialNumbersAllowed;
|
||||
}
|
94
thirdparty/qtweetlib/qtweetlib/qjson/parser.h
vendored
Normal file
94
thirdparty/qtweetlib/qtweetlib/qjson/parser.h
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
/* This file is part of QJson
|
||||
*
|
||||
* Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef QJSON_PARSER_H
|
||||
#define QJSON_PARSER_H
|
||||
|
||||
#include "qjson_export.h"
|
||||
|
||||
class QIODevice;
|
||||
class QVariant;
|
||||
|
||||
namespace QJson {
|
||||
|
||||
class ParserPrivate;
|
||||
|
||||
/**
|
||||
* @brief Main class used to convert JSON data to QVariant objects
|
||||
*/
|
||||
class QJSON_EXPORT Parser
|
||||
{
|
||||
public:
|
||||
Parser();
|
||||
~Parser();
|
||||
|
||||
/**
|
||||
* Read JSON string from the I/O Device and converts it to a QVariant object
|
||||
* @param io Input output device
|
||||
* @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.
|
||||
* @returns a QVariant object generated from the JSON string
|
||||
*/
|
||||
QVariant parse(QIODevice* io, bool* ok = 0);
|
||||
|
||||
/**
|
||||
* This is a method provided for convenience.
|
||||
* @param jsonData data containing the JSON object representation
|
||||
* @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.
|
||||
* @returns a QVariant object generated from the JSON string
|
||||
* @sa errorString
|
||||
* @sa errorLine
|
||||
*/
|
||||
QVariant parse(const QByteArray& jsonData, bool* ok = 0);
|
||||
|
||||
/**
|
||||
* This method returns the error message
|
||||
* @returns a QString object containing the error message of the last parse operation
|
||||
* @sa errorLine
|
||||
*/
|
||||
QString errorString() const;
|
||||
|
||||
/**
|
||||
* This method returns line number where the error occurred
|
||||
* @returns the line number where the error occurred
|
||||
* @sa errorString
|
||||
*/
|
||||
int errorLine() const;
|
||||
|
||||
/**
|
||||
* Sets whether special numbers (Infinity, -Infinity, NaN) are allowed as an extension to
|
||||
* the standard
|
||||
* @param allowSpecialNumbers new value of whether special numbers are allowed
|
||||
* @sa specialNumbersAllowed
|
||||
*/
|
||||
void allowSpecialNumbers(bool allowSpecialNumbers);
|
||||
|
||||
/**
|
||||
* @returns whether special numbers (Infinity, -Infinity, NaN) are allowed
|
||||
* @sa allowSpecialNumbers
|
||||
*/
|
||||
bool specialNumbersAllowed() const;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(Parser)
|
||||
ParserPrivate* const d;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // QJSON_PARSER_H
|
56
thirdparty/qtweetlib/qtweetlib/qjson/parser_p.h
vendored
Normal file
56
thirdparty/qtweetlib/qtweetlib/qjson/parser_p.h
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/* This file is part of QJson
|
||||
*
|
||||
* Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
|
||||
* Copyright (C) 2009 Michael Leupold <lemma@confuego.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef QJSON_PARSER_P_H
|
||||
#define QJSON_PARSER_P_H
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
class JSonScanner;
|
||||
|
||||
namespace yy {
|
||||
class json_parser;
|
||||
}
|
||||
|
||||
namespace QJson {
|
||||
|
||||
class ParserPrivate
|
||||
{
|
||||
public:
|
||||
ParserPrivate();
|
||||
~ParserPrivate();
|
||||
|
||||
void setError(QString errorMsg, int line);
|
||||
|
||||
JSonScanner* m_scanner;
|
||||
bool m_negate;
|
||||
bool m_error;
|
||||
int m_errorLine;
|
||||
QString m_errorMsg;
|
||||
QVariant m_result;
|
||||
bool m_specialNumbersAllowed;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // QJSON_PARSER_H
|
68
thirdparty/qtweetlib/qtweetlib/qjson/parserrunnable.cpp
vendored
Normal file
68
thirdparty/qtweetlib/qtweetlib/qjson/parserrunnable.cpp
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/* This file is part of qjson
|
||||
*
|
||||
* Copyright (C) 2009 Flavio Castelli <flavio@castelli.name>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "parserrunnable.h"
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
using namespace QJson;
|
||||
|
||||
class QJson::ParserRunnable::Private
|
||||
{
|
||||
public:
|
||||
QByteArray m_data;
|
||||
};
|
||||
|
||||
ParserRunnable::ParserRunnable(QObject* parent)
|
||||
: QObject(parent),
|
||||
QRunnable(),
|
||||
d(new Private)
|
||||
{
|
||||
qRegisterMetaType<QVariant>("QVariant");
|
||||
}
|
||||
|
||||
ParserRunnable::~ParserRunnable()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void ParserRunnable::setData( const QByteArray& data ) {
|
||||
d->m_data = data;
|
||||
}
|
||||
|
||||
void ParserRunnable::run()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
bool ok;
|
||||
Parser parser;
|
||||
QVariant result = parser.parse (d->m_data, &ok);
|
||||
if (ok) {
|
||||
qDebug() << "successfully converted json item to QVariant object";
|
||||
emit parsingFinished(result, true, QString());
|
||||
} else {
|
||||
const QString errorText = tr("An error occured while parsing json: %1").arg(parser.errorString());
|
||||
qCritical() << errorText;
|
||||
emit parsingFinished(QVariant(), false, errorText);
|
||||
}
|
||||
}
|
67
thirdparty/qtweetlib/qtweetlib/qjson/parserrunnable.h
vendored
Normal file
67
thirdparty/qtweetlib/qtweetlib/qjson/parserrunnable.h
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/* This file is part of qjson
|
||||
*
|
||||
* Copyright (C) 2009 Flavio Castelli <flavio@castelli.name>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef PARSERRUNNABLE_H
|
||||
#define PARSERRUNNABLE_H
|
||||
|
||||
#include "qjson_export.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QRunnable>
|
||||
|
||||
class QVariant;
|
||||
|
||||
namespace QJson {
|
||||
/**
|
||||
* @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread
|
||||
*/
|
||||
class QJSON_EXPORT ParserRunnable : public QObject, public QRunnable
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* This signal is emitted when the conversion process has been completed
|
||||
* @param data contains the JSON data that has to be converted
|
||||
* @param parent parent of the object
|
||||
**/
|
||||
explicit ParserRunnable(QObject* parent = 0);
|
||||
~ParserRunnable();
|
||||
|
||||
void setData( const QByteArray& data );
|
||||
|
||||
void run();
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted when the parsing process has been completed
|
||||
* @param json contains the result of the parsing
|
||||
* @param ok if a parsing error occurs ok is set to false, otherwise it's set to true.
|
||||
* @param error_msg contains a string explaining the failure reason
|
||||
**/
|
||||
void parsingFinished(const QVariant& json, bool ok, const QString& error_msg);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(ParserRunnable)
|
||||
class Private;
|
||||
Private* const d;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PARSERRUNNABLE_H
|
142
thirdparty/qtweetlib/qtweetlib/qjson/position.hh
vendored
Normal file
142
thirdparty/qtweetlib/qtweetlib/qjson/position.hh
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
|
||||
/* Positions for Bison parsers in C++
|
||||
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/**
|
||||
** \file position.hh
|
||||
** Define the yy::position class.
|
||||
*/
|
||||
|
||||
#ifndef BISON_POSITION_HH
|
||||
# define BISON_POSITION_HH
|
||||
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
|
||||
namespace yy
|
||||
{
|
||||
/// Abstract a position.
|
||||
class position
|
||||
{
|
||||
public:
|
||||
|
||||
/// Construct a position.
|
||||
position ()
|
||||
: filename (0), line (1), column (0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// Initialization.
|
||||
inline void initialize (std::string* fn)
|
||||
{
|
||||
filename = fn;
|
||||
line = 1;
|
||||
column = 0;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
public:
|
||||
/// (line related) Advance to the COUNT next lines.
|
||||
inline void lines (int count = 1)
|
||||
{
|
||||
column = 0;
|
||||
line += count;
|
||||
}
|
||||
|
||||
/// (column related) Advance to the COUNT next columns.
|
||||
inline void columns (int count = 1)
|
||||
{
|
||||
int leftmost = 0;
|
||||
int current = column;
|
||||
if (leftmost <= current + count)
|
||||
column += count;
|
||||
else
|
||||
column = 0;
|
||||
}
|
||||
/** \} */
|
||||
|
||||
public:
|
||||
/// File name to which this position refers.
|
||||
std::string* filename;
|
||||
/// Current line number.
|
||||
unsigned int line;
|
||||
/// Current column number.
|
||||
unsigned int column;
|
||||
};
|
||||
|
||||
/// Add and assign a position.
|
||||
inline const position&
|
||||
operator+= (position& res, const int width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add two position objects.
|
||||
inline const position
|
||||
operator+ (const position& begin, const int width)
|
||||
{
|
||||
position res = begin;
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Add and assign a position.
|
||||
inline const position&
|
||||
operator-= (position& res, const int width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Add two position objects.
|
||||
inline const position
|
||||
operator- (const position& begin, const int width)
|
||||
{
|
||||
return begin + -width;
|
||||
}
|
||||
|
||||
/** \brief Intercept output stream redirection.
|
||||
** \param ostr the destination output stream
|
||||
** \param pos a reference to the position to redirect
|
||||
*/
|
||||
inline std::ostream&
|
||||
operator<< (std::ostream& ostr, const position& pos)
|
||||
{
|
||||
if (pos.filename)
|
||||
ostr << *pos.filename << ':';
|
||||
return ostr << pos.line << '.' << pos.column;
|
||||
}
|
||||
|
||||
}
|
||||
#endif // not BISON_POSITION_HH
|
34
thirdparty/qtweetlib/qtweetlib/qjson/qjson.pro
vendored
Normal file
34
thirdparty/qtweetlib/qtweetlib/qjson/qjson.pro
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
TEMPLATE = lib
|
||||
QT -= gui
|
||||
TARGET = qjson
|
||||
DESTDIR = ../lib
|
||||
CONFIG += create_prl
|
||||
|
||||
windows: {
|
||||
DEFINES += QJSON_MAKEDLL
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
stack.hh \
|
||||
serializerrunnable.h \
|
||||
serializer.h \
|
||||
qobjecthelper.h \
|
||||
qjson_export.h \
|
||||
qjson_debug.h \
|
||||
position.hh \
|
||||
parserrunnable.h \
|
||||
parser_p.h \
|
||||
parser.h \
|
||||
location.hh \
|
||||
json_scanner.h \
|
||||
json_parser.hh \
|
||||
|
||||
SOURCES += \
|
||||
serializerrunnable.cpp \
|
||||
serializer.cpp \
|
||||
qobjecthelper.cpp \
|
||||
parserrunnable.cpp \
|
||||
parser.cpp \
|
||||
json_scanner.cpp \
|
||||
json_parser.cc \
|
||||
|
33
thirdparty/qtweetlib/qtweetlib/qjson/qjson_debug.h
vendored
Normal file
33
thirdparty/qtweetlib/qtweetlib/qjson/qjson_debug.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/* This file is part of qjson
|
||||
*
|
||||
* Copyright (C) 2009 Michael Leupold <lemma@confuego.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef QJSON_DEBUG_H
|
||||
#define QJSON_DEBUG_H
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
// define qjsonDebug()
|
||||
#ifdef QJSON_VERBOSE_DEBUG_OUTPUT
|
||||
inline QDebug qjsonDebug() { return QDebug(QtDebugMsg); }
|
||||
#else
|
||||
inline QNoDebug qjsonDebug() { return QNoDebug(); }
|
||||
#endif
|
||||
|
||||
#endif
|
35
thirdparty/qtweetlib/qtweetlib/qjson/qjson_export.h
vendored
Normal file
35
thirdparty/qtweetlib/qtweetlib/qjson/qjson_export.h
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/* This file is part of the KDE project
|
||||
Copyright (C) 2009 Pino Toscano <pino@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef QJSON_EXPORT_H
|
||||
#define QJSON_EXPORT_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef QJSON_EXPORT
|
||||
# if defined(QJSON_MAKEDLL)
|
||||
/* We are building this library */
|
||||
# define QJSON_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define QJSON_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user