mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 01:09:42 +01:00
Be more responsive about adding contacts
This commit is contained in:
parent
b5d1f8a8ba
commit
d3bd359e1a
@ -462,11 +462,16 @@ void
|
||||
XmppSipPlugin::addContact( const QString& jid, const QString& msg )
|
||||
{
|
||||
// Add contact to the Tomahawk group on the roster
|
||||
QString realJid = jid;
|
||||
if ( !realJid.contains( '@' ) )
|
||||
realJid += defaultSuffix();
|
||||
|
||||
m_roster->subscribe( realJid, msg, realJid, QStringList() << "Tomahawk" );
|
||||
QStringList jidParts = jid.split( '@' );
|
||||
if( jidParts.count() == 2 && !jidParts[0].trimmed().isEmpty() && !jidParts[1].trimmed().isEmpty() )
|
||||
{
|
||||
m_roster->subscribe( jid, msg, jid, QStringList() << "Tomahawk" );
|
||||
emit inviteSentSuccess( jid );
|
||||
}
|
||||
else
|
||||
{
|
||||
emit inviteSentFailure( jid );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -210,6 +210,7 @@ list(APPEND libSources
|
||||
sip/SipPlugin.cpp
|
||||
sip/SipInfo.cpp
|
||||
sip/PeerInfo.cpp
|
||||
sip/SipStatusMessage.cpp
|
||||
|
||||
audio/AudioEngine.cpp
|
||||
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
/// Please cache this.
|
||||
virtual QPixmap icon() const = 0;
|
||||
virtual QString mainText() const = 0;
|
||||
virtual QString rightColumnText() const = 0;
|
||||
virtual QString rightColumnText() const { return QString(); };
|
||||
|
||||
/**
|
||||
* If collapse item is true, sending multiple items of the same type will "collapse" them into one
|
||||
|
@ -75,6 +75,8 @@ public slots:
|
||||
signals:
|
||||
void peerStatusChanged( const Tomahawk::peerinfo_ptr& );
|
||||
void dataError( bool );
|
||||
void inviteSentSuccess( const QString& inviteId );
|
||||
void inviteSentFailure( const QString& inviteId );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
// new data for own source
|
||||
|
89
src/libtomahawk/sip/SipStatusMessage.cpp
Normal file
89
src/libtomahawk/sip/SipStatusMessage.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Dominik Schmidt <domme@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 "SipStatusMessage.h"
|
||||
#include "utils/TomahawkUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QTimer>
|
||||
|
||||
SipStatusMessage::SipStatusMessage( SipStatusMessageType statusMessageType, const QString& contactId )
|
||||
: m_statusMessageType( statusMessageType )
|
||||
, m_contactId( contactId )
|
||||
{
|
||||
// make this temporary for now, as soon as i know how: add ack button
|
||||
m_timer = new QTimer( this );
|
||||
m_timer->setInterval( 8 * 1000 );
|
||||
m_timer->setSingleShot( true );
|
||||
|
||||
connect( m_timer, SIGNAL( timeout() ), this, SIGNAL( finished() ) );
|
||||
m_timer->start();
|
||||
|
||||
if( s_typesPixmaps.value( m_statusMessageType ).isNull() )
|
||||
{
|
||||
TomahawkUtils::ImageType imageType;
|
||||
switch( m_statusMessageType )
|
||||
{
|
||||
case SipInviteFailure:
|
||||
imageType = TomahawkUtils::ProcessStop;
|
||||
break;
|
||||
|
||||
case SipInviteSuccess:
|
||||
case SipAuthReceived:
|
||||
default:
|
||||
imageType = TomahawkUtils::AddContact;
|
||||
}
|
||||
s_typesPixmaps.insert( m_statusMessageType, TomahawkUtils::defaultPixmap( imageType, TomahawkUtils::Original, QSize( 64, 64 ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QPixmap
|
||||
SipStatusMessage::icon() const
|
||||
{
|
||||
return s_typesPixmaps.value( m_statusMessageType );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
SipStatusMessage::mainText() const
|
||||
{
|
||||
QString text;
|
||||
switch( m_statusMessageType )
|
||||
{
|
||||
case SipInviteFailure:
|
||||
text = "Could not invite %1. Please check his/her id!";
|
||||
break;
|
||||
|
||||
case SipInviteSuccess:
|
||||
text = "Invitation sent to %1!";
|
||||
break;
|
||||
|
||||
case SipAuthReceived:
|
||||
text = "Received authorization from %1";
|
||||
break;
|
||||
|
||||
default:
|
||||
tLog() << Q_FUNC_INFO << "Not all status types handled";
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
return text.arg( m_contactId );
|
||||
}
|
||||
|
58
src/libtomahawk/sip/SipStatusMessage.h
Normal file
58
src/libtomahawk/sip/SipStatusMessage.h
Normal file
@ -0,0 +1,58 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Dominik Schmidt <domme@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 SIPSTATUSMESSAGE_H
|
||||
#define SIPSTATUSMESSAGE_H
|
||||
|
||||
#include "jobview/JobStatusItem.h"
|
||||
#include "DllMacro.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QHash>
|
||||
|
||||
class QTimer;
|
||||
|
||||
class DLLEXPORT SipStatusMessage : public JobStatusItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum SipStatusMessageType
|
||||
{
|
||||
SipInviteSuccess,
|
||||
SipInviteFailure,
|
||||
SipAuthReceived
|
||||
};
|
||||
|
||||
explicit SipStatusMessage( SipStatusMessageType statusMessageType, const QString& contactId );
|
||||
|
||||
QString type() const { return "sipstatusmessage"; }
|
||||
|
||||
QPixmap icon() const;
|
||||
QString mainText() const;
|
||||
|
||||
bool allowMultiLine() const { return true; }
|
||||
private:
|
||||
QString m_contactId;
|
||||
SipStatusMessageType m_statusMessageType;
|
||||
|
||||
QHash< SipStatusMessageType, QPixmap > s_typesPixmaps;
|
||||
|
||||
QTimer* m_timer;
|
||||
};
|
||||
|
||||
#endif // SIPSTATUSMESSAGE_H
|
@ -28,6 +28,10 @@
|
||||
#include "utils/AnimatedSpinner.h"
|
||||
#include "widgets/ElidedLabel.h"
|
||||
|
||||
#include "jobview/JobStatusView.h"
|
||||
#include "jobview/JobStatusModel.h"
|
||||
#include "sip/SipStatusMessage.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
@ -264,6 +268,20 @@ AccountWidget::sendInvite()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AccountWidget::onInviteSentSuccess( const QString& inviteId )
|
||||
{
|
||||
JobStatusView::instance()->model()->addJob( new SipStatusMessage( SipStatusMessage::SipInviteSuccess, inviteId ) );
|
||||
}
|
||||
|
||||
void
|
||||
AccountWidget::onInviteSentFailure( const QString& inviteId )
|
||||
{
|
||||
JobStatusView::instance()->model()->addJob( new SipStatusMessage( SipStatusMessage::SipInviteFailure, inviteId ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AccountWidget::clearInviteWidgets()
|
||||
{
|
||||
@ -297,6 +315,8 @@ AccountWidget::setupConnections( const QPersistentModelIndex& idx, int accountId
|
||||
this, SLOT( sendInvite() ) );
|
||||
|
||||
m_inviteEdit->setPlaceholderText( account->sipPlugin()->inviteString() );
|
||||
connect( account->sipPlugin(), SIGNAL( inviteSentSuccess( QString ) ), SLOT( onInviteSentSuccess( QString ) ) );
|
||||
connect( account->sipPlugin(), SIGNAL( inviteSentFailure( QString ) ), SLOT( onInviteSentFailure( QString ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,8 @@ public:
|
||||
private slots:
|
||||
void changeAccountConnectionState( bool connected );
|
||||
void sendInvite();
|
||||
void onInviteSentSuccess( const QString& inviteId );
|
||||
void onInviteSentFailure( const QString& inviteId );
|
||||
void clearInviteWidgets();
|
||||
void setInviteWidgetsEnabled( bool enabled );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user