├── .gitattributes ├── Client ├── .qmake.stash ├── Makefile ├── Makefile.Debug ├── Makefile.Release ├── client.pro ├── client.pro.user ├── client.pro.user.8298638 ├── client.pro.user.e562dc9 ├── clientwidget - 副本 (2).cpp ├── clientwidget - 副本 (2).h ├── clientwidget - 副本 (2).ui ├── clientwidget.cpp ├── clientwidget.h ├── clientwidget.ui ├── debug │ └── client.exe ├── findpassword.cpp ├── findpassword.h ├── findpassword.ui ├── image │ ├── 766971.jpg │ └── back.jpg ├── logindialog.cpp ├── logindialog.h ├── logindialog.ui ├── main.cpp ├── object_script.client.Debug ├── object_script.client.Release ├── register.cpp ├── register.h ├── register.ui ├── release │ ├── client.exe │ ├── clientwidget.o │ ├── findpassword.o │ ├── logindialog.o │ ├── main.o │ ├── moc_clientwidget.cpp │ ├── moc_clientwidget.o │ ├── moc_findpassword.cpp │ ├── moc_findpassword.o │ ├── moc_logindialog.cpp │ ├── moc_logindialog.o │ ├── moc_predefs.h │ ├── moc_register.cpp │ ├── moc_register.o │ ├── moc_sendfile.cpp │ ├── moc_sendfile.o │ ├── qrc_src.cpp │ ├── qrc_src.o │ ├── register.o │ ├── sendfile.o │ └── user_imformation.o ├── sendfile - 副本.cpp ├── sendfile - 副本.h ├── sendfile.cpp ├── sendfile.h ├── sendfile.ui ├── src.qrc ├── ui_clientwidget.h ├── ui_findpassword.h ├── ui_logindialog.h ├── ui_register.h ├── ui_sendfile.h ├── user_imformation.cpp └── user_imformation.h ├── README.md ├── Server ├── .qmake.stash ├── Makefile ├── Makefile.Debug ├── Makefile.Release ├── NP.txt ├── debug │ └── login_server.exe ├── image │ └── 1106022.jpg ├── login_server.pro ├── login_server.pro.user ├── login_server.pro.user.8298638 ├── main.cpp ├── messagequeue.cpp ├── messagequeue.h ├── release │ ├── login_server.exe │ ├── main.o │ ├── messagequeue.o │ ├── moc_predefs.h │ ├── moc_server.cpp │ ├── moc_server.o │ ├── qrc_src.cpp │ ├── qrc_src.o │ ├── server.o │ └── user_information.o ├── server.cpp ├── server.h ├── server.ui ├── src.qrc ├── ui_server.h ├── ui_serverwidget.h ├── user_information.cpp └── user_information.h └── pic ├── client.jpg └── server.jpg /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Client/.qmake.stash: -------------------------------------------------------------------------------- 1 | QMAKE_DEFAULT_INCDIRS = \ 2 | C:/Qt/Qt5.8.0/Tools/mingw530_32/lib/gcc/i686-w64-mingw32/5.3.0/include \ 3 | C:/Qt/Qt5.8.0/Tools/mingw530_32/lib/gcc/i686-w64-mingw32/5.3.0/include-fixed \ 4 | C:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include \ 5 | C:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/c++ \ 6 | C:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/c++/i686-w64-mingw32 \ 7 | C:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/c++/backward 8 | QMAKE_DEFAULT_LIBDIRS = \ 9 | C:/Qt/Qt5.8.0/Tools/mingw530_32/lib/gcc/i686-w64-mingw32/5.3.0 \ 10 | C:/Qt/Qt5.8.0/Tools/mingw530_32/lib/gcc \ 11 | C:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/lib \ 12 | C:/Qt/Qt5.8.0/Tools/mingw530_32/lib 13 | -------------------------------------------------------------------------------- /Client/client.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-11-20T18:39:34 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui network 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = client 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which as been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | 26 | SOURCES += \ 27 | clientwidget.cpp \ 28 | findpassword.cpp \ 29 | logindialog.cpp \ 30 | main.cpp \ 31 | register.cpp \ 32 | sendfile.cpp \ 33 | user_imformation.cpp 34 | 35 | HEADERS += \ 36 | clientwidget.h \ 37 | findpassword.h \ 38 | logindialog.h \ 39 | register.h \ 40 | sendfile.h \ 41 | user_imformation.h 42 | 43 | RESOURCES += \ 44 | src.qrc 45 | 46 | FORMS += \ 47 | clientwidget.ui \ 48 | findpassword.ui \ 49 | logindialog.ui \ 50 | register.ui \ 51 | sendfile.ui 52 | -------------------------------------------------------------------------------- /Client/clientwidget - 副本 (2).cpp: -------------------------------------------------------------------------------- 1 | #include "clientwidget.h" 2 | #include "ui_clientwidget.h" 3 | #include "logindialog.h" 4 | #include "findpassword.h" 5 | #include "user_imformation.h" 6 | #include "chat.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | 16 | bool isfind =false; //设置是否找回密码的标志 17 | bool isquestionreturned; // 问题是否返回 18 | 19 | QString loginmessage = ""; //这是要发送给服务器的信息,确定是登录还是注册还是找回。 20 | QString myquestion, myanswer; //服务器交流的内容 21 | 22 | 23 | const int M=20;//先假定最多用户数 24 | user_imformation *v[M]; 25 | int mysize; //当前用户数 26 | 27 | int mode; //设置消息处理的类型 28 | enum { Login=0, Send, Recv, Chatting, Client}; 29 | bool isoffline; //指示上线时是否需要接收离线消息 30 | bool istititleseted; //指示窗口名称不需要设置 31 | 32 | 33 | 34 | //被下面界面引用的变量 35 | QString connected_ip; //尝试连接本机的ip 36 | quint16 Port_number; //这个服务器的小型客户端监听端口! 37 | QString name; //本机用户名 38 | QString try_connect_ip; 39 | quint16 try_connect_port; 40 | bool isAttempToConnect; //指示此时是尝试发起私聊连接还是被连接的 41 | 42 | 43 | 44 | ClientWidget::ClientWidget(QWidget *parent) : 45 | QWidget(parent), 46 | ui(new Ui::clientwidget) 47 | { 48 | ui->setupUi(this); 49 | 50 | //初始化一些变量 51 | for (int i=0; iframe_client_off->setEnabled(false); 78 | ui->frame_client_on->setEnabled(false); 79 | ui->buttonClose->setEnabled(false); //一开始不能断开吧 80 | ui->frame_message->setEnabled(false); 81 | ui->lineEditIp->setText("222.20.104.4"); 82 | ui->lineEditPort->setText("8888"); //默认端口 83 | 84 | tcpSocket = new QTcpSocket(this); //与服务器交流 85 | //绑定监听 86 | 87 | 88 | connect(tcpSocket, &QTcpSocket::connected, 89 | [=]() 90 | { 91 | isoffline = false; //连接服务器需要离线数据 92 | ui->le_state->setText("已经连接!"); 93 | ui->frame_client_off->setEnabled(true); 94 | ui->frame_client_on->setEnabled(true); 95 | ui->frame_message->setEnabled(true); //可以发送消息 96 | ui->frame_ip->setEnabled(false); //ip不能由用户修改 97 | ui->buttonClose->setEnabled(true); //可以断开啊 98 | ui->bt_connect_client->setEnabled(true); //一开始允许连接 99 | mode = Chatting; 100 | }); 101 | 102 | connect(tcpSocket, &QTcpSocket::disconnected, 103 | [=]() 104 | { 105 | setWindowTitle(QString("客户端端口:%1").arg(Port_number)); //窗口名称复原 106 | istititleseted = false; //需要设置窗口 107 | ui->le_state->setText("未连接!"); 108 | ui->le_username->clear(); 109 | ui->frame_client_off->setEnabled(false); 110 | ui->frame_client_on->setEnabled(false); 111 | ui->frame_message->setEnabled(false); 112 | ui->frame_ip->setEnabled(true); //ip能再由用户修改 113 | ui->buttonClose->setEnabled(false); //不能断开吧 114 | //用户列表清除 115 | ui->le_usernum_off->setText("0"); 116 | ui->le_usernum_on->setText("0"); 117 | ui->cb_client_off->clear();//清除用户列表 118 | ui->cb_client_off->addItem(QString("无")); 119 | ui->cb_client_on->clear();//清除用户列表 120 | ui->cb_client_on->addItem(QString("无")); 121 | ui->lineEditIp->setText("222.20.104.4"); 122 | ui->lineEditPort->setText("8888"); //默认端口 123 | loginmessage.clear(); //清空本用户信息 124 | }); 125 | connect(tcpSocket,&QTcpSocket::readyRead, 126 | [=]() 127 | { 128 | QByteArray buf = tcpSocket->readAll(); //接收消息种类 129 | if (mode == Login) //登录 130 | { 131 | if(!isfind) //不是找回密码 132 | { 133 | if("login successed" == QString(buf).section("##",1,1) ) //登录注册成功 "##login successed##dingding" 134 | { 135 | name = QString(buf).section("##",2,2); 136 | QMessageBox::information(NULL,"恭喜",QString("%1,登录成功").arg(name)); 137 | tcpSocket->write("##login succeed, request for user_imformation"); 138 | 139 | mode = Chatting; 140 | ui->frame_message->setEnabled(true); //用户能发送消息 141 | ui->le_username->setText(name);//设置用户名 142 | } 143 | else if ("register successed" == QString(buf).section("##",1,1)) //"##register successed##dingding" 144 | { 145 | name = QString(buf).section("##",2,2); 146 | QMessageBox::information(NULL,"恭喜",QString("%1,注册并登录成功").arg(name)); //用户名放最后 147 | tcpSocket->write("##login succeed, request for user_imformation"); 148 | 149 | mode = Chatting; 150 | ui->frame_message->setEnabled(true); //用户能发送消息 151 | ui->le_username->setText(name);//设置用户名 152 | } 153 | else 154 | { 155 | QMessageBox::information(NULL,"Warning","登录或者注册失败!"); 156 | on_buttonClose_clicked(); //断开连接! 157 | } 158 | } 159 | else if("question" ==QString(buf).section("##",1,1))//问题未发送 160 | { 161 | myquestion = QString(buf).section("##",2,2); 162 | findpassword* dlgf = new findpassword(); 163 | dlgf->exec(); 164 | tcpSocket->write(myanswer.toUtf8()); //发送给服务器答案 165 | isquestionreturned = true; //问题已经收到 166 | } 167 | else if("answer is right" == QString(buf).section("##",1,1))//"##answer is right##123##dingding" 168 | { 169 | name = QString(buf).section("##",3,3); 170 | QMessageBox::information(NULL,"密码找回",QString("%1,您的密码是:%2,已经自动登录").arg(name).arg(QString(buf).section("##",2,2))); //分割的第二部分 171 | tcpSocket->write("##login succeed, request for user_imformation"); 172 | mode = Chatting; 173 | ui->frame_message->setEnabled(true); //用户能发送消息 174 | ui->le_username->setText(name);//设置用户名 175 | } 176 | else //收到其他答案 177 | { 178 | QMessageBox::information(NULL,"Warning",QString(buf)); 179 | tcpSocket->write("##something wrong!"); 180 | on_buttonClose_clicked(); //断开连接 181 | mode = Chatting; 182 | } 183 | 184 | } 185 | else if(mode == Client) //请求连接模式 186 | { 187 | if("fine, contact" == QString(buf).section("##",1,1)) //收到连接指令 ding##fine, contact##yaya 丁丁允许亚亚连接 188 | { 189 | if(name == QString(buf).section("##",2,2)) //与本机name一样 190 | { 191 | QString connect_name = QString(buf).section("##",0,0); 192 | QString myip = ""; 193 | qint16 myport = 0; 194 | for(int i=0; iusername == connect_name) //找到对方的监听端口,对方的ip和port 197 | { 198 | myip = v[i]->ip; 199 | myport = v[i]->port; 200 | } 201 | } 202 | if(myip != "" && myport != 0) 203 | { 204 | try_connect_ip = myip; 205 | try_connect_port = myport; 206 | isAttempToConnect = true; 207 | Chat* dlgc = new Chat(); 208 | dlgc->show(); 209 | } 210 | 211 | } 212 | else //与本机连接不一样 213 | { 214 | QMessageBox::information(NULL,"Warning","收到连接对象非本机的点对点连接"); 215 | } 216 | } 217 | mode = Chatting; 218 | ui->frame_message->setEnabled(true); //用户能发送消息 219 | } 220 | else if("request for contact" == QString(buf).section("##",1,1)) //服务器说要其他用户请求直接连接 dingding##request for contact##yaya 221 | { 222 | if(name != QString(buf).section("##",2,2)) 223 | { 224 | QMessageBox::information(NULL,"信息发送错了",QString("来自%1的信息错误").arg(QString(buf).section("##",0,0))); 225 | } 226 | else 227 | { 228 | QString connected_name = QString(buf).section("##",0,0); 229 | for(int i=0; iusername == connected_name) //找到对方的ip,方便监听 232 | { 233 | connected_ip = v[i]->ip; 234 | } 235 | } 236 | ui->cb_client_on->setCurrentText(QString(buf).section("##",0,0)); 237 | tcpSocket->write(QString("%1##fine, contact##%2").arg(name).arg(QString(buf).section("##",0,0)).toUtf8()); 238 | isAttempToConnect = false; //被连接的对象 239 | qDebug() << Port_number; 240 | Chat* dlgc = new Chat(); 241 | dlgc->show(); 242 | } 243 | } 244 | else if("load users' states" == QString(buf).section("##",0,0))//用户状态变更 load users' states##10##.... 245 | { 246 | for (int i=0; icb_client_off->currentText(); 252 | QString b = ui->cb_client_on->currentText(); 253 | ui->cb_client_off->clear();//清除用户列表 254 | ui->cb_client_off->addItem(QString("无")); 255 | ui->cb_client_on->clear();//清除用户列表 256 | ui->cb_client_on->addItem(QString("无")); 257 | ui->lineEditIp->clear(); 258 | ui->lineEditPort->clear(); 259 | //获取用户状态信息 260 | mysize = QString(buf).section("##",1,1).toInt(); // 10##.. 首先获取数组大小 261 | if(mysize > 0) 262 | { 263 | QString imformation = (QString(buf).section("##",2,2)); //用户信息 264 | QTextStream userinformation(&imformation);//读取用户信息 265 | int num_on = 0, num_off = 0; 266 | for(int i=0; i> myname ; 272 | userinformation >> ison; 273 | userinformation >> myip; 274 | userinformation >> myport; 275 | user_imformation *u = new user_imformation(myname,ison,myip,myport); 276 | v[i] = u; 277 | //加载用户列表信息 278 | if(!istititleseted && myname==name) 279 | { 280 | setWindowTitle(QString("ip:%1 客户服务端端口:%2").arg(myip).arg(myport)); 281 | Port_number = myport; 282 | istititleseted = true; //已经创建 283 | } 284 | if(ison==1)//在线用户 285 | { 286 | ui->cb_client_on->addItem(myname); 287 | num_on ++; 288 | } 289 | else //离线 290 | { 291 | ui->cb_client_off->addItem(myname); 292 | num_off ++; 293 | } 294 | } 295 | ui->le_usernum_on->setText(QString("%1").arg(num_on)); 296 | ui->le_usernum_off->setText(QString("%1").arg(num_off)); 297 | ui->cb_client_off->setCurrentText(a); 298 | ui->cb_client_on->setCurrentText(b); 299 | } 300 | else 301 | { 302 | ui->le_usernum_on->setText(QString("0")); 303 | ui->le_usernum_off->setText(QString("0")); 304 | } 305 | 306 | if(!isoffline)//未加载离线信息 307 | { 308 | isoffline = true; //只需要连接服务器一次的时候请求 309 | tcpSocket->write(QString("Offline message##%1").arg(name).toUtf8()); //请求离线信息 310 | qDebug() << "Offline message##%1"; 311 | 312 | } 313 | else 314 | { 315 | //do othing 316 | } 317 | } 318 | else if("offline message" == QString(buf).section("&&",0,0)) //离线消息处理 319 | { 320 | int count = QString(buf).section("&&",1,1).toInt(); 321 | 322 | for(int indexofm=2; indexofmtextBrowser->append(sendername.append(QString(" to ")). 329 | append(recvname).append(QString(": ")).append(message)); //消息显示格式! 330 | } 331 | } 332 | else if("##permission for login" == QString(buf)) //接收到允许登录 333 | { 334 | timer->stop(); 335 | LoginDialog *dlg = new LoginDialog(); //登录界面 336 | dlg->exec(); 337 | isquestionreturned = false; //问题未传回 338 | qDebug() << "发送登录消息"; 339 | ui->frame_message->setEnabled(false); //用户不能发送消息 340 | if(loginmessage != "") 341 | { 342 | tcpSocket->write(loginmessage.toUtf8());//发送登录信息 343 | ui->frame_message->setEnabled(false); //用户不能发送消息 344 | mode = Login; //登录 345 | } 346 | else 347 | { 348 | tcpSocket->write("login failed"); //断开连接 349 | } 350 | } 351 | else //处理普通消息 dingding##hello##yaya 352 | { 353 | QString sendername = QString(buf).section("##",0,0); 354 | QString message = QString(buf).section("##",1,1); 355 | QString recvname = QString(buf).section("##",2,2); 356 | ui->textBrowser->append("--------------" + QTime::currentTime().toString("hh:mm:ss") + "--------------"); 357 | ui->textBrowser->append(QString("%1 to %2 : %3").arg(sendername).arg(recvname). 358 | arg(message)); //显示对方的信息消息显示格式! 359 | } 360 | 361 | }); 362 | } 363 | ClientWidget::~ClientWidget() 364 | { 365 | for(int i=0; iclose(); 374 | delete ui; 375 | } 376 | 377 | void ClientWidget::on_buttonConnect_clicked() //打开服务器 378 | { 379 | QString ip = ui->lineEditIp->text(); 380 | qint16 port = ui->lineEditPort->text().toInt(); 381 | tcpSocket->connectToHost(QHostAddress(ip),port); 382 | tcpSocket->write("##request for login");//发送请求 383 | timer->start(100); //0.1秒 384 | qDebug() << "##request for login"; 385 | } 386 | 387 | void ClientWidget::connect_failure() 388 | { 389 | QMessageBox::information(this,"错误","未连接服务器或者服务器未打开", QMessageBox::Yes); 390 | timer->stop(); 391 | } 392 | 393 | void ClientWidget::on_buttonClose_clicked() 394 | { 395 | for (int i=0; iisOpen()) 402 | tcpSocket->disconnectFromHost(); 403 | } 404 | 405 | 406 | void ClientWidget::on_cb_client_off_currentIndexChanged(int index) 407 | { 408 | if(index != 0) //不是无 409 | { 410 | ui->frame_client_on->setEnabled(false); //在线客户区不能选择 411 | ui->cb_client_on->setCurrentIndex(0); //回到0 412 | } 413 | else 414 | { 415 | ui->frame_client_on->setEnabled(true); 416 | } 417 | } 418 | 419 | void ClientWidget::on_cb_client_on_currentIndexChanged(int index) 420 | { 421 | if(index != 0)//不是无 422 | { 423 | if(ui->cb_client_on->currentText() == ui->le_username->text()) 424 | { 425 | ui->cb_client_on->setCurrentIndex(0); 426 | } 427 | else 428 | { 429 | ui->frame_client_off->setEnabled(false); //离线客户不能选择 430 | ui->cb_client_off->setCurrentIndex(0); //回到0 431 | for(int i=0; iusername == ui->cb_client_on->currentText()) 434 | { 435 | ui->lineEditIp->setText(v[i]->ip); 436 | ui->lineEditPort->setText(QString("%1").arg(v[i]->port)); //获得他的服务器端的port 437 | } 438 | } 439 | } 440 | 441 | } 442 | else 443 | { 444 | ui->frame_client_off->setEnabled(true); //如果index==0 离线客户区可以编辑 445 | } 446 | } 447 | 448 | void ClientWidget::on_bt_connect_client_clicked() //连接客户 449 | { 450 | if(ui->cb_client_on->currentIndex() != 0) 451 | { 452 | for(int i=0; iusername == ui->cb_client_on->currentText()) //找到对方的监听端口,对方的ip和port 455 | { 456 | if(v[i]->hasbeenConnected) 457 | { 458 | QMessageBox::information(this,"提示", "已经连接上了!"); 459 | return; //直接退出 460 | } 461 | } 462 | } 463 | QString contact = QString("%1##request for contact##%2").arg(name).arg(ui->cb_client_on->currentText()); //用户名发送过去 464 | tcpSocket->write(contact.toUtf8()); 465 | mode = Client; 466 | } 467 | } 468 | 469 | void ClientWidget::on_bt_message_send_clicked() 470 | { 471 | if(ui->le_message->text().trimmed() != "") //消息框不能为空字符 472 | { 473 | QString sendername = name; 474 | QString recvname = ""; 475 | if(ui->cb_client_off->currentIndex() != 0) 476 | { 477 | recvname = ui->cb_client_off->currentText(); 478 | } 479 | else if (ui->cb_client_on->currentIndex() != 0) 480 | { 481 | recvname = ui->cb_client_on->currentText(); 482 | } 483 | else //都是无 484 | { 485 | ui->textBrowser->append("请选择有效发送对象!"); 486 | return; 487 | } 488 | QString sendmessage = sendername.append(QString("##%1##").arg(ui->le_message->text()).append(recvname)); 489 | tcpSocket->write(sendmessage.toUtf8()); //发送信息 490 | qDebug() << "server send message!"; 491 | QString mymessage = QString("%1 to %2 : %3").arg(name).arg(recvname). 492 | arg(ui->le_message->text()); //显示我的信息 493 | ui->textBrowser->append("--------------" + QTime::currentTime().toString("hh:mm:ss") + "--------------"); 494 | ui->textBrowser->append(mymessage); 495 | ui->le_message->clear(); //发送完清空le 496 | } 497 | } 498 | -------------------------------------------------------------------------------- /Client/clientwidget - 副本 (2).h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENTWIDGET_H 2 | #define CLIENTWIDGET_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #define BUF_SIZE 1024*4 10 | 11 | namespace Ui { 12 | class clientwidget; 13 | } 14 | 15 | class ClientWidget : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit ClientWidget(QWidget *parent = 0); 21 | ~ClientWidget(); 22 | 23 | private slots: 24 | void on_buttonConnect_clicked(); 25 | 26 | void on_buttonClose_clicked(); 27 | 28 | 29 | void on_cb_client_off_currentIndexChanged(int index); 30 | 31 | void on_cb_client_on_currentIndexChanged(int index); 32 | 33 | void on_bt_message_send_clicked(); 34 | 35 | void on_bt_connect_client_clicked(); 36 | 37 | void connect_failure(); 38 | 39 | private: 40 | Ui::clientwidget *ui; 41 | QTcpSocket * tcpSocket; //通信 42 | QTimer* timer; //定时器 43 | }; 44 | 45 | #endif // CLIENTWIDGET_H 46 | -------------------------------------------------------------------------------- /Client/clientwidget - 副本 (2).ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | clientwidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 828 10 | 530 11 | 12 | 13 | 14 | clientwidget 15 | 16 | 17 | false 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 0 26 | 0 27 | 831 28 | 531 29 | 30 | 31 | 32 | #frame {background-image: url(:/new/prefix1/image/back.jpg);} 33 | 34 | 35 | QFrame::StyledPanel 36 | 37 | 38 | QFrame::Raised 39 | 40 | 41 | 42 | 43 | 240 44 | 10 45 | 231 46 | 111 47 | 48 | 49 | 50 | QFrame::StyledPanel 51 | 52 | 53 | QFrame::Raised 54 | 55 | 56 | 57 | 58 | 10 59 | 80 60 | 72 61 | 15 62 | 63 | 64 | 65 | 端口号: 66 | 67 | 68 | 69 | 70 | 71 | 70 72 | 10 73 | 151 74 | 21 75 | 76 | 77 | 78 | 79 | 80 | 81 | 70 82 | 80 83 | 151 84 | 21 85 | 86 | 87 | 88 | 89 | 90 | 91 | 10 92 | 10 93 | 31 94 | 21 95 | 96 | 97 | 98 | ip: 99 | 100 | 101 | 102 | 103 | 104 | 100 105 | 40 106 | 91 107 | 31 108 | 109 | 110 | 111 | 连接服务器 112 | 113 | 114 | 115 | 116 | 117 | 118 | 70 119 | 290 120 | 101 121 | 41 122 | 123 | 124 | 125 | font: 75 18pt "Agency FB"; 126 | 127 | 128 | 客户端 129 | 130 | 131 | 132 | 133 | 134 | 110 135 | 10 136 | 101 137 | 131 138 | 139 | 140 | 141 | QFrame::StyledPanel 142 | 143 | 144 | QFrame::Raised 145 | 146 | 147 | 148 | 149 | 0 150 | 30 151 | 101 152 | 21 153 | 154 | 155 | 156 | 157 | (无) 158 | 159 | 160 | 161 | 162 | 163 | false 164 | 165 | 166 | 167 | 0 168 | 0 169 | 101 170 | 21 171 | 172 | 173 | 174 | 175 | 176 | 177 | 0 178 | 60 179 | 101 180 | 31 181 | 182 | 183 | 184 | 私聊 185 | 186 | 187 | 188 | 189 | 190 | 191 | 400 192 | 130 193 | 391 194 | 341 195 | 196 | 197 | 198 | QFrame::StyledPanel 199 | 200 | 201 | QFrame::Raised 202 | 203 | 204 | 205 | 206 | 0 207 | 0 208 | 391 209 | 291 210 | 211 | 212 | 213 | selection-color: rgb(85, 255, 127); 214 | background-image: url(:/new/prefix1/image/766971.jpg); 215 | font: 12pt "楷体"; 216 | 217 | 218 | 219 | 220 | 221 | 260 222 | 310 223 | 93 224 | 28 225 | 226 | 227 | 228 | 发送消息 229 | 230 | 231 | 232 | 233 | 234 | 0 235 | 310 236 | 221 237 | 31 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 110 246 | 150 247 | 101 248 | 51 249 | 250 | 251 | 252 | QFrame::StyledPanel 253 | 254 | 255 | QFrame::Raised 256 | 257 | 258 | 259 | 260 | 0 261 | 30 262 | 101 263 | 21 264 | 265 | 266 | 267 | 268 | (无) 269 | 270 | 271 | 272 | 273 | 274 | false 275 | 276 | 277 | 278 | 0 279 | 0 280 | 101 281 | 21 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 470 290 | 10 291 | 351 292 | 111 293 | 294 | 295 | 296 | QFrame::StyledPanel 297 | 298 | 299 | QFrame::Raised 300 | 301 | 302 | 303 | false 304 | 305 | 306 | 307 | 140 308 | 10 309 | 91 310 | 21 311 | 312 | 313 | 314 | 315 | 316 | false 317 | 318 | 319 | 320 | 140 321 | 40 322 | 91 323 | 21 324 | 325 | 326 | 327 | 328 | 329 | 330 | 0 331 | 10 332 | 111 333 | 21 334 | 335 | 336 | 337 | 服务器连接状态: 338 | 339 | 340 | 341 | 342 | 343 | 240 344 | 10 345 | 111 346 | 21 347 | 348 | 349 | 350 | 断开服务器连接 351 | 352 | 353 | 354 | 355 | 356 | 10 357 | 40 358 | 72 359 | 15 360 | 361 | 362 | 363 | 用户名: 364 | 365 | 366 | 367 | 368 | 369 | 370 | 10 371 | 10 372 | 101 373 | 20 374 | 375 | 376 | 377 | 在线用户数量: 378 | 379 | 380 | 381 | 382 | 383 | 10 384 | 150 385 | 101 386 | 20 387 | 388 | 389 | 390 | 离线用户数量: 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | -------------------------------------------------------------------------------- /Client/clientwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENTWIDGET_H 2 | #define CLIENTWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define BUF_SIZE 1024*4 11 | 12 | namespace Ui { 13 | class clientwidget; 14 | } 15 | 16 | class ClientWidget : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit ClientWidget(QWidget *parent = 0); 22 | ~ClientWidget(); 23 | 24 | private slots: 25 | void on_buttonConnect_clicked(); 26 | 27 | void on_buttonClose_clicked(); 28 | 29 | 30 | void on_cb_client_off_currentIndexChanged(int index); 31 | 32 | void on_cb_client_on_currentIndexChanged(int index); 33 | 34 | void on_bt_message_send_clicked(); 35 | 36 | void on_bt_connect_client_clicked(); 37 | 38 | void on_bt_disconnect_client_clicked(); 39 | 40 | void on_bt_file_send_clicked(); 41 | 42 | void connect_failure(); 43 | 44 | private: 45 | Ui::clientwidget *ui; 46 | QTcpServer * tcpServer; //监听 47 | QTcpSocket * tcpSocket; //通信 48 | QTcpSocket * tcpSocket_client; //客户机通讯 49 | 50 | QTimer* timer; //定时器 51 | }; 52 | 53 | #endif // CLIENTWIDGET_H 54 | -------------------------------------------------------------------------------- /Client/clientwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | clientwidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 828 10 | 530 11 | 12 | 13 | 14 | clientwidget 15 | 16 | 17 | false 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 0 26 | 0 27 | 831 28 | 531 29 | 30 | 31 | 32 | #frame {background-image: url(:/new/prefix1/image/back.jpg);} 33 | 34 | 35 | QFrame::StyledPanel 36 | 37 | 38 | QFrame::Raised 39 | 40 | 41 | 42 | 43 | 240 44 | 10 45 | 231 46 | 111 47 | 48 | 49 | 50 | QFrame::StyledPanel 51 | 52 | 53 | QFrame::Raised 54 | 55 | 56 | 57 | 58 | 10 59 | 80 60 | 72 61 | 15 62 | 63 | 64 | 65 | 端口号: 66 | 67 | 68 | 69 | 70 | 71 | 70 72 | 10 73 | 151 74 | 21 75 | 76 | 77 | 78 | 79 | 80 | 81 | 70 82 | 80 83 | 151 84 | 21 85 | 86 | 87 | 88 | 89 | 90 | 91 | 10 92 | 10 93 | 31 94 | 21 95 | 96 | 97 | 98 | ip: 99 | 100 | 101 | 102 | 103 | 104 | 100 105 | 40 106 | 91 107 | 31 108 | 109 | 110 | 111 | 连接服务器 112 | 113 | 114 | 115 | 116 | 117 | 118 | 70 119 | 290 120 | 101 121 | 41 122 | 123 | 124 | 125 | font: 75 18pt "Agency FB"; 126 | 127 | 128 | 客户端 129 | 130 | 131 | 132 | 133 | 134 | 660 135 | 480 136 | 93 137 | 28 138 | 139 | 140 | 141 | 发送文件 142 | 143 | 144 | 145 | 146 | 147 | 110 148 | 10 149 | 101 150 | 131 151 | 152 | 153 | 154 | QFrame::StyledPanel 155 | 156 | 157 | QFrame::Raised 158 | 159 | 160 | 161 | 162 | 0 163 | 30 164 | 101 165 | 21 166 | 167 | 168 | 169 | 170 | (无) 171 | 172 | 173 | 174 | 175 | 176 | false 177 | 178 | 179 | 180 | 0 181 | 0 182 | 101 183 | 21 184 | 185 | 186 | 187 | 188 | 189 | 190 | 0 191 | 60 192 | 101 193 | 31 194 | 195 | 196 | 197 | 连接在线用户 198 | 199 | 200 | 201 | 202 | 203 | 0 204 | 100 205 | 101 206 | 31 207 | 208 | 209 | 210 | 断开在线连接 211 | 212 | 213 | 214 | 215 | 216 | 217 | 400 218 | 130 219 | 391 220 | 341 221 | 222 | 223 | 224 | QFrame::StyledPanel 225 | 226 | 227 | QFrame::Raised 228 | 229 | 230 | 231 | 232 | 0 233 | 0 234 | 391 235 | 291 236 | 237 | 238 | 239 | selection-color: rgb(85, 255, 127); 240 | background-image: url(:/new/prefix1/image/766971.jpg); 241 | font: 12pt "楷体"; 242 | 243 | 244 | 245 | 246 | 247 | 260 248 | 310 249 | 93 250 | 28 251 | 252 | 253 | 254 | 发送消息 255 | 256 | 257 | 258 | 259 | 260 | 0 261 | 310 262 | 221 263 | 31 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 110 272 | 150 273 | 101 274 | 51 275 | 276 | 277 | 278 | QFrame::StyledPanel 279 | 280 | 281 | QFrame::Raised 282 | 283 | 284 | 285 | 286 | 0 287 | 30 288 | 101 289 | 21 290 | 291 | 292 | 293 | 294 | (无) 295 | 296 | 297 | 298 | 299 | 300 | false 301 | 302 | 303 | 304 | 0 305 | 0 306 | 101 307 | 21 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 470 316 | 10 317 | 351 318 | 111 319 | 320 | 321 | 322 | QFrame::StyledPanel 323 | 324 | 325 | QFrame::Raised 326 | 327 | 328 | 329 | false 330 | 331 | 332 | 333 | 140 334 | 10 335 | 91 336 | 21 337 | 338 | 339 | 340 | 341 | 342 | false 343 | 344 | 345 | 346 | 140 347 | 40 348 | 91 349 | 21 350 | 351 | 352 | 353 | 354 | 355 | 356 | 0 357 | 10 358 | 111 359 | 21 360 | 361 | 362 | 363 | 服务器连接状态: 364 | 365 | 366 | 367 | 368 | 369 | 240 370 | 10 371 | 111 372 | 21 373 | 374 | 375 | 376 | 断开服务器连接 377 | 378 | 379 | 380 | 381 | 382 | 10 383 | 40 384 | 72 385 | 15 386 | 387 | 388 | 389 | 用户名: 390 | 391 | 392 | 393 | 394 | 395 | 0 396 | 70 397 | 91 398 | 16 399 | 400 | 401 | 402 | 点对点连接: 403 | 404 | 405 | 406 | 407 | false 408 | 409 | 410 | 411 | 140 412 | 70 413 | 91 414 | 21 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 10 423 | 10 424 | 101 425 | 20 426 | 427 | 428 | 429 | 在线用户数量: 430 | 431 | 432 | 433 | 434 | 435 | 10 436 | 150 437 | 101 438 | 20 439 | 440 | 441 | 442 | 离线用户数量: 443 | 444 | 445 | frame_ip 446 | label 447 | bt_file_send 448 | frame_client_on 449 | frame_message 450 | frame_client_off 451 | frame_state 452 | label_7 453 | label_8 454 | label_8 455 | 456 | 457 | 458 | 459 | 460 | 461 | -------------------------------------------------------------------------------- /Client/debug/client.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/debug/client.exe -------------------------------------------------------------------------------- /Client/findpassword.cpp: -------------------------------------------------------------------------------- 1 | #include "findpassword.h" 2 | #include "ui_findpassword.h" 3 | #include 4 | extern QString myquestion; 5 | extern QString myanswer; 6 | findpassword::findpassword(QWidget *parent) : 7 | QDialog(parent), 8 | ui(new Ui::findpassword) 9 | { 10 | ui->setupUi(this); 11 | ui->bt_find->setEnabled(false); 12 | ui->le_question->setText(myquestion); 13 | } 14 | 15 | findpassword::~findpassword() 16 | { 17 | delete ui; 18 | } 19 | 20 | void findpassword::on_le_answer_textChanged(const QString &arg1) 21 | { 22 | if(arg1.trimmed()=="") 23 | { 24 | QMessageBox::warning(this, "Warning!", "答案不为空!", QMessageBox::Yes); 25 | } 26 | else 27 | ui->bt_find->setEnabled(true); 28 | } 29 | 30 | void findpassword::on_bt_find_clicked() 31 | { 32 | myanswer = QString("answer##%1").arg(ui->le_answer->text()); 33 | close(); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /Client/findpassword.h: -------------------------------------------------------------------------------- 1 | #ifndef FINDPASSWORD_H 2 | #define FINDPASSWORD_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class findpassword; 8 | } 9 | 10 | class findpassword : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit findpassword(QWidget *parent = 0); 16 | ~findpassword(); 17 | 18 | private slots: 19 | void on_le_answer_textChanged(const QString &arg1); 20 | 21 | void on_bt_find_clicked(); 22 | 23 | private: 24 | Ui::findpassword *ui; 25 | }; 26 | 27 | #endif // FINDPASSWORD_H 28 | -------------------------------------------------------------------------------- /Client/findpassword.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | findpassword 4 | 5 | 6 | 7 | 0 8 | 0 9 | 465 10 | 358 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 260 20 | 230 21 | 93 22 | 28 23 | 24 | 25 | 26 | 找回密码 27 | 28 | 29 | 30 | 31 | 32 | 70 33 | 90 34 | 72 35 | 15 36 | 37 | 38 | 39 | 密码问题: 40 | 41 | 42 | 43 | 44 | 45 | 70 46 | 160 47 | 72 48 | 15 49 | 50 | 51 | 52 | 密码答案: 53 | 54 | 55 | 56 | 57 | false 58 | 59 | 60 | 61 | 160 62 | 90 63 | 201 64 | 21 65 | 66 | 67 | 68 | 69 | 70 | 71 | 160 72 | 150 73 | 201 74 | 21 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /Client/image/766971.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/image/766971.jpg -------------------------------------------------------------------------------- /Client/image/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/image/back.jpg -------------------------------------------------------------------------------- /Client/logindialog.cpp: -------------------------------------------------------------------------------- 1 | #include "logindialog.h" 2 | #include "ui_logindialog.h" 3 | #include "register.h" 4 | 5 | extern bool isfind; 6 | extern QString loginmessage; //发送给服务器的信息 7 | LoginDialog::LoginDialog(QWidget *parent) : 8 | QDialog(parent), 9 | ui(new Ui::LoginDialog) 10 | { 11 | ui->setupUi(this); 12 | connect(this, &LoginDialog::require_register, this, &LoginDialog::open_register); 13 | } 14 | 15 | LoginDialog::~LoginDialog() 16 | { 17 | delete ui; 18 | } 19 | 20 | void LoginDialog::on_login_pushButton_clicked() 21 | { 22 | if (ui->user_lineEdit->text().trimmed() != "" && 23 | ui->pwd_lineEdit->text() != "") 24 | { 25 | isfind = false; 26 | loginmessage = QString("login##%1##%2").arg(ui->user_lineEdit->text()).arg(ui->pwd_lineEdit->text()); 27 | close();//都需要直接关闭这个窗口 28 | } 29 | else 30 | { 31 | QMessageBox::warning(this, "Warning!", "用户名或密码不为空", QMessageBox::Yes); 32 | ui->user_lineEdit->clear(); 33 | ui->pwd_lineEdit->clear(); 34 | ui->user_lineEdit->setFocus(); 35 | } 36 | } 37 | 38 | void LoginDialog::on_register_pushButton_clicked() 39 | { 40 | emit require_register(); 41 | } 42 | 43 | void LoginDialog::open_register() 44 | { 45 | isfind = false; 46 | Register * dlg = new Register(); 47 | dlg->exec(); 48 | close();//都需要直接关闭这个窗口 49 | } 50 | 51 | void LoginDialog::on_find_pushButton_clicked() 52 | { 53 | if(ui->user_lineEdit->text().trimmed() != "") 54 | { 55 | isfind = true; 56 | loginmessage = QString("find##%1").arg(ui->user_lineEdit->text()); //找回密码 57 | close(); //都需要直接关闭这个窗口 58 | } 59 | else 60 | { 61 | QMessageBox::warning(this, "Warning!", "请输入用户名", QMessageBox::Yes); 62 | ui->user_lineEdit->clear(); 63 | ui->user_lineEdit->setFocus(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Client/logindialog.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGINDIALOG_H 2 | #define LOGINDIALOG_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class LoginDialog; 9 | } 10 | 11 | class LoginDialog : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit LoginDialog(QWidget *parent = 0); 17 | ~LoginDialog(); 18 | 19 | signals: 20 | void require_register(); 21 | 22 | private slots: 23 | 24 | void on_login_pushButton_clicked(); 25 | 26 | void on_register_pushButton_clicked(); 27 | 28 | void open_register(); 29 | 30 | void on_find_pushButton_clicked(); 31 | 32 | private: 33 | Ui::LoginDialog *ui; 34 | }; 35 | 36 | #endif // LOGINDIALOG_H 37 | -------------------------------------------------------------------------------- /Client/logindialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | LoginDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 465 10 | 323 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 140 20 | 40 21 | 221 22 | 31 23 | 24 | 25 | 26 | font: 25 14pt "等线 Light"; 27 | 28 | 29 | 欢迎使用咚咚 30 | 31 | 32 | Qt::AlignCenter 33 | 34 | 35 | 36 | 37 | 38 | 91 39 | 89 40 | 51 41 | 81 42 | 43 | 44 | 45 | Qt::Vertical 46 | 47 | 48 | 49 | font: 25 10pt "等线 Light"; 50 | 51 | 52 | 账户 53 | 54 | 55 | 56 | 57 | font: 25 10pt "等线 Light"; 58 | 59 | 60 | 密码 61 | 62 | 63 | 64 | 65 | 66 | 67 | 140 68 | 90 69 | 231 70 | 81 71 | 72 | 73 | 74 | Qt::Vertical 75 | 76 | 77 | 78 | font: 25 10pt "等线 Light"; 79 | 80 | 81 | 请输入账号 82 | 83 | 84 | 85 | 86 | font: 25 10pt "等线 Light"; 87 | 88 | 89 | QLineEdit::Password 90 | 91 | 92 | 输入密码 93 | 94 | 95 | 96 | 97 | 98 | 99 | 60 100 | 190 101 | 101 102 | 51 103 | 104 | 105 | 106 | 107 | 108 | 109 | 登录 110 | 111 | 112 | 113 | 114 | 115 | 180 116 | 190 117 | 111 118 | 51 119 | 120 | 121 | 122 | 123 | 124 | 125 | 注册 126 | 127 | 128 | 129 | 130 | 131 | 310 132 | 190 133 | 111 134 | 51 135 | 136 | 137 | 138 | 139 | 140 | 141 | 找回密码 142 | 143 | 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /Client/main.cpp: -------------------------------------------------------------------------------- 1 | #include "clientwidget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ClientWidget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Client/object_script.client.Debug: -------------------------------------------------------------------------------- 1 | INPUT( 2 | ./debug\clientwidget.o 3 | ./debug\findpassword.o 4 | ./debug\logindialog.o 5 | ./debug\main.o 6 | ./debug\register.o 7 | ./debug\sendfile.o 8 | ./debug\user_imformation.o 9 | ./debug\qrc_src.o 10 | ./debug\moc_clientwidget.o 11 | ./debug\moc_findpassword.o 12 | ./debug\moc_logindialog.o 13 | ./debug\moc_register.o 14 | ./debug\moc_sendfile.o 15 | ); 16 | -------------------------------------------------------------------------------- /Client/object_script.client.Release: -------------------------------------------------------------------------------- 1 | INPUT( 2 | ./release\clientwidget.o 3 | ./release\findpassword.o 4 | ./release\logindialog.o 5 | ./release\main.o 6 | ./release\register.o 7 | ./release\sendfile.o 8 | ./release\user_imformation.o 9 | ./release\qrc_src.o 10 | ./release\moc_clientwidget.o 11 | ./release\moc_findpassword.o 12 | ./release\moc_logindialog.o 13 | ./release\moc_register.o 14 | ./release\moc_sendfile.o 15 | ); 16 | -------------------------------------------------------------------------------- /Client/register.cpp: -------------------------------------------------------------------------------- 1 | #include "register.h" 2 | #include "ui_register.h" 3 | #include 4 | #include 5 | extern QString loginmessage; //发送给服务器的信息 6 | Register::Register(QWidget *parent) : 7 | QDialog(parent), 8 | ui(new Ui::Register) 9 | { 10 | ui->setupUi(this); 11 | ui->Button_reg->setEnabled(false); 12 | } 13 | 14 | Register::~Register() 15 | { 16 | delete ui; 17 | } 18 | 19 | void Register::on_Button_accept_clicked() 20 | { 21 | ui->Button_reg->setText("注册"); 22 | ui->Button_reg->setEnabled(true); 23 | } 24 | 25 | void Register::on_Button_reject_clicked() 26 | { 27 | ui->Button_reg->setText("退出"); 28 | ui->Button_reg->setEnabled(true); 29 | } 30 | 31 | void Register::on_Button_reg_clicked() 32 | { 33 | if (ui->Button_reg->text() == "退出") //退出 34 | close(); 35 | else if(ui->le_user->text().trimmed() != "" && ui->le_password->text().trimmed() != "" && ui->le_question->text().trimmed() != "" && ui->le_answer->text().trimmed() != "" ) 36 | { 37 | loginmessage = QString("register##%1##%2##%3##%4").arg(ui->le_user->text()) 38 | .arg(ui->le_password->text()).arg(ui->le_question->text()).arg(ui->le_answer->text()); 39 | close(); 40 | } 41 | else 42 | { 43 | QMessageBox::warning(this, "Warning!", "任何一项不能为空", QMessageBox::Yes); 44 | ui->le_user->clear(); 45 | ui->le_password->clear(); 46 | ui->le_question->clear(); 47 | ui->le_answer->clear(); 48 | ui->le_user->setFocus(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Client/register.h: -------------------------------------------------------------------------------- 1 | #ifndef REGISTER_H 2 | #define REGISTER_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class Register; 8 | } 9 | 10 | class Register : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit Register(QWidget *parent = 0); 16 | ~Register(); 17 | 18 | 19 | 20 | private slots: 21 | 22 | void on_Button_accept_clicked(); 23 | 24 | void on_Button_reject_clicked(); 25 | 26 | void on_Button_reg_clicked(); 27 | 28 | private: 29 | Ui::Register *ui; 30 | }; 31 | 32 | #endif // REGISTER_H 33 | -------------------------------------------------------------------------------- /Client/register.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Register 4 | 5 | 6 | 7 | 0 8 | 0 9 | 538 10 | 398 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 190 20 | 250 21 | 125 22 | 70 23 | 24 | 25 | 26 | 27 | 0 28 | 0 29 | 30 | 31 | 32 | 33 | 125 34 | 70 35 | 36 | 37 | 38 | 39 | 125 40 | 71 41 | 42 | 43 | 44 | true 45 | 46 | 47 | 48 | 49 | 50 | Qt::Vertical 51 | 52 | 53 | 54 | 55 | 125 56 | 30 57 | 58 | 59 | 60 | Qt::Horizontal 61 | 62 | 63 | 64 | 65 | 0 66 | 0 67 | 68 | 69 | 70 | 71 | 60 72 | 30 73 | 74 | 75 | 76 | 77 | 60 78 | 30 79 | 80 | 81 | 82 | 83 | 84 | 85 | 同意 86 | 87 | 88 | 89 | 90 | 91 | 0 92 | 0 93 | 94 | 95 | 96 | 97 | 60 98 | 30 99 | 100 | 101 | 102 | 103 | 60 104 | 30 105 | 106 | 107 | 108 | 拒绝 109 | 110 | 111 | 112 | 113 | 114 | 115 | 0 116 | 0 117 | 118 | 119 | 120 | 121 | 84 122 | 35 123 | 124 | 125 | 126 | 127 | 125 128 | 35 129 | 130 | 131 | 132 | QPushButton { 133 | border: 2px solid #8f8f91; 134 | border-radius: 6px; 135 | background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, 136 | stop: 0 #f6f7fa, stop: 1 #dadbde); 137 | min-width: 80px; 138 | } 139 | 140 | QPushButton:pressed { 141 | background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, 142 | stop: 0 #dadbde, stop: 1 #f6f7fa); 143 | } 144 | 145 | QPushButton:flat { 146 | border: none; /* no border for a flat push button */ 147 | } 148 | 149 | QPushButton:default { 150 | border-color: navy; /* make the default button prominent */ 151 | } 152 | 153 | 154 | 注册 155 | 156 | 157 | 158 | 159 | 160 | 161 | 300 162 | 50 163 | 211 164 | 151 165 | 166 | 167 | 168 | font: 25 11pt "等线 Light"; 169 | 170 | 171 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> 172 | <html><head><meta name="qrichtext" content="1" /><style type="text/css"> 173 | p, li { white-space: pre-wrap; } 174 | </style></head><body style=" font-family:'等线 Light'; font-size:11pt; font-weight:24; font-style:normal;"> 175 | <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun'; font-size:9pt; font-weight:400;">注册须知:</span></p> 176 | <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun'; font-size:9pt; font-weight:400;">同学您好!欢迎加入咚咚。</span></p> 177 | <p style="-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'SimSun'; font-size:9pt; font-weight:400;"><br /></p> 178 | <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'SimSun'; font-size:9pt; font-weight:400;">以上便是您需要遵循的使用规则,同意条文,才可继续注册!</span></p></body></html> 179 | 180 | 181 | 182 | 183 | 184 | 30 185 | 50 186 | 81 187 | 161 188 | 189 | 190 | 191 | 192 | 193 | 194 | 用户名 195 | 196 | 197 | 198 | 199 | 200 | 201 | 密码 202 | 203 | 204 | 205 | 206 | 207 | 208 | 密码问题 209 | 210 | 211 | 212 | 213 | 214 | 215 | 密码答案 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 120 225 | 50 226 | 151 227 | 161 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | QLineEdit::Password 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | -------------------------------------------------------------------------------- /Client/release/client.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/client.exe -------------------------------------------------------------------------------- /Client/release/clientwidget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/clientwidget.o -------------------------------------------------------------------------------- /Client/release/findpassword.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/findpassword.o -------------------------------------------------------------------------------- /Client/release/logindialog.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/logindialog.o -------------------------------------------------------------------------------- /Client/release/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/main.o -------------------------------------------------------------------------------- /Client/release/moc_clientwidget.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Meta object code from reading C++ file 'clientwidget.h' 3 | ** 4 | ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.8.0) 5 | ** 6 | ** WARNING! All changes made in this file will be lost! 7 | *****************************************************************************/ 8 | 9 | #include "../clientwidget.h" 10 | #include 11 | #include 12 | #if !defined(Q_MOC_OUTPUT_REVISION) 13 | #error "The header file 'clientwidget.h' doesn't include ." 14 | #elif Q_MOC_OUTPUT_REVISION != 67 15 | #error "This file was generated using the moc from 5.8.0. It" 16 | #error "cannot be used with the include files from this version of Qt." 17 | #error "(The moc has changed too much.)" 18 | #endif 19 | 20 | QT_BEGIN_MOC_NAMESPACE 21 | QT_WARNING_PUSH 22 | QT_WARNING_DISABLE_DEPRECATED 23 | struct qt_meta_stringdata_ClientWidget_t { 24 | QByteArrayData data[12]; 25 | char stringdata0[269]; 26 | }; 27 | #define QT_MOC_LITERAL(idx, ofs, len) \ 28 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ 29 | qptrdiff(offsetof(qt_meta_stringdata_ClientWidget_t, stringdata0) + ofs \ 30 | - idx * sizeof(QByteArrayData)) \ 31 | ) 32 | static const qt_meta_stringdata_ClientWidget_t qt_meta_stringdata_ClientWidget = { 33 | { 34 | QT_MOC_LITERAL(0, 0, 12), // "ClientWidget" 35 | QT_MOC_LITERAL(1, 13, 24), // "on_buttonConnect_clicked" 36 | QT_MOC_LITERAL(2, 38, 0), // "" 37 | QT_MOC_LITERAL(3, 39, 22), // "on_buttonClose_clicked" 38 | QT_MOC_LITERAL(4, 62, 36), // "on_cb_client_off_currentIndex..." 39 | QT_MOC_LITERAL(5, 99, 5), // "index" 40 | QT_MOC_LITERAL(6, 105, 35), // "on_cb_client_on_currentIndexC..." 41 | QT_MOC_LITERAL(7, 141, 26), // "on_bt_message_send_clicked" 42 | QT_MOC_LITERAL(8, 168, 28), // "on_bt_connect_client_clicked" 43 | QT_MOC_LITERAL(9, 197, 31), // "on_bt_disconnect_client_clicked" 44 | QT_MOC_LITERAL(10, 229, 23), // "on_bt_file_send_clicked" 45 | QT_MOC_LITERAL(11, 253, 15) // "connect_failure" 46 | 47 | }, 48 | "ClientWidget\0on_buttonConnect_clicked\0" 49 | "\0on_buttonClose_clicked\0" 50 | "on_cb_client_off_currentIndexChanged\0" 51 | "index\0on_cb_client_on_currentIndexChanged\0" 52 | "on_bt_message_send_clicked\0" 53 | "on_bt_connect_client_clicked\0" 54 | "on_bt_disconnect_client_clicked\0" 55 | "on_bt_file_send_clicked\0connect_failure" 56 | }; 57 | #undef QT_MOC_LITERAL 58 | 59 | static const uint qt_meta_data_ClientWidget[] = { 60 | 61 | // content: 62 | 7, // revision 63 | 0, // classname 64 | 0, 0, // classinfo 65 | 9, 14, // methods 66 | 0, 0, // properties 67 | 0, 0, // enums/sets 68 | 0, 0, // constructors 69 | 0, // flags 70 | 0, // signalCount 71 | 72 | // slots: name, argc, parameters, tag, flags 73 | 1, 0, 59, 2, 0x08 /* Private */, 74 | 3, 0, 60, 2, 0x08 /* Private */, 75 | 4, 1, 61, 2, 0x08 /* Private */, 76 | 6, 1, 64, 2, 0x08 /* Private */, 77 | 7, 0, 67, 2, 0x08 /* Private */, 78 | 8, 0, 68, 2, 0x08 /* Private */, 79 | 9, 0, 69, 2, 0x08 /* Private */, 80 | 10, 0, 70, 2, 0x08 /* Private */, 81 | 11, 0, 71, 2, 0x08 /* Private */, 82 | 83 | // slots: parameters 84 | QMetaType::Void, 85 | QMetaType::Void, 86 | QMetaType::Void, QMetaType::Int, 5, 87 | QMetaType::Void, QMetaType::Int, 5, 88 | QMetaType::Void, 89 | QMetaType::Void, 90 | QMetaType::Void, 91 | QMetaType::Void, 92 | QMetaType::Void, 93 | 94 | 0 // eod 95 | }; 96 | 97 | void ClientWidget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) 98 | { 99 | if (_c == QMetaObject::InvokeMetaMethod) { 100 | ClientWidget *_t = static_cast(_o); 101 | Q_UNUSED(_t) 102 | switch (_id) { 103 | case 0: _t->on_buttonConnect_clicked(); break; 104 | case 1: _t->on_buttonClose_clicked(); break; 105 | case 2: _t->on_cb_client_off_currentIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break; 106 | case 3: _t->on_cb_client_on_currentIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break; 107 | case 4: _t->on_bt_message_send_clicked(); break; 108 | case 5: _t->on_bt_connect_client_clicked(); break; 109 | case 6: _t->on_bt_disconnect_client_clicked(); break; 110 | case 7: _t->on_bt_file_send_clicked(); break; 111 | case 8: _t->connect_failure(); break; 112 | default: ; 113 | } 114 | } 115 | } 116 | 117 | const QMetaObject ClientWidget::staticMetaObject = { 118 | { &QWidget::staticMetaObject, qt_meta_stringdata_ClientWidget.data, 119 | qt_meta_data_ClientWidget, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} 120 | }; 121 | 122 | 123 | const QMetaObject *ClientWidget::metaObject() const 124 | { 125 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; 126 | } 127 | 128 | void *ClientWidget::qt_metacast(const char *_clname) 129 | { 130 | if (!_clname) return Q_NULLPTR; 131 | if (!strcmp(_clname, qt_meta_stringdata_ClientWidget.stringdata0)) 132 | return static_cast(const_cast< ClientWidget*>(this)); 133 | return QWidget::qt_metacast(_clname); 134 | } 135 | 136 | int ClientWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) 137 | { 138 | _id = QWidget::qt_metacall(_c, _id, _a); 139 | if (_id < 0) 140 | return _id; 141 | if (_c == QMetaObject::InvokeMetaMethod) { 142 | if (_id < 9) 143 | qt_static_metacall(this, _c, _id, _a); 144 | _id -= 9; 145 | } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { 146 | if (_id < 9) 147 | *reinterpret_cast(_a[0]) = -1; 148 | _id -= 9; 149 | } 150 | return _id; 151 | } 152 | QT_WARNING_POP 153 | QT_END_MOC_NAMESPACE 154 | -------------------------------------------------------------------------------- /Client/release/moc_clientwidget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/moc_clientwidget.o -------------------------------------------------------------------------------- /Client/release/moc_findpassword.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Meta object code from reading C++ file 'findpassword.h' 3 | ** 4 | ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.8.0) 5 | ** 6 | ** WARNING! All changes made in this file will be lost! 7 | *****************************************************************************/ 8 | 9 | #include "../findpassword.h" 10 | #include 11 | #include 12 | #if !defined(Q_MOC_OUTPUT_REVISION) 13 | #error "The header file 'findpassword.h' doesn't include ." 14 | #elif Q_MOC_OUTPUT_REVISION != 67 15 | #error "This file was generated using the moc from 5.8.0. It" 16 | #error "cannot be used with the include files from this version of Qt." 17 | #error "(The moc has changed too much.)" 18 | #endif 19 | 20 | QT_BEGIN_MOC_NAMESPACE 21 | QT_WARNING_PUSH 22 | QT_WARNING_DISABLE_DEPRECATED 23 | struct qt_meta_stringdata_findpassword_t { 24 | QByteArrayData data[5]; 25 | char stringdata0[63]; 26 | }; 27 | #define QT_MOC_LITERAL(idx, ofs, len) \ 28 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ 29 | qptrdiff(offsetof(qt_meta_stringdata_findpassword_t, stringdata0) + ofs \ 30 | - idx * sizeof(QByteArrayData)) \ 31 | ) 32 | static const qt_meta_stringdata_findpassword_t qt_meta_stringdata_findpassword = { 33 | { 34 | QT_MOC_LITERAL(0, 0, 12), // "findpassword" 35 | QT_MOC_LITERAL(1, 13, 24), // "on_le_answer_textChanged" 36 | QT_MOC_LITERAL(2, 38, 0), // "" 37 | QT_MOC_LITERAL(3, 39, 4), // "arg1" 38 | QT_MOC_LITERAL(4, 44, 18) // "on_bt_find_clicked" 39 | 40 | }, 41 | "findpassword\0on_le_answer_textChanged\0" 42 | "\0arg1\0on_bt_find_clicked" 43 | }; 44 | #undef QT_MOC_LITERAL 45 | 46 | static const uint qt_meta_data_findpassword[] = { 47 | 48 | // content: 49 | 7, // revision 50 | 0, // classname 51 | 0, 0, // classinfo 52 | 2, 14, // methods 53 | 0, 0, // properties 54 | 0, 0, // enums/sets 55 | 0, 0, // constructors 56 | 0, // flags 57 | 0, // signalCount 58 | 59 | // slots: name, argc, parameters, tag, flags 60 | 1, 1, 24, 2, 0x08 /* Private */, 61 | 4, 0, 27, 2, 0x08 /* Private */, 62 | 63 | // slots: parameters 64 | QMetaType::Void, QMetaType::QString, 3, 65 | QMetaType::Void, 66 | 67 | 0 // eod 68 | }; 69 | 70 | void findpassword::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) 71 | { 72 | if (_c == QMetaObject::InvokeMetaMethod) { 73 | findpassword *_t = static_cast(_o); 74 | Q_UNUSED(_t) 75 | switch (_id) { 76 | case 0: _t->on_le_answer_textChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break; 77 | case 1: _t->on_bt_find_clicked(); break; 78 | default: ; 79 | } 80 | } 81 | } 82 | 83 | const QMetaObject findpassword::staticMetaObject = { 84 | { &QDialog::staticMetaObject, qt_meta_stringdata_findpassword.data, 85 | qt_meta_data_findpassword, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} 86 | }; 87 | 88 | 89 | const QMetaObject *findpassword::metaObject() const 90 | { 91 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; 92 | } 93 | 94 | void *findpassword::qt_metacast(const char *_clname) 95 | { 96 | if (!_clname) return Q_NULLPTR; 97 | if (!strcmp(_clname, qt_meta_stringdata_findpassword.stringdata0)) 98 | return static_cast(const_cast< findpassword*>(this)); 99 | return QDialog::qt_metacast(_clname); 100 | } 101 | 102 | int findpassword::qt_metacall(QMetaObject::Call _c, int _id, void **_a) 103 | { 104 | _id = QDialog::qt_metacall(_c, _id, _a); 105 | if (_id < 0) 106 | return _id; 107 | if (_c == QMetaObject::InvokeMetaMethod) { 108 | if (_id < 2) 109 | qt_static_metacall(this, _c, _id, _a); 110 | _id -= 2; 111 | } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { 112 | if (_id < 2) 113 | *reinterpret_cast(_a[0]) = -1; 114 | _id -= 2; 115 | } 116 | return _id; 117 | } 118 | QT_WARNING_POP 119 | QT_END_MOC_NAMESPACE 120 | -------------------------------------------------------------------------------- /Client/release/moc_findpassword.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/moc_findpassword.o -------------------------------------------------------------------------------- /Client/release/moc_logindialog.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Meta object code from reading C++ file 'logindialog.h' 3 | ** 4 | ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.8.0) 5 | ** 6 | ** WARNING! All changes made in this file will be lost! 7 | *****************************************************************************/ 8 | 9 | #include "../logindialog.h" 10 | #include 11 | #include 12 | #if !defined(Q_MOC_OUTPUT_REVISION) 13 | #error "The header file 'logindialog.h' doesn't include ." 14 | #elif Q_MOC_OUTPUT_REVISION != 67 15 | #error "This file was generated using the moc from 5.8.0. It" 16 | #error "cannot be used with the include files from this version of Qt." 17 | #error "(The moc has changed too much.)" 18 | #endif 19 | 20 | QT_BEGIN_MOC_NAMESPACE 21 | QT_WARNING_PUSH 22 | QT_WARNING_DISABLE_DEPRECATED 23 | struct qt_meta_stringdata_LoginDialog_t { 24 | QByteArrayData data[7]; 25 | char stringdata0[130]; 26 | }; 27 | #define QT_MOC_LITERAL(idx, ofs, len) \ 28 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ 29 | qptrdiff(offsetof(qt_meta_stringdata_LoginDialog_t, stringdata0) + ofs \ 30 | - idx * sizeof(QByteArrayData)) \ 31 | ) 32 | static const qt_meta_stringdata_LoginDialog_t qt_meta_stringdata_LoginDialog = { 33 | { 34 | QT_MOC_LITERAL(0, 0, 11), // "LoginDialog" 35 | QT_MOC_LITERAL(1, 12, 16), // "require_register" 36 | QT_MOC_LITERAL(2, 29, 0), // "" 37 | QT_MOC_LITERAL(3, 30, 27), // "on_login_pushButton_clicked" 38 | QT_MOC_LITERAL(4, 58, 30), // "on_register_pushButton_clicked" 39 | QT_MOC_LITERAL(5, 89, 13), // "open_register" 40 | QT_MOC_LITERAL(6, 103, 26) // "on_find_pushButton_clicked" 41 | 42 | }, 43 | "LoginDialog\0require_register\0\0" 44 | "on_login_pushButton_clicked\0" 45 | "on_register_pushButton_clicked\0" 46 | "open_register\0on_find_pushButton_clicked" 47 | }; 48 | #undef QT_MOC_LITERAL 49 | 50 | static const uint qt_meta_data_LoginDialog[] = { 51 | 52 | // content: 53 | 7, // revision 54 | 0, // classname 55 | 0, 0, // classinfo 56 | 5, 14, // methods 57 | 0, 0, // properties 58 | 0, 0, // enums/sets 59 | 0, 0, // constructors 60 | 0, // flags 61 | 1, // signalCount 62 | 63 | // signals: name, argc, parameters, tag, flags 64 | 1, 0, 39, 2, 0x06 /* Public */, 65 | 66 | // slots: name, argc, parameters, tag, flags 67 | 3, 0, 40, 2, 0x08 /* Private */, 68 | 4, 0, 41, 2, 0x08 /* Private */, 69 | 5, 0, 42, 2, 0x08 /* Private */, 70 | 6, 0, 43, 2, 0x08 /* Private */, 71 | 72 | // signals: parameters 73 | QMetaType::Void, 74 | 75 | // slots: parameters 76 | QMetaType::Void, 77 | QMetaType::Void, 78 | QMetaType::Void, 79 | QMetaType::Void, 80 | 81 | 0 // eod 82 | }; 83 | 84 | void LoginDialog::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) 85 | { 86 | if (_c == QMetaObject::InvokeMetaMethod) { 87 | LoginDialog *_t = static_cast(_o); 88 | Q_UNUSED(_t) 89 | switch (_id) { 90 | case 0: _t->require_register(); break; 91 | case 1: _t->on_login_pushButton_clicked(); break; 92 | case 2: _t->on_register_pushButton_clicked(); break; 93 | case 3: _t->open_register(); break; 94 | case 4: _t->on_find_pushButton_clicked(); break; 95 | default: ; 96 | } 97 | } else if (_c == QMetaObject::IndexOfMethod) { 98 | int *result = reinterpret_cast(_a[0]); 99 | void **func = reinterpret_cast(_a[1]); 100 | { 101 | typedef void (LoginDialog::*_t)(); 102 | if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&LoginDialog::require_register)) { 103 | *result = 0; 104 | return; 105 | } 106 | } 107 | } 108 | Q_UNUSED(_a); 109 | } 110 | 111 | const QMetaObject LoginDialog::staticMetaObject = { 112 | { &QDialog::staticMetaObject, qt_meta_stringdata_LoginDialog.data, 113 | qt_meta_data_LoginDialog, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} 114 | }; 115 | 116 | 117 | const QMetaObject *LoginDialog::metaObject() const 118 | { 119 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; 120 | } 121 | 122 | void *LoginDialog::qt_metacast(const char *_clname) 123 | { 124 | if (!_clname) return Q_NULLPTR; 125 | if (!strcmp(_clname, qt_meta_stringdata_LoginDialog.stringdata0)) 126 | return static_cast(const_cast< LoginDialog*>(this)); 127 | return QDialog::qt_metacast(_clname); 128 | } 129 | 130 | int LoginDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a) 131 | { 132 | _id = QDialog::qt_metacall(_c, _id, _a); 133 | if (_id < 0) 134 | return _id; 135 | if (_c == QMetaObject::InvokeMetaMethod) { 136 | if (_id < 5) 137 | qt_static_metacall(this, _c, _id, _a); 138 | _id -= 5; 139 | } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { 140 | if (_id < 5) 141 | *reinterpret_cast(_a[0]) = -1; 142 | _id -= 5; 143 | } 144 | return _id; 145 | } 146 | 147 | // SIGNAL 0 148 | void LoginDialog::require_register() 149 | { 150 | QMetaObject::activate(this, &staticMetaObject, 0, Q_NULLPTR); 151 | } 152 | QT_WARNING_POP 153 | QT_END_MOC_NAMESPACE 154 | -------------------------------------------------------------------------------- /Client/release/moc_logindialog.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/moc_logindialog.o -------------------------------------------------------------------------------- /Client/release/moc_predefs.h: -------------------------------------------------------------------------------- 1 | #define __DBL_MIN_EXP__ (-1021) 2 | #define __cpp_attributes 200809 3 | #define __pentiumpro__ 1 4 | #define __UINT_LEAST16_MAX__ 0xffff 5 | #define __ATOMIC_ACQUIRE 2 6 | #define __FLT_MIN__ 1.17549435082228750797e-38F 7 | #define __GCC_IEC_559_COMPLEX 2 8 | #define __UINT_LEAST8_TYPE__ unsigned char 9 | #define __SIZEOF_FLOAT80__ 12 10 | #define _WIN32 1 11 | #define __INTMAX_C(c) c ## LL 12 | #define __CHAR_BIT__ 8 13 | #define __UINT8_MAX__ 0xff 14 | #define __WINT_MAX__ 0xffff 15 | #define __cpp_static_assert 200410 16 | #define __ORDER_LITTLE_ENDIAN__ 1234 17 | #define __SIZE_MAX__ 0xffffffffU 18 | #define __WCHAR_MAX__ 0xffff 19 | #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 20 | #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 21 | #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 22 | #define __DBL_DENORM_MIN__ double(4.94065645841246544177e-324L) 23 | #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 24 | #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 25 | #define __GCC_IEC_559 2 26 | #define __FLT_EVAL_METHOD__ 2 27 | #define __cpp_binary_literals 201304 28 | #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 29 | #define __cpp_variadic_templates 200704 30 | #define __UINT_FAST64_MAX__ 0xffffffffffffffffULL 31 | #define __SIG_ATOMIC_TYPE__ int 32 | #define __DBL_MIN_10_EXP__ (-307) 33 | #define __FINITE_MATH_ONLY__ 0 34 | #define __GNUC_PATCHLEVEL__ 0 35 | #define __UINT_FAST8_MAX__ 0xff 36 | #define __has_include(STR) __has_include__(STR) 37 | #define _stdcall __attribute__((__stdcall__)) 38 | #define __DEC64_MAX_EXP__ 385 39 | #define __INT8_C(c) c 40 | #define __UINT_LEAST64_MAX__ 0xffffffffffffffffULL 41 | #define __SHRT_MAX__ 0x7fff 42 | #define __LDBL_MAX__ 1.18973149535723176502e+4932L 43 | #define __UINT_LEAST8_MAX__ 0xff 44 | #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 45 | #define __UINTMAX_TYPE__ long long unsigned int 46 | #define __DEC32_EPSILON__ 1E-6DF 47 | #define __OPTIMIZE__ 1 48 | #define __UINT32_MAX__ 0xffffffffU 49 | #define __GXX_EXPERIMENTAL_CXX0X__ 1 50 | #define __LDBL_MAX_EXP__ 16384 51 | #define __WINT_MIN__ 0 52 | #define __SCHAR_MAX__ 0x7f 53 | #define __WCHAR_MIN__ 0 54 | #define __INT64_C(c) c ## LL 55 | #define __DBL_DIG__ 15 56 | #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 57 | #define __SIZEOF_INT__ 4 58 | #define __SIZEOF_POINTER__ 4 59 | #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 60 | #define __USER_LABEL_PREFIX__ _ 61 | #define __STDC_HOSTED__ 1 62 | #define __WIN32 1 63 | #define __LDBL_HAS_INFINITY__ 1 64 | #define __FLT_EPSILON__ 1.19209289550781250000e-7F 65 | #define __GXX_WEAK__ 1 66 | #define __LDBL_MIN__ 3.36210314311209350626e-4932L 67 | #define __DEC32_MAX__ 9.999999E96DF 68 | #define __MINGW32__ 1 69 | #define __INT32_MAX__ 0x7fffffff 70 | #define __SIZEOF_LONG__ 4 71 | #define __UINT16_C(c) c 72 | #define __DECIMAL_DIG__ 21 73 | #define __has_include_next(STR) __has_include_next__(STR) 74 | #define __LDBL_HAS_QUIET_NAN__ 1 75 | #define _REENTRANT 1 76 | #define __GNUC__ 5 77 | #define _cdecl __attribute__((__cdecl__)) 78 | #define __GXX_RTTI 1 79 | #define __cpp_delegating_constructors 200604 80 | #define __FLT_HAS_DENORM__ 1 81 | #define __SIZEOF_LONG_DOUBLE__ 12 82 | #define __BIGGEST_ALIGNMENT__ 16 83 | #define __STDC_UTF_16__ 1 84 | #define __i686 1 85 | #define __DBL_MAX__ double(1.79769313486231570815e+308L) 86 | #define _thiscall __attribute__((__thiscall__)) 87 | #define __cpp_raw_strings 200710 88 | #define __INT_FAST32_MAX__ 0x7fffffff 89 | #define __WINNT 1 90 | #define __DBL_HAS_INFINITY__ 1 91 | #define __INT64_MAX__ 0x7fffffffffffffffLL 92 | #define __WINNT__ 1 93 | #define __DEC32_MIN_EXP__ (-94) 94 | #define __INT_FAST16_TYPE__ short int 95 | #define _fastcall __attribute__((__fastcall__)) 96 | #define __LDBL_HAS_DENORM__ 1 97 | #define __cplusplus 201103L 98 | #define __cpp_ref_qualifiers 200710 99 | #define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL 100 | #define __INT_LEAST32_MAX__ 0x7fffffff 101 | #define __DEC32_MIN__ 1E-95DF 102 | #define __DEPRECATED 1 103 | #define __DBL_MAX_EXP__ 1024 104 | #define __DEC128_EPSILON__ 1E-33DL 105 | #define __ATOMIC_HLE_RELEASE 131072 106 | #define __WIN32__ 1 107 | #define __PTRDIFF_MAX__ 0x7fffffff 108 | #define __ATOMIC_HLE_ACQUIRE 65536 109 | #define __GNUG__ 5 110 | #define __LONG_LONG_MAX__ 0x7fffffffffffffffLL 111 | #define __SIZEOF_SIZE_T__ 4 112 | #define __cpp_rvalue_reference 200610 113 | #define __cpp_nsdmi 200809 114 | #define __SIZEOF_WINT_T__ 2 115 | #define __cpp_initializer_lists 200806 116 | #define __GCC_HAVE_DWARF2_CFI_ASM 1 117 | #define __GXX_ABI_VERSION 1009 118 | #define __FLT_MIN_EXP__ (-125) 119 | #define __i686__ 1 120 | #define __cpp_lambdas 200907 121 | #define __INT_FAST64_TYPE__ long long int 122 | #define __DBL_MIN__ double(2.22507385850720138309e-308L) 123 | #define __FLT_MIN_10_EXP__ (-37) 124 | #define __DECIMAL_BID_FORMAT__ 1 125 | #define __GXX_TYPEINFO_EQUALITY_INLINE 0 126 | #define __DEC128_MIN__ 1E-6143DL 127 | #define __REGISTER_PREFIX__ 128 | #define __UINT16_MAX__ 0xffff 129 | #define __DBL_HAS_DENORM__ 1 130 | #define __cdecl __attribute__((__cdecl__)) 131 | #define __UINT8_TYPE__ unsigned char 132 | #define __i386 1 133 | #define __FLT_MANT_DIG__ 24 134 | #define __VERSION__ "5.3.0" 135 | #define __UINT64_C(c) c ## ULL 136 | #define __cpp_unicode_characters 200704 137 | #define __GCC_ATOMIC_INT_LOCK_FREE 2 138 | #define _X86_ 1 139 | #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ 140 | #define __INT32_C(c) c 141 | #define __DEC64_EPSILON__ 1E-15DD 142 | #define __ORDER_PDP_ENDIAN__ 3412 143 | #define __DEC128_MIN_EXP__ (-6142) 144 | #define __code_model_32__ 1 145 | #define __INT_FAST32_TYPE__ int 146 | #define __UINT_LEAST16_TYPE__ short unsigned int 147 | #define __INT16_MAX__ 0x7fff 148 | #define __i386__ 1 149 | #define __cpp_rtti 199711 150 | #define __SIZE_TYPE__ unsigned int 151 | #define __UINT64_MAX__ 0xffffffffffffffffULL 152 | #define __INT8_TYPE__ signed char 153 | #define __FLT_RADIX__ 2 154 | #define __INT_LEAST16_TYPE__ short int 155 | #define __LDBL_EPSILON__ 1.08420217248550443401e-19L 156 | #define __UINTMAX_C(c) c ## ULL 157 | #define __SIG_ATOMIC_MAX__ 0x7fffffff 158 | #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 159 | #define __SIZEOF_PTRDIFF_T__ 4 160 | #define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF 161 | #define __pentiumpro 1 162 | #define __MSVCRT__ 1 163 | #define __INT_FAST16_MAX__ 0x7fff 164 | #define __UINT_FAST32_MAX__ 0xffffffffU 165 | #define __UINT_LEAST64_TYPE__ long long unsigned int 166 | #define __FLT_HAS_QUIET_NAN__ 1 167 | #define __FLT_MAX_10_EXP__ 38 168 | #define __LONG_MAX__ 0x7fffffffL 169 | #define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL 170 | #define __FLT_HAS_INFINITY__ 1 171 | #define __cpp_unicode_literals 200710 172 | #define __UINT_FAST16_TYPE__ short unsigned int 173 | #define __DEC64_MAX__ 9.999999999999999E384DD 174 | #define __CHAR16_TYPE__ short unsigned int 175 | #define __PRAGMA_REDEFINE_EXTNAME 1 176 | #define __INT_LEAST16_MAX__ 0x7fff 177 | #define __DEC64_MANT_DIG__ 16 178 | #define __UINT_LEAST32_MAX__ 0xffffffffU 179 | #define __GCC_ATOMIC_LONG_LOCK_FREE 2 180 | #define __INT_LEAST64_TYPE__ long long int 181 | #define __INT16_TYPE__ short int 182 | #define __INT_LEAST8_TYPE__ signed char 183 | #define __DEC32_MAX_EXP__ 97 184 | #define __INT_FAST8_MAX__ 0x7f 185 | #define __INTPTR_MAX__ 0x7fffffff 186 | #define __GXX_MERGED_TYPEINFO_NAMES 0 187 | #define __cpp_range_based_for 200907 188 | #define __stdcall __attribute__((__stdcall__)) 189 | #define __EXCEPTIONS 1 190 | #define __LDBL_MANT_DIG__ 64 191 | #define __DBL_HAS_QUIET_NAN__ 1 192 | #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) 193 | #define __INTPTR_TYPE__ int 194 | #define __UINT16_TYPE__ short unsigned int 195 | #define __WCHAR_TYPE__ short unsigned int 196 | #define __SIZEOF_FLOAT__ 4 197 | #define __UINTPTR_MAX__ 0xffffffffU 198 | #define __DEC64_MIN_EXP__ (-382) 199 | #define __cpp_decltype 200707 200 | #define __INT_FAST64_MAX__ 0x7fffffffffffffffLL 201 | #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 202 | #define __FLT_DIG__ 6 203 | #define __UINT_FAST64_TYPE__ long long unsigned int 204 | #define __INT_MAX__ 0x7fffffff 205 | #define WIN32 1 206 | #define __INT64_TYPE__ long long int 207 | #define __FLT_MAX_EXP__ 128 208 | #define __DBL_MANT_DIG__ 53 209 | #define __cpp_inheriting_constructors 200802 210 | #define __SIZEOF_FLOAT128__ 16 211 | #define __INT_LEAST64_MAX__ 0x7fffffffffffffffLL 212 | #define __DEC64_MIN__ 1E-383DD 213 | #define __WINT_TYPE__ short unsigned int 214 | #define __UINT_LEAST32_TYPE__ unsigned int 215 | #define __SIZEOF_SHORT__ 2 216 | #define __LDBL_MIN_EXP__ (-16381) 217 | #define __INT_LEAST8_MAX__ 0x7f 218 | #define __WCHAR_UNSIGNED__ 1 219 | #define __LDBL_MAX_10_EXP__ 4932 220 | #define __ATOMIC_RELAXED 0 221 | #define __DBL_EPSILON__ double(2.22044604925031308085e-16L) 222 | #define __thiscall __attribute__((__thiscall__)) 223 | #define __UINT8_C(c) c 224 | #define __INT_LEAST32_TYPE__ int 225 | #define __SIZEOF_WCHAR_T__ 2 226 | #define __UINT64_TYPE__ long long unsigned int 227 | #define __INT_FAST8_TYPE__ signed char 228 | #define __fastcall __attribute__((__fastcall__)) 229 | #define __GNUC_STDC_INLINE__ 1 230 | #define __DBL_DECIMAL_DIG__ 17 231 | #define __STDC_UTF_32__ 1 232 | #define __DEC_EVAL_METHOD__ 2 233 | #define __ORDER_BIG_ENDIAN__ 4321 234 | #define __cpp_runtime_arrays 198712 235 | #define __UINT32_C(c) c ## U 236 | #define __INTMAX_MAX__ 0x7fffffffffffffffLL 237 | #define __cpp_alias_templates 200704 238 | #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ 239 | #define WINNT 1 240 | #define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F 241 | #define __INT8_MAX__ 0x7f 242 | #define __UINT_FAST32_TYPE__ unsigned int 243 | #define __CHAR32_TYPE__ unsigned int 244 | #define __FLT_MAX__ 3.40282346638528859812e+38F 245 | #define __cpp_constexpr 200704 246 | #define __INT32_TYPE__ int 247 | #define __SIZEOF_DOUBLE__ 8 248 | #define __cpp_exceptions 199711 249 | #define __INTMAX_TYPE__ long long int 250 | #define i386 1 251 | #define _INTEGRAL_MAX_BITS 64 252 | #define __DEC128_MAX_EXP__ 6145 253 | #define __ATOMIC_CONSUME 1 254 | #define __GNUC_MINOR__ 3 255 | #define __UINTMAX_MAX__ 0xffffffffffffffffULL 256 | #define __DEC32_MANT_DIG__ 7 257 | #define __DBL_MAX_10_EXP__ 308 258 | #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L 259 | #define __INT16_C(c) c 260 | #define __STDC__ 1 261 | #define __PTRDIFF_TYPE__ int 262 | #define __ATOMIC_SEQ_CST 5 263 | #define __UINT32_TYPE__ unsigned int 264 | #define __UINTPTR_TYPE__ unsigned int 265 | #define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD 266 | #define __DEC128_MANT_DIG__ 34 267 | #define __LDBL_MIN_10_EXP__ (-4931) 268 | #define __SIZEOF_LONG_LONG__ 8 269 | #define __cpp_user_defined_literals 200809 270 | #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 271 | #define __LDBL_DIG__ 18 272 | #define __FLT_DECIMAL_DIG__ 9 273 | #define __UINT_FAST16_MAX__ 0xffff 274 | #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 275 | #define __UINT_FAST8_TYPE__ unsigned char 276 | #define __ATOMIC_ACQ_REL 4 277 | #define __ATOMIC_RELEASE 3 278 | #define __declspec(x) __attribute__((x)) 279 | -------------------------------------------------------------------------------- /Client/release/moc_register.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Meta object code from reading C++ file 'register.h' 3 | ** 4 | ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.8.0) 5 | ** 6 | ** WARNING! All changes made in this file will be lost! 7 | *****************************************************************************/ 8 | 9 | #include "../register.h" 10 | #include 11 | #include 12 | #if !defined(Q_MOC_OUTPUT_REVISION) 13 | #error "The header file 'register.h' doesn't include ." 14 | #elif Q_MOC_OUTPUT_REVISION != 67 15 | #error "This file was generated using the moc from 5.8.0. It" 16 | #error "cannot be used with the include files from this version of Qt." 17 | #error "(The moc has changed too much.)" 18 | #endif 19 | 20 | QT_BEGIN_MOC_NAMESPACE 21 | QT_WARNING_PUSH 22 | QT_WARNING_DISABLE_DEPRECATED 23 | struct qt_meta_stringdata_Register_t { 24 | QByteArrayData data[5]; 25 | char stringdata0[82]; 26 | }; 27 | #define QT_MOC_LITERAL(idx, ofs, len) \ 28 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ 29 | qptrdiff(offsetof(qt_meta_stringdata_Register_t, stringdata0) + ofs \ 30 | - idx * sizeof(QByteArrayData)) \ 31 | ) 32 | static const qt_meta_stringdata_Register_t qt_meta_stringdata_Register = { 33 | { 34 | QT_MOC_LITERAL(0, 0, 8), // "Register" 35 | QT_MOC_LITERAL(1, 9, 24), // "on_Button_accept_clicked" 36 | QT_MOC_LITERAL(2, 34, 0), // "" 37 | QT_MOC_LITERAL(3, 35, 24), // "on_Button_reject_clicked" 38 | QT_MOC_LITERAL(4, 60, 21) // "on_Button_reg_clicked" 39 | 40 | }, 41 | "Register\0on_Button_accept_clicked\0\0" 42 | "on_Button_reject_clicked\0on_Button_reg_clicked" 43 | }; 44 | #undef QT_MOC_LITERAL 45 | 46 | static const uint qt_meta_data_Register[] = { 47 | 48 | // content: 49 | 7, // revision 50 | 0, // classname 51 | 0, 0, // classinfo 52 | 3, 14, // methods 53 | 0, 0, // properties 54 | 0, 0, // enums/sets 55 | 0, 0, // constructors 56 | 0, // flags 57 | 0, // signalCount 58 | 59 | // slots: name, argc, parameters, tag, flags 60 | 1, 0, 29, 2, 0x08 /* Private */, 61 | 3, 0, 30, 2, 0x08 /* Private */, 62 | 4, 0, 31, 2, 0x08 /* Private */, 63 | 64 | // slots: parameters 65 | QMetaType::Void, 66 | QMetaType::Void, 67 | QMetaType::Void, 68 | 69 | 0 // eod 70 | }; 71 | 72 | void Register::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) 73 | { 74 | if (_c == QMetaObject::InvokeMetaMethod) { 75 | Register *_t = static_cast(_o); 76 | Q_UNUSED(_t) 77 | switch (_id) { 78 | case 0: _t->on_Button_accept_clicked(); break; 79 | case 1: _t->on_Button_reject_clicked(); break; 80 | case 2: _t->on_Button_reg_clicked(); break; 81 | default: ; 82 | } 83 | } 84 | Q_UNUSED(_a); 85 | } 86 | 87 | const QMetaObject Register::staticMetaObject = { 88 | { &QDialog::staticMetaObject, qt_meta_stringdata_Register.data, 89 | qt_meta_data_Register, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} 90 | }; 91 | 92 | 93 | const QMetaObject *Register::metaObject() const 94 | { 95 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; 96 | } 97 | 98 | void *Register::qt_metacast(const char *_clname) 99 | { 100 | if (!_clname) return Q_NULLPTR; 101 | if (!strcmp(_clname, qt_meta_stringdata_Register.stringdata0)) 102 | return static_cast(const_cast< Register*>(this)); 103 | return QDialog::qt_metacast(_clname); 104 | } 105 | 106 | int Register::qt_metacall(QMetaObject::Call _c, int _id, void **_a) 107 | { 108 | _id = QDialog::qt_metacall(_c, _id, _a); 109 | if (_id < 0) 110 | return _id; 111 | if (_c == QMetaObject::InvokeMetaMethod) { 112 | if (_id < 3) 113 | qt_static_metacall(this, _c, _id, _a); 114 | _id -= 3; 115 | } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { 116 | if (_id < 3) 117 | *reinterpret_cast(_a[0]) = -1; 118 | _id -= 3; 119 | } 120 | return _id; 121 | } 122 | QT_WARNING_POP 123 | QT_END_MOC_NAMESPACE 124 | -------------------------------------------------------------------------------- /Client/release/moc_register.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/moc_register.o -------------------------------------------------------------------------------- /Client/release/moc_sendfile.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Meta object code from reading C++ file 'sendfile.h' 3 | ** 4 | ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.8.0) 5 | ** 6 | ** WARNING! All changes made in this file will be lost! 7 | *****************************************************************************/ 8 | 9 | #include "../sendfile.h" 10 | #include 11 | #include 12 | #if !defined(Q_MOC_OUTPUT_REVISION) 13 | #error "The header file 'sendfile.h' doesn't include ." 14 | #elif Q_MOC_OUTPUT_REVISION != 67 15 | #error "This file was generated using the moc from 5.8.0. It" 16 | #error "cannot be used with the include files from this version of Qt." 17 | #error "(The moc has changed too much.)" 18 | #endif 19 | 20 | QT_BEGIN_MOC_NAMESPACE 21 | QT_WARNING_PUSH 22 | QT_WARNING_DISABLE_DEPRECATED 23 | struct qt_meta_stringdata_Sendfile_t { 24 | QByteArrayData data[8]; 25 | char stringdata0[145]; 26 | }; 27 | #define QT_MOC_LITERAL(idx, ofs, len) \ 28 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ 29 | qptrdiff(offsetof(qt_meta_stringdata_Sendfile_t, stringdata0) + ofs \ 30 | - idx * sizeof(QByteArrayData)) \ 31 | ) 32 | static const qt_meta_stringdata_Sendfile_t qt_meta_stringdata_Sendfile = { 33 | { 34 | QT_MOC_LITERAL(0, 0, 8), // "Sendfile" 35 | QT_MOC_LITERAL(1, 9, 27), // "on_buttonChooseFile_clicked" 36 | QT_MOC_LITERAL(2, 37, 0), // "" 37 | QT_MOC_LITERAL(3, 38, 26), // "on_butttonSendFile_clicked" 38 | QT_MOC_LITERAL(4, 65, 8), // "sendData" 39 | QT_MOC_LITERAL(5, 74, 25), // "readPendingDatagrams_send" 40 | QT_MOC_LITERAL(6, 100, 25), // "readPendingDatagrams_recv" 41 | QT_MOC_LITERAL(7, 126, 18) // "on_bt_exit_clicked" 42 | 43 | }, 44 | "Sendfile\0on_buttonChooseFile_clicked\0" 45 | "\0on_butttonSendFile_clicked\0sendData\0" 46 | "readPendingDatagrams_send\0" 47 | "readPendingDatagrams_recv\0on_bt_exit_clicked" 48 | }; 49 | #undef QT_MOC_LITERAL 50 | 51 | static const uint qt_meta_data_Sendfile[] = { 52 | 53 | // content: 54 | 7, // revision 55 | 0, // classname 56 | 0, 0, // classinfo 57 | 6, 14, // methods 58 | 0, 0, // properties 59 | 0, 0, // enums/sets 60 | 0, 0, // constructors 61 | 0, // flags 62 | 0, // signalCount 63 | 64 | // slots: name, argc, parameters, tag, flags 65 | 1, 0, 44, 2, 0x08 /* Private */, 66 | 3, 0, 45, 2, 0x08 /* Private */, 67 | 4, 0, 46, 2, 0x08 /* Private */, 68 | 5, 0, 47, 2, 0x08 /* Private */, 69 | 6, 0, 48, 2, 0x08 /* Private */, 70 | 7, 0, 49, 2, 0x08 /* Private */, 71 | 72 | // slots: parameters 73 | QMetaType::Void, 74 | QMetaType::Void, 75 | QMetaType::Void, 76 | QMetaType::Void, 77 | QMetaType::Void, 78 | QMetaType::Void, 79 | 80 | 0 // eod 81 | }; 82 | 83 | void Sendfile::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) 84 | { 85 | if (_c == QMetaObject::InvokeMetaMethod) { 86 | Sendfile *_t = static_cast(_o); 87 | Q_UNUSED(_t) 88 | switch (_id) { 89 | case 0: _t->on_buttonChooseFile_clicked(); break; 90 | case 1: _t->on_butttonSendFile_clicked(); break; 91 | case 2: _t->sendData(); break; 92 | case 3: _t->readPendingDatagrams_send(); break; 93 | case 4: _t->readPendingDatagrams_recv(); break; 94 | case 5: _t->on_bt_exit_clicked(); break; 95 | default: ; 96 | } 97 | } 98 | Q_UNUSED(_a); 99 | } 100 | 101 | const QMetaObject Sendfile::staticMetaObject = { 102 | { &QDialog::staticMetaObject, qt_meta_stringdata_Sendfile.data, 103 | qt_meta_data_Sendfile, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} 104 | }; 105 | 106 | 107 | const QMetaObject *Sendfile::metaObject() const 108 | { 109 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; 110 | } 111 | 112 | void *Sendfile::qt_metacast(const char *_clname) 113 | { 114 | if (!_clname) return Q_NULLPTR; 115 | if (!strcmp(_clname, qt_meta_stringdata_Sendfile.stringdata0)) 116 | return static_cast(const_cast< Sendfile*>(this)); 117 | return QDialog::qt_metacast(_clname); 118 | } 119 | 120 | int Sendfile::qt_metacall(QMetaObject::Call _c, int _id, void **_a) 121 | { 122 | _id = QDialog::qt_metacall(_c, _id, _a); 123 | if (_id < 0) 124 | return _id; 125 | if (_c == QMetaObject::InvokeMetaMethod) { 126 | if (_id < 6) 127 | qt_static_metacall(this, _c, _id, _a); 128 | _id -= 6; 129 | } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { 130 | if (_id < 6) 131 | *reinterpret_cast(_a[0]) = -1; 132 | _id -= 6; 133 | } 134 | return _id; 135 | } 136 | QT_WARNING_POP 137 | QT_END_MOC_NAMESPACE 138 | -------------------------------------------------------------------------------- /Client/release/moc_sendfile.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/moc_sendfile.o -------------------------------------------------------------------------------- /Client/release/qrc_src.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/qrc_src.o -------------------------------------------------------------------------------- /Client/release/register.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/register.o -------------------------------------------------------------------------------- /Client/release/sendfile.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/sendfile.o -------------------------------------------------------------------------------- /Client/release/user_imformation.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Client/release/user_imformation.o -------------------------------------------------------------------------------- /Client/sendfile - 副本.h: -------------------------------------------------------------------------------- 1 | #ifndef SENDFILE_H 2 | #define SENDFILE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace Ui { 11 | class Sendfile; 12 | } 13 | 14 | class Sendfile : public QDialog 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit Sendfile(QWidget *parent = 0); 20 | ~Sendfile(); 21 | 22 | private slots: 23 | void on_buttonChooseFile_clicked(); 24 | 25 | void on_butttonSendFile_clicked(); 26 | 27 | void sendData(); 28 | 29 | void readPendingDatagrams_send(); 30 | 31 | void readPendingDatagrams_recv(); 32 | 33 | void on_bt_exit_clicked(); 34 | 35 | private: 36 | Ui::Sendfile *ui; 37 | QUdpSocket* udpSocketserver; //socket 38 | QUdpSocket* udpSocketclient; //socket 39 | QFile filesend; //文件对象 40 | QString filesend_information; //发送文件头中的文件基本信息 41 | QFile filerecv; 42 | QString fileNamesend; //文件名字 43 | QString filenamerecv; 44 | qint64 fileSizesend; //文件大小 45 | qint64 fileSizerecv; //接收文件大小 46 | qint64 recvSize; //已经接收大小 47 | qint64 sendSize; //已经发送大小 48 | QTimer* timer; //倒计时器,测定超时 49 | QHostAddress recverhost; 50 | quint16 recverPort = 12580; 51 | QHostAddress senderhost; 52 | quint16 senderPort; 53 | bool isfirst; //文件已经接收完毕,第一次收到重复的包,需要提示,后面不再提示收到重复的包 54 | }; 55 | 56 | #endif // SENDFILE_H 57 | -------------------------------------------------------------------------------- /Client/sendfile.h: -------------------------------------------------------------------------------- 1 | #ifndef SENDFILE_H 2 | #define SENDFILE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace Ui { 11 | class Sendfile; 12 | } 13 | 14 | class Sendfile : public QDialog 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit Sendfile(QWidget *parent = 0); 20 | ~Sendfile(); 21 | 22 | private slots: 23 | void on_buttonChooseFile_clicked(); 24 | 25 | void on_butttonSendFile_clicked(); 26 | 27 | void sendData(); 28 | 29 | void readPendingDatagrams_send(); 30 | 31 | void readPendingDatagrams_recv(); 32 | 33 | void on_bt_exit_clicked(); 34 | 35 | private: 36 | Ui::Sendfile *ui; 37 | QUdpSocket* udpSocketserver; //socket 38 | QUdpSocket* udpSocketclient; //socket 39 | QFile filesend; //文件对象 40 | QString filesend_information; //发送文件头中的文件基本信息 41 | QFile filerecv; 42 | QString fileNamesend; //文件名字 43 | QString filenamerecv; 44 | qint64 fileSizesend; //文件大小 45 | qint64 fileSizerecv; //接收文件大小 46 | qint64 recvSize; //已经接收大小 47 | qint64 sendSize; //已经发送大小 48 | QTimer* timer; //倒计时器,测定超时 49 | QHostAddress recverhost; 50 | quint16 recverPort = 12580; 51 | // QHostAddress senderhost; 52 | // quint16 senderPort; 53 | bool isfirst; //文件已经接收完毕,第一次收到重复的包,需要提示,后面不再提示收到重复的包 54 | }; 55 | 56 | #endif // SENDFILE_H 57 | -------------------------------------------------------------------------------- /Client/sendfile.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sendfile 4 | 5 | 6 | 7 | 0 8 | 0 9 | 486 10 | 439 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 50 20 | 110 21 | 361 22 | 91 23 | 24 | 25 | 26 | QFrame::StyledPanel 27 | 28 | 29 | QFrame::Raised 30 | 31 | 32 | 33 | 34 | 210 35 | 10 36 | 93 37 | 28 38 | 39 | 40 | 41 | 开始传送 42 | 43 | 44 | 45 | 46 | 47 | 110 48 | 60 49 | 241 50 | 21 51 | 52 | 53 | 54 | 0 55 | 56 | 57 | 58 | 59 | 60 | 30 61 | 10 62 | 93 63 | 28 64 | 65 | 66 | 67 | 选择文件 68 | 69 | 70 | 71 | 72 | 73 | 0 74 | 60 75 | 72 76 | 15 77 | 78 | 79 | 80 | 发送进度: 81 | 82 | 83 | 84 | 85 | 86 | false 87 | 88 | 89 | 90 | 140 91 | 20 92 | 241 93 | 21 94 | 95 | 96 | 97 | 98 | 99 | 100 | 70 101 | 20 102 | 72 103 | 15 104 | 105 | 106 | 107 | 文件名: 108 | 109 | 110 | 111 | 112 | 113 | 40 114 | 50 115 | 101 116 | 21 117 | 118 | 119 | 120 | 文件总大小: 121 | 122 | 123 | 124 | 125 | false 126 | 127 | 128 | 129 | 140 130 | 50 131 | 113 132 | 21 133 | 134 | 135 | 136 | 0 137 | 138 | 139 | 140 | 141 | 142 | 50 143 | 210 144 | 361 145 | 191 146 | 147 | 148 | 149 | 150 | 151 | 152 | 350 153 | 410 154 | 93 155 | 28 156 | 157 | 158 | 159 | 退出 160 | 161 | 162 | 163 | 164 | 165 | 40 166 | 80 167 | 81 168 | 16 169 | 170 | 171 | 172 | 目的主机ip: 173 | 174 | 175 | 176 | 177 | false 178 | 179 | 180 | 181 | 140 182 | 80 183 | 113 184 | 21 185 | 186 | 187 | 188 | 189 | 190 | 191 | 340 192 | 50 193 | 111 194 | 31 195 | 196 | 197 | 198 | 文件传输速率: 199 | 200 | 201 | 202 | 203 | false 204 | 205 | 206 | 207 | 330 208 | 80 209 | 113 210 | 21 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | -------------------------------------------------------------------------------- /Client/src.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | image/766971.jpg 4 | image/back.jpg 5 | 6 | 7 | -------------------------------------------------------------------------------- /Client/ui_clientwidget.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | ** Form generated from reading UI file 'clientwidget.ui' 3 | ** 4 | ** Created by: Qt User Interface Compiler version 5.8.0 5 | ** 6 | ** WARNING! All changes made in this file will be lost when recompiling UI file! 7 | ********************************************************************************/ 8 | 9 | #ifndef UI_CLIENTWIDGET_H 10 | #define UI_CLIENTWIDGET_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | QT_BEGIN_NAMESPACE 26 | 27 | class Ui_clientwidget 28 | { 29 | public: 30 | QFrame *frame; 31 | QFrame *frame_ip; 32 | QLabel *label_3; 33 | QLineEdit *lineEditIp; 34 | QLineEdit *lineEditPort; 35 | QLabel *label_2; 36 | QPushButton *buttonConnect; 37 | QLabel *label; 38 | QPushButton *bt_file_send; 39 | QFrame *frame_client_on; 40 | QComboBox *cb_client_on; 41 | QLineEdit *le_usernum_on; 42 | QPushButton *bt_connect_client; 43 | QPushButton *bt_disconnect_client; 44 | QFrame *frame_message; 45 | QTextBrowser *textBrowser; 46 | QPushButton *bt_message_send; 47 | QLineEdit *le_message; 48 | QFrame *frame_client_off; 49 | QComboBox *cb_client_off; 50 | QLineEdit *le_usernum_off; 51 | QFrame *frame_state; 52 | QLineEdit *le_state; 53 | QLineEdit *le_username; 54 | QLabel *label_5; 55 | QPushButton *buttonClose; 56 | QLabel *label_6; 57 | QLabel *label_9; 58 | QLineEdit *le_file_permission; 59 | QLabel *label_7; 60 | QLabel *label_8; 61 | 62 | void setupUi(QWidget *clientwidget) 63 | { 64 | if (clientwidget->objectName().isEmpty()) 65 | clientwidget->setObjectName(QStringLiteral("clientwidget")); 66 | clientwidget->resize(828, 530); 67 | clientwidget->setAutoFillBackground(false); 68 | clientwidget->setStyleSheet(QStringLiteral("")); 69 | frame = new QFrame(clientwidget); 70 | frame->setObjectName(QStringLiteral("frame")); 71 | frame->setGeometry(QRect(0, 0, 831, 531)); 72 | frame->setStyleSheet(QStringLiteral("#frame {background-image: url(:/new/prefix1/image/back.jpg);}")); 73 | frame->setFrameShape(QFrame::StyledPanel); 74 | frame->setFrameShadow(QFrame::Raised); 75 | frame_ip = new QFrame(frame); 76 | frame_ip->setObjectName(QStringLiteral("frame_ip")); 77 | frame_ip->setGeometry(QRect(240, 10, 231, 111)); 78 | frame_ip->setFrameShape(QFrame::StyledPanel); 79 | frame_ip->setFrameShadow(QFrame::Raised); 80 | label_3 = new QLabel(frame_ip); 81 | label_3->setObjectName(QStringLiteral("label_3")); 82 | label_3->setGeometry(QRect(10, 80, 72, 15)); 83 | lineEditIp = new QLineEdit(frame_ip); 84 | lineEditIp->setObjectName(QStringLiteral("lineEditIp")); 85 | lineEditIp->setGeometry(QRect(70, 10, 151, 21)); 86 | lineEditPort = new QLineEdit(frame_ip); 87 | lineEditPort->setObjectName(QStringLiteral("lineEditPort")); 88 | lineEditPort->setGeometry(QRect(70, 80, 151, 21)); 89 | label_2 = new QLabel(frame_ip); 90 | label_2->setObjectName(QStringLiteral("label_2")); 91 | label_2->setGeometry(QRect(10, 10, 31, 21)); 92 | buttonConnect = new QPushButton(frame_ip); 93 | buttonConnect->setObjectName(QStringLiteral("buttonConnect")); 94 | buttonConnect->setGeometry(QRect(100, 40, 91, 31)); 95 | label = new QLabel(frame); 96 | label->setObjectName(QStringLiteral("label")); 97 | label->setGeometry(QRect(70, 290, 101, 41)); 98 | label->setStyleSheet(QStringLiteral("font: 75 18pt \"Agency FB\";")); 99 | bt_file_send = new QPushButton(frame); 100 | bt_file_send->setObjectName(QStringLiteral("bt_file_send")); 101 | bt_file_send->setGeometry(QRect(660, 480, 93, 28)); 102 | frame_client_on = new QFrame(frame); 103 | frame_client_on->setObjectName(QStringLiteral("frame_client_on")); 104 | frame_client_on->setGeometry(QRect(110, 10, 101, 131)); 105 | frame_client_on->setFrameShape(QFrame::StyledPanel); 106 | frame_client_on->setFrameShadow(QFrame::Raised); 107 | cb_client_on = new QComboBox(frame_client_on); 108 | cb_client_on->setObjectName(QStringLiteral("cb_client_on")); 109 | cb_client_on->setGeometry(QRect(0, 30, 101, 21)); 110 | le_usernum_on = new QLineEdit(frame_client_on); 111 | le_usernum_on->setObjectName(QStringLiteral("le_usernum_on")); 112 | le_usernum_on->setEnabled(false); 113 | le_usernum_on->setGeometry(QRect(0, 0, 101, 21)); 114 | bt_connect_client = new QPushButton(frame_client_on); 115 | bt_connect_client->setObjectName(QStringLiteral("bt_connect_client")); 116 | bt_connect_client->setGeometry(QRect(0, 60, 101, 31)); 117 | bt_disconnect_client = new QPushButton(frame_client_on); 118 | bt_disconnect_client->setObjectName(QStringLiteral("bt_disconnect_client")); 119 | bt_disconnect_client->setGeometry(QRect(0, 100, 101, 31)); 120 | frame_message = new QFrame(frame); 121 | frame_message->setObjectName(QStringLiteral("frame_message")); 122 | frame_message->setGeometry(QRect(400, 130, 391, 341)); 123 | frame_message->setFrameShape(QFrame::StyledPanel); 124 | frame_message->setFrameShadow(QFrame::Raised); 125 | textBrowser = new QTextBrowser(frame_message); 126 | textBrowser->setObjectName(QStringLiteral("textBrowser")); 127 | textBrowser->setGeometry(QRect(0, 0, 391, 291)); 128 | textBrowser->setStyleSheet(QString::fromUtf8("selection-color: rgb(85, 255, 127);\n" 129 | "background-image: url(:/new/prefix1/image/766971.jpg);\n" 130 | "font: 12pt \"\346\245\267\344\275\223\";")); 131 | bt_message_send = new QPushButton(frame_message); 132 | bt_message_send->setObjectName(QStringLiteral("bt_message_send")); 133 | bt_message_send->setGeometry(QRect(260, 310, 93, 28)); 134 | le_message = new QLineEdit(frame_message); 135 | le_message->setObjectName(QStringLiteral("le_message")); 136 | le_message->setGeometry(QRect(0, 310, 221, 31)); 137 | frame_client_off = new QFrame(frame); 138 | frame_client_off->setObjectName(QStringLiteral("frame_client_off")); 139 | frame_client_off->setGeometry(QRect(110, 150, 101, 51)); 140 | frame_client_off->setFrameShape(QFrame::StyledPanel); 141 | frame_client_off->setFrameShadow(QFrame::Raised); 142 | cb_client_off = new QComboBox(frame_client_off); 143 | cb_client_off->setObjectName(QStringLiteral("cb_client_off")); 144 | cb_client_off->setGeometry(QRect(0, 30, 101, 21)); 145 | le_usernum_off = new QLineEdit(frame_client_off); 146 | le_usernum_off->setObjectName(QStringLiteral("le_usernum_off")); 147 | le_usernum_off->setEnabled(false); 148 | le_usernum_off->setGeometry(QRect(0, 0, 101, 21)); 149 | frame_state = new QFrame(frame); 150 | frame_state->setObjectName(QStringLiteral("frame_state")); 151 | frame_state->setGeometry(QRect(470, 10, 351, 111)); 152 | frame_state->setFrameShape(QFrame::StyledPanel); 153 | frame_state->setFrameShadow(QFrame::Raised); 154 | le_state = new QLineEdit(frame_state); 155 | le_state->setObjectName(QStringLiteral("le_state")); 156 | le_state->setEnabled(false); 157 | le_state->setGeometry(QRect(140, 10, 91, 21)); 158 | le_username = new QLineEdit(frame_state); 159 | le_username->setObjectName(QStringLiteral("le_username")); 160 | le_username->setEnabled(false); 161 | le_username->setGeometry(QRect(140, 40, 91, 21)); 162 | label_5 = new QLabel(frame_state); 163 | label_5->setObjectName(QStringLiteral("label_5")); 164 | label_5->setGeometry(QRect(0, 10, 111, 21)); 165 | buttonClose = new QPushButton(frame_state); 166 | buttonClose->setObjectName(QStringLiteral("buttonClose")); 167 | buttonClose->setGeometry(QRect(240, 10, 111, 21)); 168 | label_6 = new QLabel(frame_state); 169 | label_6->setObjectName(QStringLiteral("label_6")); 170 | label_6->setGeometry(QRect(10, 40, 72, 15)); 171 | label_9 = new QLabel(frame_state); 172 | label_9->setObjectName(QStringLiteral("label_9")); 173 | label_9->setGeometry(QRect(0, 70, 91, 16)); 174 | le_file_permission = new QLineEdit(frame_state); 175 | le_file_permission->setObjectName(QStringLiteral("le_file_permission")); 176 | le_file_permission->setEnabled(false); 177 | le_file_permission->setGeometry(QRect(140, 70, 91, 21)); 178 | label_7 = new QLabel(frame); 179 | label_7->setObjectName(QStringLiteral("label_7")); 180 | label_7->setGeometry(QRect(10, 10, 101, 20)); 181 | label_8 = new QLabel(frame); 182 | label_8->setObjectName(QStringLiteral("label_8")); 183 | label_8->setGeometry(QRect(10, 150, 101, 20)); 184 | frame_ip->raise(); 185 | label->raise(); 186 | bt_file_send->raise(); 187 | frame_client_on->raise(); 188 | frame_message->raise(); 189 | frame_client_off->raise(); 190 | frame_state->raise(); 191 | label_7->raise(); 192 | label_8->raise(); 193 | label_8->raise(); 194 | 195 | retranslateUi(clientwidget); 196 | 197 | QMetaObject::connectSlotsByName(clientwidget); 198 | } // setupUi 199 | 200 | void retranslateUi(QWidget *clientwidget) 201 | { 202 | clientwidget->setWindowTitle(QApplication::translate("clientwidget", "clientwidget", Q_NULLPTR)); 203 | label_3->setText(QApplication::translate("clientwidget", "\347\253\257\345\217\243\345\217\267:", Q_NULLPTR)); 204 | label_2->setText(QApplication::translate("clientwidget", "ip:", Q_NULLPTR)); 205 | buttonConnect->setText(QApplication::translate("clientwidget", "\350\277\236\346\216\245\346\234\215\345\212\241\345\231\250", Q_NULLPTR)); 206 | label->setText(QApplication::translate("clientwidget", "\345\256\242\346\210\267\347\253\257", Q_NULLPTR)); 207 | bt_file_send->setText(QApplication::translate("clientwidget", "\345\217\221\351\200\201\346\226\207\344\273\266", Q_NULLPTR)); 208 | cb_client_on->clear(); 209 | cb_client_on->insertItems(0, QStringList() 210 | << QApplication::translate("clientwidget", "\357\274\210\346\227\240\357\274\211", Q_NULLPTR) 211 | ); 212 | bt_connect_client->setText(QApplication::translate("clientwidget", "\350\277\236\346\216\245\345\234\250\347\272\277\347\224\250\346\210\267", Q_NULLPTR)); 213 | bt_disconnect_client->setText(QApplication::translate("clientwidget", "\346\226\255\345\274\200\345\234\250\347\272\277\350\277\236\346\216\245", Q_NULLPTR)); 214 | bt_message_send->setText(QApplication::translate("clientwidget", "\345\217\221\351\200\201\346\266\210\346\201\257", Q_NULLPTR)); 215 | cb_client_off->clear(); 216 | cb_client_off->insertItems(0, QStringList() 217 | << QApplication::translate("clientwidget", "\357\274\210\346\227\240\357\274\211", Q_NULLPTR) 218 | ); 219 | label_5->setText(QApplication::translate("clientwidget", "\346\234\215\345\212\241\345\231\250\350\277\236\346\216\245\347\212\266\346\200\201\357\274\232", Q_NULLPTR)); 220 | buttonClose->setText(QApplication::translate("clientwidget", "\346\226\255\345\274\200\346\234\215\345\212\241\345\231\250\350\277\236\346\216\245", Q_NULLPTR)); 221 | label_6->setText(QApplication::translate("clientwidget", "\347\224\250\346\210\267\345\220\215\357\274\232", Q_NULLPTR)); 222 | label_9->setText(QApplication::translate("clientwidget", "\347\202\271\345\257\271\347\202\271\350\277\236\346\216\245\357\274\232", Q_NULLPTR)); 223 | label_7->setText(QApplication::translate("clientwidget", "\345\234\250\347\272\277\347\224\250\346\210\267\346\225\260\351\207\217\357\274\232", Q_NULLPTR)); 224 | label_8->setText(QApplication::translate("clientwidget", "\347\246\273\347\272\277\347\224\250\346\210\267\346\225\260\351\207\217\357\274\232", Q_NULLPTR)); 225 | } // retranslateUi 226 | 227 | }; 228 | 229 | namespace Ui { 230 | class clientwidget: public Ui_clientwidget {}; 231 | } // namespace Ui 232 | 233 | QT_END_NAMESPACE 234 | 235 | #endif // UI_CLIENTWIDGET_H 236 | -------------------------------------------------------------------------------- /Client/ui_findpassword.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | ** Form generated from reading UI file 'findpassword.ui' 3 | ** 4 | ** Created by: Qt User Interface Compiler version 5.8.0 5 | ** 6 | ** WARNING! All changes made in this file will be lost when recompiling UI file! 7 | ********************************************************************************/ 8 | 9 | #ifndef UI_FINDPASSWORD_H 10 | #define UI_FINDPASSWORD_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | QT_BEGIN_NAMESPACE 23 | 24 | class Ui_findpassword 25 | { 26 | public: 27 | QPushButton *bt_find; 28 | QLabel *label; 29 | QLabel *label_2; 30 | QLineEdit *le_question; 31 | QLineEdit *le_answer; 32 | 33 | void setupUi(QDialog *findpassword) 34 | { 35 | if (findpassword->objectName().isEmpty()) 36 | findpassword->setObjectName(QStringLiteral("findpassword")); 37 | findpassword->resize(465, 358); 38 | bt_find = new QPushButton(findpassword); 39 | bt_find->setObjectName(QStringLiteral("bt_find")); 40 | bt_find->setGeometry(QRect(260, 230, 93, 28)); 41 | label = new QLabel(findpassword); 42 | label->setObjectName(QStringLiteral("label")); 43 | label->setGeometry(QRect(70, 90, 72, 15)); 44 | label_2 = new QLabel(findpassword); 45 | label_2->setObjectName(QStringLiteral("label_2")); 46 | label_2->setGeometry(QRect(70, 160, 72, 15)); 47 | le_question = new QLineEdit(findpassword); 48 | le_question->setObjectName(QStringLiteral("le_question")); 49 | le_question->setEnabled(false); 50 | le_question->setGeometry(QRect(160, 90, 201, 21)); 51 | le_answer = new QLineEdit(findpassword); 52 | le_answer->setObjectName(QStringLiteral("le_answer")); 53 | le_answer->setGeometry(QRect(160, 150, 201, 21)); 54 | 55 | retranslateUi(findpassword); 56 | 57 | QMetaObject::connectSlotsByName(findpassword); 58 | } // setupUi 59 | 60 | void retranslateUi(QDialog *findpassword) 61 | { 62 | findpassword->setWindowTitle(QApplication::translate("findpassword", "Dialog", Q_NULLPTR)); 63 | bt_find->setText(QApplication::translate("findpassword", "\346\211\276\345\233\236\345\257\206\347\240\201", Q_NULLPTR)); 64 | label->setText(QApplication::translate("findpassword", "\345\257\206\347\240\201\351\227\256\351\242\230:", Q_NULLPTR)); 65 | label_2->setText(QApplication::translate("findpassword", "\345\257\206\347\240\201\347\255\224\346\241\210\357\274\232", Q_NULLPTR)); 66 | } // retranslateUi 67 | 68 | }; 69 | 70 | namespace Ui { 71 | class findpassword: public Ui_findpassword {}; 72 | } // namespace Ui 73 | 74 | QT_END_NAMESPACE 75 | 76 | #endif // UI_FINDPASSWORD_H 77 | -------------------------------------------------------------------------------- /Client/ui_logindialog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | ** Form generated from reading UI file 'logindialog.ui' 3 | ** 4 | ** Created by: Qt User Interface Compiler version 5.8.0 5 | ** 6 | ** WARNING! All changes made in this file will be lost when recompiling UI file! 7 | ********************************************************************************/ 8 | 9 | #ifndef UI_LOGINDIALOG_H 10 | #define UI_LOGINDIALOG_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | QT_BEGIN_NAMESPACE 24 | 25 | class Ui_LoginDialog 26 | { 27 | public: 28 | QLabel *label_3; 29 | QSplitter *splitter; 30 | QLabel *label_2; 31 | QLabel *label; 32 | QSplitter *splitter_2; 33 | QLineEdit *user_lineEdit; 34 | QLineEdit *pwd_lineEdit; 35 | QPushButton *login_pushButton; 36 | QPushButton *register_pushButton; 37 | QPushButton *find_pushButton; 38 | 39 | void setupUi(QDialog *LoginDialog) 40 | { 41 | if (LoginDialog->objectName().isEmpty()) 42 | LoginDialog->setObjectName(QStringLiteral("LoginDialog")); 43 | LoginDialog->resize(465, 323); 44 | label_3 = new QLabel(LoginDialog); 45 | label_3->setObjectName(QStringLiteral("label_3")); 46 | label_3->setGeometry(QRect(140, 40, 221, 31)); 47 | label_3->setStyleSheet(QString::fromUtf8("font: 25 14pt \"\347\255\211\347\272\277 Light\";")); 48 | label_3->setAlignment(Qt::AlignCenter); 49 | splitter = new QSplitter(LoginDialog); 50 | splitter->setObjectName(QStringLiteral("splitter")); 51 | splitter->setGeometry(QRect(91, 89, 51, 81)); 52 | splitter->setOrientation(Qt::Vertical); 53 | label_2 = new QLabel(splitter); 54 | label_2->setObjectName(QStringLiteral("label_2")); 55 | label_2->setStyleSheet(QString::fromUtf8("font: 25 10pt \"\347\255\211\347\272\277 Light\";")); 56 | splitter->addWidget(label_2); 57 | label = new QLabel(splitter); 58 | label->setObjectName(QStringLiteral("label")); 59 | label->setStyleSheet(QString::fromUtf8("font: 25 10pt \"\347\255\211\347\272\277 Light\";")); 60 | splitter->addWidget(label); 61 | splitter_2 = new QSplitter(LoginDialog); 62 | splitter_2->setObjectName(QStringLiteral("splitter_2")); 63 | splitter_2->setGeometry(QRect(140, 90, 231, 81)); 64 | splitter_2->setOrientation(Qt::Vertical); 65 | user_lineEdit = new QLineEdit(splitter_2); 66 | user_lineEdit->setObjectName(QStringLiteral("user_lineEdit")); 67 | user_lineEdit->setStyleSheet(QString::fromUtf8("font: 25 10pt \"\347\255\211\347\272\277 Light\";")); 68 | splitter_2->addWidget(user_lineEdit); 69 | pwd_lineEdit = new QLineEdit(splitter_2); 70 | pwd_lineEdit->setObjectName(QStringLiteral("pwd_lineEdit")); 71 | pwd_lineEdit->setStyleSheet(QString::fromUtf8("font: 25 10pt \"\347\255\211\347\272\277 Light\";")); 72 | pwd_lineEdit->setEchoMode(QLineEdit::Password); 73 | splitter_2->addWidget(pwd_lineEdit); 74 | login_pushButton = new QPushButton(LoginDialog); 75 | login_pushButton->setObjectName(QStringLiteral("login_pushButton")); 76 | login_pushButton->setGeometry(QRect(60, 190, 101, 51)); 77 | login_pushButton->setStyleSheet(QStringLiteral("")); 78 | register_pushButton = new QPushButton(LoginDialog); 79 | register_pushButton->setObjectName(QStringLiteral("register_pushButton")); 80 | register_pushButton->setGeometry(QRect(180, 190, 111, 51)); 81 | register_pushButton->setStyleSheet(QStringLiteral("")); 82 | find_pushButton = new QPushButton(LoginDialog); 83 | find_pushButton->setObjectName(QStringLiteral("find_pushButton")); 84 | find_pushButton->setGeometry(QRect(310, 190, 111, 51)); 85 | find_pushButton->setStyleSheet(QStringLiteral("")); 86 | 87 | retranslateUi(LoginDialog); 88 | 89 | QMetaObject::connectSlotsByName(LoginDialog); 90 | } // setupUi 91 | 92 | void retranslateUi(QDialog *LoginDialog) 93 | { 94 | LoginDialog->setWindowTitle(QApplication::translate("LoginDialog", "Dialog", Q_NULLPTR)); 95 | label_3->setText(QApplication::translate("LoginDialog", "\346\254\242\350\277\216\344\275\277\347\224\250\345\222\232\345\222\232", Q_NULLPTR)); 96 | label_2->setText(QApplication::translate("LoginDialog", "\350\264\246\346\210\267", Q_NULLPTR)); 97 | label->setText(QApplication::translate("LoginDialog", "\345\257\206\347\240\201", Q_NULLPTR)); 98 | user_lineEdit->setPlaceholderText(QApplication::translate("LoginDialog", "\350\257\267\350\276\223\345\205\245\350\264\246\345\217\267", Q_NULLPTR)); 99 | pwd_lineEdit->setPlaceholderText(QApplication::translate("LoginDialog", "\350\276\223\345\205\245\345\257\206\347\240\201", Q_NULLPTR)); 100 | login_pushButton->setText(QApplication::translate("LoginDialog", "\347\231\273\345\275\225", Q_NULLPTR)); 101 | register_pushButton->setText(QApplication::translate("LoginDialog", "\346\263\250\345\206\214", Q_NULLPTR)); 102 | find_pushButton->setText(QApplication::translate("LoginDialog", "\346\211\276\345\233\236\345\257\206\347\240\201", Q_NULLPTR)); 103 | } // retranslateUi 104 | 105 | }; 106 | 107 | namespace Ui { 108 | class LoginDialog: public Ui_LoginDialog {}; 109 | } // namespace Ui 110 | 111 | QT_END_NAMESPACE 112 | 113 | #endif // UI_LOGINDIALOG_H 114 | -------------------------------------------------------------------------------- /Client/ui_register.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | ** Form generated from reading UI file 'register.ui' 3 | ** 4 | ** Created by: Qt User Interface Compiler version 5.8.0 5 | ** 6 | ** WARNING! All changes made in this file will be lost when recompiling UI file! 7 | ********************************************************************************/ 8 | 9 | #ifndef UI_REGISTER_H 10 | #define UI_REGISTER_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | QT_BEGIN_NAMESPACE 28 | 29 | class Ui_Register 30 | { 31 | public: 32 | QSplitter *splitter_3; 33 | QSplitter *splitter_5; 34 | QRadioButton *Button_accept; 35 | QRadioButton *Button_reject; 36 | QPushButton *Button_reg; 37 | QTextBrowser *text_note; 38 | QFrame *verticalFrame1; 39 | QVBoxLayout *verticalLayout; 40 | QLabel *label; 41 | QLabel *label_2; 42 | QLabel *label_3; 43 | QLabel *label_4; 44 | QFrame *verticalFrame; 45 | QVBoxLayout *verticalLayout_2; 46 | QLineEdit *le_user; 47 | QLineEdit *le_password; 48 | QLineEdit *le_question; 49 | QLineEdit *le_answer; 50 | 51 | void setupUi(QDialog *Register) 52 | { 53 | if (Register->objectName().isEmpty()) 54 | Register->setObjectName(QStringLiteral("Register")); 55 | Register->resize(538, 398); 56 | splitter_3 = new QSplitter(Register); 57 | splitter_3->setObjectName(QStringLiteral("splitter_3")); 58 | splitter_3->setGeometry(QRect(190, 250, 125, 70)); 59 | QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 60 | sizePolicy.setHorizontalStretch(0); 61 | sizePolicy.setVerticalStretch(0); 62 | sizePolicy.setHeightForWidth(splitter_3->sizePolicy().hasHeightForWidth()); 63 | splitter_3->setSizePolicy(sizePolicy); 64 | splitter_3->setMinimumSize(QSize(125, 70)); 65 | splitter_3->setMaximumSize(QSize(125, 71)); 66 | splitter_3->setAutoFillBackground(true); 67 | splitter_3->setStyleSheet(QStringLiteral("")); 68 | splitter_3->setOrientation(Qt::Vertical); 69 | splitter_5 = new QSplitter(splitter_3); 70 | splitter_5->setObjectName(QStringLiteral("splitter_5")); 71 | splitter_5->setMinimumSize(QSize(125, 30)); 72 | splitter_5->setOrientation(Qt::Horizontal); 73 | Button_accept = new QRadioButton(splitter_5); 74 | Button_accept->setObjectName(QStringLiteral("Button_accept")); 75 | sizePolicy.setHeightForWidth(Button_accept->sizePolicy().hasHeightForWidth()); 76 | Button_accept->setSizePolicy(sizePolicy); 77 | Button_accept->setMinimumSize(QSize(60, 30)); 78 | Button_accept->setMaximumSize(QSize(60, 30)); 79 | Button_accept->setStyleSheet(QStringLiteral("")); 80 | splitter_5->addWidget(Button_accept); 81 | Button_reject = new QRadioButton(splitter_5); 82 | Button_reject->setObjectName(QStringLiteral("Button_reject")); 83 | sizePolicy.setHeightForWidth(Button_reject->sizePolicy().hasHeightForWidth()); 84 | Button_reject->setSizePolicy(sizePolicy); 85 | Button_reject->setMinimumSize(QSize(60, 30)); 86 | Button_reject->setMaximumSize(QSize(60, 30)); 87 | splitter_5->addWidget(Button_reject); 88 | splitter_3->addWidget(splitter_5); 89 | Button_reg = new QPushButton(splitter_3); 90 | Button_reg->setObjectName(QStringLiteral("Button_reg")); 91 | sizePolicy.setHeightForWidth(Button_reg->sizePolicy().hasHeightForWidth()); 92 | Button_reg->setSizePolicy(sizePolicy); 93 | Button_reg->setMinimumSize(QSize(84, 35)); 94 | Button_reg->setMaximumSize(QSize(125, 35)); 95 | Button_reg->setStyleSheet(QLatin1String("QPushButton {\n" 96 | " border: 2px solid #8f8f91;\n" 97 | " border-radius: 6px;\n" 98 | " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n" 99 | " stop: 0 #f6f7fa, stop: 1 #dadbde);\n" 100 | " min-width: 80px;\n" 101 | "}\n" 102 | "\n" 103 | "QPushButton:pressed {\n" 104 | " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n" 105 | " stop: 0 #dadbde, stop: 1 #f6f7fa);\n" 106 | "}\n" 107 | "\n" 108 | "QPushButton:flat {\n" 109 | " border: none; /* no border for a flat push button */\n" 110 | "}\n" 111 | "\n" 112 | "QPushButton:default {\n" 113 | " border-color: navy; /* make the default button prominent */\n" 114 | "}")); 115 | splitter_3->addWidget(Button_reg); 116 | text_note = new QTextBrowser(Register); 117 | text_note->setObjectName(QStringLiteral("text_note")); 118 | text_note->setGeometry(QRect(300, 50, 211, 151)); 119 | text_note->setStyleSheet(QString::fromUtf8("font: 25 11pt \"\347\255\211\347\272\277 Light\";")); 120 | verticalFrame1 = new QFrame(Register); 121 | verticalFrame1->setObjectName(QStringLiteral("verticalFrame1")); 122 | verticalFrame1->setGeometry(QRect(30, 50, 81, 161)); 123 | verticalLayout = new QVBoxLayout(verticalFrame1); 124 | verticalLayout->setObjectName(QStringLiteral("verticalLayout")); 125 | label = new QLabel(verticalFrame1); 126 | label->setObjectName(QStringLiteral("label")); 127 | 128 | verticalLayout->addWidget(label); 129 | 130 | label_2 = new QLabel(verticalFrame1); 131 | label_2->setObjectName(QStringLiteral("label_2")); 132 | 133 | verticalLayout->addWidget(label_2); 134 | 135 | label_3 = new QLabel(verticalFrame1); 136 | label_3->setObjectName(QStringLiteral("label_3")); 137 | 138 | verticalLayout->addWidget(label_3); 139 | 140 | label_4 = new QLabel(verticalFrame1); 141 | label_4->setObjectName(QStringLiteral("label_4")); 142 | 143 | verticalLayout->addWidget(label_4); 144 | 145 | verticalFrame = new QFrame(Register); 146 | verticalFrame->setObjectName(QStringLiteral("verticalFrame")); 147 | verticalFrame->setGeometry(QRect(120, 50, 151, 161)); 148 | verticalLayout_2 = new QVBoxLayout(verticalFrame); 149 | verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2")); 150 | le_user = new QLineEdit(verticalFrame); 151 | le_user->setObjectName(QStringLiteral("le_user")); 152 | 153 | verticalLayout_2->addWidget(le_user); 154 | 155 | le_password = new QLineEdit(verticalFrame); 156 | le_password->setObjectName(QStringLiteral("le_password")); 157 | le_password->setEchoMode(QLineEdit::Password); 158 | 159 | verticalLayout_2->addWidget(le_password); 160 | 161 | le_question = new QLineEdit(verticalFrame); 162 | le_question->setObjectName(QStringLiteral("le_question")); 163 | 164 | verticalLayout_2->addWidget(le_question); 165 | 166 | le_answer = new QLineEdit(verticalFrame); 167 | le_answer->setObjectName(QStringLiteral("le_answer")); 168 | 169 | verticalLayout_2->addWidget(le_answer); 170 | 171 | 172 | retranslateUi(Register); 173 | 174 | QMetaObject::connectSlotsByName(Register); 175 | } // setupUi 176 | 177 | void retranslateUi(QDialog *Register) 178 | { 179 | Register->setWindowTitle(QApplication::translate("Register", "Dialog", Q_NULLPTR)); 180 | Button_accept->setText(QApplication::translate("Register", "\345\220\214\346\204\217", Q_NULLPTR)); 181 | Button_reject->setText(QApplication::translate("Register", "\346\213\222\347\273\235", Q_NULLPTR)); 182 | Button_reg->setText(QApplication::translate("Register", "\346\263\250\345\206\214", Q_NULLPTR)); 183 | text_note->setHtml(QApplication::translate("Register", "\n" 184 | "\n" 187 | "

