Ejemplo n.º 1
0
int Buddies::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: countOnlineUsers(); break;
        case 1: setUserStatus(); break;
        case 2: loginUser(); break;
        case 3: loginCurrentStatus(); break;
        case 4: validateUser(); break;
        case 5: stopifNotConnected(); break;
        case 6: myexit(); break;
        case 7: focusTabEdit(); break;
        case 8: structUser(); break;
        case 9: startChat(); break;
        case 10: helpAbout(); break;
        case 11: getSysInfo(); break;
        case 12: onlineNotify(); break;
        case 13: WriteOnWall(); break;
        case 14: Information(); break;
        case 15: dbstatus(); break;
        case 16: openNotes(); break;
        case 17: setIcon((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 18: iconActivated((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break;
        case 19: messageClicked(); break;
        case 20: showMessage(); break;
        }
        _id -= 21;
    }
    return _id;
}
Ejemplo n.º 2
0
// function called by a new thread only
void Client::inputListening()
{
	sf::TcpListener chatListener;
	//~ use of a selector to be non-blocking. There may be a better idea
	sf::SocketSelector selector;
	if(chatListener.listen(sf::Socket::AnyPort) != sf::Socket::Done)
	{
		std::cerr << "Unable to listen to arriving chat connections!" << std::endl;
		_chatListenerPort = 0;
		exit(UNABLE_TO_LISTEN);
	}
	else
		_chatListenerPort = chatListener.getLocalPort();
	std::cout << "waiting for connections on port " << _chatListenerPort << std::endl;
	selector.add(chatListener);
	while(_threadLoop.load())
	{
		// set waiting to 0.1 second so that the loop variable is checked frequently enough
		if(!selector.wait(SOCKET_TIME_SLEEP))
			continue;
		sf::TcpSocket socket;
		if(chatListener.accept(socket) == sf::Socket::Done)
		{
			sf::Packet packet;
			socket.receive(packet);
			TransferType type;
			packet >> type;
			if(type == TransferType::CHAT_PLAYER_IP)
				startChat(packet);
			else if(type == TransferType::NEW_GAME_SERVER_CONNECTION)
				initInGameConnection(packet);
			else
				std::cerr << "Unknown type of message\n";
		}
	}
Ejemplo n.º 3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    chat(new ChatEngine(this)),
    logWindow(new QTextEdit(this)),
    audio(new QMediaPlayer(this)),
    settings(new Settings(this))
{
    ui->setupUi(this);
    setWindowTitle(QApplication::applicationName());
    readSettings();

    audio->setMedia(QMediaContent(QUrl::fromLocalFile("C:/Users/fAg1r/Documents/qt-projects/ChatVdvoem/sounds/stranger.mp3")));

    connect(chat, SIGNAL(newMessage(QString,bool)), SLOT(receiveMessage(QString,bool)));
    connect(chat, SIGNAL(startedTyping()), SLOT(startedTyping()));
    connect(chat, SIGNAL(chatStarted()), SLOT(chatStarted()));
    connect(chat, SIGNAL(chatStopped()), SLOT(chatStopped()));
    connect(chat, SIGNAL(newLog(QString)), SLOT(newLog(QString)));

    connect(ui->exitAction, SIGNAL(triggered()), SLOT(close()));
    connect(ui->settingsAction, SIGNAL(triggered()), settings, SLOT(show()));
    connect(ui->startAction, SIGNAL(triggered()), chat, SLOT(startChat()));
    connect(ui->stopAction, SIGNAL(triggered()), chat, SLOT(stopChatRequest()));

    logWindow->setWindowFlags(Qt::Window);
    if (settings->showLog())
        logWindow->show();

    ui->lineEdit->setEnabled(false);

    ui->textEdit->setPlaceholderText("Здесь будет бесполезный трёп");

    addAnswerForMessage(QStringList() << "прив" << "дарова" << "хай" << "хэй" << "здравствуй" << "ку" << "мж"
                        << "м или ж" << "м ж" << "м/ж" << "здрасьте" << "добрый" << "=ага" << "и тебе", "я парень, мне 23");
    addAnswerForMessage(QStringList() << "девушка" << "девка" << "=ж" << "девочка" << "женщина" << "я ж" << "я нет"
                        << "баба" << "тян", "Хочешь фоточку моего выбритого члена?))");
    addAnswerForMessage(QStringList() << "как звать" << "как зовут" << "ж?" << "девушка?" << "я парень" << "транс" << "=м" << "=я м" << "мужик" << "=и я" << "и че" << "и что"
                        << "гей" << "тоже" << "я тож" << "бывает" << "прикольно" << "круто" << "молодец" << "поздравляю"
                        << "иди на" << "пошел на" << "иди в" << "нет" << "=не" << "=неа" << "=и?" << "похуй", "<disconnect>");

    for (quint8 i = 0; i < 5; ++i) {
        QAction *action = new QAction(ui->lineEdit);
        ui->lineEdit->addAction(action);
        action->setShortcut(QKeySequence(Qt::CTRL + 0x31 + i));
        connect(action, SIGNAL(triggered()), SLOT(hotAnswer()));
        hotAnswerActions << action;
    }

    QLabel *l = new QLabel(this);
    connect(chat, SIGNAL(online(QString)), l, SLOT(setText(QString)));
    ui->statusBar->addPermanentWidget(l);
}
Ejemplo n.º 4
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->inputBox->installEventFilter(this);
    ui->outputBox->setReadOnly(true);
    saveFile = false;
    connected = false;
    connect(ui->chatButton, SIGNAL(clicked()), this, SLOT(startChat()));
    connect(this, SIGNAL(enterPressed()), this, SLOT(sendData()));
}
Ejemplo n.º 5
0
void PopupChatWidget::goOnline()
{
  if (!online_) {
    online_ = true;

    int tries = 1;
    Wt::WString name = name_;
    if (name.empty())
      name = server().suggestGuest();

    while (!startChat(name)) {
      if (name_.empty())
	name = server().suggestGuest();
      else
	name = name_ + boost::lexical_cast<std::string>(++tries);
    }

    name_ = name;
  }

  missedMessages_ = 0;
  bar_->removeStyleClass("alert");
}
Ejemplo n.º 6
0
		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();
	}

	// FIXME: After KDE 3.2 we should make isReachable do the isConnected call so it can be removed here - Martijn
	const bool reach = account()->isConnected() && isReachable();
	const bool myself = (this == account()->myself());

	KAction *actionSendMessage = KopeteStdAction::sendMessage( this, SLOT(sendMessage()), menu );
	actionSendMessage->setEnabled( reach && !myself );
	menu->addAction( actionSendMessage );

	KAction *actionChat = KopeteStdAction::chat( this, SLOT(startChat()), menu );
	actionChat->setEnabled( reach && !myself );
	menu->addAction( actionChat );

	KAction *actionSendFile = KopeteStdAction::sendFile( this, SLOT(sendFile()), menu );
	actionSendFile->setEnabled( reach && d->fileCapable && !myself );
	menu->addAction( actionSendFile );

	// Protocol specific options will go below this separator
	// through the use of the customContextMenuActions() function

	// Get the custom actions from the protocols ( pure virtual function )
	QList<KAction*> *customActions = customContextMenuActions();
	if( customActions && !customActions->isEmpty() )
	{
		menu->addSeparator();