Ejemplo n.º 1
0
QString JabberTransport::legacyId( const XMPP::Jid & jid )
{
	if(jid.node().isEmpty())
		return QString();
	QString node = jid.node();
	return node.replace("%","@");
}
Ejemplo n.º 2
0
void KMessageJabber::slotGroupChatPresence(const XMPP::Jid& jid, const XMPP::Status& status)
{
  kDebug() << jid.full() << status.status();
  if (jid.full() == mPeerJid && !status.isAvailable())
  {
    emit connectionBroken();
  }
}
Ejemplo n.º 3
0
/**
 * Process unregister actions with database and close the legacy connection.
 */
void GatewayTask::processUnregister(const XMPP::Jid& user)
{
    ICQ::Session *conn = d->jidIcqTable.value(user.bare());
    if ( conn ) {
        d->icqJidTable.remove(conn);
        d->jidIcqTable.remove(user.bare());
        d->jidResources.remove(user.bare());
        delete conn;
    }
    UserManager::instance()->del(user);
}
Ejemplo n.º 4
0
void GatewayTask::processVCardRequest(const XMPP::Jid& user, const QString& uin, const QString& requestID)
{
    ICQ::Session *session = d->jidIcqTable.value( user.bare() );
    if ( !session ) {
        emit incomingVCard(user, uin, requestID, XMPP::vCard() );
        return;
    }
    QString key = user.bare()+"-"+uin;
    Private::vCardRequestInfo info;
    info.requestID = requestID;
    info.resource = user.resource();
    d->vCardRequests.insert(key, info);
    session->requestShortUserDetails(uin);
}
Ejemplo n.º 5
0
void JabberAvatarPepFetcher::avatarMetadataQueryFinished(const XMPP::Jid &jid, const QString &node, const XMPP::PubSubItem &item)
{
	if (jid.bare() != MyContact.id() || node != XMLNS_AVATAR_METADATA)
		return; // not our data :(

	AvatarId = item.id();
	if (AvatarId == "current")
	{
		Avatar contactAvatar = AvatarManager::instance()->byContact(MyContact, ActionCreateAndAdd);
		contactAvatar.setLastUpdated(QDateTime::currentDateTime());
		contactAvatar.setNextUpdate(QDateTime::fromTime_t(QDateTime::currentDateTime().toTime_t() + 7200));
		contactAvatar.setPixmap(QPixmap());

		done();
		deleteLater();
		return;
	}

	JabberProtocol *jabberProtocol = qobject_cast<JabberProtocol *>(MyContact.contactAccount().protocolHandler());
	if (jabberProtocol)
	{
		disconnect(jabberProtocol->client()->pepManager(), SIGNAL(itemPublished(XMPP::Jid,QString,XMPP::PubSubItem)), this, SLOT(avatarMetadataQueryFinished(XMPP::Jid,QString,XMPP::PubSubItem)));
		connect(jabberProtocol->client()->pepManager(), SIGNAL(itemPublished(XMPP::Jid,QString,XMPP::PubSubItem)), this, SLOT(avatarDataQueryFinished(XMPP::Jid,QString,XMPP::PubSubItem)));
		jabberProtocol->client()->pepManager()->get(MyContact.id(), XMLNS_AVATAR_DATA, item.id());
	}
}
Ejemplo n.º 6
0
void JabberAvatarPepFetcher::avatarDataQueryFinished(const XMPP::Jid &jid, const QString &node, const XMPP::PubSubItem &item)
{
	if (jid.bare() != MyContact.id() || node != XMLNS_AVATAR_DATA || item.id() != AvatarId)
		return; // not our data :(

	JabberProtocol *jabberProtocol = qobject_cast<JabberProtocol *>(MyContact.contactAccount().protocolHandler());
	if (jabberProtocol)
		disconnect(jabberProtocol->client()->pepManager(), SIGNAL(itemPublished(XMPP::Jid,QString,XMPP::PubSubItem)), this, SLOT(avatarDataQueryFinished(XMPP::Jid,QString,XMPP::PubSubItem)));

	XMPP::Base64 base64;
	QByteArray imageData = base64.decode(item.payload().text());

	Avatar contactAvatar = AvatarManager::instance()->byContact(MyContact, ActionCreateAndAdd);
	contactAvatar.setLastUpdated(QDateTime::currentDateTime());
	contactAvatar.setNextUpdate(QDateTime::fromTime_t(QDateTime::currentDateTime().toTime_t() + 7200));

	QPixmap pixmap;

	if (!imageData.isEmpty())
		pixmap.loadFromData(imageData);

	contactAvatar.setPixmap(pixmap);

	done();
	deleteLater();
}
Ejemplo n.º 7
0
void GatewayTask::processUserStatusRequest(const XMPP::Jid& user)
{
    ICQ::Session *session = d->jidIcqTable.value( user.bare() );
    if ( !session ) {
        return;
    }
    if ( session->onlineStatus() == ICQ::Session::Offline ) {
        emit offlineNotifyFor(user);
    } else {
        int show;
        switch ( session->onlineStatus() ) {
            case ICQ::Session::Away:
                show = XMPP::Presence::Away;
                break;
            case ICQ::Session::NotAvailable:
                show = XMPP::Presence::NotAvailable;
                break;
            case ICQ::Session::FreeForChat:
                show = XMPP::Presence::Chat;
                break;
            case ICQ::Session::DoNotDisturb:
                show = XMPP::Presence::DoNotDisturb;
                break;
            default:
                show = XMPP::Presence::None;
                break;
        }
        emit onlineNotifyFor(user, show);
    }
}
Ejemplo n.º 8
0
/**
 * Sends @a message from jabber-user @a user to ICQ user with specified @a uin
 */
