1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-25 02:09:48 +01:00

Port zeroconf plugin

This commit is contained in:
Leo Franchi 2011-12-18 13:31:36 -05:00
parent 2e45bf5e26
commit f74165424f
16 changed files with 248 additions and 232 deletions

View File

@ -198,8 +198,8 @@ IF(GLOOX_FOUND)
SET( tomahawkHeaders ${tomahawkHeaders} xmppbot/xmppbot.h )
SET( tomahawkSources ${tomahawkSources} xmppbot/xmppbot.cpp )
ENDIF(GLOOX_FOUND)
ADD_SUBDIRECTORY( accounts )
ADD_SUBDIRECTORY( sip )
IF(QCA2_FOUND)
INCLUDE_DIRECTORIES( ${QCA2_INCLUDE_DIR} )

View File

@ -7,4 +7,4 @@ IF( QTWEETLIB_FOUND AND BUILD_GUI )
#ADD_SUBDIRECTORY( twitter )
ENDIF()
#ADD_SUBDIRECTORY( zeroconf )
ADD_SUBDIRECTORY( zeroconf )

View File

@ -162,6 +162,10 @@ TwitterAccount::connectAuthVerifyReply( const QTweetUser &user )
emit nowAuthenticated( m_twitterAuth, user );
}
}
QIcon
TwitterAccount::icon() const {
return QIcon( ":/twitter-icon.png" );
}
}

View File

@ -58,7 +58,7 @@ public:
TwitterAccount( const QString &accountId );
virtual ~TwitterAccount();
QIcon icon() const { return QIcon( ":/twitter-icon.png" ); }
QIcon icon() const;
void authenticate();
void deauthenticate();
@ -82,6 +82,7 @@ private slots:
void connectAuthVerifyReply( const QTweetUser &user );
private:
QIcon m_icon;
bool m_isAuthenticated;
QWeakPointer< TomahawkOAuthTwitter > m_twitterAuth;
QWeakPointer< TwitterConfigWidget > m_configWidget;

View File

