예제 #1
0
	void IrcAccount::JoinServer (ServerOptions server,
			ChannelOptions channel, bool onlyServer)
	{
		if (server.ServerName_.isEmpty ())
			server.ServerName_ = DefaultServer_;
		if (!server.ServerPort_)
			server.ServerPort_ = DefaultPort_;
		if (server.ServerEncoding_.isEmpty ())
			server.ServerEncoding_ = DefaultEncoding_;
		if (server.ServerNickName_.isEmpty ())
			server.ServerNickName_ = NickNames_.value (0, GetOurNick ());

		if (channel.ServerName_.isEmpty ())
			channel.ServerName_ = server.ServerName_;
		if (channel.ChannelName_.isEmpty ())
			channel.ChannelName_ = DefaultChannel_;

		QString serverId = server.ServerName_ + ":" +
				QString::number (server.ServerPort_);
		if (!ClientConnection_->IsServerExists (serverId))
		{
			ClientConnection_->JoinServer (server);
			if (!onlyServer)
				ClientConnection_->GetIrcServerHandler (serverId)->
						Add2ChannelsQueue (channel);
		}
		else if (!onlyServer)
			ClientConnection_->JoinChannel (server, channel);
	}
예제 #2
0
	void GlooxAccount::handleServerHistoryFetched (const QString& jid,
			const QString& id, SrvHistMessages_t messages)
	{
		const auto& index = Xep0313ModelMgr_->Jid2Index (jid);

		const auto& ourNick = GetOurNick ();

		const auto jidEntry = ClientConnection_->GetCLEntry (jid);
		const auto& otherNick = jidEntry ?
				qobject_cast<ICLEntry*> (jidEntry)->GetHumanReadableID () :
				jid;
		for (auto& message : messages)
			message.Nick_ = message.Dir_ == IMessage::Direction::DIn ?
					otherNick :
					ourNick;

		emit serverHistoryFetched (index, id.toUtf8 (), messages);
	}