Exemplo n.º 1
0
void IRCNetworkPlugin::handleMessageSendRequest(const std::string &user, const std::string &legacyName, const std::string &message, const std::string &/*xhtml*/) {
	std::string u = user;
	std::cout << "AAAAA " << legacyName << "\n";
	if (!CONFIG_BOOL(config, "service.server_mode")) {
		u = user + legacyName.substr(legacyName.find("@") + 1);
		if (u.find("/") != std::string::npos) {
			u = u.substr(0, u.find("/"));
		}
	}
	if (m_sessions[u] == NULL) {
		std::cout << "No session for " << u << "\n";
		return;
	}

	std::string r = legacyName;
	if (!CONFIG_BOOL(config, "service.server_mode")) {
		if (legacyName.find("/") == std::string::npos) {
			r = legacyName.substr(0, r.find("@"));
		}
		else {
			r = legacyName.substr(legacyName.find("/") + 1);
		}
	}
	std::cout << "MESSAGE " << u << " " << r << "\n";
	m_sessions[u]->sendCommand(IrcCommand::createMessage(FROM_UTF8(r), FROM_UTF8(message)));
	std::cout << "SENT\n";
}
Exemplo n.º 2
0
void IRCNetworkPlugin::handleJoinRoomRequest(const std::string &user, const std::string &room, const std::string &nickname, const std::string &password) {
	std::cout << "JOIN\n";
	std::string r = room;
	std::string u = user;
	if (!CONFIG_BOOL(config, "service.server_mode")) {
		u = user + room.substr(room.find("@") + 1);
		r = room.substr(0, room.find("@"));
	}
	if (m_sessions[u] == NULL) {
		// in gateway mode we want to login this user to network according to legacyName
		if (room.find("@") != std::string::npos) {
			// suffix is %irc.freenode.net to let MyIrcSession return #room%irc.freenode.net
			MyIrcSession *session = new MyIrcSession(user, this, room.substr(room.find("@")));
			session->setNickName(FROM_UTF8(nickname));
			session->setHost(FROM_UTF8(room.substr(room.find("@") + 1)));
			session->setPort(6667);
			session->open();
			std::cout << "CONNECTING IRC NETWORK " << room.substr(room.find("@") + 1) << "\n";
			std::cout << "SUFFIX " << room.substr(room.find("@")) << "\n";
			m_sessions[u] = session;
		}
		else {
			return;
		}
	}
	std::cout << "JOINING " << r << "\n";
	m_sessions[u]->addAutoJoinChannel(r);
	m_sessions[u]->sendCommand(IrcCommand::createJoin(FROM_UTF8(r), FROM_UTF8(password)));
	m_sessions[u]->rooms += 1;
	// update nickname, because we have nickname per session, no nickname per room.
	handleRoomNicknameChanged(user, r, TO_UTF8(m_sessions[u]->nickName()));
}
Exemplo n.º 3
0
std::string IRCNetworkPlugin::getSessionName(const std::string &user, const std::string &legacyName) {
	std::string u = user;
	if (!CONFIG_BOOL(m_config, "service.server_mode") && m_servers.empty()) {
		u = user + legacyName.substr(legacyName.find("@") + 1);
		if (u.find("/") != std::string::npos) {
			u = u.substr(0, u.find("/"));
		}
	}
	return u;
}
Exemplo n.º 4
0
void IRCNetworkPlugin::handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password) {
	// Server is in server-mode, so user is JID of server when we want to connect
	if (CONFIG_BOOL(config, "service.server_mode")) {
		MyIrcSession *session = new MyIrcSession(user, this);
		std::string h = user.substr(0, user.find("@"));
		session->setNickName(FROM_UTF8(h.substr(0, h.find("%"))));
		session->setHost(FROM_UTF8(h.substr(h.find("%") + 1)));
		session->setPort(6667);
		session->open();
		std::cout << "CONNECTING IRC NETWORK " << h.substr(h.find("%") + 1) << "\n";
		m_sessions[user] = session;
	}
	else {
		handleConnected(user);
	}
}
Exemplo n.º 5
0
void IRCNetworkPlugin::handleLeaveRoomRequest(const std::string &user, const std::string &room) {
	std::string r = room;
	std::string u = user;
	if (!CONFIG_BOOL(config, "service.server_mode")) {
		r = room.substr(0, room.find("@"));
		u = user + room.substr(room.find("@") + 1);
	}

	if (m_sessions[u] == NULL)
		return;

	m_sessions[u]->sendCommand(IrcCommand::createPart(FROM_UTF8(r)));
	m_sessions[u]->removeAutoJoinChannel(r);
	m_sessions[u]->rooms -= 1;

	if (m_sessions[u]->rooms <= 0) {
		m_sessions[u]->close();
		m_sessions[u]->deleteLater();
		m_sessions.erase(u);
	}
}
Exemplo n.º 6
0
/*********************************************************************
 * The Panels
 *********************************************************************/
SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                          int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
{
    module_config_t *p_config;
    ConfigControl *control;
    number = _number;

#define CONFIG_GENERIC( option, type, label, qcontrol )                   \
            p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
            if( p_config )                                                \
            {                                                             \
                control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
                           p_config, label, ui.qcontrol, false );         \
                controls.append( control );                               \
            }                                                             \
            else {                                                        \
                ui.qcontrol->setEnabled( false );                         \
                if( label ) label->setEnabled( false );                   \
            }

#define CONFIG_BOOL( option, qcontrol )                           \
            p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
            if( p_config )                                                \
            {                                                             \
                control =  new BoolConfigControl( VLC_OBJECT(p_intf),     \
                           p_config, NULL, ui.qcontrol, false );          \
                controls.append( control );                               \
            }                                                             \
            else { ui.qcontrol->setEnabled( false ); }


#define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol )             \
            p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
            if( p_config )                                                \
            {                                                             \
                control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
                           p_config, label, qcontrol, false );            \
                controls.append( control );                               \
            }                                                             \
            else {                                                        \
                QWidget *widget = label;                                  \
                qcontrol->setVisible( false );                            \
                if( widget ) widget->setEnabled( false );                 \
            }


