mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
port google wrapper over
This commit is contained in:
@@ -60,5 +60,5 @@ ENDIF( APPLE )
|
|||||||
|
|
||||||
install( TARGETS tomahawk_account_xmpp DESTINATION lib${LIB_SUFFIX} )
|
install( TARGETS tomahawk_account_xmpp DESTINATION lib${LIB_SUFFIX} )
|
||||||
|
|
||||||
#add_subdirectory(googlewrapper)
|
add_subdirectory(googlewrapper)
|
||||||
|
|
||||||
|
@@ -2,17 +2,22 @@
|
|||||||
# fake google plugin
|
# fake google plugin
|
||||||
|
|
||||||
set( googleHeaders
|
set( googleHeaders
|
||||||
../jabber.h
|
../xmppaccount.h
|
||||||
../avatarmanager.h
|
../xmppconfigwidget.h
|
||||||
../xmlconsole.h
|
../sip/xmppsip.h
|
||||||
|
../sip/avatarmanager.h
|
||||||
|
../sip/xmlconsole.h
|
||||||
googlewrapper.h )
|
googlewrapper.h )
|
||||||
|
|
||||||
set( googleSources
|
set( googleSources
|
||||||
../jabber.cpp
|
../xmppaccount.cpp
|
||||||
../tomahawkxmppmessage.cpp
|
../xmppconfigwidget.cpp
|
||||||
../tomahawkxmppmessagefactory.cpp
|
../sip/xmppsip.cpp
|
||||||
../avatarmanager.cpp
|
../sip/tomahawkxmppmessage.cpp
|
||||||
../xmlconsole.cpp
|
../sip/tomahawkxmppmessagefactory.cpp
|
||||||
|
../sip/avatarmanager.cpp
|
||||||
|
../sip/xmlconsole.cpp
|
||||||
|
|
||||||
googlewrapper.cpp )
|
googlewrapper.cpp )
|
||||||
|
|
||||||
add_definitions(-DGOOGLE_WRAPPER)
|
add_definitions(-DGOOGLE_WRAPPER)
|
||||||
@@ -20,13 +25,13 @@ add_definitions(-DGOOGLE_WRAPPER)
|
|||||||
qt4_add_resources( RCX_SRCS "resources.qrc" )
|
qt4_add_resources( RCX_SRCS "resources.qrc" )
|
||||||
|
|
||||||
qt4_wrap_cpp( googleMoc ${googleHeaders} )
|
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}
|
${QT_LIBRARIES}
|
||||||
${LIBJREEN_LIBRARY}
|
${LIBJREEN_LIBRARY}
|
||||||
${OS_SPECIFIC_LINK_LIBRARIES}
|
${OS_SPECIFIC_LINK_LIBRARIES}
|
||||||
tomahawklib
|
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 "googlewrapper.h"
|
||||||
#include "ui_configwidget.h"
|
#include "xmppconfigwidget.h"
|
||||||
|
#include "ui_xmppconfigwidget.h"
|
||||||
|
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
|
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
|
||||||
|
using namespace Tomahawk;
|
||||||
|
using namespace Accounts;
|
||||||
|
|
||||||
SipPlugin*
|
Account*
|
||||||
GoogleWrapperFactory::createPlugin( const QString& pluginId )
|
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" );
|
return QIcon( ":/gmail-logo.png" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GoogleWrapperSip::GoogleWrapperSip( Account* account )
|
||||||
GoogleWrapper::GoogleWrapper ( const QString& pluginID )
|
: XmppSipPlugin( account )
|
||||||
: 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GoogleWrapperSip::~GoogleWrapperSip()
|
||||||
QIcon
|
|
||||||
GoogleWrapper::icon() const
|
|
||||||
{
|
{
|
||||||
return QIcon( ":/gmail-logo.png" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString
|
|
||||||
GoogleWrapper::defaultSuffix() const
|
|
||||||
{
|
|
||||||
return "@gmail.com";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GoogleWrapper::showAddFriendDialog()
|
GoogleWrapperSip::showAddFriendDialog()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
QString id = QInputDialog::getText( TomahawkUtils::tomahawkWindow(), tr( "Add Friend" ),
|
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
|
#ifdef GOOGLE_WRAPPER
|
||||||
Q_EXPORT_PLUGIN2( sipfactory, GoogleWrapperFactory )
|
Q_EXPORT_PLUGIN2( Tomahawk::Accounts::AccountFactory, Tomahawk::Accounts::GoogleWrapperFactory )
|
||||||
#endif
|
#endif
|
||||||
|
@@ -19,12 +19,18 @@
|
|||||||
#ifndef GOOGLEWRAPPER_H
|
#ifndef GOOGLEWRAPPER_H
|
||||||
#define 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_OBJECT
|
||||||
Q_INTERFACES( SipPluginFactory )
|
Q_INTERFACES( Tomahawk::Accounts::AccountFactory )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GoogleWrapperFactory() {}
|
GoogleWrapperFactory() {}
|
||||||
@@ -33,25 +39,42 @@ public:
|
|||||||
virtual QString prettyName() const { return "Google"; }
|
virtual QString prettyName() const { return "Google"; }
|
||||||
virtual QString factoryId() const { return "sipgoogle"; }
|
virtual QString factoryId() const { return "sipgoogle"; }
|
||||||
virtual QIcon icon() const;
|
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:
|
||||||
|
GoogleWrapperSip( Tomahawk::Accounts::Account* account );
|
||||||
|
virtual ~GoogleWrapperSip();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void showAddFriendDialog();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString defaultSuffix() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ACCOUNTDLLEXPORT GoogleWrapper : public XmppAccount
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GoogleWrapper( const QString& pluginID );
|
GoogleWrapper( const QString& pluginID );
|
||||||
virtual ~GoogleWrapper() {}
|
virtual ~GoogleWrapper();
|
||||||
|
|
||||||
virtual const QString name() const { return QString( "Google" ); }
|
virtual const QString name() const { return QString( "Google" ); }
|
||||||
virtual const QString friendlyName() const { return "Google"; }
|
virtual const QString friendlyName() const { return "Google"; }
|
||||||
virtual QIcon icon() const;
|
virtual QIcon icon() const;
|
||||||
|
|
||||||
protected:
|
virtual SipPlugin* sipPlugin();
|
||||||
QString defaultSuffix() const;
|
|
||||||
|
|
||||||
public slots:
|
private:
|
||||||
void showAddFriendDialog();
|
QWeakPointer< GoogleWrapperSip > m_sipPlugin;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // GOOGLEWRAPPER_H
|
#endif // GOOGLEWRAPPER_H
|
||||||
|
@@ -83,8 +83,6 @@ XmppAccount::isAuthenticated() const
|
|||||||
Account::ConnectionState
|
Account::ConnectionState
|
||||||
XmppAccount::connectionState() const
|
XmppAccount::connectionState() const
|
||||||
{
|
{
|
||||||
// Ensure we exist
|
|
||||||
const_cast<XmppAccount*>( this )->sipPlugin();
|
|
||||||
return m_xmppSipPlugin.data()->connectionState();
|
return m_xmppSipPlugin.data()->connectionState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,4 +114,6 @@ XmppAccount::sipPlugin()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef GOOGLE_WRAPPER
|
||||||
Q_EXPORT_PLUGIN2( Tomahawk::Accounts::AccountFactory, Tomahawk::Accounts::XmppAccountFactory )
|
Q_EXPORT_PLUGIN2( Tomahawk::Accounts::AccountFactory, Tomahawk::Accounts::XmppAccountFactory )
|
||||||
|
#endif
|
||||||
|
@@ -73,11 +73,12 @@ public:
|
|||||||
|
|
||||||
virtual Tomahawk::Accounts::Account::ConnectionState connectionState() const;
|
virtual Tomahawk::Accounts::Account::ConnectionState connectionState() const;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
Ui_XmppConfigWidget* m_ui; // so the google wrapper can change the config dialog a bit
|
QWeakPointer< QWidget > m_configWidget; // so the google wrapper can change the config dialog a bit
|
||||||
QWeakPointer< QWidget > m_configWidget;
|
|
||||||
QWeakPointer< XmppSipPlugin > m_xmppSipPlugin;
|
QWeakPointer< XmppSipPlugin > m_xmppSipPlugin;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
// for settings access
|
// for settings access
|
||||||
friend class XmppConfigWidget;
|
friend class XmppConfigWidget;
|
||||||
|
@@ -35,6 +35,7 @@ namespace Accounts
|
|||||||
{
|
{
|
||||||
|
|
||||||
class XmppAccount;
|
class XmppAccount;
|
||||||
|
class GoogleWrapper;
|
||||||
|
|
||||||
|
|
||||||
class DLLEXPORT XmppConfigWidget : public QWidget
|
class DLLEXPORT XmppConfigWidget : public QWidget
|
||||||
@@ -56,6 +57,8 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
Ui::XmppConfigWidget *m_ui;
|
Ui::XmppConfigWidget *m_ui;
|
||||||
XmppAccount *m_account;
|
XmppAccount *m_account;
|
||||||
|
|
||||||
|
friend class GoogleWrapper; // So google wrapper can modify the labels and text
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user