\346\263\250\345\206\214\351\241\273\347\237\245\357\274\232

\n" 188 | "

\345\220\214\345\255\246\346\202\250\345\245\275\357\274\201\346\254\242\350\277\216\345\212\240\345\205\245\345\222\232\345\222\232\343\200\202

\n" 189 | "


\n" 191 | "

\344\273\245\344\270\212\344\276\277\346\230\257\346\202\250\351\234\200\350\246\201\351\201\265\345\276\252\347\232\204\344\275\277\347\224\250\350\247\204\345\210\231\357\274\214\345\220\214\346\204\217\346\235\241\346\226\207\357\274\214\346\211\215\345\217\257\347\273\247\347\273\255\346\263\250\345\206\214\357\274\201

", Q_NULLPTR)); 192 | label->setText(QApplication::translate("Register", "\347\224\250\346\210\267\345\220\215", Q_NULLPTR)); 193 | label_2->setText(QApplication::translate("Register", "\345\257\206\347\240\201", Q_NULLPTR)); 194 | label_3->setText(QApplication::translate("Register", "\345\257\206\347\240\201\351\227\256\351\242\230", Q_NULLPTR)); 195 | label_4->setText(QApplication::translate("Register", "\345\257\206\347\240\201\347\255\224\346\241\210", Q_NULLPTR)); 196 | } // retranslateUi 197 | 198 | }; 199 | 200 | namespace Ui { 201 | class Register: public Ui_Register {}; 202 | } // namespace Ui 203 | 204 | QT_END_NAMESPACE 205 | 206 | #endif // UI_REGISTER_H 207 | -------------------------------------------------------------------------------- /Client/ui_sendfile.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | ** Form generated from reading UI file 'sendfile.ui' 3 | ** 4 | ** Created by: Qt User Interface Compiler version 5.8.0 5 | ** 6 | ** WARNING! All changes made in this file will be lost when recompiling UI file! 7 | ********************************************************************************/ 8 | 9 | #ifndef UI_SENDFILE_H 10 | #define UI_SENDFILE_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | QT_BEGIN_NAMESPACE 26 | 27 | class Ui_Sendfile 28 | { 29 | public: 30 | QFrame *frame_file; 31 | QPushButton *butttonSendFile; 32 | QProgressBar *progressBar; 33 | QPushButton *buttonChooseFile; 34 | QLabel *label_process; 35 | QLineEdit *le_name; 36 | QLabel *label; 37 | QLabel *label_2; 38 | QLineEdit *le_size; 39 | QTextBrowser *textBrowser; 40 | QPushButton *bt_exit; 41 | QLabel *label_recvip; 42 | QLineEdit *le_recv_ip; 43 | QLabel *label_3; 44 | QLineEdit *le_speed; 45 | 46 | void setupUi(QDialog *Sendfile) 47 | { 48 | if (Sendfile->objectName().isEmpty()) 49 | Sendfile->setObjectName(QStringLiteral("Sendfile")); 50 | Sendfile->resize(486, 439); 51 | frame_file = new QFrame(Sendfile); 52 | frame_file->setObjectName(QStringLiteral("frame_file")); 53 | frame_file->setGeometry(QRect(50, 110, 361, 91)); 54 | frame_file->setFrameShape(QFrame::StyledPanel); 55 | frame_file->setFrameShadow(QFrame::Raised); 56 | butttonSendFile = new QPushButton(frame_file); 57 | butttonSendFile->setObjectName(QStringLiteral("butttonSendFile")); 58 | butttonSendFile->setGeometry(QRect(210, 10, 93, 28)); 59 | progressBar = new QProgressBar(frame_file); 60 | progressBar->setObjectName(QStringLiteral("progressBar")); 61 | progressBar->setGeometry(QRect(110, 60, 241, 21)); 62 | progressBar->setValue(0); 63 | buttonChooseFile = new QPushButton(frame_file); 64 | buttonChooseFile->setObjectName(QStringLiteral("buttonChooseFile")); 65 | buttonChooseFile->setGeometry(QRect(30, 10, 93, 28)); 66 | label_process = new QLabel(frame_file); 67 | label_process->setObjectName(QStringLiteral("label_process")); 68 | label_process->setGeometry(QRect(0, 60, 72, 15)); 69 | le_name = new QLineEdit(Sendfile); 70 | le_name->setObjectName(QStringLiteral("le_name")); 71 | le_name->setEnabled(false); 72 | le_name->setGeometry(QRect(140, 20, 241, 21)); 73 | label = new QLabel(Sendfile); 74 | label->setObjectName(QStringLiteral("label")); 75 | label->setGeometry(QRect(70, 20, 72, 15)); 76 | label_2 = new QLabel(Sendfile); 77 | label_2->setObjectName(QStringLiteral("label_2")); 78 | label_2->setGeometry(QRect(40, 50, 101, 21)); 79 | le_size = new QLineEdit(Sendfile); 80 | le_size->setObjectName(QStringLiteral("le_size")); 81 | le_size->setEnabled(false); 82 | le_size->setGeometry(QRect(140, 50, 113, 21)); 83 | textBrowser = new QTextBrowser(Sendfile); 84 | textBrowser->setObjectName(QStringLiteral("textBrowser")); 85 | textBrowser->setGeometry(QRect(50, 210, 361, 191)); 86 | bt_exit = new QPushButton(Sendfile); 87 | bt_exit->setObjectName(QStringLiteral("bt_exit")); 88 | bt_exit->setGeometry(QRect(350, 410, 93, 28)); 89 | label_recvip = new QLabel(Sendfile); 90 | label_recvip->setObjectName(QStringLiteral("label_recvip")); 91 | label_recvip->setGeometry(QRect(40, 80, 81, 16)); 92 | le_recv_ip = new QLineEdit(Sendfile); 93 | le_recv_ip->setObjectName(QStringLiteral("le_recv_ip")); 94 | le_recv_ip->setEnabled(false); 95 | le_recv_ip->setGeometry(QRect(140, 80, 113, 21)); 96 | label_3 = new QLabel(Sendfile); 97 | label_3->setObjectName(QStringLiteral("label_3")); 98 | label_3->setGeometry(QRect(340, 50, 111, 31)); 99 | le_speed = new QLineEdit(Sendfile); 100 | le_speed->setObjectName(QStringLiteral("le_speed")); 101 | le_speed->setEnabled(false); 102 | le_speed->setGeometry(QRect(330, 80, 113, 21)); 103 | 104 | retranslateUi(Sendfile); 105 | 106 | QMetaObject::connectSlotsByName(Sendfile); 107 | } // setupUi 108 | 109 | void retranslateUi(QDialog *Sendfile) 110 | { 111 | Sendfile->setWindowTitle(QApplication::translate("Sendfile", "Dialog", Q_NULLPTR)); 112 | butttonSendFile->setText(QApplication::translate("Sendfile", "\345\274\200\345\247\213\344\274\240\351\200\201", Q_NULLPTR)); 113 | buttonChooseFile->setText(QApplication::translate("Sendfile", "\351\200\211\346\213\251\346\226\207\344\273\266", Q_NULLPTR)); 114 | label_process->setText(QApplication::translate("Sendfile", "\345\217\221\351\200\201\350\277\233\345\272\246\357\274\232", Q_NULLPTR)); 115 | label->setText(QApplication::translate("Sendfile", "\346\226\207\344\273\266\345\220\215\357\274\232", Q_NULLPTR)); 116 | label_2->setText(QApplication::translate("Sendfile", "\346\226\207\344\273\266\346\200\273\345\244\247\345\260\217\357\274\232", Q_NULLPTR)); 117 | le_size->setText(QApplication::translate("Sendfile", "0", Q_NULLPTR)); 118 | bt_exit->setText(QApplication::translate("Sendfile", "\351\200\200\345\207\272", Q_NULLPTR)); 119 | label_recvip->setText(QApplication::translate("Sendfile", "\347\233\256\347\232\204\344\270\273\346\234\272ip\357\274\232", Q_NULLPTR)); 120 | label_3->setText(QApplication::translate("Sendfile", "\346\226\207\344\273\266\344\274\240\350\276\223\351\200\237\347\216\207:", Q_NULLPTR)); 121 | } // retranslateUi 122 | 123 | }; 124 | 125 | namespace Ui { 126 | class Sendfile: public Ui_Sendfile {}; 127 | } // namespace Ui 128 | 129 | QT_END_NAMESPACE 130 | 131 | #endif // UI_SENDFILE_H 132 | -------------------------------------------------------------------------------- /Client/user_imformation.cpp: -------------------------------------------------------------------------------- 1 | #include "user_imformation.h" 2 | 3 | user_imformation::user_imformation(QString myname, int ison, QString myip, int myport, bool myhasbeenConnected) 4 | { 5 | this->username = myname; 6 | this->state = ison; 7 | this->ip = myip; 8 | this->port = myport; 9 | this->hasbeenConnected = myhasbeenConnected; 10 | } 11 | 12 | QString user_imformation::toString() 13 | { 14 | return QString("%1 %2 %3 %4 ").arg(username).arg(state).arg(ip).arg(port); 15 | } 16 | -------------------------------------------------------------------------------- /Client/user_imformation.h: -------------------------------------------------------------------------------- 1 | #ifndef USER_IMFORMATION_H 2 | #define USER_IMFORMATION_H 3 | #include 4 | 5 | class user_imformation 6 | { 7 | public: 8 | QString username; 9 | int state;//1表示在线,0表示不在线 10 | QString ip; 11 | int port; 12 | bool hasbeenConnected; 13 | user_imformation(QString myname, int ison, QString myip, int myport, bool myhasbeenConnected=false); 14 | QString toString(); 15 | }; 16 | 17 | #endif // USER_IMFORMATION_H 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Socket_chat 2 | 3 | tags: socket QT 4 | 5 | * [1.开发平台](#h1) 6 | * [2.基本功能](#h2) 7 | * [3.实现原理](#h3) 8 | 9 |

