1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

Merge branch 'jreen-tpqt4-comp'

This commit is contained in:
Dominik Schmidt
2011-04-18 22:35:42 +02:00
16 changed files with 632 additions and 186 deletions

View File

@@ -8,10 +8,10 @@ ENDIF( ${CMAKE_VERSION} VERSION_GREATER 2.8.3 )
### ###
### Tomahawk application info ### Tomahawk application info
### ###
SET( ORGANIZATION_NAME "Tomahawk" ) SET( TOMAHAWK_ORGANIZATION_NAME "Tomahawk" )
SET( ORGANIZATION_DOMAIN "tomahawk-player.org" ) SET( TOMAHAWK_ORGANIZATION_DOMAIN "tomahawk-player.org" )
SET( APPLICATION_NAME "Tomahawk" ) SET( TOMAHAWK_APPLICATION_NAME "Tomahawk" )
SET( VERSION "0.0.3" ) SET( TOMAHAWK_VERSION "0.0.3" )
# set paths # set paths
@@ -50,6 +50,28 @@ macro_log_feature(QJSON_FOUND "QJson" "Qt library that maps JSON data to QVarian
macro_optional_find_package(Taglib 1.6.0) macro_optional_find_package(Taglib 1.6.0)
macro_log_feature(TAGLIB_FOUND "TagLib" "Audio Meta-Data Library" "http://developer.kde.org/~wheeler/taglib.html" TRUE "" "taglib is needed for reading meta data from audio files") macro_log_feature(TAGLIB_FOUND "TagLib" "Audio Meta-Data Library" "http://developer.kde.org/~wheeler/taglib.html" TRUE "" "taglib is needed for reading meta data from audio files")
# this installs headers and such and should really be handled in a separate package by packagers
IF( INTERNAL_JREEN )
ADD_SUBDIRECTORY( thirdparty/jreen )
SET( LIBJREEN_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/include )
IF( UNIX AND NOT APPLE )
SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.so )
ENDIF( UNIX AND NOT APPLE )
IF( APPLE )
SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.dylib )
ENDIF( APPLE )
IF( WIN32 )
SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.dll )
ENDIF( WIN32 )
SET( LIBJREEN_FOUND true )
MESSAGE(STATUS "INTERNAL libjreen: ${LIBJREEN_INCLUDE_DIR}, ${LIBJREEN_LIBRARY}")
ELSE( INTERNAL_JREEN )
macro_optional_find_package(Jreen)
ENDIF( INTERNAL_JREEN )
macro_log_feature(LIBJREEN_FOUND "Jreen" "Qt XMPP Library" "http://gitorious.org/jreen/jreen" FALSE "" "Jreen is needed for the Jabber SIP plugin. \n\n Use -DINTERNAL_JREEN=ON to build the git submodule inside Tomahawk \n Be aware this installs a full jreen with headers and everything!")
# we need pthreads too # we need pthreads too
find_package(Threads) find_package(Threads)
@@ -65,32 +87,6 @@ ENDIF()
include( CheckTagLibFileName ) include( CheckTagLibFileName )
check_taglib_filename( COMPLEX_TAGLIB_FILENAME ) check_taglib_filename( COMPLEX_TAGLIB_FILENAME )
# optional
IF( ENABLE_JREEN )
macro_optional_find_package(Jreen)
IF( LIBJREEN_FOUND )
macro_log_feature(JREEN_FOUND "Jreen" "Qt XMPP library" "http://gitorious.org/jreen" FALSE "" "Jreen is needed for the alternative/new Jabber SIP plugin. Built automatically inside Tomahawk, if not installed systemwide and ENABLE_JREEN is true")
ELSE( LIBJREEN_FOUND )
SET( OLD_C_FLAGS ${CMAKE_C_FLAGS} )
SET( CMAKE_C_FLAGS ${CLEAN_C_FLAGS} )
ADD_SUBDIRECTORY( thirdparty/jreen )
SET( LIBJREEN_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/include )
IF( UNIX AND NOT APPLE )
SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.so )
ENDIF( UNIX AND NOT APPLE )
IF( WIN32 )
SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.dll )
ENDIF( WIN32 )
SET( LIBJREEN_FOUND true )
MESSAGE(STATUS "Internal libjreen: ${LIBJREEN_INCLUDE_DIR}, ${LIBJREEN_LIBRARY}")
SET( CMAKE_C_FLAGS ${OLD_C_FLAGS} )
ENDIF( LIBJREEN_FOUND )
ELSE( LIBJREEN_FOUND )
macro_optional_find_package(Gloox 1.0)
macro_log_feature(GLOOX_FOUND "Gloox" "A portable high-level Jabber/XMPP library for C++" "http://camaya.net/gloox" FALSE "" "Gloox is needed for the Jabber SIP plugin and the XMPP-Bot")
ENDIF( ENABLE_JREEN )
IF( WIN32 ) IF( WIN32 )
find_library(QTSPARKLE_LIBRARIES qtsparkle) find_library(QTSPARKLE_LIBRARIES qtsparkle)
ENDIF( WIN32 ) ENDIF( WIN32 )

View File