void GatewayTask::processSendMessage(const XMPP::Jid& user, const QString& uin, const QString& message)
{
    ICQ::Session *conn = d->jidIcqTable.value( user.bare() );
    if ( !conn ) {
        return;
    }
    conn->sendMessage(uin, message);
}
Ejemplo n.º 9
0
void GatewayTask::processAuthDeny(const XMPP::Jid& user, const QString& uin)
{
    ICQ::Session *conn = d->jidIcqTable.value( user.bare() );
    if ( !conn ) {
        return;
    }
    conn->authDeny(uin);
}
Ejemplo n.º 10
0
/**
 * This slot is triggered when jabber user @a user requests to remove a contact @a uin from server.
 */
void GatewayTask::processUnsubscribeRequest(const XMPP::Jid& user, const QString& uin)
{
    ICQ::Session *conn = d->jidIcqTable.value( user.bare() );
    if ( !conn ) {
        return;
    }
    conn->contactDel(uin);
}
Ejemplo n.º 11
0
YaProfile::YaProfile(PsiAccount* account, const XMPP::Jid& jid)
	: QObject(account)
	, account_(account)
	, jid_(jid.bare())
	, lastMessage_(QDateTime::currentDateTime().addDays(-1))
{
	init();
}
Ejemplo n.º 12
0
/**
 * This slot is triggered when jabber user @a user goes offline.
 */
