Exemplo n.º 1
0
void CWizardIrcConnection::accept()
{
	if ( !quazaaSettings.Chat.NickNames.contains( nickName(), Qt::CaseInsensitive ) )
	{
		quazaaSettings.Chat.NickNames << nickName();
	}
	if ( !quazaaSettings.Chat.RealNames.contains( realName(), Qt::CaseInsensitive ) )
	{
		quazaaSettings.Chat.RealNames << realName();
	}
	if ( !quazaaSettings.Chat.Hosts.contains( hostName(), Qt::CaseInsensitive ) )
	{
		quazaaSettings.Chat.Hosts << hostName();
	}
	if ( !quazaaSettings.Chat.UserNames.contains( userName(), Qt::CaseInsensitive ) )
	{
		quazaaSettings.Chat.UserNames << userName();
	}
	if ( !quazaaSettings.Chat.ConnectionNames.contains( connectionName(), Qt::CaseInsensitive ) )
	{
		quazaaSettings.Chat.ConnectionNames << connectionName();
	}
	quazaaSettings.saveChatConnectionWizard();

	QDialog::accept();
}
Exemplo n.º 2
0
void DlgGroupChat::AppendChatMsg(IMChat::MsgData* ptrMsg, const std::string* ptrStr)
{
	CString csTime;
	time_t msgTime = ptrMsg->timestamp();
	struct tm msgTm;
	localtime_s(&msgTm, &msgTime);
	csTime.Format(_T("%d-%d-%d %d:%d:%d"), msgTm.tm_year + 1900, msgTm.tm_mon + 1, msgTm.tm_mday, msgTm.tm_hour, msgTm.tm_min, msgTm.tm_sec);
#ifdef UNICODE
	CA2W dataTemp(ptrMsg->msgdata().c_str());//ptrMsg->msgdata().c_str()
	CString csContent(dataTemp);
	CA2W nickNameTemp(ptrStr->c_str());//ptrMsg->msgdata().c_str()
	CString nickName(nickNameTemp);
#else
	//MultiByteToWideChar
	CString csContent(ptrMsg->msgdata().c_str());
	CString nickName(ptrStr->c_str());
#endif
	m_csChatLog.Append(nickName);
	m_csChatLog.Append(_T("  "));
	m_csChatLog.Append(csTime);
	m_csChatLog.Append(_T("\r\n"));
	m_csChatLog.Append(csContent);
	m_csChatLog.Append(_T("\r\n"));
	//滚动条自动下拉;
	::PostMessage(m_editLog.GetSafeHwnd(), WM_VSCROLL, SB_BOTTOM, 0);
	UpdateData(FALSE);
}
Exemplo n.º 3
0
void FacebookContact::slotUserInfo()
{
    KDialog infoDialog;
    infoDialog.setButtons( KDialog::Close);
    infoDialog.setDefaultButton(KDialog::Close);
    Ui::FacebookInfo info;
    info.setupUi(infoDialog.mainWidget());
    info.m_displayName->setText(nickName());
    info.m_personalMessage->setPlainText(statusMessage().message());
    QVariant picture(property(Kopete::Global::Properties::self()->photo()).value());    
    info.m_photo->setPixmap(picture.value<QPixmap>());    

    infoDialog.setCaption(nickName());
    infoDialog.exec();
}
Exemplo n.º 4
0
//![receive]
void IrcBot::processMessage(IrcPrivateMessage* message)
{
    if (message->isPrivate()) {
        // private message: reply to the message sender
        // => triggers: "!<cmd> <params>" and "<cmd> <params>"
        parser.setTarget(message->nick());
        parser.setTriggers(QStringList() << "!" << "");
    } else {
        // channel message: reply to the target channel
        // => triggers: "!<cmd> <params>" and "bot: <cmd> <params>"
        parser.setTarget(message->target());
        parser.setTriggers(QStringList() << "!" << nickName().append(":"));
    }

    IrcCommand* cmd = parser.parse(message->content());
    if (cmd) {
        if (cmd->type() == IrcCommand::Custom && cmd->parameters().value(0) == "HELP") {
            help(cmd->parameters().mid(1));
        } else {
            sendCommand(cmd);

            if (cmd->type() == IrcCommand::Quit) {
                connect(this, SIGNAL(disconnected()), qApp, SLOT(quit()));
                QTimer::singleShot(1000, qApp, SLOT(quit()));
            }
        }
    }
}
Exemplo n.º 5
0
void MyIrcSession::on_socketError(QAbstractSocket::SocketError error) {
	std::string reason;
	switch(error) {
		case QAbstractSocket::ConnectionRefusedError: reason = "The connection was refused by the peer (or timed out)."; break;
		case QAbstractSocket::RemoteHostClosedError: reason = "The remote host closed the connection."; break;
		case QAbstractSocket::HostNotFoundError: reason = "The host address was not found."; break;
		case QAbstractSocket::SocketAccessError: reason = "The socket operation failed because the application lacked the required privileges."; break;
		case QAbstractSocket::SocketResourceError: reason = "The local system ran out of resources."; break;
		case QAbstractSocket::SocketTimeoutError: reason = "The socket operation timed out."; break;
		case QAbstractSocket::DatagramTooLargeError: reason = "The datagram was larger than the operating system's limit."; break;
		case QAbstractSocket::NetworkError: reason = "An error occurred with the network."; break;
		case QAbstractSocket::SslHandshakeFailedError: reason = "The SSL/TLS handshake failed, so the connection was closed"; break;
		case QAbstractSocket::UnknownSocketError: reason = "An unidentified error occurred."; break;
		default: reason= "Unknown error."; break;
	};

	if (!suffix.empty()) {
		for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
			np->handleParticipantChanged(user, TO_UTF8(nickName()), it->second->getChannel() + suffix, pbnetwork::PARTICIPANT_FLAG_ROOM_NOT_FOUND, pbnetwork::STATUS_NONE, reason);
		}
	}
	else {
		np->handleDisconnected(user, 0, reason);
		np->tryNextServer();
	}
	m_connected = false;
}
Exemplo n.º 6
0
BufferId NetworkModelController::findQueryBuffer(const QModelIndex &index, const QString &predefinedNick) const
{
    NetworkId networkId = index.data(NetworkModel::NetworkIdRole).value<NetworkId>();
    if (!networkId.isValid())
        return BufferId();

    QString nick = predefinedNick.isEmpty() ? nickName(index) : predefinedNick;
    if (nick.isEmpty())
        return BufferId();

    return findQueryBuffer(networkId, nick);
}
Exemplo n.º 7
0
ConnectionInfo CWizardIrcConnection::connection() const
{
	ConnectionInfo connection;
	connection.nick = nickName();
	connection.real = realName();
	connection.host = hostName();
	connection.port = port();
	connection.secure = isSecure();
	connection.user = userName();
	connection.pass = password();
	connection.name = connectionName();
	return connection;
}
Exemplo n.º 8
0
ConnectionInfo Session::toConnection() const
{
    ConnectionInfo connection;
    connection.name = name();
    connection.secure = isSecure();
    connection.host = host();
    connection.port = port();
    connection.user = userName();
    connection.nick = nickName();
    connection.real = realName();
    connection.pass = password();
    connection.channels = channels();
    connection.quit = m_quit;
    return connection;
}
int QXmppMucRoom::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 32)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 32;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QXmppMucRoom::Actions*>(_v) = allowedActions(); break;
        case 1: *reinterpret_cast< bool*>(_v) = isJoined(); break;
        case 2: *reinterpret_cast< QString*>(_v) = jid(); break;
        case 3: *reinterpret_cast< QString*>(_v) = name(); break;
        case 4: *reinterpret_cast< QString*>(_v) = nickName(); break;
        case 5: *reinterpret_cast< QStringList*>(_v) = participants(); break;
        case 6: *reinterpret_cast< QString*>(_v) = password(); break;
        case 7: *reinterpret_cast< QString*>(_v) = subject(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 4: setNickName(*reinterpret_cast< QString*>(_v)); break;
        case 6: setPassword(*reinterpret_cast< QString*>(_v)); break;
        case 7: setSubject(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemplo n.º 10
0
QList<QStandardItem *> NickNameEntry::toModelRow() const
{
    const QVariant nickNameData = nickName();
    const Qt::ItemFlags flags = Qt::ItemIsSelectable|Qt::ItemIsEnabled;
    QStandardItem *i1 = new QStandardItem(name);
    i1->setFlags(flags);
    i1->setData(nickNameData, NickNameRole);
    QStandardItem *i2 = new QStandardItem(email);
    i1->setFlags(flags);
    i2->setData(nickNameData, NickNameRole);
    QStandardItem *i3 = new QStandardItem(aliasName);
    i3->setFlags(flags);
    i3->setData(nickNameData, NickNameRole);
    QStandardItem *i4 = new QStandardItem(aliasEmail);
    i4->setFlags(flags);
    i4->setData(nickNameData, NickNameRole);
    QList<QStandardItem *> row;
    row << i1 << i2 << i3 << i4;
    return row;
}
Exemplo n.º 11
0
KMenu* Contact::popupMenu()
{
	KMenu *menu = new KMenu();

	QString titleText;
	const QString nick = nickName();
	if( nick == contactId() )
		titleText = QString::fromLatin1( "%1 (%2)" ).arg( contactId(), onlineStatus().description() );
	else
		titleText = QString::fromLatin1( "%1 <%2> (%3)" ).arg( nick, contactId(), onlineStatus().description() );
	menu->addTitle( titleText );

	if( metaContact() && metaContact()->isTemporary() && contactId() != account()->myself()->contactId() )
	{
		KAction *actionAddContact = new KAction( KIcon("list-add-user"), i18n( "&Add to Your Contact List" ), menu );
		connect( actionAddContact, SIGNAL(triggered(bool)), this, SLOT(slotAddContact()) );

		menu->addAction(actionAddContact);
		menu->addSeparator();
	}
Exemplo n.º 12
0
void MyIrcSession::on_numericMessageReceived(IrcMessage *message) {
	QString channel;
	QStringList members;
	std::string nick;

	IrcNumericMessage *m = (IrcNumericMessage *) message;
	QStringList parameters = m->parameters();
	switch (m->code()) {
		case 301:
			break;
		case 315:
			LOG4CXX_INFO(logger, "End of /who request " << TO_UTF8(parameters[1]));
			break;
		case 332:
			m_topicData = TO_UTF8(parameters[2]);
			break;
		case 333:
			nick = TO_UTF8(parameters[2]);
			if (nick.find("!") != std::string::npos) {
				nick = nick.substr(0, nick.find("!"));
			}
			if (nick.find("/") != std::string::npos) {
				nick = nick.substr(0, nick.find("/"));
			}
			np->handleSubject(user, TO_UTF8(parameters[1].toLower()) + suffix, m_topicData, nick);
			break;
		case 352: {
			channel = parameters[1].toLower();
			nick = TO_UTF8(parameters[5]);
			IRCBuddy &buddy = getIRCBuddy(TO_UTF8(channel), nick);

			if (parameters[6].toUpper().startsWith("G")) {
				if (!buddy.isAway()) {
					buddy.setAway(true);
					np->handleParticipantChanged(user, nick, TO_UTF8(channel) + suffix, buddy.isOp(), pbnetwork::STATUS_AWAY);
				}
			}
			else if (buddy.isAway()) {
				buddy.setAway(false);
				np->handleParticipantChanged(user, nick, TO_UTF8(channel) + suffix, buddy.isOp(), pbnetwork::STATUS_ONLINE);
			}
			break;
		}
		case 353:
			channel = parameters[2].toLower();
			members = parameters[3].split(" ");

			LOG4CXX_INFO(logger, user << ": Received members for " << TO_UTF8(channel) << suffix);
			for (int i = 0; i < members.size(); i++) {
				bool op = 0;
				std::string nickname = TO_UTF8(members.at(i));
				op = correctNickname(nickname);
				IRCBuddy &buddy = getIRCBuddy(TO_UTF8(channel), nickname);
				buddy.setOp(op);
				np->handleParticipantChanged(user, nickname, TO_UTF8(channel) + suffix, buddy.isOp(), pbnetwork::STATUS_ONLINE);
			}

			break;
		case 366:
			// ask /who to get away states
			channel = parameters[1].toLower();
			LOG4CXX_INFO(logger, user << "Asking /who for channel " << TO_UTF8(channel));
			sendCommand(IrcCommand::createWho(channel));
			break;
		case 432:
			np->handleDisconnected(user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Erroneous Nickname");
			break;
		case 433:
			for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
				np->handleParticipantChanged(user, TO_UTF8(nickName()), it->second->getChannel() + suffix, pbnetwork::PARTICIPANT_FLAG_CONFLICT);
			}
			if (suffix.empty()) {
				np->handleDisconnected(user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Nickname is already in use");
			}
			break;
		case 436:
			for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
				np->handleParticipantChanged(user, TO_UTF8(nickName()), it->second->getChannel() + suffix, pbnetwork::PARTICIPANT_FLAG_CONFLICT);
			}
			np->handleDisconnected(user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Nickname collision KILL");
		case 464:
			for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
				np->handleParticipantChanged(user, TO_UTF8(nickName()), it->second->getChannel() + suffix, pbnetwork::PARTICIPANT_FLAG_NOT_AUTHORIZED);
			}
			if (suffix.empty()) {
				np->handleDisconnected(user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Password incorrect");
			}
		case 321:
			m_rooms.clear();
			m_names.clear();
			break;
		case 322:
			m_rooms.push_back(TO_UTF8(parameters[1]));
			m_names.push_back(TO_UTF8(parameters[1]));
			break;
		case 323:
			np->handleRoomList("", m_rooms, m_names);
			break;
		default:
			break;
	}

	if (m->code() >= 400 && m->code() < 500) {
			LOG4CXX_INFO(logger, user << ": Error message received: " << message->toData().data());
	}
}