#define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol )           \
            p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
            if( p_config )                                                \
            {                                                             \
                control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
                           p_config, label, ui.qcontrol );                \
                controls.append( control );                               \
            }

#define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton )     \
            p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
            if( p_config )                                                \
            {                                                             \
                control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
                           p_config, label, qcontrol, qbutton );          \
                controls.append( control );                               \
            }

#define START_SPREFS_CAT( name , label )    \
        case SPrefs ## name:                \
        {                                   \
            Ui::SPrefs ## name ui;      \
            ui.setupUi( panel );            \
            panel_label->setText( label );

#define END_SPREFS_CAT      \
            break;          \
        }

    QVBoxLayout *panel_layout = new QVBoxLayout();
    QWidget *panel = new QWidget();
    panel_layout->setMargin( 3 );

    // Title Label
    QLabel *panel_label = new QLabel;
    QFont labelFont = QApplication::font( static_cast<QWidget*>(0) );
    labelFont.setPointSize( labelFont.pointSize() + 6 );
    labelFont.setFamily( "Verdana" );
    panel_label->setFont( labelFont );

    // Title <hr>
    QFrame *title_line = new QFrame;
    title_line->setFrameShape(QFrame::HLine);
    title_line->setFrameShadow(QFrame::Sunken);

    QFont italicFont = QApplication::font( static_cast<QWidget*>(0) );
    italicFont.setItalic( true );

    switch( number )
    {
        /******************************
         * VIDEO Panel Implementation *
         ******************************/
        START_SPREFS_CAT( Video , qtr("Video Settings") );
            CONFIG_BOOL( "video", enableVideo );

            CONFIG_BOOL( "fullscreen", fullscreen );
            CONFIG_BOOL( "overlay", overlay );
            CONFIG_BOOL( "video-on-top", alwaysOnTop );
            CONFIG_BOOL( "video-deco", windowDecorations );
            CONFIG_BOOL( "skip-frames", skipFrames );
            CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );

            CONFIG_BOOL( "video-wallpaper", wallpaperMode );
#ifdef WIN32
            CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
                            dXdisplayDevice );
            CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
#else
            ui.directXBox->setVisible( false );
            ui.hwYUVBox->setVisible( false );
#endif

            CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
            CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
            CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );

            CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
                                 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
            CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
            CONFIG_BOOL( "snapshot-sequential",
                            snapshotsSequentialNumbering );
            CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
                            snapshotsFormat );
         END_SPREFS_CAT;

        /******************************
         * AUDIO Panel Implementation *
         ******************************/
        START_SPREFS_CAT( Audio, qtr("Audio Settings") );

            CONFIG_BOOL( "audio", enableAudio );
            ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() );
            CONNECT( ui.enableAudio, toggled( bool ),
                     ui.SPrefsAudio_zone, setEnabled( bool ) );

#define audioCommon( name ) \
            QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
            QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
            name ## Layout->setMargin( 0 ); \
            name ## Layout->setSpacing( 0 ); \
            QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
            name ## Label->setMinimumSize(QSize(250, 0)); \
            name ## Layout->addWidget( name ## Label ); \

#define audioControl( name) \
            audioCommon( name ) \
            QComboBox * name ## Device = new QComboBox( name ## Control ); \
            name ## Layout->addWidget( name ## Device ); \
            name ## Label->setBuddy( name ## Device ); \
            outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );

#define audioControl2( name) \
            audioCommon( name ) \
            QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
            name ## Layout->addWidget( name ## Device ); \
            name ## Label->setBuddy( name ## Device ); \
            QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
            name ## Layout->addWidget( name ## Browse ); \
            outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );

            /* Build if necessary */
            QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
#ifdef WIN32
            audioControl( DirectX );
            optionWidgets.append( DirectXControl );
            CONFIG_GENERIC_NO_UI( "directx-audio-device-name", StringList,
                    DirectXLabel, DirectXDevice );
#else
            if( module_exists( "alsa" ) )
            {
                audioControl( alsa );
                optionWidgets.append( alsaControl );

                CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
                                alsaDevice );
            }
            else
                optionWidgets.append( NULL );
            if( module_exists( "oss" ) )
            {
                audioControl2( OSS );
                optionWidgets.append( OSSControl );
                CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
                                 OSSBrowse );
            }
            else
                optionWidgets.append( NULL );
#endif