void GatewayTask::processUserOffline(const XMPP::Jid& user)
{
    ICQ::Session *conn = d->jidIcqTable.value( user.bare() );
    emit offlineNotifyFor(user);
    if ( !conn ) {
        return;
    }

    QStringListIterator ci(conn->contactList());
    while ( ci.hasNext() ) {
        emit contactOffline( user, ci.next() );
    }

    d->jidIcqTable.remove( user.bare() );
    d->icqJidTable.remove(conn);
    d->jidResources.remove( user.bare() );
    conn->disconnect();
    conn->deleteLater();
}
HistoryDlg::HistoryDlg(const XMPP::Jid& j, PsiAccount* pa)
: pa_(pa), jidFull_(j), from_(0), count_(30)
{
	setupUi(this);
	setModal(false);
	setAttribute(Qt::WA_DeleteOnClose);
	pa_->dialogRegister(this, jidFull_);
	setWindowTitle(tr("History for ") + j.full());
#ifndef Q_WS_MAC
	setWindowIcon(IconsetFactory::icon("psi/history").icon());
#endif


	DateTree->setHeaderLabel(tr("Date"));
	DateTree->setSortingEnabled(true);
	DateTree->setColumnHidden(1,true);
	connect(DateTree, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(doDateContextMenu(const QPoint &)));

	EventsTree->setColumnCount(4);
	QStringList headers;
	headers << tr("Type") << tr("Time") << tr("Origin") << tr("Text");
	EventsTree->setHeaderLabels(headers);
	EventsTree->sortItems(1,Qt::AscendingOrder);
	EventsTree->setSortingEnabled(true);
	EventsTree->setWordWrap(true);
	EventsTree->hideColumn(2);

	connect(EventsTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), SLOT(actionOpenEvent(QTreeWidgetItem *, int)));
	connect(EventsTree, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(doEventContextMenu(const QPoint &)));
	connect(tb_previousMonth, SIGNAL(clicked()), SLOT(doPrev()));
	connect(tb_latest, SIGNAL(clicked()), SLOT(doLatest()));
	connect(tb_nextMonth, SIGNAL(clicked()), SLOT(doNext()));
	connect(pb_find, SIGNAL(clicked()), SLOT(doFind()));
	connect(pb_export, SIGNAL(clicked()), SLOT(doExport()));
	connect(pb_close, SIGNAL(clicked()), SLOT(close()));

	jid_ = j.bare();
	doLatest();

	X11WM_CLASS("history");
}
ArchiveDlg::ArchiveDlg(const XMPP::Jid &jid, PsiAccount *pa)
{
	max = 30;
	page_ = 0;
	setupUi(this);
	tw_log->setColumnCount(3);
	QStringList headers;
	headers << tr("Time") << tr("") << tr("Message");
	tw_log->setHeaderLabels(headers);
	setAttribute(Qt::WA_DeleteOnClose);
	setWindowTitle(tr("Archive for ") + jid.full());
#ifndef Q_WS_MAC
	setWindowIcon(IconsetFactory::icon("psi/history").icon());
#endif

	gct_ = NULL;

	pa_ = pa;
	jid_ = jid;

	last_ =  QDateTime::currentDateTime();

	connect(pb_close, SIGNAL(clicked()), this, SLOT(hide()));

	connect(calendar, SIGNAL(selectionChanged()), this, SLOT(dateSelected()));
	connect(calendar, SIGNAL(currentPageChanged(int, int)), this, SLOT(dateChanged(int, int)));

	connect(lw_conversations, SIGNAL(itemSelectionChanged()), this, SLOT(collectionSelected()));
	connect(lw_conversations, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(doCollectionContextMenu(const QPoint&)));
	lw_conversations->

	connect(tb_prevPage, SIGNAL(clicked()), this, SLOT(prevPage()));	connect(tb_nextPage, SIGNAL(clicked()), this, SLOT(nextPage()));

	gclt_ = new GetCollectionListTask(pa->client()->rootTask());
	connect(gclt_, SIGNAL(busy()), this, SLOT(busy()));
	connect(gclt_, SIGNAL(done()), this, SLOT(collectionListRetrieved()));
	connect(gclt_, SIGNAL(error()), this, SLOT(error()));

	gct_ = new GetCollectionTask(pa_->client()->rootTask());
	connect(gct_, SIGNAL(busy()), this, SLOT(busy()));
	connect(gct_, SIGNAL(done(int)), this, SLOT(collectionRetrieved(int)));
	connect(gct_, SIGNAL(msg(int, bool, const QString&)), this, SLOT(collectionMsg(int, bool, const QString&)));
	connect(gct_, SIGNAL(error()), this, SLOT(error()));
	
	QDate m(last_.date().year(), last_.date().month(), 1);
	gclt_->get(jid, m, 50);
//	X11WM_CLASS("history");
}
Ejemplo n.º 15
0
/**
 * Process legacy roster request from jabber user @a user.
 */