@@ -6,15 +6,15 @@
# LIBJREEN_FOUND, whether libjreen was found # LIBJREEN_FOUND, whether libjreen was found
find_path(LIBJREEN_INCLUDE_DIR NAMES jreen.h find_path(LIBJREEN_INCLUDE_DIR NAMES jreen/jreen.h
HINTS HINTS
~/usr/include ~/usr/include
/opt/local/include /opt/local/include
/usr/include /usr/include
/usr/local/include /usr/local/include
/opt/kde4/include /opt/kde4/include
${CMAKE_INSTALL_PREFIX}/include
${KDE4_INCLUDE_DIR} ${KDE4_INCLUDE_DIR}
PATH_SUFFIXES jreen
) )
find_library( LIBJREEN_LIBRARY NAMES jreen find_library( LIBJREEN_LIBRARY NAMES jreen
@@ -25,6 +25,8 @@ find_library( LIBJREEN_LIBRARY NAMES jreen
/usr/lib64 /usr/lib64
/usr/local/lib /usr/local/lib
/opt/kde4/lib /opt/kde4/lib
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib64
${KDE4_LIB_DIR} ${KDE4_LIB_DIR}
) )
@@ -33,7 +35,7 @@ if(LIBJREEN_INCLUDE_DIR AND LIBJREEN_LIBRARY)
set(LIBJREEN_FOUND TRUE) set(LIBJREEN_FOUND TRUE)
message(STATUS "Found libjreen: ${LIBJREEN_INCLUDE_DIR}, ${LIBJREEN_LIBRARY}") message(STATUS "Found libjreen: ${LIBJREEN_INCLUDE_DIR}, ${LIBJREEN_LIBRARY}")
else(LIBJREEN_INCLUDE_DIR AND LIBJREEN_LIBRARY) else(LIBJREEN_INCLUDE_DIR AND LIBJREEN_LIBRARY)
set(LIBJREEN_FOUND FALSE) set(LIBJREEN_FOUND FALSE)
if (LIBJREEN_FIND_REQUIRED) if (LIBJREEN_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find required package libjreen") message(FATAL_ERROR "Could NOT find required package libjreen")
endif(LIBJREEN_FIND_REQUIRED) endif(LIBJREEN_FIND_REQUIRED)

View File

@@ -1,14 +1,15 @@
#ifndef CONFIG_H_IN #ifndef CONFIG_H_IN
#define CONFIG_H_IN #define CONFIG_H_IN
#cmakedefine ORGANIZATION_NAME "${ORGANIZATION_NAME}" #cmakedefine TOMAHAWK_ORGANIZATION_NAME "${TOMAHAWK_ORGANIZATION_NAME}"
#cmakedefine ORGANIZATION_DOMAIN "${ORGANIZATION_DOMAIN}" #cmakedefine TOMAHAWK_ORGANIZATION_DOMAIN "${TOMAHAWK_ORGANIZATION_DOMAIN}"
#cmakedefine APPLICATION_NAME "${APPLICATION_NAME}" #cmakedefine TOMAHAWK_APPLICATION_NAME "${TOMAHAWK_APPLICATION_NAME}"
#cmakedefine VERSION "${VERSION}" #cmakedefine TOMAHAWK_VERSION "${TOMAHAWK_VERSION}"
#cmakedefine DEBUG_BUILD #cmakedefine DEBUG_BUILD
#define CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" #define CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}"
#define CMAKE_SYSTEM "${CMAKE_SYSTEM}"
#cmakedefine SNOW_LEOPARD #cmakedefine SNOW_LEOPARD
#cmakedefine LEOPARD #cmakedefine LEOPARD

View File

@@ -1,10 +1,11 @@
# only build one of them, if ENABLE_JREEN is true, GLOOX_FOUND is automatically set to "false" # only build one of them, if ENABLE_JREEN is true, GLOOX_FOUND is automatically set to "false"
IF( GLOOX_FOUND ) IF( GLOOX_FOUND AND NOT LIBJREEN_FOUND )
ADD_SUBDIRECTORY( jabber ) ADD_SUBDIRECTORY( jabber )
ENDIF( GLOOX_FOUND ) ENDIF( GLOOX_FOUND AND NOT LIBJREEN_FOUND )
IF( ENABLE_JREEN )
IF( LIBJREEN_FOUND )
ADD_SUBDIRECTORY( jreen ) ADD_SUBDIRECTORY( jreen )
ENDIF( ENABLE_JREEN) ENDIF( LIBJREEN_FOUND )
ADD_SUBDIRECTORY( twitter ) ADD_SUBDIRECTORY( twitter )
ADD_SUBDIRECTORY( zeroconf ) ADD_SUBDIRECTORY( zeroconf )

View File

@@ -9,11 +9,15 @@ add_definitions( -DSIPDLLEXPORT_PRO )
set( jabberSources set( jabberSources
jabber.cpp jabber.cpp
jabber_p.cpp jabber_p.cpp
tomahawksipmessage.cpp
tomahawksipmessagefactory.cpp
) )
set( jabberHeaders set( jabberHeaders
jabber.h jabber.h
jabber_p.h jabber_p.h
tomahawksipmessage.h
tomahawksipmessagefactory.h
) )
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
@@ -22,7 +26,7 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
) )
qt4_wrap_cpp( jabberMoc ${jabberHeaders} ) qt4_wrap_cpp( jabberMoc ${jabberHeaders} )
add_library( tomahawk_sipjreen SHARED ${jabberSources} ${jabberMoc} ) add_library( tomahawk_sipjabber SHARED ${jabberSources} ${jabberMoc} )
IF( WIN32 ) IF( WIN32 )
SET( OS_SPECIFIC_LINK_LIBRARIES SET( OS_SPECIFIC_LINK_LIBRARIES
@@ -33,7 +37,7 @@ SET( OS_SPECIFIC_LINK_LIBRARIES
) )
ENDIF( WIN32 ) ENDIF( WIN32 )
target_link_libraries( tomahawk_sipjreen target_link_libraries( tomahawk_sipjabber
${QT_LIBRARIES} ${QT_LIBRARIES}
${LIBJREEN_LIBRARY} ${LIBJREEN_LIBRARY}
${OS_SPECIFIC_LINK_LIBRARIES} ${OS_SPECIFIC_LINK_LIBRARIES}
@@ -44,4 +48,4 @@ 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_sipjreen DESTINATION lib${LIB_SUFFIX} ) install( TARGETS tomahawk_sipjabber DESTINATION lib${LIB_SUFFIX} )

View File

@@ -1,5 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === 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> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -105,8 +106,10 @@ JabberPlugin::connectPlugin( bool startup )
QObject::connect( p, SIGNAL( peerOffline( QString ) ), SIGNAL( peerOffline( QString ) ) ); QObject::connect( p, SIGNAL( peerOffline( QString ) ), SIGNAL( peerOffline( QString ) ) );
QObject::connect( p, SIGNAL( msgReceived( QString, QString ) ), SIGNAL( msgReceived( QString, QString ) ) ); QObject::connect( p, SIGNAL( msgReceived( QString, QString ) ), SIGNAL( msgReceived( QString, QString ) ) );
QObject::connect( p, SIGNAL( connected() ), SIGNAL( onConnected() ) ); QObject::connect( p, SIGNAL( connected() ), SLOT( onConnected() ) );
QObject::connect( p, SIGNAL( disconnected() ), SIGNAL( onDisconnected() ) ); QObject::connect( p, SIGNAL( disconnected() ), SLOT( onDisconnected() ) );
QObject::connect( p, SIGNAL( authError( int, QString ) ), SLOT( onAuthError( int, QString ) ) );
return true; return true;
} }
@@ -155,6 +158,33 @@ JabberPlugin::onDisconnected()
emit disconnected(); emit disconnected();
} }
void
JabberPlugin::onAuthError( int code, const QString& msg )
{
switch( code )
{
case Jreen::Client::AuthorizationError:
emit error( SipPlugin::AuthError, msg );
break;
case Jreen::Client::HostUnknown:
case Jreen::Client::ItemNotFound:
case Jreen::Client::RemoteStreamError:
case Jreen::Client::RemoteConnectionFailed:
case Jreen::Client::InternalServerError:
case Jreen::Client::SystemShutdown:
case Jreen::Client::Conflict:
case Jreen::Client::Unknown:
emit error( SipPlugin::ConnectionError, msg );
break;
default:
qDebug() << "Not all Client::DisconnectReasons checked";
Q_ASSERT(false);
break;
}
}
void void
JabberPlugin::sendMsg(const QString& to, const QString& msg) JabberPlugin::sendMsg(const QString& to, const QString& msg)
{ {

View File

@@ -1,5 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === 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> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -24,7 +25,7 @@
#include "../sipdllmacro.h" #include "../sipdllmacro.h"
#define MYNAME "SIPJABBER" #define MYNAME "SIPJREEN"
class SIPDLLEXPORT JabberPlugin : public SipPlugin class SIPDLLEXPORT JabberPlugin : public SipPlugin
{ {
@@ -56,6 +57,7 @@ private slots:
void showAddFriendDialog(); void showAddFriendDialog();
void onConnected(); void onConnected();
void onDisconnected(); void onDisconnected();
void onAuthError(int code, const QString &msg);
private: private:
Jabber_p* p; Jabber_p* p;

View File

@@ -1,5 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === 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> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -17,6 +18,16 @@
*/ */
#include "jabber_p.h" #include "jabber_p.h"
#include "tomahawksipmessage.h"
#include "tomahawksipmessagefactory.h"
#include "config.h"
#include "utils/tomahawkutils.h"
#include <jreen/capabilities.h>
#include <qjson/parser.h>
#include <qjson/serializer.h>
#include <QDebug> #include <QDebug>
#include <QTime> #include <QTime>
@@ -24,58 +35,53 @@
#include <QString> #include <QString>
#include <QRegExp> #include <QRegExp>
#include <QThread> #include <QThread>
#include <utils/tomahawkutils.h> #include <QVariant>
#include <QMap>
#include <jreen/abstractroster.h> #define TOMAHAWK_FEATURE QLatin1String( "tomahawk:sip:v1" )
#include <jreen/capabilities.h>
#define TOMAHAWK_CAP_NODE_NAME QLatin1String( "http://tomahawk-player.org/" )
//remove
#include <QMessageBox>
#include <jreen/connection.h>
using namespace std;
#define TOMAHAWK_CAP_NODE_NAME QLatin1String("http://tomahawk-player.org/")
Jabber_p::Jabber_p( const QString& jid, const QString& password, const QString& server, const int port ) Jabber_p::Jabber_p( const QString& jid, const QString& password, const QString& server, const int port )
: QObject() : QObject()
, m_server() , m_server()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
//qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) );
qsrand(QDateTime::currentDateTime().toTime_t()); qsrand(QDateTime::currentDateTime().toTime_t());
m_presences[Jreen::Presence::Available] = "available"; // setup JID object
m_presences[Jreen::Presence::Chat] = "chat";
m_presences[Jreen::Presence::Away] = "away";
m_presences[Jreen::Presence::DND] = "dnd";
m_presences[Jreen::Presence::XA] = "xa";
m_presences[Jreen::Presence::Unavailable] = "unavailable";
m_presences[Jreen::Presence::Probe] = "probe";
m_presences[Jreen::Presence::Error] = "error";
m_presences[Jreen::Presence::Invalid] = "invalid";
m_jid = Jreen::JID( jid ); m_jid = Jreen::JID( jid );
// general client setup
m_client = new Jreen::Client( jid, password ); m_client = new Jreen::Client( jid, password );
m_client->setResource( QString( "tomahawk-jreen%1" ).arg( QString::number( qrand() % 10000 ) ) ); m_client->registerStanzaExtension(new TomahawkSipMessageFactory);
m_client->setResource( QString( "tomahawk%1" ).arg( QString::number( qrand() % 10000 ) ) );
// setup disco
m_client->disco()->setSoftwareVersion( "Tomahawk Player", TOMAHAWK_VERSION, CMAKE_SYSTEM );
m_client->disco()->addIdentity( Jreen::Disco::Identity( "client", "type", "tomahawk", "en" ) );
m_client->disco()->addFeature( TOMAHAWK_FEATURE );
// setup caps node, legacy peer detection - used before 0.1
Jreen::Capabilities::Ptr caps = m_client->presence().findExtension<Jreen::Capabilities>(); Jreen::Capabilities::Ptr caps = m_client->presence().findExtension<Jreen::Capabilities>();
caps->setNode(TOMAHAWK_CAP_NODE_NAME); caps->setNode( TOMAHAWK_CAP_NODE_NAME );
// print connection parameters
qDebug() << "Our JID set to:" << m_client->jid().full(); qDebug() << "Our JID set to:" << m_client->jid().full();
qDebug() << "Our Server set to:" << m_client->server(); qDebug() << "Our Server set to:" << m_client->server();
qDebug() << "Our Port set to" << m_client->port(); qDebug() << "Our Port set to" << m_client->port();
// setup slots
connect(m_client->connection(), SIGNAL(error(SocketError)), SLOT(onError(SocketError))); connect(m_client->connection(), SIGNAL(error(SocketError)), SLOT(onError(SocketError)));
connect(m_client, SIGNAL(serverFeaturesReceived(QSet<QString>)), SLOT(onConnect())); connect(m_client, SIGNAL(serverFeaturesReceived(QSet<QString>)), SLOT(onConnect()));
connect(m_client, SIGNAL(disconnected(Jreen::Client::DisconnectReason)), SLOT(onDisconnect(Jreen::Client::DisconnectReason))); connect(m_client, SIGNAL(disconnected(Jreen::Client::DisconnectReason)), SLOT(onDisconnect(Jreen::Client::DisconnectReason)));
connect(m_client, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroy())); connect(m_client, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroy()));
connect(m_client, SIGNAL(newMessage(Jreen::Message)), SLOT(onNewMessage(Jreen::Message))); connect(m_client, SIGNAL(newMessage(Jreen::Message)), SLOT(onNewMessage(Jreen::Message)));
connect(m_client, SIGNAL(newPresence(Jreen::Presence)), SLOT(onNewPresence(Jreen::Presence))); connect(m_client, SIGNAL(newPresence(Jreen::Presence)), SLOT(onNewPresence(Jreen::Presence)));
connect(m_client, SIGNAL(newIQ(Jreen::IQ)), SLOT(onNewIq(Jreen::IQ)));
// connect
qDebug() << "Connecting to the XMPP server..."; qDebug() << "Connecting to the XMPP server...";
m_client->connectToServer(); m_client->connectToServer();
} }
@@ -105,28 +111,57 @@ Jabber_p::disconnect()
void void
Jabber_p::sendMsg( const QString& to, const QString& msg ) Jabber_p::sendMsg( const QString& to, const QString& msg )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO << to << msg;
if ( QThread::currentThread() != thread() )
{
qDebug() << Q_FUNC_INFO << "invoking in correct thread, not"
<< QThread::currentThread();
QMetaObject::invokeMethod( this, "sendMsg",
Qt::QueuedConnection,
Q_ARG( const QString, to ),
Q_ARG( const QString, msg )
);
return;
}
if ( !m_client ) { if ( !m_client ) {
return; return;
} }
qDebug() << Q_FUNC_INFO << to << msg; if( m_legacy_peers.contains( to ) )
Jreen::Message m( Jreen::Message::Chat, Jreen::JID(to), msg); {
qDebug() << Q_FUNC_INFO << to << "Send legacy message" << msg;
Jreen::Message m( Jreen::Message::Chat, Jreen::JID(to), msg);
m_client->send( m );
m_client->send( m ); // assuming this is threadsafe return;
}
/*******************************************************
* Obsolete this by a SipMessage class
*/
QJson::Parser parser;
bool ok;
QVariant v = parser.parse( msg.toAscii(), &ok );
if ( !ok || v.type() != QVariant::Map )
{
qDebug() << "Invalid JSON in XMPP msg";
return;
}
QVariantMap m = v.toMap();
/*******************************************************/
TomahawkSipMessage *sipMessage;
if(m["visible"].toBool())
{
sipMessage = new TomahawkSipMessage(m["ip"].toString(),
m["port"].toInt(),
m["uniqname"].toString(),
m["key"].toString(),
m["visible"].toBool()
);
}
else
{
sipMessage = new TomahawkSipMessage();
}
qDebug() << "Send sip messsage to " << to;
Jreen::IQ iq( Jreen::IQ::Set, to );
iq.addExtension( sipMessage );
m_client->send( iq, this, SLOT( onNewIq( Jreen::IQ, int ) ), SipMessageSent );
} }
@@ -134,23 +169,13 @@ void
Jabber_p::broadcastMsg( const QString &msg ) Jabber_p::broadcastMsg( const QString &msg )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if ( QThread::currentThread() != thread() )
{
QMetaObject::invokeMethod( this, "broadcastMsg",
Qt::QueuedConnection,
Q_ARG(const QString, msg)
);
return;
}
if ( !m_client ) if ( !m_client )
return; return;
foreach( const QString& jidstr, m_peers.keys() ) foreach( const QString& jidstr, m_peers.keys() )
{ {
qDebug() << "Broadcasting to" << jidstr <<"..."; sendMsg( jidstr, msg );
Jreen::Message m(Jreen::Message::Chat, Jreen::JID(jidstr), msg, "");
m_client->send( m );
} }
} }
@@ -158,16 +183,6 @@ Jabber_p::broadcastMsg( const QString &msg )
void void
Jabber_p::addContact( const QString& jid, const QString& msg ) 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;
}
// Add contact to the Tomahawk group on the roster // Add contact to the Tomahawk group on the roster
m_roster->add( jid, jid, QStringList() << "Tomahawk" ); m_roster->add( jid, jid, QStringList() << "Tomahawk" );
@@ -183,6 +198,7 @@ Jabber_p::onConnect()
// have changed our requested /resource // have changed our requested /resource
if ( m_client->jid().resource() != m_jid.resource() ) if ( m_client->jid().resource() != m_jid.resource() )
{ {
// TODO: check if this is still neccessary with jreen
m_jid.setResource( m_client->jid().resource() ); m_jid.setResource( m_client->jid().resource() );
QString jidstr( m_jid.full() ); QString jidstr( m_jid.full() );
emit jidChanged( jidstr ); emit jidChanged( jidstr );
@@ -191,22 +207,27 @@ Jabber_p::onConnect()
emit connected(); emit connected();
qDebug() << "Connected as:" << m_jid.full(); qDebug() << "Connected as:" << m_jid.full();
m_client->setPresence(Jreen::Presence::Available, "Tomahawk-JREEN available", 1); // set presence to least valid value
m_client->disco()->setSoftwareVersion( "Tomahawk JREEN", "0.0.0.0", "Foobar" ); m_client->setPresence(Jreen::Presence::XA, "Got Tomahawk? http://gettomahawk.com", -127);
m_client->setPingInterval(60000);
// set ping timeout to 15 secs (TODO: verify if this works)
m_client->setPingInterval(15000);
// load roster
m_roster = new Jreen::SimpleRoster( m_client ); m_roster = new Jreen::SimpleRoster( m_client );
m_roster->load(); m_roster->load();
//FIXME: this implementation is totally broken atm, so it's disabled to avoid harm :P
// join MUC with bare jid as nickname // join MUC with bare jid as nickname
//TODO: make the room a list of rooms and make that configurable //TODO: make the room a list of rooms and make that configurable
QString bare(m_jid.bare()); QString mucNickname = QString( "tomahawk@conference.qutim.org/" ).append( QString( m_jid.bare() ).replace( "@", "-" ) );
m_room = new Jreen::MUCRoom(m_client, Jreen::JID(QString("tomahawk@conference.qutim.org/").append(bare.replace("@", "-")))); m_room = new Jreen::MUCRoom(m_client, Jreen::JID( mucNickname ) );
//m_room->setHistorySeconds(0); //m_room->setHistorySeconds(0);
//m_room->join(); //m_room->join();
// treat muc participiants like contacts // treat muc participiants like contacts
connect(m_room, SIGNAL(messageReceived(Jreen::Message, bool)), this, SLOT(onNewMessage(Jreen::Message))); connect( m_room, SIGNAL( messageReceived( Jreen::Message, bool ) ), this, SLOT( onNewMessage( Jreen::Message ) ) );
connect(m_room, SIGNAL(presenceReceived(Jreen::Presence,const Jreen::MUCRoom::Participant*)), this, SLOT(onNewPresence(Jreen::Presence))); connect( m_room, SIGNAL( presenceReceived( Jreen::Presence, const Jreen::MUCRoom::Participant* ) ), this, SLOT( onNewPresence( Jreen::Presence ) ) );
} }
@@ -262,6 +283,10 @@ Jabber_p::onDisconnect( Jreen::Client::DisconnectReason reason )
} }
qDebug() << "Disconnected from server:" << error; qDebug() << "Disconnected from server:" << error;
if( reason != Jreen::Client::User )
{
emit authError( reason, error );
}
if(reconnect) if(reconnect)
QTimer::singleShot(reconnectInSeconds*1000, m_client, SLOT(connectToServer())); QTimer::singleShot(reconnectInSeconds*1000, m_client, SLOT(connectToServer()));
@@ -278,81 +303,151 @@ Jabber_p::onNewMessage( const Jreen::Message& m )
if ( msg.isEmpty() ) if ( msg.isEmpty() )
return; return;
qDebug() << Q_FUNC_INFO << m.from().full() << ":" << m.body(); QJson::Parser parser;
bool ok;
QVariant v = parser.parse( msg.toAscii(), &ok );
if ( !ok || v.type() != QVariant::Map )
{
QString to = from;
QString response = QString( tr("I'm sorry -- I'm just an automatic presence used by Tomahawk Player"
" (http://gettomahawk.com). If you are getting this message, the person you"
" are trying to reach is probably not signed on, so please try again later!") );
// this is not a sip message, so we send it directly through the client
m_client->send( Jreen::Message ( Jreen::Message::Chat, Jreen::JID(to), response) );
return;
}
qDebug() << Q_FUNC_INFO << "From:" << m.from().full() << ":" << m.body();
emit msgReceived( from, msg ); emit msgReceived( from, msg );
} }
void Jabber_p::onNewPresence( const Jreen::Presence& presence) void Jabber_p::onNewPresence( const Jreen::Presence& presence)
{ {
Jreen::JID jid = presence.from(); Jreen::JID jid = presence.from();
QString fulljid( jid.full() ); QString fulljid( jid.full() );
qDebug() << Q_FUNC_INFO << "handle presence" << fulljid << presence.subtype(); qDebug() << Q_FUNC_INFO << "* New presence: " << fulljid << presence.subtype();
if( jid == m_jid ) if( jid == m_jid )
return; return;
if ( presence.error() ) { if ( presence.error() ) {
qDebug() << Q_FUNC_INFO << "presence error: no tomahawk"; //qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk: no" << "presence error";
return; return;
} }
// ignore anyone not running tomahawk: // ignore anyone not Running tomahawk:
Jreen::Capabilities::Ptr caps = presence.findExtension<Jreen::Capabilities>(); Jreen::Capabilities::Ptr caps = presence.findExtension<Jreen::Capabilities>();
if ( caps && (caps->node() == TOMAHAWK_CAP_NODE_NAME )) if ( caps && ( caps->node() == TOMAHAWK_CAP_NODE_NAME ) )
{ {
qDebug() << Q_FUNC_INFO << presence.from().full() << "tomahawk detected by caps"; // must be a jreen resource, implementation in gloox was broken
qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk: yes" << "caps " << caps->node();
handlePeerStatus( fulljid, presence.subtype() );
} }
// this is a hack actually as long as gloox based libsip_jabber is around else if( caps )
// remove this as soon as everyone is using jreen
else if( presence.from().resource().startsWith( QLatin1String("tomahawk") ) )
{ {
qDebug() << Q_FUNC_INFO << presence.from().full() << "tomahawk detected by resource"; qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk: maybe" << "caps " << caps->node()
} << "requesting disco..";
else if( caps && caps->node() != TOMAHAWK_CAP_NODE_NAME )
{ // request disco features
qDebug() << Q_FUNC_INFO << presence.from().full() << "*no tomahawk* detected by caps!" << caps->node() << presence.from().resource(); QString node = caps->node() + '#' + caps->ver();
return;
Jreen::IQ iq( Jreen::IQ::Get, jid );
iq.addExtension( new Jreen::Disco::Info( node ) );
m_client->send( iq, this, SLOT( onNewIq( Jreen::IQ, int ) ), RequestDisco );
} }
else if( !caps ) else if( !caps )
{ {
qDebug() << Q_FUNC_INFO << "no tomahawk detected by resource and !caps"; qDebug() << Q_FUNC_INFO << "Running tomahawk: no" << "no caps";
return;
} }
}
qDebug() << Q_FUNC_INFO << fulljid << " is a tomahawk resource."; void
Jabber_p::onNewIq( const Jreen::IQ &iq, int context )
// "going offline" event {
if ( !presenceMeansOnline( presence.subtype() ) && if( context == RequestDisco )
( !m_peers.contains( fulljid ) ||
presenceMeansOnline( m_peers.value( fulljid ) )
)
)
{ {
m_peers[ fulljid ] = presence.subtype(); qDebug() << Q_FUNC_INFO << "Received disco IQ...";
qDebug() << Q_FUNC_INFO << "* Peer goes offline:" << fulljid; Jreen::Disco::Info *discoInfo = iq.findExtension<Jreen::Disco::Info>().data();
emit peerOffline( fulljid ); if(!discoInfo)
return; return;
} iq.accept();
// "coming online" event QString fulljid = iq.from().full();
if( presenceMeansOnline( presence.subtype() ) && Jreen::DataForm::Ptr form = discoInfo->form();
( !m_peers.contains( fulljid ) ||
!presenceMeansOnline( m_peers.value( fulljid ) ) if(discoInfo->features().contains( TOMAHAWK_FEATURE ))
) {
) qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk/feature enabled: yes";
// the actual presence doesn't matter, it just needs to be "online"
handlePeerStatus( fulljid, Jreen::Presence::Available );
}
else
{
qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk/feature enabled: no";
//LEGACY: accept resources starting with tomahawk too
if( iq.from().resource().startsWith("tomahawk") )
{
qDebug() << Q_FUNC_INFO << fulljid << "Detected legacy tomahawk..";
// add to legacy peers, so we can send text messages instead of iqs
m_legacy_peers.append( fulljid );
handlePeerStatus( fulljid, Jreen::Presence::Available );
}
}
}
else if(context == RequestedDisco)
{ {
m_peers[ fulljid ] = presence.subtype(); qDebug() << "Sent IQ(Set), what should be happening here?";
qDebug() << Q_FUNC_INFO << "* Peer goes online:" << fulljid;
emit peerOnline( fulljid );
return;
} }
else if(context == SipMessageSent )
{
qDebug() << "Sent SipMessage... what now?!";
}
else
{
TomahawkSipMessage *sipMessage = iq.findExtension<TomahawkSipMessage>().data();
if(sipMessage)
{
qDebug() << Q_FUNC_INFO << "Got SipMessage ...";
qDebug() << "ip" << sipMessage->ip();
qDebug() << "port" << sipMessage->port();
qDebug() << "uniqname" << sipMessage->uniqname();
qDebug() << "key" << sipMessage->key();
qDebug() << "visible" << sipMessage->visible();
//qDebug() << "Updating presence data for" << fulljid;
m_peers[ fulljid ] = presence.subtype();
QVariantMap m;
if( sipMessage->visible() )
{
m["visible"] = true;
m["ip"] = sipMessage->ip();
m["port"] = sipMessage->port();
m["key"] = sipMessage->key();
m["uniqname"] = sipMessage->uniqname();
}
else
{
m["visible"] = false;
}
QJson::Serializer ser;
QByteArray ba = ser.serialize( m );
QString msg = QString::fromAscii( ba );
QString from = iq.from().full();
qDebug() << Q_FUNC_INFO << "From:" << from << ":" << msg;
emit msgReceived( from, msg );
}
}
} }
bool bool
@@ -369,3 +464,44 @@ Jabber_p::presenceMeansOnline( Jreen::Presence::Type p )
return true; return true;
} }
} }
void
Jabber_p::handlePeerStatus( const QString& fulljid, Jreen::Presence::Type presenceType )
{
// "going offline" event
if ( !presenceMeansOnline( presenceType ) &&
( !m_peers.contains( fulljid ) ||
presenceMeansOnline( m_peers.value( fulljid ) )
)
)
{
m_peers[ fulljid ] = presenceType;
qDebug() << Q_FUNC_INFO << "* Peer goes offline:" << fulljid;
// remove peer from legacy peers
if( m_legacy_peers.contains( fulljid ) )
{
m_legacy_peers.removeAll( fulljid );
}
emit peerOffline( fulljid );
return;
}
// "coming online" event
if( presenceMeansOnline( presenceType ) &&
( !m_peers.contains( fulljid ) ||
!presenceMeansOnline( m_peers.value( fulljid ) )
)
)
{
m_peers[ fulljid ] = presenceType;
qDebug() << Q_FUNC_INFO << "* Peer goes online:" << fulljid;
emit peerOnline( fulljid );
return;
}
//qDebug() << "Updating presence data for" << fulljid;
m_peers[ fulljid ] = presenceType;
}

