mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-19 23:39:42 +01:00
port google wrapper over
This commit is contained in:
parent
aefec1eaac
commit
3607d364e7
@ -60,5 +60,5 @@ ENDIF( APPLE )
|
||||
|
||||
install( TARGETS tomahawk_account_xmpp DESTINATION lib${LIB_SUFFIX} )
|
||||
|
||||
#add_subdirectory(googlewrapper)
|
||||
add_subdirectory(googlewrapper)
|
||||
|
||||
|
@ -2,31 +2,36 @@
|
||||
# fake google plugin
|
||||
|
||||
set( googleHeaders
|
||||
../jabber.h
|
||||
../avatarmanager.h
|
||||
../xmlconsole.h
|
||||
googlewrapper.h )
|
||||
../xmppaccount.h
|
||||
../xmppconfigwidget.h
|
||||
../sip/xmppsip.h
|
||||
../sip/avatarmanager.h
|
||||
../sip/xmlconsole.h
|
||||
googlewrapper.h )
|
||||
|
||||
set( googleSources
|
||||
../jabber.cpp
|
||||
../tomahawkxmppmessage.cpp
|
||||
../tomahawkxmppmessagefactory.cpp
|
||||
../avatarmanager.cpp
|
||||
../xmlconsole.cpp
|
||||
googlewrapper.cpp )
|
||||
../xmppaccount.cpp
|
||||
../xmppconfigwidget.cpp
|
||||
../sip/xmppsip.cpp
|
||||
../sip/tomahawkxmppmessage.cpp
|
||||
../sip/tomahawkxmppmessagefactory.cpp
|
||||
../sip/avatarmanager.cpp
|
||||
../sip/xmlconsole.cpp
|
||||
|
||||
googlewrapper.cpp )
|
||||
|
||||
add_definitions(-DGOOGLE_WRAPPER)
|
||||
|
||||
qt4_add_resources( RCX_SRCS "resources.qrc" )
|
||||
|
||||
qt4_wrap_cpp( googleMoc ${googleHeaders} )
|
||||
add_library( tomahawk_sipgoogle SHARED ${googleSources} ${googleMoc} ${googleMoc} ${RCX_SRCS} )
|
||||
add_library( tomahawk_account_google SHARED ${googleSources} ${googleMoc} ${googleMoc} ${RCX_SRCS} )
|
||||
|
||||
target_link_libraries( tomahawk_sipgoogle
|
||||
target_link_libraries( tomahawk_account_google
|
||||
${QT_LIBRARIES}
|
||||
${LIBJREEN_LIBRARY}
|
||||
${OS_SPECIFIC_LINK_LIBRARIES}
|
||||
tomahawklib
|
||||
)
|
||||
|
||||
install( TARGETS tomahawk_sipgoogle DESTINATION lib${LIB_SUFFIX} )
|
||||
install( TARGETS tomahawk_account_google DESTINATION lib${LIB_SUFFIX} )
|
||||
|
@ -18,18 +18,21 @@
|
||||
|
||||
|
||||
#include "googlewrapper.h"
|
||||
#include "ui_configwidget.h"
|
||||
#include "xmppconfigwidget.h"
|
||||
#include "ui_xmppconfigwidget.h"
|
||||
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QInputDialog>
|
||||
|
||||
using namespace Tomahawk;
|
||||
using namespace Accounts;
|
||||
|
||||
SipPlugin*
|
||||
GoogleWrapperFactory::createPlugin( const QString& pluginId )
|
||||
Account*
|
||||
GoogleWrapperFactory::createAccount( const QString& pluginId )
|
||||
{
|
||||
return new GoogleWrapper( pluginId.isEmpty() ? generateId() : pluginId );
|
||||
return new GoogleWrapper( pluginId.isEmpty() ? generateId( factoryId() ) : pluginId );
|
||||
}
|
||||
|
||||
|
||||
@ -39,36 +42,19 @@ GoogleWrapperFactory::icon() const
|
||||
return QIcon( ":/gmail-logo.png" );
|
||||
}
|
||||
|
||||
|
||||
GoogleWrapper::GoogleWrapper ( const QString& pluginID )
|
||||
: JabberPlugin ( pluginID )
|
||||
GoogleWrapperSip::GoogleWrapperSip( Account* account )
|
||||
: XmppSipPlugin( account )
|
||||
{
|
||||
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
|
||||
GoogleWrapperSip::~GoogleWrapperSip()
|
||||
{
|
||||
return QIcon( ":/gmail-logo.png" );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
GoogleWrapper::defaultSuffix() const
|
||||
{
|
||||
return "@gmail.com";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GoogleWrapper::showAddFriendDialog()
|
||||
GoogleWrapperSip::showAddFriendDialog()
|
||||
{
|
||||
bool ok;
|
||||
QString id = QInputDialog::getText( TomahawkUtils::tomahawkWindow(), tr( "Add Friend" ),
|
||||
@ -81,6 +67,55 @@ GoogleWrapper::showAddFriendDialog()
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
GoogleWrapperSip::defaultSuffix() const
|
||||
{
|
||||
return "@gmail.com";
|
||||
}
|
||||
|
||||
|
||||
GoogleWrapper::GoogleWrapper ( const QString& pluginID )
|
||||
: XmppAccount ( pluginID )
|
||||
{
|
||||
XmppConfigWidget* config = static_cast< XmppConfigWidget* >( m_configWidget.data() );
|
||||
config->m_ui->headerLabel->setText( tr( "Configure this Google Account" ) );
|
||||
config->m_ui->emailLabel->setText( tr( "Google Address" ) );
|
||||
config->m_ui->xmppBlurb->setText( tr( "Enter your Google login to connect with your friends using Tomahawk!" ) );
|
||||
config->m_ui->logoLabel->setPixmap( QPixmap( ":/gmail-logo.png" ) );
|
||||
config->m_ui->xmppServer->setText( "talk.google.com" );
|
||||
config->m_ui->xmppPort->setValue( 5222 );
|
||||
config->m_ui->groupBoxXmppAdvanced->hide();
|
||||
}
|
||||
|
||||
GoogleWrapper::~GoogleWrapper()
|
||||
{
|
||||
delete m_sipPlugin.data();
|
||||
}
|
||||
|
||||
|
||||
QIcon
|
||||
GoogleWrapper::icon() const
|
||||
{
|
||||
return QIcon( ":/gmail-logo.png" );
|
||||
}
|
||||
|
||||
|
||||
SipPlugin*
|
||||
GoogleWrapper::sipPlugin()
|
||||
{
|
||||
if ( m_xmppSipPlugin.isNull() )
|
||||
{
|
||||
m_xmppSipPlugin = QWeakPointer< XmppSipPlugin >( new GoogleWrapperSip( const_cast< GoogleWrapper* >( this ) ) );
|
||||
|
||||
connect( m_xmppSipPlugin.data(), SIGNAL( stateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), this, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
|
||||
connect( m_xmppSipPlugin.data(), SIGNAL( error( int, QString ) ), this, SIGNAL( error( int, QString ) ) );
|
||||
|
||||
return m_xmppSipPlugin.data();
|
||||
}
|
||||
return m_xmppSipPlugin.data();
|
||||
}
|
||||
|
||||
|
||||
#ifdef GOOGLE_WRAPPER
|
||||
Q_EXPORT_PLUGIN2( sipfactory, GoogleWrapperFactory )
|
||||
Q_EXPORT_PLUGIN2( Tomahawk::Accounts::AccountFactory, Tomahawk::Accounts::GoogleWrapperFactory )
|
||||
#endif
|
||||
|
@ -19,12 +19,18 @@
|
||||
#ifndef GOOGLEWRAPPER_H
|
||||
#define GOOGLEWRAPPER_H
|
||||
|
||||
#include "sip/jabber/jabber.h"
|
||||
#include "xmppaccount.h"
|
||||
|
||||
class SIPDLLEXPORT GoogleWrapperFactory : public SipPluginFactory
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
namespace Accounts
|
||||
{
|
||||
|
||||
class ACCOUNTDLLEXPORT GoogleWrapperFactory : public XmppAccountFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES( SipPluginFactory )
|
||||
Q_INTERFACES( Tomahawk::Accounts::AccountFactory )
|
||||
|
||||
public:
|
||||
GoogleWrapperFactory() {}
|
||||
@ -33,25 +39,42 @@ public:
|
||||
virtual QString prettyName() const { return "Google"; }
|
||||
virtual QString factoryId() const { return "sipgoogle"; }
|
||||
virtual QIcon icon() const;
|
||||
virtual SipPlugin* createPlugin( const QString& pluginId );
|
||||
virtual Account* createAccount( const QString& pluginId );
|
||||
};
|
||||
|
||||
class SIPDLLEXPORT GoogleWrapper : public JabberPlugin
|
||||
class ACCOUNTDLLEXPORT GoogleWrapperSip : public XmppSipPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GoogleWrapper( const QString& pluginID );
|
||||
virtual ~GoogleWrapper() {}
|
||||
|
||||
virtual const QString name() const { return QString( "Google" ); }
|
||||
virtual const QString friendlyName() const { return "Google"; }
|
||||
virtual QIcon icon() const;
|
||||
|
||||
protected:
|
||||
QString defaultSuffix() const;
|
||||
GoogleWrapperSip( Tomahawk::Accounts::Account* account );
|
||||
virtual ~GoogleWrapperSip();
|
||||
|
||||
public slots:
|
||||
void showAddFriendDialog();
|
||||
|
||||
protected:
|
||||
QString defaultSuffix() const;
|
||||
};
|
||||
|
||||
class ACCOUNTDLLEXPORT GoogleWrapper : public XmppAccount
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GoogleWrapper( const QString& pluginID );
|
||||
virtual ~GoogleWrapper();
|
||||
|
||||
virtual const QString name() const { return QString( "Google" ); }
|
||||
virtual const QString friendlyName() const { return "Google"; }
|
||||
virtual QIcon icon() const;
|
||||
|
||||
virtual SipPlugin* sipPlugin();
|
||||
|
||||
private:
|
||||
QWeakPointer< GoogleWrapperSip > m_sipPlugin;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // GOOGLEWRAPPER_H
|
||||
|
@ -83,8 +83,6 @@ XmppAccount::isAuthenticated() const
|
||||
Account::ConnectionState
|
||||
XmppAccount::connectionState() const
|
||||
{
|
||||
// Ensure we exist
|
||||
const_cast<XmppAccount*>( this )->sipPlugin();
|
||||
return m_xmppSipPlugin.data()->connectionState();
|
||||
}
|
||||
|
||||
@ -116,4 +114,6 @@ XmppAccount::sipPlugin()
|
||||
|
||||
}
|
||||
|
||||
#ifndef GOOGLE_WRAPPER
|
||||
Q_EXPORT_PLUGIN2( Tomahawk::Accounts::AccountFactory, Tomahawk::Accounts::XmppAccountFactory )
|
||||
#endif
|
||||
|
@ -73,11 +73,12 @@ public:
|
||||
|
||||
virtual Tomahawk::Accounts::Account::ConnectionState connectionState() const;
|
||||
|
||||
private:
|
||||
Ui_XmppConfigWidget* m_ui; // so the google wrapper can change the config dialog a bit
|
||||
QWeakPointer< QWidget > m_configWidget;
|
||||
protected:
|
||||
QWeakPointer< QWidget > m_configWidget; // so the google wrapper can change the config dialog a bit
|
||||
QWeakPointer< XmppSipPlugin > m_xmppSipPlugin;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
// for settings access
|
||||
friend class XmppConfigWidget;
|
||||
|
@ -35,6 +35,7 @@ namespace Accounts
|
||||
{
|
||||
|
||||
class XmppAccount;
|
||||
class GoogleWrapper;
|
||||
|
||||
|
||||
class DLLEXPORT XmppConfigWidget : public QWidget
|
||||
@ -56,6 +57,8 @@ private slots:
|
||||
private:
|
||||
Ui::XmppConfigWidget *m_ui;
|
||||
XmppAccount *m_account;
|
||||
|
||||
friend class GoogleWrapper; // So google wrapper can modify the labels and text
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user