#undef audioControl2
#undef audioControl
#undef audioCommon

            /* Audio Options */
            CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
                                     defaultVolume );
            CONNECT( ui.defaultVolume, valueChanged( int ),
                     this, updateAudioVolume( int ) );

            CONFIG_BOOL( "qt-autosave-volume", keepVolumeRadio );
            ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
            CONNECT( ui.resetVolumeRadio, toggled( bool ),
                     ui.defaultVolume_zone, setEnabled( bool ) );

            CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
                            preferredAudioLanguage );

            CONFIG_BOOL( "spdif", spdifBox );
            CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
                            detectionDolby );

            CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
                                    volNormSpin );
            CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
                            replayCombo );
            CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel,
                            visualisation);
            CONFIG_BOOL( "audio-time-stretch", autoscaleBox );

            /* Audio Output Specifics */
            CONFIG_GENERIC( "aout", Module, ui.outputLabel, outputModule );

            CONNECT( ui.outputModule, currentIndexChanged( int ),
                     this, updateAudioOptions( int ) );

            /* File output exists on all platforms */
            CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
                                 ui.fileName, ui.fileBrowseButton );

            optionWidgets.append( ui.fileControl );
            optionWidgets.append( ui.outputModule );
            optionWidgets.append( ui.volNormBox );
            /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
            ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
            optionWidgets.append( ui.volumeValue );
            optionWidgets.append( ui.headphoneEffect );
            optionWidgets.append( ui.spdifBox );
            updateAudioOptions( ui.outputModule->currentIndex() );

            /* LastFM */
            if( module_exists( "audioscrobbler" ) )
            {
                CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
                        lastfm_user_edit );
                CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
                        lastfm_pass_edit );

                if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
                    ui.lastfm->setChecked( true );
                else
                    ui.lastfm->setChecked( false );

                ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );

                CONNECT( ui.lastfm, toggled( bool ),
                         ui.lastfm_zone, setVisible( bool ) );
                CONNECT( ui.lastfm, stateChanged( int ),
                         this, lastfm_Changed( int ) );
            }
            else
            {
Exemplo n.º 7
0
static config_index_t CFG_X264_ME;
static config_index_t CFG_X264_ME_RANGE;
static config_index_t CFG_X264_SUBME;
static config_index_t CFG_X264_USE_VBV;
static config_index_t CFG_X264_VBV_MAXRATE;
static config_index_t CFG_X264_VBV_BUFSIZE;
static config_index_t CFG_X264_BIT_RATE_TOLERANCE;
static config_index_t CFG_X264_THREADS;
static config_index_t CFG_X264_SAR_WIDTH;
static config_index_t CFG_X264_SAR_HEIGHT;

static SConfigVariable X264EncoderVariables[] = {
  CONFIG_BOOL_HELP(CFG_X264_FORCE_BASELINE, "x264ForceBaseline", false, "Turns off CABC and b-frames. Turns on VBV."),
  CONFIG_BOOL_HELP(CFG_X264_USE_CABAC, "x264UseCabac", true, "Turn on CABAC (Context-based Adaptive Binary Arithmetic Coding) (--no-cabac)"),
#ifndef HAVE_X264_PARAM_T_RC_I_RC_METHOD
  CONFIG_BOOL(CFG_X264_USE_CBR, "x264UseCbr", true),
#endif
  CONFIG_BOOL_HELP(CFG_X264_USE_PSNR, "x264UsePsnr", true, "Enable Peak Signal-to-Noise Ratio computation (--no-psnr)"),
  CONFIG_BOOL_HELP(CFG_X264_USE_SSIM, "x264UseSsim", true, "Enable Structural Similarity Index computation (--no-ssim)"),
  CONFIG_BOOL_HELP(CFG_X264_USE_8x8_DCT, "x264Use8x8dct", false, "Adaptive spatial transform size (--8x8dct)"),
  CONFIG_STRING_HELP(CFG_X264_LEVEL, "x264Level", NULL, "Specify level (as defined by Annex A) (--level)"),
  CONFIG_STRING_HELP(CFG_X264_PARTITIONS, "x264Partitions", NULL, "Partitions to consider [\"p8x8,b8x8,i8x8,i4x4\"] (--partitions)\n     - p8x8, p4x4, b8x8, i8x8, i4x4\n     - none, all\n     (p4x4 requires p8x8. i8x8 requires --8x8dct.)"),
  CONFIG_STRING_HELP(CFG_X264_ME, "x264Me", NULL, "Integer pixel motion estimation method [\"hex\"] (--me)\n     - dia: diamond search, radius 1 (fast)\n     - hex: hexagonal search, radius 2\n     - umh: uneven multi-hexagon search\n     - esa: exhaustive search (slow)"),
  CONFIG_INT_HELP(CFG_X264_ME_RANGE, "x264MeRange", 16, "Maximum motion vector search range [16] (--merange)"),
  CONFIG_INT_HELP(CFG_X264_SUBME, "x264Subme", 5, "Subpixel motion estimation and partition decision quality: 1=fast, 7=best. [5] (--subme)"),
  CONFIG_BOOL(CFG_X264_USE_VBV, "x264UseVbv", false),
  CONFIG_INT_HELP(CFG_X264_VBV_MAXRATE, "x264VbvMaxrate", 0, "Max local bitrate (kbit/s) [0] (--vbv-maxrate)"),
  CONFIG_INT_HELP(CFG_X264_VBV_BUFSIZE, "x264VbvBufsize", 0, "Enable CBR and set size of the VBV buffer (kbit) [0] (--vbv-bufsize)"),
  CONFIG_FLOAT_HELP(CFG_X264_BIT_RATE_TOLERANCE, "x264BitRateTolerance", 1.0, "Allowed variance of average bitrate [1.0] (--ratetol)"),
  CONFIG_INT_HELP(CFG_X264_THREADS, "x264Threads", 0, "Parallel encoding (0=auto) (--threads)"),
  CONFIG_INT_HELP(CFG_X264_SAR_WIDTH, "x264SarWidth", 0, "Specify Sample Aspect Ratio Width (--sar width:height)"),
Exemplo n.º 8
0
Component::Component(Swift::EventLoop *loop, Swift::NetworkFactories *factories, Config *config, Factory *factory, Transport::UserRegistry *userRegistry) {
	m_component = NULL;
	m_userRegistry = NULL;
	m_server = NULL;
	m_reconnectCount = 0;
	m_config = config;
	m_factory = factory;
	m_loop = loop;
	m_userRegistry = userRegistry;

	m_jid = Swift::JID(CONFIG_STRING(m_config, "service.jid"));

	m_factories = factories;

	m_reconnectTimer = m_factories->getTimerFactory()->createTimer(3000);
	m_reconnectTimer->onTick.connect(bind(&Component::start, this)); 

	if (CONFIG_BOOL(m_config, "service.server_mode")) {
		LOG4CXX_INFO(logger, "Creating component in server mode on port " << CONFIG_INT(m_config, "service.port"));
		m_server = new Swift::Server(loop, m_factories, m_userRegistry, m_jid, CONFIG_INT(m_config, "service.port"));
		if (!CONFIG_STRING(m_config, "service.cert").empty()) {
#ifndef _WIN32
//TODO: fix
			LOG4CXX_INFO(logger, "Using PKCS#12 certificate " << CONFIG_STRING(m_config, "service.cert"));
			LOG4CXX_INFO(logger, "SSLv23_server_method used.");
			TLSServerContextFactory *f = new OpenSSLServerContextFactory();
			m_server->addTLSEncryption(f, boost::make_shared<PKCS12Certificate>(CONFIG_STRING(m_config, "service.cert"), createSafeByteArray(CONFIG_STRING(m_config, "service.cert_password"))));
#endif
			
		}
		else {
			LOG4CXX_WARN(logger, "No PKCS#12 certificate used. TLS is disabled.");
		}
// 		m_server->start();
		m_stanzaChannel = m_server->getStanzaChannel();
		m_iqRouter = m_server->getIQRouter();

		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<StorageParser>("private", "jabber:iq:private"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::AttentionParser>("attention", "urn:xmpp:attention:0"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::XHTMLIMParser>("html", "http://jabber.org/protocol/xhtml-im"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Transport::BlockParser>("block", "urn:xmpp:block:0"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::InvisibleParser>("invisible", "urn:xmpp:invisible:0"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::StatsParser>("query", "http://jabber.org/protocol/stats"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::GatewayPayloadParser>("query", "jabber:iq:gateway"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::MUCPayloadParser>("x", "http://jabber.org/protocol/muc"));

		m_server->addPayloadSerializer(new Swift::AttentionSerializer());
		m_server->addPayloadSerializer(new Swift::XHTMLIMSerializer());
		m_server->addPayloadSerializer(new Transport::BlockSerializer());
		m_server->addPayloadSerializer(new Swift::InvisibleSerializer());
		m_server->addPayloadSerializer(new Swift::StatsSerializer());
		m_server->addPayloadSerializer(new Swift::SpectrumErrorSerializer());
		m_server->addPayloadSerializer(new Swift::GatewayPayloadSerializer());

		m_server->onDataRead.connect(boost::bind(&Component::handleDataRead, this, _1));
		m_server->onDataWritten.connect(boost::bind(&Component::handleDataWritten, this, _1));
	}
	else {
		LOG4CXX_INFO(logger, "Creating component in gateway mode");
		m_component = new Swift::Component(loop, m_factories, m_jid, CONFIG_STRING(m_config, "service.password"));
		m_component->setSoftwareVersion("", "");
		m_component->onConnected.connect(bind(&Component::handleConnected, this));
		m_component->onError.connect(boost::bind(&Component::handleConnectionError, this, _1));
		m_component->onDataRead.connect(boost::bind(&Component::handleDataRead, this, _1));
		m_component->onDataWritten.connect(boost::bind(&Component::handleDataWritten, this, _1));

		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<StorageParser>("private", "jabber:iq:private"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::AttentionParser>("attention", "urn:xmpp:attention:0"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::XHTMLIMParser>("html", "http://jabber.org/protocol/xhtml-im"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Transport::BlockParser>("block", "urn:xmpp:block:0"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::InvisibleParser>("invisible", "urn:xmpp:invisible:0"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::StatsParser>("query", "http://jabber.org/protocol/stats"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::GatewayPayloadParser>("query", "jabber:iq:gateway"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::MUCPayloadParser>("x", "http://jabber.org/protocol/muc"));

		m_component->addPayloadSerializer(new Swift::AttentionSerializer());
		m_component->addPayloadSerializer(new Swift::XHTMLIMSerializer());
		m_component->addPayloadSerializer(new Transport::BlockSerializer());
		m_component->addPayloadSerializer(new Swift::InvisibleSerializer());
		m_component->addPayloadSerializer(new Swift::StatsSerializer());
		m_component->addPayloadSerializer(new Swift::SpectrumErrorSerializer());
		m_component->addPayloadSerializer(new Swift::GatewayPayloadSerializer());

		m_stanzaChannel = m_component->getStanzaChannel();
		m_iqRouter = m_component->getIQRouter();
	}

	m_capsMemoryStorage = new CapsMemoryStorage();
	m_capsManager = new CapsManager(m_capsMemoryStorage, m_stanzaChannel, m_iqRouter);
	m_entityCapsManager = new EntityCapsManager(m_capsManager, m_stanzaChannel);
 	m_entityCapsManager->onCapsChanged.connect(boost::bind(&Component::handleCapsChanged, this, _1));
	
	m_presenceOracle = new Transport::PresenceOracle(m_stanzaChannel);
	m_presenceOracle->onPresenceChange.connect(bind(&Component::handlePresence, this, _1));

	m_discoInfoResponder = new DiscoInfoResponder(m_iqRouter, m_config);
	m_discoInfoResponder->start();

// 
// 	m_registerHandler = new SpectrumRegisterHandler(m_component);
// 	m_registerHandler->start();
}
Exemplo n.º 9
0
 *              Bill May        [email protected]
 */
/*
 * mpeg2 video codec with libmpeg2 library
 */
#define DECLARE_CONFIG_VARIABLES
#include "ffmpeg.h"
#include "mp4av.h"
#include "mp4av_h264.h"
#include <mpeg2t/mpeg2t_defines.h>
#include "mp4util/mpeg4_sdp.h"
#include "mp4util/h264_sdp.h"
#include <mpeg2ps/mpeg2_ps.h>

static SConfigVariable MyConfigVariables[] = {
    CONFIG_BOOL(CONFIG_USE_FFMPEG, "UseFFmpeg", false),
};

#define ffmpeg_message (ffmpeg->m_vft->log_msg)

//#define DEBUG_FFMPEG_FRAME 1
//#define DEBUG_FFMPEG_PTS 1
static enum CodecID ffmpeg_find_codec (const char *stream_type,
                                       const char *compressor,
                                       int type,
                                       int profile,
                                       format_list_t *fptr,
                                       const uint8_t *userdata,
                                       uint32_t ud_size)
{
    bool have_mp4_file = strcasecmp(stream_type, STREAM_TYPE_MP4_FILE) == 0;
Exemplo n.º 10
0
bool UserRegistration::handleSetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::InBandRegistrationPayload> payload) {
	if (CONFIG_STRING(m_config, "service.protocol") == "irc") {
		Swift::GetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify);
		return true;
	}

	std::string barejid = from.toBare().toString();

// 	AbstractUser *user = m_component->userManager()->getUserByJID(barejid);
	if (!CONFIG_BOOL(m_config,"registration.enable_public_registration")) {
		std::list<std::string> const &x = CONFIG_LIST(m_config,"service.allowed_servers");
		if (std::find(x.begin(), x.end(), from.getDomain()) == x.end()) {
// 			Log("UserRegistration", "This user has no permissions to register an account");
			Swift::SetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify);
			return true;
		}
	}

	UserInfo res;
	bool registered = m_storageBackend->getUser(barejid, res);

	std::string encoding;
	std::string language;

	Form::ref form = payload->getForm();
	if (form) {
		const std::vector<FormField::ref> fields = form->getFields();
		for (std::vector<FormField::ref>::const_iterator it = fields.begin(); it != fields.end(); it++) {
			TextSingleFormField::ref textSingle = boost::dynamic_pointer_cast<TextSingleFormField>(*it);
			if (textSingle) {
				if (textSingle->getName() == "username") {
					payload->setUsername(textSingle->getValue());
				}
				else if (textSingle->getName() == "encoding") {
					encoding = textSingle->getValue();
				}
				continue;
			}

			TextPrivateFormField::ref textPrivate = boost::dynamic_pointer_cast<TextPrivateFormField>(*it);
			if (textPrivate) {
				if (textPrivate->getName() == "password") {
					payload->setPassword(textPrivate->getValue());
				}
				continue;
			}

			ListSingleFormField::ref listSingle = boost::dynamic_pointer_cast<ListSingleFormField>(*it);
			if (listSingle) {
				if (listSingle->getName() == "language") {
					language = listSingle->getValue();
				}
				continue;
			}

			BooleanFormField::ref boolean = boost::dynamic_pointer_cast<BooleanFormField>(*it);
			if (boolean) {
				if (boolean->getName() == "unregister") {
					if (boolean->getValue()) {
						payload->setRemove(true);
					}
				}
				continue;
			}
		}
	}

	if (payload->isRemove()) {
		unregisterUser(barejid);
		Swift::SetResponder<Swift::InBandRegistrationPayload>::sendResponse(from, id, InBandRegistrationPayload::ref());
		return true;
	}

	if (!payload->getUsername() || !payload->getPassword()) {
		Swift::SetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify);
		return true;
	}

	// Register or change password
	if (payload->getUsername()->empty() ||
		(payload->getPassword()->empty() && CONFIG_STRING(m_config, "service.protocol") != "twitter" && CONFIG_STRING(m_config, "service.protocol") != "bonjour")
// 		|| localization.getLanguages().find(language) == localization.getLanguages().end()
	)
	{
		Swift::SetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify);
		return true;
	}

	if (CONFIG_STRING(m_config, "service.protocol") == "xmpp") {
		// User tries to register himself.
		if ((Swift::JID(*payload->getUsername()).toBare() == from.toBare())) {
			Swift::SetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify);
			return true;
		}

		// User tries to register someone who's already registered.
		UserInfo user_row;
		bool registered = m_storageBackend->getUser(Swift::JID(*payload->getUsername()).toBare().toString(), user_row);
		if (registered) {
			Swift::SetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify);
			return true;
		}
	}

	std::string username = *payload->getUsername();
// 	m_component->protocol()->prepareUsername(username);

	std::string newUsername(username);
	if (!CONFIG_STRING(m_config, "registration.username_mask").empty()) {
		newUsername = CONFIG_STRING(m_config, "registration.username_mask");
// 		replace(newUsername, "$username", username.c_str());
	}

// 	if (!m_component->protocol()->isValidUsername(newUsername)) {
// 		Log("UserRegistration", "This is not valid username: "******"registration.reg_allowed_usernames").empty() &&
// 		!g_regex_match_simple(CONFIG_STRING(m_config, "registration.reg_allowed_usernames"), newUsername.c_str(),(GRegexCompileFlags) (G_REGEX_CASELESS | G_REGEX_EXTENDED), (GRegexMatchFlags) 0)) {
// 		Log("UserRegistration", "This is not valid username: "******"UserRegistration", "changing user password: "******", " << username);
		res.jid = barejid;
		res.password = *payload->getPassword();
		res.language = language;
		res.encoding = encoding;
		m_storageBackend->setUser(res);
		onUserUpdated(res);
	}

	Swift::SetResponder<Swift::InBandRegistrationPayload>::sendResponse(from, id, InBandRegistrationPayload::ref());
	return true;
}
Exemplo n.º 11
0
bool UserRegistration::handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::InBandRegistrationPayload> payload) {
	if (CONFIG_STRING(m_config, "service.protocol") == "irc") {
		Swift::GetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify);
		return true;
	}

	std::string barejid = from.toBare().toString();

// 	User *user = m_userManager->getUserByJID(barejid);
	if (!CONFIG_BOOL(m_config,"registration.enable_public_registration")) {
		std::list<std::string> const &x = CONFIG_LIST(m_config,"service.allowed_servers");
		if (std::find(x.begin(), x.end(), from.getDomain()) == x.end()) {
// 			Log("UserRegistration", "This user has no permissions to register an account");
			Swift::GetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify);
			return true;
		}
	}

// 	const char *_language = user ? user->getLang() : CONFIG_STRING(m_config, "registration.language").c_str();

	boost::shared_ptr<InBandRegistrationPayload> reg(new InBandRegistrationPayload());

	UserInfo res;
	bool registered = m_storageBackend->getUser(barejid, res);

	std::string instructions = CONFIG_STRING(m_config, "registration.instructions");

	reg->setInstructions(instructions);
	reg->setRegistered(registered);
	reg->setUsername(res.uin);
	if (CONFIG_STRING(m_config, "service.protocol") != "twitter" && CONFIG_STRING(m_config, "service.protocol") != "bonjour")
		reg->setPassword(res.password);

	std::string usernameField = CONFIG_STRING(m_config, "registration.username_field");

	Form::ref form(new Form(Form::FormType));
	form->setTitle(tr(_language, _("Registration")));
	form->setInstructions(tr(_language, instructions));

	HiddenFormField::ref type = HiddenFormField::create();
	type->setName("FORM_TYPE");
	type->setValue("jabber:iq:register");
	form->addField(type);

	TextSingleFormField::ref username = TextSingleFormField::create();
	username->setName("username");
	username->setLabel(tr(_language, usernameField));
	username->setValue(res.uin);
	username->setRequired(true);
	form->addField(username);

	if (CONFIG_STRING(m_config, "service.protocol") != "twitter" && CONFIG_STRING(m_config, "service.protocol") != "bonjour") {
		TextPrivateFormField::ref password = TextPrivateFormField::create();
		password->setName("password");
		password->setLabel(tr(_language, _("Password")));
		password->setRequired(true);
		form->addField(password);
	}

	ListSingleFormField::ref language = ListSingleFormField::create();
	language->setName("language");
	language->setLabel(tr(_language, _("Language")));
	if (registered)
		language->setValue(res.language);
	else
		language->setValue(CONFIG_STRING(m_config, "registration.language"));
// 	std::map <std::string, std::string> languages = localization.getLanguages();
// 	for (std::map <std::string, std::string>::iterator it = languages.begin(); it != languages.end(); it++) {
// 		language->addOption(FormField::Option((*it).second, (*it).first));
// 	}
	form->addField(language);

	TextSingleFormField::ref encoding = TextSingleFormField::create();
	encoding->setName("encoding");
	encoding->setLabel(tr(_language, _("Encoding")));
	if (registered)
		encoding->setValue(res.encoding);
	else
		encoding->setValue(CONFIG_STRING(m_config, "registration.encoding"));
	form->addField(encoding);

	if (registered) {
		BooleanFormField::ref boolean = BooleanFormField::create();
		boolean->setName("unregister");
		boolean->setLabel(tr(_language, _("Remove your registration")));
		boolean->setValue(0);
		form->addField(boolean);
	}

	reg->setForm(form);

	Swift::GetResponder<Swift::InBandRegistrationPayload>::sendResponse(from, id, reg);

	return true;
}
Exemplo n.º 12
0
  CONFIG_INT_HELP(CONFIG_IPPORT_MIN, "RtpIpPortMin", UINT32_MAX, "Set minimum IP port to receive on"),
  CONFIG_INT_HELP(CONFIG_IPPORT_MAX, "RtpIpPortMax", UINT32_MAX, "Set maximum IP port to receive on"),
  CONFIG_INT(CONFIG_USE_OLD_MP4_LIB, "UseOldMp4Lib", 0),
  CONFIG_INT_HELP(CONFIG_USE_RTP_OVER_RTSP, "UseRtpOverRtsp", 0, "Use RTP in TCP session (for firewalls)"),
  CONFIG_INT(CONFIG_SEND_RTCP_IN_RTP_OVER_RTSP, "SendRtcpInRtpOverRtsp", 0), 
  CONFIG_STRING(CONFIG_PREV_DIRECTORY, "PrevDirectory", NULL),
  CONFIG_INT(CONFIG_RTP_DEBUG, "RtpDebug", LOG_ALERT),
  CONFIG_INT(CONFIG_PLAY_AUDIO, "PlayAudio", 1),
  CONFIG_INT(CONFIG_PLAY_VIDEO, "PlayVideo", 1),
  CONFIG_INT(CONFIG_PLAY_TEXT, "PlayText", 1),
  CONFIG_INT(CONFIG_RTP_BUFFER_TIME_MSEC, "RtpBufferTimeMsec", 2000),
  CONFIG_INT_HELP(CONFIG_MPEG2T_PAM_WAIT_SECS, "Mpeg2tPamWaitSecs", 30, "Time to wait for Program Map (seconds)"),
  CONFIG_INT(CONFIG_LIMIT_AUDIO_SDL_BUFFER, "LimitAudioSdlBuffer", 0),
  CONFIG_INT(CONFIG_MPEG2T_DEBUG, "Mpeg2tDebug", LOG_ALERT),
  CONFIG_INT(CONFIG_ASPECT_RATIO, "AspectRatio", 0),
  CONFIG_BOOL(CONFIG_FULL_SCREEN, "FullScreen", false),
  CONFIG_STRING_HELP(CONFIG_MULTICAST_RX_IF, "MulticastIf", NULL, "Physical interface to receive multicast"),
  CONFIG_INT_HELP(CONFIG_RX_SOCKET_SIZE, "RxSocketSize", 0, "Default receive buffer socket size"),
  CONFIG_STRING(CONFIG_MULTICAST_SRC, "MulticastSrc", NULL),
  CONFIG_STRING(CONFIG_LOG_FILE, "LogFile", NULL),
  CONFIG_BOOL_HELP(CONFIG_DISPLAY_DEBUG, "DisplayDebug", false, "In gmp4player, display status information every second"),
  CONFIG_INT(CONFIG_MPEG2PS_DEBUG, "Mpeg2psDebug", LOG_ALERT),
  CONFIG_STRING_HELP(CONFIG_URL_EXEC, "UrlExec", NULL, 
		     "Enter full path to browser launch - default /usr/bin/firefox/firefox"),
  CONFIG_BOOL(CONFIG_SHORT_VIDEO_RENDER, "ShortVideoRender", false),
  CONFIG_STRING_HELP(CONFIG_RTSP_PROXY_ADDR, "RtspProxyAddr", NULL, 
		     "RTSP proxy address"),
  CONFIG_INT(CONFIG_RTSP_PROXY_PORT, "RtspProxyPort", 0),
  CONFIG_STRING(CONFIG_OPENIPMPDRM_XMLFILE, "drmXML", NULL),
  CONFIG_STRING(CONFIG_OPENIPMPDRM_SENSITIVE, "drmInfo", NULL),
};
Exemplo n.º 13
0
#include <typeapi.h>
#include <mode.hpp>
#include <vopses.hpp>
#include <bitstrm.hpp>
#include <tps_enhcbuf.hpp>
#include <enhcbufdec.hpp>
#include <vopsedec.hpp>
#include "mpeg4.h"

#include <mp4v2/mp4.h>
#include <mp4av/mp4av.h>

#define iso_message (iso->m_vft->log_msg)
static const char *mp4iso = "mp4iso";
static SConfigVariable MyConfigVariables[] = {
  CONFIG_BOOL(CONFIG_USE_MPEG4_ISO_ONLY, "Mpeg4IsoOnly", false),
};

// Convert a hex character to it's decimal value.
static uint8_t tohex (char a)
{ 
  if (isdigit(a))
    return (a - '0');
  return (tolower(a) - 'a' + 10);
}

static double calculate_aspect_ratio (iso_decode_t *iso)
{
  double ret_val;
  int aspect_ratio_h;
  int aspect_ratio_w;
Exemplo n.º 14
0
    void GLTFEffect::evaluate(void *context) {
        GLTFAsset* asset = (GLTFAsset*)context;
        bool bUseKhrMaterialsCommon = CONFIG_BOOL(asset, "useKhrMaterialsCommon");
        shared_ptr <JSONObject> techniqueGenerator = this->getTechniqueGenerator();

        if (!bUseKhrMaterialsCommon)
        {
            std::string techniqueID = GLTF::getReferenceTechniqueID(techniqueGenerator, asset);

            this->setString(kTechnique, techniqueID);
            shared_ptr<JSONObject> outputs(new JSONObject());
            shared_ptr <JSONObject> values = this->getValues();
            std::vector <std::string> keys = values->getAllKeys();
            for (size_t i = 0; i < keys.size(); i++) {
                shared_ptr <JSONObject> parameter = static_pointer_cast <JSONObject> (values->getValue(keys[i]));
                shared_ptr <JSONObject> parameterValue = static_pointer_cast <JSONObject> (parameter->getValue(kValue));
                shared_ptr<JSONObject> output(new JSONObject());
                if (parameterValue) {
                    outputs->setValue(keys[i], parameterValue);
                }
            }
            this->setValue(kValues, outputs);
        }
        else
        {
            //
            // Export KHR_materials_common extension
            //
            shared_ptr <GLTF::JSONObject> extensions = this->createObjectIfNeeded("extensions");
            shared_ptr <GLTF::JSONObject> khrMaterialsCommon(new GLTF::JSONObject());

            shared_ptr<JSONObject> techniqueExtras = techniqueGenerator->getObject("techniqueExtras");
            bool doubleSided = techniqueExtras->getBool(kDoubleSided);

            std::string lightingModel = techniqueGenerator->getString("lightingModel");
            std::transform(lightingModel.begin(), lightingModel.end(), lightingModel.begin(), ::toupper);
            khrMaterialsCommon->setString(kTechnique, lightingModel);
            shared_ptr<JSONObject> materialsCommonValues(new JSONObject());

            if (doubleSided)
            {
                materialsCommonValues->setBool("doubleSided", doubleSided);
            }
            AddMaterialsCommonValue(materialsCommonValues, _khrMaterialsCommonValues, "emission");
            AddMaterialsCommonValue(materialsCommonValues, _khrMaterialsCommonValues, "transparency");

            if (lightingModel != "CONSTANT")
            {
                AddMaterialsCommonValue(materialsCommonValues, _khrMaterialsCommonValues, "ambient");
                AddMaterialsCommonValue(materialsCommonValues, _khrMaterialsCommonValues, "diffuse");

                if (lightingModel != "LAMBERT")
                {
                    AddMaterialsCommonValue(materialsCommonValues, _khrMaterialsCommonValues, "specular");
                    AddMaterialsCommonValue(materialsCommonValues, _khrMaterialsCommonValues, "shininess");
                }
            }

            khrMaterialsCommon->setValue(kValues, materialsCommonValues);

            extensions->setValue("KHR_materials_common", khrMaterialsCommon);
        }
    }
Exemplo n.º 15
0
 *		Dave Mackie		[email protected]
 */

#include "mp4live.h"
#ifdef HAVE_FFMPEG
#include "video_ffmpeg.h"
#include "mp4av.h"
#include "ffmpeg_if.h"
//#include "encoder-h263.h"
//#include <dsputil.h>
//#include <mpegvideo.h>

#ifdef HAVE_AVCODECCONTEXT_TIME_BASE
static config_index_t CFG_FFMPEG_USE_STRICT;
static SConfigVariable ffmpegEncoderVariables[] = {
  CONFIG_BOOL(CFG_FFMPEG_USE_STRICT, "FfmpegUseStrictStdCompliance", false),
};

#endif
GUI_BOOL(gui_bframe, CFG_VIDEO_USE_B_FRAMES, "Use B Frames");
GUI_INT_RANGE(gui_bframenum, CFG_VIDEO_NUM_OF_B_FRAMES, "Number of B frames", 1, 4);
DECLARE_TABLE(ffmpeg_mpeg4_gui_options) = {
  TABLE_GUI(gui_bframe),
  TABLE_GUI(gui_bframenum),
};
DECLARE_TABLE_FUNC(ffmpeg_mpeg4_gui_options);

void AddFfmpegConfigVariables (CVideoProfile *pConfig)
{
#ifdef HAVE_AVCODECCONTEXT_TIME_BASE
  pConfig->AddConfigVariables(ffmpegEncoderVariables,
Exemplo n.º 16
0
void XMPPFrontend::init(Component *transport, Swift::EventLoop *loop, Swift::NetworkFactories *factories, Config *config, Transport::UserRegistry *userRegistry) {
	m_transport = transport;
	m_component = NULL;
	m_server = NULL;
	m_rawXML = false;
	m_config = transport->getConfig();
	m_jid = Swift::JID(CONFIG_STRING(m_config, "service.jid"));

	m_config->onBackendConfigUpdated.connect(boost::bind(&XMPPFrontend::handleBackendConfigChanged, this));

	if (CONFIG_BOOL(m_config, "service.server_mode")) {
		LOG4CXX_INFO(logger, "Creating component in server mode on port " << CONFIG_INT(m_config, "service.port"));
		m_server = new Swift::Server(loop, factories, userRegistry, m_jid, CONFIG_STRING(m_config, "service.server"), CONFIG_INT(m_config, "service.port"));
		if (!CONFIG_STRING(m_config, "service.cert").empty()) {
#ifndef _WIN32
#ifndef __APPLE__
//TODO: fix
			LOG4CXX_INFO(logger, "Using PKCS#12 certificate " << CONFIG_STRING(m_config, "service.cert"));
			LOG4CXX_INFO(logger, "SSLv23_server_method used.");
			TLSServerContextFactory *f = new OpenSSLServerContextFactory();
			CertificateWithKey::ref certificate = boost::make_shared<PKCS12Certificate>(CONFIG_STRING(m_config, "service.cert"), createSafeByteArray(CONFIG_STRING(m_config, "service.cert_password")));
			m_server->addTLSEncryption(f, certificate);
#endif
#endif
			
		}
		else {
			LOG4CXX_WARN(logger, "No PKCS#12 certificate used. TLS is disabled.");
		}
// 		m_server->start();
		m_stanzaChannel = m_server->getStanzaChannel();
		m_iqRouter = m_server->getIQRouter();

		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<StorageParser>("private", "jabber:iq:private"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::AttentionParser>("attention", "urn:xmpp:attention:0"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::XHTMLIMParser>("html", "http://jabber.org/protocol/xhtml-im"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Transport::BlockParser>("block", "urn:xmpp:block:0"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::InvisibleParser>("invisible", "urn:xmpp:invisible:0"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::StatsParser>("query", "http://jabber.org/protocol/stats"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::GatewayPayloadParser>("query", "jabber:iq:gateway"));
		m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::MUCPayloadParser>("x", "http://jabber.org/protocol/muc"));

		m_server->addPayloadSerializer(new Swift::AttentionSerializer());
		m_server->addPayloadSerializer(new Swift::XHTMLIMSerializer());
		m_server->addPayloadSerializer(new Transport::BlockSerializer());
		m_server->addPayloadSerializer(new Swift::InvisibleSerializer());
		m_server->addPayloadSerializer(new Swift::StatsSerializer());
		m_server->addPayloadSerializer(new Swift::SpectrumErrorSerializer());
		m_server->addPayloadSerializer(new Swift::GatewayPayloadSerializer());

		m_server->onDataRead.connect(boost::bind(&XMPPFrontend::handleDataRead, this, _1));
		m_server->onDataWritten.connect(boost::bind(&XMPPFrontend::handleDataWritten, this, _1));
	}
	else {
		LOG4CXX_INFO(logger, "Creating component in gateway mode");
#if HAVE_SWIFTEN_3
		m_component = new Swift::Component(m_jid, CONFIG_STRING(m_config, "service.password"), factories);
#else
		m_component = new Swift::Component(loop, factories, m_jid, CONFIG_STRING(m_config, "service.password"));
#endif
		m_component->setSoftwareVersion("Spectrum", SPECTRUM_VERSION);
		m_component->onConnected.connect(bind(&XMPPFrontend::handleConnected, this));
		m_component->onError.connect(boost::bind(&XMPPFrontend::handleConnectionError, this, _1));
		m_component->onDataRead.connect(boost::bind(&XMPPFrontend::handleDataRead, this, _1));
		m_component->onDataWritten.connect(boost::bind(&XMPPFrontend::handleDataWritten, this, _1));

		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<StorageParser>("private", "jabber:iq:private"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::AttentionParser>("attention", "urn:xmpp:attention:0"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::XHTMLIMParser>("html", "http://jabber.org/protocol/xhtml-im"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Transport::BlockParser>("block", "urn:xmpp:block:0"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::InvisibleParser>("invisible", "urn:xmpp:invisible:0"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::StatsParser>("query", "http://jabber.org/protocol/stats"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::GatewayPayloadParser>("query", "jabber:iq:gateway"));
		m_component->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::MUCPayloadParser>("x", "http://jabber.org/protocol/muc"));

		m_component->addPayloadSerializer(new Swift::AttentionSerializer());
		m_component->addPayloadSerializer(new Swift::XHTMLIMSerializer());
		m_component->addPayloadSerializer(new Transport::BlockSerializer());
		m_component->addPayloadSerializer(new Swift::InvisibleSerializer());
		m_component->addPayloadSerializer(new Swift::StatsSerializer());
		m_component->addPayloadSerializer(new Swift::SpectrumErrorSerializer());
		m_component->addPayloadSerializer(new Swift::GatewayPayloadSerializer());

		m_stanzaChannel = m_component->getStanzaChannel();
		m_iqRouter = m_component->getIQRouter();
	}

	m_capsMemoryStorage = new CapsMemoryStorage();
#if HAVE_SWIFTEN_3
	m_capsManager = new CapsManager(m_capsMemoryStorage, m_stanzaChannel, m_iqRouter, factories->getCryptoProvider());
#else
	m_capsManager = new CapsManager(m_capsMemoryStorage, m_stanzaChannel, m_iqRouter);
#endif
	m_entityCapsManager = new EntityCapsManager(m_capsManager, m_stanzaChannel);
	m_entityCapsManager->onCapsChanged.connect(boost::bind(&XMPPFrontend::handleCapsChanged, this, _1));

	m_stanzaChannel->onPresenceReceived.connect(bind(&XMPPFrontend::handleGeneralPresence, this, _1));
	m_stanzaChannel->onMessageReceived.connect(bind(&XMPPFrontend::handleMessage, this, _1));

	m_discoItemsResponder = new DiscoItemsResponder(transport);
	m_discoItemsResponder->start();
}