View File

@@ -1,5 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === 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> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -16,20 +17,10 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
/*
This is the Jabber client that the rest of the app sees
Gloox stuff should NOT leak outside this class.
We may replace jreen later, this interface should remain the same.
*/
#ifndef JABBER_P_H #ifndef JABBER_P_H
#define JABBER_P_H #define JABBER_P_H
#include <QObject> #include "../sipdllmacro.h"
#include <QSharedPointer>
#include <QMap>
#include <QNetworkProxy>
#include <string>
#include <jreen/client.h> #include <jreen/client.h>
#include <jreen/disco.h> #include <jreen/disco.h>
@@ -41,16 +32,19 @@
#include <jreen/presence.h> #include <jreen/presence.h>
#include <jreen/vcard.h> #include <jreen/vcard.h>
#include <jreen/abstractroster.h> #include <jreen/abstractroster.h>
#include <jreen/connection.h>
#include <jreen/mucroom.h>
#include <QObject>
#include <QSharedPointer>
#include <QMap>
#include <QNetworkProxy>
#if defined( WIN32 ) || defined( _WIN32 ) #if defined( WIN32 ) || defined( _WIN32 )
# include <windows.h> #include <windows.h>
#endif #endif
#include "../sipdllmacro.h"
#include <jreen/connection.h>
#include <jreen/mucroom.h>
class SIPDLLEXPORT Jabber_p : class SIPDLLEXPORT Jabber_p :
public QObject public QObject
{ {
@@ -87,9 +81,12 @@ private slots:
{ {
qDebug() << e; qDebug() << e;
} }
virtual void onNewIq( const Jreen::IQ &iq, int context = NoContext );
private: private:
bool presenceMeansOnline( Jreen::Presence::Type p ); bool presenceMeansOnline( Jreen::Presence::Type p );
void handlePeerStatus( const QString &fulljid, Jreen::Presence::Type presenceType );
Jreen::Client *m_client; Jreen::Client *m_client;
Jreen::MUCRoom *m_room; Jreen::MUCRoom *m_room;
Jreen::SimpleRoster *m_roster; Jreen::SimpleRoster *m_roster;
@@ -97,6 +94,10 @@ private:
QMap<Jreen::Presence::Type, QString> m_presences; QMap<Jreen::Presence::Type, QString> m_presences;
QMap<QString, Jreen::Presence::Type> m_peers; QMap<QString, Jreen::Presence::Type> m_peers;
QString m_server; QString m_server;
enum IqContext { NoContext, RequestDisco, RequestedDisco, SipMessageSent };
QStringList m_legacy_peers;
}; };
#endif // JABBER_H #endif // JABBER_H

