Listening::Listening(MainWindow *mainWindow, Socket *socket, Book *book) { this->mainWindow = mainWindow; this->listenSocket = socket; this->book = book; this->udp = new NetworkUDP(); this->rfc = new RFC1664(); QString global_room_name(this->book->getRooms().at(0).getName().c_str()); this->mainWindow->getUi()->QTabWidget_onglets->setTabText(0, global_room_name); this->keepalive = NULL; QObject::connect(this, SIGNAL(statusBarChanged(QString)),this->mainWindow->getUi()->statusBar, SLOT(showMessage(QString))); QObject::connect(this, SIGNAL(newRoom(QString)),this, SLOT(createNewTab(QString))); }
void Core::handleStatusBarChanged (const QString& msg) { emit statusBarChanged (static_cast<QWidget*> (sender ()), msg); }
void Listening::run() { while(!end) { while (1) { cout << "Main() -> Attente d'un nouveau message" << endl; memset(this->message, 0, sizeof this->message); //vide le message SOCKADDR_IN addr_in; this->udp->receiveDatagrams(listenSocket->getSocket(), this->message, sizeof this->message, (SOCKADDR*)&addr_in, this->listenSocket->getAddrinfo()); cout << "Main() -> Message reçu : " << this->message << endl; cout << "Main() -> Type du message reçu : " << this->rfc->type(this->message) << endl; string testString(message); string champ1(rfc->fieldFromMesg(testString, 1, "§")); string champ2(rfc->fieldFromMesg(testString, 2, "§")); string champ3(rfc->fieldFromMesg(testString, 3, "§")); string champ4(rfc->fieldFromMesg(testString, 4, "§")); string champ5(rfc->fieldFromMesg(testString, 5, "§")); QString chaine1(champ1.c_str()); QString chaine2(champ2.c_str()); QString chaine3(champ3.c_str()); QString chaine4(champ4.c_str()); QString chaine5(champ5.c_str()); QString msg_com = ""; switch (rfc->type(message)) { case MSG_COM: cout << "Debug :" << champ2 << " a envoyé un message" << endl; msg_com = chaine2; msg_com += " - "; msg_com += chaine4; msg_com += "\n"; mainWindow->getUi()->textEdit->moveCursor(QTextCursor::End); mainWindow->getUi()->textEdit->insertPlainText(msg_com); break; case MSG_BOOK_LIST_RESP: cout << "Debug :j'ai reçu l'annuaire" << endl; this->book->addNewClient(chaine2.toStdString(), chaine3.toStdString(), chaine4.toStdString(), &addr_in); mainWindow->getUi()->listWidget->addItem(chaine2); break; case MSG_ACK: if(champ2 == MSG_ACK_CONNEXION_FAILED) { this->mainWindow->setConnected(false); emit statusBarChanged(QString("Connexion échouée")); } if(champ2 == MSG_ACK_CONNEXION_SUCCESS) { this->mainWindow->setConnected(true); this->mainWindow->getUi()->action_Cr_er_un_nouveau_salon->setEnabled(true); this->mainWindow->getUi()->action_Joindre_un_salon->setEnabled(true); this->mainWindow->getUi()->label_pseudo->setEnabled(true); this->mainWindow->getUi()->lineEdit->setEnabled(true); this->mainWindow->getUi()->pushButton->setEnabled(true); this->mainWindow->getUi()->action_Connexion_au_serveur->setEnabled(false); keepalive = new Signalisation(mainWindow->getUi()->label_pseudo->text().toStdString(), mainWindow->getSocket()); this->mainWindow->setSig(keepalive); keepalive->start(); emit statusBarChanged(QString("Connexion effectuée avec succès")); } if(champ2 == MSG_ACK_REMOVE_CLIENT_FAILED) { } if(champ2 == MSG_ACK_REMOVE_CLIENT_SUCCESS) { this->keepalive->stop(); emit statusBarChanged(QString("Déconnexion effectuée avec succès")); } if(champ2 == MSG_ACK_ADD_CLIENT_TO_ROOM_FAILED) { } if(champ2 == MSG_ACK_ADD_CLIENT_TO_ROOM_SUCCESS) { } if(champ2 == MSG_ACK_REMOVE_CLIENT_TO_ROOM_FAILED) { } if(champ2 == MSG_ACK_REMOVE_CLIENT_TO_ROOM_SUCCESS) { } if(champ2 == MSG_ACK_ROOM_CREATE_FAILED) { } if(champ2 == MSG_ACK_ROOM_CREATE_SUCCESS) { emit statusBarChanged(QString("Le salon a été créé avec succès")); emit newRoom(QString(champ2.c_str())); } if(champ2 == MSG_ACK_UNKNOWN_CLIENT) { emit statusBarChanged(QString("Vous n'etes pas connecté")); } break; default: break; } } } }
void DiagramCanvas::mouseMoveEvent(QMouseEvent *e) { int i; bool status_bar_changed = FALSE, near_vertex = FALSE; QString status; setCursor(Qt::arrowCursor); if (edge_creation_in_progress) if (!completed_edge_general_position(currentEdge, &i )) { status.sprintf(" Right click to kill cord."); status_bar_changed = TRUE; } for(i=0;i<vertexList.size();i++) if (proximity(e->pos(),vertexList[i]->position)) { near_vertex = TRUE; setCursor(Qt::pointingHandCursor); if (!status_bar_changed && !edge_creation_in_progress) { if (vertexList[i]->link_id == -1) { if (!readOnly) status.sprintf("Right click and drag to move."); } else status.sprintf(" Vertex:\t%d", vertexList[i]->link_id+1 ); status_bar_changed = TRUE; } } if (!edge_creation_in_progress && !status_bar_changed && !near_vertex ) for(i=0;i<edgeList.size();i++) if (proximity(e->pos(),edgeList[i])) { setCursor(Qt::pointingHandCursor); if (edgeList[i]->edge_type == singular) status.sprintf(" Coloured Edge:\t%d", edgeList[i]->arc_id+1); else if (readOnly && edgeList[i]->cuff_id > -1 ) status.sprintf(" Vertex:\t%d\tCuff:\t%d", edgeList[i]->link_id+1, edgeList[i]->cuff_id+1); else status.sprintf(" Vertex:\t%d", edgeList[i]->link_id+1); status_bar_changed = TRUE; } if (edge_creation_in_progress) redrawMovedEdge( e ); else for(i=0;i<crossingList.size();i++) if (!readOnly && proximity(e->pos(),crossingList[i]->position)) { setCursor(Qt::pointingHandCursor); status.sprintf(" Click to switch crossing."); status_bar_changed = TRUE; } if (vertex_drag_in_progress) redrawDraggedVertex( e ); if (!status_bar_changed) status.sprintf(" "); emit statusBarChanged(status); }