mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 23:26:40 +02:00
Add beginnings of twitter sip plugin
This commit is contained in:
@@ -132,6 +132,7 @@ IF( UNIX )
|
||||
ENDIF( UNIX )
|
||||
|
||||
ADD_SUBDIRECTORY( sip/jabber )
|
||||
ADD_SUBDIRECTORY( sip/twitter )
|
||||
ADD_SUBDIRECTORY( sip/zeroconf )
|
||||
|
||||
kde4_add_app_icon( tomahawkSources "${CMAKE_CURRENT_SOURCE_DIR}/../data/icons/tomahawk-icon-*.png" )
|
||||
|
44
src/sip/twitter/CMakeLists.txt
Normal file
44
src/sip/twitter/CMakeLists.txt
Normal file
@@ -0,0 +1,44 @@
|
||||
project( tomahawk )
|
||||
|
||||
include( ${QT_USE_FILE} )
|
||||
add_definitions( ${QT_DEFINITIONS} )
|
||||
add_definitions( -DQT_PLUGIN )
|
||||
add_definitions( -DQT_SHARED )
|
||||
|
||||
set( twitterSources
|
||||
# twitter.cpp
|
||||
tomahawkoauthtwitter.cpp
|
||||
)
|
||||
|
||||
set( twitterHeaders
|
||||
# twitter.h
|
||||
tomahawkoauthtwitter.h
|
||||
)
|
||||
|
||||
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
|
||||
${QT_INCLUDE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/thirdparty/qtweetlib/src
|
||||
)
|
||||
|
||||
qt4_wrap_cpp( twitterMoc ${twitterHeaders} )
|
||||
add_library( sip_twitter SHARED ${twitterSources} ${twitterMoc} )
|
||||
|
||||
IF( WIN32 )
|
||||
SET( OS_SPECIFIC_LINK_LIBRARIES
|
||||
${OS_SPECIFIC_LINK_LIBRARIES}
|
||||
"winmm.dll"
|
||||
"iphlpapi.a"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../../build/src/libtomahawk/libtomahawklib.dll"
|
||||
)
|
||||
ENDIF( WIN32 )
|
||||
|
||||
target_link_libraries( sip_twitter
|
||||
${QT_LIBRARIES}
|
||||
${OS_SPECIFIC_LINK_LIBRARIES}
|
||||
)
|
||||
|
||||
IF( APPLE )
|
||||
SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" )
|
||||
ENDIF( APPLE )
|
||||
|
||||
install( TARGETS sip_twitter DESTINATION lib )
|
12
src/sip/twitter/tomahawkoauthtwitter.cpp
Normal file
12
src/sip/twitter/tomahawkoauthtwitter.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "tomahawkoauthtwitter.h"
|
||||
#include <QInputDialog>
|
||||
|
||||
int TomahawkOAuthTwitter::authorizationWidget()
|
||||
{
|
||||
bool ok;
|
||||
int i = QInputDialog::getInt(0, QString( "Twitter PIN" ), QString( "After authenticating, enter the displayed PIN number here:" ), 0, 0, 2147483647, 1, &ok);
|
||||
if (ok)
|
||||
return i;
|
||||
|
||||
return 0;
|
||||
}
|
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>
|
||||
|
||||
class TomahawkOAuthTwitter : public OAuthTwitter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TomahawkOAuthTwitter(QObject *parent = 0)
|
||||
: OAuthTwitter( parent )
|
||||
{}
|
||||
|
||||
~TomahawkOAuthTwitter() {}
|
||||
|
||||
protected:
|
||||
virtual int authorizationWidget();
|
||||
};
|
||||
|
||||
#endif
|
29
src/sip/twitter/twitter.cpp
Normal file
29
src/sip/twitter/twitter.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "zeroconf.h"
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
|
||||
bool
|
||||
ZeroconfPlugin::connect( bool /*startup*/ )
|
||||
{
|
||||
delete m_zeroconf;
|
||||
m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this );
|
||||
QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ),
|
||||
SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) );
|
||||
|
||||
m_zeroconf->advertise();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid )
|
||||
{
|
||||
qDebug() << "Found LAN host:" << host << port << nodeid;
|
||||
|
||||
if ( !Servent::instance()->connectedToSession( nodeid ) )
|
||||
Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid );
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2( sip, ZeroconfPlugin )
|
47
src/sip/twitter/twitter.h
Normal file
47
src/sip/twitter/twitter.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef ZEROCONF_H
|
||||
#define ZEROCONF_H
|
||||
|
||||
#include "sip/SipPlugin.h"
|
||||
#include "tomahawkzeroconf.h"
|
||||
|
||||
#include "../sipdllmacro.h"
|
||||
|
||||
class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES( SipPlugin )
|
||||
|
||||
public:
|
||||
ZeroconfPlugin()
|
||||
: m_zeroconf( 0 )
|
||||
{}
|
||||
|
||||
virtual ~ZeroconfPlugin() {}
|
||||
|
||||
public slots:
|
||||
virtual bool connect( bool startup );
|
||||
|
||||
void disconnect()
|
||||
{
|
||||
}
|
||||
|
||||
void sendMsg( const QString& to, const QString& msg )
|
||||
{
|
||||
}
|
||||
|
||||
void broadcastMsg( const QString &msg )
|
||||
{
|
||||
}
|
||||
|
||||
void addContact( const QString &jid, const QString& msg = QString() )
|
||||
{
|
||||
}
|
||||
|
||||
private slots:
|
||||
void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid );
|
||||
|
||||
private:
|
||||
TomahawkZeroconf* m_zeroconf;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user