mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-08 18:12:41 +02:00
XMPP via Accounts compiles. NFC if it works, but this is a big step...
(Also, GoogleWrapper not ported yet)
This commit is contained in:
parent
1736f4caaa
commit
d50e41f4d2
@ -1 +1,2 @@
|
||||
add_subdirectory( xmpp )
|
||||
add_subdirectory( twitter )
|
||||
|
@ -87,6 +87,4 @@ TwitterAccount::sipPlugin()
|
||||
|
||||
}
|
||||
|
||||
#ifndef GOOGLE_WRAPPER
|
||||
Q_EXPORT_PLUGIN2( Tomahawk::Accounts::AccountFactory, Tomahawk::Accounts::TwitterAccountFactory )
|
||||
#endif
|
||||
Q_EXPORT_PLUGIN2( Tomahawk::Accounts::AccountFactory, Tomahawk::Accounts::TwitterAccountFactory )
|
@ -41,20 +41,20 @@ namespace Accounts
|
||||
|
||||
TwitterConfigWidget::TwitterConfigWidget( TwitterAccount* account, QWidget *parent ) :
|
||||
QWidget( parent ),
|
||||
ui( new Ui::TwitterConfigWidget ),
|
||||
m_ui( new Ui::TwitterConfigWidget ),
|
||||
m_account( account )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
m_ui->setupUi( this );
|
||||
|
||||
connect( ui->twitterAuthenticateButton, SIGNAL( pressed() ),
|
||||
connect( m_ui->twitterAuthenticateButton, SIGNAL( pressed() ),
|
||||
this, SLOT( authDeauthTwitter() ) );
|
||||
connect( ui->twitterTweetGotTomahawkButton, SIGNAL( pressed() ),
|
||||
connect( m_ui->twitterTweetGotTomahawkButton, SIGNAL( pressed() ),
|
||||
this, SLOT( startPostGotTomahawkStatus() ) );
|
||||
connect( ui->twitterTweetComboBox, SIGNAL( currentIndexChanged( int ) ),
|
||||
connect( m_ui->twitterTweetComboBox, SIGNAL( currentIndexChanged( int ) ),
|
||||
this, SLOT( tweetComboBoxIndexChanged( int ) ) );
|
||||
|
||||
ui->twitterTweetComboBox->setCurrentIndex( 0 );
|
||||
ui->twitterTweetGotTomahawkButton->setText( tr( "Tweet!" ) );
|
||||
m_ui->twitterTweetComboBox->setCurrentIndex( 0 );
|
||||
m_ui->twitterTweetGotTomahawkButton->setText( tr( "Tweet!" ) );
|
||||
|
||||
QVariantHash credentials = m_account->credentials();
|
||||
|
||||
@ -62,18 +62,18 @@ TwitterConfigWidget::TwitterConfigWidget( TwitterAccount* account, QWidget *pare
|
||||
credentials[ "oauthtokensecret" ].toString().isEmpty() ||
|
||||
credentials[ "username" ].toString().isEmpty() )
|
||||
{
|
||||
ui->twitterStatusLabel->setText( tr( "Status: No saved credentials" ) );
|
||||
ui->twitterAuthenticateButton->setText( tr( "Authenticate" ) );
|
||||
ui->twitterSyncGroupBox->setVisible( false );
|
||||
m_ui->twitterStatusLabel->setText( tr( "Status: No saved credentials" ) );
|
||||
m_ui->twitterAuthenticateButton->setText( tr( "Authenticate" ) );
|
||||
m_ui->twitterSyncGroupBox->setVisible( false );
|
||||
|
||||
emit twitterAuthed( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->twitterStatusLabel->setText( tr( "Status: Credentials saved for %1" ).arg( m_account->credentials()[ "username" ].toString() ) );
|
||||
ui->twitterAuthenticateButton->setText( tr( "De-authenticate" ) );
|
||||
ui->twitterSyncGroupBox->setVisible( true );
|
||||
ui->twitterUserTweetLineEdit->setVisible( false );
|
||||
m_ui->twitterStatusLabel->setText( tr( "Status: Credentials saved for %1" ).arg( m_account->credentials()[ "username" ].toString() ) );
|
||||
m_ui->twitterAuthenticateButton->setText( tr( "De-authenticate" ) );
|
||||
m_ui->twitterSyncGroupBox->setVisible( true );
|
||||
m_ui->twitterUserTweetLineEdit->setVisible( false );
|
||||
|
||||
emit twitterAuthed( true );
|
||||
}
|
||||
@ -82,13 +82,13 @@ TwitterConfigWidget::TwitterConfigWidget( TwitterAccount* account, QWidget *pare
|
||||
|
||||
TwitterConfigWidget::~TwitterConfigWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void
|
||||
TwitterConfigWidget::authDeauthTwitter()
|
||||
{
|
||||
if ( ui->twitterAuthenticateButton->text() == tr( "Authenticate" ) ) //FIXME: don't rely on UI strings here!
|
||||
if ( m_ui->twitterAuthenticateButton->text() == tr( "Authenticate" ) ) //FIXME: don't rely on UI strings here!
|
||||
authenticateTwitter();
|
||||
else
|
||||
deauthenticateTwitter();
|
||||
@ -132,12 +132,12 @@ TwitterConfigWidget::authenticateVerifyReply( const QTweetUser &user )
|
||||
configuration[ "sipcachedmentionssinceid" ] = 0;
|
||||
m_account->setConfiguration( configuration );
|
||||
|
||||
ui->twitterStatusLabel->setText( tr( "Status: Credentials saved for %1" ).arg( user.screenName() ) );
|
||||
ui->twitterAuthenticateButton->setText( tr( "De-authenticate" ) );
|
||||
ui->twitterSyncGroupBox->setVisible( true );
|
||||
ui->twitterTweetComboBox->setCurrentIndex( 0 );
|
||||
ui->twitterUserTweetLineEdit->setVisible( false );
|
||||
ui->twitterTweetGotTomahawkButton->setText( tr( "Tweet!" ) );
|
||||
m_ui->twitterStatusLabel->setText( tr( "Status: Credentials saved for %1" ).arg( user.screenName() ) );
|
||||
m_ui->twitterAuthenticateButton->setText( tr( "De-authenticate" ) );
|
||||
m_ui->twitterSyncGroupBox->setVisible( true );
|
||||
m_ui->twitterTweetComboBox->setCurrentIndex( 0 );
|
||||
m_ui->twitterUserTweetLineEdit->setVisible( false );
|
||||
m_ui->twitterTweetGotTomahawkButton->setText( tr( "Tweet!" ) );
|
||||
|
||||
emit twitterAuthed( true );
|
||||
emit sizeHintChanged();
|
||||
@ -148,7 +148,7 @@ TwitterConfigWidget::authenticateVerifyError( QTweetNetBase::ErrorCode code, con
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qDebug() << "Error validating credentials, error code is " << code << ", error message is " << errorMsg;
|
||||
ui->twitterStatusLabel->setText(tr("Status: Error validating credentials"));
|
||||
m_ui->twitterStatusLabel->setText(tr("Status: Error validating credentials"));
|
||||
emit twitterAuthed( false );
|
||||
return;
|
||||
}
|
||||
@ -163,9 +163,9 @@ TwitterConfigWidget::deauthenticateTwitter()
|
||||
credentials[ "username" ] = QString();
|
||||
m_account->setCredentials( credentials );
|
||||
|
||||
ui->twitterStatusLabel->setText(tr("Status: No saved credentials"));
|
||||
ui->twitterAuthenticateButton->setText( tr( "Authenticate" ) );
|
||||
ui->twitterSyncGroupBox->setVisible( false );
|
||||
m_ui->twitterStatusLabel->setText(tr("Status: No saved credentials"));
|
||||
m_ui->twitterAuthenticateButton->setText( tr( "Authenticate" ) );
|
||||
m_ui->twitterSyncGroupBox->setVisible( false );
|
||||
|
||||
emit twitterAuthed( false );
|
||||
emit sizeHintChanged();
|
||||
@ -175,26 +175,26 @@ void
|
||||
TwitterConfigWidget::tweetComboBoxIndexChanged( int index )
|
||||
{
|
||||
Q_UNUSED( index );
|
||||
if ( ui->twitterTweetComboBox->currentText() == tr( "Global Tweet" ) ) //FIXME: use data!
|
||||
ui->twitterUserTweetLineEdit->setVisible( false );
|
||||
if ( m_ui->twitterTweetComboBox->currentText() == tr( "Global Tweet" ) ) //FIXME: use data!
|
||||
m_ui->twitterUserTweetLineEdit->setVisible( false );
|
||||
else
|
||||
ui->twitterUserTweetLineEdit->setVisible( true );
|
||||
m_ui->twitterUserTweetLineEdit->setVisible( true );
|
||||
|
||||
if ( ui->twitterTweetComboBox->currentText() == tr( "Direct Message" ) ) //FIXME: use data!
|
||||
ui->twitterTweetGotTomahawkButton->setText( tr( "Send Message!" ) );
|
||||
else if ( ui->twitterTweetComboBox->currentText() == tr( "@Mention" ) )
|
||||
ui->twitterTweetGotTomahawkButton->setText( tr( "Send Mention!" ) );
|
||||
if ( m_ui->twitterTweetComboBox->currentText() == tr( "Direct Message" ) ) //FIXME: use data!
|
||||
m_ui->twitterTweetGotTomahawkButton->setText( tr( "Send Message!" ) );
|
||||
else if ( m_ui->twitterTweetComboBox->currentText() == tr( "@Mention" ) )
|
||||
m_ui->twitterTweetGotTomahawkButton->setText( tr( "Send Mention!" ) );
|
||||
else
|
||||
ui->twitterTweetGotTomahawkButton->setText( tr( "Tweet!" ) );
|
||||
m_ui->twitterTweetGotTomahawkButton->setText( tr( "Tweet!" ) );
|
||||
}
|
||||
|
||||
void
|
||||
TwitterConfigWidget::startPostGotTomahawkStatus()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
m_postGTtype = ui->twitterTweetComboBox->currentText();
|
||||
m_postGTtype = m_ui->twitterTweetComboBox->currentText();
|
||||
|
||||
if ( m_postGTtype != "Global Tweet" && ( ui->twitterUserTweetLineEdit->text().isEmpty() || ui->twitterUserTweetLineEdit->text() == "@" ) )
|
||||
if ( m_postGTtype != "Global Tweet" && ( m_ui->twitterUserTweetLineEdit->text().isEmpty() || m_ui->twitterUserTweetLineEdit->text() == "@" ) )
|
||||
{
|
||||
QMessageBox::critical( this, tr("Tweetin' Error"), tr("You must enter a user name for this type of tweet.") );
|
||||
return;
|
||||
@ -242,7 +242,7 @@ TwitterConfigWidget::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &use
|
||||
QString message = QString( "Got Tomahawk? {" ) + Database::instance()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) + QString( " http://gettomahawk.com" );
|
||||
if ( m_postGTtype == "@Mention" )
|
||||
{
|
||||
QString user = ui->twitterUserTweetLineEdit->text();
|
||||
QString user = m_ui->twitterUserTweetLineEdit->text();
|
||||
if ( user.startsWith( "@" ) )
|
||||
user.remove( 0, 1 );
|
||||
message = QString( "@" ) + user + QString( " " ) + message;
|
||||
@ -256,7 +256,7 @@ TwitterConfigWidget::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &use
|
||||
connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
|
||||
QString uuid = QUuid::createUuid();
|
||||
QString message = QString( "Got Tomahawk? {" ) + Database::instance()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) + QString( " http://gettomahawk.com" );
|
||||
QString user = ui->twitterUserTweetLineEdit->text();
|
||||
QString user = m_ui->twitterUserTweetLineEdit->text();
|
||||
if ( user.startsWith( "@" ) )
|
||||
user.remove( 0, 1 );
|
||||
statUpdate->post( user, message );
|
||||
|
@ -28,8 +28,6 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class TwitterAccount;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class TwitterConfigWidget;
|
||||
@ -72,7 +70,7 @@ private:
|
||||
void authenticateTwitter();
|
||||
void deauthenticateTwitter();
|
||||
|
||||
Ui::TwitterConfigWidget *ui;
|
||||
Ui::TwitterConfigWidget *m_ui;
|
||||
TwitterAccount *m_account;
|
||||
QString m_postGTtype;
|
||||
};
|
||||
|
53
src/accounts/xmpp/CMakeLists.txt
Normal file
53
src/accounts/xmpp/CMakeLists.txt
Normal file
@ -0,0 +1,53 @@
|
||||
project( tomahawk )
|
||||
|
||||
include( ${QT_USE_FILE} )
|
||||
add_definitions( ${QT_DEFINITIONS} )
|
||||
add_definitions( -DQT_PLUGIN )
|
||||
add_definitions( -DQT_SHARED )
|
||||
add_definitions( -DDLLEXPORT_PRO )
|
||||
|
||||
set( xmppAccountSources
|
||||
xmppaccount.cpp
|
||||
xmppconfigwidget.cpp
|
||||
)
|
||||
|
||||
set( xmppAccountHeaders
|
||||
xmppaccount.h
|
||||
xmppconfigwidget.h
|
||||
)
|
||||
|
||||
set( xmppAccountUI
|
||||
xmppconfigwidget.ui
|
||||
)
|
||||
|
||||
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
|
||||
${QT_INCLUDE_DIR}
|
||||
${LIBJREEN_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
qt4_wrap_cpp( xmppAccountMoc ${xmppAccountHeaders} )
|
||||
qt4_wrap_ui( xmppAccountUI_H ${xmppAccountUI} )
|
||||
qt4_add_resources( RC_SRCS "resources.qrc" )
|
||||
add_library( tomahawk_account_xmpp SHARED ${xmppAccountUI_H} ${xmppAccountSources} ${xmppAccountMoc} ${RC_SRCS} )
|
||||
|
||||
IF( WIN32 )
|
||||
SET( OS_SPECIFIC_LINK_LIBRARIES
|
||||
${OS_SPECIFIC_LINK_LIBRARIES}
|
||||
"winmm.dll"
|
||||
"iphlpapi.a"
|
||||
)
|
||||
ENDIF( WIN32 )
|
||||
|
||||
target_link_libraries( tomahawk_account_xmpp
|
||||
tomahawk_sipxmpp
|
||||
${TOMAHAWK_LIBRARIES}
|
||||
${JREEN_LIBRARY}
|
||||
${QT_LIBRARIES}
|
||||
${OS_SPECIFIC_LINK_LIBRARIES}
|
||||
)
|
||||
|
||||
IF( APPLE )
|
||||
# SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" )
|
||||
ENDIF( APPLE )
|
||||
|
||||
install( TARGETS tomahawk_account_xmpp DESTINATION lib${LIB_SUFFIX} )
|
@ -1,5 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>jabber-icon.png</file>
|
||||
<file>xmpp-icon.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
75
src/accounts/xmpp/xmppaccount.cpp
Normal file
75
src/accounts/xmpp/xmppaccount.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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 "xmppaccount.h"
|
||||
#include "xmppconfigwidget.h"
|
||||
#include "sip/SipPlugin.h"
|
||||
|
||||
#include <QtCore/QtPlugin>
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
namespace Accounts
|
||||
{
|
||||
|
||||
Account*
|
||||
XmppAccountFactory::createAccount( const QString& accountId )
|
||||
{
|
||||
return new XmppAccount( accountId.isEmpty() ? Tomahawk::Accounts::generateId( factoryId() ) : accountId );
|
||||
}
|
||||
|
||||
|
||||
XmppAccount::XmppAccount( const QString &accountId )
|
||||
: Account( accountId )
|
||||
, m_isAuthenticated( false )
|
||||
{
|
||||
loadFromConfig( accountId );
|
||||
|
||||
setAccountServiceName( "XMPP (Jabber)" );
|
||||
QSet< AccountType > types;
|
||||
types << SipType;
|
||||
setTypes( types );
|
||||
|
||||
m_configWidget = QWeakPointer< XmppConfigWidget >( new XmppConfigWidget( this, 0 ) );
|
||||
}
|
||||
|
||||
|
||||
XmppAccount::~XmppAccount()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
SipPlugin*
|
||||
XmppAccount::sipPlugin()
|
||||
{
|
||||
if ( m_xmppSipPlugin.isNull() )
|
||||
{
|
||||
m_xmppSipPlugin = QWeakPointer< XmppSipPlugin >( new XmppSipPlugin( this ) );
|
||||
return m_xmppSipPlugin.data();
|
||||
}
|
||||
return m_xmppSipPlugin.data();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2( Tomahawk::Accounts::AccountFactory, Tomahawk::Accounts::XmppAccountFactory )
|
88
src/accounts/xmpp/xmppaccount.h
Normal file
88
src/accounts/xmpp/xmppaccount.h
Normal file
@ -0,0 +1,88 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Dominik Schmidt <dev@dominik-schmidt.de>
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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 XMPPACCOUNT_H
|
||||
#define XMPPACCOUNT_H
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include "sip/xmpp/xmppsip.h"
|
||||
#include "accounts/account.h"
|
||||
|
||||
#define MYNAME "ACCOUNTJABBER"
|
||||
|
||||
class Ui_XmppConfigWidget;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
namespace Accounts
|
||||
{
|
||||
|
||||
class DLLEXPORT XmppAccountFactory : public AccountFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES( Tomahawk::Accounts::AccountFactory )
|
||||
|
||||
public:
|
||||
XmppAccountFactory() {}
|
||||
virtual ~XmppAccountFactory() {}
|
||||
|
||||
QString prettyName() const { return "XMPP (Jabber)"; }
|
||||
QString factoryId() const { return "xmppaccount"; }
|
||||
QIcon icon() const { return QIcon( ":/xmpp-icon.png" ); }
|
||||
Account* createAccount( const QString& pluginId = QString() );
|
||||
};
|
||||
|
||||
class DLLEXPORT XmppAccount : public Account
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
XmppAccount( const QString &accountId );
|
||||
virtual ~XmppAccount();
|
||||
|
||||
QIcon icon() const { return QIcon( ":/xmpp-icon.png" ); }
|
||||
|
||||
bool canSelfAuthenticate() { return false; }
|
||||
bool authenticate() { return false; }
|
||||
bool isAuthenticated() const { return m_isAuthenticated; }
|
||||
|
||||
Tomahawk::InfoSystem::InfoPlugin* infoPlugin() { return 0; }
|
||||
SipPlugin* sipPlugin();
|
||||
|
||||
QWidget* configurationWidget() { return m_configWidget.data(); }
|
||||
QWidget* aclWidget() { return 0; }
|
||||
|
||||
private:
|
||||
Ui_XmppConfigWidget* m_ui; // so the google wrapper can change the config dialog a bit
|
||||
bool m_isAuthenticated;
|
||||
QWeakPointer< QWidget > m_configWidget;
|
||||
QWeakPointer< XmppSipPlugin > m_xmppSipPlugin;
|
||||
|
||||
|
||||
// for settings access
|
||||
friend class XmppConfigWidget;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
89
src/accounts/xmpp/xmppconfigwidget.cpp
Normal file
89
src/accounts/xmpp/xmppconfigwidget.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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 "xmppaccount.h"
|
||||
#include "xmppconfigwidget.h"
|
||||
#include "ui_xmppconfigwidget.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <accounts/accountmanager.h>
|
||||
#include <utils/logger.h>
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
namespace Accounts
|
||||
{
|
||||
|
||||
XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent ) :
|
||||
QWidget( parent ),
|
||||
m_ui( new Ui::XmppConfigWidget ),
|
||||
m_account( account )
|
||||
{
|
||||
m_ui->setupUi( this );
|
||||
|
||||
m_ui->xmppUsername->setText( account->credentials().contains( "username" ) ? account->credentials()[ "username" ].toString() : QString() );
|
||||
m_ui->xmppPassword->setText( account->credentials().contains( "password" ) ? account->credentials()[ "password" ].toString() : QString() );
|
||||
m_ui->xmppServer->setText( account->configuration().contains( "server" ) ? account->configuration()[ "server" ].toString() : QString() );
|
||||
m_ui->xmppPort->setValue( account->configuration().contains( "port" ) ? account->configuration()[ "port" ].toInt() : 5222 );
|
||||
m_ui->jidExistsLabel->hide();
|
||||
|
||||
connect( m_ui->xmppUsername, SIGNAL( textChanged( QString ) ), SLOT( onCheckJidExists( QString ) ) );
|
||||
}
|
||||
|
||||
|
||||
XmppConfigWidget::~XmppConfigWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmppConfigWidget::onCheckJidExists( QString jid )
|
||||
{
|
||||
QList< Tomahawk::Accounts::Account* > accounts = Tomahawk::Accounts::AccountManager::instance()->getAccounts( Tomahawk::Accounts::SipType );
|
||||
foreach( Tomahawk::Accounts::Account* account, accounts )
|
||||
{
|
||||
if ( account->accountId() == m_account->accountId() )
|
||||
continue;
|
||||
|
||||
QString savedUsername = account->credentials()[ "username" ].toString();
|
||||
QStringList savedSplitUsername = account->credentials()[ "username" ].toString().split("@");
|
||||
QString savedServer = account->configuration()[ "server" ].toString();
|
||||
int savedPort = account->configuration()[ "port" ].toInt();
|
||||
|
||||
if ( ( savedUsername == jid || savedSplitUsername.contains( jid ) ) &&
|
||||
savedServer == m_ui->xmppServer->text() &&
|
||||
savedPort == m_ui->xmppPort->value() &&
|
||||
!jid.trimmed().isEmpty() )
|
||||
{
|
||||
m_ui->jidExistsLabel->show();
|
||||
// the already jid exists
|
||||
emit dataError( true );
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_ui->jidExistsLabel->hide();
|
||||
emit dataError( false );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
63
src/accounts/xmpp/xmppconfigwidget.h
Normal file
63
src/accounts/xmpp/xmppconfigwidget.h
Normal file
@ -0,0 +1,63 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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 JABBERACCOUNTCONFIGWIDGET_H
|
||||
#define JABBERACCOUNTCONFIGWIDGET_H
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class XmppConfigWidget;
|
||||
}
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
namespace Accounts
|
||||
{
|
||||
|
||||
class XmppAccount;
|
||||
|
||||
|
||||
class DLLEXPORT XmppConfigWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit XmppConfigWidget( XmppAccount* account = 0, QWidget *parent = 0 );
|
||||
virtual ~XmppConfigWidget();
|
||||
|
||||
signals:
|
||||
void dataError( bool exists );
|
||||
|
||||
private slots:
|
||||
void onCheckJidExists( QString jid );
|
||||
|
||||
private:
|
||||
Ui::XmppConfigWidget *m_ui;
|
||||
XmppAccount *m_account;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // TWITTERCONFIGWIDGET_H
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>JabberConfig</class>
|
||||
<widget class="QWidget" name="JabberConfig">
|
||||
<class>XmppConfigWidget</class>
|
||||
<widget class="QWidget" name="XmppConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Jabber Configuration</string>
|
||||
<string>Xmpp Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
@ -35,7 +35,7 @@
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="resources.qrc">:/jabber-icon.png</pixmap>
|
||||
<pixmap resource="resources.qrc">:/xmpp-icon.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -49,7 +49,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Configure this Jabber account</string>
|
||||
<string>Configure this Xmpp account</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -84,9 +84,9 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="jabberBlurb">
|
||||
<widget class="QLabel" name="xmppBlurb">
|
||||
<property name="text">
|
||||
<string>Enter your Jabber login to connect with your friends using Tomahawk!</string>
|
||||
<string>Enter your Xmpp login to connect with your friends using Tomahawk!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -128,15 +128,15 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Jabber ID:</string>
|
||||
<string>Xmpp ID:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>jabberUsername</cstring>
|
||||
<cstring>xmppUsername</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="jabberUsername">
|
||||
<widget class="QLineEdit" name="xmppUsername">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -160,12 +160,12 @@
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>jabberPassword</cstring>
|
||||
<cstring>xmppPassword</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="jabberPassword">
|
||||
<widget class="QLineEdit" name="xmppPassword">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -196,7 +196,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBoxJabberAdvanced">
|
||||
<widget class="QGroupBox" name="groupBoxXmppAdvanced">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -207,13 +207,13 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Advanced Jabber Settings</string>
|
||||
<string>Advanced Xmpp Settings</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelJabberServer">
|
||||
<widget class="QLabel" name="labelXmppServer">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
@ -233,12 +233,12 @@
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>jabberServer</cstring>
|
||||
<cstring>xmppServer</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="jabberServer">
|
||||
<widget class="QLineEdit" name="xmppServer">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -248,7 +248,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelJabberPort">
|
||||
<widget class="QLabel" name="labelXmppPort">
|
||||
<property name="text">
|
||||
<string>Port:</string>
|
||||
</property>
|
||||
@ -258,7 +258,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="jabberPort">
|
||||
<widget class="QSpinBox" name="xmppPort">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
@ -63,18 +63,18 @@ public:
|
||||
, m_accountId( accountId ) {}
|
||||
virtual ~Account() {}
|
||||
|
||||
virtual QString accountServiceName() const { return m_accountServiceName; } // e.g. "Twitter", "Last.fm"
|
||||
virtual QString accountFriendlyName() const { return m_accountFriendlyName; } // e.g. screen name on the service, JID, etc.
|
||||
virtual bool enabled() const { return m_enabled; }
|
||||
virtual bool autoConnect() const { return m_autoConnect; }
|
||||
virtual QString accountId() const { return m_accountId; }
|
||||
virtual QString accountServiceName() const { QMutexLocker locker( &m_mutex ); return m_accountServiceName; } // e.g. "Twitter", "Last.fm"
|
||||
virtual QString accountFriendlyName() const { QMutexLocker locker( &m_mutex ); return m_accountFriendlyName; } // e.g. screen name on the service, JID, etc.
|
||||
virtual bool enabled() const { QMutexLocker locker( &m_mutex ); return m_enabled; }
|
||||
virtual bool autoConnect() const { QMutexLocker locker( &m_mutex ); return m_autoConnect; }
|
||||
virtual QString accountId() const { QMutexLocker locker( &m_mutex ); return m_accountId; }
|
||||
|
||||
virtual QVariantHash configuration() const { return m_configuration; }
|
||||
virtual QVariantHash configuration() const { QMutexLocker locker( &m_mutex ); return m_configuration; }
|
||||
virtual QWidget* configurationWidget() = 0;
|
||||
|
||||
virtual QVariantHash credentials() { return m_credentials; }
|
||||
virtual QVariantHash credentials() { QMutexLocker locker( &m_mutex ); return m_credentials; }
|
||||
|
||||
virtual QVariantMap acl() const { return m_acl; }
|
||||
virtual QVariantMap acl() const { QMutexLocker locker( &m_mutex ); return m_acl; }
|
||||
virtual QWidget* aclWidget() = 0;
|
||||
|
||||
virtual QIcon icon() const = 0;
|
||||
@ -87,6 +87,7 @@ public:
|
||||
|
||||
virtual QSet< AccountType > types() const
|
||||
{
|
||||
QMutexLocker locker( &m_mutex );
|
||||
QSet< AccountType > set;
|
||||
foreach ( QString type, m_types )
|
||||
{
|
||||
@ -98,19 +99,20 @@ public:
|
||||
return set;
|
||||
}
|
||||
|
||||
virtual void setAccountServiceName( const QString &serviceName ) { m_accountServiceName = serviceName; }
|
||||
virtual void setAccountFriendlyName( const QString &friendlyName ) { m_accountFriendlyName = friendlyName; }
|
||||
virtual void setEnabled( bool enabled ) { m_enabled = enabled; }
|
||||
virtual void setAutoConnect( bool autoConnect ) { m_autoConnect = autoConnect; }
|
||||
virtual void setAccountId( const QString &accountId ) { m_accountId = accountId; }
|
||||
virtual void setCredentials( const QVariantHash &credentialHash ) { m_credentials = credentialHash; }
|
||||
virtual void setAccountServiceName( const QString &serviceName ) { QMutexLocker locker( &m_mutex ); m_accountServiceName = serviceName; }
|
||||
virtual void setAccountFriendlyName( const QString &friendlyName ) { QMutexLocker locker( &m_mutex ); m_accountFriendlyName = friendlyName; }
|
||||
virtual void setEnabled( bool enabled ) { QMutexLocker locker( &m_mutex ); m_enabled = enabled; }
|
||||
virtual void setAutoConnect( bool autoConnect ) { QMutexLocker locker( &m_mutex ); m_autoConnect = autoConnect; }
|
||||
virtual void setAccountId( const QString &accountId ) { QMutexLocker locker( &m_mutex ); m_accountId = accountId; }
|
||||
virtual void setCredentials( const QVariantHash &credentialHash ) { QMutexLocker locker( &m_mutex ); m_credentials = credentialHash; }
|
||||
|
||||
virtual void setConfiguration( const QVariantHash &configuration ) { m_configuration = configuration; }
|
||||
virtual void setConfiguration( const QVariantHash &configuration ) { QMutexLocker locker( &m_mutex ); m_configuration = configuration; }
|
||||
|
||||
virtual void setAcl( const QVariantMap &acl ) { m_acl = acl; }
|
||||
virtual void setAcl( const QVariantMap &acl ) { QMutexLocker locker( &m_mutex ); m_acl = acl; }
|
||||
|
||||
virtual void setTypes( const QSet< AccountType > types )
|
||||
{
|
||||
QMutexLocker locker( &m_mutex );
|
||||
m_types = QStringList();
|
||||
foreach ( AccountType type, types )
|
||||
{
|
||||
@ -129,6 +131,7 @@ public:
|
||||
|
||||
virtual void loadFromConfig( const QString &accountId )
|
||||
{
|
||||
QMutexLocker locker( &m_mutex );
|
||||
m_accountId = accountId;
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
s->beginGroup( "accounts/" + m_accountId );
|
||||
@ -144,6 +147,7 @@ public:
|
||||
|
||||
virtual void syncConfig()
|
||||
{
|
||||
QMutexLocker locker( &m_mutex );
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
s->beginGroup( "accounts/" + m_accountId );
|
||||
s->setValue( "accountfriendlyname", m_accountFriendlyName );
|
||||
@ -166,6 +170,7 @@ public:
|
||||
QVariantHash m_configuration;
|
||||
QVariantMap m_acl;
|
||||
QStringList m_types;
|
||||
mutable QMutex m_mutex;
|
||||
|
||||
signals:
|
||||
void configurationChanged();
|
||||
|
@ -130,9 +130,3 @@ SipPlugin::onPeerOffline( const QString& peerId )
|
||||
{
|
||||
m_peersOnline.removeAll( peerId );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SipPlugin::deletePlugin()
|
||||
{
|
||||
}
|
||||
|
@ -70,9 +70,6 @@ public slots:
|
||||
|
||||
virtual void refreshProxy();
|
||||
|
||||
// so plugins can clean up after themselves
|
||||
virtual void deletePlugin();
|
||||
|
||||
signals:
|
||||
void error( int, const QString& );
|
||||
void stateChanged( SipPlugin::ConnectionState state );
|
||||
|
@ -1,6 +1,6 @@
|
||||
#IF( LIBJREEN_FOUND )
|
||||
# ADD_SUBDIRECTORY( jabber )
|
||||
#ENDIF( LIBJREEN_FOUND )
|
||||
IF( LIBJREEN_FOUND )
|
||||
ADD_SUBDIRECTORY( xmpp )
|
||||
ENDIF( LIBJREEN_FOUND )
|
||||
|
||||
IF( QTWEETLIB_FOUND )
|
||||
ADD_SUBDIRECTORY( twitter )
|
||||
|
@ -95,7 +95,7 @@ TwitterSipPlugin::connectionState() const
|
||||
|
||||
void TwitterSipPlugin::checkSettings()
|
||||
{
|
||||
//TODO/FIXME: check status and enable/disable?
|
||||
configurationChanged();
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,22 +6,21 @@ add_definitions( -DQT_PLUGIN )
|
||||
add_definitions( -DQT_SHARED )
|
||||
add_definitions( -DSIPDLLEXPORT_PRO )
|
||||
|
||||
set( jabberSources
|
||||
jabber.cpp
|
||||
set( xmppSipSources
|
||||
xmppsip.cpp
|
||||
tomahawkxmppmessage.cpp
|
||||
tomahawkxmppmessagefactory.cpp
|
||||
avatarmanager.cpp
|
||||
xmlconsole.cpp
|
||||
)
|
||||
|
||||
set( jabberHeaders
|
||||
jabber.h
|
||||
set( xmppSipHeaders
|
||||
xmppsip.h
|
||||
avatarmanager.h
|
||||
xmlconsole.h
|
||||
)
|
||||
|
||||
set( jabberUI
|
||||
configwidget.ui
|
||||
set( xmppSipUI
|
||||
xmlconsole.ui
|
||||
)
|
||||
|
||||
@ -30,10 +29,9 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
|
||||
${LIBJREEN_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
qt4_add_resources( RC_SRCS "resources.qrc" )
|
||||
qt4_wrap_ui( jabberUI_H ${jabberUI} )
|
||||
qt4_wrap_cpp( jabberMoc ${jabberHeaders} )
|
||||
add_library( tomahawk_sipjabber SHARED ${jabberSources} ${jabberMoc} ${jabberUI_H} ${RC_SRCS} )
|
||||
qt4_wrap_ui( xmppSipUI_H ${xmppSipUI} )
|
||||
qt4_wrap_cpp( xmppSipMoc ${xmppSipHeaders} )
|
||||
add_library( tomahawk_sipxmpp SHARED ${xmppSipSources} ${xmppSipMoc} ${xmppSipUI_H} ${RC_SRCS} )
|
||||
|
||||
IF( WIN32 )
|
||||
SET( OS_SPECIFIC_LINK_LIBRARIES
|
||||
@ -44,7 +42,7 @@ SET( OS_SPECIFIC_LINK_LIBRARIES
|
||||
)
|
||||
ENDIF( WIN32 )
|
||||
|
||||
target_link_libraries( tomahawk_sipjabber
|
||||
target_link_libraries( tomahawk_sipxmpp
|
||||
${QT_LIBRARIES}
|
||||
${LIBJREEN_LIBRARY}
|
||||
${OS_SPECIFIC_LINK_LIBRARIES}
|
||||
@ -55,7 +53,7 @@ IF( APPLE )
|
||||
# SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" )
|
||||
ENDIF( APPLE )
|
||||
|
||||
install( TARGETS tomahawk_sipjabber DESTINATION lib${LIB_SUFFIX} )
|
||||
install( TARGETS tomahawk_sipxmpp DESTINATION lib${LIB_SUFFIX} )
|
||||
|
||||
|
||||
add_subdirectory(googlewrapper)
|
||||
#add_subdirectory(googlewrapper)
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
@ -21,7 +21,7 @@
|
||||
#include "utils/logger.h"
|
||||
|
||||
|
||||
class TomahawkXMPPMessagePrivate
|
||||
class TomahawkXmppMessagePrivate
|
||||
{
|
||||
public:
|
||||
QString ip;
|
||||
@ -31,9 +31,9 @@ public:
|
||||
bool visible;
|
||||
};
|
||||
|
||||
TomahawkXMPPMessage::TomahawkXMPPMessage(const QString &ip, unsigned int port, const QString &uniqname, const QString &key) : d_ptr(new TomahawkXMPPMessagePrivate)
|
||||
TomahawkXmppMessage::TomahawkXmppMessage(const QString &ip, unsigned int port, const QString &uniqname, const QString &key) : d_ptr(new TomahawkXmppMessagePrivate)
|
||||
{
|
||||
Q_D(TomahawkXMPPMessage);
|
||||
Q_D(TomahawkXmppMessage);
|
||||
d->ip = ip;
|
||||
d->port = port;
|
||||
d->uniqname = uniqname;
|
||||
@ -41,39 +41,39 @@ TomahawkXMPPMessage::TomahawkXMPPMessage(const QString &ip, unsigned int port, c
|
||||
d->visible = true;
|
||||
}
|
||||
|
||||
TomahawkXMPPMessage::TomahawkXMPPMessage() : d_ptr(new TomahawkXMPPMessagePrivate)
|
||||
TomahawkXmppMessage::TomahawkXmppMessage() : d_ptr(new TomahawkXmppMessagePrivate)
|
||||
{
|
||||
Q_D(TomahawkXMPPMessage);
|
||||
Q_D(TomahawkXmppMessage);
|
||||
d->visible = false;
|
||||
d->port = -1;
|
||||
}
|
||||
|
||||
|
||||
TomahawkXMPPMessage::~TomahawkXMPPMessage()
|
||||
TomahawkXmppMessage::~TomahawkXmppMessage()
|
||||
{
|
||||
}
|
||||
|
||||
const QString TomahawkXMPPMessage::ip() const
|
||||
const QString TomahawkXmppMessage::ip() const
|
||||
{
|
||||
return d_func()->ip;
|
||||
}
|
||||
|
||||
unsigned int TomahawkXMPPMessage::port() const
|
||||
unsigned int TomahawkXmppMessage::port() const
|
||||
{
|
||||
return d_func()->port;
|
||||
}
|
||||
|
||||
const QString TomahawkXMPPMessage::uniqname() const
|
||||
const QString TomahawkXmppMessage::uniqname() const
|
||||
{
|
||||
return d_func()->uniqname;
|
||||
}
|
||||
|
||||
const QString TomahawkXMPPMessage::key() const
|
||||
const QString TomahawkXmppMessage::key() const
|
||||
{
|
||||
return d_func()->key;
|
||||
}
|
||||
|
||||
bool TomahawkXMPPMessage::visible() const
|
||||
bool TomahawkXmppMessage::visible() const
|
||||
{
|
||||
return d_func()->visible;
|
||||
}
|
@ -25,18 +25,18 @@
|
||||
|
||||
#include "../sipdllmacro.h"
|
||||
|
||||
class TomahawkXMPPMessagePrivate;
|
||||
class SIPDLLEXPORT TomahawkXMPPMessage : public Jreen::Payload
|
||||
class TomahawkXmppMessagePrivate;
|
||||
class SIPDLLEXPORT TomahawkXmppMessage : public Jreen::Payload
|
||||
{
|
||||
J_PAYLOAD(TomahawkXMPPMessage)
|
||||
Q_DECLARE_PRIVATE(TomahawkXMPPMessage)
|
||||
J_PAYLOAD(TomahawkXmppMessage)
|
||||
Q_DECLARE_PRIVATE(TomahawkXmppMessage)
|
||||
public:
|
||||
// sets visible to true
|
||||
TomahawkXMPPMessage(const QString &ip, unsigned int port, const QString &uniqname, const QString &key);
|
||||
TomahawkXmppMessage(const QString &ip, unsigned int port, const QString &uniqname, const QString &key);
|
||||
|
||||
// sets visible to false as we dont have any extra information
|
||||
TomahawkXMPPMessage();
|
||||
~TomahawkXMPPMessage();
|
||||
TomahawkXmppMessage();
|
||||
~TomahawkXmppMessage();
|
||||
|
||||
const QString ip() const;
|
||||
unsigned int port() const;
|
||||
@ -44,7 +44,7 @@ class SIPDLLEXPORT TomahawkXMPPMessage : public Jreen::Payload
|
||||
const QString key() const;
|
||||
bool visible() const;
|
||||
private:
|
||||
QScopedPointer<TomahawkXMPPMessagePrivate> d_ptr;
|
||||
QScopedPointer<TomahawkXmppMessagePrivate> d_ptr;
|
||||
};
|
||||
|
||||
#endif // ENTITYTIME_H
|
@ -26,29 +26,29 @@
|
||||
|
||||
using namespace Jreen;
|
||||
|
||||
TomahawkXMPPMessageFactory::TomahawkXMPPMessageFactory()
|
||||
TomahawkXmppMessageFactory::TomahawkXmppMessageFactory()
|
||||
{
|
||||
m_depth = 0;
|
||||
m_state = AtNowhere;
|
||||
}
|
||||
|
||||
TomahawkXMPPMessageFactory::~TomahawkXMPPMessageFactory()
|
||||
TomahawkXmppMessageFactory::~TomahawkXmppMessageFactory()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList TomahawkXMPPMessageFactory::features() const
|
||||
QStringList TomahawkXmppMessageFactory::features() const
|
||||
{
|
||||
return QStringList(TOMAHAWK_SIP_MESSAGE_NS);
|
||||
}
|
||||
|
||||
bool TomahawkXMPPMessageFactory::canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes)
|
||||
bool TomahawkXmppMessageFactory::canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes)
|
||||
{
|
||||
Q_UNUSED(uri);
|
||||
Q_UNUSED(attributes);
|
||||
return name == QLatin1String("tomahawk") && uri == TOMAHAWK_SIP_MESSAGE_NS;
|
||||
}
|
||||
|
||||
void TomahawkXMPPMessageFactory::handleStartElement(const QStringRef &name, const QStringRef &uri,
|
||||
void TomahawkXmppMessageFactory::handleStartElement(const QStringRef &name, const QStringRef &uri,
|
||||
const QXmlStreamAttributes &attributes)
|
||||
{
|
||||
m_depth++;
|
||||
@ -83,7 +83,7 @@ void TomahawkXMPPMessageFactory::handleStartElement(const QStringRef &name, cons
|
||||
Q_UNUSED(attributes);
|
||||
}
|
||||
|
||||
void TomahawkXMPPMessageFactory::handleEndElement(const QStringRef &name, const QStringRef &uri)
|
||||
void TomahawkXmppMessageFactory::handleEndElement(const QStringRef &name, const QStringRef &uri)
|
||||
{
|
||||
if (m_depth == 3)
|
||||
m_state = AtNowhere;
|
||||
@ -92,7 +92,7 @@ void TomahawkXMPPMessageFactory::handleEndElement(const QStringRef &name, const
|
||||
m_depth--;
|
||||
}
|
||||
|
||||
void TomahawkXMPPMessageFactory::handleCharacterData(const QStringRef &text)
|
||||
void TomahawkXmppMessageFactory::handleCharacterData(const QStringRef &text)
|
||||
{
|
||||
/*if (m_state == AtUtc) {
|
||||
//m_utc = Util::fromStamp(text.toString());
|
||||
@ -105,9 +105,9 @@ void TomahawkXMPPMessageFactory::handleCharacterData(const QStringRef &text)
|
||||
Q_UNUSED(text);
|
||||
}
|
||||
|
||||
void TomahawkXMPPMessageFactory::serialize(Payload *extension, QXmlStreamWriter *writer)
|
||||
void TomahawkXmppMessageFactory::serialize(Payload *extension, QXmlStreamWriter *writer)
|
||||
{
|
||||
TomahawkXMPPMessage *sipMessage = se_cast<TomahawkXMPPMessage*>(extension);
|
||||
TomahawkXmppMessage *sipMessage = se_cast<TomahawkXmppMessage*>(extension);
|
||||
|
||||
writer->writeStartElement(QLatin1String("tomahawk"));
|
||||
writer->writeDefaultNamespace(TOMAHAWK_SIP_MESSAGE_NS);
|
||||
@ -137,10 +137,10 @@ void TomahawkXMPPMessageFactory::serialize(Payload *extension, QXmlStreamWriter
|
||||
writer->writeEndElement();
|
||||
}
|
||||
|
||||
Payload::Ptr TomahawkXMPPMessageFactory::createPayload()
|
||||
Payload::Ptr TomahawkXmppMessageFactory::createPayload()
|
||||
{
|
||||
if(m_visible)
|
||||
return Payload::Ptr(new TomahawkXMPPMessage(m_ip, m_port, m_uniqname, m_key));
|
||||
return Payload::Ptr(new TomahawkXmppMessage(m_ip, m_port, m_uniqname, m_key));
|
||||
else
|
||||
return Payload::Ptr(new TomahawkXMPPMessage());
|
||||
return Payload::Ptr(new TomahawkXmppMessage());
|
||||
}
|
@ -25,11 +25,11 @@
|
||||
|
||||
#include "../sipdllmacro.h"
|
||||
|
||||
class SIPDLLEXPORT TomahawkXMPPMessageFactory : public Jreen::PayloadFactory<TomahawkXMPPMessage>
|
||||
class SIPDLLEXPORT TomahawkXmppMessageFactory : public Jreen::PayloadFactory<TomahawkXmppMessage>
|
||||
{
|
||||
public:
|
||||
TomahawkXMPPMessageFactory();
|
||||
virtual ~TomahawkXMPPMessageFactory();
|
||||
TomahawkXmppMessageFactory();
|
||||
virtual ~TomahawkXmppMessageFactory();
|
||||
QStringList features() const;
|
||||
bool canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes);
|
||||
void handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes);
|
@ -17,14 +17,12 @@
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "jabber.h"
|
||||
#include "ui_configwidget.h"
|
||||
#include "xmppsip.h"
|
||||
|
||||
#include "xmlconsole.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "tomahawksettings.h"
|
||||
#include "tomahawkxmppmessage.h"
|
||||
#include "tomahawkxmppmessagefactory.h"
|
||||
|
||||
@ -49,54 +47,30 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include <utils/tomahawkutils.h>
|
||||
#include "utils/logger.h"
|
||||
#include <utils/logger.h>
|
||||
#include <accounts/accountmanager.h>
|
||||
|
||||
SipPlugin*
|
||||
JabberFactory::createPlugin( const QString& pluginId )
|
||||
{
|
||||
return new JabberPlugin( pluginId.isEmpty() ? generateId() : pluginId );
|
||||
}
|
||||
|
||||
QIcon
|
||||
JabberFactory::icon() const
|
||||
{
|
||||
return QIcon( ":/jabber-icon.png" );
|
||||
}
|
||||
|
||||
JabberPlugin::JabberPlugin( const QString& pluginId )
|
||||
: SipPlugin( pluginId )
|
||||
XmppSipPlugin::XmppSipPlugin( Tomahawk::Accounts::Account *account )
|
||||
: SipPlugin( account )
|
||||
, m_menu( 0 )
|
||||
, m_xmlConsole( 0 )
|
||||
, m_state( Disconnected )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_configWidget = QWeakPointer< QWidget >( new QWidget );
|
||||
m_ui = new Ui_JabberConfig;
|
||||
m_ui->setupUi( m_configWidget.data() );
|
||||
m_configWidget.data()->setVisible( false );
|
||||
|
||||
m_currentUsername = accountName();
|
||||
m_currentUsername = readUsername();
|
||||
m_currentServer = readServer();
|
||||
m_currentPassword = readPassword();
|
||||
m_currentPort = readPort();
|
||||
|
||||
m_ui->jabberUsername->setText( m_currentUsername );
|
||||
m_ui->jabberPassword->setText( m_currentPassword );
|
||||
m_ui->jabberServer->setText( m_currentServer );
|
||||
m_ui->jabberPort->setValue( m_currentPort );
|
||||
m_ui->jidExistsLabel->hide();
|
||||
|
||||
|
||||
connect( m_ui->jabberUsername, SIGNAL( textChanged( QString ) ), SLOT( onCheckJidExists( QString ) ) );
|
||||
// setup JID object
|
||||
Jreen::JID jid = Jreen::JID( accountName() );
|
||||
Jreen::JID jid = Jreen::JID( readUsername() );
|
||||
|
||||
// general client setup
|
||||
m_client = new Jreen::Client( jid, m_currentPassword );
|
||||
setupClientHelper();
|
||||
|
||||
m_client->registerPayload(new TomahawkXMPPMessageFactory);
|
||||
m_client->registerPayload( new TomahawkXmppMessageFactory );
|
||||
m_currentResource = QString::fromAscii( "tomahawk%1" ).arg( QString::number( qrand() % 10000 ) );
|
||||
m_client->setResource( m_currentResource );
|
||||
|
||||
@ -145,55 +119,22 @@ JabberPlugin::JabberPlugin( const QString& pluginId )
|
||||
connect(m_avatarManager, SIGNAL(newAvatar(QString)), SLOT(onNewAvatar(QString)));
|
||||
}
|
||||
|
||||
JabberPlugin::~JabberPlugin()
|
||||
XmppSipPlugin::~XmppSipPlugin()
|
||||
{
|
||||
delete m_avatarManager;
|
||||
delete m_roster;
|
||||
delete m_xmlConsole;
|
||||
delete m_client;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
const QString
|
||||
JabberPlugin::name() const
|
||||
{
|
||||
return QString( MYNAME );
|
||||
}
|
||||
|
||||
const QString
|
||||
JabberPlugin::friendlyName() const
|
||||
{
|
||||
return QString( "Jabber" );
|
||||
}
|
||||
|
||||
const QString
|
||||
JabberPlugin::accountName() const
|
||||
{
|
||||
return TomahawkSettings::instance()->value( pluginId() + "/username" ).toString();
|
||||
}
|
||||
|
||||
QMenu*
|
||||
JabberPlugin::menu()
|
||||
XmppSipPlugin::menu()
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
|
||||
QWidget*
|
||||
JabberPlugin::configWidget()
|
||||
{
|
||||
return m_configWidget.data();
|
||||
}
|
||||
|
||||
QIcon
|
||||
JabberPlugin::icon() const
|
||||
{
|
||||
return QIcon( ":/jabber-icon.png" );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
JabberPlugin::connectPlugin()
|
||||
XmppSipPlugin::connectPlugin()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@ -203,7 +144,7 @@ JabberPlugin::connectPlugin()
|
||||
return true; //FIXME: should i return false here?!
|
||||
}
|
||||
|
||||
qDebug() << "Connecting to the XMPP server..." << m_client->jid().full();
|
||||
qDebug() << "Connecting to the Xmpp server..." << m_client->jid().full();
|
||||
|
||||
//FIXME: we're badly workarounding some missing reconnection api here, to be fixed soon
|
||||
QTimer::singleShot( 1000, m_client, SLOT( connectToServer() ) );
|
||||
@ -217,7 +158,7 @@ JabberPlugin::connectPlugin()
|
||||
}
|
||||
|
||||
void
|
||||
JabberPlugin::disconnectPlugin()
|
||||
XmppSipPlugin::disconnectPlugin()
|
||||
{
|
||||
if (!m_client->isConnected())
|
||||
{
|
||||
@ -242,7 +183,7 @@ JabberPlugin::disconnectPlugin()
|
||||
}
|
||||
|
||||
void
|
||||
JabberPlugin::onConnect()
|
||||
XmppSipPlugin::onConnect()
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@ -254,7 +195,7 @@ JabberPlugin::onConnect()
|
||||
emit jidChanged( m_client->jid().full() );
|
||||
}
|
||||
|
||||
qDebug() << "Connected to jabber as:" << m_client->jid().full();
|
||||
qDebug() << "Connected to xmpp as:" << m_client->jid().full();
|
||||
|
||||
// set presence to least valid value
|
||||
m_client->setPresence(Jreen::Presence::XA, "Got Tomahawk? http://gettomahawk.com", -127);
|
||||
@ -284,7 +225,7 @@ JabberPlugin::onConnect()
|
||||
}
|
||||
|
||||
void
|
||||
JabberPlugin::onDisconnect( Jreen::Client::DisconnectReason reason )
|
||||
XmppSipPlugin::onDisconnect( Jreen::Client::DisconnectReason reason )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@ -325,13 +266,13 @@ JabberPlugin::onDisconnect( Jreen::Client::DisconnectReason reason )
|
||||
}
|
||||
|
||||
void
|
||||
JabberPlugin::onError( const Jreen::Connection::SocketError& e )
|
||||
XmppSipPlugin::onError( const Jreen::Connection::SocketError& e )
|
||||
{
|
||||
tLog() << "JABBER error:" << e;
|
||||
}
|
||||
|
||||
QString
|
||||
JabberPlugin::errorMessage( Jreen::Client::DisconnectReason reason )
|
||||
XmppSipPlugin::errorMessage( Jreen::Client::DisconnectReason reason )
|
||||
{
|
||||
switch( reason )
|
||||
{
|
||||
@ -380,7 +321,7 @@ JabberPlugin::errorMessage( Jreen::Client::DisconnectReason reason )
|
||||
}
|
||||
|
||||
void
|
||||
JabberPlugin::sendMsg(const QString& to, const QString& msg)
|
||||
XmppSipPlugin::sendMsg(const QString& to, const QString& msg)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << to << msg;
|
||||
|
||||
@ -396,16 +337,16 @@ JabberPlugin::sendMsg(const QString& to, const QString& msg)
|
||||
QVariant v = parser.parse( msg.toAscii(), &ok );
|
||||
if ( !ok || v.type() != QVariant::Map )
|
||||
{
|
||||
qDebug() << "Invalid JSON in XMPP msg";
|
||||
qDebug() << "Invalid JSON in Xmpp msg";
|
||||
return;
|
||||
}
|
||||
QVariantMap m = v.toMap();
|
||||
/*******************************************************/
|
||||
|
||||
TomahawkXMPPMessage *sipMessage;
|
||||
TomahawkXmppMessage *sipMessage;
|
||||
if(m["visible"].toBool())
|
||||
{
|
||||
sipMessage = new TomahawkXMPPMessage(m["ip"].toString(),
|
||||
sipMessage = new TomahawkXmppMessage(m["ip"].toString(),
|
||||
m["port"].toInt(),
|
||||
m["uniqname"].toString(),
|
||||
m["key"].toString()
|
||||
@ -413,7 +354,7 @@ JabberPlugin::sendMsg(const QString& to, const QString& msg)
|
||||
}
|
||||
else
|
||||
{
|
||||
sipMessage = new TomahawkXMPPMessage();
|
||||
sipMessage = new TomahawkXmppMessage();
|
||||
}
|
||||
|
||||
qDebug() << "Send sip messsage to " << to;
|
||||
@ -425,7 +366,7 @@ JabberPlugin::sendMsg(const QString& to, const QString& msg)
|
||||
}
|
||||
|
||||
void
|
||||
JabberPlugin::broadcastMsg(const QString& msg)
|
||||
XmppSipPlugin::broadcastMsg(const QString& msg)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@ -439,7 +380,7 @@ JabberPlugin::broadcastMsg(const QString& msg)
|
||||
}
|
||||
|
||||
void
|
||||
JabberPlugin::addContact(const QString& jid, const QString& msg)
|
||||
XmppSipPlugin::addContact(const QString& jid, const QString& msg)
|
||||
{
|
||||
// Add contact to the Tomahawk group on the roster
|
||||
|
||||
@ -453,40 +394,48 @@ JabberPlugin::addContact(const QString& jid, const QString& msg)
|
||||
}
|
||||
|
||||
void
|
||||
JabberPlugin::showAddFriendDialog()
|
||||
XmppSipPlugin::showAddFriendDialog()
|
||||
{
|
||||
bool ok;
|
||||
QString id = QInputDialog::getText( TomahawkUtils::tomahawkWindow(), tr( "Add Friend" ),
|
||||
tr( "Enter Jabber ID:" ), QLineEdit::Normal, "", &ok );
|
||||
tr( "Enter Xmpp ID:" ), QLineEdit::Normal, "", &ok );
|
||||
if ( !ok )
|
||||
return;
|
||||
|
||||
qDebug() << "Attempting to add jabber contact to roster:" << id;
|
||||
qDebug() << "Attempting to add xmpp contact to roster:" << id;
|
||||
addContact( id );
|
||||
}
|
||||
|
||||
QString
|
||||
JabberPlugin::defaultSuffix() const
|
||||
XmppSipPlugin::defaultSuffix() const
|
||||
{
|
||||
return "@jabber.org";
|
||||
return "@xmpp.org";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
JabberPlugin::showXmlConsole()
|
||||
XmppSipPlugin::showXmlConsole()
|
||||
{
|
||||
m_xmlConsole->show();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
JabberPlugin::checkSettings()
|
||||
XmppSipPlugin::checkSettings()
|
||||
{
|
||||
configurationChanged();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmppSipPlugin::configurationChanged()
|
||||
{
|
||||
bool reconnect = false;
|
||||
|
||||
QString username, password, server;
|
||||
int port;
|
||||
|
||||
username = accountName();
|
||||
username = readUsername();
|
||||
password = readPassword();
|
||||
server = readServer();
|
||||
port = readPort();
|
||||
@ -515,7 +464,10 @@ JabberPlugin::checkSettings()
|
||||
if ( !m_currentUsername.contains( '@' ) )
|
||||
{
|
||||
m_currentUsername += defaultSuffix();
|
||||
TomahawkSettings::instance()->setValue( pluginId() + "/username", m_currentUsername );
|
||||
QVariantHash credentials = m_account->credentials();
|
||||
credentials[ "username" ] = m_currentUsername;
|
||||
m_account->setCredentials( credentials );
|
||||
m_account->syncConfig();
|
||||
}
|
||||
|
||||
if ( reconnect )
|
||||
@ -530,7 +482,7 @@ JabberPlugin::checkSettings()
|
||||
}
|
||||
}
|
||||
|
||||
void JabberPlugin::setupClientHelper()
|
||||
void XmppSipPlugin::setupClientHelper()
|
||||
{
|
||||
Jreen::JID jid = Jreen::JID( m_currentUsername );
|
||||
m_client->setJID( jid );
|
||||
@ -550,11 +502,11 @@ void JabberPlugin::setupClientHelper()
|
||||
}
|
||||
}
|
||||
|
||||
void JabberPlugin::addMenuHelper()
|
||||
void XmppSipPlugin::addMenuHelper()
|
||||
{
|
||||
if( !m_menu )
|
||||
{
|
||||
m_menu = new QMenu( QString( "%1 (" ).arg( friendlyName() ).append( accountName() ).append(")" ) );
|
||||
m_menu = new QMenu( QString( "%1 (" ).arg( friendlyName() ).append( readUsername() ).append(")" ) );
|
||||
|
||||
QAction* addFriendAction = m_menu->addAction( tr( "Add Friend..." ) );
|
||||
connect( addFriendAction, SIGNAL( triggered() ), this, SLOT( showAddFriendDialog() ) );
|
||||
@ -569,7 +521,7 @@ void JabberPlugin::addMenuHelper()
|
||||
}
|
||||
}
|
||||
|
||||
void JabberPlugin::removeMenuHelper()
|
||||
void XmppSipPlugin::removeMenuHelper()
|
||||
{
|
||||
if( m_menu )
|
||||
{
|
||||
@ -580,7 +532,7 @@ void JabberPlugin::removeMenuHelper()
|
||||
}
|
||||
}
|
||||
|
||||
void JabberPlugin::onNewMessage(const Jreen::Message& message)
|
||||
void XmppSipPlugin::onNewMessage(const Jreen::Message& message)
|
||||
{
|
||||
if ( m_state != Connected )
|
||||
return;
|
||||
@ -621,7 +573,7 @@ void JabberPlugin::onNewMessage(const Jreen::Message& message)
|
||||
}
|
||||
|
||||
|
||||
void JabberPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr &item, const Jreen::Presence& presence )
|
||||
void XmppSipPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr &item, const Jreen::Presence& presence )
|
||||
{
|
||||
Q_UNUSED(item);
|
||||
if ( m_state != Connected )
|
||||
@ -664,7 +616,7 @@ void JabberPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr &item, const
|
||||
}
|
||||
}
|
||||
|
||||
void JabberPlugin::onSubscriptionReceived(const Jreen::RosterItem::Ptr& item, const Jreen::Presence& presence)
|
||||
void XmppSipPlugin::onSubscriptionReceived(const Jreen::RosterItem::Ptr& item, const Jreen::Presence& presence)
|
||||
{
|
||||
if ( m_state != Connected )
|
||||
return;
|
||||
@ -716,7 +668,7 @@ void JabberPlugin::onSubscriptionReceived(const Jreen::RosterItem::Ptr& item, co
|
||||
}
|
||||
|
||||
void
|
||||
JabberPlugin::onSubscriptionRequestConfirmed( int result )
|
||||
XmppSipPlugin::onSubscriptionRequestConfirmed( int result )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << result;
|
||||
|
||||
@ -750,7 +702,7 @@ JabberPlugin::onSubscriptionRequestConfirmed( int result )
|
||||
m_roster->allowSubscription( jid, allowSubscription == QMessageBox::Yes );
|
||||
}
|
||||
|
||||
void JabberPlugin::onNewIq(const Jreen::IQ& iq)
|
||||
void XmppSipPlugin::onNewIq(const Jreen::IQ& iq)
|
||||
{
|
||||
if ( m_state != Connected )
|
||||
return;
|
||||
@ -802,7 +754,7 @@ void JabberPlugin::onNewIq(const Jreen::IQ& iq)
|
||||
}*/
|
||||
else
|
||||
{
|
||||
TomahawkXMPPMessage::Ptr sipMessage = iq.payload<TomahawkXMPPMessage>();
|
||||
TomahawkXmppMessage::Ptr sipMessage = iq.payload<TomahawkXmppMessage>();
|
||||
if(sipMessage)
|
||||
{
|
||||
iq.accept();
|
||||
@ -831,7 +783,7 @@ void JabberPlugin::onNewIq(const Jreen::IQ& iq)
|
||||
}
|
||||
}
|
||||
|
||||
bool JabberPlugin::presenceMeansOnline(Jreen::Presence::Type p)
|
||||
bool XmppSipPlugin::presenceMeansOnline(Jreen::Presence::Type p)
|
||||
{
|
||||
switch(p)
|
||||
{
|
||||
@ -845,7 +797,7 @@ bool JabberPlugin::presenceMeansOnline(Jreen::Presence::Type p)
|
||||
}
|
||||
}
|
||||
|
||||
void JabberPlugin::handlePeerStatus(const Jreen::JID& jid, Jreen::Presence::Type presenceType)
|
||||
void XmppSipPlugin::handlePeerStatus(const Jreen::JID& jid, Jreen::Presence::Type presenceType)
|
||||
{
|
||||
QString fulljid = jid.full();
|
||||
|
||||
@ -892,7 +844,7 @@ void JabberPlugin::handlePeerStatus(const Jreen::JID& jid, Jreen::Presence::Type
|
||||
m_peers[ jid ] = presenceType;
|
||||
}
|
||||
|
||||
void JabberPlugin::onNewAvatar(const QString& jid)
|
||||
void XmppSipPlugin::onNewAvatar(const QString& jid)
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO << jid;
|
||||
if ( m_state != Connected )
|
||||
@ -918,82 +870,49 @@ void JabberPlugin::onNewAvatar(const QString& jid)
|
||||
emit avatarReceived ( jid, m_avatarManager->avatar( jid ) );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
JabberPlugin::readXmlConsoleEnabled()
|
||||
XmppSipPlugin::readXmlConsoleEnabled()
|
||||
{
|
||||
return TomahawkSettings::instance()->value( pluginId() + "/xmlconsole", QVariant( false ) ).toBool();
|
||||
QVariantHash configuration = m_account->configuration();
|
||||
return configuration.contains( "xmlconsole" ) && configuration[ "xmlconsole" ].toBool();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
JabberPlugin::readPassword()
|
||||
XmppSipPlugin::readUsername()
|
||||
{
|
||||
return TomahawkSettings::instance()->value( pluginId() + "/password" ).toString();
|
||||
QVariantHash credentials = m_account->credentials();
|
||||
return credentials.contains( "username" ) ? credentials[ "username" ].toString() : QString();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
XmppSipPlugin::readPassword()
|
||||
{
|
||||
QVariantHash credentials = m_account->credentials();
|
||||
return credentials.contains( "password" ) ? credentials[ "password" ].toString() : QString();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
JabberPlugin::readPort()
|
||||
XmppSipPlugin::readPort()
|
||||
{
|
||||
return TomahawkSettings::instance()->value( pluginId() + "/port", 5222 ).toInt();
|
||||
QVariantHash configuration = m_account->configuration();
|
||||
return configuration.contains( "port" ) ? configuration[ "port" ].toInt() : 5222;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
JabberPlugin::readServer()
|
||||
XmppSipPlugin::readServer()
|
||||
{
|
||||
return TomahawkSettings::instance()->value( pluginId() + "/server" ).toString();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
JabberPlugin::onCheckJidExists( QString jid )
|
||||
{
|
||||
for ( int i=0; i<TomahawkSettings::instance()->sipPlugins().count(); i++ )
|
||||
{
|
||||
QString savedUsername = TomahawkSettings::instance()->value(
|
||||
TomahawkSettings::instance()->sipPlugins().at( i ) + "/username" ).toString();
|
||||
QStringList splitUserName = TomahawkSettings::instance()->value(
|
||||
TomahawkSettings::instance()->sipPlugins().at( i ) + "/username" ).toString().split("@");
|
||||
QString server = TomahawkSettings::instance()->value(
|
||||
TomahawkSettings::instance()->sipPlugins().at( i ) + "/server" ).toString();
|
||||
|
||||
if ( ( savedUsername == jid || splitUserName.contains( jid ) ) &&
|
||||
server == m_ui->jabberServer->text() && !jid.trimmed().isEmpty() )
|
||||
{
|
||||
m_ui->jidExistsLabel->show();
|
||||
// the already jid exists
|
||||
emit dataError( true );
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_ui->jidExistsLabel->hide();
|
||||
emit dataError( false );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
JabberPlugin::saveConfig()
|
||||
{
|
||||
TomahawkSettings::instance()->setValue( pluginId() + "/username", m_ui->jabberUsername->text() );
|
||||
TomahawkSettings::instance()->setValue( pluginId() + "/password", m_ui->jabberPassword->text() );
|
||||
TomahawkSettings::instance()->setValue( pluginId() + "/port", m_ui->jabberPort->value() );
|
||||
TomahawkSettings::instance()->setValue( pluginId() + "/server", m_ui->jabberServer->text() );
|
||||
|
||||
checkSettings();
|
||||
}
|
||||
|
||||
void
|
||||
JabberPlugin::deletePlugin()
|
||||
{
|
||||
TomahawkSettings::instance()->remove( pluginId() );
|
||||
QVariantHash configuration = m_account->configuration();
|
||||
return configuration.contains( "server" ) ? configuration[ "server" ].toString() : QString();
|
||||
}
|
||||
|
||||
|
||||
SipPlugin::ConnectionState
|
||||
JabberPlugin::connectionState() const
|
||||
XmppSipPlugin::connectionState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
#ifndef GOOGLE_WRAPPER
|
||||
Q_EXPORT_PLUGIN2( sipfactory, JabberFactory )
|
||||
#endif
|
@ -17,8 +17,8 @@
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef JABBER_H
|
||||
#define JABBER_H
|
||||
#ifndef XMPPSIP_H
|
||||
#define XMPPSIP_H
|
||||
|
||||
#include "sip/SipPlugin.h"
|
||||
|
||||
@ -40,57 +40,32 @@
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#define MYNAME "SIPJREEN"
|
||||
#define TOMAHAWK_FEATURE QLatin1String( "tomahawk:sip:v1" )
|
||||
#define TOMAHAWK_CAP_NODE_NAME QLatin1String( "http://tomahawk-player.org/" )
|
||||
|
||||
#include "../sipdllmacro.h"
|
||||
|
||||
class Ui_JabberConfig;
|
||||
|
||||
class SIPDLLEXPORT JabberFactory : public SipPluginFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES( SipPluginFactory )
|
||||
|
||||
public:
|
||||
JabberFactory() {}
|
||||
virtual ~JabberFactory() {}
|
||||
|
||||
virtual QString prettyName() const { return "Jabber"; }
|
||||
virtual QString factoryId() const { return "sipjabber"; }
|
||||
virtual QIcon icon() const;
|
||||
virtual SipPlugin* createPlugin( const QString& pluginId );
|
||||
};
|
||||
|
||||
class SIPDLLEXPORT JabberPlugin : public SipPlugin
|
||||
class SIPDLLEXPORT XmppSipPlugin : public SipPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
JabberPlugin( const QString& pluginId );
|
||||
virtual ~JabberPlugin();
|
||||
XmppSipPlugin( Tomahawk::Accounts::Account* account );
|
||||
virtual ~XmppSipPlugin();
|
||||
|
||||
//FIXME: Make this more correct
|
||||
virtual bool isValid() const { return true; }
|
||||
virtual const QString name() const;
|
||||
virtual const QString friendlyName() const;
|
||||
virtual const QString accountName() const;
|
||||
virtual ConnectionState connectionState() const;
|
||||
virtual QMenu* menu();
|
||||
virtual QIcon icon() const;
|
||||
virtual QWidget* configWidget();
|
||||
virtual void saveConfig();
|
||||
virtual void deletePlugin();
|
||||
|
||||
signals:
|
||||
void dataError( bool exists );
|
||||
void jidChanged( const QString& );
|
||||
|
||||
public slots:
|
||||
virtual bool connectPlugin();
|
||||
void disconnectPlugin();
|
||||
void checkSettings();
|
||||
void configurationChanged();
|
||||
void sendMsg( const QString& to, const QString& msg );
|
||||
void broadcastMsg( const QString &msg );
|
||||
void addContact( const QString &jid, const QString& msg = QString() );
|
||||
@ -99,8 +74,6 @@ public slots:
|
||||
protected:
|
||||
virtual QString defaultSuffix() const;
|
||||
|
||||
Ui_JabberConfig* m_ui; // so the google wrapper can change the config dialog a bit
|
||||
|
||||
private slots:
|
||||
void showXmlConsole();
|
||||
void onConnect();
|
||||
@ -114,10 +87,10 @@ private slots:
|
||||
void onError( const Jreen::Connection::SocketError& e );
|
||||
void onNewIq( const Jreen::IQ &iq );
|
||||
void onNewAvatar( const QString &jid );
|
||||
void onCheckJidExists( QString jid );
|
||||
|
||||
private:
|
||||
bool readXmlConsoleEnabled();
|
||||
QString readUsername();
|
||||
QString readPassword();
|
||||
QString readServer();
|
||||
int readPort();
|
||||
@ -140,8 +113,6 @@ private:
|
||||
int m_currentPort;
|
||||
ConnectionState m_state;
|
||||
|
||||
QWeakPointer< QWidget > m_configWidget;
|
||||
|
||||
QString m_currentResource;
|
||||
|
||||
// sort out
|
Loading…
x
Reference in New Issue
Block a user