View File

@@ -0,0 +1,74 @@
/****************************************************************************
*
* This file is part of qutIM
*
* Copyright (c) 2011 by Nigmatullin Ruslan <euroelessar@gmail.com>
*
***************************************************************************
* *
* This file is part of 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 2 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************
****************************************************************************/
#include "tomahawksipmessage.h"
class TomahawkSipMessagePrivate
{
public:
QString ip;
int port;
QString uniqname;
QString key;
bool visible;
};
TomahawkSipMessage::TomahawkSipMessage(QString ip, unsigned int port, QString uniqname, QString key, bool visible) : d_ptr(new TomahawkSipMessagePrivate)
{
Q_D(TomahawkSipMessage);
d->ip = ip;
d->port = port;
d->uniqname = uniqname;
d->key = key;
d->visible = visible;
}
TomahawkSipMessage::TomahawkSipMessage() : d_ptr(new TomahawkSipMessagePrivate)
{
Q_D(TomahawkSipMessage);
d->visible = false;
d->port = -1;
}
TomahawkSipMessage::~TomahawkSipMessage()
{
}
const QString TomahawkSipMessage::ip() const
{
return d_func()->ip;
}
unsigned int TomahawkSipMessage::port() const
{
return d_func()->port;
}
QString TomahawkSipMessage::uniqname() const
{
return d_func()->uniqname;
}
QString TomahawkSipMessage::key() const
{
return d_func()->key;
}
bool TomahawkSipMessage::visible() const
{
return d_func()->visible;
}