void GatewayTask::processCmd_RosterRequest(const XMPP::Jid& user)
{
    ICQ::Session *session = d->jidIcqTable.value( user.bare() );
    if ( !session ) {
        return;
    }

    QStringList contacts = session->contactList();
    QStringListIterator i(contacts);
    QList<XMPP::RosterXItem> items;
    while ( i.hasNext() ) {
        QString uin = i.next();
        QString name = session->contactName(uin);
        XMPP::RosterXItem item(uin, XMPP::RosterXItem::Add, name);
        items << item;
    }
    emit rosterAdd(user, items);
}
Ejemplo n.º 16
0
void GatewayTask::processRegister(const XMPP::Jid& user, const QString& uin, const QString& password)
{
    if ( d->jidIcqTable.contains(user.bare()) ) {
        ICQ::Session *conn = d->jidIcqTable.value(user.bare());
        d->jidIcqTable.remove(user.bare());
        d->jidResources.remove(user.bare());
        d->icqJidTable.remove(conn);

        delete conn;
    }

    UserManager::instance()->add(user.bare(), uin, password);
    UserManager::instance()->setOption(user.bare(), "first_login", QVariant(true));
    emit gatewayMessage( user, tr("You have been successfully registered") );
}
Ejemplo n.º 17
0
AddUserDlg::AddUserDlg(const XMPP::Jid &jid, const QString &nick, const QString &group, const QStringList &groups, PsiAccount *pa)
{
	init(groups, pa);

	le_jid->setText(jid.full());	// TODO: do we want to encourage adding jids with resource?
	le_nick->setText(nick);

	QStringList suggestedGroups = groups.filter(group, Qt::CaseInsensitive);
	if (suggestedGroups.size() > 0) {
		cb_group->lineEdit()->setText(suggestedGroups[0]);
	} else {
		cb_group->lineEdit()->setText(group);
	}

	QSize s(te_info->width(), w_serviceTranslation->sizeHint().height());
	w_serviceTranslation->hide();
	w_serviceTranslation->setEnabled(false);
	te_info->hide();

	resize(size() - s);
}
Ejemplo n.º 18
0
void JabberClient::connect(const XMPP::Jid &jid, const QString &password, bool auth)
{
	/*
	 * Close any existing connection.
	 */
	if (jabberClient)
		jabberClient->close();

	MyJid = jid;
	Password = password;

	/*
	 * Return an error if we should force TLS but it's not available.
	 */
	if ((forceTLS() || useSSL() || probeSSL()) && !QCA::isSupported("tls"))
	{
		qDebug("no TLS");
		// no SSL support, at the connecting stage this means the problem is client-side
		QMessageBox *m = new QMessageBox(QMessageBox::Critical, tr("Jabber SSL Error"), tr("SSL support could not be initialized for account %1. This is most likely because the QCA TLS plugin is not installed on your system.").arg(jid.bare()), QMessageBox::Ok, 0, Qt::Popup);
		m->setModal(true);
		m->show();
		return;
	}

	/*
	 * Instantiate connector, responsible for dealing with the socket.
	 * This class uses KDE's socket code, which in turn makes use of
	 * the global proxy settings.
	 */
	JabberClientConnector = new XMPP::AdvancedConnector;

	JabberClientConnector->setOptSSL(useSSL());

	if (useXMPP09())
	{
		if (overrideHost())
			JabberClientConnector->setOptHostPort(Server, Port);

		JabberClientConnector->setOptProbe(probeSSL());

	}

	/*
	 * Setup authentication layer
	 */
	if ((forceTLS() || useSSL()) && QCA::isSupported("tls"))
	{
		JabberTLS = new QCA::TLS;
		JabberTLS->setTrustedCertificates(CertificateHelpers::allCertificates(CertificateHelpers::getCertificateStoreDirs()));
		JabberTLSHandler = new QCATLSHandler(JabberTLS);
		JabberTLSHandler->setXMPPCertCheck(true);

		QObject::connect(JabberTLSHandler, SIGNAL(tlsHandshaken()), SLOT(slotTLSHandshaken()));
	}

	/*
	 * Instantiate client stream which handles the network communication by referring
	 * to a connector (proxying etc.) and a TLS handler (security layer)
	 */
	JabberClientStream = new XMPP::ClientStream(JabberClientConnector, JabberTLSHandler);

	{
		using namespace XMPP;
		QObject::connect(JabberClientStream, SIGNAL(needAuthParams(bool, bool, bool)),
				   this, SLOT(slotCSNeedAuthParams(bool, bool, bool)));
		QObject::connect(JabberClientStream, SIGNAL(authenticated()),
				   this, SLOT(slotCSAuthenticated()));
		QObject::connect(JabberClientStream, SIGNAL(connectionClosed()),
				   this, SLOT(slotCSDisconnected()));
		QObject::connect(JabberClientStream, SIGNAL(delayedCloseFinished()),
				   this, SLOT(slotCSDisconnected()));
		QObject::connect(JabberClientStream, SIGNAL(warning(int)),
				   this, SLOT(slotCSWarning(int)));
		QObject::connect(JabberClientStream, SIGNAL(error(int)),
				   this, SLOT(slotCSError(int)));
	}

	JabberClientStream->setOldOnly(useXMPP09());

	/*
	 * Initiate anti-idle timer (will be triggered every 55 seconds).
	 */
	JabberClientStream->setNoopTime(55000);

	/*
	 * Allow plaintext password authentication or not?
	 */
	JabberClientStream->setAllowPlain(allowPlainTextPassword());

	/*
	 * Setup client layer.
	 */
	jabberClient = new XMPP::Client(this);

	/*
	 * Setup privacy manager
	 */
	///privacyManager = new PrivacyManager ( rootTask() );

	/*
	 * Enable file transfer (IP and server will be set after connection
	 * has been established.
	 */
	if (fileTransfersEnabled())
	{
		jabberClient->setFileTransferEnabled(true);
		{
			using namespace XMPP;
			QObject::connect(jabberClient->fileTransferManager(), SIGNAL(incomingReady()),
					   this, SLOT(slotIncomingFileTransfer()));
		}
	}

	/*if (jingleEnabled())
	{*/

#ifdef JINGLE_SUPPORT
		jabberClient->setJingleEnabled(true);

		{
			using namespace XMPP;
			QObject::connect ( jabberClient->jingleSessionManager(), SIGNAL ( incomingSession() ),
					   this, SLOT ( slotIncomingJingleSession () ) );
		}
#else
		jabberClient->setJingleEnabled(false);
#endif
	/*}*/

	/* This should only be done here to connect the signals, otherwise it is a
	 * bad idea.
	 */
	{
		using namespace XMPP;
		QObject::connect(jabberClient, SIGNAL(subscription(const Jid &, const QString &, const QString &)),
				   this, SLOT(slotSubscription(const Jid &, const QString &)));
		QObject::connect(jabberClient, SIGNAL(rosterRequestFinished(bool, int, const QString &)),
				   this, SLOT(slotRosterRequestFinished(bool, int, const QString &)));
		QObject::connect(jabberClient, SIGNAL(rosterItemAdded(const RosterItem &)),
				   this, SLOT(slotNewContact(const RosterItem &)));
		QObject::connect(jabberClient, SIGNAL(rosterItemUpdated(const RosterItem &)),
				   this, SLOT(slotContactUpdated(const RosterItem &)));
		QObject::connect(jabberClient, SIGNAL(rosterItemRemoved(const RosterItem &)),
				   this, SLOT(slotContactDeleted(const RosterItem &)));
		QObject::connect(jabberClient, SIGNAL(resourceAvailable(const Jid &, const Resource &)),
				   this, SLOT(slotResourceAvailable(const Jid &, const Resource &)));
		QObject::connect(jabberClient, SIGNAL(resourceUnavailable(const Jid &, const Resource &)),
				   this, SLOT(slotResourceUnavailable(const Jid &, const Resource &)));
		QObject::connect(jabberClient, SIGNAL(messageReceived(const Message &)),
				   this, SLOT(slotReceivedMessage(const Message &)));
		QObject::connect(jabberClient, SIGNAL(groupChatJoined(const Jid &)),
				   this, SLOT(slotGroupChatJoined(const Jid &)));
		QObject::connect(jabberClient, SIGNAL(groupChatLeft(const Jid &)),
				   this, SLOT(slotGroupChatLeft(const Jid &)));
		QObject::connect(jabberClient, SIGNAL(groupChatPresence(const Jid &, const Status &)),
				   this, SLOT(slotGroupChatPresence(const Jid &, const Status &)));
		QObject::connect(jabberClient, SIGNAL(groupChatError(const Jid &, int, const QString &)),
				   this, SLOT(slotGroupChatError(const Jid &, int, const QString &)));
		//QObject::connect(jabberClient, SIGNAL(debugText(const QString &)),
		//		   this, SLOT(slotPsiDebug(const QString &)));
		QObject::connect(jabberClient, SIGNAL(xmlIncoming(const QString&)),
				   this, SLOT(slotIncomingXML(const QString &)));
		QObject::connect(jabberClient, SIGNAL(xmlOutgoing(const QString&)),
				   this, SLOT(slotOutgoingXML(const QString &)));
	}

	jabberClient->setClientName(clientName());
	jabberClient->setClientVersion(clientVersion());
	jabberClient->setOSName(osName());

	// Set caps information
	jabberClient->setCapsNode(capsNode());
	jabberClient->setCapsVersion(capsVersion());

	// Set Disco Identity
	//jabberClient->setIdentity( discoIdentity());


	DiscoItem::Identity identity;
	identity.category = "client";
	identity.type = "pc";
	identity.name = "Kadu";
	jabberClient->setIdentity(identity);

	QStringList features;
//	features << "http://jabber.org/protocol/commands";
	features << "http://jabber.org/protocol/rosterx";
//	features << "http://jabber.org/protocol/muc";
	features << "jabber:x:data";
	jabberClient->setFeatures(Features(features));

	jabberClient->setTimeZone(timeZoneName(), timeZoneOffset());

	jabberClient->connectToServer(JabberClientStream, jid, auth);
}
Ejemplo n.º 19
0
void JT_JingleRtp::request(const XMPP::Jid &to, const JingleRtpEnvelope &envelope)
{
    to_ = to;
    iq_ = createIQ(doc(), "set", to.full(), id());
    QDomElement query = doc()->createElement("jingle");
    query.setAttribute("xmlns", "urn:xmpp:jingle:1");
    query.setAttribute("action", envelope.action);
    if(!envelope.initiator.isEmpty())
        query.setAttribute("initiator", envelope.initiator);
    if(!envelope.responder.isEmpty())
        query.setAttribute("responder", envelope.responder);
    query.setAttribute("sid", envelope.sid);

    if(envelope.action == "session-terminate")
    {
        // for session terminate, there is no content list, just
        //   a reason for termination
        query.appendChild(reasonToElement(doc(), envelope.reason));
    }
    else
    {
        foreach(const JingleRtpContent &c, envelope.contentList)
        {
            QDomElement content = doc()->createElement("content");
            content.setAttribute("creator", c.creator);
            if(!c.disposition.isEmpty())
                content.setAttribute("disposition", c.disposition);
            content.setAttribute("name", c.name);
            if(!c.senders.isEmpty())
                content.setAttribute("senders", c.senders);

            if(!c.desc.media.isEmpty())
            {
                // TODO: ssrc, bitrate, crypto
                QDomElement description = doc()->createElement("description");
                description.setAttribute("xmlns", "urn:xmpp:jingle:apps:rtp:1");
                description.setAttribute("media", c.desc.media);
                foreach(const JingleRtpPayloadType &pt, c.desc.payloadTypes)
                {
                    QDomElement p = payloadTypeToElement(doc(), pt);
                    if(!p.isNull())
                        description.appendChild(p);
                }
                content.appendChild(description);
            }

            if(!c.trans.user.isEmpty())
            {
                QDomElement transport = doc()->createElement("transport");
                transport.setAttribute("xmlns", "urn:xmpp:jingle:transports:ice-udp:1");
                transport.setAttribute("ufrag", c.trans.user);
                transport.setAttribute("pwd", c.trans.pass);
                foreach(const XMPP::Ice176::Candidate &ic, c.trans.candidates)
                {
                    QDomElement e = candidateToElement(doc(), ic);
                    if(!e.isNull())
                        transport.appendChild(e);
                }
                content.appendChild(transport);
            }

            query.appendChild(content);
        }
Ejemplo n.º 20
0
void GatewayTask::processUserOnline(const XMPP::Jid& user, int showStatus)
{
    bool first_login = UserManager::instance()->getOption(user.bare(), "first_login").toBool();

    if ( d->icqHost.isEmpty() || !d->icqPort ) {
        qCritical("[GT] processLogin: icq host and/or port values are not set. Aborting...");
        return;
    }
    ICQ::Session::OnlineStatus icqStatus = xmmpToIcqStatus(XMPP::Presence::Show(showStatus));

    if ( d->jidIcqTable.contains( user.bare() ) ) {
        ICQ::Session *conn = d->jidIcqTable.value( user.bare() );
        conn->setOnlineStatus(icqStatus);
        d->jidResources.insert(user.bare(), user);
        return;
    }

    if ( UserManager::instance()->isRegistered(user.bare()) ) {
        QString uin = UserManager::instance()->getUin(user.bare());
        QString password = UserManager::instance()->getPassword(user.bare());

        ICQ::Session *conn = new ICQ::Session(this);
        conn->setUin(uin);
        conn->setPassword(password);
        conn->setServerHost(d->icqHost);
        conn->setServerPort(d->icqPort);
        conn->setOnlineStatus(ICQ::Session::Online);

        QObject::connect( conn, SIGNAL( statusChanged(int) ),
                          SLOT( processIcqStatus(int) ) );
        QObject::connect( conn, SIGNAL( userOnline(QString,int) ),
                          SLOT( processContactOnline(QString,int) ) );
        QObject::connect( conn, SIGNAL( userOffline(QString) ),
                          SLOT( processContactOffline(QString) ) );
        QObject::connect( conn, SIGNAL( authGranted(QString) ),
                          SLOT( processAuthGranted(QString) ) );
        QObject::connect( conn, SIGNAL( authDenied(QString) ),
                          SLOT( processAuthDenied(QString) ) );
        QObject::connect( conn, SIGNAL( authRequest(QString) ),
                          SLOT( processAuthRequest(QString) ) );
        QObject::connect( conn, SIGNAL( incomingMessage(QString,QString) ),
                          SLOT( processIncomingMessage(QString,QString) ) );
        QObject::connect( conn, SIGNAL( incomingMessage(QString,QString,QDateTime) ),
                          SLOT( processIncomingMessage(QString,QString,QDateTime) ) );
        QObject::connect( conn, SIGNAL( connected() ),
                          SLOT( processIcqSignOn() ) );
        QObject::connect( conn, SIGNAL( disconnected() ),
                          SLOT( processIcqSignOff() ) );
        QObject::connect( conn, SIGNAL( error(QString) ),
                          SLOT( processIcqError(QString) ) );
        QObject::connect( conn, SIGNAL( shortUserDetailsAvailable(QString) ),
                          SLOT( processShortUserDetails(QString) ) );

        if ( first_login ) {
            QObject::connect( conn, SIGNAL( rosterAvailable() ), SLOT( processIcqFirstLogin() ) );
        }

        d->jidIcqTable.insert(user.bare(), conn);
        d->icqJidTable.insert(conn, user.bare());
        d->jidResources.insert(user.bare(), user);

        QTextCodec *codec;
        if ( UserManager::instance()->hasOption(user.bare(), "encoding") ) {
            codec = QTextCodec::codecForName( UserManager::instance()->getOption(user.bare(), "encoding").toByteArray() );
            if ( codec == 0 ) {
                codec = QTextCodec::codecForName("windows-1251");
            }
        } else {
            codec = QTextCodec::codecForName("windows-1251");
        }
        Q_ASSERT( codec != 0 );
        conn->setCodecForMessages(codec);
        conn->connect();
    }
}
Ejemplo n.º 21
0
void PEPManager::get(const XMPP::Jid &jid, const QString &node, const QString &id)
{
	PEPGetTask* g = new PEPGetTask(client_->rootTask(), jid.bare(), node, id);
	connect(g, SIGNAL(finished()), SLOT(getFinished()));
	g->go(true);
}
Ejemplo n.º 22
0
static XMPP::Jid processJid(const XMPP::Jid& jid)
{
	return jid.userHost();
}