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