View File

@@ -0,0 +1,28 @@
#ifndef ENTITYTIME_H
#define ENTITYTIME_H
#include <jreen/stanzaextension.h>
#define TOMAHAWK_SIP_MESSAGE_NS QLatin1String("http://www.tomhawk-player.org/sip/transports")
class TomahawkSipMessagePrivate;
class TomahawkSipMessage : public Jreen::StanzaExtension
{
J_EXTENSION(TomahawkSipMessage, "")
Q_DECLARE_PRIVATE(TomahawkSipMessage)
public:
TomahawkSipMessage(QString ip, unsigned int port, QString uniqname, QString key, bool visible);
// sets visible to false as we dont have any extra information
TomahawkSipMessage();
~TomahawkSipMessage();
const QString ip() const;
unsigned int port() const;
QString uniqname() const;
QString key() const;
bool visible() const;
private:
QScopedPointer<TomahawkSipMessagePrivate> d_ptr;
};
#endif // ENTITYTIME_H

View File

@@ -0,0 +1,124 @@
#include "tomahawksipmessagefactory.h"
//#include "util.h"
#include <QStringList>
#include <QXmlStreamWriter>
#include <QDebug>
#include <QVariant>
using namespace Jreen;
TomahawkSipMessageFactory::TomahawkSipMessageFactory()
{
m_depth = 0;
m_state = AtNowhere;
}
TomahawkSipMessageFactory::~TomahawkSipMessageFactory()
{
}
QStringList TomahawkSipMessageFactory::features() const
{
return QStringList(TOMAHAWK_SIP_MESSAGE_NS);
}
bool TomahawkSipMessageFactory::canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes)
{
Q_UNUSED(uri);
Q_UNUSED(attributes);
return name == QLatin1String("tomahawk") && uri == TOMAHAWK_SIP_MESSAGE_NS;
}
void TomahawkSipMessageFactory::handleStartElement(const QStringRef &name, const QStringRef &uri,
const QXmlStreamAttributes &attributes)
{
m_depth++;
if (m_depth == 1) {
m_state = AtNowhere;
m_ip = QString();
m_port = -1;
m_uniqname = QString();
m_key = QString();
m_visible = false;
} else if (m_depth == 2) {
if (name == QLatin1String("transport"))
{
qDebug() << "Found Transport";
m_state = AtTransport;
m_uniqname = attributes.value(QLatin1String("uniqname")).toString();
m_key = attributes.value(QLatin1String("pwd")).toString();
m_visible = true;
}
} else if(m_depth == 3) {
if (name == QLatin1String("candidate"))
{
m_state = AtCandidate;
qDebug() << "Found candidate";
m_ip = attributes.value(QLatin1String("ip")).toString();
m_port = attributes.value(QLatin1String("port")).toString().toInt();
}
}
Q_UNUSED(uri);
Q_UNUSED(attributes);
}
void TomahawkSipMessageFactory::handleEndElement(const QStringRef &name, const QStringRef &uri)
{
if (m_depth == 3)
m_state = AtNowhere;
Q_UNUSED(name);
Q_UNUSED(uri);
m_depth--;
}
void TomahawkSipMessageFactory::handleCharacterData(const QStringRef &text)
{
/*if (m_state == AtUtc) {
//m_utc = Util::fromStamp(text.toString());
} else if (m_state == AtTzo) {
QString str = text.toString();
int multiple = str.startsWith('-') ? -1 : 1;
//QTime delta = QTime::fromString(str.mid(1), QLatin1String("hh:mm"));
//m_tzo = multiple * (delta.hour() * 60 + delta.minute());
}*/
Q_UNUSED(text);
}
void TomahawkSipMessageFactory::serialize(StanzaExtension *extension, QXmlStreamWriter *writer)
{
TomahawkSipMessage *sipMessage = se_cast<TomahawkSipMessage*>(extension);
writer->writeStartElement(QLatin1String("tomahawk"));
writer->writeDefaultNamespace(TOMAHAWK_SIP_MESSAGE_NS);
if(sipMessage->visible())
{
// add transport tag
writer->writeStartElement(QLatin1String("transport"));
writer->writeAttribute(QLatin1String("pwd"), sipMessage->key());
writer->writeAttribute(QLatin1String("uniqname"), sipMessage->uniqname());
writer->writeEmptyElement(QLatin1String("candidate"));
writer->writeAttribute(QLatin1String("component"), "1");
writer->writeAttribute(QLatin1String("id"), "el0747fg11"); // FIXME
writer->writeAttribute(QLatin1String("ip"), sipMessage->ip());
writer->writeAttribute(QLatin1String("network"), "1");
writer->writeAttribute(QLatin1String("port"), QVariant(sipMessage->port()).toString());
writer->writeAttribute(QLatin1String("priority"), "1"); //TODO
writer->writeAttribute(QLatin1String("protocol"), "tcp");
writer->writeAttribute(QLatin1String("type"), "host"); //FIXME: correct?!
writer->writeEndElement();
}
else
{
writer->writeEmptyElement(QLatin1String("transport"));
}
writer->writeEndElement();
}
StanzaExtension::Ptr TomahawkSipMessageFactory::createExtension()
{
return StanzaExtension::Ptr(new TomahawkSipMessage(m_ip, m_port, m_uniqname, m_key, m_visible));
}

