mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-17 19:37:09 +02:00
* You can now add jabber friends within Tomahawk (Menu Network -> Add Friend).
* If the mainwindow (not the app itself) gets closed, it will now hide in the SysTray. * Cleaned up menus.
This commit is contained in:
@@ -96,6 +96,7 @@ signals:
|
||||
public slots:
|
||||
QSharedPointer<QIODevice> getIODeviceForUrl( const Tomahawk::result_ptr& result );
|
||||
void reconnectJabber();
|
||||
void jabberAddContact( const QString& jid );
|
||||
|
||||
private slots:
|
||||
void jabberMessage( const QString&, const QString& );
|
||||
|
@@ -1,14 +1,17 @@
|
||||
#ifndef JABBER_H
|
||||
#define JABBER_H
|
||||
|
||||
/*
|
||||
Pimpl of jabber_p, which inherits from a gazillion gloox classes
|
||||
and it littered with public methods.
|
||||
*/
|
||||
|
||||
#include "jabber_p.h"
|
||||
|
||||
class Jabber : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
Jabber( const QString &jid, const QString password, const QString server = "", const int port=-1 )
|
||||
@@ -30,29 +33,29 @@ public slots:
|
||||
|
||||
void start()
|
||||
{
|
||||
//connect( &p, SIGNAL(finished()),
|
||||
// this, SIGNAL(finished()) );
|
||||
//connect( &p, SIGNAL( finished() ),
|
||||
// this, SIGNAL( finished() ) );
|
||||
|
||||
connect( &p, SIGNAL(msgReceived(QString,QString)),
|
||||
this, SIGNAL(msgReceived(QString,QString)) );
|
||||
connect( &p, SIGNAL( msgReceived( QString, QString ) ),
|
||||
this, SIGNAL( msgReceived( QString, QString ) ) );
|
||||
|
||||
connect( &p, SIGNAL(peerOnline(QString)),
|
||||
this, SIGNAL(peerOnline(QString)) );
|
||||
connect( &p, SIGNAL( peerOnline( QString ) ),
|
||||
this, SIGNAL( peerOnline( QString ) ) );
|
||||
|
||||
connect( &p, SIGNAL(peerOffline(QString)),
|
||||
this, SIGNAL(peerOffline(QString)) );
|
||||
connect( &p, SIGNAL( peerOffline( QString ) ),
|
||||
this, SIGNAL( peerOffline( QString ) ) );
|
||||
|
||||
connect( &p, SIGNAL(connected()),
|
||||
this, SIGNAL(connected()) );
|
||||
connect( &p, SIGNAL( connected() ),
|
||||
this, SIGNAL( connected() ) );
|
||||
|
||||
connect( &p, SIGNAL(disconnected()),
|
||||
this, SIGNAL(disconnected()) );
|
||||
connect( &p, SIGNAL( disconnected() ),
|
||||
this, SIGNAL( disconnected() ) );
|
||||
|
||||
connect( &p, SIGNAL(jidChanged(QString)),
|
||||
this, SIGNAL(jidChanged(QString)) );
|
||||
connect( &p, SIGNAL( jidChanged( QString ) ),
|
||||
this, SIGNAL( jidChanged( QString ) ) );
|
||||
|
||||
connect( &p, SIGNAL(authError(int,const QString&)),
|
||||
this, SIGNAL(authError(int,const QString&)) );
|
||||
connect( &p, SIGNAL( authError( int, const QString& ) ),
|
||||
this, SIGNAL( authError( int, const QString& ) ) );
|
||||
|
||||
p.go();
|
||||
}
|
||||
@@ -65,7 +68,7 @@ public slots:
|
||||
);
|
||||
}
|
||||
|
||||
void sendMsg(const QString& to, const QString& msg)
|
||||
void sendMsg( const QString& to, const QString& msg )
|
||||
{
|
||||
QMetaObject::invokeMethod( &p,
|
||||
"sendMsg",
|
||||
@@ -75,7 +78,7 @@ public slots:
|
||||
);
|
||||
}
|
||||
|
||||
void broadcastMsg(const QString &msg)
|
||||
void broadcastMsg( const QString &msg )
|
||||
{
|
||||
QMetaObject::invokeMethod( &p,
|
||||
"broadcastMsg",
|
||||
@@ -84,16 +87,26 @@ public slots:
|
||||
);
|
||||
}
|
||||
|
||||
void addContact( const QString &jid, const QString& msg = QString() )
|
||||
{
|
||||
QMetaObject::invokeMethod( &p,
|
||||
"addContact",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(const QString, jid),
|
||||
Q_ARG(const QString, msg)
|
||||
);
|
||||
}
|
||||
|
||||
signals:
|
||||
//void finished();
|
||||
|
||||
void msgReceived(const QString&, const QString&); //from, msg
|
||||
void peerOnline(const QString&);
|
||||
void peerOffline(const QString&);
|
||||
void msgReceived( const QString&, const QString& );
|
||||
void peerOnline( const QString& );
|
||||
void peerOffline( const QString& );
|
||||
void connected();
|
||||
void disconnected();
|
||||
void jidChanged(const QString&);
|
||||
void authError(int, const QString&);
|
||||
void jidChanged( const QString& );
|
||||
void authError( int, const QString& );
|
||||
|
||||
private:
|
||||
Jabber_p p;
|
||||
|
@@ -207,6 +207,23 @@ Jabber_p::broadcastMsg( const QString &msg )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber_p::addContact( const QString& jid, const QString& msg )
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( this, "addContact",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(const QString, jid),
|
||||
Q_ARG(const QString, msg)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
handleSubscription(JID(jid.toStdString()), msg.toStdString());
|
||||
return;
|
||||
}
|
||||
|
||||
/// GLOOX IMPL STUFF FOLLOWS
|
||||
|
||||
void
|
||||
@@ -521,11 +538,21 @@ void
|
||||
Jabber_p::handleSelfPresence( const RosterItem& item, const std::string& resource,
|
||||
Presence::PresenceType presence, const std::string& msg )
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
handleRosterPresence( item, resource, presence, msg );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Jabber_p::handleSubscription( const JID& jid, const std::string& /*msg*/ )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << jid.bare().c_str();
|
||||
|
||||
StringList groups;
|
||||
m_client->rosterManager()->subscribe( jid, "", groups, "" );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Jabber_p::handleSubscriptionRequest( const JID& jid, const std::string& /*msg*/ )
|
||||
{
|
||||
|
@@ -92,6 +92,7 @@ public:
|
||||
gloox::Presence::PresenceType presence, const std::string& /*msg*/ );
|
||||
virtual void handleSelfPresence( const gloox::RosterItem& item, const std::string& resource,
|
||||
gloox::Presence::PresenceType presence, const std::string& msg );
|
||||
virtual bool handleSubscription( const gloox::JID& jid, const std::string& /*msg*/ );
|
||||
virtual bool handleSubscriptionRequest( const gloox::JID& jid, const std::string& /*msg*/ );
|
||||
virtual bool handleUnsubscriptionRequest( const gloox::JID& jid, const std::string& /*msg*/ );
|
||||
virtual void handleNonrosterPresence( const gloox::Presence& presence );
|
||||
@@ -121,7 +122,8 @@ signals:
|
||||
public slots:
|
||||
void go();
|
||||
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() );
|
||||
|
||||
private slots:
|
||||
void doJabberRecv();
|
||||
|
@@ -480,6 +480,13 @@ TomahawkApp::reconnectJabber()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkApp::jabberAddContact( const QString& jid )
|
||||
{
|
||||
m_jabber->addContact( jid );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkApp::jabberAuthError( int code, const QString& msg )
|
||||
{
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include "ui_tomahawkwindow.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QCloseEvent>
|
||||
#include <QInputDialog>
|
||||
#include <QPixmap>
|
||||
#include <QPropertyAnimation>
|
||||
@@ -55,7 +56,6 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
#ifndef Q_WS_MAC
|
||||
ui->centralWidget->layout()->setContentsMargins( 4, 4, 4, 2 );
|
||||
#else
|
||||
// ui->actionProgress->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
// ui->playlistView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
ui->sourceTreeView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
#endif
|
||||
@@ -110,12 +110,6 @@ TomahawkWindow::saveSettings()
|
||||
void
|
||||
TomahawkWindow::setupSignals()
|
||||
{
|
||||
connect( ui->actionExit, SIGNAL( triggered() ),
|
||||
qApp, SLOT( closeAllWindows() ) );
|
||||
|
||||
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
||||
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
||||
|
||||
// <Playlist>
|
||||
connect( m_topbar, SIGNAL( filterTextChanged( const QString& ) ),
|
||||
playlistManager(), SLOT( setFilter( const QString& ) ) );
|
||||
@@ -133,10 +127,10 @@ TomahawkWindow::setupSignals()
|
||||
m_topbar, SLOT( setNumShown( unsigned int ) ) );
|
||||
|
||||
connect( m_topbar, SIGNAL( flatMode() ),
|
||||
m_playlistManager, SLOT( setTableMode() ) );
|
||||
playlistManager(), SLOT( setTableMode() ) );
|
||||
|
||||
connect( m_topbar, SIGNAL( artistMode() ),
|
||||
m_playlistManager, SLOT( setTreeMode() ) );
|
||||
playlistManager(), SLOT( setTreeMode() ) );
|
||||
|
||||
// <From PlaylistManager>
|
||||
connect( playlistManager(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ),
|
||||
@@ -152,8 +146,12 @@ TomahawkWindow::setupSignals()
|
||||
// <Menu Items>
|
||||
connect( ui->actionPreferences, SIGNAL( triggered() ), SLOT( showSettingsDialog() ) );
|
||||
connect( ui->actionAddPeerManually, SIGNAL( triggered() ), SLOT( addPeerManually() ) );
|
||||
connect( ui->actionAddFriendManually, SIGNAL( triggered() ), SLOT( addFriendManually() ) );
|
||||
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
|
||||
connect( ui->actionAbout_Tomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
||||
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
||||
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
||||
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
||||
connect( ui->actionExit, SIGNAL( triggered() ), APP, SLOT( quit() ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +172,21 @@ TomahawkWindow::changeEvent( QEvent* e )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::closeEvent( QCloseEvent* e )
|
||||
{
|
||||
if ( QSystemTrayIcon::isSystemTrayAvailable() )
|
||||
{
|
||||
e->ignore();
|
||||
hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PlaylistManager*
|
||||
TomahawkWindow::playlistManager()
|
||||
{
|
||||
@@ -225,16 +238,15 @@ void
|
||||
TomahawkWindow::addPeerManually()
|
||||
{
|
||||
TomahawkSettings* s = APP->settings();
|
||||
// stealing this for connecting to peers for now:
|
||||
bool ok;
|
||||
QString addr = QInputDialog::getText( this, tr( "Connect to peer" ),
|
||||
QString addr = QInputDialog::getText( this, tr( "Connect To Peer" ),
|
||||
tr( "Enter peer address:" ), QLineEdit::Normal,
|
||||
s->value( "connip" ).toString(), &ok ); // FIXME
|
||||
if ( !ok )
|
||||
return;
|
||||
|
||||
s->setValue( "connip", addr );
|
||||
QString ports = QInputDialog::getText( this, tr( "Connect to peer" ),
|
||||
QString ports = QInputDialog::getText( this, tr( "Connect To Peer" ),
|
||||
tr( "Enter peer port:" ), QLineEdit::Normal,
|
||||
s->value( "connport", "50210" ).toString(), &ok );
|
||||
if ( !ok )
|
||||
@@ -242,17 +254,32 @@ TomahawkWindow::addPeerManually()
|
||||
|
||||
s->setValue( "connport", ports );
|
||||
int port = ports.toInt();
|
||||
QString key = QInputDialog::getText( this, tr( "Connect to peer" ),
|
||||
QString key = QInputDialog::getText( this, tr( "Connect To Peer" ),
|
||||
tr( "Enter peer key:" ), QLineEdit::Normal,
|
||||
"whitelist", &ok );
|
||||
if ( !ok )
|
||||
return;
|
||||
|
||||
qDebug() << "Attempting to connect to " << addr;
|
||||
qDebug() << "Attempting to connect to" << addr;
|
||||
APP->servent().connectToPeer( addr, port, key );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::addFriendManually()
|
||||
{
|
||||
bool ok;
|
||||
QString id = QInputDialog::getText( this, tr( "Add Friend" ),
|
||||
tr( "Enter Jabber ID:" ), QLineEdit::Normal,
|
||||
"", &ok );
|
||||
if ( !ok )
|
||||
return;
|
||||
|
||||
qDebug() << "Attempting to add jabber contact to roster:" << id;
|
||||
APP->jabberAddContact( id );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::loadSpiff()
|
||||
{
|
||||
|
@@ -40,6 +40,7 @@ signals:
|
||||
|
||||
protected:
|
||||
void changeEvent( QEvent* e );
|
||||
void closeEvent( QCloseEvent* e );
|
||||
|
||||
public slots:
|
||||
void createPlaylist();
|
||||
@@ -50,6 +51,7 @@ private slots:
|
||||
void scanFinished();
|
||||
void rescanCollectionManually();
|
||||
void addPeerManually();
|
||||
void addFriendManually();
|
||||
|
||||
void onPlaybackLoading( const Tomahawk::result_ptr& result );
|
||||
|
||||
|
@@ -50,7 +50,7 @@
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuApp">
|
||||
<property name="title">
|
||||
<string>Music &Player</string>
|
||||
<string>&Music Player</string>
|
||||
</property>
|
||||
<addaction name="actionRescanCollection"/>
|
||||
<addaction name="separator"/>
|
||||
@@ -66,15 +66,16 @@
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuNetwork">
|
||||
<property name="title">
|
||||
<string>Network</string>
|
||||
<string>&Network</string>
|
||||
</property>
|
||||
<addaction name="actionAddPeerManually"/>
|
||||
<addaction name="actionAddFriendManually"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Help">
|
||||
<property name="title">
|
||||
<string>&Help</string>
|
||||
</property>
|
||||
<addaction name="actionAbout_Tomahawk"/>
|
||||
<addaction name="actionAboutTomahawk"/>
|
||||
</widget>
|
||||
<addaction name="menuApp"/>
|
||||
<addaction name="menuPlaylist"/>
|
||||
@@ -96,12 +97,17 @@
|
||||
</action>
|
||||
<action name="actionAddPeerManually">
|
||||
<property name="text">
|
||||
<string>&Add Peer Manually</string>
|
||||
<string>Add &Peer Manually...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAddFriendManually">
|
||||
<property name="text">
|
||||
<string>Add &Friend...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRescanCollection">
|
||||
<property name="text">
|
||||
<string>Re&scan Collection</string>
|
||||
<string>Re&scan Collection...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPreferences">
|
||||
@@ -114,7 +120,7 @@
|
||||
</action>
|
||||
<action name="actionLoadXSPF">
|
||||
<property name="text">
|
||||
<string>Load &XSPF</string>
|
||||
<string>Load &XSPF...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreatePlaylist">
|
||||
@@ -122,9 +128,12 @@
|
||||
<string>Create &New Playlist...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout_Tomahawk">
|
||||
<action name="actionAboutTomahawk">
|
||||
<property name="text">
|
||||
<string>About &Tomahawk</string>
|
||||
<string>About &Tomahawk...</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::AboutRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
|
Reference in New Issue
Block a user