@ -8,11 +8,13 @@ add_definitions( -DSIPDLLEXPORT_PRO )
set( zeroconfSources
zeroconf.cpp
zeroconfaccount.cpp
)
set( zeroconfHeaders
zeroconf.h
tomahawkzeroconf.h
zeroconfaccount.h
)
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
@ -22,7 +24,7 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
qt4_wrap_ui( UI_SRCS configwidget.ui )
qt4_add_resources( RC_SRCS "resources.qrc" )
qt4_wrap_cpp( zeroconfMoc ${zeroconfHeaders} )
add_library( tomahawk_sipzeroconf SHARED ${zeroconfSources} ${zeroconfMoc} ${RC_SRCS} ${UI_SRCS} )
add_library( tomahawk_account_zeroconf SHARED ${zeroconfSources} ${zeroconfMoc} ${RC_SRCS} ${UI_SRCS} )
IF( WIN32 )
SET( OS_SPECIFIC_LINK_LIBRARIES
@ -32,7 +34,7 @@ SET( OS_SPECIFIC_LINK_LIBRARIES
)
ENDIF( WIN32 )
target_link_libraries( tomahawk_sipzeroconf
target_link_libraries( tomahawk_account_zeroconf
${QT_LIBRARIES}
${OS_SPECIFIC_LINK_LIBRARIES}
${TOMAHAWK_LIBRARIES}
@ -42,4 +44,4 @@ IF( APPLE )
# SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" )
ENDIF( APPLE )
install( TARGETS tomahawk_sipzeroconf DESTINATION lib${LIB_SUFFIX} )
install( TARGETS tomahawk_account_zeroconf DESTINATION lib${LIB_SUFFIX} )

View File

@ -31,9 +31,7 @@
#include "database/database.h"
#include "network/servent.h"
#include "../sipdllmacro.h"
class SIPDLLEXPORT Node : public QObject
class Node : public QObject
{
Q_OBJECT
@ -71,7 +69,7 @@ private:
};
class SIPDLLEXPORT TomahawkZeroconf : public QObject
class TomahawkZeroconf : public QObject
{
Q_OBJECT

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -24,20 +25,15 @@
#include "tomahawksettings.h"
#include "utils/logger.h"
#include "zeroconfaccount.h"
using namespace Tomahawk;
using namespace Accounts;
SipPlugin*
ZeroconfFactory::createPlugin( const QString& pluginId )
{
return new ZeroconfPlugin( pluginId.isEmpty() ? generateId() : pluginId );
}
ZeroconfPlugin::ZeroconfPlugin() : SipPlugin( "") {}
ZeroconfPlugin::ZeroconfPlugin ( const QString& pluginId )
: SipPlugin( pluginId )
ZeroconfPlugin::ZeroconfPlugin ( ZeroconfAccount* parent )
: SipPlugin( parent )
, m_zeroconf( 0 )
, m_state( Disconnected )
, m_state( Account::Disconnected )
, m_cachedNodes()
{
qDebug() << Q_FUNC_INFO;
@ -66,21 +62,14 @@ ZeroconfPlugin::friendlyName() const
return QString( MYNAME );
}
SipPlugin::ConnectionState
Account::ConnectionState
ZeroconfPlugin::connectionState() const
{
return m_state;
}
#ifndef ENABLE_HEADLESS
QIcon
ZeroconfFactory::icon() const
{
return QIcon( ":/zeroconf-icon.png" );
}
#endif
bool
void
ZeroconfPlugin::connectPlugin()
{
delete m_zeroconf;
@ -89,7 +78,7 @@ ZeroconfPlugin::connectPlugin()
SLOT( lanHostFound( QString, int, QString, QString ) ) );
advertise();
m_state = Connected;
m_state = Account::Connected;
foreach( const QStringList& nodeSet, m_cachedNodes )
{
@ -99,15 +88,13 @@ ZeroconfPlugin::connectPlugin()
m_cachedNodes.clear();
m_advertisementTimer.start();
return true;
}
void
ZeroconfPlugin::disconnectPlugin()
{
m_advertisementTimer.stop();
m_state = Disconnected;
m_state = Account::Disconnected;
delete m_zeroconf;
m_zeroconf = 0;
@ -118,7 +105,7 @@ ZeroconfPlugin::disconnectPlugin()
QIcon
ZeroconfPlugin::icon() const
{
return QIcon( ":/zeroconf-icon.png" );
return account()->icon();
}
#endif
@ -138,7 +125,7 @@ ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name
qDebug() << "Found LAN host:" << host << port << nodeid;
if ( m_state != Connected )
if ( m_state != Account::Connected )
{
qDebug() << "Not online, so not connecting.";
QStringList nodeSet;
@ -153,5 +140,3 @@ ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name
qDebug() << "Already connected to" << host;
}
Q_EXPORT_PLUGIN2( sipfactory, ZeroconfFactory )

View File

@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,55 +21,45 @@
#define ZEROCONF_H
#include "sip/SipPlugin.h"
#include "accounts/Account.h"
#include "tomahawkzeroconf.h"
#include "../sipdllmacro.h"
#include "../accountdllmacro.h"
#include <QtCore/QTimer>
#define MYNAME "Local Network"
class SIPDLLEXPORT ZeroconfFactory : public SipPluginFactory
namespace Tomahawk
{
namespace Accounts
{
Q_OBJECT
Q_INTERFACES( SipPluginFactory )
public:
ZeroconfFactory() {}
virtual ~ZeroconfFactory() {}
virtual QString factoryId() const { return "sipzeroconf"; }
virtual QString prettyName() const { return "Local Network"; }
virtual bool isUnique() const { return true; }
#ifndef ENABLE_HEADLESS
virtual QIcon icon() const;
#endif
class ZeroconfAccount;
virtual SipPlugin* createPlugin ( const QString& pluginId = QString() );
};
class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin
class ACCOUNTDLLEXPORT ZeroconfPlugin : public SipPlugin
{
Q_OBJECT
public:
ZeroconfPlugin();
ZeroconfPlugin( const QString& pluginId );
ZeroconfPlugin( ZeroconfAccount* acc );
virtual ~ZeroconfPlugin();
virtual const QString name() const;
virtual const QString friendlyName() const;
virtual const QString accountName() const;
virtual ConnectionState connectionState() const;
virtual Account::ConnectionState connectionState() const;
virtual bool isValid() const { return true; }
#ifndef ENABLE_HEADLESS
virtual QIcon icon() const;
#endif
virtual void checkSettings() {}
virtual void configurationChanged() {}
public slots:
virtual bool connectPlugin();
void connectPlugin();
void disconnectPlugin();
void advertise();
@ -82,9 +73,12 @@ private slots:
private:
TomahawkZeroconf* m_zeroconf;
ConnectionState m_state;
Account::ConnectionState m_state;
QVector<QStringList> m_cachedNodes;
QTimer m_advertisementTimer;
};
}
}
#endif

View File

@ -0,0 +1,126 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk 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 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "zeroconfaccount.h"
#include "sip/SipPlugin.h"
#include "zeroconf.h"
#include <QtCore/QtPlugin>
using namespace Tomahawk;
using namespace Accounts;
QIcon* s_icon = 0;
ZeroconfFactory::ZeroconfFactory()
{
#ifndef ENABLE_HEADLESS
if ( s_icon == 0 )
s_icon = new QIcon( ":/zeroconf-icon.png" );
#endif
}
ZeroconfFactory::~ZeroconfFactory()
{
if ( s_icon )
{
delete s_icon;
s_icon = 0;
}
}
Account*
ZeroconfFactory::createAccount( const QString& pluginId )
{
return new ZeroconfAccount( pluginId.isEmpty() ? generateId( factoryId() ) : pluginId );
}
QIcon
ZeroconfFactory::icon() const
{
return *s_icon;
}
ZeroconfAccount::ZeroconfAccount( const QString& accountId )
: Account( accountId )
{
setAccountServiceName( "Local Network" );
setAccountFriendlyName( "Local Network" );
}
ZeroconfAccount::~ZeroconfAccount()
{
}
QIcon
ZeroconfAccount::icon() const
{
return *s_icon;
}
void
ZeroconfAccount::authenticate()
{
if ( !isAuthenticated() )
static_cast< ZeroconfPlugin* >( m_sipPlugin.data() )->connectPlugin();
}
void
ZeroconfAccount::deauthenticate()
{
if ( isAuthenticated() )
static_cast< ZeroconfPlugin* >( m_sipPlugin.data() )->disconnectPlugin();
}
bool
ZeroconfAccount::isAuthenticated() const
{
return connectionState() == Connected;
}
Account::ConnectionState
ZeroconfAccount::connectionState() const
{
if ( m_sipPlugin.isNull() )
return Disconnected;
// TODO can we get called before sipPlugin()?
return static_cast< ZeroconfPlugin* >( m_sipPlugin.data() )->connectionState();
}
SipPlugin*
ZeroconfAccount::sipPlugin()
{
if ( m_sipPlugin.isNull() )
m_sipPlugin = QWeakPointer< SipPlugin >( new ZeroconfPlugin( this ) );
return m_sipPlugin.data();
}
Q_EXPORT_PLUGIN2( Tomahawk::Accounts::AccountFactory, Tomahawk::Accounts::ZeroconfFactory )

View File

@ -0,0 +1,78 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk 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 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ZEROCONF_ACCOUNTS_H
#define ZEROCONF_ACCOUNTS_H
#include "accounts/Account.h"
#include "../accountdllmacro.h"
class SipPlugin;
namespace Tomahawk
{
namespace Accounts
{
class ACCOUNTDLLEXPORT ZeroconfFactory : public AccountFactory
{
Q_OBJECT
Q_INTERFACES( Tomahawk::Accounts::AccountFactory )
public:
ZeroconfFactory();
virtual ~ZeroconfFactory();
virtual QString factoryId() const { return "zeroconfaccount"; }
virtual QString prettyName() const { return "Local Network"; }
virtual bool isUnique() const { return true; }
#ifndef ENABLE_HEADLESS
virtual QIcon icon() const;
#endif
virtual Account* createAccount ( const QString& pluginId = QString() );
};
class ACCOUNTDLLEXPORT ZeroconfAccount : public Account
{
Q_OBJECT
public:
ZeroconfAccount( const QString &accountId );
virtual ~ZeroconfAccount();
QIcon icon() const;
void authenticate();
void deauthenticate();
bool isAuthenticated() const;
ConnectionState connectionState() const;
Tomahawk::InfoSystem::InfoPlugin* infoPlugin() { return 0; }
SipPlugin* sipPlugin();
QWidget* configurationWidget() { return 0; }
QWidget* aclWidget() { return 0; }
private:
QWeakPointer< SipPlugin > m_sipPlugin;
};
}
}
#endif

View File

View File

@ -1,86 +0,0 @@
/*
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 2011 Leo Franchi <leo.franchi@kdab.com>
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 3 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/>.
*/
#include "googlewrapper.h"
#include "ui_configwidget.h"
#include "utils/tomahawkutilsgui.h"
#include <QtPlugin>
#include <QInputDialog>
SipPlugin*
GoogleWrapperFactory::createPlugin( const QString& pluginId )
{
return new GoogleWrapper( pluginId.isEmpty() ? generateId() : pluginId );
}
QIcon
GoogleWrapperFactory::icon() const
{
return QIcon( ":/gmail-logo.png" );
}
GoogleWrapper::GoogleWrapper ( const QString& pluginID )
: JabberPlugin ( pluginID )
{
m_ui->headerLabel->setText( tr( "Configure this Google Account" ) );
m_ui->emailLabel->setText( tr( "Google Address" ) );
m_ui->jabberBlurb->setText( tr( "Enter your Google login to connect with your friends using Tomahawk!" ) );
m_ui->logoLabel->setPixmap( QPixmap( ":/gmail-logo.png" ) );
m_ui->jabberServer->setText( "talk.google.com" );
m_ui->jabberPort->setValue( 5222 );
m_ui->groupBoxJabberAdvanced->hide();
}
QIcon
GoogleWrapper::icon() const
{
return QIcon( ":/gmail-logo.png" );
}
QString
GoogleWrapper::defaultSuffix() const
{
return "@gmail.com";
}
void
GoogleWrapper::showAddFriendDialog()
{
bool ok;
QString id = QInputDialog::getText( TomahawkUtils::tomahawkWindow(), tr( "Add Friend" ),
tr( "Enter Google Address:" ), QLineEdit::Normal, "", &ok ).trimmed();
if ( !ok )
return;
qDebug() << "Attempting to add google contact to roster:" << id;
addContact( id );
}
#ifdef GOOGLE_WRAPPER
Q_EXPORT_PLUGIN2( sipfactory, GoogleWrapperFactory )
#endif

View File

@ -1,86 +0,0 @@
project( tomahawk )
include( ${QT_USE_FILE} )
add_definitions( ${QT_DEFINITIONS} )
add_definitions( -DQT_PLUGIN )
add_definitions( -DQT_SHARED )
add_definitions( -DSIPDLLEXPORT_PRO )
<<<<<<< HEAD:src/sip/xmpp/CMakeLists.txt
set( xmppSipSources
xmppsip.cpp
tomahawkxmppmessage.cpp
tomahawkxmppmessagefactory.cpp
=======
set( jabberSources
jabber.cpp
tomahawksipmessage.cpp
tomahawksipmessagefactory.cpp
)
set( jabberSourcesGui
>>>>>>> origin/master:src/sip/jabber/CMakeLists.txt
avatarmanager.cpp
xmlconsole.cpp
)
<<<<<<< HEAD:src/sip/xmpp/CMakeLists.txt
set( xmppSipHeaders
xmppsip.h
=======
set( jabberHeaders
jabber.h
)
set( jabberHeadersGui
>>>>>>> origin/master:src/sip/jabber/CMakeLists.txt
avatarmanager.h
xmlconsole.h
)
set( xmppSipUI
xmlconsole.ui
)
if(BUILD_GUI)
list(APPEND jabberSources ${jabberSourcesGui})
list(APPEND jabberHeaders ${jabberHeadersGui})
endif()
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
${QT_INCLUDE_DIR}
${LIBJREEN_INCLUDE_DIR}
)
qt4_wrap_ui( xmppSipUI_H ${xmppSipUI} )
qt4_wrap_cpp( xmppSipMoc ${xmppSipHeaders} )
add_library( tomahawk_sip_xmpp SHARED ${xmppSipSources} ${xmppSipMoc} ${xmppSipUI_H} ${RC_SRCS} )
IF( WIN32 )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
"secur32.dll"
"crypt32.dll"
${TOMAHAWK_LIBRARIES}
)
ENDIF( WIN32 )
target_link_libraries( tomahawk_sip_xmpp
${QT_LIBRARIES}
${LIBJREEN_LIBRARY}
${OS_SPECIFIC_LINK_LIBRARIES}
tomahawklib
)
IF( APPLE )
# SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" )
ENDIF( APPLE )
install( TARGETS tomahawk_sip_xmpp DESTINATION lib${LIB_SUFFIX} )
<<<<<<< HEAD:src/sip/xmpp/CMakeLists.txt
#add_subdirectory(googlewrapper)
=======
if(BUILD_GUI)
add_subdirectory(googlewrapper)
endif()
>>>>>>> origin/master:src/sip/jabber/CMakeLists.txt