View File

@@ -0,0 +1,46 @@
/****************************************************************************
*
* This file is part of qutIM
*
* Copyright (c) 2011 by Nigmatullin Ruslan <euroelessar@gmail.com>
*
***************************************************************************
* *
* This file is part of 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 2 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************
****************************************************************************/
#ifndef ENTITYTIMEFACTORY_P_H
#define ENTITYTIMEFACTORY_P_H
#include "tomahawksipmessage.h"
#include <jreen/stanzaextension.h>
class TomahawkSipMessageFactory : public Jreen::StanzaExtensionFactory<TomahawkSipMessage>
{
public:
TomahawkSipMessageFactory();
virtual ~TomahawkSipMessageFactory();
QStringList features() const;
bool canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes);
void handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes);
void handleEndElement(const QStringRef &name, const QStringRef &uri);
void handleCharacterData(const QStringRef &text);
void serialize(Jreen::StanzaExtension *extension, QXmlStreamWriter *writer);
Jreen::StanzaExtension::Ptr createExtension();
private:
enum State { AtNowhere, AtTransport, AtCandidate } m_state;
int m_depth;
QString m_ip;
int m_port;
QString m_uniqname;
QString m_key;
bool m_visible;
};
#endif // ENTITYTIMEFACTORY_P_H

