mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-20 07:52:30 +02:00
* New SipPlugin::addContact() api. You can specify whether this is an invitation or a simple contact addition.
This commit is contained in:
parent
f4aa6291c8
commit
8b09d19341
@ -1,22 +1,22 @@
|
||||
/*
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 2011 Leo Franchi <leo.franchi@kdab.com>
|
||||
Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||
* Copyright 2010-2011, Jeff Mitchell <jeff@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 "GoogleWrapper.h"
|
||||
#include "../xmpp/XmppConfigWidget.h"
|
||||
@ -70,7 +70,7 @@ GoogleWrapperSip::showAddFriendDialog()
|
||||
return;
|
||||
|
||||
qDebug() << "Attempting to add google contact to roster:" << id;
|
||||
addContact( id );
|
||||
addContact( id, SendInvite );
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ public slots:
|
||||
void disconnectPlugin();
|
||||
void checkSettings() {}
|
||||
void configurationChanged() {}
|
||||
void addContact( const QString &, const QString& ) {}
|
||||
bool addContact( const QString&, AddContactOptions, const QString& ) { return false; }
|
||||
void sendMsg( const QString&, const SipInfo& ) {}
|
||||
void webSocketConnected();
|
||||
void webSocketDisconnected();
|
||||
|
@ -72,10 +72,13 @@ public slots:
|
||||
Q_UNUSED( msg );
|
||||
}
|
||||
|
||||
void addContact( const QString &peerId, const QString& msg = QString() )
|
||||
bool addContact( const QString &peerId, AddContactOptions options, const QString& msg = QString() )
|
||||
{
|
||||
Q_UNUSED( peerId );
|
||||
Q_UNUSED( msg );
|
||||
Q_UNUSED( options );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void checkSettings();
|
||||
|
@ -465,20 +465,28 @@ XmppSipPlugin::sendSipInfos( const Tomahawk::peerinfo_ptr& receiver, const QList
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmppSipPlugin::addContact( const QString& jid, const QString& msg )
|
||||
bool
|
||||
XmppSipPlugin::addContact( const QString& jid, AddContactOptions options, const QString& msg )
|
||||
{
|
||||
// Add contact to the Tomahawk group on the roster
|
||||
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 );
|
||||
|
||||
if ( options & SendInvite )
|
||||
{
|
||||
emit inviteSentSuccess( jid );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
if ( options & SendInvite )
|
||||
{
|
||||
emit inviteSentFailure( jid );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -494,7 +502,7 @@ XmppSipPlugin::showAddFriendDialog()
|
||||
return;
|
||||
|
||||
qDebug() << "Attempting to add xmpp contact to roster:" << id;
|
||||
addContact( id );
|
||||
addContact( id, SendInvite );
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -847,7 +855,7 @@ XmppSipPlugin::onSubscriptionRequestConfirmed( int result )
|
||||
if ( allowSubscription == QMessageBox::Yes )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << jid.bare() << "accepted by user, adding to roster";
|
||||
addContact( jid, "" );
|
||||
addContact( jid );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -90,7 +90,7 @@ public slots:
|
||||
virtual void disconnectPlugin();
|
||||
virtual void checkSettings();
|
||||
virtual void configurationChanged();
|
||||
virtual void addContact( const QString& peerId, const QString& msg = QString() );
|
||||
virtual bool addContact( const QString& peerId, AddContactOptions options = NoOptions, const QString& msg = QString() );
|
||||
|
||||
virtual void sendSipInfos( const Tomahawk::peerinfo_ptr& receiver, const QList<SipInfo>& info );
|
||||
|
||||
|
@ -51,8 +51,10 @@ class DLLEXPORT SipPlugin : public QObject
|
||||
friend class Tomahawk::PeerInfo;
|
||||
|
||||
public:
|
||||
enum AddContactOptions { NoOptions = 0, SendInvite = 1 };
|
||||
|
||||
SipPlugin();
|
||||
explicit SipPlugin( Tomahawk::Accounts::Account *account, QObject* parent = 0 );
|
||||
explicit SipPlugin( Tomahawk::Accounts::Account* account, QObject* parent = 0 );
|
||||
virtual ~SipPlugin();
|
||||
|
||||
// plugin id is "pluginfactoryname_someuniqueid". get it from SipPluginFactory::generateId
|
||||
@ -76,7 +78,7 @@ public slots:
|
||||
virtual void checkSettings() = 0;
|
||||
virtual void configurationChanged() = 0;
|
||||
|
||||
virtual void addContact( const QString& peerId, const QString& msg = QString() ) = 0;
|
||||
virtual bool addContact( const QString& peerId, AddContactOptions options = NoOptions, const QString& msg = QString() ) = 0;
|
||||
|
||||
/**
|
||||
* Send a list of SipInfos to all contacts.
|
||||
|
Loading…
x
Reference in New Issue
Block a user