1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-09 07:36:48 +02:00

Add beginnings of twitter sip plugin

This commit is contained in:
Jeff Mitchell
2011-02-11 22:39:19 -05:00
parent 1ef02210d6
commit 31ce7a5a2d
6 changed files with 154 additions and 0 deletions

View File

@@ -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" )

View 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 )

View 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;
}

View 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

View 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
View 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