View File

@@ -154,10 +154,11 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
, m_mainwindow( 0 ) , m_mainwindow( 0 )
{ {
qDebug() << "TomahawkApp thread:" << this->thread(); qDebug() << "TomahawkApp thread:" << this->thread();
setOrganizationName( QLatin1String( ORGANIZATION_NAME ) ); setOrganizationName( QLatin1String( TOMAHAWK_ORGANIZATION_NAME ) );
setOrganizationDomain( QLatin1String( ORGANIZATION_DOMAIN ) ); setOrganizationDomain( QLatin1String( TOMAHAWK_ORGANIZATION_DOMAIN ) );
setApplicationName( QLatin1String( APPLICATION_NAME ) ); setApplicationName( QLatin1String( TOMAHAWK_APPLICATION_NAME ) );
setApplicationVersion( QLatin1String( VERSION ) ); setApplicationVersion( QLatin1String( TOMAHAWK_VERSION ) );
registerMetaTypes();
setupLogfile(); setupLogfile();
} }

View File

@@ -1,5 +1,5 @@
add_subdirectory( jdns ) ADD_SUBDIRECTORY( jdns )
add_subdirectory( qtweetlib ) ADD_SUBDIRECTORY( qtweetlib )
ADD_SUBDIRECTORY( libportfwd ) ADD_SUBDIRECTORY( libportfwd )
ADD_SUBDIRECTORY( qxt ) ADD_SUBDIRECTORY( qxt )
ADD_SUBDIRECTORY( liblastfm2 ) ADD_SUBDIRECTORY( liblastfm2 )