开发平台

10 | > 基于QT5.8.0 MINGW版本开发 11 | 运行环境为win 64bit 12 | 13 |

基本功能

14 | 1. 工具包括服务器端和客户端;
15 | 2. 具备用户注册、登录、找回密码功能(基于TCP协议); 16 | 3. 两个用户如果同时在线,采用点到点通信方式进行聊天,信息不需要通过服务器中转,服>务器也不保存(基于TCP协议); 17 | 4. 支持离线消息(基于TCP协议); 18 | 5. 支持点到点可靠文件传输(基于UDP协议); 19 | 6. 存储在服务器端的数据需要进行强加密; 20 | 7. 支持不少于两组用户同时在线交流和传输文件; 21 | 8. 文件传输具有良好的性能,能够充分利用网路带宽; 22 | 23 | # 预期实现功能 24 | 25 | > + 服务器端在linux机器上完成,部署到云主机上 26 | > 27 | > + 服务器进程做成主机的服务进程 28 | > 29 | > + 数据库存储用户信息,支持用户注册找回密码,预计支持**邮件**找回密码 30 | > + 文件传输改为TCP,采用多线程传输 31 | > + 支持好友机制,支持图片发送 32 | > + 离线消息存入数据库,读取数据库 33 | 34 | -------------------------------------------------------------------------------- /Server/.qmake.stash: -------------------------------------------------------------------------------- 1 | QMAKE_DEFAULT_INCDIRS = \ 2 | C:/Qt/Qt5.8.0/Tools/mingw530_32/lib/gcc/i686-w64-mingw32/5.3.0/include \ 3 | C:/Qt/Qt5.8.0/Tools/mingw530_32/lib/gcc/i686-w64-mingw32/5.3.0/include-fixed \ 4 | C:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include \ 5 | C:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/c++ \ 6 | C:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/c++/i686-w64-mingw32 \ 7 | C:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/include/c++/backward 8 | QMAKE_DEFAULT_LIBDIRS = \ 9 | C:/Qt/Qt5.8.0/Tools/mingw530_32/lib/gcc/i686-w64-mingw32/5.3.0 \ 10 | C:/Qt/Qt5.8.0/Tools/mingw530_32/lib/gcc \ 11 | C:/Qt/Qt5.8.0/Tools/mingw530_32/i686-w64-mingw32/lib \ 12 | C:/Qt/Qt5.8.0/Tools/mingw530_32/lib 13 | -------------------------------------------------------------------------------- /Server/NP.txt: -------------------------------------------------------------------------------- 1 | MTIzIDEyMyAxMjMgMTIzIGRpbmcgMTIzIDEyMyAxMjMgeWF5YSAxMjMgMTIzIDEyMyBiYWJhIDEyMyAxMjMgMTIzIG1hbWEgMTIzIDEyMyAxMjMgcXFxIDEyMyAxMjMgMTIzIHd3d3cgMTIzIDEyMyAxMjMg -------------------------------------------------------------------------------- /Server/debug/login_server.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Server/debug/login_server.exe -------------------------------------------------------------------------------- /Server/image/1106022.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Server/image/1106022.jpg -------------------------------------------------------------------------------- /Server/login_server.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-11-06T18:20:23 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui network 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = login_server 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which as been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | 26 | SOURCES += main.cpp\ 27 | server.cpp \ 28 | user_information.cpp \ 29 | messagequeue.cpp 30 | 31 | HEADERS += server.h \ 32 | user_information.h \ 33 | messagequeue.h 34 | 35 | FORMS += server.ui 36 | 37 | RESOURCES += \ 38 | src.qrc 39 | -------------------------------------------------------------------------------- /Server/main.cpp: -------------------------------------------------------------------------------- 1 | #include "server.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | server w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Server/messagequeue.cpp: -------------------------------------------------------------------------------- 1 | #include "messagequeue.h" 2 | 3 | messageQueue::messageQueue(QString mymessage, QString myname, messageQueue* mynext, bool mysend) 4 | { 5 | this->message = mymessage; 6 | this->recvname = myname; 7 | this->next = mynext; 8 | this->issended = mysend; 9 | } 10 | -------------------------------------------------------------------------------- /Server/messagequeue.h: -------------------------------------------------------------------------------- 1 | #ifndef MESSAGEQUEUE_H 2 | #define MESSAGEQUEUE_H 3 | 4 | #include 5 | class messageQueue 6 | { 7 | public: 8 | QString message; 9 | QString recvname; //接受者 10 | messageQueue* next; 11 | bool issended; 12 | messageQueue(QString mymessage, QString myname, messageQueue* mynext=NULL, bool mysend=false); 13 | }; 14 | 15 | #endif // MESSAGEQUEUE_H 16 | -------------------------------------------------------------------------------- /Server/release/login_server.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Server/release/login_server.exe -------------------------------------------------------------------------------- /Server/release/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Server/release/main.o -------------------------------------------------------------------------------- /Server/release/messagequeue.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Server/release/messagequeue.o -------------------------------------------------------------------------------- /Server/release/moc_predefs.h: -------------------------------------------------------------------------------- 1 | #define __DBL_MIN_EXP__ (-1021) 2 | #define __cpp_attributes 200809 3 | #define __pentiumpro__ 1 4 | #define __UINT_LEAST16_MAX__ 0xffff 5 | #define __ATOMIC_ACQUIRE 2 6 | #define __FLT_MIN__ 1.17549435082228750797e-38F 7 | #define __GCC_IEC_559_COMPLEX 2 8 | #define __UINT_LEAST8_TYPE__ unsigned char 9 | #define __SIZEOF_FLOAT80__ 12 10 | #define _WIN32 1 11 | #define __INTMAX_C(c) c ## LL 12 | #define __CHAR_BIT__ 8 13 | #define __UINT8_MAX__ 0xff 14 | #define __WINT_MAX__ 0xffff 15 | #define __cpp_static_assert 200410 16 | #define __ORDER_LITTLE_ENDIAN__ 1234 17 | #define __SIZE_MAX__ 0xffffffffU 18 | #define __WCHAR_MAX__ 0xffff 19 | #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 20 | #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 21 | #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 22 | #define __DBL_DENORM_MIN__ double(4.94065645841246544177e-324L) 23 | #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 24 | #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 25 | #define __GCC_IEC_559 2 26 | #define __FLT_EVAL_METHOD__ 2 27 | #define __cpp_binary_literals 201304 28 | #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 29 | #define __cpp_variadic_templates 200704 30 | #define __UINT_FAST64_MAX__ 0xffffffffffffffffULL 31 | #define __SIG_ATOMIC_TYPE__ int 32 | #define __DBL_MIN_10_EXP__ (-307) 33 | #define __FINITE_MATH_ONLY__ 0 34 | #define __GNUC_PATCHLEVEL__ 0 35 | #define __UINT_FAST8_MAX__ 0xff 36 | #define __has_include(STR) __has_include__(STR) 37 | #define _stdcall __attribute__((__stdcall__)) 38 | #define __DEC64_MAX_EXP__ 385 39 | #define __INT8_C(c) c 40 | #define __UINT_LEAST64_MAX__ 0xffffffffffffffffULL 41 | #define __SHRT_MAX__ 0x7fff 42 | #define __LDBL_MAX__ 1.18973149535723176502e+4932L 43 | #define __UINT_LEAST8_MAX__ 0xff 44 | #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 45 | #define __UINTMAX_TYPE__ long long unsigned int 46 | #define __DEC32_EPSILON__ 1E-6DF 47 | #define __OPTIMIZE__ 1 48 | #define __UINT32_MAX__ 0xffffffffU 49 | #define __GXX_EXPERIMENTAL_CXX0X__ 1 50 | #define __LDBL_MAX_EXP__ 16384 51 | #define __WINT_MIN__ 0 52 | #define __SCHAR_MAX__ 0x7f 53 | #define __WCHAR_MIN__ 0 54 | #define __INT64_C(c) c ## LL 55 | #define __DBL_DIG__ 15 56 | #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 57 | #define __SIZEOF_INT__ 4 58 | #define __SIZEOF_POINTER__ 4 59 | #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 60 | #define __USER_LABEL_PREFIX__ _ 61 | #define __STDC_HOSTED__ 1 62 | #define __WIN32 1 63 | #define __LDBL_HAS_INFINITY__ 1 64 | #define __FLT_EPSILON__ 1.19209289550781250000e-7F 65 | #define __GXX_WEAK__ 1 66 | #define __LDBL_MIN__ 3.36210314311209350626e-4932L 67 | #define __DEC32_MAX__ 9.999999E96DF 68 | #define __MINGW32__ 1 69 | #define __INT32_MAX__ 0x7fffffff 70 | #define __SIZEOF_LONG__ 4 71 | #define __UINT16_C(c) c 72 | #define __DECIMAL_DIG__ 21 73 | #define __has_include_next(STR) __has_include_next__(STR) 74 | #define __LDBL_HAS_QUIET_NAN__ 1 75 | #define _REENTRANT 1 76 | #define __GNUC__ 5 77 | #define _cdecl __attribute__((__cdecl__)) 78 | #define __GXX_RTTI 1 79 | #define __cpp_delegating_constructors 200604 80 | #define __FLT_HAS_DENORM__ 1 81 | #define __SIZEOF_LONG_DOUBLE__ 12 82 | #define __BIGGEST_ALIGNMENT__ 16 83 | #define __STDC_UTF_16__ 1 84 | #define __i686 1 85 | #define __DBL_MAX__ double(1.79769313486231570815e+308L) 86 | #define _thiscall __attribute__((__thiscall__)) 87 | #define __cpp_raw_strings 200710 88 | #define __INT_FAST32_MAX__ 0x7fffffff 89 | #define __WINNT 1 90 | #define __DBL_HAS_INFINITY__ 1 91 | #define __INT64_MAX__ 0x7fffffffffffffffLL 92 | #define __WINNT__ 1 93 | #define __DEC32_MIN_EXP__ (-94) 94 | #define __INT_FAST16_TYPE__ short int 95 | #define _fastcall __attribute__((__fastcall__)) 96 | #define __LDBL_HAS_DENORM__ 1 97 | #define __cplusplus 201103L 98 | #define __cpp_ref_qualifiers 200710 99 | #define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL 100 | #define __INT_LEAST32_MAX__ 0x7fffffff 101 | #define __DEC32_MIN__ 1E-95DF 102 | #define __DEPRECATED 1 103 | #define __DBL_MAX_EXP__ 1024 104 | #define __DEC128_EPSILON__ 1E-33DL 105 | #define __ATOMIC_HLE_RELEASE 131072 106 | #define __WIN32__ 1 107 | #define __PTRDIFF_MAX__ 0x7fffffff 108 | #define __ATOMIC_HLE_ACQUIRE 65536 109 | #define __GNUG__ 5 110 | #define __LONG_LONG_MAX__ 0x7fffffffffffffffLL 111 | #define __SIZEOF_SIZE_T__ 4 112 | #define __cpp_rvalue_reference 200610 113 | #define __cpp_nsdmi 200809 114 | #define __SIZEOF_WINT_T__ 2 115 | #define __cpp_initializer_lists 200806 116 | #define __GCC_HAVE_DWARF2_CFI_ASM 1 117 | #define __GXX_ABI_VERSION 1009 118 | #define __FLT_MIN_EXP__ (-125) 119 | #define __i686__ 1 120 | #define __cpp_lambdas 200907 121 | #define __INT_FAST64_TYPE__ long long int 122 | #define __DBL_MIN__ double(2.22507385850720138309e-308L) 123 | #define __FLT_MIN_10_EXP__ (-37) 124 | #define __DECIMAL_BID_FORMAT__ 1 125 | #define __GXX_TYPEINFO_EQUALITY_INLINE 0 126 | #define __DEC128_MIN__ 1E-6143DL 127 | #define __REGISTER_PREFIX__ 128 | #define __UINT16_MAX__ 0xffff 129 | #define __DBL_HAS_DENORM__ 1 130 | #define __cdecl __attribute__((__cdecl__)) 131 | #define __UINT8_TYPE__ unsigned char 132 | #define __i386 1 133 | #define __FLT_MANT_DIG__ 24 134 | #define __VERSION__ "5.3.0" 135 | #define __UINT64_C(c) c ## ULL 136 | #define __cpp_unicode_characters 200704 137 | #define __GCC_ATOMIC_INT_LOCK_FREE 2 138 | #define _X86_ 1 139 | #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ 140 | #define __INT32_C(c) c 141 | #define __DEC64_EPSILON__ 1E-15DD 142 | #define __ORDER_PDP_ENDIAN__ 3412 143 | #define __DEC128_MIN_EXP__ (-6142) 144 | #define __code_model_32__ 1 145 | #define __INT_FAST32_TYPE__ int 146 | #define __UINT_LEAST16_TYPE__ short unsigned int 147 | #define __INT16_MAX__ 0x7fff 148 | #define __i386__ 1 149 | #define __cpp_rtti 199711 150 | #define __SIZE_TYPE__ unsigned int 151 | #define __UINT64_MAX__ 0xffffffffffffffffULL 152 | #define __INT8_TYPE__ signed char 153 | #define __FLT_RADIX__ 2 154 | #define __INT_LEAST16_TYPE__ short int 155 | #define __LDBL_EPSILON__ 1.08420217248550443401e-19L 156 | #define __UINTMAX_C(c) c ## ULL 157 | #define __SIG_ATOMIC_MAX__ 0x7fffffff 158 | #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 159 | #define __SIZEOF_PTRDIFF_T__ 4 160 | #define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF 161 | #define __pentiumpro 1 162 | #define __MSVCRT__ 1 163 | #define __INT_FAST16_MAX__ 0x7fff 164 | #define __UINT_FAST32_MAX__ 0xffffffffU 165 | #define __UINT_LEAST64_TYPE__ long long unsigned int 166 | #define __FLT_HAS_QUIET_NAN__ 1 167 | #define __FLT_MAX_10_EXP__ 38 168 | #define __LONG_MAX__ 0x7fffffffL 169 | #define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL 170 | #define __FLT_HAS_INFINITY__ 1 171 | #define __cpp_unicode_literals 200710 172 | #define __UINT_FAST16_TYPE__ short unsigned int 173 | #define __DEC64_MAX__ 9.999999999999999E384DD 174 | #define __CHAR16_TYPE__ short unsigned int 175 | #define __PRAGMA_REDEFINE_EXTNAME 1 176 | #define __INT_LEAST16_MAX__ 0x7fff 177 | #define __DEC64_MANT_DIG__ 16 178 | #define __UINT_LEAST32_MAX__ 0xffffffffU 179 | #define __GCC_ATOMIC_LONG_LOCK_FREE 2 180 | #define __INT_LEAST64_TYPE__ long long int 181 | #define __INT16_TYPE__ short int 182 | #define __INT_LEAST8_TYPE__ signed char 183 | #define __DEC32_MAX_EXP__ 97 184 | #define __INT_FAST8_MAX__ 0x7f 185 | #define __INTPTR_MAX__ 0x7fffffff 186 | #define __GXX_MERGED_TYPEINFO_NAMES 0 187 | #define __cpp_range_based_for 200907 188 | #define __stdcall __attribute__((__stdcall__)) 189 | #define __EXCEPTIONS 1 190 | #define __LDBL_MANT_DIG__ 64 191 | #define __DBL_HAS_QUIET_NAN__ 1 192 | #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) 193 | #define __INTPTR_TYPE__ int 194 | #define __UINT16_TYPE__ short unsigned int 195 | #define __WCHAR_TYPE__ short unsigned int 196 | #define __SIZEOF_FLOAT__ 4 197 | #define __UINTPTR_MAX__ 0xffffffffU 198 | #define __DEC64_MIN_EXP__ (-382) 199 | #define __cpp_decltype 200707 200 | #define __INT_FAST64_MAX__ 0x7fffffffffffffffLL 201 | #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 202 | #define __FLT_DIG__ 6 203 | #define __UINT_FAST64_TYPE__ long long unsigned int 204 | #define __INT_MAX__ 0x7fffffff 205 | #define WIN32 1 206 | #define __INT64_TYPE__ long long int 207 | #define __FLT_MAX_EXP__ 128 208 | #define __DBL_MANT_DIG__ 53 209 | #define __cpp_inheriting_constructors 200802 210 | #define __SIZEOF_FLOAT128__ 16 211 | #define __INT_LEAST64_MAX__ 0x7fffffffffffffffLL 212 | #define __DEC64_MIN__ 1E-383DD 213 | #define __WINT_TYPE__ short unsigned int 214 | #define __UINT_LEAST32_TYPE__ unsigned int 215 | #define __SIZEOF_SHORT__ 2 216 | #define __LDBL_MIN_EXP__ (-16381) 217 | #define __INT_LEAST8_MAX__ 0x7f 218 | #define __WCHAR_UNSIGNED__ 1 219 | #define __LDBL_MAX_10_EXP__ 4932 220 | #define __ATOMIC_RELAXED 0 221 | #define __DBL_EPSILON__ double(2.22044604925031308085e-16L) 222 | #define __thiscall __attribute__((__thiscall__)) 223 | #define __UINT8_C(c) c 224 | #define __INT_LEAST32_TYPE__ int 225 | #define __SIZEOF_WCHAR_T__ 2 226 | #define __UINT64_TYPE__ long long unsigned int 227 | #define __INT_FAST8_TYPE__ signed char 228 | #define __fastcall __attribute__((__fastcall__)) 229 | #define __GNUC_STDC_INLINE__ 1 230 | #define __DBL_DECIMAL_DIG__ 17 231 | #define __STDC_UTF_32__ 1 232 | #define __DEC_EVAL_METHOD__ 2 233 | #define __ORDER_BIG_ENDIAN__ 4321 234 | #define __cpp_runtime_arrays 198712 235 | #define __UINT32_C(c) c ## U 236 | #define __INTMAX_MAX__ 0x7fffffffffffffffLL 237 | #define __cpp_alias_templates 200704 238 | #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ 239 | #define WINNT 1 240 | #define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F 241 | #define __INT8_MAX__ 0x7f 242 | #define __UINT_FAST32_TYPE__ unsigned int 243 | #define __CHAR32_TYPE__ unsigned int 244 | #define __FLT_MAX__ 3.40282346638528859812e+38F 245 | #define __cpp_constexpr 200704 246 | #define __INT32_TYPE__ int 247 | #define __SIZEOF_DOUBLE__ 8 248 | #define __cpp_exceptions 199711 249 | #define __INTMAX_TYPE__ long long int 250 | #define i386 1 251 | #define _INTEGRAL_MAX_BITS 64 252 | #define __DEC128_MAX_EXP__ 6145 253 | #define __ATOMIC_CONSUME 1 254 | #define __GNUC_MINOR__ 3 255 | #define __UINTMAX_MAX__ 0xffffffffffffffffULL 256 | #define __DEC32_MANT_DIG__ 7 257 | #define __DBL_MAX_10_EXP__ 308 258 | #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L 259 | #define __INT16_C(c) c 260 | #define __STDC__ 1 261 | #define __PTRDIFF_TYPE__ int 262 | #define __ATOMIC_SEQ_CST 5 263 | #define __UINT32_TYPE__ unsigned int 264 | #define __UINTPTR_TYPE__ unsigned int 265 | #define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD 266 | #define __DEC128_MANT_DIG__ 34 267 | #define __LDBL_MIN_10_EXP__ (-4931) 268 | #define __SIZEOF_LONG_LONG__ 8 269 | #define __cpp_user_defined_literals 200809 270 | #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 271 | #define __LDBL_DIG__ 18 272 | #define __FLT_DECIMAL_DIG__ 9 273 | #define __UINT_FAST16_MAX__ 0xffff 274 | #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 275 | #define __UINT_FAST8_TYPE__ unsigned char 276 | #define __ATOMIC_ACQ_REL 4 277 | #define __ATOMIC_RELEASE 3 278 | #define __declspec(x) __attribute__((x)) 279 | -------------------------------------------------------------------------------- /Server/release/moc_server.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Meta object code from reading C++ file 'server.h' 3 | ** 4 | ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.8.0) 5 | ** 6 | ** WARNING! All changes made in this file will be lost! 7 | *****************************************************************************/ 8 | 9 | #include "../server.h" 10 | #include 11 | #include 12 | #if !defined(Q_MOC_OUTPUT_REVISION) 13 | #error "The header file 'server.h' doesn't include ." 14 | #elif Q_MOC_OUTPUT_REVISION != 67 15 | #error "This file was generated using the moc from 5.8.0. It" 16 | #error "cannot be used with the include files from this version of Qt." 17 | #error "(The moc has changed too much.)" 18 | #endif 19 | 20 | QT_BEGIN_MOC_NAMESPACE 21 | QT_WARNING_PUSH 22 | QT_WARNING_DISABLE_DEPRECATED 23 | struct qt_meta_stringdata_server_t { 24 | QByteArrayData data[3]; 25 | char stringdata0[27]; 26 | }; 27 | #define QT_MOC_LITERAL(idx, ofs, len) \ 28 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ 29 | qptrdiff(offsetof(qt_meta_stringdata_server_t, stringdata0) + ofs \ 30 | - idx * sizeof(QByteArrayData)) \ 31 | ) 32 | static const qt_meta_stringdata_server_t qt_meta_stringdata_server = { 33 | { 34 | QT_MOC_LITERAL(0, 0, 6), // "server" 35 | QT_MOC_LITERAL(1, 7, 18), // "on_bt_save_clicked" 36 | QT_MOC_LITERAL(2, 26, 0) // "" 37 | 38 | }, 39 | "server\0on_bt_save_clicked\0" 40 | }; 41 | #undef QT_MOC_LITERAL 42 | 43 | static const uint qt_meta_data_server[] = { 44 | 45 | // content: 46 | 7, // revision 47 | 0, // classname 48 | 0, 0, // classinfo 49 | 1, 14, // methods 50 | 0, 0, // properties 51 | 0, 0, // enums/sets 52 | 0, 0, // constructors 53 | 0, // flags 54 | 0, // signalCount 55 | 56 | // slots: name, argc, parameters, tag, flags 57 | 1, 0, 19, 2, 0x08 /* Private */, 58 | 59 | // slots: parameters 60 | QMetaType::Void, 61 | 62 | 0 // eod 63 | }; 64 | 65 | void server::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) 66 | { 67 | if (_c == QMetaObject::InvokeMetaMethod) { 68 | server *_t = static_cast(_o); 69 | Q_UNUSED(_t) 70 | switch (_id) { 71 | case 0: _t->on_bt_save_clicked(); break; 72 | default: ; 73 | } 74 | } 75 | Q_UNUSED(_a); 76 | } 77 | 78 | const QMetaObject server::staticMetaObject = { 79 | { &QWidget::staticMetaObject, qt_meta_stringdata_server.data, 80 | qt_meta_data_server, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} 81 | }; 82 | 83 | 84 | const QMetaObject *server::metaObject() const 85 | { 86 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; 87 | } 88 | 89 | void *server::qt_metacast(const char *_clname) 90 | { 91 | if (!_clname) return Q_NULLPTR; 92 | if (!strcmp(_clname, qt_meta_stringdata_server.stringdata0)) 93 | return static_cast(const_cast< server*>(this)); 94 | return QWidget::qt_metacast(_clname); 95 | } 96 | 97 | int server::qt_metacall(QMetaObject::Call _c, int _id, void **_a) 98 | { 99 | _id = QWidget::qt_metacall(_c, _id, _a); 100 | if (_id < 0) 101 | return _id; 102 | if (_c == QMetaObject::InvokeMetaMethod) { 103 | if (_id < 1) 104 | qt_static_metacall(this, _c, _id, _a); 105 | _id -= 1; 106 | } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { 107 | if (_id < 1) 108 | *reinterpret_cast(_a[0]) = -1; 109 | _id -= 1; 110 | } 111 | return _id; 112 | } 113 | QT_WARNING_POP 114 | QT_END_MOC_NAMESPACE 115 | -------------------------------------------------------------------------------- /Server/release/moc_server.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Server/release/moc_server.o -------------------------------------------------------------------------------- /Server/release/qrc_src.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Server/release/qrc_src.o -------------------------------------------------------------------------------- /Server/release/server.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Server/release/server.o -------------------------------------------------------------------------------- /Server/release/user_information.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/Server/release/user_information.o -------------------------------------------------------------------------------- /Server/server.cpp: -------------------------------------------------------------------------------- 1 | #include "server.h" 2 | #include "ui_server.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "user_information.h" 8 | #include "messagequeue.h" 9 | 10 | 11 | int currentsize; //总的下标位置 12 | 13 | struct user_data 14 | { 15 | user_imformation *v[M]; 16 | int size; //用户数 17 | }*User_data; 18 | 19 | messageQueue* Me; 20 | 21 | bool isfirst =false; 22 | 23 | int mode[M]; 24 | enum {Acceptlogin=0, Chat}; //登录交流和离线消息发送 25 | 26 | int indexofv; 27 | 28 | server::server(QWidget *parent) : 29 | QWidget(parent), 30 | ui(new Ui::server) 31 | { 32 | ui->setupUi(this); 33 | User_data = new user_data(); 34 | for (int i=0; iv[i] = NULL; 37 | mode[i] = Chat; 38 | } 39 | indexofv = 0; 40 | User_data->size = 0; 41 | currentsize = 0; 42 | Me = NULL; 43 | isfirst = true; 44 | userload(); //加载用户信息 45 | userstateupdate(); 46 | QTime t = QTime::currentTime(); 47 | qsrand(t.msec()+t.second()*1000); 48 | 49 | QString localHostName = QHostInfo::localHostName(); 50 | qDebug() <<"localHostName: "<textBrowser->append(address.toString()); 58 | } 59 | } 60 | for(int i=0;i listen(QHostAddress::Any,8888); 68 | setWindowTitle(QString("服务器端口:8888")); 69 | ui->bt_save->hide(); 70 | connect(tcpServer,&QTcpServer::newConnection, 71 | [=]() 72 | { 73 | //获取通信套接字 74 | int index = currentsize;//currentsize为1的时候只有一个套接字 75 | tcpSocket[index] = tcpServer->nextPendingConnection(); 76 | 77 | currentsize++; //每次总个数总要发生变化,但是单独的下标不发生变化 78 | 79 | //获取对方IP、port 80 | QString ip = tcpSocket[index]->peerAddress().toString().section(":",3,3); 81 | // QString ip = tcpSocket[index]->peerAddress().toString(); 82 | quint16 port = tcpSocket[index]->peerPort(); 83 | 84 | QString str = QString("[%1:%2]:成功连接").arg(ip).arg(port); 85 | ui->textBrowser->append(str); 86 | 87 | 88 | connect(tcpSocket[index], &QTcpSocket::connected, //连接上的处理操作 89 | [=]() 90 | { 91 | 92 | //消息队列处理 93 | 94 | ui->bt_save->setEnabled(false);//此时不能保存 95 | 96 | }); 97 | 98 | connect(tcpSocket[index], &QTcpSocket::disconnected, //断开连接的操作 99 | [=]() 100 | { 101 | QString str2 = QString("[%1:%2]:断开连接").arg(ip).arg(port); 102 | ui->textBrowser->append(str2); 103 | for(int i=0; isize; i++) 104 | { 105 | // if(User_data->v[i]->ip == ip && User_data->v[i]->port == port) 106 | if(User_data->v[i]->ip == ip) 107 | { 108 | ui->textBrowser->append(QString("%1离线了").arg(User_data->v[i]->username)); 109 | User_data->v[i]->state = 0; //离线 110 | break; 111 | } 112 | } 113 | if(index < currentsize-1) //不是在最后一个,需要改变指针数组里面元素的值 114 | { 115 | for(int i=index; ireadAll(); 128 | //采用回射信息进行粘包处理 129 | 130 | if(mode[index] == Acceptlogin) 131 | { 132 | if("login" == QString(buf).section("##",0,0)) //login 133 | { 134 | //比较密码 135 | qDebug() << "login"; 136 | bool ispass=false; 137 | for(int i=0; isize; i++) 138 | { 139 | if(User_data->v[i]->username == QString(buf).section("##",1,1) 140 | && User_data->v[i]->password == QString(buf).section("##",2,2)) 141 | { 142 | ispass = true; //通过 143 | ui->textBrowser->append(QString("%1上线了").arg(User_data->v[i]->username)); 144 | User_data->v[i]->state = 1; //在线 145 | User_data->v[i]->ip = ip; 146 | User_data->v[i]->port = qrand()%10000+10000; //存储 客户端服务器port信息 的地方,由自己定 147 | 148 | break; 149 | } 150 | } 151 | if(ispass) //##login successed##dingding 152 | { 153 | //发送离线消息 154 | 155 | tcpSocket[index]->write(QString("##login successed##%1").arg(QString(buf).section("##",1,1)).toUtf8()); 156 | qDebug() << "##login successed##%1"; 157 | } 158 | else 159 | { 160 | tcpSocket[index]->write(QString("##login fail##%1").arg(QString(buf).section("##",1,1)).toUtf8()); 161 | mode[index] = Chat; 162 | } 163 | 164 | } 165 | else if("register" == QString(buf).section("##",0,0) )//注册 166 | { 167 | qDebug() << "regsiter"; 168 | QString myname = QString(buf).section("##",1,1); 169 | QString mypassword = QString(buf).section("##",2,2); 170 | QString myquestion = QString(buf).section("##",3,3); 171 | QString myanswer = QString(buf).section("##",4,4); 172 | bool islogined=false; 173 | for(int i=0; isize; i++) 174 | { 175 | if(User_data->v[i]->username == myname) 176 | { 177 | islogined = true; //注册过 178 | break; 179 | } 180 | } 181 | if(!islogined) //未注册过 182 | { 183 | int newport = qrand()%10000+10000; //存储 客户端服务器port信息 的地方,由自己定 184 | User_data->v[User_data->size] = new user_imformation(myname, mypassword, myquestion, myanswer,1, ip, newport); 185 | User_data->size++; //需要改变大小 186 | 187 | tcpSocket[index]->write(QString("##register successed##%1").arg(myname).toUtf8()); 188 | on_bt_save_clicked(); //保存数据 189 | qDebug() << "##register successed##%1"; 190 | } 191 | 192 | else //已经注册过 193 | { 194 | tcpSocket[index]->write("register failed! 重复用户名"); 195 | mode[index] = Chat; 196 | } 197 | } 198 | else if("find" == QString(buf).section("##",0,0) ) //找回密码 199 | { 200 | qDebug() << "find"; 201 | QString findname = QString(buf).section("##",1,1); 202 | bool isreturnquestion =false; 203 | for(int i=0; isize; i++) 204 | { 205 | if(User_data->v[i]->username == findname) 206 | { 207 | indexofv = i; //存下此时的i 208 | isreturnquestion = true; 209 | tcpSocket[index]->write(QString("##question##%1").arg(User_data->v[i]->question).toUtf8()); //发送问题 210 | qDebug() << "##question##%1"; 211 | } 212 | 213 | } 214 | if(!isreturnquestion) //问题返回 215 | { 216 | tcpSocket[index]->write("user don't exist"); //不存在用户 217 | mode[index] = Chat; 218 | } 219 | } 220 | else if("answer" == QString(buf).section("##",0,0))//传输回来的问题答案 221 | { 222 | QString answer = QString(buf).section("##",1,1); 223 | if(User_data->v[indexofv]->answer == answer) //##answer is right##dingding##123 224 | { 225 | ui->textBrowser->append(QString("%1上线了").arg(User_data->v[indexofv]->username)); 226 | User_data->v[indexofv]->state = 1; //在线 227 | User_data->v[indexofv]->ip = ip; 228 | User_data->v[indexofv]->port = qrand()%10000+10000; //存储 客户端服务器port信息 的地方,由自己定 229 | tcpSocket[index]->write(QString("##answer is right##%1##%2"). 230 | arg(User_data->v[indexofv]->username).arg(User_data->v[indexofv]->password).toUtf8()); 231 | 232 | qDebug() << "##answer is right##%1##%2"; 233 | } 234 | else 235 | { 236 | tcpSocket[index]->write("the answer is wrong"); 237 | mode[index] = Chat; 238 | } 239 | 240 | } 241 | else if("##login succeed, request for user_imformation" == QString(buf)) 242 | { 243 | userstateupdate(); 244 | ui->bt_save->setEnabled(true); 245 | } 246 | else if("Offline message" == QString(buf).section("##",0,0)) 247 | { 248 | qDebug() << "开始传递离线消息"; 249 | handlemessage(QString(buf).section("##",1,1),tcpSocket[index]); 250 | mode[index] = Chat; 251 | } 252 | else 253 | { 254 | ui->textBrowser->append(QString("登录失败")); 255 | tcpSocket[index]->disconnectFromHost(); //服务器断开连接 256 | mode[index] = Chat; //登录失败 257 | 258 | } 259 | } 260 | else if(mode[index] == Chat) 261 | { 262 | if("##request for login" == QString(buf)) //登录类请求 263 | { 264 | qDebug() << "##request for login"; 265 | tcpSocket[index]->write("##permission for login"); 266 | qDebug() << "##permission for login"; 267 | mode[index] = Acceptlogin; 268 | } 269 | else //离线消息队列 270 | { 271 | qDebug() << "普通消息:" << QString(buf); 272 | QString recvname = QString(buf).section("##",2,2); 273 | for(int i=0; isize; i++) 274 | { 275 | qDebug() << i << " " << User_data->size << " " << User_data->v[i]->username; 276 | if(recvname == User_data->v[i]->username) 277 | { 278 | if(User_data->v[i]->state == 1) //在线 279 | { 280 | for(int j=0; jpeerAddress().toString().section(":",3,3) 283 | if(tcpSocket[j]->peerAddress().toString().section(":",3,3) == User_data->v[i]->ip) //找到相等的ip说明发给这个人 284 | { 285 | tcpSocket[j]->write(buf); 286 | break; 287 | } 288 | } 289 | } 290 | else //离线 291 | { 292 | messageQueue* m = Me; 293 | if(Me == NULL) //如果首队列为空 294 | { 295 | Me = new messageQueue(QString(buf), QString(buf).section("##",2,2)); 296 | } 297 | else //添加最后一个为空的队列 298 | { 299 | while(m->next != NULL) 300 | { 301 | m = m->next; 302 | } 303 | m->next = new messageQueue(QString(buf), QString(buf).section("##",2,2)); 304 | } 305 | } 306 | break; 307 | } 308 | } 309 | } 310 | } 311 | }); //函数完毕 312 | }); 313 | 314 | } 315 | 316 | server::~server() 317 | { 318 | delete User_data; 319 | User_data =NULL; 320 | delete ui; 321 | } 322 | 323 | void server::userload() 324 | { 325 | QFile myfile("NP.txt"); 326 | qDebug() << "读取数据"; 327 | if(myfile.open(QIODevice::ReadOnly | QIODevice :: Text)) 328 | { 329 | /*文本输出流,用于保存数据*/ 330 | QByteArray a = QByteArray::fromBase64(myfile.readAll()); 331 | QString b = QString(a); 332 | QTextStream in(&b); 333 | QString username = ""; 334 | QString password = ""; 335 | QString question = ""; 336 | QString answer = ""; 337 | User_data->size = 0; 338 | while( !in.atEnd()) //未到文件尾 339 | { 340 | in >> username; 341 | if(username != "") 342 | { 343 | qDebug() << username; 344 | in >> password; 345 | in >> question; 346 | in >> answer; 347 | User_data->v[User_data->size] = new user_imformation(username, password, question, answer); 348 | User_data->size++; 349 | } 350 | else 351 | { 352 | break; 353 | } 354 | } 355 | myfile.close(); 356 | 357 | } 358 | else //用户密码文件打开失败 359 | { 360 | QMessageBox::warning(this, "Warning!", "用户密码文件打开失败", QMessageBox::Yes); 361 | close(); //退出 362 | } 363 | } 364 | 365 | void server::userstateupdate() 366 | { 367 | qDebug() << "状态更新,用户数:" << User_data->size; 368 | ui->le_usernum_off->clear(); 369 | ui->le_usernum_on->clear(); 370 | ui->tb_off->clear(); 371 | ui->tb_on->clear(); 372 | int num_on=0, num_off=0; 373 | QString updatemessage = QString("load users' states##%1##").arg(User_data->size); 374 | for(int i=0; isize; i++) 375 | { 376 | updatemessage = updatemessage.append(User_data->v[i]->toString()); 377 | // ui->textBrowser->append(QString::number(User_data->v[i]->state) +" " + User_data->v[i]->username); 378 | if(User_data->v[i]->state == 1) //在线 379 | { 380 | ui->tb_on->append(User_data->v[i]->username); 381 | num_on ++; 382 | } 383 | else 384 | { 385 | ui->tb_off->append(User_data->v[i]->username); 386 | num_off ++; 387 | } 388 | } 389 | ui->le_usernum_on->setText(QString::number(num_on, 10)); 390 | ui->le_usernum_off->setText(QString::number(num_off, 10)); 391 | if(isfirst) //第一次加载不需要发送 392 | { 393 | isfirst = false; 394 | } 395 | else 396 | { 397 | for(int i=0; iisOpen()) 400 | { 401 | qDebug() << "状态信息发送给的客户端下标:" << i; 402 | tcpSocket[i]->write(updatemessage.toUtf8()); //发送更新消息 403 | } 404 | else 405 | { 406 | break; 407 | } 408 | } 409 | } 410 | 411 | } 412 | 413 | void server::handlemessage(QString myname, QTcpSocket* socket) //用户发出离线消息请求 414 | { 415 | messageQueue *a=Me; 416 | QString sendmessage = ""; 417 | int count = 0; 418 | while(a) //不为空 419 | { 420 | if(a->recvname == myname) //要发送给的对象一样选择发送 421 | { 422 | // socket->write(a->message.toUtf8()); //发送消息 423 | sendmessage.append(QString("&&%1").arg(a->message)); 424 | count ++; 425 | a->issended = true; //已经被发送 426 | } 427 | a = a->next; 428 | } 429 | if(count != 0) 430 | { 431 | QString sendmessage2 = QString("offline message&&%1").arg(count).append(sendmessage); 432 | socket->write(sendmessage2.toUtf8()); 433 | } 434 | // QMessageBox::information(this, "提示!", "离线消息发送完毕", QMessageBox::Yes); 435 | ui->textBrowser->append("离线消息发送完毕"); 436 | //开始清理已经发送过的消息 437 | messageQueue* head = Me; 438 | while(head!=NULL && head->issended) //找到第一个未被发送的信息 439 | { 440 | messageQueue* pre = head; 441 | head = head->next; 442 | delete pre; //销毁空间 443 | pre = NULL; 444 | } 445 | if(head == NULL) 446 | { 447 | Me = NULL; //头结点为空 448 | } 449 | else 450 | { 451 | Me = head; //头结点重新定位 452 | messageQueue* p = Me; //定位未发送节点 453 | messageQueue* q = Me->next; //定位未发送节点的下一位 454 | while(q != NULL) 455 | { 456 | if(q->issended) //发送过了 457 | { 458 | while(q!= NULL && q->issended) //寻找下一个未发送的节点 459 | { 460 | messageQueue* later = q; 461 | q = q->next; 462 | delete later; //销毁空间 463 | later = NULL; 464 | } 465 | if(q == NULL) //全部发送了 466 | { 467 | //不做啥 468 | } 469 | else 470 | { 471 | p = q; //q此时未发送 472 | q = p->next; 473 | } 474 | } //q未发送 475 | else 476 | { 477 | p = q; 478 | q = p->next; 479 | } 480 | } 481 | } 482 | 483 | } 484 | 485 | void server::on_bt_save_clicked() 486 | { 487 | //文件保存 488 | QFile myfile("NP.txt"); 489 | if(myfile.open(QIODevice::WriteOnly)) //以文本文式写入 490 | { 491 | QByteArray in; 492 | for(int i=0; isize; i++) 493 | { 494 | in.append(User_data->v[i]->username.toUtf8()); 495 | in.append(QString(" ").toUtf8()); 496 | in.append(User_data->v[i]->password.toUtf8()); 497 | in.append(QString(" ").toUtf8()); 498 | in.append(User_data->v[i]->question.toUtf8()); 499 | in.append(QString(" ").toUtf8()); 500 | in.append(User_data->v[i]->answer.toUtf8()); 501 | in.append(QString(" ").toUtf8()); 502 | } 503 | myfile.write(in.toBase64()); 504 | myfile.close(); 505 | } 506 | else 507 | { 508 | QMessageBox::warning(this, "Warning!", "用户密码文件打开失败", QMessageBox::Yes); 509 | close(); //退出 510 | } 511 | } 512 | 513 | -------------------------------------------------------------------------------- /Server/server.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVER_H 2 | #define SERVER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | const int M=20; 11 | 12 | namespace Ui { 13 | class server; 14 | } 15 | 16 | class server : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit server(QWidget *parent = 0); 22 | ~server(); 23 | void userload(); 24 | void handlemessage(QString myname, QTcpSocket *a); 25 | void userstateupdate(); 26 | 27 | private slots: 28 | void on_bt_save_clicked(); 29 | 30 | private: 31 | Ui::server *ui; 32 | QTcpServer * tcpServer; //监听 33 | QTcpSocket * tcpSocket[M]; //通信 34 | QTimer timer; //定时器 35 | }; 36 | 37 | #endif // SERVER_H 38 | -------------------------------------------------------------------------------- /Server/server.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | server 4 | 5 | 6 | 7 | 0 8 | 0 9 | 725 10 | 475 11 | 12 | 13 | 14 | server 15 | 16 | 17 | #server {background-image: url(:/new/prefix1/image/1106022.jpg);} 18 | 19 | 20 | 21 | 22 | 290 23 | 20 24 | 91 25 | 31 26 | 27 | 28 | 29 | font: 75 14pt "Agency FB"; 30 | 31 | 32 | 服务器端 33 | 34 | 35 | 36 | 37 | 38 | 0 39 | 70 40 | 281 41 | 291 42 | 43 | 44 | 45 | 46 | 47 | 48 | 290 49 | 70 50 | 211 51 | 291 52 | 53 | 54 | 55 | QFrame::StyledPanel 56 | 57 | 58 | QFrame::Raised 59 | 60 | 61 | 62 | false 63 | 64 | 65 | 66 | 110 67 | 10 68 | 81 69 | 21 70 | 71 | 72 | 73 | 74 | 75 | 76 | 0 77 | 10 78 | 101 79 | 20 80 | 81 | 82 | 83 | 在线用户数量: 84 | 85 | 86 | 87 | 88 | 89 | 10 90 | 50 91 | 171 92 | 211 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 510 101 | 70 102 | 211 103 | 291 104 | 105 | 106 | 107 | QFrame::StyledPanel 108 | 109 | 110 | QFrame::Raised 111 | 112 | 113 | 114 | 115 | 1 116 | 10 117 | 101 118 | 20 119 | 120 | 121 | 122 | 离线用户数量: 123 | 124 | 125 | 126 | 127 | false 128 | 129 | 130 | 131 | 110 132 | 10 133 | 81 134 | 21 135 | 136 | 137 | 138 | 139 | 140 | 141 | 10 142 | 50 143 | 171 144 | 211 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 310 153 | 400 154 | 93 155 | 28 156 | 157 | 158 | 159 | 保存用户信息 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /Server/src.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | image/1106022.jpg 4 | 5 | 6 | -------------------------------------------------------------------------------- /Server/ui_server.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | ** Form generated from reading UI file 'server.ui' 3 | ** 4 | ** Created by: Qt User Interface Compiler version 5.8.0 5 | ** 6 | ** WARNING! All changes made in this file will be lost when recompiling UI file! 7 | ********************************************************************************/ 8 | 9 | #ifndef UI_SERVER_H 10 | #define UI_SERVER_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | QT_BEGIN_NAMESPACE 25 | 26 | class Ui_server 27 | { 28 | public: 29 | QLabel *label; 30 | QTextBrowser *textBrowser; 31 | QFrame *frame_client_on; 32 | QLineEdit *le_usernum_on; 33 | QLabel *label_7; 34 | QTextBrowser *tb_on; 35 | QFrame *frame_client_off; 36 | QLabel *label_8; 37 | QLineEdit *le_usernum_off; 38 | QTextBrowser *tb_off; 39 | QPushButton *bt_save; 40 | 41 | void setupUi(QWidget *server) 42 | { 43 | if (server->objectName().isEmpty()) 44 | server->setObjectName(QStringLiteral("server")); 45 | server->resize(725, 475); 46 | server->setStyleSheet(QStringLiteral("#server {background-image: url(:/new/prefix1/image/1106022.jpg);}")); 47 | label = new QLabel(server); 48 | label->setObjectName(QStringLiteral("label")); 49 | label->setGeometry(QRect(290, 20, 91, 31)); 50 | label->setStyleSheet(QStringLiteral("font: 75 14pt \"Agency FB\";")); 51 | textBrowser = new QTextBrowser(server); 52 | textBrowser->setObjectName(QStringLiteral("textBrowser")); 53 | textBrowser->setGeometry(QRect(0, 70, 281, 291)); 54 | frame_client_on = new QFrame(server); 55 | frame_client_on->setObjectName(QStringLiteral("frame_client_on")); 56 | frame_client_on->setGeometry(QRect(290, 70, 211, 291)); 57 | frame_client_on->setFrameShape(QFrame::StyledPanel); 58 | frame_client_on->setFrameShadow(QFrame::Raised); 59 | le_usernum_on = new QLineEdit(frame_client_on); 60 | le_usernum_on->setObjectName(QStringLiteral("le_usernum_on")); 61 | le_usernum_on->setEnabled(false); 62 | le_usernum_on->setGeometry(QRect(110, 10, 81, 21)); 63 | label_7 = new QLabel(frame_client_on); 64 | label_7->setObjectName(QStringLiteral("label_7")); 65 | label_7->setGeometry(QRect(0, 10, 101, 20)); 66 | tb_on = new QTextBrowser(frame_client_on); 67 | tb_on->setObjectName(QStringLiteral("tb_on")); 68 | tb_on->setGeometry(QRect(10, 50, 171, 211)); 69 | frame_client_off = new QFrame(server); 70 | frame_client_off->setObjectName(QStringLiteral("frame_client_off")); 71 | frame_client_off->setGeometry(QRect(510, 70, 211, 291)); 72 | frame_client_off->setFrameShape(QFrame::StyledPanel); 73 | frame_client_off->setFrameShadow(QFrame::Raised); 74 | label_8 = new QLabel(frame_client_off); 75 | label_8->setObjectName(QStringLiteral("label_8")); 76 | label_8->setGeometry(QRect(1, 10, 101, 20)); 77 | le_usernum_off = new QLineEdit(frame_client_off); 78 | le_usernum_off->setObjectName(QStringLiteral("le_usernum_off")); 79 | le_usernum_off->setEnabled(false); 80 | le_usernum_off->setGeometry(QRect(110, 10, 81, 21)); 81 | tb_off = new QTextBrowser(frame_client_off); 82 | tb_off->setObjectName(QStringLiteral("tb_off")); 83 | tb_off->setGeometry(QRect(10, 50, 171, 211)); 84 | bt_save = new QPushButton(server); 85 | bt_save->setObjectName(QStringLiteral("bt_save")); 86 | bt_save->setGeometry(QRect(310, 400, 93, 28)); 87 | 88 | retranslateUi(server); 89 | 90 | QMetaObject::connectSlotsByName(server); 91 | } // setupUi 92 | 93 | void retranslateUi(QWidget *server) 94 | { 95 | server->setWindowTitle(QApplication::translate("server", "server", Q_NULLPTR)); 96 | label->setText(QApplication::translate("server", "\346\234\215\345\212\241\345\231\250\347\253\257", Q_NULLPTR)); 97 | label_7->setText(QApplication::translate("server", "\345\234\250\347\272\277\347\224\250\346\210\267\346\225\260\351\207\217\357\274\232", Q_NULLPTR)); 98 | label_8->setText(QApplication::translate("server", "\347\246\273\347\272\277\347\224\250\346\210\267\346\225\260\351\207\217\357\274\232", Q_NULLPTR)); 99 | bt_save->setText(QApplication::translate("server", "\344\277\235\345\255\230\347\224\250\346\210\267\344\277\241\346\201\257", Q_NULLPTR)); 100 | } // retranslateUi 101 | 102 | }; 103 | 104 | namespace Ui { 105 | class server: public Ui_server {}; 106 | } // namespace Ui 107 | 108 | QT_END_NAMESPACE 109 | 110 | #endif // UI_SERVER_H 111 | -------------------------------------------------------------------------------- /Server/ui_serverwidget.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | ** Form generated from reading UI file 'serverwidget.ui' 3 | ** 4 | ** Created by: Qt User Interface Compiler version 5.8.0 5 | ** 6 | ** WARNING! All changes made in this file will be lost when recompiling UI file! 7 | ********************************************************************************/ 8 | 9 | #ifndef UI_SERVERWIDGET_H 10 | #define UI_SERVERWIDGET_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | QT_BEGIN_NAMESPACE 23 | 24 | class Ui_serverwidget 25 | { 26 | public: 27 | QLabel *label; 28 | QTextEdit *textEdit; 29 | QPushButton *buttonChooseFile; 30 | QPushButton *butttonSendFile; 31 | 32 | void setupUi(QWidget *serverwidget) 33 | { 34 | if (serverwidget->objectName().isEmpty()) 35 | serverwidget->setObjectName(QStringLiteral("serverwidget")); 36 | serverwidget->resize(657, 577); 37 | label = new QLabel(serverwidget); 38 | label->setObjectName(QStringLiteral("label")); 39 | label->setGeometry(QRect(240, 60, 141, 71)); 40 | label->setStyleSheet(QStringLiteral("font: 75 14pt \"Agency FB\";")); 41 | textEdit = new QTextEdit(serverwidget); 42 | textEdit->setObjectName(QStringLiteral("textEdit")); 43 | textEdit->setGeometry(QRect(120, 140, 391, 301)); 44 | buttonChooseFile = new QPushButton(serverwidget); 45 | buttonChooseFile->setObjectName(QStringLiteral("buttonChooseFile")); 46 | buttonChooseFile->setGeometry(QRect(120, 490, 93, 28)); 47 | butttonSendFile = new QPushButton(serverwidget); 48 | butttonSendFile->setObjectName(QStringLiteral("butttonSendFile")); 49 | butttonSendFile->setGeometry(QRect(420, 490, 93, 28)); 50 | 51 | retranslateUi(serverwidget); 52 | 53 | QMetaObject::connectSlotsByName(serverwidget); 54 | } // setupUi 55 | 56 | void retranslateUi(QWidget *serverwidget) 57 | { 58 | serverwidget->setWindowTitle(QApplication::translate("serverwidget", "serverwidget", Q_NULLPTR)); 59 | label->setText(QApplication::translate("serverwidget", "\346\234\215\345\212\241\345\231\250\347\253\257", Q_NULLPTR)); 60 | buttonChooseFile->setText(QApplication::translate("serverwidget", "\351\200\211\346\213\251\346\226\207\344\273\266", Q_NULLPTR)); 61 | butttonSendFile->setText(QApplication::translate("serverwidget", "\345\274\200\345\247\213\344\274\240\351\200\201", Q_NULLPTR)); 62 | } // retranslateUi 63 | 64 | }; 65 | 66 | namespace Ui { 67 | class serverwidget: public Ui_serverwidget {}; 68 | } // namespace Ui 69 | 70 | QT_END_NAMESPACE 71 | 72 | #endif // UI_SERVERWIDGET_H 73 | -------------------------------------------------------------------------------- /Server/user_information.cpp: -------------------------------------------------------------------------------- 1 | #include "user_information.h" 2 | 3 | user_imformation::user_imformation(QString myname, QString mypassword, QString myquestion, QString myanswer, int ison, QString myip, int myport) 4 | { 5 | this->username = myname; 6 | this->password = mypassword; 7 | this->answer = myanswer; 8 | this->question = myquestion; 9 | this->state = ison; 10 | this->ip = myip; 11 | this->port = myport; 12 | } 13 | 14 | bool user_imformation::setIpPort(QString myname, QString myip, int myport) 15 | { 16 | if(this->username == myname) 17 | { 18 | this->ip = myip; 19 | this->port = myport; 20 | return true; 21 | } 22 | else return false; 23 | } 24 | 25 | bool user_imformation::setstate(QString myname) 26 | { 27 | if(this->username == myname) 28 | { 29 | this->state = 1; 30 | return true; 31 | } 32 | else return false; 33 | } 34 | 35 | QString user_imformation::toString() 36 | { 37 | return QString("%1 %2 %3 %4 ").arg(username).arg(state).arg(ip).arg(port); 38 | } 39 | -------------------------------------------------------------------------------- /Server/user_information.h: -------------------------------------------------------------------------------- 1 | #ifndef USER_IMFORMATION_H 2 | #define USER_IMFORMATION_H 3 | #include 4 | 5 | class user_imformation 6 | { 7 | public: 8 | QString username; 9 | QString password; 10 | QString question; 11 | QString answer; 12 | int state;//1表示在线,0表示不在线 13 | QString ip; 14 | int port; 15 | user_imformation(QString myname, QString mypassword, QString myquestion, QString myanswer, int ison=0, QString myip="ip", int myport=0); 16 | bool setIpPort(QString myname, QString myip, int myport); 17 | bool setstate(QString myname); 18 | QString toString(); 19 | }; 20 | 21 | #endif // USER_IMFORMATION_H 22 | -------------------------------------------------------------------------------- /pic/client.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/pic/client.jpg -------------------------------------------------------------------------------- /pic/server.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bansheng/Socket_chat/790fda0844c615baaf474b709c1023a797f9e449/pic/server.jpg --------------------------------------------------------------------------------